MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / replaceObject

Method replaceObject

src/App/ObjectIdentifier.cpp:396–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394}
395
396bool ObjectIdentifier::replaceObject(ObjectIdentifier& res,
397 const App::DocumentObject* parent,
398 App::DocumentObject* oldObj,
399 App::DocumentObject* newObj) const
400{
401 ResolveResults result(*this);
402
403 if (!result.resolvedDocumentObject) {
404 return false;
405 }
406
407 auto r = PropertyLinkBase::tryReplaceLink(owner,
408 result.resolvedDocumentObject,
409 parent,
410 oldObj,
411 newObj,
412 subObjectName.getString().c_str());
413
414 if (!r.first) {
415 return false;
416 }
417
418 res = *this;
419 if (r.first != result.resolvedDocumentObject) {
420 if (r.first->getDocument() != owner->getDocument()) {
421 auto doc = r.first->getDocument();
422 bool useLabel = res.documentName.isRealString();
423 const char* name = useLabel ? doc->Label.getValue() : doc->getName();
424 res.setDocumentName(String(name, useLabel), true);
425 }
426 if (documentObjectName.isRealString()) {
427 res.documentObjectName = String(r.first->Label.getValue(), true);
428 }
429 else {
430 res.documentObjectName = String(r.first->getNameInDocument(), false, true);
431 }
432 }
433 res.subObjectName = String(r.second, true);
434 res._cache.clear();
435 res.shadowSub.newName.clear();
436 res.shadowSub.oldName.clear();
437 return true;
438}
439
440std::string ObjectIdentifier::toEscapedString() const
441{

Callers

nothing calls this directly

Calls 10

isRealStringMethod · 0.80
StringClass · 0.70
c_strMethod · 0.45
getStringMethod · 0.45
getDocumentMethod · 0.45
getValueMethod · 0.45
getNameMethod · 0.45
setDocumentNameMethod · 0.45
getNameInDocumentMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected