1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-07-15 12:35:51 +03:00

0029443: It is not possible to store an ExtStringArray Ocaf attribute to any previous version in XML file format

This commit is contained in:
vro 2018-01-23 14:06:18 +03:00 committed by apn
parent 00dfcc765a
commit 93445088d8

View File

@ -24,6 +24,7 @@
#include <XmlObjMgt.hxx> #include <XmlObjMgt.hxx>
#include <XmlObjMgt_Document.hxx> #include <XmlObjMgt_Document.hxx>
#include <XmlObjMgt_Persistent.hxx> #include <XmlObjMgt_Persistent.hxx>
#include <XmlLDrivers.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_ExtStringArrayDriver,XmlMDF_ADriver) IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_ExtStringArrayDriver,XmlMDF_ADriver)
IMPLEMENT_DOMSTRING (FirstIndexString, "first") IMPLEMENT_DOMSTRING (FirstIndexString, "first")
@ -238,39 +239,45 @@ void XmlMDataStd_ExtStringArrayDriver::Paste (const Handle(TDF_Attribute)& theSo
// Find a separator. // Find a separator.
Standard_Boolean found(Standard_True); Standard_Boolean found(Standard_True);
// Preferrable symbols for the separator: - _ . : ^ ~ // This improvement was defined in the version 8.
// Don't use a space as a separator: XML low-level parser sometimes "eats" it. // So, if the user wants to save the document under the 7th or earlier versions,
// don't apply this improvement.
Standard_Character c = '-'; Standard_Character c = '-';
static Standard_Character aPreferable[] = "-_.:^~"; if (XmlLDrivers::StorageVersion() > 7)
for (i = 0; found && aPreferable[i]; i++)
{ {
c = aPreferable[i]; // Preferrable symbols for the separator: - _ . : ^ ~
found = Contains(aExtStringArray, TCollection_ExtendedString(c)); // Don't use a space as a separator: XML low-level parser sometimes "eats" it.
} static Standard_Character aPreferable[] = "-_.:^~";
// If all prefferable symbols exist in the array, for (i = 0; found && aPreferable[i]; i++)
// try to use any other simple symbols.
if (found)
{
c = '!';
while (found && c < '~')
{ {
found = Standard_False; c = aPreferable[i];
#ifdef _DEBUG found = Contains(aExtStringArray, TCollection_ExtendedString(c));
TCollection_AsciiString cseparator(c); // deb }
#endif // If all prefferable symbols exist in the array,
TCollection_ExtendedString separator(c); // try to use any other simple symbols.
found = Contains(aExtStringArray, separator); if (found)
if (found) {
c = '!';
while (found && c < '~')
{ {
c++; found = Standard_False;
// Skip forbidden symbols for XML. #ifdef _DEBUG
while (c < '~' && (c == '&' || c == '<')) TCollection_AsciiString cseparator(c); // deb
#endif
TCollection_ExtendedString separator(c);
found = Contains(aExtStringArray, separator);
if (found)
{ {
c++; c++;
// Skip forbidden symbols for XML.
while (c < '~' && (c == '&' || c == '<'))
{
c++;
}
} }
} }
} }
} }// check doc version
if (found) if (found)
{ {