summaryrefslogtreecommitdiffstats
path: root/src/xml
diff options
context:
space:
mode:
Diffstat (limited to 'src/xml')
-rw-r--r--src/xml/node.h19
-rw-r--r--src/xml/repr-io.cpp5
-rw-r--r--src/xml/simple-node.cpp92
-rw-r--r--src/xml/simple-node.h4
4 files changed, 7 insertions, 113 deletions
diff --git a/src/xml/node.h b/src/xml/node.h
index 8d9fc19e4..29cfdab46 100644
--- a/src/xml/node.h
+++ b/src/xml/node.h
@@ -384,20 +384,6 @@ public:
*/
virtual void changeOrder(Node *child, Node *after)=0;
- /**
- * @brief Remove all elements that not in src node
- * @param src The node to check for elemments into this node
- * @param key The attribute to use as the identity attribute
- */
- virtual void cleanOriginal(Node *src, gchar const *key)=0;
-
-
- /**
- * @brief Compare 2 nodes equality
- * @param other The other node to compare
- * @param recursive Recursive mode check
- */
- virtual bool equal(Node const *other, bool recursive)=0;
/**
* @brief Merge all children of another node with the current
*
@@ -411,11 +397,8 @@ public:
*
* @param src The node to merge into this node
* @param key The attribute to use as the identity attribute
- * @param noid If true process noid items
- * @param key If clean callback to cleanOriginal
*/
-
- virtual void mergeFrom(Node const *src, char const *key, bool extension = false, bool clean = false)=0;
+ virtual void mergeFrom(Node const *src, char const *key)=0;
/*@}*/
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp
index c7b483dcb..2ff9d4776 100644
--- a/src/xml/repr-io.cpp
+++ b/src/xml/repr-io.cpp
@@ -872,10 +872,7 @@ static void sp_repr_write_stream_root_element(Node *repr, Writer &out,
if (clean) sp_attribute_clean_tree( repr );
// Sort attributes in a canonical order (helps with "diffing" SVG files).
- bool sort = prefs->getBool("/options/svgoutput/disable_optimizations");
- if (!sort) {
- sort = prefs->getBool("/options/svgoutput/sort_attributes");
- }
+ bool sort = prefs->getBool("/options/svgoutput/sort_attributes");
if (sort) sp_attribute_sort_tree( repr );
Glib::QueryQuark xml_prefix=g_quark_from_static_string("xml");
diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp
index a1a7127cc..78fc52a27 100644
--- a/src/xml/simple-node.cpp
+++ b/src/xml/simple-node.cpp
@@ -315,7 +315,7 @@ SimpleNode::setAttribute(gchar const *name, gchar const *value, bool const /*is_
// Check usefulness of attributes on elements in the svg namespace, optionally don't add them to tree.
Glib::ustring element = g_quark_to_string(_name);
- //g_message("setAttribute: %s: %s: %s", element.c_str(), name, value);
+ // g_message("setAttribute: %s: %s: %s", element.c_str(), name, value);
gchar* cleaned_value = g_strdup( value );
// Only check elements in SVG name space and don't block setting attribute to NULL.
@@ -645,112 +645,28 @@ Node *SimpleNode::root() {
}
}
-void SimpleNode::cleanOriginal(Node *src, gchar const *key){
- std::vector<Node *> to_delete;
- for ( Node *child = this->firstChild() ; child != NULL ; child = child->next() )
- {
- gchar const *id = child->attribute(key);
- if (id) {
- Node *rch = sp_repr_lookup_child(src, key, id);
- if (rch) {
- child->cleanOriginal(rch, key);
- } else {
- to_delete.push_back(child);
- }
- } else {
- to_delete.push_back(child);
- }
- }
- for ( std::vector<Node *>::iterator i = to_delete.begin(); i != to_delete.end(); ++i) {
- removeChild(*i);
- }
-}
-
-bool SimpleNode::equal(Node const *other, bool recursive) {
- if(strcmp(name(),other->name())!= 0){
- return false;
- }
- if (!(strcmp("sodipodi:namedview", name()))) {
- return true;
- }
- guint orig_length = 0;
- guint other_length = 0;
-
- if(content() && other->content() && strcmp(content(), other->content()) != 0){
- return false;
- }
- for (List<AttributeRecord const> orig_attr = attributeList(); orig_attr; ++orig_attr) {
- for (List<AttributeRecord const> other_attr = other->attributeList(); other_attr; ++other_attr) {
- const gchar * key_orig = g_quark_to_string(orig_attr->key);
- const gchar * key_other = g_quark_to_string(other_attr->key);
- if (!strcmp(key_orig, key_other) &&
- !strcmp(orig_attr->value, other_attr->value))
- {
- other_length++;
- break;
- }
- }
- orig_length++;
- }
- if (orig_length != other_length) {
- return false;
- }
- if (recursive) {
- //NOTE: for faster the childs need to be in the same order
- Node const *other_child = other->firstChild();
- for ( Node *child = firstChild();
- child;
- child = child->next())
- {
- if (!child->equal(other_child, recursive)) {
- return false;
- }
- other_child = other_child->next();
- if(!other_child) {
- return false;
- }
- }
- }
- return true;
-}
-
-void SimpleNode::mergeFrom(Node const *src, gchar const *key, bool extension, bool clean) {
+void SimpleNode::mergeFrom(Node const *src, gchar const *key) {
g_return_if_fail(src != NULL);
g_return_if_fail(key != NULL);
g_assert(src != this);
setContent(src->content());
- if(_parent) {
- setPosition(src->position());
- }
-
- if (clean) {
- Node * srcp = const_cast<Node *>(src);
- cleanOriginal(srcp, key);
- }
for ( Node const *child = src->firstChild() ; child != NULL ; child = child->next() )
{
gchar const *id = child->attribute(key);
if (id) {
Node *rch=sp_repr_lookup_child(this, key, id);
- if (rch && (!extension || rch->equal(child, false))) {
- rch->mergeFrom(child, key, extension);
+ if (rch) {
+ rch->mergeFrom(child, key);
} else {
- if(rch) {
- removeChild(rch);
- }
- guint pos = child->position();
rch = child->duplicate(_document);
appendChild(rch);
- rch->setPosition(pos);
rch->release();
}
} else {
- guint pos = child->position();
Node *rch=child->duplicate(_document);
appendChild(rch);
- rch->setPosition(pos);
rch->release();
}
}
diff --git a/src/xml/simple-node.h b/src/xml/simple-node.h
index fd41e53a8..f2cfa953c 100644
--- a/src/xml/simple-node.h
+++ b/src/xml/simple-node.h
@@ -91,9 +91,7 @@ public:
char const *content() const;
void setContent(char const *value);
- void cleanOriginal(Node *src, gchar const *key);
- bool equal(Node const *other, bool recursive);
- void mergeFrom(Node const *src, char const *key, bool extension = false, bool clean = false);
+ void mergeFrom(Node const *src, char const *key);
Inkscape::Util::List<AttributeRecord const> attributeList() const {
return _attributes;