MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0025683Community[OCCT] OCCT:Application Frameworkpublic2015-01-06 05:522017-07-27 09:43
ReporterVico Liang 
Assigned Tovro 
PrioritylowSeverityminor 
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version 
Target Version[OCCT] 7.4.0*Fixed in Version 
Summary0025683: No entrance to construct a LDOMBasicString from TCollection_ExtendedString.
DescriptionTo support unicode in XML driver, TCollection_ExtendedString is a way provided by OCCT. There is a class XmlObjMgt to manage the TCollection_ExtendedString storage for XmlObjMgt_Element text value. But it can't store TCollection_ExtendedString in attribute.

  //! Add attribute <theElement extstring="theString" ...>
  Standard_EXPORT static Standard_Boolean SetExtendedString (XmlObjMgt_Element& theElement, const TCollection_ExtendedString& theString) ;
  
  //! Get attribute <theElement extstring="theString" ...>
  Standard_EXPORT static Standard_Boolean GetExtendedString (const XmlObjMgt_Element& theElement, TCollection_ExtendedString& theString) ;

The best way to solve this issue is to provide a method to construct a LDOMBasicString from TCollection_ExtendedString. This method can be in class XmlObjMgt.
TagsNo tags attached.
Test case number
Attached Files

- Relationships

-  Notes
(0035918)
Vico Liang (developer)
2015-01-06 06:05

Two methods like these might work:
XmlObjMgt_DOMString XmlObjMgt::ToDOMString(const TCollection_ExtendedString& theString)
{
    TCollection_AsciiString anAString;
    if (theString.IsAscii())
    {
        anAString = TCollection_AsciiString(theString, '?');
        return XmlObjMgt_DOMString(anAString.ToCString());
    }
    else
    {
        const Standard_Integer aLen = theString.Length();
        char * buf0 = new char[4 * (aLen + 1) + 3];
        Sprintf(&buf0[0], "##%04x", 0xfeff); // set UNICODE header
        char * buf = &buf0[6];
        SprintfExtStr(buf, theString);
        XmlObjMgt_DOMString aDOMString(buf0);
        delete[] buf0;
        return aDOMString;
    }
}

XmlObjMgt_DOMString XmlObjMgt::ToDOMString(const TCollection_AsciiString& theString)
{
    return XmlObjMgt_DOMString(theString.ToCString());
}
(0050515)
vro (developer)
2016-02-09 11:51

Hello Vico. I'm not sure I understand well your proposal... sorry. The methods you declare above exist in XmlObjMgt.cxx the lines 108..152. Do you mean renaming of the methods? What is the added-value?
(0050632)
Vico Liang (developer)
2016-02-11 14:18

Dear vro,

Sorry for that my description is not clear. My proposal doesn't mean method renaming but provide a mean to create XmlObjMgt_DOMString from TCollection_ExtendedString. The background is that i want to save TCollection_ExtendedString data in xml file, and the data might be store in XML attribute, text, and comment nodes. But all these nodes just accept XmlObjMgt_DOMString as input rather than TCollection_ExtendedString.

To construct XmlObjMgt_DOMString from TCollection_ExtendedString, there are two means:
The first is to add a constructor XmlObjMgt_DOMString(const TCollection_ExtendedString& theString);

The second is to add a utility method : XmlObjMgt_DOMString XmlObjMgt::ToDOMString(const TCollection_ExtendedString& theString);

Is it clear?
(0050633)
vro (developer)
2016-02-11 14:27

Hello Vico, many thanks, now it is clearer. Would it be possible to use a TDataStd_Comment or TDataStd_Name attributes to store a TCollection_ExtendedString object in XML document? Or do you consider an opportunity to store a UNICODE string without OCAF?
In general, I don't see any obstacles to implement these additional methods (one of them). Would you do it?
(0050641)
Vico Liang (developer)
2016-02-11 15:00

Dear vro,

Actually i'm using OCAF, and i find a bug in XmlTObjDrivers_ReferenceDriver which will cause issue if the model name is unicode. Please see my fix in last two lines, i added my own utility method XmlObjMgt::ToDOMString to correct the UNICODE issue, the implementation is like my previous post. I do hope that OCCT can have an entrance to construct XmlObjMgt_DOMString from TCollection_ExtendedString directly. I may want to extend OCAF built-in attributes to support application domain UNICODE.

void XmlTObjDrivers_ReferenceDriver::Paste
                         (const Handle(TDF_Attribute)& Source,
                          XmlObjMgt_Persistent& Target,
                          XmlObjMgt_SRelocationTable& /*RelocTable*/) const
{
  Handle(TObj_TReference) aSource =
    Handle(TObj_TReference)::DownCast (Source);

  Handle(TObj_Object) aLObject = aSource->Get();
  if (aLObject.IsNull())
    return;

  // referred entry
  TCollection_AsciiString entry;
  TDF_Label aLabel = aLObject->GetLabel();
  TDF_Tool::Entry( aLabel, entry );
  Target.Element().setAttribute(::ReferredEntry(), entry.ToCString());

  // master entry
  entry.Clear();
  TDF_Label aMasterLabel = aSource->GetMasterLabel();
  TDF_Tool::Entry( aMasterLabel, entry );
  Target.Element().setAttribute(::MasterEntry(), entry.ToCString());

  // is reference to other document
  if (aLabel.Root() == aMasterLabel.Root()) return;

  Handle(TObj_Model) aModel =
    Handle(TObj_Model)::DownCast( aLObject->GetModel() );
  XmlObjMgt_DOMString aModelName = XmlObjMgt::ToDOMString(aModel->GetModelName()->String());
  Target.Element().setAttribute(::ReferredModelEntry(), aModelName);
}

- Issue History
Date Modified Username Field Change
2015-01-06 05:52 Vico Liang New Issue
2015-01-06 05:52 Vico Liang Assigned To => szy
2015-01-06 06:05 Vico Liang Note Added: 0035918
2015-03-05 11:23 szy Priority normal => low
2015-03-05 11:23 szy Target Version 6.9.0 => 6.7.1
2015-03-05 11:42 szy Target Version 6.7.1 => 7.1.0
2015-12-30 16:04 szy Assigned To szy => vro
2015-12-30 16:04 szy Status new => assigned
2016-02-09 11:47 vro Assigned To vro => Vico Liang
2016-02-09 11:51 vro Note Added: 0050515
2016-02-11 14:18 Vico Liang Note Added: 0050632
2016-02-11 14:19 Vico Liang Assigned To Vico Liang => vro
2016-02-11 14:27 vro Note Added: 0050633
2016-02-11 14:27 vro Assigned To vro => Vico Liang
2016-02-11 15:00 Vico Liang Note Added: 0050641
2016-02-11 15:02 Vico Liang Assigned To Vico Liang => vro
2016-11-03 17:13 abv Target Version 7.1.0 => 7.2.0
2017-07-27 09:43 abv Target Version 7.2.0 => 7.4.0*


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker