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

Method importObjects

src/App/Document.cpp:1773–1836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1771}
1772
1773std::vector<DocumentObject*> Document::importObjects(Base::XMLReader& reader)
1774{
1775 d->hashers.clear();
1776 Base::FlagToggler<> flag(globalIsRestoring, false);
1777 Base::ObjectStatusLocker<Status, Document> restoreBit(Status::Restoring, this);
1778 Base::ObjectStatusLocker<Status, Document> restoreBit2(Status::Importing, this);
1779 ExpressionParser::ExpressionImporter expImporter(reader);
1780 reader.readElement("Document");
1781 const long scheme = reader.getAttribute<long>("SchemaVersion");
1782 reader.DocumentSchema = static_cast<int>(scheme);
1783 if (reader.hasAttribute("ProgramVersion")) {
1784 reader.ProgramVersion = reader.getAttribute<const char*>("ProgramVersion");
1785 }
1786 else {
1787 reader.ProgramVersion = "pre-0.14";
1788 }
1789 if (reader.hasAttribute("FileVersion")) {
1790 reader.FileVersion = static_cast<int>(reader.getAttribute<unsigned long>("FileVersion"));
1791 }
1792 else {
1793 reader.FileVersion = 0;
1794 }
1795
1796 std::vector<DocumentObject*> objs = readObjects(reader);
1797 for (const auto o : objs) {
1798 if (o && o->isAttachedToDocument()) {
1799 o->setStatus(ObjImporting, true);
1800 FC_LOG("importing " << o->getFullName());
1801 if (const auto propUUID =
1802 freecad_cast<PropertyUUID*>(o->getPropertyByName("_ObjectUUID"))) {
1803 auto propSource =
1804 freecad_cast<PropertyUUID*>(o->getPropertyByName("_SourceUUID"));
1805 if (!propSource) {
1806 propSource = static_cast<PropertyUUID*>(
1807 o->addDynamicProperty("App::PropertyUUID",
1808 "_SourceUUID",
1809 nullptr,
1810 nullptr,
1811 Prop_Output | Prop_Hidden));
1812 }
1813 if (propSource) {
1814 propSource->setValue(propUUID->getValue());
1815 }
1816 propUUID->setValue(Base::Uuid::createUuid());
1817 }
1818 }
1819 }
1820
1821 reader.readEndElement("Document");
1822
1823 signalImportObjects(objs, reader);
1824 afterRestore(objs, true);
1825
1826 signalFinishImportObjects(objs);
1827
1828 for (const auto o : objs) {
1829 if (o && o->isAttachedToDocument()) {
1830 o->setStatus(ObjImporting, false);

Callers 3

mergeProjectMethod · 0.45
copyObjectMethod · 0.45
importLinksMethod · 0.45

Calls 12

afterRestoreFunction · 0.85
readElementMethod · 0.80
hasAttributeMethod · 0.80
readEndElementMethod · 0.80
clearMethod · 0.45
isAttachedToDocumentMethod · 0.45
setStatusMethod · 0.45
getFullNameMethod · 0.45
getPropertyByNameMethod · 0.45
addDynamicPropertyMethod · 0.45
setValueMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected