diff --git a/src/sp-object.h b/src/sp-object.h
index b563d8d3b8abd708a263cde9f92fae961533e9b9..59cab2328252d99cebe84bf2b760a5620f6360fd 100644 (file)
--- a/src/sp-object.h
+++ b/src/sp-object.h
-#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
#define SP_OBJECT_WRITE_ALL (1 << 2)
/* Convenience stuff */
-#define SP_OBJECT_ID(o) (((SPObject *) (o))->id)
+#define SP_OBJECT_ID(o) (((SPObject *) (o))->getId())
#define SP_OBJECT_REPR(o) (((SPObject *) (o))->repr)
#define SP_OBJECT_DOCUMENT(o) (((SPObject *) (o))->document)
#define SP_OBJECT_PARENT(o) (((SPObject *) (o))->parent)
#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>
namespace Inkscape {
namespace XML {
class Node;
+class Document;
}
}
SPObject *_last_child; /* Remembered last child */
SPObject *next; /* Next object in linked list */
Inkscape::XML::Node *repr; /* Our xml representation */
+
+private:
gchar *id; /* Our very own unique id */
+public:
+
+ /**
+ * Returns the objects current ID string.
+ */
+ gchar const* getId() const;
/** @brief cleans up an SPObject, releasing its references and
* requesting that references to it be released
/* A non-const version can be similarly constructed if you want one.
* (Don't just cast away the constness, which would be ill-formed.) */
+ SPObject *getNext();
+ SPObject *getPrev();
+
bool hasChildren() const { return ( children != NULL ); }
SPObject *firstChild() { return children; }
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.
*
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 */ }
+ bool setTitle(gchar const *title, bool verbatim=false);
/** 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 */ }
+ bool setDesc(gchar const *desc, bool verbatim=false);
/** @brief Set the policy under which this object will be
* orphan-collected.
/** @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
*
*
* @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.
*
CollectionPolicy _collection_policy;
gchar *_label;
mutable gchar *_default_label;
+
+private:
+ // Private member functions used in the definitions of setTitle(),
+ // setDesc(), title() and desc().
+ bool setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verbatim);
+ gchar * getTitleOrDesc(gchar const *svg_tagname) const;
+ SPObject * findFirstChild(gchar const *tagname) const;
+ GString * textualContent() const;
+
+ friend class SPObjectImpl;
};
/// The SPObject vtable.
/* 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);
};
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,16 +565,14 @@ 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);
-
-Inkscape::Version sp_object_get_sodipodi_version(SPObject *object);
+ gchar const *key, gchar const *def);
int sp_object_compare_position(SPObject const *first, SPObject const *second);
SPObject *sp_object_prev(SPObject *child);
-#endif
+#endif // SP_OBJECT_H_SEEN
/*
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :