summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMenTaLguY <mental@rydia.net>2008-06-08 19:44:26 +0000
committermental <mental@users.sourceforge.net>2008-06-08 19:44:26 +0000
commit3e9f14e201944380006bb851d40f5cacb860678d (patch)
tree05e1d487b101aead4e985c4187209cdff5bb041f /src
parentAdd option to either suppress path flash for items with LPE (e.g., spiro spli... (diff)
downloadinkscape-3e9f14e201944380006bb851d40f5cacb860678d.tar.gz
inkscape-3e9f14e201944380006bb851d40f5cacb860678d.zip
plumb document references a little deeper in
(bzr r5861)
Diffstat (limited to 'src')
-rw-r--r--src/jabber_whiteboard/inkboard-document.cpp10
-rw-r--r--src/jabber_whiteboard/inkboard-node.cpp4
-rw-r--r--src/xml/comment-node.h9
-rw-r--r--src/xml/element-node.h8
-rw-r--r--src/xml/pi-node.h8
-rw-r--r--src/xml/repr-css.cpp15
-rw-r--r--src/xml/simple-document.cpp8
-rw-r--r--src/xml/simple-document.h3
-rw-r--r--src/xml/simple-node.cpp11
-rw-r--r--src/xml/simple-node.h4
-rw-r--r--src/xml/text-node.h8
11 files changed, 53 insertions, 35 deletions
diff --git a/src/jabber_whiteboard/inkboard-document.cpp b/src/jabber_whiteboard/inkboard-document.cpp
index dd039ab6f..7e4afff8d 100644
--- a/src/jabber_whiteboard/inkboard-document.cpp
+++ b/src/jabber_whiteboard/inkboard-document.cpp
@@ -44,7 +44,7 @@ namespace Whiteboard {
InkboardDocument::InkboardDocument(int code, State::SessionType sessionType,
Glib::ustring const& to)
-: XML::SimpleNode(code), sessionType(sessionType), recipient(to),
+: XML::SimpleNode(code, NULL), sessionType(sessionType), recipient(to),
_in_transaction(false)
{
_initBindings();
@@ -348,25 +348,25 @@ InkboardDocument::commitUndoable()
XML::Node*
InkboardDocument::createElement(char const* name)
{
- return new XML::ElementNode(g_quark_from_string(name));
+ return new XML::ElementNode(g_quark_from_string(name), this);
}
XML::Node*
InkboardDocument::createTextNode(char const* content)
{
- return new XML::TextNode(Util::share_string(content));
+ return new XML::TextNode(Util::share_string(content), this);
}
XML::Node*
InkboardDocument::createComment(char const* content)
{
- return new XML::CommentNode(Util::share_string(content));
+ return new XML::CommentNode(Util::share_string(content), this);
}
XML::Node*
InkboardDocument::createPI(char const *target, char const* content)
{
- return new XML::PINode(g_quark_from_string(target), Util::share_string(content));
+ return new XML::PINode(g_quark_from_string(target), Util::share_string(content), this);
}
diff --git a/src/jabber_whiteboard/inkboard-node.cpp b/src/jabber_whiteboard/inkboard-node.cpp
index d3d568551..e6eee7304 100644
--- a/src/jabber_whiteboard/inkboard-node.cpp
+++ b/src/jabber_whiteboard/inkboard-node.cpp
@@ -104,7 +104,7 @@ InkboardDocument::changeNew(Glib::ustring parentid, Glib::ustring id,
if(name == "text")
{
XML::Node *parent = this->tracker->get(parentid);
- XML::Node *node = new XML::TextNode(Util::share_string(data->getValue().c_str()));
+ XML::Node *node = new XML::TextNode(Util::share_string(data->getValue().c_str()), this);
if(parent && node)
{
@@ -113,7 +113,7 @@ InkboardDocument::changeNew(Glib::ustring parentid, Glib::ustring id,
}
}else
{
- XML::Node *node = new XML::ElementNode(g_quark_from_string(name.c_str()));
+ XML::Node *node = new XML::ElementNode(g_quark_from_string(name.c_str()), this);
this->tracker->put(id,node);
XML::Node *parent = (parentid != "ROOT")
diff --git a/src/xml/comment-node.h b/src/xml/comment-node.h
index 4be09ec85..5cff9caf6 100644
--- a/src/xml/comment-node.h
+++ b/src/xml/comment-node.h
@@ -23,16 +23,19 @@ namespace Inkscape {
namespace XML {
struct CommentNode : public SimpleNode {
- explicit CommentNode(Util::ptr_shared<char> content)
- : SimpleNode(g_quark_from_static_string("comment"))
+ CommentNode(Util::ptr_shared<char> content, Document *doc)
+ : SimpleNode(g_quark_from_static_string("comment"), doc)
{
setContent(content);
}
+ CommentNode(CommentNode const &other, Document *doc)
+ : SimpleNode(other, doc) {}
+
Inkscape::XML::NodeType type() const { return Inkscape::XML::COMMENT_NODE; }
protected:
- SimpleNode *_duplicate(Document* /*doc*/) const { return new CommentNode(*this); }
+ SimpleNode *_duplicate(Document* doc) const { return new CommentNode(*this, doc); }
};
}
diff --git a/src/xml/element-node.h b/src/xml/element-node.h
index 1b79910a8..11bc8e03a 100644
--- a/src/xml/element-node.h
+++ b/src/xml/element-node.h
@@ -23,13 +23,15 @@ namespace XML {
class ElementNode : public SimpleNode {
public:
- explicit ElementNode(int code)
- : SimpleNode(code) {}
+ ElementNode(int code, Document *doc)
+ : SimpleNode(code, doc) {}
+ ElementNode(ElementNode const &other, Document *doc)
+ : SimpleNode(other, doc) {}
Inkscape::XML::NodeType type() const { return Inkscape::XML::ELEMENT_NODE; }
protected:
- SimpleNode *_duplicate(Document* /*doc*/) const { return new ElementNode(*this); }
+ SimpleNode *_duplicate(Document* doc) const { return new ElementNode(*this, doc); }
};
}
diff --git a/src/xml/pi-node.h b/src/xml/pi-node.h
index b89ef25a0..502c5cd71 100644
--- a/src/xml/pi-node.h
+++ b/src/xml/pi-node.h
@@ -23,16 +23,18 @@ namespace Inkscape {
namespace XML {
struct PINode : public SimpleNode {
- explicit PINode(GQuark target, Util::ptr_shared<char> content)
- : SimpleNode(target)
+ PINode(GQuark target, Util::ptr_shared<char> content, Document *doc)
+ : SimpleNode(target, doc)
{
setContent(content);
}
+ PINode(PINode const &other, Document *doc)
+ : SimpleNode(other, doc) {}
Inkscape::XML::NodeType type() const { return Inkscape::XML::PI_NODE; }
protected:
- SimpleNode *_duplicate(Document* /*doc*/) const { return new PINode(*this); }
+ SimpleNode *_duplicate(Document* doc) const { return new PINode(*this, doc); }
};
}
diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp
index 888250c40..be125f453 100644
--- a/src/xml/repr-css.cpp
+++ b/src/xml/repr-css.cpp
@@ -8,6 +8,7 @@
#include <glibmm/ustring.h>
#include "xml/repr.h"
+#include "xml/simple-document.h"
#include "xml/simple-node.h"
#include "style.h"
#include "libcroco/cr-sel-eng.h"
@@ -21,20 +22,28 @@ using Inkscape::XML::Document;
struct SPCSSAttrImpl : public SimpleNode, public SPCSSAttr {
public:
- SPCSSAttrImpl() : SimpleNode(g_quark_from_static_string("css")) {}
+ SPCSSAttrImpl(Document *doc)
+ : SimpleNode(g_quark_from_static_string("css"), doc) {}
+ SPCSSAttrImpl(SPCSSAttrImpl const &other, Document *doc)
+ : SimpleNode(other, doc) {}
NodeType type() const { return Inkscape::XML::ELEMENT_NODE; }
protected:
- SimpleNode *_duplicate(Document* /*doc*/) const { return new SPCSSAttrImpl(*this); }
+ SimpleNode *_duplicate(Document* doc) const { return new SPCSSAttrImpl(*this, doc); }
};
static void sp_repr_css_add_components(SPCSSAttr *css, Node *repr, gchar const *attr);
+
SPCSSAttr *
sp_repr_css_attr_new()
{
- return new SPCSSAttrImpl();
+ static Inkscape::XML::Document *attr_doc=NULL;
+ if (!attr_doc) {
+ attr_doc = new Inkscape::XML::SimpleDocument();
+ }
+ return new SPCSSAttrImpl(attr_doc);
}
void
diff --git a/src/xml/simple-document.cpp b/src/xml/simple-document.cpp
index d0aa31939..0a2cb15fb 100644
--- a/src/xml/simple-document.cpp
+++ b/src/xml/simple-document.cpp
@@ -55,19 +55,19 @@ Inkscape::XML::Event *SimpleDocument::commitUndoable() {
}
Node *SimpleDocument::createElement(char const *name) {
- return new ElementNode(g_quark_from_string(name));
+ return new ElementNode(g_quark_from_string(name), this);
}
Node *SimpleDocument::createTextNode(char const *content) {
- return new TextNode(Util::share_string(content));
+ return new TextNode(Util::share_string(content), this);
}
Node *SimpleDocument::createComment(char const *content) {
- return new CommentNode(Util::share_string(content));
+ return new CommentNode(Util::share_string(content), this);
}
Node *SimpleDocument::createPI(char const *target, char const *content) {
- return new PINode(g_quark_from_string(target), Util::share_string(content));
+ return new PINode(g_quark_from_string(target), Util::share_string(content), this);
}
void SimpleDocument::notifyChildAdded(Node &parent,
diff --git a/src/xml/simple-document.h b/src/xml/simple-document.h
index cadda36cb..9b3157add 100644
--- a/src/xml/simple-document.h
+++ b/src/xml/simple-document.h
@@ -30,7 +30,8 @@ class SimpleDocument : public SimpleNode,
{
public:
explicit SimpleDocument()
- : SimpleNode(g_quark_from_static_string("xml")), _in_transaction(false)
+ : SimpleNode(g_quark_from_static_string("xml"), NULL),
+ _in_transaction(false)
{
_initBindings();
}
diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp
index 084547a59..8ddc5b167 100644
--- a/src/xml/simple-node.cpp
+++ b/src/xml/simple-node.cpp
@@ -160,33 +160,32 @@ using Util::cons;
using Util::rest;
using Util::set_rest;
-SimpleNode::SimpleNode(int code)
+SimpleNode::SimpleNode(int code, Document *document)
: Node(), _name(code), _attributes(), _child_count(0),
_cached_positions_valid(false)
{
- this->_document = NULL;
- this->_document = NULL;
+ this->_document = document;
this->_parent = this->_next = NULL;
this->_first_child = this->_last_child = NULL;
_observers.add(_subtree_observers);
}
-SimpleNode::SimpleNode(SimpleNode const &node)
+SimpleNode::SimpleNode(SimpleNode const &node, Document *document)
: Node(),
_cached_position(node._cached_position),
_name(node._name), _attributes(), _content(node._content),
_child_count(node._child_count),
_cached_positions_valid(node._cached_positions_valid)
{
- _document = NULL;
+ _document = document;
_parent = _next = NULL;
_first_child = _last_child = NULL;
for ( Node *child = node._first_child ;
child != NULL ; child = child->next() )
{
- Node *child_copy=child->duplicate(NULL); // FIXME
+ Node *child_copy=child->duplicate(document);
child_copy->_setParent(this);
if (_last_child) {
diff --git a/src/xml/simple-node.h b/src/xml/simple-node.h
index 60bb53454..7c5556f27 100644
--- a/src/xml/simple-node.h
+++ b/src/xml/simple-node.h
@@ -113,8 +113,8 @@ public:
}
protected:
- SimpleNode(int code);
- SimpleNode(SimpleNode const &repr);
+ SimpleNode(int code, Document *document);
+ SimpleNode(SimpleNode const &repr, Document *document);
virtual SimpleNode *_duplicate(Document *doc) const=0;
diff --git a/src/xml/text-node.h b/src/xml/text-node.h
index adcacb604..8fb797276 100644
--- a/src/xml/text-node.h
+++ b/src/xml/text-node.h
@@ -23,16 +23,18 @@ namespace Inkscape {
namespace XML {
struct TextNode : public SimpleNode {
- TextNode(Util::ptr_shared<char> content)
- : SimpleNode(g_quark_from_static_string("string"))
+ TextNode(Util::ptr_shared<char> content, Document *doc)
+ : SimpleNode(g_quark_from_static_string("string"), doc)
{
setContent(content);
}
+ TextNode(TextNode const &other, Document *doc)
+ : SimpleNode(other, doc) {}
Inkscape::XML::NodeType type() const { return Inkscape::XML::TEXT_NODE; }
protected:
- SimpleNode *_duplicate(Document* /*doc*/) const { return new TextNode(*this); }
+ SimpleNode *_duplicate(Document* doc) const { return new TextNode(*this, doc); }
};
}