diff --git a/src/App/Document.cpp b/src/App/Document.cpp
index 894ddf508e..f1b3272fee 100644
--- a/src/App/Document.cpp
+++ b/src/App/Document.cpp
@@ -88,7 +88,6 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
#include
#include
#include
-#include
#include
#include
#include
@@ -1285,6 +1284,7 @@ Document::readObjects(Base::XMLReader& reader)
// read the object types
reader.readElement("Objects");
int Cnt = reader.getAttributeAsInteger("Count");
+
if(!reader.hasAttribute(FC_ATTR_DEPENDENCIES))
d->partialLoadObjects.clear();
else if(!d->partialLoadObjects.empty()) {
@@ -2084,12 +2084,12 @@ void Document::restore (const char *filename,
// without GUI. But if available then follow after all data files of the App document.
signalRestoreDocument(reader);
reader.readFiles(zipstream);
-
+
if (reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestore)) {
setStatus(Document::PartialRestore, true);
Base::Console().Error("There were errors while loading the file. Some data might have been modified or not recovered at all. Look above for more specific information about the objects involved.\n");
}
-
+
if(!delaySignal)
afterRestore(true);
}
diff --git a/src/App/DynamicProperty.cpp b/src/App/DynamicProperty.cpp
index 892462844f..cc21764ada 100644
--- a/src/App/DynamicProperty.cpp
+++ b/src/App/DynamicProperty.cpp
@@ -26,7 +26,6 @@
#include
#include
#include
-#include
#include "DynamicProperty.h"
#include "Application.h"
@@ -323,35 +322,6 @@ Property *DynamicProperty::restore(PropertyContainer &pc,
return addDynamicProperty(pc,TypeName, PropName, group, doc, attribute, readonly, hidden);
}
-Property *DynamicProperty::restore(PropertyContainer &pc,
- const char *PropName, const char *TypeName, Base::DocumentReader &reader, XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *PropertyDOM)
-{
- const char* group_cstr = reader.GetAttribute(PropertyDOM,"group");
- if(!group_cstr)
- return nullptr;
-
- short attribute = 0;
- bool readonly = false, hidden = false;
-
- const char* doc_cstr = reader.GetAttribute(PropertyDOM,"doc");
- const char* attr_cstr = reader.GetAttribute(PropertyDOM,"attr");
-
- if(attr_cstr){
- std::istringstream str(attr_cstr);
- str >> attribute;
- }
-
- const char* ro_cstr = reader.GetAttribute(PropertyDOM,"ro");
- if(ro_cstr)
- readonly = (ro_cstr[0]-48) != 0;
-
- const char* hide_cstr = reader.GetAttribute(PropertyDOM,"hide");
- if(hide_cstr)
- hidden = (hide_cstr[0]-48) != 0;
-
- return addDynamicProperty(pc,TypeName, PropName, group_cstr, doc_cstr, attribute, readonly, hidden);
-}
-
DynamicProperty::PropData DynamicProperty::getDynamicPropertyData(const Property *prop) const
{
auto &index = props.get<1>();
diff --git a/src/App/DynamicProperty.h b/src/App/DynamicProperty.h
index e02a2e9659..a292f74c8e 100644
--- a/src/App/DynamicProperty.h
+++ b/src/App/DynamicProperty.h
@@ -33,15 +33,6 @@
#include
#include
#include
-#include
-
-
-XERCES_CPP_NAMESPACE_BEGIN
- class DOMNode;
- class DOMElement;
-// class DefaultHandler;
-// class SAX2XMLReader;
-XERCES_CPP_NAMESPACE_END
namespace Base {
@@ -154,8 +145,6 @@ public:
Property *restore(PropertyContainer &pc,
const char *PropName, const char *TypeName, Base::XMLReader &reader);
- Property *restore(PropertyContainer &pc,
- const char *PropName, const char *TypeName, Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *PropertyDOM);
struct PropData {
Property* property;
diff --git a/src/App/Extension.cpp b/src/App/Extension.cpp
index 5c392a9b51..8fa6ecc0a1 100644
--- a/src/App/Extension.cpp
+++ b/src/App/Extension.cpp
@@ -34,6 +34,7 @@
#include "ExtensionPython.h"
#include
+
/* We do not use a standard property macro for type initiation. The reason is that we have the first
* PropertyData in the extension chain, there is no parent property data.
*/
@@ -196,24 +197,6 @@ bool Extension::extensionHandleChangedPropertyType(Base::XMLReader &reader, cons
return false;
};
-bool Extension::extensionHandleChangedPropertyName(Base::DocumentReader &reader, const char * TypeName, const char *PropName)
-{
- (void) reader;
- (void) TypeName;
- (void) PropName;
-
- return false;
-};
-
-bool Extension::extensionHandleChangedPropertyType(Base::DocumentReader &reader, const char * TypeName, Property * prop)
-{
- (void) reader;
- (void) TypeName;
- (void) prop;
-
- return false;
-};
-
namespace App {
EXTENSION_PROPERTY_SOURCE_TEMPLATE(App::ExtensionPython, App::ExtensionPython::Inherited)
diff --git a/src/App/Extension.h b/src/App/Extension.h
index f9251e249c..10e54e4355 100644
--- a/src/App/Extension.h
+++ b/src/App/Extension.h
@@ -273,7 +273,6 @@ public:
//@{
virtual void extensionSave(Base::Writer&) const {}
virtual void extensionRestore(Base::XMLReader&) {}
- virtual void extensionRestore(Base::DocumentReader&) {}
//@}
/** @name TypeHandling */
@@ -290,10 +289,6 @@ protected:
virtual bool extensionHandleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName);
/// returns true if the property type change was handled by the extension.
virtual bool extensionHandleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, Property * prop);
- /// returns true if the property name change was handled by the extension.
- virtual bool extensionHandleChangedPropertyName(Base::DocumentReader &reader, const char * TypeName, const char *PropName);
- /// returns true if the property type change was handled by the extension.
- virtual bool extensionHandleChangedPropertyType(Base::DocumentReader &reader, const char * TypeName, Property * prop);
friend class App::ExtensionContainer;
diff --git a/src/App/ExtensionContainer.cpp b/src/App/ExtensionContainer.cpp
index 88aaca16f3..04b17ef19a 100644
--- a/src/App/ExtensionContainer.cpp
+++ b/src/App/ExtensionContainer.cpp
@@ -30,12 +30,6 @@
#include "Extension.h"
#include "ExtensionContainer.h"
-#include
-
-#ifndef _PreComp_
-# include
-//# include
-#endif
using namespace App;
@@ -312,17 +306,6 @@ void ExtensionContainer::Restore(Base::XMLReader& reader) {
App::PropertyContainer::Restore(reader);
}
-void ExtensionContainer::Restore(Base::DocumentReader& reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *containerEl) {
- //restore dynamic extensions.
- //Note 1: The extension element must be read first, before all other object elements. That is
- // needed as the element works together with an object element attribute, which would be
- // cleared if another attribute is read first
- //Note 2: This must happen before the py object of this container is used, as only in the
- // pyobject constructor the extension methods are added to the container.
- restoreExtensions(reader,containerEl);
- App::PropertyContainer::Restore(reader,containerEl);
-}
-
void ExtensionContainer::saveExtensions(Base::Writer& writer) const {
//we don't save anything if there are no dynamic extensions
@@ -368,80 +351,6 @@ void ExtensionContainer::saveExtensions(Base::Writer& writer) const {
writer.decInd();
}
-void ExtensionContainer::restoreExtensions(Base::DocumentReader& reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *containerEl) {
- //Dynamic extensions are optional (also because they are introduced late into the document format)
- //and hence it is possible that the element does not exist. As we cannot check for the existence of
- //an element a object attribute is set if extensions are available. Here we check that
- //attribute, and only if it exists the extensions element will be available.
- const char* expanded_cstr = reader.GetAttribute(containerEl,"expanded");
- if(!expanded_cstr)
- return;
- auto ExtensionsDOM = reader.FindElement(containerEl,"Extensions");
- if(ExtensionsDOM){
- const char* cnt_cstr = reader.GetAttribute(ExtensionsDOM,"Count");
- if(cnt_cstr){
- long Cnt = reader.ContentToInt( cnt_cstr );
- auto prev_ExtensionDOM = reader.FindElement(ExtensionsDOM,"Extension");
- readExtension(reader,prev_ExtensionDOM);
- for (int i=1 ;i(extension.createInstance());
- //check if this really is a python extension!
- if (!ext->isPythonExtension()) {
- delete ext;
- std::stringstream str;
- str << "Extension is not a python addable version: '" << type_cstr << "'" << std::ends;
- throw Base::TypeError(str.str());
- }
- ext->initExtension(this);
- }
- if (ext && strcmp(ext->getExtensionTypeId().getName(), type_cstr) == 0)
- ext->extensionRestore(reader);
- }
- catch (const Base::XMLParseException&) {
- throw; // re-throw
- }
- catch (const Base::Exception &e) {
- Base::Console().Error("%s\n", e.what());
- }
- catch (const std::exception &e) {
- Base::Console().Error("%s\n", e.what());
- }
- catch (const char* e) {
- Base::Console().Error("%s\n", e);
- }
-#ifndef FC_DEBUG
- catch (...) {
- Base::Console().Error("ExtensionContainer::Restore: Unknown C++ exception thrown\n");
- }
-#endif
-
-}
-
void ExtensionContainer::restoreExtensions(Base::XMLReader& reader) {
//Dynamic extensions are optional (also because they are introduced late into the document format)
@@ -521,20 +430,6 @@ void ExtensionContainer::handleChangedPropertyName(Base::XMLReader &reader, cons
PropertyContainer::handleChangedPropertyName(reader, TypeName, PropName);
}
-void ExtensionContainer::handleChangedPropertyName(Base::DocumentReader &reader, const char * TypeName, const char *PropName)
-{
- //inform all extensions about changed property name. This includes all properties from the
- //extended object (this) as well as all extension properties
- for(const auto& entry : _extensions) {
- bool handled = entry.second->extensionHandleChangedPropertyName(reader, TypeName, PropName);
-
- if(handled)
- return; // one property change needs only be handled once
- }
-
- PropertyContainer::handleChangedPropertyName(reader, TypeName, PropName);
-}
-
void ExtensionContainer::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, Property * prop)
{
//inform all extensions about changed property type. This includes all properties from the
@@ -548,17 +443,3 @@ void ExtensionContainer::handleChangedPropertyType(Base::XMLReader &reader, cons
PropertyContainer::handleChangedPropertyType(reader, TypeName, prop);
}
-
-void ExtensionContainer::handleChangedPropertyType(Base::DocumentReader &reader, const char * TypeName, Property * prop)
-{
- //inform all extensions about changed property type. This includes all properties from the
- //extended object (this) as well as all extension properties
- for(const auto& entry : _extensions) {
- bool handled = entry.second->extensionHandleChangedPropertyType(reader, TypeName, prop);
-
- if(handled)
- return; // one property change needs only be handled once
- }
-
- PropertyContainer::handleChangedPropertyType(reader, TypeName, prop);
-}
diff --git a/src/App/ExtensionContainer.h b/src/App/ExtensionContainer.h
index 2586de023c..68517fda3d 100644
--- a/src/App/ExtensionContainer.h
+++ b/src/App/ExtensionContainer.h
@@ -25,14 +25,6 @@
#define APP_EXTENSIONCONTAINER_H
#include "PropertyContainer.h"
-#include
-
-XERCES_CPP_NAMESPACE_BEGIN
- class DOMNode;
- class DOMElement;
-// class DefaultHandler;
-// class SAX2XMLReader;
-XERCES_CPP_NAMESPACE_END
namespace App {
@@ -185,13 +177,11 @@ public:
void Save(Base::Writer& writer) const override;
void Restore(Base::XMLReader& reader) override;
- void Restore(Base::DocumentReader& reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *containerEl);
//those methods save/restore the dynamic extensions without handling properties, which is something
//done by the default Save/Restore methods.
void saveExtensions(Base::Writer& writer) const;
void restoreExtensions(Base::XMLReader& reader);
- void restoreExtensions(Base::DocumentReader& reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *containerEl);
/** Extends the rules for handling property name changed, so that extensions are given an opportunity to handle it.
* If an extension handles a change, neither the rest of the extensions, nor the container itself get to handle it.
@@ -201,7 +191,6 @@ public:
* If no extension handles the request, then the containers handleChangedPropertyName() is called.
*/
void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName) override;
- virtual void handleChangedPropertyName(Base::DocumentReader &reader, const char * TypeName, const char *PropName) override;
/** Extends the rules for handling property type changed, so that extensions are given an opportunity to handle it.
* If an extension handles a change, neither the rest of the extensions, nor the container itself get to handle it.
*
@@ -210,9 +199,6 @@ public:
* If no extension handles the request, then the containers handleChangedPropertyType() is called.
*/
void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, Property * prop) override;
- virtual void handleChangedPropertyType(Base::DocumentReader &reader, const char * TypeName, Property * prop) override;
-
- void readExtension(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ExtensionDOM);
private:
//stored extensions
diff --git a/src/App/PropertyContainer.cpp b/src/App/PropertyContainer.cpp
index 2ccf2c8f1e..10100e65a3 100644
--- a/src/App/PropertyContainer.cpp
+++ b/src/App/PropertyContainer.cpp
@@ -30,11 +30,6 @@
#include "Property.h"
#include "PropertyContainer.h"
-#include
-
-#ifndef _PreComp_
-# include
-#endif
FC_LOG_LEVEL_INIT("App",true,true)
@@ -79,7 +74,7 @@ App::Property* PropertyContainer::addDynamicProperty(
Property *PropertyContainer::getPropertyByName(const char* name) const
{
auto prop = dynamicProps.getDynamicPropertyByName(name);
- if(prop){
+ if (prop) {
return prop;
}
return getPropertyData().getPropertyByName(this,name);
@@ -204,13 +199,6 @@ void PropertyContainer::handleChangedPropertyName(Base::XMLReader &reader, const
(void)PropName;
}
-void PropertyContainer::handleChangedPropertyName(Base::DocumentReader &reader, const char * TypeName, const char *PropName)
-{
- (void)reader;
- (void)TypeName;
- (void)PropName;
-}
-
/**
* @brief PropertyContainer::handleChangedPropertyType is called during restore to possibly
* fix reading of older versions of the property container. This method is typically called
@@ -230,13 +218,6 @@ void PropertyContainer::handleChangedPropertyType(XMLReader &reader, const char
(void)prop;
}
-void PropertyContainer::handleChangedPropertyType(DocumentReader &reader, const char *TypeName, Property *prop)
-{
- (void)reader;
- (void)TypeName;
- (void)prop;
-}
-
PropertyData PropertyContainer::propertyData;
void PropertyContainer::beforeSave() const
@@ -358,7 +339,6 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
if(reader.hasAttribute("TransientCount"))
transientCount = reader.getAttributeAsUnsigned("TransientCount");
-
for (int i=0;igetContainer() != this){
+ if (!prop || prop->getContainer() != this) {
prop = dynamicProps.restore(*this,PropName.c_str(),TypeName.c_str(),reader);
}
@@ -442,117 +422,6 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
reader.readEndElement("Properties");
}
-void PropertyContainer::Restore(Base::DocumentReader &reader, XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *containerEl)
-{
- reader.clearPartialRestoreProperty();
-
- auto PropertiesDOM = reader.FindElement(containerEl,"Properties");
- const char* count_cstr = reader.GetAttribute(PropertiesDOM,"Count");
- if(count_cstr){
- long Cnt = reader.ContentToInt( count_cstr );
- const char* TransientCount_cstr = reader.GetAttribute(PropertiesDOM,"TransientCount");
- int transientCount = 0;
- if(TransientCount_cstr)
- transientCount = reader.ContentToUnsigned( TransientCount_cstr );
-
- for (int i=0;igetName() << "'");
- if(prop && status_cstr){
- int u_status = reader.ContentToUnsigned( status_cstr );
- prop->setStatusValue(u_status);
- }
- }
- if(Cnt){
- auto prev_PropertyDOM = reader.FindElement(PropertiesDOM,"Property");
- readProperty(reader,prev_PropertyDOM);
- for (int i=1 ;igetContainer() != this){
- prop = dynamicProps.restore(*this,name_cstr,type_cstr,reader,PropertyDOM);
- }
-
- decltype(Property::StatusBits) status;
- const char* status_cstr = reader.GetAttribute(PropertyDOM,"status");
- if(status_cstr){
- int u_status = reader.ContentToUnsigned( status_cstr );
- status = decltype(status)(u_status);
- if(prop)
- prop->setStatusValue(status.to_ulong());
- }
- // name and type match
- if (prop && strcmp(prop->getTypeId().getName(), type_cstr) == 0) {
- if (!prop->testStatus(Property::Transient)
- && !status.test(Property::Transient)
- && !status.test(Property::PropTransient)
- && !prop->testStatus(Property::PropTransient))
- {
- FC_TRACE("restore property '" << prop->getName() << "'");
- prop->Restore(reader,PropertyDOM);
- }else
- FC_TRACE("skip transient '" << prop->getName() << "'");
- }
- // name matches but not the type
- else if (prop) {
- handleChangedPropertyType(reader, type_cstr, prop);
- }
- // name doesn't match, the sub-class then has to know
- // if the property has been renamed or removed
- else {
- handleChangedPropertyName(reader, type_cstr, name_cstr);
- }
-
- if (reader.testStatus(Base::DocumentReader::ReaderStatus::PartialRestoreInProperty)) {
- Base::Console().Error("Property %s of type %s was subject to a partial restore.\n",name_cstr,type_cstr);
- reader.clearPartialRestoreProperty();
- }
- }
- catch (const Base::XMLParseException&) {
- throw; // re-throw
- }
- catch (const Base::RestoreError &) {
- reader.setPartialRestore(true);
- reader.clearPartialRestoreProperty();
- Base::Console().Error("Property %s of type %s was subject to a partial restore.\n",name_cstr,type_cstr);
- }
- catch (const Base::Exception &e) {
- Base::Console().Error("%s\n", e.what());
- }
- catch (const std::exception &e) {
- Base::Console().Error("%s\n", e.what());
- }
- catch (const char* e) {
- Base::Console().Error("%s\n", e);
- }
-#ifndef FC_DEBUG
- catch (...) {
- Base::Console().Error("PropertyContainer::Restore: Unknown C++ exception thrown\n");
- }
-#endif
-}
-
void PropertyContainer::onPropertyStatusChanged(const Property &prop, unsigned long oldStatus)
{
(void)prop;
diff --git a/src/App/PropertyContainer.h b/src/App/PropertyContainer.h
index f31099adb7..17a2102efc 100644
--- a/src/App/PropertyContainer.h
+++ b/src/App/PropertyContainer.h
@@ -30,16 +30,6 @@
#include "DynamicProperty.h"
-#include
-
-XERCES_CPP_NAMESPACE_BEGIN
- class DOMNode;
- class DOMElement;
-// class DefaultHandler;
-// class SAX2XMLReader;
-XERCES_CPP_NAMESPACE_END
-
-
namespace Base {
class Writer;
}
@@ -230,7 +220,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader, XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *containerEl) override;
virtual void beforeSave() const;
virtual void editProperty(const char * /*propName*/) {}
@@ -259,14 +248,11 @@ protected:
virtual void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName);
virtual void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, Property * prop);
- virtual void handleChangedPropertyName(Base::DocumentReader &reader, const char * TypeName, const char *PropName);
- virtual void handleChangedPropertyType(Base::DocumentReader &reader, const char * TypeName, Property * prop);
public:
// forbidden
PropertyContainer(const PropertyContainer&) = delete;
PropertyContainer& operator = (const PropertyContainer&) = delete;
- void readProperty(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *PropertyDOM);
protected:
DynamicProperty dynamicProps;
diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp
index 01cced5580..a72364f265 100644
--- a/src/App/PropertyGeo.cpp
+++ b/src/App/PropertyGeo.cpp
@@ -26,7 +26,6 @@
#include
#include
#include
-#include
#include
#include
@@ -41,7 +40,6 @@
#include "Placement.h"
#include "ObjectIdentifier.h"
-#include
using namespace App;
using namespace Base;
@@ -154,25 +152,6 @@ void PropertyVector::Restore(Base::XMLReader &reader)
hasSetValue();
}
-void PropertyVector::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- // read my Element
- auto PropertyVectorDOM = reader.FindElement(ContainerDOM,"PropertyVector");
- if(PropertyVectorDOM){
- // get the value of my Attribute
- const char* valueX_cstr = reader.GetAttribute(PropertyVectorDOM,"valueX");
- const char* valueY_cstr = reader.GetAttribute(PropertyVectorDOM,"valueY");
- const char* valueZ_cstr = reader.GetAttribute(PropertyVectorDOM,"valueZ");
- if(valueX_cstr || valueY_cstr || valueZ_cstr){
- aboutToSetValue();
- _cVec.x = reader.ContentToFloat(valueX_cstr);
- _cVec.y = reader.ContentToFloat(valueY_cstr);
- _cVec.z = reader.ContentToFloat(valueZ_cstr);
- hasSetValue();
- }
- }
-}
-
Property *PropertyVector::Copy() const
{
diff --git a/src/App/PropertyGeo.h b/src/App/PropertyGeo.h
index c29be90761..829e251f98 100644
--- a/src/App/PropertyGeo.h
+++ b/src/App/PropertyGeo.h
@@ -89,7 +89,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader, XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *containerEl) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -274,7 +273,7 @@ public:
void setPyObject(PyObject *) override;
void Save (Base::Writer &writer) const override;
- void Restore(Base::XMLReader &reader) override;
+ void Restore(Base::XMLReader &reader) override;
Property *Copy() const override;
void Paste(const Property &from) override;
diff --git a/src/App/PropertyPythonObject.cpp b/src/App/PropertyPythonObject.cpp
index e21738f575..0efc797efb 100644
--- a/src/App/PropertyPythonObject.cpp
+++ b/src/App/PropertyPythonObject.cpp
@@ -30,13 +30,8 @@
#include
#include
#include
-#include
#include
-//#ifndef _PreComp_
-//# include
-//#endif
-
#include "PropertyPythonObject.h"
#include "DocumentObject.h"
@@ -286,37 +281,6 @@ void PropertyPythonObject::restoreObject(Base::XMLReader &reader)
}
}
-void PropertyPythonObject::restoreObject(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- Base::PyGILStateLocker lock;
- try {
- PropertyContainer* parent = this->getContainer();
- const char* object_cstr = reader.GetAttribute(ContainerDOM,"object");
- if (object_cstr) {
- if (strcmp(object_cstr,"yes") == 0) {
- Py::Object obj = Py::asObject(parent->getPyObject());
- this->object.setAttr("__object__", obj);
- }
- }
- const char* vobject_cstr = reader.GetAttribute(ContainerDOM,"vobject");
- if (vobject_cstr) {
- if (strcmp(vobject_cstr,"yes") == 0) {
- Py::Object obj = Py::asObject(parent->getPyObject());
- this->object.setAttr("__vobject__", obj);
- }
- }
- }
- catch (Py::Exception& e) {
- e.clear();
- }
- catch (const Base::Exception& e) {
- Base::Console().Error("%s\n",e.what());
- }
- catch (...) {
- Base::Console().Error("Critical error in PropertyPythonObject::restoreObject\n");
- }
-}
-
void PropertyPythonObject::Save (Base::Writer &writer) const
{
//if (writer.isForceXML()) {
@@ -434,88 +398,6 @@ void PropertyPythonObject::Restore(Base::XMLReader &reader)
}
}
-void PropertyPythonObject::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto PythonDOM = reader.FindElement(ContainerDOM,"Python");
- if(PythonDOM){
- const char* file_cstr = reader.GetAttribute(PythonDOM,"file");
- if (file_cstr){
- reader.addFile(file_cstr,this);
- }else{
- bool load_json=false;
- bool load_pickle=false;
- bool load_failed=false;
- const char* value_cstr = reader.GetAttribute(PythonDOM,"value");
- const char* encoded_cstr = reader.GetAttribute(PythonDOM,"encoded");
- std::string buffer = value_cstr;
- if (encoded_cstr && strcmp(encoded_cstr,"yes") == 0) {
- buffer = Base::base64_decode(buffer);
- }else {
- buffer = decodeValue(buffer);
- }
- Base::PyGILStateLocker lock;
- try {
- boost::regex pickle(R"(^\(i(\w+)\n(\w+)\n)");
- boost::match_results what;
- std::string::const_iterator start, end;
- start = buffer.begin();
- end = buffer.end();
-
- const char* module_cstr = reader.GetAttribute(PythonDOM,"module");
- const char* class_cstr = reader.GetAttribute(PythonDOM,"class");
- const char* json_cstr = reader.GetAttribute(PythonDOM,"json");
- if (module_cstr && class_cstr) {
- Py::Module mod(PyImport_ImportModule(module_cstr),true);
- if (mod.isNull())
- throw Py::Exception();
- PyObject* cls = mod.getAttr(class_cstr).ptr();
- if (!cls) {
- std::stringstream s;
- s << "Module " << module_cstr
- << " has no class " << class_cstr;
- throw Py::AttributeError(s.str());
- }
- if (PyType_Check(cls)) {
- this->object = PyType_GenericAlloc((PyTypeObject*)cls, 0);
- }
- else {
- throw Py::TypeError("neither class nor type object");
- }
- load_json = true;
- }
- else if (boost::regex_search(start, end, what, pickle)) {
- std::string name = std::string(what[1].first, what[1].second);
- std::string type = std::string(what[2].first, what[2].second);
- Py::Module mod(PyImport_ImportModule(name.c_str()),true);
- if (mod.isNull())
- throw Py::Exception();
- this->object = PyObject_CallObject(mod.getAttr(type).ptr(), nullptr);
- load_pickle = true;
- buffer = std::string(what[2].second, end);
- }
- else if (json_cstr) {
- load_json = true;
- }
- }
- catch (Py::Exception&) {
- Base::PyException e; // extract the Python error text
- e.ReportException();
- this->object = Py::None();
- load_failed = true;
- }
- aboutToSetValue();
- if (load_json)
- this->fromString(buffer);
- else if (load_pickle)
- this->loadPickle(buffer);
- else if (!load_failed)
- Base::Console().Warning("PropertyPythonObject::Restore: unsupported serialisation: %s\n", buffer.c_str());
- restoreObject(reader,PythonDOM);
- hasSetValue();
- }
- }
-}
-
void PropertyPythonObject::SaveDocFile (Base::Writer &writer) const
{
std::string buffer = this->toString();
diff --git a/src/App/PropertyPythonObject.h b/src/App/PropertyPythonObject.h
index febdbb255b..cf1357a234 100644
--- a/src/App/PropertyPythonObject.h
+++ b/src/App/PropertyPythonObject.h
@@ -60,7 +60,6 @@ public:
void Save (Base::Writer &writer) const override;
/** Use Python's pickle module to restore the object */
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
void SaveDocFile (Base::Writer &writer) const override;
void RestoreDocFile(Base::Reader &reader) override;
@@ -74,7 +73,6 @@ public:
private:
void saveObject(Base::Writer &writer) const;
void restoreObject(Base::XMLReader &reader);
- void restoreObject(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM);
std::string encodeValue(const std::string& str) const;
std::string decodeValue(const std::string& str) const;
void loadPickle(const std::string& str);
diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp
index 3017cc89b8..be966ccc6c 100644
--- a/src/App/PropertyStandard.cpp
+++ b/src/App/PropertyStandard.cpp
@@ -23,10 +23,6 @@
#include "PreCompiled.h"
-#ifndef _PreComp_
-# include
-#endif
-
#include
#include
@@ -34,7 +30,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -122,20 +117,6 @@ void PropertyInteger::Restore(Base::XMLReader &reader)
setValue(reader.getAttributeAsInteger("value"));
}
-void PropertyInteger::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- // read my Element
- auto IntegerDOM = reader.FindElement(ContainerDOM,"Integer");
- if(IntegerDOM){
- // get the value of my Attribute
- const char* value_cstr = reader.GetAttribute(IntegerDOM,"value");
- if(value_cstr){
- long value = reader.ContentToInt( value_cstr );
- setValue(value);
- }
- }
-}
-
Property *PropertyInteger::Copy() const
{
PropertyInteger *p= new PropertyInteger();
@@ -261,18 +242,6 @@ void PropertyPath::Restore(Base::XMLReader &reader)
setValue(reader.getAttribute("value"));
}
-void PropertyPath::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto PathDOM = reader.FindElement(ContainerDOM,"Path");
- if(PathDOM){
- // get the value of my Attribute
- const char* value_cstr = reader.GetAttribute(PathDOM,"value");
- if(value_cstr){
- setValue(value_cstr);
- }
- }
-}
-
Property *PropertyPath::Copy() const
{
PropertyPath *p= new PropertyPath();
@@ -463,54 +432,6 @@ void PropertyEnumeration::Restore(Base::XMLReader &reader)
hasSetValue();
}
-void PropertyEnumeration::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto IntegerDOM = reader.FindElement(ContainerDOM,"Integer");
- if(IntegerDOM){
- // get the value of my Attribute
- const char* value_cstr = reader.GetAttribute(IntegerDOM,"value");
- if(value_cstr){
- long val = reader.ContentToInt( value_cstr );
- aboutToSetValue();
-
- const char* CustomEnum_cstr = reader.GetAttribute(IntegerDOM,"CustomEnum");
- if(CustomEnum_cstr){
- auto CustomEnumListDOM = reader.FindElement(IntegerDOM,"CustomEnumList");
- if(CustomEnumListDOM){
- const char* count_cstr = reader.GetAttribute(IntegerDOM,"count");
- if(count_cstr){
- long count = reader.ContentToInt( count_cstr );
- std::vector values(count);
-
- if(count >= 1){
- auto prev_EnumDOM = reader.FindElement(CustomEnumListDOM,"Enum");
- const char* enum_value_cstr = reader.GetAttribute(prev_EnumDOM,"value");
- values[0] = enum_value_cstr;
- for(int i = 1; i < count; i++) {
- auto EnumDOM_i = reader.FindNextElement(prev_EnumDOM,"Enum");
- const char* _enum_value_cstr = reader.GetAttribute(EnumDOM_i,"value");
- values[i] = _enum_value_cstr;
-
- prev_EnumDOM = EnumDOM_i;
- }
- }
- _enum.setEnums(values);
- }
- }
- }
- if (val < 0) {
- // If the enum is empty at this stage do not print a warning
- if (_enum.hasEnums())
- Base::Console().Warning("Enumeration index %d is out of range, ignore it\n", val);
- val = getValue();
- }
-
- _enum.setValue(val);
- hasSetValue();
- }
- }
-}
-
PyObject * PropertyEnumeration::getPyObject()
{
if (!_enum.isValid()) {
@@ -856,35 +777,6 @@ void PropertyIntegerList::Restore(Base::XMLReader &reader)
setValues(values);
}
-void PropertyIntegerList::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto IntegerListDOM = reader.FindElement(ContainerDOM,"IntegerList");
- if(IntegerListDOM){
- // get the value of my Attribute
- const char* count_cstr = reader.GetAttribute(IntegerListDOM,"count");
- long count = reader.ContentToInt( count_cstr );
- std::vector values(count);
- if(count >= 1){
- auto prev_I_DOM = reader.FindElement(IntegerListDOM,"I");
- const char* v_cstr = reader.GetAttribute(prev_I_DOM,"v");
- long v = reader.ContentToInt( v_cstr );
- values[0] = v;
-
- for(int i = 1; i < count; i++) {
- auto I_DOM_i = reader.FindNextElement(prev_I_DOM,"I");
- const char* _v_cstr = reader.GetAttribute(I_DOM_i,"v");
- long v = reader.ContentToInt( _v_cstr );
- values[i] = v;
-
- prev_I_DOM = I_DOM_i;
- }
- }
- //assignment
- setValues(values);
- }
-}
-
-
Property *PropertyIntegerList::Copy() const
{
PropertyIntegerList *p= new PropertyIntegerList();
@@ -1005,35 +897,6 @@ void PropertyIntegerSet::Restore(Base::XMLReader &reader)
setValues(values);
}
-void PropertyIntegerSet::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto IntegerSetDOM = reader.FindElement(ContainerDOM,"IntegerSet");
- if(IntegerSetDOM){
- // get the value of my Attribute
- const char* count_cstr = reader.GetAttribute(IntegerSetDOM,"count");
- long count = reader.ContentToInt( count_cstr );
- std::set values;
-
- if(count >= 1){
- auto prev_I_DOM = reader.FindElement(IntegerSetDOM,"I");
- const char* v_cstr = reader.GetAttribute(prev_I_DOM,"v");
- long v = reader.ContentToInt( v_cstr );
- values.insert( v );
-
- for(int i = 1; i < count; i++) {
- auto I_DOM_i = reader.FindNextElement(prev_I_DOM,"I");
- const char* _v_cstr = reader.GetAttribute(I_DOM_i,"v");
- long v = reader.ContentToInt( _v_cstr );
- values.insert( v );
-
- prev_I_DOM = I_DOM_i;
- }
- }
- //assignment
- setValues(values);
- }
-}
-
Property *PropertyIntegerSet::Copy() const
{
PropertyIntegerSet *p= new PropertyIntegerSet();
@@ -1125,21 +988,6 @@ void PropertyFloat::Restore(Base::XMLReader &reader)
setValue(reader.getAttributeAsFloat("value"));
}
-void PropertyFloat::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto FloatDOM = reader.FindElement(ContainerDOM,"Float");
- if(FloatDOM){
- // get the value of my Attribute
- const char* value_cstr = reader.GetAttribute(FloatDOM,"value");
- if(value_cstr){
- double value = reader.ContentToFloat( value_cstr );
- setValue(value);
- }
- }
-}
-
-
-
Property *PropertyFloat::Copy() const
{
PropertyFloat *p= new PropertyFloat();
@@ -1385,24 +1233,6 @@ void PropertyFloatList::Restore(Base::XMLReader &reader)
}
}
-void PropertyFloatList::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- //TODO for this its needed to implement addFile() into Reader.cpp, and ReadFiles() since its not possible to have an XMLReader object at this point, because it gives error to use both methods(XMLReader progressive reading and DocumentReader reading) probably because there is something wrong with the zipios implementation, it looks like its locking file or in some way makes the file structure invalid to be readed by xerces by both methods.
- //worked around reimplementing ReadFiles in DocumentReader.cpp:
- auto FloatListDOM = reader.FindElement(ContainerDOM,"FloatList");
- if(FloatListDOM){
- // get the value of my Attribute
- const char* file_cstr = reader.GetAttribute(FloatListDOM,"file");
- if(file_cstr){
- string file ( file_cstr );
- if (!file.empty()) {
- // initiate a file read
- reader.addFile(file.c_str(),this);
- }
- }
- }
-}
-
void PropertyFloatList::SaveDocFile (Base::Writer &writer) const
{
Base::OutputStream str(writer.Stream());
@@ -1663,31 +1493,6 @@ void PropertyString::Restore(Base::XMLReader &reader)
setValue(reader.getAttribute("value"));
}
-void PropertyString::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto StringDOM = reader.FindElement(ContainerDOM,"String");
- const char* value_cstr = reader.GetAttribute(StringDOM,"value");
-
- auto obj = dynamic_cast(getContainer());
- if(obj && &obj->Label==this) {
- const char* restore_cstr = reader.GetAttribute(StringDOM,"restore");
-
- if(restore_cstr) {
- int restore = reader.ContentToInt( restore_cstr );
- if(restore == 1) {
- aboutToSetValue();
- _cValue = value_cstr;
- hasSetValue();
- return;
- }
- return;
- }
- }
- setValue(value_cstr);
-
-
-}
-
Property *PropertyString::Copy() const
{
PropertyString *p= new PropertyString();
@@ -1820,18 +1625,6 @@ void PropertyUUID::Restore(Base::XMLReader &reader)
setValue(reader.getAttribute("value"));
}
-void PropertyUUID::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto UuidDOM = reader.FindElement(ContainerDOM,"Uuid");
- if(UuidDOM){
- // get the value of my Attribute
- const char* value_cstr = reader.GetAttribute(UuidDOM,"value");
- if(value_cstr){
- setValue(value_cstr);
- }
- }
-}
-
Property *PropertyUUID::Copy() const
{
PropertyUUID *p= new PropertyUUID();
@@ -1953,32 +1746,6 @@ void PropertyStringList::Restore(Base::XMLReader &reader)
setValues(values);
}
-void PropertyStringList::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto StringListDOM = reader.FindElement(ContainerDOM,"StringList");
- if(StringListDOM){
- // get the value of my Attribute
- const char* count_cstr = reader.GetAttribute(StringListDOM,"count");
- long count = reader.ContentToInt( count_cstr );
- std::vector values(count);
- if(count >= 1){
- auto prev_StringDOM = reader.FindElement(StringListDOM,"String");
- const char* value_cstr = reader.GetAttribute(prev_StringDOM,"value");
- values[0] = value_cstr;
- for(int i = 1; i < count; i++) {
- auto StringDOM_i = reader.FindNextElement(prev_StringDOM,"String");
- const char* _value_cstr = reader.GetAttribute(StringDOM_i,"value");
- values[i] = _value_cstr;
-
- prev_StringDOM = StringDOM_i;
- }
-
- }
- // assignment
- setValues(values);
- }
-}
-
Property *PropertyStringList::Copy() const
{
PropertyStringList *p= new PropertyStringList();
@@ -2143,32 +1910,6 @@ void PropertyMap::Restore(Base::XMLReader &reader)
setValues(values);
}
-void PropertyMap::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto MapDOM = reader.FindElement(ContainerDOM,"Map");
- if(MapDOM){
- // get the value of my Attribute
- const char* count_cstr = reader.GetAttribute(MapDOM,"count");
- int count = reader.ContentToInt( count_cstr );
- std::map values;
- auto prev_ItemDOM = reader.FindElement(MapDOM,"Item");
- const char* key_cstr = reader.GetAttribute(prev_ItemDOM,"key");
- const char* value_cstr = reader.GetAttribute(prev_ItemDOM,"value");
- values[key_cstr] = value_cstr;
-
- for(int i = 1; i < count; i++) {
- auto ItemDOM_i = reader.FindNextElement(prev_ItemDOM,"Item");
- const char* key_cstr = reader.GetAttribute(ItemDOM_i,"key");
- const char* value_cstr = reader.GetAttribute(ItemDOM_i,"value");
- values[key_cstr] = value_cstr;
-
- prev_ItemDOM = ItemDOM_i;
- }
- // assignment
- setValues(values);
- }
-}
-
Property *PropertyMap::Copy() const
{
PropertyMap *p= new PropertyMap();
@@ -2254,15 +1995,6 @@ void PropertyBool::Restore(Base::XMLReader &reader)
(b == "true") ? setValue(true) : setValue(false);
}
-void PropertyBool::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto BoolDOM = reader.FindElement(ContainerDOM,"Bool");
- if(BoolDOM){
- // get the value of my Attribute
- string b = reader.GetAttribute(BoolDOM,"value");
- (b == "true") ? setValue(true) : setValue(false);
- }
-}
Property *PropertyBool::Copy() const
{
@@ -2381,18 +2113,6 @@ void PropertyBoolList::Restore(Base::XMLReader &reader)
setValues(bitset);
}
-void PropertyBoolList::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- // read my Element
- auto BoolListDOM = reader.FindElement(ContainerDOM,"BoolList");
- if(BoolListDOM){
- // get the value of my Attribute
- string str = reader.GetAttribute(BoolListDOM,"value");
- boost::dynamic_bitset<> bitset(str);
- setValues(bitset);
- }
-}
-
Property *PropertyBoolList::Copy() const
{
PropertyBoolList *p= new PropertyBoolList();
@@ -2546,17 +2266,6 @@ void PropertyColor::Restore(Base::XMLReader &reader)
setValue(rgba);
}
-void PropertyColor::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- // read my Element
- auto PropertyColorDOM = reader.FindElement(ContainerDOM,"PropertyColor");
- if(PropertyColorDOM){
- const char* val_cstr = reader.GetAttribute(PropertyColorDOM,"value");
- unsigned long rgba = reader.ContentToUnsigned(val_cstr);
- setValue(rgba);
- }
-}
-
Property *PropertyColor::Copy() const
{
PropertyColor *p= new PropertyColor();
@@ -2636,22 +2345,6 @@ void PropertyColorList::Restore(Base::XMLReader &reader)
}
}
-void PropertyColorList::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto ColorListDOM = reader.FindElement(ContainerDOM,"ColorList");
- if(ColorListDOM){
- // get the value of my Attribute
- const char* file_cstr = reader.GetAttribute(ColorListDOM,"file");
- if(file_cstr){
- std::string file (file_cstr);
- if (!file.empty()) {
- // initiate a file read
- reader.addFile(file.c_str(),this);
- }
- }
- }
-}
-
void PropertyColorList::SaveDocFile (Base::Writer &writer) const
{
Base::OutputStream str(writer.Stream());
@@ -2802,32 +2495,6 @@ void PropertyMaterial::Restore(Base::XMLReader &reader)
hasSetValue();
}
-void PropertyMaterial::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- // read my Element
- auto PropertyMaterialDOM = reader.FindElement(ContainerDOM,"PropertyMaterial");
- if(PropertyMaterialDOM){
- // get the value of my Attribute
- aboutToSetValue();
-
- const char* ambientColor_cstr = reader.GetAttribute(PropertyMaterialDOM,"ambientColor");
- const char* diffuseColor_cstr = reader.GetAttribute(PropertyMaterialDOM,"diffuseColor");
- const char* specularColor_cstr = reader.GetAttribute(PropertyMaterialDOM,"specularColor");
- const char* emissiveColor_cstr = reader.GetAttribute(PropertyMaterialDOM,"emissiveColor");
- const char* shininess_cstr = reader.GetAttribute(PropertyMaterialDOM,"shininess");
- const char* transparency_cstr = reader.GetAttribute(PropertyMaterialDOM,"transparency");
-
- _cMat.ambientColor.setPackedValue(reader.ContentToUnsigned(ambientColor_cstr));
- _cMat.diffuseColor.setPackedValue(reader.ContentToUnsigned(diffuseColor_cstr));
- _cMat.specularColor.setPackedValue(reader.ContentToUnsigned(specularColor_cstr));
- _cMat.emissiveColor.setPackedValue(reader.ContentToUnsigned(emissiveColor_cstr));
- _cMat.shininess = (float)reader.ContentToFloat(shininess_cstr);
- _cMat.transparency = (float)reader.ContentToFloat(transparency_cstr);
- hasSetValue();
- }
-}
-
-
const char* PropertyMaterial::getEditorName() const
{
if(testStatus(MaterialEdit))
@@ -2907,22 +2574,6 @@ void PropertyMaterialList::Restore(Base::XMLReader &reader)
}
}
-void PropertyMaterialList::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- auto MaterialListDOM = reader.FindElement(ContainerDOM,"MaterialList");
- if(MaterialListDOM){
- // get the value of my Attribute
- const char* file_cstr = reader.GetAttribute(MaterialListDOM,"file");
- if(file_cstr){
- std::string file (file_cstr);
- if (!file.empty()) {
- // initiate a file read
- reader.addFile(file.c_str(),this);
- }
- }
- }
-}
-
void PropertyMaterialList::SaveDocFile(Base::Writer &writer) const
{
Base::OutputStream str(writer.Stream());
@@ -3019,14 +2670,6 @@ void PropertyPersistentObject::Restore(Base::XMLReader &reader){
reader.readEndElement(ELEMENT_PERSISTENT_OBJ);
}
-void PropertyPersistentObject::Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM)
-{
- inherited::Restore(reader,ContainerDOM);
- auto element_persistent_obj_DOM = reader.FindElement(ELEMENT_PERSISTENT_OBJ);
- if(_pObject)
- _pObject->Restore(reader,element_persistent_obj_DOM);
-}
-
Property *PropertyPersistentObject::Copy() const{
auto *p= new PropertyPersistentObject();
p->_cValue = _cValue;
diff --git a/src/App/PropertyStandard.h b/src/App/PropertyStandard.h
index 7d39ef055c..7fb7be85c5 100644
--- a/src/App/PropertyStandard.h
+++ b/src/App/PropertyStandard.h
@@ -36,12 +36,6 @@
#include "Enumeration.h"
#include "Material.h"
-#include
-
-XERCES_CPP_NAMESPACE_BEGIN
- class DOMElement;
-XERCES_CPP_NAMESPACE_END
-
namespace Base {
class Writer;
@@ -76,7 +70,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -128,7 +121,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -228,7 +220,6 @@ public:
void Save(Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property * Copy() const override;
void Paste(const Property &from) override;
@@ -367,7 +358,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -413,7 +403,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -473,7 +462,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -527,7 +515,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -671,7 +658,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
void SaveDocFile (Base::Writer &writer) const override;
void RestoreDocFile(Base::Reader &reader) override;
@@ -719,7 +705,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -773,7 +758,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -840,7 +824,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -882,7 +865,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -920,7 +902,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -968,7 +949,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
@@ -1008,7 +988,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
void SaveDocFile (Base::Writer &writer) const override;
void RestoreDocFile(Base::Reader &reader) override;
@@ -1061,7 +1040,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
const char* getEditorName() const override;
@@ -1105,7 +1083,6 @@ public:
void Save(Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
void SaveDocFile(Base::Writer &writer) const override;
void RestoreDocFile(Base::Reader &reader) override;
@@ -1135,7 +1112,6 @@ public:
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
- void Restore(Base::DocumentReader &reader,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ContainerDOM) override;
Property *Copy() const override;
void Paste(const Property &from) override;
diff --git a/src/Base/CMakeLists.txt b/src/Base/CMakeLists.txt
index e095c55c53..d73271bed1 100644
--- a/src/Base/CMakeLists.txt
+++ b/src/Base/CMakeLists.txt
@@ -278,7 +278,6 @@ SET(FreeCADBase_CPP_SRCS
Writer.cpp
XMLTools.cpp
ZipHeader.cpp
- DocumentReader.cpp
)
SET(SWIG_HEADERS
diff --git a/src/Base/DocumentReader.cpp b/src/Base/DocumentReader.cpp
deleted file mode 100644
index b91c0e5b1f..0000000000
--- a/src/Base/DocumentReader.cpp
+++ /dev/null
@@ -1,351 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2011 Jürgen Riegel *
- * *
- * This file is part of the FreeCAD CAx development system. *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Library General Public *
- * License as published by the Free Software Foundation; either *
- * version 2 of the License, or (at your option) any later version. *
- * *
- * This library is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; see the file COPYING.LIB. If not, *
- * write to the Free Software Foundation, Inc., 59 Temple Place, *
- * Suite 330, Boston, MA 02111-1307, USA *
- * *
- ***************************************************************************/
-#include "PreCompiled.h"
-#include "DocumentReader.h"
-#include "InputSource.h"
-#include "XMLTools.h"
-
-#include
-#include
-#include "Persistence.h"
-#include "Sequencer.h"
-
-
-#ifdef _MSC_VER
-#include
-#endif
-#include
-
-#ifndef _PreComp_
-//# include
-# include
-# include
-# include
-#endif
-
-#ifdef _MSC_VER
-# define strdup _strdup
-#endif
-
-XERCES_CPP_NAMESPACE_USE
-
-//using namespace std;
-using namespace Base;
-
-// ---------------------------------------------------------------------------
-// DocumentReader: Constructors and Destructor
-// ---------------------------------------------------------------------------
-static XercesDOMParser::ValSchemes gValScheme = XercesDOMParser::Val_Auto;
-DocumentReader::DocumentReader()
-{
- gDoNamespaces = false;
- gDoSchema = false;
- gSchemaFullChecking = false;
- gDoCreate = true;
-}
-
-int DocumentReader::LoadDocument(Base::Reader& reader)
-{
- FileInfo _File( reader.getFileName() );
- StdInputSource inputSource(reader, _File.filePath().c_str());
-
- //
- // Create our parser, then attach an error handler to the parser.
- // The parser will call back to methods of the ErrorHandler if it
- // discovers errors during the course of parsing the XML document.
- //
- XercesDOMParser *parser = new XercesDOMParser;
- parser->setValidationScheme(gValScheme);
- parser->setDoNamespaces(gDoNamespaces);
- parser->setDoSchema(gDoSchema);
- parser->setValidationSchemaFullChecking(gSchemaFullChecking);
- parser->setCreateEntityReferenceNodes(gDoCreate);
-
- DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter();
- parser->setErrorHandler(errReporter);
- //
- // Parse the XML file, catching any XML exceptions that might propagate
- // out of it.
- //
- bool errorsOccured = false;
- try {
- parser->parse(inputSource);
- }
- catch (const XMLException& e) {
- std::cerr << "An error occurred during parsing\n Message: "
- << StrX(e.getMessage()) << std::endl;
- errorsOccured = true;
- }
- catch (const DOMException& e) {
- std::cerr << "A DOM error occurred during parsing\n DOMException code: "
- << e.code << std::endl;
- errorsOccured = true;
- }
- catch (...) {
- std::cerr << "An error occurred during parsing\n " << std::endl;
- errorsOccured = true;
- }
-
- if (errorsOccured) {
- delete parser;
- delete errReporter;
- return 0;
- }
-
- XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* _pDocument = parser->adoptDocument();
- delete parser;
- delete errReporter;
-
- if (!_pDocument)
- throw XMLBaseException("Malformed Parameter document: Invalid document");
-
- DOMElement* rootElem = _pDocument->getDocumentElement();
- if (!rootElem)
- throw XMLBaseException("Malformed Parameter document: Root group not found");
-
- _pGroupNode = rootElem;
-
- if (!_pGroupNode){
- throw XMLBaseException("Malformed document.");
- }
-
- return 1;
-}
-
-XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *DocumentReader::GetRootElement() const
-{
- //if (!_pGroupNode)
- //return nullptr;
- return _pGroupNode;
-}
-
-XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *DocumentReader::FindElement(const char* Type) const
-{
- if(!Type)
- return nullptr;
-
- for (DOMNode *clChild = _pGroupNode->getFirstChild(); clChild != nullptr; clChild = clChild->getNextSibling()) {
- if (clChild->getNodeType() == DOMNode::ELEMENT_NODE) {
- if (!strcmp(Type,StrX(clChild->getNodeName()).c_str())) {
- return static_cast(clChild);
- }
- }
- }
- return nullptr;
-}
-
-XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *DocumentReader::FindElementByField(
- XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
- const char* TypeEl,const char* field_name,const char* field_value) const
-{
- if(!TypeEl || !field_name ||!field_value)
- return nullptr;
- for (DOMNode *clChild = Start; clChild != nullptr; clChild = clChild->getNextSibling()) {
- //auto cast = static_cast(clChild);
- const char* attr = GetAttribute( static_cast(clChild), field_name );
- if(attr){
- if( !strcmp( attr, field_value ) ){
- return static_cast(clChild);;
- }
- }
- }
- return nullptr;
-}
-
-XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *DocumentReader::FindElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start, const char* Type) const
-{
- if(!Start || !Type)
- return nullptr;
- for (DOMNode *clChild = Start->getFirstChild(); clChild != nullptr; clChild = clChild->getNextSibling()) {
- if (clChild->getNodeType() == DOMNode::ELEMENT_NODE) {
- if (!strcmp(Type,StrX(clChild->getNodeName()).c_str())) {
- return static_cast(clChild);
- }
- }
- }
- return nullptr;
-}
-
-XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *DocumentReader::FindNextElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *Prev, const char* Type) const
-{
- if (!Prev || !Type)
- return nullptr;
- DOMNode *clChild = Prev;
- while ((clChild = clChild->getNextSibling()) != nullptr) {
- if (clChild->getNodeType() == DOMNode::ELEMENT_NODE) {
- // the right node Type
- if (!strcmp(Type,StrX(clChild->getNodeName()).c_str())) {
- return static_cast(clChild);
- }
- }
- }
- return nullptr;
-}
-
-long DocumentReader::ContentToInt( const char* content )
-{
- return atol( content );
-}
-
-unsigned long DocumentReader::ContentToUnsigned(const char* content)
-{
- return strtoul(content,nullptr,10);
-}
-
-double DocumentReader::ContentToFloat(const char* content)
-{
- return atof(content);
-}
-
-bool DocumentReader::ContentToBool(const char* content)
-{
- if (strcmp(content,"1"))
- return false;
- else
- return true;
-}
-
-//ATTRIBUTE:
-const char * DocumentReader::GetAttribute(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *DOMEl, const char* Attr) const
-{
- if(!Attr)
- return nullptr;
- XStr xstr( Attr );
- bool hasAttr = DOMEl->hasAttribute(xstr.unicodeForm());
- if (!hasAttr){
- return nullptr;
- }
- const XMLCh * attr = DOMEl->getAttribute( xstr.unicodeForm() );
- return strdup( StrX( attr ).c_str() );
-}
-
-const char * DocumentReader::GetAttribute(const char* Attr) const
-{
- if(!Attr)
- return nullptr;
- XStr xstr( Attr );
- bool hasAttr = _pGroupNode->hasAttribute(xstr.unicodeForm());
- if (!hasAttr){
- return nullptr;
- }
- const XMLCh * attr = _pGroupNode->getAttribute( xstr.unicodeForm() );
- return strdup( StrX( attr ).c_str() );//strdup is needed since pointer from strx only exists in context where StrX() is created.
-}
-//Status
-void Base::DocumentReader::setPartialRestore(bool on)
-{
- setStatus(PartialRestore, on);
- setStatus(PartialRestoreInDocumentObject, on);
- setStatus(PartialRestoreInProperty, on);
- setStatus(PartialRestoreInObject, on);
-}
-
-void Base::DocumentReader::clearPartialRestoreProperty()
-{
- setStatus(PartialRestoreInProperty, false);
- setStatus(PartialRestoreInObject, false);
-}
-
-bool Base::DocumentReader::testStatus(ReaderStatus pos) const
-{
- return StatusBits.test(static_cast(pos));
-}
-
-void Base::DocumentReader::setStatus(ReaderStatus pos, bool on)
-{
- StatusBits.set(static_cast(pos), on);
-}
-
-const char *Base::DocumentReader::addFile(const char* Name, Base::Persistence *Object)
-{
- FileEntry temp;
- temp.FileName = Name;
- temp.Object = Object;
-
- FileList.push_back(temp);
- FileNames.push_back( temp.FileName );
-
- return Name;
-}
-
-void Base::DocumentReader::readFiles(zipios::ZipInputStream &zipstream) const
-{
- // It's possible that not all objects inside the document could be created, e.g. if a module
- // is missing that would know these object types. So, there may be data files inside the zip
- // file that cannot be read. We simply ignore these files.
- // On the other hand, however, it could happen that a file should be read that is not part of
- // the zip file. This happens e.g. if a document is written without GUI up but is read with GUI
- // up. In this case the associated GUI document asks for its file which is not part of the ZIP
- // file, then.
- // In either case it's guaranteed that the order of the files is kept.
- zipios::ConstEntryPointer entry;
- try {
- entry = zipstream.getNextEntry();
- }
- catch (const std::exception&) {
- // There is no further file at all. This can happen if the
- // project file was created without GUI
- return;
- }
- std::vector::const_iterator it = FileList.begin();
- Base::SequencerLauncher seq("Importing project files...", FileList.size());
- while (entry->isValid() && it != FileList.end()) {
- std::vector::const_iterator jt = it;
- // Check if the current entry is registered, otherwise check the next registered files as soon as
- // both file names match
- while (jt != FileList.end() && entry->getName() != jt->FileName)
- ++jt;
- // If this condition is true both file names match and we can read-in the data, otherwise
- // no file name for the current entry in the zip was registered.
- if (jt != FileList.end()) {
- try {
- Base::Reader reader(zipstream, jt->FileName, FileVersion);
- jt->Object->RestoreDocFile(reader);
- if (reader.getLocalReader())
- reader.getLocalReader()->readFiles(zipstream);
- if (reader.getLocalDocReader())
- reader.getLocalDocReader()->readFiles(zipstream);
-
- }catch(...) {
- // For any exception we just continue with the next file.
- // It doesn't matter if the last reader has read more or
- // less data than the file size would allow.
- // All what we need to do is to notify the user about the
- // failure.
- Base::Console().Error("Reading failed from embedded file(DocumentReader): %s\n", entry->toString().c_str());
- }
- // Go to the next registered file name
- it = jt + 1;
- }
-
- seq.next();
-
- // In either case we must go to the next entry
- try {
- entry = zipstream.getNextEntry();
- }
- catch (const std::exception&) {
- // there is no further entry
- break;
- }
- }
-}
diff --git a/src/Base/DocumentReader.h b/src/Base/DocumentReader.h
deleted file mode 100644
index cf9bf4e71e..0000000000
--- a/src/Base/DocumentReader.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2011 Jürgen Riegel *
- * *
- * This file is part of the FreeCAD CAx development system. *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Library General Public *
- * License as published by the Free Software Foundation; either *
- * version 2 of the License, or (at your option) any later version. *
- * *
- * This library is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; see the file COPYING.LIB. If not, *
- * write to the Free Software Foundation, Inc., 59 Temple Place, *
- * Suite 330, Boston, MA 02111-1307, USA *
- * *
- ***************************************************************************/
-
-#ifndef BASE_DOCUMENTREADER_H
-#define BASE_DOCUMENTREADER_H
-
-#include
-#include