| 443 | } |
| 444 | |
| 445 | bool 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()) { |
nothing calls this directly
no test coverage detected