Code

plumb XML::Documents in everywhere
[inkscape.git] / src / sp-object.h
index b563d8d3b8abd708a263cde9f92fae961533e9b9..ccc063d5f1d688ab323bc609aa8b36867861881a 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __SP_OBJECT_H__
-#define __SP_OBJECT_H__
+#ifndef SP_OBJECT_H_SEEN
+#define SP_OBJECT_H_SEEN
 
 /** \file
  * Abstract base class for all nodes
@@ -53,8 +53,6 @@
 #define SP_OBJECT_PREV(o) (sp_object_prev((SPObject *) (o)))
 #define SP_OBJECT_HREFCOUNT(o) (((SPObject *) (o))->hrefcount)
 #define SP_OBJECT_STYLE(o) (((SPObject *) (o))->style)
-#define SP_OBJECT_TITLE(o) sp_object_title_get((SPObject *) (o))
-#define SP_OBJECT_DESCRIPTION(o) sp_object_description_get((SPObject *) (o))
 
 
 #include <glib-object.h>
@@ -69,6 +67,7 @@
 namespace Inkscape {
 namespace XML {
 class Node;
+class Document;
 }
 }
 
@@ -221,15 +220,15 @@ struct SPObject : public GObject {
     SPObject *lastChild() { return _last_child; }
     SPObject const *lastChild() const { return _last_child; }
 
-    enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow };    
+    enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow };
     /** @brief Retrieves children as a GSList */
     GSList *childList(bool add_ref, Action action = ActionGeneral);
 
     SPObject *appendChildRepr(Inkscape::XML::Node *repr);
 
-    /** @brief Gets the author-visible label for this object. */ 
+    /** @brief Gets the author-visible label for this object. */
     gchar const *label() const;
-    /** @brief Returns a default label for this object. */ 
+    /** @brief Returns a default label for this object. */
     gchar const *defaultLabel() const;
     /** @brief Sets the author-visible label for this object.
      *
@@ -240,14 +239,14 @@ struct SPObject : public GObject {
     void setLabel(gchar const *label);
 
     /** Retrieves the title of this object */
-    gchar const *title() const { return NULL; /* TODO */ }
+    gchar *title() const;
     /** Sets the title of this object */
-    void setTitle(gchar const *title) { /* TODO */ }
+    void setTitle(gchar const *title);
 
     /** Retrieves the description of this object */
-    gchar const *desc() const { return NULL; /* TODO */ }
+    gchar *desc() const;
     /** Sets the description of this object */
-    void setDesc(gchar const *desc) { /* TODO */ }
+    void setDesc(gchar const *desc);
 
     /** @brief Set the policy under which this object will be
      *         orphan-collected.
@@ -376,7 +375,7 @@ struct SPObject : public GObject {
     /** @brief Updates the object's repr based on the object's state.
      *
      *  This method updates the the repr attached to the object to reflect the object's current
-     *  state; see the two-argument version for details.
+     *  state; see the three-argument version for details.
      *
      *  @param flags object write flags that apply to this update
      *
@@ -404,7 +403,7 @@ struct SPObject : public GObject {
      *
      *  @return the updated repr
      */
-    Inkscape::XML::Node *updateRepr(Inkscape::XML::Node *repr, unsigned int flags);
+    Inkscape::XML::Node *updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags);
 
     /** @brief Queues an deferred update of this object's display.
      *
@@ -488,6 +487,14 @@ struct SPObject : public GObject {
     CollectionPolicy _collection_policy;
     gchar *_label;
     mutable gchar *_default_label;
+
+private:
+    // Private member functions used in the definitions of setTitle(),
+    // setDesc(), title() and desc().
+    void setTitleOrDesc(gchar const *value, gchar const *svg_tagname);
+    gchar * getTitleOrDesc(gchar const *svg_tagname) const;
+    SPObject * findFirstChild(gchar const *tagname) const;
+    GString * textualContent() const;
 };
 
 /// The SPObject vtable.
@@ -512,7 +519,7 @@ struct SPObjectClass {
     /* Modification handler */
     void (* modified) (SPObject *object, unsigned int flags);
 
-    Inkscape::XML::Node * (* write) (SPObject *object, Inkscape::XML::Node *repr, unsigned int flags);
+    Inkscape::XML::Node * (* write) (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags);
 };
 
 
@@ -535,17 +542,6 @@ void sp_object_set(SPObject *object, unsigned int key, gchar const *value);
 
 void sp_object_read_attr(SPObject *object, gchar const *key);
 
-/*
- * Get and set descriptive parameters.
- *
- * These are inefficent, so they are not intended to be used interactively.
- */
-
-gchar const *sp_object_title_get(SPObject *object);
-gchar const *sp_object_description_get(SPObject *object);
-unsigned int sp_object_title_set(SPObject *object, gchar const *title);
-unsigned int sp_object_description_set(SPObject *object, gchar const *desc);
-
 /* Public */
 
 gchar const *sp_object_tagName_get(SPObject const *object, SPException *ex);
@@ -556,7 +552,7 @@ void sp_object_removeAttribute(SPObject *object, gchar const *key, SPException *
 /* Style */
 
 gchar const *sp_object_get_style_property(SPObject const *object,
-                                         gchar const *key, gchar const *def);
+                                          gchar const *key, gchar const *def);
 
 Inkscape::Version sp_object_get_sodipodi_version(SPObject *object);
 
@@ -565,7 +561,7 @@ int sp_object_compare_position(SPObject const *first, SPObject const *second);
 SPObject *sp_object_prev(SPObject *child);
 
 
-#endif
+#endif // SP_OBJECT_H_SEEN
 
 
 /*