- boost::shared_ptr<Model_Document> aDoc =
- boost::dynamic_pointer_cast<Model_Document>(owner()->document());
- myRef->Set(aData->label().Father()); // references to the feature label
+ if (anObjLab.IsNull()) {
+ myRef->Set(myRef->Label());
+ } else {
+ myRef->Set(anObjLab); // references to the object label
+ }
+ // remove external link attributes (if any)
+ myRef->Label().ForgetAttribute(TDataStd_Comment::GetID());
+ myRef->Label().ForgetAttribute(TDataStd_AsciiString::GetID());
+ } else { // different document: store the document name (comment) and entry (string): external
+ // if these attributes exist, the link is external: keep reference to access the label
+ std::ostringstream anIdString; // string with document Id
+ anIdString<<theObject->document()->id();
+ TDataStd_Comment::Set(myRef->Label(), anIdString.str().c_str());
+ TCollection_AsciiString anEntry;
+ TDF_Tool::Entry(anObjLab, anEntry);
+ TDataStd_AsciiString::Set(myRef->Label(), anEntry);
+ }
+ // do it before the transaction finish to make just created/removed objects know dependencies
+ // and reference from composite feature is removed automatically
+ ADD_BACK_REF(theObject);