From 7dbe11bc23efa5f51a9b84e7d0f6dd16e63e0902 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 27 Oct 2008 13:03:09 -0500 Subject: From trunk (bzr r6885) --- src/xml/node-observer.h | 17 +++++++++++------ src/xml/repr-io.cpp | 7 ++++--- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'src/xml') diff --git a/src/xml/node-observer.h b/src/xml/node-observer.h index 6052e48b6..8f317e2d0 100644 --- a/src/xml/node-observer.h +++ b/src/xml/node-observer.h @@ -29,7 +29,7 @@ namespace XML { /** * @brief Interface for XML node observers * - * This pure abstract class defines an interface for objects that can receive + * This class defines an interface for objects that can receive * XML node state change notifications. The observer has to be registered using * the Node::addObserver() method to be notified of changes of this node only, * or using Node::addSubtreeObserver() to also receive notifications about its @@ -40,6 +40,11 @@ namespace XML { * The method will be called again due to the XML modification performed in it. If you * don't take special precautions to ignore the second call, it will result in infinite * recursion. + * + * The virtual methods of this class do nothing by default, so you don't need to provide + * stubs for things you don't use. A good idea is to make the observer register itself + * on construction and unregister itself on destruction. This will ensure there are + * no dangling references. */ class NodeObserver { public: @@ -56,7 +61,7 @@ public: * @param child The newly added child node * @param prev The node after which the new child was inserted into the sibling order, or NULL */ - virtual void notifyChildAdded(Node &node, Node &child, Node *prev)=0; + virtual void notifyChildAdded(Node &node, Node &child, Node *prev) {} /** * @brief Child removal callback @@ -68,7 +73,7 @@ public: * @param child The removed child node * @param prev The node that was before the removed node in sibling order, or NULL */ - virtual void notifyChildRemoved(Node &node, Node &child, Node *prev)=0; + virtual void notifyChildRemoved(Node &node, Node &child, Node *prev) {} /** * @brief Child order change callback @@ -84,7 +89,7 @@ public: * @param new_prev The node that is before @c child after the order change */ virtual void notifyChildOrderChanged(Node &node, Node &child, - Node *old_prev, Node *new_prev)=0; + Node *old_prev, Node *new_prev) {} /** * @brief Content change callback @@ -98,7 +103,7 @@ public: */ virtual void notifyContentChanged(Node &node, Util::ptr_shared old_content, - Util::ptr_shared new_content)=0; + Util::ptr_shared new_content) {} /** * @brief Attribute change callback @@ -112,7 +117,7 @@ public: */ virtual void notifyAttributeChanged(Node &node, GQuark name, Util::ptr_shared old_value, - Util::ptr_shared new_value)=0; + Util::ptr_shared new_value) {} }; } // namespace XML diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 2a5125375..371af729f 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -29,7 +29,7 @@ #include "io/stringstream.h" #include "io/gzipstream.h" -#include "prefs-utils.h" +#include "preferences.h" using Inkscape::IO::Writer; using Inkscape::Util::List; @@ -511,8 +511,9 @@ void sp_repr_save_writer(Document *doc, Inkscape::IO::Writer *out, gchar const *default_ns) { - int inlineattrs = prefs_get_int_attribute("options.svgoutput", "inlineattrs", 0); - int indent = prefs_get_int_attribute("options.svgoutput", "indent", 2); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool inlineattrs = prefs->getBool("/options/svgoutput/inlineattrs"); + int indent = prefs->getInt("/options/svgoutput/indent", 2); /* fixme: do this The Right Way */ out->writeString( "\n" ); -- cgit v1.2.3