sp-object.cpp revision 799ef6104315c04f9bffa7e230c768d9485918bd
567N/A#include "helper/sp-marshal.h"
567N/A#include "xml/node-event-vector.h"
567N/A#include "attributes.h"
567N/A#include "attribute-rel-util.h"
567N/A#include "color-profile.h"
567N/A#include "document.h"
567N/A#include "preferences.h"
567N/A#include "sp-factory.h"
567N/A#include "sp-paint-server.h"
705N/A#include "sp-style-elem.h"
606N/A#include "sp-script.h"
606N/A#include "xml/node-fns.h"
606N/A#include "debug/event-tracker.h"
606N/A#include "debug/simple-event.h"
606N/A#include "debug/demangle.h"
567N/A#include "util/longest-common-suffix.h"
705N/A#define noSP_OBJECT_DEBUG_CASCADE
705N/A#define noSP_OBJECT_DEBUG
705N/A#ifdef SP_OBJECT_DEBUG
// A friend class used to set internal members on SPObject so as to not expose settors in SPObject's public API
class SPObjectImpl
if (obj) {
if (id) {
// FIXME: now we create style for all objects, but per SVG, only the following can have style attribute:
// vg, g, defs, desc, title, symbol, use, image, switch, path, rect, circle, ellipse, line, polyline,
// polygon, text, tspan, tref, textPath, altGlyph, glyphRef, marker, linearGradient, radialGradient,
if (this->_successor) {
return id;
return repr;
return repr;
return object;
delete object;
return NULL;
return object;
return NULL;
if (topmost_collectable) {
while (object) {
if ( object == this ) {
return result;
int result = 0;
if ( ancestor ) {
return result;
if ( !cloned ) {
return NULL;
if (add_ref) {
return _label;
if (_label) {
return _label;
if (!_default_label) {
if (getId()) {
return _default_label;
if (SP_IS_STYLE_ELEM(this)) {
} else if (SP_IS_SCRIPT(this)) {
} else if ((! prefs->getBool("/options/cleanupswatches/value", false)) && SP_IS_PAINT_SERVER(this) && static_cast<SPPaintServer*>(this)->isSwatch() ) {
} else if (IS_COLORPROFILE(this)) {
* gradient list when the defs are vacuumed. gradient-vector.cpp
if (propagate) {
if (propagate_descendants) {
this->_sendDeleteSignalRecursive();
if (_successor) {
if (prev) {
if (!next) {
if (old_prev) {
if (!next) {
if (prev) {
if (!next) {
if (prev) {
if (!next) {
return result;
if (ochild) {
void SPObject::order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node * old_ref, Inkscape::XML::Node *new_ref) {
if (!cloned) {
if ( !cloned ) {
} else if (id) {
return def;
this->release();
if (!cloned) {
if (this->id) {
if (this->style) {
return prev;
void SPObject::repr_child_added(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data)
void SPObject::repr_child_removed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node * /*ref*/, gpointer data)
void SPObject::repr_order_changed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data)
switch (key) {
case SP_ATTR_ID:
if (new_id) {
if (new_id) {
case SP_ATTR_INKSCAPE_LABEL:
if (value) {
case SP_ATTR_INKSCAPE_COLLECT:
case SP_ATTR_XML_SPACE:
case SP_ATTR_STYLE:
void SPObject::repr_attr_changed(Inkscape::XML::Node * /*repr*/, gchar const *key, gchar const * /*oldval*/, gchar const * /*newval*/, bool is_interactive, gpointer data)
if (is_interactive) {
void SPObject::repr_content_changed(Inkscape::XML::Node * /*repr*/, gchar const * /*oldcontent*/, gchar const * /*newcontent*/, gpointer data)
switch (space) {
case SP_XML_SPACE_DEFAULT:
case SP_XML_SPACE_PRESERVE:
return NULL;
Inkscape::XML::Node* SPObject::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
char const *xml_space;
if (obj_style) {
g_free( s );
g_free(s);
if (!style_str) {
return repr;
if ( !cloned ) {
if (repr) {
return NULL;
return NULL;
Inkscape::XML::Node * SPObject::updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags)
if (cloned) {
return NULL;
if (update_in_progress) {
bool already_propagated = (!(this->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG)));
if (already_propagated) {
if (parent) {
#ifdef SP_OBJECT_DEBUG_CASCADE
g_print("Update %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *) this), getId(), flags, this->uflags, this->mflags);
this->uflags = 0;
* in case of catching an exception we need to inform the user somehow that the document is corrupted
g_warning("SPObject::updateDisplay(SPCtx *ctx, unsigned int flags) : throw in ((SPObjectClass *) G_OBJECT_GET_CLASS(this))->update(this, ctx, flags);");
bool already_propagated = (!(this->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG)));
if (already_propagated) {
if (parent) {
#ifdef SP_OBJECT_DEBUG_CASCADE
g_print("Modified %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *) this), getId(), flags, this->uflags, this->mflags);
this->mflags = 0;
sp_object_ref(this);
sp_object_unref(this);
return NULL;
return NULL;
static gchar*
static unsigned long count = 0;
count++;
if (local) {
++count;
return buf;
if (style) {
!= NULL )
p += len;
return val;
if (this->parent) {
return def;
if ( elem ) {
return result;
if (!verbatim) {
// If the new title/description is just whitespace,
if (value) {
bool just_whitespace = true;
just_whitespace = false;
if (just_whitespace) {
if (value) {
if (current_value) {
if (!different) {
// delete the title/description(s)
while (elem) {
return child;
return NULL;
return text;