| 394 | } |
| 395 | |
| 396 | bool 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 | |
| 440 | std::string ObjectIdentifier::toEscapedString() const |
| 441 | { |
nothing calls this directly
no test coverage detected