summaryrefslogtreecommitdiffstats
path: root/src/xml
diff options
context:
space:
mode:
Diffstat (limited to 'src/xml')
-rw-r--r--src/xml/node.h2
-rw-r--r--src/xml/simple-node.cpp20
-rw-r--r--src/xml/simple-node.h3
3 files changed, 25 insertions, 0 deletions
diff --git a/src/xml/node.h b/src/xml/node.h
index 8bb70acc0..29cfdab46 100644
--- a/src/xml/node.h
+++ b/src/xml/node.h
@@ -469,6 +469,8 @@ public:
* @deprecated Use synthesizeEvents(NodeObserver &) instead
*/
virtual void synthesizeEvents(NodeEventVector const *vector, void *data)=0;
+
+ virtual void recursivePrintTree(unsigned level)=0;
/*@}*/
diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp
index 4965f81c8..3cbedc80b 100644
--- a/src/xml/simple-node.cpp
+++ b/src/xml/simple-node.cpp
@@ -606,6 +606,26 @@ void SimpleNode::synthesizeEvents(NodeObserver &observer) {
synthesizeEvents(&OBSERVER_EVENT_VECTOR, &observer);
}
+void SimpleNode::recursivePrintTree(unsigned level) {
+
+ if (level == 0) {
+ std::cout << "XML Node Tree" << std::endl;
+ }
+ std::cout << "XML: ";
+ for (unsigned i = 0; i < level; ++i) {
+ std::cout << " ";
+ }
+ char const *id=attribute("id");
+ if (id) {
+ std::cout << id << std::endl;
+ } else {
+ std::cout << name() << std::endl;
+ }
+ for (SimpleNode *child = _first_child; child != NULL; child = child->_next) {
+ child->recursivePrintTree( level+1 );
+ }
+}
+
Node *SimpleNode::root() {
Node *parent=this;
while (parent->parent()) {
diff --git a/src/xml/simple-node.h b/src/xml/simple-node.h
index 1fcb9193b..d09392249 100644
--- a/src/xml/simple-node.h
+++ b/src/xml/simple-node.h
@@ -19,6 +19,7 @@
#define SEEN_INKSCAPE_XML_SIMPLE_NODE_H
#include <cassert>
+#include <iostream>
#include "xml/node.h"
#include "xml/attribute-record.h"
@@ -120,6 +121,8 @@ public:
_subtree_observers.remove(observer);
}
+ void recursivePrintTree(unsigned level = 0);
+
protected:
SimpleNode(int code, Document *document);
SimpleNode(SimpleNode const &repr, Document *document);