1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0029822: Make TDocStd_Document extensible

Two virtual methods NewDocument() and InitDocument() are moved from TDocStd_Application to its parent class CDF_Application. In TDocStd_Application these methods remain redefined. These little changes allow creation of a new document only in one virtual method NewDocument(). The methods CreateDocument() in all retrieval drivers are deleted.

Modified files:
- CDF_Application.hxx and cxx: two virtual methods NewDocument() and InitDocument() are moved from TDocStd_Application. The input parameter TDocStd_Document is changed to parent class CDM_Document.
- TDocStd_Application.hxx and cxx: redefines new virtual methods NewDocument() and InitDocument() of the parent class CDF_Application.
- BinLDrivers_DocumentRetrievalDriver.hxx and cxx, StdLDrivers_DocumentRetrievalDriver.hxx and cxx, XmlLDrivers_DocumentRetrievalDriver.hxx and cxx, PCDM_Reader.hxx: a virtual method CreateDocument() is deleted.
- TObj_Application.cxx, XCAFApp_Application.hxx and cxx: down-casting to a descendant class TDocStd_Document is applied.

Documentation:
- upgrade.md is modified.
This commit is contained in:
vro
2020-12-17 14:34:47 +03:00
committed by bugmaster
parent 04114fd201
commit 5fd0b80027
14 changed files with 63 additions and 50 deletions

View File

@@ -52,6 +52,24 @@ Handle(CDF_Application) CDF_Application::Load(const Standard_GUID& aGUID) {
return Handle(CDF_Application)::DownCast(Plugin::Load(aGUID));
}
//=======================================================================
//function : NewDocument
//purpose :
//=======================================================================
void CDF_Application::NewDocument(const TCollection_ExtendedString& /*theFormat*/, Handle(CDM_Document)& /*theDoc*/)
{
}
//=======================================================================
//function : InitDocument
//purpose : do nothing
//=======================================================================
void CDF_Application::InitDocument(const Handle(CDM_Document)& /*theDoc*/) const
{
}
//=======================================================================
//function : Open
//purpose :
@@ -264,7 +282,7 @@ Handle(CDM_Document) CDF_Application::Retrieve (const Handle(CDM_MetaData)& aMet
theDocument->RemoveAllReferences();
}
else
theDocument=theReader->CreateDocument();
NewDocument(aFormat, theDocument);
SetReferenceCounter(theDocument,PCDM_RetrievalDriver::ReferenceCounter(aMetaData->FileName(), MessageDriver()));
@@ -362,7 +380,7 @@ Handle(CDM_Document) CDF_Application::Read (Standard_IStream& theIStream,
Handle(PCDM_Reader) aReader = ReaderFromFormat (aFormat);
// 2. create document with the detected reader
aDoc = aReader->CreateDocument();
NewDocument(aFormat, aDoc);
// 3. read the content of theIStream to aDoc
try

View File

@@ -58,7 +58,19 @@ public:
//! opened by an application since the application resources are
//! needed to store it.
Standard_EXPORT static Handle(CDF_Application) Load (const Standard_GUID& aGUID);
//! Constructs an new empty document.
//! This document will have the specified format.
//! If InitDocument() is redefined for a specific
//! application, the new document is handled by the
//! applicative session.
Standard_EXPORT virtual void NewDocument(const TCollection_ExtendedString& theFormat, Handle(CDM_Document)& theDoc);
//! Initialize a document for the applicative session.
//! This virtual function is called by NewDocument
//! and should be redefined for each specific application.
Standard_EXPORT virtual void InitDocument(const Handle(CDM_Document)& theDoc) const;
//! puts the document in the current session directory
//! and calls the virtual method Activate on it.
Standard_EXPORT void Open (const Handle(CDM_Document)& aDocument);