diff --git a/src/CDF/CDF_MetaDataDriverError.hxx b/src/CDF/CDF_MetaDataDriverError.hxx deleted file mode 100644 index 4b9e173d23..0000000000 --- a/src/CDF/CDF_MetaDataDriverError.hxx +++ /dev/null @@ -1,41 +0,0 @@ -// Created on: 1997-08-07 -// Created by: Jean-Louis Frenkel -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _CDF_MetaDataDriverError_HeaderFile -#define _CDF_MetaDataDriverError_HeaderFile - -#include -#include -#include -#include - -//! This exception is used in the deferred methods. -//! Programmer implementing such methods may use this -//! exception or any exception inheriting MetaDataDriverError. - -class CDF_MetaDataDriverError; -DEFINE_STANDARD_HANDLE(CDF_MetaDataDriverError, Standard_Failure) - -#if !defined No_Exception && !defined No_CDF_MetaDataDriverError - #define CDF_MetaDataDriverError_Raise_if(CONDITION, MESSAGE) \ - if (CONDITION) throw CDF_MetaDataDriverError(MESSAGE); -#else - #define CDF_MetaDataDriverError_Raise_if(CONDITION, MESSAGE) -#endif - -DEFINE_STANDARD_EXCEPTION(CDF_MetaDataDriverError, Standard_Failure) - -#endif // _CDF_MetaDataDriverError_HeaderFile diff --git a/src/CDF/CDF_StoreList.cxx b/src/CDF/CDF_StoreList.cxx index 5ef2668fb6..e8b44c3a86 100644 --- a/src/CDF/CDF_StoreList.cxx +++ b/src/CDF/CDF_StoreList.cxx @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -25,8 +24,6 @@ #include #include #include -#include -#include #include IMPLEMENT_STANDARD_RTTIEXT(CDF_StoreList,Standard_Transient) @@ -77,62 +74,65 @@ PCDM_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData, TCollection_ExtendedString& aStatusAssociatedText, const Message_ProgressRange& theRange) { - Handle(CDF_MetaDataDriver) theMetaDataDriver = Handle(CDF_Application)::DownCast((myMainDocument->Application()))->MetaDataDriver(); - PCDM_StoreStatus status = PCDM_SS_OK; + Handle(CDF_MetaDataDriver) theMetaDataDriver = Handle(CDF_Application)::DownCast ((myMainDocument->Application()))->MetaDataDriver(); + for (; !myStack.IsEmpty(); myStack.RemoveFirst()) { - try { - OCC_CATCH_SIGNALS - for (; !myStack.IsEmpty(); myStack.RemoveFirst()) { - - Handle(CDM_Document) theDocument = myStack.First(); - if( theDocument == myMainDocument || theDocument->IsModified()) { - - Handle(CDF_Application) anApp = Handle(CDF_Application)::DownCast (theDocument->Application()); - if (anApp.IsNull()) - { - throw Standard_Failure("Document has no application, cannot save!"); - } - Handle(PCDM_StorageDriver) aDocumentStorageDriver = - anApp->WriterFromFormat(theDocument->StorageFormat()); + Handle(CDM_Document) theDocument = myStack.First(); + if (theDocument == myMainDocument || theDocument->IsModified()) + { + try + { + OCC_CATCH_SIGNALS + Handle(CDF_Application) anApp = Handle(CDF_Application)::DownCast (theDocument->Application()); + if (anApp.IsNull()) + { + aStatusAssociatedText = "driver failed; reason: "; + aStatusAssociatedText += "document has no application, cannot save!"; + status = PCDM_SS_Failure; + } + else + { + Handle(PCDM_StorageDriver) aDocumentStorageDriver = anApp->WriterFromFormat(theDocument->StorageFormat()); if (aDocumentStorageDriver.IsNull()) { - Standard_SStream aMsg; - aMsg <<"No storage driver does exist for this format: " << theDocument->StorageFormat() << (char)0; - throw Standard_Failure(aMsg.str().c_str()); + aStatusAssociatedText = "driver not found; reason: no storage driver does exist for this format: "; + aStatusAssociatedText += theDocument->StorageFormat(); + status = PCDM_SS_UnrecognizedFormat; } + else + { + // Reset the store-status. + // It has sense in multi-threaded access to the storage driver - this way we reset the status for each call. + aDocumentStorageDriver->SetStoreStatus(PCDM_SS_OK); - // Reset the store-status. - // It has sense in multi-threaded access to the storage driver - this way we reset the status for each call. - aDocumentStorageDriver->SetStoreStatus(PCDM_SS_OK); + if (!theMetaDataDriver->FindFolder(theDocument->RequestedFolder())) + { + aStatusAssociatedText = "driver not found; reason: "; + aStatusAssociatedText += "could not find the active dbunit "; + aStatusAssociatedText += theDocument->RequestedFolder(); + status = PCDM_SS_UnrecognizedFormat; + } + else + { + TCollection_ExtendedString theName = theMetaDataDriver->BuildFileName (theDocument); + aDocumentStorageDriver->Write (theDocument, theName, theRange); + status = aDocumentStorageDriver->GetStoreStatus(); + aMetaData = theMetaDataDriver->CreateMetaData (theDocument, theName); + theDocument->SetMetaData (aMetaData); - if(!theMetaDataDriver->FindFolder(theDocument->RequestedFolder())) { - Standard_SStream aMsg; aMsg << "could not find the active dbunit"; - aMsg << TCollection_ExtendedString(theDocument->RequestedFolder())<< (char)0; - throw Standard_NoSuchObject(aMsg.str().c_str()); - } - TCollection_ExtendedString theName=theMetaDataDriver->BuildFileName(theDocument); - - aDocumentStorageDriver->Write(theDocument, theName, theRange); - status = aDocumentStorageDriver->GetStoreStatus(); - aMetaData = theMetaDataDriver->CreateMetaData(theDocument,theName); - theDocument->SetMetaData(aMetaData); - - CDM_ReferenceIterator it(theDocument); - for(; it.More();it.Next()) { - theMetaDataDriver->CreateReference(aMetaData,it.Document()->MetaData(),it.ReferenceIdentifier(),it.DocumentVersion()); + CDM_ReferenceIterator it (theDocument); + for (; it.More(); it.Next()) + theMetaDataDriver->CreateReference (aMetaData, it.Document()->MetaData(), it.ReferenceIdentifier(), it.DocumentVersion()); + } } } } - } - - catch (CDF_MetaDataDriverError const& anException) { - CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("metadatadriver failed; reason:")); - status = PCDM_SS_DriverFailure; - } - catch (Standard_Failure const& anException) { - CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("driver failed; reason:")); - status = PCDM_SS_Failure; + catch (Standard_Failure const& anException) + { + CAUGHT (anException, aStatusAssociatedText, TCollection_ExtendedString ("driver failed; reason: ")); + status = PCDM_SS_DriverFailure; + } } } diff --git a/src/CDF/FILES b/src/CDF/FILES index 1bdfb4dd53..fdf055df2c 100755 --- a/src/CDF/FILES +++ b/src/CDF/FILES @@ -8,7 +8,6 @@ CDF_FWOSDriver.cxx CDF_FWOSDriver.hxx CDF_MetaDataDriver.cxx CDF_MetaDataDriver.hxx -CDF_MetaDataDriverError.hxx CDF_MetaDataDriverFactory.cxx CDF_MetaDataDriverFactory.hxx CDF_Store.cxx diff --git a/src/PCDM/PCDM_StoreStatus.hxx b/src/PCDM/PCDM_StoreStatus.hxx index cd0e56354c..ed6c50abed 100644 --- a/src/PCDM/PCDM_StoreStatus.hxx +++ b/src/PCDM/PCDM_StoreStatus.hxx @@ -17,17 +17,20 @@ #ifndef _PCDM_StoreStatus_HeaderFile #define _PCDM_StoreStatus_HeaderFile - +//! Status of storage of a document on disk. +//! If it is PCDM_SS_OK, the document is successfully saved on disk. +//! Else - there is an error. enum PCDM_StoreStatus { -PCDM_SS_OK, -PCDM_SS_DriverFailure, -PCDM_SS_WriteFailure, -PCDM_SS_Failure, -PCDM_SS_Doc_IsNull, -PCDM_SS_No_Obj, -PCDM_SS_Info_Section_Error, -PCDM_SS_UserBreak +PCDM_SS_OK, //!< Document is saved successfully +PCDM_SS_DriverFailure, //!< Storage driver is not found +PCDM_SS_WriteFailure, //!< Attempt to write a file on disk failed +PCDM_SS_Failure, //!< A general error occurred (unexpected) +PCDM_SS_Doc_IsNull, //!< Attempt to save a null document +PCDM_SS_No_Obj, //!< Document has no objects to be saved +PCDM_SS_Info_Section_Error, //!< Error occured on writing of an information-section +PCDM_SS_UserBreak, //!< User interrupted the process of storage of the document on disk +PCDM_SS_UnrecognizedFormat //!< No storage driver exist for this document format }; #endif // _PCDM_StoreStatus_HeaderFile diff --git a/src/TDocStd/TDocStd_Application.cxx b/src/TDocStd/TDocStd_Application.cxx index 7c1d347f21..d172b0228f 100644 --- a/src/TDocStd/TDocStd_Application.cxx +++ b/src/TDocStd/TDocStd_Application.cxx @@ -383,8 +383,10 @@ PCDM_StoreStatus TDocStd_Application::SaveAs (const Handle(TDocStd_Document)& th MessageDriver()->Send(aString.ToExtString(), Message_Fail); } } - if(storer.StoreStatus() == PCDM_SS_OK) + if (storer.StoreStatus() == PCDM_SS_OK) theDoc->SetSaved(); + else if (!MessageDriver().IsNull()) + MessageDriver()->Send (storer.AssociatedStatusText(), Message_Fail); #ifdef OCCT_DEBUG std::cout<<"TDocStd_Application::SaveAs(): The status = "<StorageFormat() << "\n"; + break; } return 0;