+ std::ostringstream anIdString; // string with document Id
+ anIdString<<theObject->document()->id();
+ std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(theObject->data());
+ TCollection_AsciiString anEntry;
+ TDF_Tool::Entry(aData->label().Father(), anEntry);
+ bool aFound = false;
+ TDataStd_ListIteratorOfListOfExtendedString anExtIter(anOldExts);
+ for (TDF_ListIteratorOfLabelList aLIter(anOldList); aLIter.More(); aLIter.Next()) {
+ if (aLIter.Value() == myRef->Label()) {
+ if (anExtIter.Value() == anIdString.str().c_str()) {
+ TDataStd_ListIteratorOfListOfExtendedString anExtIter2 = anExtIter;
+ anExtIter2.Next();
+ if (anExtIter2.Value() == anEntry) { // fully matches, so, remove(don't copy)
+ aFound = true;
+ continue;
+ }
+ }
+ myExtDocRef->Append(anExtIter.Value());
+ anExtIter.Next();
+ myExtDocRef->Append(anExtIter.Value());
+ anExtIter.Next();
+ }
+ myRef->Append(aLIter.Value());
+ }
+ if (aFound) {
+ REMOVE_BACK_REF(theObject);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+ // LCOV_EXCL_STOP
+ }
+ }
+ else { // in case of empty object remove, the first empty object is removed from the list
+ std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
+ owner()->document());
+ if (aDoc) {
+ const TDF_LabelList& aList = myRef->List();
+ for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) {
+ ObjectPtr anObj = aDoc->objects()->object(aLIter.Value());
+ if (anObj.get() == NULL) {
+ myRef->Remove(aLIter.Value());
+ REMOVE_BACK_REF(theObject);
+ owner()->data()->sendAttributeUpdated(this);
+ break;
+ }
+ }
+ }
+ }
+}
+
+void Model_AttributeRefList::clear()
+{
+ std::list<ObjectPtr> anOldList = list();
+ myRef->Clear();
+ std::list<ObjectPtr>::iterator anOldIter = anOldList.begin();
+ for(; anOldIter != anOldList.end(); anOldIter++) {
+ REMOVE_BACK_REF((*anOldIter));
+ }
+ myExtDocRef->Clear();
+ eraseHash();