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

Method updateLabelReference

src/App/ObjectIdentifier.cpp:445–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443}
444
445bool ObjectIdentifier::updateLabelReference(const App::DocumentObject* obj,
446 const std::string& ref,
447 const char* newLabel)
448{
449 if (!owner) {
450 return false;
451 }
452
453 ResolveResults result(*this);
454
455 if (!subObjectName.getString().empty() && result.resolvedDocumentObject) {
456 std::string sub = PropertyLinkBase::updateLabelReference(result.resolvedDocumentObject,
457 subObjectName.getString().c_str(),
458 obj,
459 ref,
460 newLabel);
461 if (!sub.empty()) {
462 subObjectName = String(sub, true);
463 _cache.clear();
464 return true;
465 }
466 }
467
468 if (result.resolvedDocument != obj->getDocument()) {
469 return false;
470 }
471
472 if (!documentObjectName.getString().empty()) {
473 if (documentObjectName.isForceIdentifier()) {
474 return false;
475 }
476
477 if (!documentObjectName.isRealString()
478 && documentObjectName.getString() == obj->getNameInDocument()) {
479 return false;
480 }
481
482 if (documentObjectName.getString() != obj->Label.getValue()) {
483 return false;
484 }
485
486 documentObjectName = ObjectIdentifier::String(newLabel, true);
487
488 _cache.clear();
489 return true;
490 }
491
492 if (result.resolvedDocumentObject == obj && result.propertyIndex == 1
493 && result.resolvedDocumentObjectName.isRealString()
494 && result.resolvedDocumentObjectName.getString() == obj->Label.getValue()) {
495 components[0].name = ObjectIdentifier::String(newLabel, true);
496 _cache.clear();
497 return true;
498 }
499
500 // If object identifier uses the label then resolving the document object will fail.
501 // So, it must be checked if using the new label will succeed
502 if (components.size() > 1 && components[0].getName() == obj->Label.getValue()) {

Callers

nothing calls this directly

Calls 12

isForceIdentifierMethod · 0.80
isRealStringMethod · 0.80
StringClass · 0.70
emptyMethod · 0.45
getStringMethod · 0.45
c_strMethod · 0.45
clearMethod · 0.45
getDocumentMethod · 0.45
getNameInDocumentMethod · 0.45
getValueMethod · 0.45
sizeMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected