| 3334 | } |
| 3335 | |
| 3336 | DocumentObject* Document::addObject( |
| 3337 | std::string_view sType, |
| 3338 | const char* pObjectName, |
| 3339 | const bool isNew, |
| 3340 | const char* viewType, |
| 3341 | const bool isPartial |
| 3342 | ) |
| 3343 | { |
| 3344 | const Base::Type type = |
| 3345 | Base::Type::getTypeIfDerivedFrom(sType, DocumentObject::getClassTypeId(), true); |
| 3346 | if (type.isBad()) { |
| 3347 | std::stringstream str; |
| 3348 | str << "Document::addObject: '" << sType << "' is not a document object type"; |
| 3349 | throw Base::TypeError(str.str()); |
| 3350 | } |
| 3351 | |
| 3352 | void* typeInstance = type.createInstance(); |
| 3353 | if (!typeInstance) { |
| 3354 | return nullptr; |
| 3355 | } |
| 3356 | |
| 3357 | auto* pcObject = static_cast<DocumentObject*>(typeInstance); |
| 3358 | pcObject->setDocument(this); |
| 3359 | |
| 3360 | _addObject(pcObject, |
| 3361 | pObjectName, |
| 3362 | AddObjectOption::SetNewStatus |
| 3363 | | (isPartial ? AddObjectOption::SetPartialStatus : AddObjectOption::UnsetPartialStatus) |
| 3364 | | (isNew ? AddObjectOption::DoSetup : AddObjectOption::None) |
| 3365 | | AddObjectOption::ActivateObject, |
| 3366 | viewType); |
| 3367 | |
| 3368 | // return the Object |
| 3369 | return pcObject; |
| 3370 | } |
| 3371 | |
| 3372 | std::vector<DocumentObject*> |
| 3373 | Document::addObjects(const char* sType, const std::vector<std::string>& objectNames, bool isNew) |
nothing calls this directly
no test coverage detected