From: vro Date: Tue, 20 Jul 2021 02:02:43 +0000 (+0300) Subject: 0032125: Application Framework, OCAF - need to have adequate message if document... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=fbeed435b4536e4c6ec287cc267b40328901a954;p=occt-copy.git 0032125: Application Framework, OCAF - need to have adequate message if document cannot be saved due to unrecognized format A list of storage statuses (PCDM_StoreStatus) is extended for PCDM_SS_UnrecognizedFormat. It is set if - extension of a document file name is not defined (the extension doesn't correspond to any declared file formats) or - a storage driver is not found for the document storage format. Modifications: - CDF_StoreList.cxx: a unique exception is raised in case of the driver is not found by the document format. - PCDM_StoreStatus.hxx: a new enumeration value is added - PCDM_SS_UnrecognizedFormat. - DDocStd_ApplicationCommands.cxx: processing of a new enumeration value PCDM_SS_UnrecognizedFormat by SaveAs draw-command. - XDEDRAW.cxx: processing of a new enumeration value PCDM_SS_UnrecognizedFormat by saveDoc draw-command. --- diff --git a/src/CDF/CDF_StoreList.cxx b/src/CDF/CDF_StoreList.cxx index 5ef2668fb6..6fa570fa67 100644 --- a/src/CDF/CDF_StoreList.cxx +++ b/src/CDF/CDF_StoreList.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include IMPLEMENT_STANDARD_RTTIEXT(CDF_StoreList,Standard_Transient) @@ -99,7 +100,7 @@ PCDM_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData, { Standard_SStream aMsg; aMsg <<"No storage driver does exist for this format: " << theDocument->StorageFormat() << (char)0; - throw Standard_Failure(aMsg.str().c_str()); + throw Standard_ProgramError(aMsg.str().c_str()); } // Reset the store-status. @@ -130,6 +131,14 @@ PCDM_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData, CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("metadatadriver failed; reason:")); status = PCDM_SS_DriverFailure; } + catch (Standard_ProgramError const& anException) { + CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("driver not found; reason:")); + status = PCDM_SS_UnrecognizedFormat; + } + catch (Standard_NoSuchObject const& anException) { + CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("driver not found; reason:")); + status = PCDM_SS_UnrecognizedFormat; + } catch (Standard_Failure const& anException) { CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("driver failed; reason:")); status = PCDM_SS_Failure; diff --git a/src/DDocStd/DDocStd_ApplicationCommands.cxx b/src/DDocStd/DDocStd_ApplicationCommands.cxx index c923df9cf5..37aa27b8b4 100644 --- a/src/DDocStd/DDocStd_ApplicationCommands.cxx +++ b/src/DDocStd/DDocStd_ApplicationCommands.cxx @@ -336,6 +336,10 @@ static Standard_Integer DDocStd_SaveAs (Draw_Interpretor& di, di << "Error saving document: User break \n" ; break; } + case PCDM_SS_UnrecognizedFormat: { + di << "Error saving document: unrecognized document storage format " << D->StorageFormat() << "\n" ; + break; + } default: break; } diff --git a/src/PCDM/PCDM_StoreStatus.hxx b/src/PCDM/PCDM_StoreStatus.hxx index cd0e56354c..4d089129b1 100644 --- a/src/PCDM/PCDM_StoreStatus.hxx +++ b/src/PCDM/PCDM_StoreStatus.hxx @@ -27,7 +27,8 @@ PCDM_SS_Failure, PCDM_SS_Doc_IsNull, PCDM_SS_No_Obj, PCDM_SS_Info_Section_Error, -PCDM_SS_UserBreak +PCDM_SS_UserBreak, +PCDM_SS_UnrecognizedFormat }; #endif // _PCDM_StoreStatus_HeaderFile diff --git a/src/XDEDRAW/XDEDRAW.cxx b/src/XDEDRAW/XDEDRAW.cxx index bb9ecf0a79..184db58f78 100644 --- a/src/XDEDRAW/XDEDRAW.cxx +++ b/src/XDEDRAW/XDEDRAW.cxx @@ -192,6 +192,9 @@ static Standard_Integer saveDoc (Draw_Interpretor& di, Standard_Integer argc, co case PCDM_SS_UserBreak: di << "Storage error: user break\n"; break; + case PCDM_SS_UnrecognizedFormat: + di << "Storage error: unrecognized document storage format " << D->StorageFormat() << "\n"; + break; } return 0;