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

0030169: Application Framework - Document format version management improvement

This commit is contained in:
szy
2018-10-09 17:30:10 +03:00
committed by apn
parent 90fd614536
commit b34d86cb28
58 changed files with 315 additions and 305 deletions

View File

@@ -45,7 +45,6 @@
#include <XmlMDataStd_VariableDriver.hxx>
#include <XmlMDF_ADriverTable.hxx>
static Standard_Integer myDocumentVersion = -1;
//=======================================================================
//function : AddDrivers
//purpose :
@@ -81,20 +80,3 @@ void XmlMDataStd::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
aDriverTable-> AddDriver (new XmlMDataStd_AsciiStringDriver (anMsgDrv));
aDriverTable-> AddDriver (new XmlMDataStd_IntPackedMapDriver (anMsgDrv));
}
//=======================================================================
//function : SetDocumentVersion
//purpose : Sets current document version
//=======================================================================
void XmlMDataStd::SetDocumentVersion(const Standard_Integer theVersion)
{
myDocumentVersion = theVersion;
}
//=======================================================================
//function : DocumentVersion
//purpose : Retrieved document version
//=======================================================================
Standard_Integer XmlMDataStd::DocumentVersion()
{
return myDocumentVersion;
}

View File

@@ -60,12 +60,6 @@ public:
//! Adds the attribute drivers to <aDriverTable>.
Standard_EXPORT static void AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable, const Handle(Message_Messenger)& anMsgDrv);
Standard_EXPORT static void SetDocumentVersion (const Standard_Integer DocVersion);
Standard_EXPORT static Standard_Integer DocumentVersion();
protected:

View File

@@ -55,7 +55,7 @@ Handle(TDF_Attribute) XmlMDataStd_ByteArrayDriver::NewEmpty() const
//=======================================================================
Standard_Boolean XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& ) const
XmlObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aFirstInd, aLastInd, aValue;
const XmlObjMgt_Element& anElement = theSource;
@@ -129,7 +129,7 @@ Standard_Boolean XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent&
Standard_Boolean aDelta(Standard_False);
if(XmlMDataStd::DocumentVersion() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{
@@ -144,8 +144,7 @@ Standard_Boolean XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent&
aDelta = aDeltaValue != 0;
}
#ifdef OCCT_DEBUG
else if(XmlMDataStd::DocumentVersion() == -1)
cout << "Current DocVersion field is not initialized. " <<endl;
cout << "Current Document Format Version = " << theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() <<endl;
#endif
aByteArray->SetDelta(aDelta);

View File

@@ -76,7 +76,7 @@ Handle(TDF_Attribute) XmlMDataStd_ExtStringArrayDriver::NewEmpty() const
Standard_Boolean XmlMDataStd_ExtStringArrayDriver::Paste
(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& ) const
XmlObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aFirstInd, aLastInd, ind;
TCollection_ExtendedString aValue;
@@ -195,7 +195,7 @@ Standard_Boolean XmlMDataStd_ExtStringArrayDriver::Paste
// Read delta-flag.
Standard_Boolean aDelta(Standard_False);
if(XmlMDataStd::DocumentVersion() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{
@@ -209,10 +209,7 @@ Standard_Boolean XmlMDataStd_ExtStringArrayDriver::Paste
else
aDelta = aDeltaValue != 0;
}
#ifdef OCCT_DEBUG
else if(XmlMDataStd::DocumentVersion() == -1)
cout << "Current DocVersion field is not initialized. " <<endl;
#endif
aExtStringArray->SetDelta(aDelta);
return Standard_True;
@@ -224,7 +221,7 @@ Standard_Boolean XmlMDataStd_ExtStringArrayDriver::Paste
//=======================================================================
void XmlMDataStd_ExtStringArrayDriver::Paste (const Handle(TDF_Attribute)& theSource,
XmlObjMgt_Persistent& theTarget,
XmlObjMgt_SRelocationTable& ) const
XmlObjMgt_SRelocationTable& theRelocTable) const
{
Handle(TDataStd_ExtStringArray) aExtStringArray =
Handle(TDataStd_ExtStringArray)::DownCast(theSource);
@@ -243,7 +240,7 @@ void XmlMDataStd_ExtStringArrayDriver::Paste (const Handle(TDF_Attribute)& theSo
// So, if the user wants to save the document under the 7th or earlier versions,
// don't apply this improvement.
Standard_Character c = '-';
if (XmlLDrivers::StorageVersion() > 7)
if (theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 7)
{
// Preferrable symbols for the separator: - _ . : ^ ~
// Don't use a space as a separator: XML low-level parser sometimes "eats" it.

View File

@@ -59,7 +59,7 @@ Handle(TDF_Attribute) XmlMDataStd_IntPackedMapDriver::NewEmpty () const
Standard_Boolean XmlMDataStd_IntPackedMapDriver::Paste
(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& ) const
XmlObjMgt_RRelocationTable& theRelocTable) const
{
Handle(TDataStd_IntPackedMap) aPackedMap =
Handle(TDataStd_IntPackedMap)::DownCast(theTarget);
@@ -106,7 +106,7 @@ Standard_Boolean XmlMDataStd_IntPackedMapDriver::Paste
if(Ok) {
Standard_Boolean aDelta(Standard_False);
if(XmlMDataStd::DocumentVersion() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{
@@ -120,10 +120,6 @@ Standard_Boolean XmlMDataStd_IntPackedMapDriver::Paste
else
aDelta = aDeltaValue != 0;
}
#ifdef OCCT_DEBUG
else if(XmlMDataStd::DocumentVersion() == -1)
cout << "Current DocVersion field is not initialized. " <<endl;
#endif
aPackedMap->SetDelta(aDelta);
return Standard_True;
}

View File

@@ -57,7 +57,7 @@ Handle(TDF_Attribute) XmlMDataStd_IntegerArrayDriver::NewEmpty() const
Standard_Boolean XmlMDataStd_IntegerArrayDriver::Paste
(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& ) const
XmlObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aFirstInd, aLastInd, aValue, ind;
const XmlObjMgt_Element& anElement = theSource;
@@ -129,7 +129,7 @@ Standard_Boolean XmlMDataStd_IntegerArrayDriver::Paste
}
Standard_Boolean aDelta(Standard_False);
if(XmlMDataStd::DocumentVersion() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{
@@ -143,10 +143,7 @@ Standard_Boolean XmlMDataStd_IntegerArrayDriver::Paste
else
aDelta = aDeltaValue != 0;
}
#ifdef OCCT_DEBUG
else if(XmlMDataStd::DocumentVersion() == -1)
cout << "Current DocVersion field is not initialized. " <<endl;
#endif
anIntArray->SetDelta(aDelta);
return Standard_True;

View File

@@ -60,7 +60,7 @@ Handle(TDF_Attribute) XmlMDataStd_RealArrayDriver::NewEmpty() const
Standard_Boolean XmlMDataStd_RealArrayDriver::Paste
(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& ) const
XmlObjMgt_RRelocationTable& theRelocTable) const
{
Handle(TDataStd_RealArray) aRealArray = Handle(TDataStd_RealArray)::DownCast(theTarget);
@@ -136,7 +136,7 @@ Standard_Boolean XmlMDataStd_RealArrayDriver::Paste
}
Standard_Boolean aDelta(Standard_False);
if(XmlMDataStd::DocumentVersion() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{
@@ -150,10 +150,6 @@ Standard_Boolean XmlMDataStd_RealArrayDriver::Paste
else
aDelta = aDeltaValue != 0;
}
#ifdef OCCT_DEBUG
else if(XmlMDataStd::DocumentVersion() == -1)
cout << "Current DocVersion field is not initialized. " <<endl;
#endif
aRealArray->SetDelta(aDelta);
return Standard_True;

View File

@@ -118,7 +118,7 @@ void XmlMDataStd_TreeNodeDriver::Paste
// tree id
// A not default ID is skipped for storage version 8 and newer.
if (aS->ID() != TDataStd_TreeNode::GetDefaultTreeID() ||
XmlLDrivers::StorageVersion() < 8)
theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() < 8)
{
Standard_Character aGuidStr [40];
Standard_PCharacter pGuidStr=aGuidStr;