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

0028691: Storage of Ocaf documents in XML file format in old document version

This commit is contained in:
vro
2017-05-03 15:22:21 +03:00
committed by bugmaster
parent a1073ae267
commit c2f5b8211b
9 changed files with 188 additions and 33 deletions

View File

@@ -24,6 +24,7 @@
#include <XmlObjMgt.hxx>
#include <XmlObjMgt_Document.hxx>
#include <XmlObjMgt_Persistent.hxx>
#include <XmlLDrivers.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_ExtStringArrayDriver,XmlMDF_ADriver)
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
@@ -227,39 +228,44 @@ void XmlMDataStd_ExtStringArrayDriver::Paste (const Handle(TDF_Attribute)& theSo
// Find a separator.
Standard_Boolean found(Standard_True);
// Preferrable symbols for the separator: - _ . : ^ ~
// Don't use a space as a separator: XML low-level parser sometimes "eats" it.
// Optimization of storage of string array elements.
// It is applied since the storage version 8 and newer.
Standard_Character c = '-';
static Standard_Character aPreferable[] = "-_.:^~";
for (i = 0; found && aPreferable[i]; i++)
if (XmlLDrivers::StorageVersion() > 7)
{
c = aPreferable[i];
found = Contains(aExtStringArray, TCollection_ExtendedString(c));
}
// If all prefferable symbols exist in the array,
// try to use any other simple symbols.
if (found)
{
c = '!';
while (found && c < '~')
// Preferrable symbols for the separator: - _ . : ^ ~
// Don't use a space as a separator: XML low-level parser sometimes "eats" it.
static Standard_Character aPreferable[] = "-_.:^~";
for (i = 0; found && aPreferable[i]; i++)
{
found = Standard_False;
#ifdef _DEBUG
TCollection_AsciiString cseparator(c); // deb
#endif
TCollection_ExtendedString separator(c);
found = Contains(aExtStringArray, separator);
if (found)
c = aPreferable[i];
found = Contains(aExtStringArray, TCollection_ExtendedString(c));
}
// If all prefferable symbols exist in the array,
// try to use any other simple symbols.
if (found)
{
c = '!';
while (found && c < '~')
{
c++;
// Skip forbidden symbols for XML.
while (c < '~' && (c == '&' || c == '<'))
found = Standard_False;
#ifdef _DEBUG
TCollection_AsciiString cseparator(c); // deb
#endif
TCollection_ExtendedString separator(c);
found = Contains(aExtStringArray, separator);
if (found)
{
c++;
// Skip forbidden symbols for XML.
while (c < '~' && (c == '&' || c == '<'))
{
c++;
}
}
}
}
}
}// check doc version
if (found)
{

View File

@@ -22,6 +22,7 @@
#include <XmlMDataStd_TreeNodeDriver.hxx>
#include <XmlObjMgt.hxx>
#include <XmlObjMgt_Persistent.hxx>
#include <XmlLDrivers.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_TreeNodeDriver,XmlMDF_ADriver)
IMPLEMENT_DOMSTRING (TreeIdString, "treeid")
@@ -115,7 +116,9 @@ void XmlMDataStd_TreeNodeDriver::Paste
Handle(TDataStd_TreeNode) aS = Handle(TDataStd_TreeNode)::DownCast(theSource);
// tree id
if (aS->ID() != TDataStd_TreeNode::GetDefaultTreeID())
// A not default ID is skipped for storage version 8 and newer.
if (aS->ID() != TDataStd_TreeNode::GetDefaultTreeID() ||
XmlLDrivers::StorageVersion() < 8)
{
Standard_Character aGuidStr [40];
Standard_PCharacter pGuidStr=aGuidStr;