mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +03:00
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. Modified: CDF_StoreList.cxx: the mechanism of raising and catching exceptions is replaced by direct setting the status and error message for each particular error. PCDM_StoreStatus.hxx: a new enumeration value is added - PCDM_SS_UnrecognizedFormat. Also, a short explanation is added to each enumeration value. DDocStd_ApplicationCommands.cxx: processing of a new enumeration value by the draw-command. XDEDRAW.cxx: processed a new enumeration value PCDM_SS_UnrecognizedFormat by saveDoc draw-command. Deleted: CDF_MetaDataDriverError.hxx: It is not used anywhere and it seems it will not be used by someone.
This commit is contained in:
@@ -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 <Standard_Type.hxx>
|
||||
#include <Standard_DefineException.hxx>
|
||||
#include <Standard_SStream.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
|
||||
//! 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
|
@@ -17,7 +17,6 @@
|
||||
|
||||
#include <CDF_Application.hxx>
|
||||
#include <CDF_MetaDataDriver.hxx>
|
||||
#include <CDF_MetaDataDriverError.hxx>
|
||||
#include <CDF_StoreList.hxx>
|
||||
#include <CDM_Document.hxx>
|
||||
#include <CDM_MetaData.hxx>
|
||||
@@ -25,8 +24,6 @@
|
||||
#include <PCDM.hxx>
|
||||
#include <PCDM_Document.hxx>
|
||||
#include <PCDM_StorageDriver.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user