From 1283ff19f8baabbea8fae03faddce5e27acbb110 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 20 Aug 2012 00:38:14 +0200 Subject: Added "virtual pad" to SPTRef. (bzr r11608.1.28) --- src/sp-tref.cpp | 131 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 87 insertions(+), 44 deletions(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 938b7c7cc..0c7e52d60 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -115,9 +115,20 @@ sp_tref_class_init(SPTRefClass *tref_class) item_class->description = sp_tref_description; } +CTRef::CTRef(SPTRef* tref) : CItem(tref) { + this->sptref = tref; +} + +CTRef::~CTRef() { +} + static void sp_tref_init(SPTRef *tref) { + tref->ctref = new CTRef(tref); + tref->citem = tref->ctref; + tref->cobject = tref->ctref; + new (&tref->attributes) TextTagAttributes; tref->href = NULL; @@ -129,7 +140,6 @@ sp_tref_init(SPTRef *tref) tref->uriOriginalRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_tref_href_changed), tref)); } - static void sp_tref_finalize(GObject *obj) { @@ -141,16 +151,10 @@ sp_tref_finalize(GObject *obj) tref->_changed_connection.~connection(); } +void CTRef::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + SPTRef* object = this->sptref; -/** - * Reads the Inkscape::XML::Node, and initializes SPTRef variables. - */ -static void -sp_tref_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ - if (((SPObjectClass *) tref_parent_class)->build) { - ((SPObjectClass *) tref_parent_class)->build(object, document, repr); - } + CItem::onBuild(document, repr); object->readAttr( "xlink:href" ); object->readAttr( "x" ); @@ -161,11 +165,17 @@ sp_tref_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) } /** - * Drops any allocated memory. + * Reads the Inkscape::XML::Node, and initializes SPTRef variables. */ static void -sp_tref_release(SPObject *object) +sp_tref_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { + ((SPTRef*)object)->ctref->onBuild(document, repr); +} + +void CTRef::onRelease() { + SPTRef* object = this->sptref; + SPTRef *tref = SP_TREF(object); tref->attributes.~TextTagAttributes(); @@ -178,16 +188,21 @@ sp_tref_release(SPObject *object) tref->uriOriginalRef->detach(); - if (((SPObjectClass *) tref_parent_class)->release) - ((SPObjectClass *) tref_parent_class)->release(object); + CItem::onRelease(); } /** - * Sets a specific value in the SPTRef. + * Drops any allocated memory. */ static void -sp_tref_set(SPObject *object, unsigned int key, gchar const *value) +sp_tref_release(SPObject *object) { + ((SPTRef*)object)->ctref->onRelease(); +} + +void CTRef::onSet(unsigned int key, const gchar* value) { + SPTRef* object = this->sptref; + debug("0x%p %s(%u): '%s'",object, sp_attribute_name(key),key,value ? value : ""); @@ -225,27 +240,27 @@ sp_tref_set(SPObject *object, unsigned int key, gchar const *value) } } else { // default - if (((SPObjectClass *) tref_parent_class)->set) { - ((SPObjectClass *) tref_parent_class)->set(object, key, value); - } + CItem::onSet(key, value); } - - } /** - * Receives update notifications. Code based on sp_use_update and sp_tspan_update. + * Sets a specific value in the SPTRef. */ static void -sp_tref_update(SPObject *object, SPCtx *ctx, guint flags) +sp_tref_set(SPObject *object, unsigned int key, gchar const *value) { + ((SPTRef*)object)->ctref->onSet(key, value); +} + +void CTRef::onUpdate(SPCtx *ctx, guint flags) { + SPTRef* object = this->sptref; + debug("0x%p",object); SPTRef *tref = SP_TREF(object); - if (((SPObjectClass *) tref_parent_class)->update) { - ((SPObjectClass *) tref_parent_class)->update(object, ctx, flags); - } + CItem::onUpdate(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -259,13 +274,20 @@ sp_tref_update(SPObject *object, SPCtx *ctx, guint flags) child->updateDisplay(ctx, flags); } } - - } +/** + * Receives update notifications. Code based on sp_use_update and sp_tspan_update. + */ static void -sp_tref_modified(SPObject *object, guint flags) +sp_tref_update(SPObject *object, SPCtx *ctx, guint flags) { + ((SPTRef*)object)->ctref->onUpdate(ctx, flags); +} + +void CTRef::onModified(unsigned int flags) { + SPTRef* object = this->sptref; + SPTRef *tref_obj = SP_TREF(object); if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -284,12 +306,15 @@ sp_tref_modified(SPObject *object, guint flags) } } -/** - * Writes its settings to an incoming repr object, if any. - */ -static Inkscape::XML::Node * -sp_tref_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static void +sp_tref_modified(SPObject *object, guint flags) { + ((SPTRef*)object)->ctref->onModified(flags); +} + +Inkscape::XML::Node* CTRef::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPTRef* object = this->sptref; + debug("0x%p",object); SPTRef *tref = SP_TREF(object); @@ -307,19 +332,23 @@ sp_tref_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML: g_free(uri_string); } - if (((SPObjectClass *) tref_parent_class)->write) { - ((SPObjectClass *) tref_parent_class)->write(object, xml_doc, repr, flags); - } + CItem::onWrite(xml_doc, repr, flags); return repr; } -/* - * The code for this function is swiped from the tspan bbox code, since tref should work pretty much the same way +/** + * Writes its settings to an incoming repr object, if any. */ -static Geom::OptRect -sp_tref_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) +static Inkscape::XML::Node * +sp_tref_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + return ((SPTRef*)object)->ctref->onWrite(xml_doc, repr, flags); +} + +Geom::OptRect CTRef::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { + SPTRef* item = this->sptref; + Geom::OptRect bbox; // find out the ancestor text which holds our layout SPObject const *parent_text = item; @@ -343,10 +372,18 @@ sp_tref_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType return bbox; } - -static gchar * -sp_tref_description(SPItem *item) +/* + * The code for this function is swiped from the tspan bbox code, since tref should work pretty much the same way + */ +static Geom::OptRect +sp_tref_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { + return ((SPTRef*)item)->ctref->onBbox(transform, type); +} + +gchar* CTRef::onDescription() { + SPTRef* item = this->sptref; + SPTRef *tref = SP_TREF(item); if (tref) @@ -373,6 +410,12 @@ sp_tref_description(SPItem *item) return g_strdup(_("Orphaned cloned character data")); } +static gchar * +sp_tref_description(SPItem *item) +{ + return ((SPTRef*)item)->ctref->onDescription(); +} + /* For the sigc::connection changes (i.e. when the object being refered to changes) */ static void -- cgit v1.2.3 From 99cb30e28d4ee193f39e23464abbd7630cac8a2d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 6 Oct 2012 23:56:27 +0200 Subject: Added virtual pad to SPFlowtext; removed old calls to virtual SPItem methods. (bzr r11608.1.46) --- src/sp-tref.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 0c7e52d60..4296fd416 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -111,8 +111,8 @@ sp_tref_class_init(SPTRefClass *tref_class) SPItemClass *item_class = (SPItemClass *) tref_class; - item_class->bbox = sp_tref_bbox; - item_class->description = sp_tref_description; +// item_class->bbox = sp_tref_bbox; +// item_class->description = sp_tref_description; } CTRef::CTRef(SPTRef* tref) : CItem(tref) { -- cgit v1.2.3 From a0a8d020201e0e38a63d9aa3dce228d7d9e6fb35 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 14 Mar 2013 12:42:39 +0100 Subject: Various changes. (bzr r11608.1.48) --- src/sp-tref.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 4296fd416..0ec0c3ebc 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -100,7 +100,7 @@ sp_tref_class_init(SPTRefClass *tref_class) tref_parent_class = (SPObjectClass*)g_type_class_peek_parent(tref_class); - sp_object_class->build = sp_tref_build; + //sp_object_class->build = sp_tref_build; sp_object_class->release = sp_tref_release; sp_object_class->write = sp_tref_write; sp_object_class->set = sp_tref_set; -- cgit v1.2.3 From 957c3e4b7909d42c5a13f1b1dd583f877fc32259 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:46:57 +0100 Subject: Removed function pointers from SPObject and subclasses. Added some missing virtual pads for classes that were hidden by preprocessor macros. (bzr r11608.1.55) --- src/sp-tref.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 0ec0c3ebc..58972e078 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -101,11 +101,11 @@ sp_tref_class_init(SPTRefClass *tref_class) tref_parent_class = (SPObjectClass*)g_type_class_peek_parent(tref_class); //sp_object_class->build = sp_tref_build; - sp_object_class->release = sp_tref_release; - sp_object_class->write = sp_tref_write; - sp_object_class->set = sp_tref_set; - sp_object_class->update = sp_tref_update; - sp_object_class->modified = sp_tref_modified; +// sp_object_class->release = sp_tref_release; +// sp_object_class->write = sp_tref_write; +// sp_object_class->set = sp_tref_set; +// sp_object_class->update = sp_tref_update; +// sp_object_class->modified = sp_tref_modified; gobject_class->finalize = sp_tref_finalize; -- cgit v1.2.3 From 7df6616da5ea2debb86838366ddf746841549cdb Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:56:13 +0100 Subject: Renamed virtual function names. (bzr r11608.1.57) --- src/sp-tref.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 8f33a7bd0..7d17f9d3b 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -104,10 +104,10 @@ sp_tref_finalize(GObject *obj) tref->_changed_connection.~connection(); } -void CTRef::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { +void CTRef::build(SPDocument *document, Inkscape::XML::Node *repr) { SPTRef* object = this->sptref; - CItem::onBuild(document, repr); + CItem::build(document, repr); object->readAttr( "xlink:href" ); object->readAttr( "x" ); @@ -117,7 +117,7 @@ void CTRef::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "rotate" ); } -void CTRef::onRelease() { +void CTRef::release() { SPTRef* object = this->sptref; SPTRef *tref = SP_TREF(object); @@ -132,10 +132,10 @@ void CTRef::onRelease() { tref->uriOriginalRef->detach(); - CItem::onRelease(); + CItem::release(); } -void CTRef::onSet(unsigned int key, const gchar* value) { +void CTRef::set(unsigned int key, const gchar* value) { SPTRef* object = this->sptref; debug("0x%p %s(%u): '%s'",object, @@ -175,18 +175,18 @@ void CTRef::onSet(unsigned int key, const gchar* value) { } } else { // default - CItem::onSet(key, value); + CItem::set(key, value); } } -void CTRef::onUpdate(SPCtx *ctx, guint flags) { +void CTRef::update(SPCtx *ctx, guint flags) { SPTRef* object = this->sptref; debug("0x%p",object); SPTRef *tref = SP_TREF(object); - CItem::onUpdate(ctx, flags); + CItem::update(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -202,7 +202,7 @@ void CTRef::onUpdate(SPCtx *ctx, guint flags) { } } -void CTRef::onModified(unsigned int flags) { +void CTRef::modified(unsigned int flags) { SPTRef* object = this->sptref; SPTRef *tref_obj = SP_TREF(object); @@ -223,7 +223,7 @@ void CTRef::onModified(unsigned int flags) { } } -Inkscape::XML::Node* CTRef::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node* CTRef::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPTRef* object = this->sptref; debug("0x%p",object); @@ -243,12 +243,12 @@ Inkscape::XML::Node* CTRef::onWrite(Inkscape::XML::Document *xml_doc, Inkscape:: g_free(uri_string); } - CItem::onWrite(xml_doc, repr, flags); + CItem::write(xml_doc, repr, flags); return repr; } -Geom::OptRect CTRef::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect CTRef::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { SPTRef* item = this->sptref; Geom::OptRect bbox; @@ -274,7 +274,7 @@ Geom::OptRect CTRef::onBbox(Geom::Affine const &transform, SPItem::BBoxType type return bbox; } -gchar* CTRef::onDescription() { +gchar* CTRef::description() { SPTRef* item = this->sptref; SPTRef *tref = SP_TREF(item); -- cgit v1.2.3 From a5d6e692d661f0bf7648e64e8fcb04588bb8f3ab Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 1 Apr 2013 00:07:00 +0200 Subject: Prepared exchange of casting macros. (bzr r11608.1.63) --- src/sp-tref.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 7d17f9d3b..6eee54450 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -77,6 +77,7 @@ static void sp_tref_init(SPTRef *tref) { tref->ctref = new CTRef(tref); + tref->typeHierarchy.insert(typeid(SPTRef)); delete tref->citem; tref->citem = tref->ctref; -- cgit v1.2.3 From 7eb077e4097aed62c11e5b4e97ff4b16039e73fa Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 1 Apr 2013 23:04:54 +0200 Subject: Replaced calls to g_object_(un)ref with sp_object_(un)ref. (bzr r11608.1.65) --- src/sp-tref.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 6eee54450..398304e4c 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -216,11 +216,11 @@ void CTRef::modified(unsigned int flags) { SPObject *child = tref_obj->stringChild; if (child) { - g_object_ref(G_OBJECT(child)); + sp_object_ref(child); if (flags || (child->mflags & SP_OBJECT_MODIFIED_FLAG)) { child->emitModified(flags); } - g_object_unref(G_OBJECT(child)); + sp_object_unref(child); } } -- cgit v1.2.3 From 69f3b6f1abb2bb422935d43262e1e99aab359954 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 01:41:30 +0200 Subject: Added constructors to SP classes. (bzr r11608.1.67) --- src/sp-tref.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 398304e4c..83b0746d8 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -57,7 +57,7 @@ static void sp_tref_finalize(GObject *obj); static void sp_tref_href_changed(SPObject *old_ref, SPObject *ref, SPTRef *tref); static void sp_tref_delete_self(SPObject *deleted, SPTRef *self); -G_DEFINE_TYPE(SPTRef, sp_tref, SP_TYPE_ITEM); +G_DEFINE_TYPE(SPTRef, sp_tref, G_TYPE_OBJECT); static void sp_tref_class_init(SPTRefClass *tref_class) @@ -73,9 +73,9 @@ CTRef::CTRef(SPTRef* tref) : CItem(tref) { CTRef::~CTRef() { } -static void -sp_tref_init(SPTRef *tref) -{ +SPTRef::SPTRef() : SPItem() { + SPTRef* tref = this; + tref->ctref = new CTRef(tref); tref->typeHierarchy.insert(typeid(SPTRef)); @@ -83,6 +83,8 @@ sp_tref_init(SPTRef *tref) tref->citem = tref->ctref; tref->cobject = tref->ctref; + tref->stringChild = NULL; + new (&tref->attributes) TextTagAttributes; tref->href = NULL; @@ -94,6 +96,12 @@ sp_tref_init(SPTRef *tref) tref->uriOriginalRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_tref_href_changed), tref)); } +static void +sp_tref_init(SPTRef *tref) +{ + new (tref) SPTRef(); +} + static void sp_tref_finalize(GObject *obj) { -- cgit v1.2.3 From d1af3566872dfff2aeec84859c87f1f8d13f79df Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 19:14:36 +0200 Subject: Registered classes with new factory. Hkern, Vkern and FeFuncX have to be rewritten, as they aren't real classes. (bzr r11608.1.69) --- src/sp-tref.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 83b0746d8..22ebb5c17 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -35,6 +35,15 @@ #include "xml/node.h" #include "xml/repr.h" +#include "sp-factory.h" + +namespace { + SPObject* createTRef() { + return new SPTRef(); + } + + bool trefRegistered = SPFactory::instance().registerObject("svg:tref", createTRef); +} //#define DEBUG_TREF #ifdef DEBUG_TREF -- cgit v1.2.3 From 8443720ce6429b9beec839e60b8a808595f4ba72 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 23:01:45 +0200 Subject: Cleaned up a bit. Uses some C++11 features. (bzr r11608.1.72) --- src/sp-tref.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 22ebb5c17..e52879a03 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -469,7 +469,7 @@ void sp_tref_update_text(SPTRef *tref) Inkscape::XML::Document *xml_doc = tref->document->getReprDoc(); Inkscape::XML::Node *newStringRepr = xml_doc->createTextNode(charData.c_str()); - tref->stringChild = SP_OBJECT(g_object_new(sp_repr_type_lookup(newStringRepr), NULL)); + tref->stringChild = SPFactory::instance().createObject(*newStringRepr); //SP_OBJECT(g_object_new(sp_repr_type_lookup(newStringRepr), NULL)); // Add this SPString as a child of the tref tref->attach(tref->stringChild, tref->lastChild()); -- cgit v1.2.3 From 19d00efa85cfc42ccae9bd17ef575602f0d22c50 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 19:42:32 +0200 Subject: Merged more classes. (bzr r11608.1.78) --- src/sp-tref.cpp | 234 +++++++++++++++++++++----------------------------------- 1 file changed, 88 insertions(+), 146 deletions(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index e52879a03..1929b6820 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -60,149 +60,99 @@ namespace { static void build_string_from_root(Inkscape::XML::Node *root, Glib::ustring *retString); /* TRef base class */ - -static void sp_tref_finalize(GObject *obj); - static void sp_tref_href_changed(SPObject *old_ref, SPObject *ref, SPTRef *tref); static void sp_tref_delete_self(SPObject *deleted, SPTRef *self); -G_DEFINE_TYPE(SPTRef, sp_tref, G_TYPE_OBJECT); - -static void -sp_tref_class_init(SPTRefClass *tref_class) -{ - GObjectClass *gobject_class = (GObjectClass *) tref_class; - gobject_class->finalize = sp_tref_finalize; -} - -CTRef::CTRef(SPTRef* tref) : CItem(tref) { - this->sptref = tref; -} - -CTRef::~CTRef() { -} - -SPTRef::SPTRef() : SPItem() { - SPTRef* tref = this; +SPTRef::SPTRef() : SPItem(), CItem(this) { + delete this->citem; + this->citem = this; + this->cobject = this; - tref->ctref = new CTRef(tref); - tref->typeHierarchy.insert(typeid(SPTRef)); + this->stringChild = NULL; - delete tref->citem; - tref->citem = tref->ctref; - tref->cobject = tref->ctref; + new (&this->attributes) TextTagAttributes; - tref->stringChild = NULL; + this->href = NULL; + this->uriOriginalRef = new SPTRefReference(this); + new (&this->_delete_connection) sigc::connection(); + new (&this->_changed_connection) sigc::connection(); - new (&tref->attributes) TextTagAttributes; - - tref->href = NULL; - tref->uriOriginalRef = new SPTRefReference(tref); - new (&tref->_delete_connection) sigc::connection(); - new (&tref->_changed_connection) sigc::connection(); - - tref->_changed_connection = - tref->uriOriginalRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_tref_href_changed), tref)); + this->_changed_connection = + this->uriOriginalRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_tref_href_changed), this)); } -static void -sp_tref_init(SPTRef *tref) -{ - new (tref) SPTRef(); -} +SPTRef::~SPTRef() { + delete this->uriOriginalRef; -static void -sp_tref_finalize(GObject *obj) -{ - SPTRef *tref = (SPTRef *) obj; - - delete tref->uriOriginalRef; - - tref->_delete_connection.~connection(); - tref->_changed_connection.~connection(); + this->_delete_connection.~connection(); + this->_changed_connection.~connection(); } -void CTRef::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPTRef* object = this->sptref; - +void SPTRef::build(SPDocument *document, Inkscape::XML::Node *repr) { CItem::build(document, repr); - object->readAttr( "xlink:href" ); - object->readAttr( "x" ); - object->readAttr( "y" ); - object->readAttr( "dx" ); - object->readAttr( "dy" ); - object->readAttr( "rotate" ); + this->readAttr( "xlink:href" ); + this->readAttr( "x" ); + this->readAttr( "y" ); + this->readAttr( "dx" ); + this->readAttr( "dy" ); + this->readAttr( "rotate" ); } -void CTRef::release() { - SPTRef* object = this->sptref; +void SPTRef::release() { + this->attributes.~TextTagAttributes(); - SPTRef *tref = SP_TREF(object); + this->_delete_connection.disconnect(); + this->_changed_connection.disconnect(); - tref->attributes.~TextTagAttributes(); + g_free(this->href); + this->href = NULL; - tref->_delete_connection.disconnect(); - tref->_changed_connection.disconnect(); - - g_free(tref->href); - tref->href = NULL; - - tref->uriOriginalRef->detach(); + this->uriOriginalRef->detach(); CItem::release(); } -void CTRef::set(unsigned int key, const gchar* value) { - SPTRef* object = this->sptref; - - debug("0x%p %s(%u): '%s'",object, +void SPTRef::set(unsigned int key, const gchar* value) { + debug("0x%p %s(%u): '%s'",this, sp_attribute_name(key),key,value ? value : ""); - SPTRef *tref = SP_TREF(object); - - if (tref->attributes.readSingleAttribute(key, value)) { // x, y, dx, dy, rotate - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + if (this->attributes.readSingleAttribute(key, value)) { // x, y, dx, dy, rotate + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } else if (key == SP_ATTR_XLINK_HREF) { // xlink:href if ( !value ) { // No value - g_free(tref->href); - tref->href = NULL; - tref->uriOriginalRef->detach(); - } else if ((tref->href && strcmp(value, tref->href) != 0) || (!tref->href)) { - + g_free(this->href); + this->href = NULL; + this->uriOriginalRef->detach(); + } else if ((this->href && strcmp(value, this->href) != 0) || (!this->href)) { // Value has changed - if ( tref->href ) { - g_free(tref->href); - tref->href = NULL; + if ( this->href ) { + g_free(this->href); + this->href = NULL; } - tref->href = g_strdup(value); + this->href = g_strdup(value); try { - tref->uriOriginalRef->attach(Inkscape::URI(value)); - tref->uriOriginalRef->updateObserver(); + this->uriOriginalRef->attach(Inkscape::URI(value)); + this->uriOriginalRef->updateObserver(); } catch ( Inkscape::BadURIException &e ) { g_warning("%s", e.what()); - tref->uriOriginalRef->detach(); + this->uriOriginalRef->detach(); } // No matter what happened, an update should be in order - tref->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } - } else { // default CItem::set(key, value); } } -void CTRef::update(SPCtx *ctx, guint flags) { - SPTRef* object = this->sptref; - - debug("0x%p",object); - - SPTRef *tref = SP_TREF(object); +void SPTRef::update(SPCtx *ctx, guint flags) { + debug("0x%p",this); CItem::update(ctx, flags); @@ -212,7 +162,8 @@ void CTRef::update(SPCtx *ctx, guint flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - SPObject *child = tref->stringChild; + SPObject *child = this->stringChild; + if (child) { if ( flags || ( child->uflags & SP_OBJECT_MODIFIED_FLAG )) { child->updateDisplay(ctx, flags); @@ -220,42 +171,37 @@ void CTRef::update(SPCtx *ctx, guint flags) { } } -void CTRef::modified(unsigned int flags) { - SPTRef* object = this->sptref; - - SPTRef *tref_obj = SP_TREF(object); - +void SPTRef::modified(unsigned int flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } flags &= SP_OBJECT_MODIFIED_CASCADE; - SPObject *child = tref_obj->stringChild; + SPObject *child = this->stringChild; + if (child) { sp_object_ref(child); + if (flags || (child->mflags & SP_OBJECT_MODIFIED_FLAG)) { child->emitModified(flags); } + sp_object_unref(child); } } -Inkscape::XML::Node* CTRef::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPTRef* object = this->sptref; - - debug("0x%p",object); - - SPTRef *tref = SP_TREF(object); +Inkscape::XML::Node* SPTRef::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + debug("0x%p",this); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:tref"); } - tref->attributes.writeTo(repr); + this->attributes.writeTo(repr); - if (tref->uriOriginalRef->getURI()) { - gchar *uri_string = tref->uriOriginalRef->getURI()->toString(); + if (this->uriOriginalRef->getURI()) { + gchar *uri_string = this->uriOriginalRef->getURI()->toString(); debug("uri_string=%s", uri_string); repr->setAttribute("xlink:href", uri_string); g_free(uri_string); @@ -266,58 +212,54 @@ Inkscape::XML::Node* CTRef::write(Inkscape::XML::Document *xml_doc, Inkscape::XM return repr; } -Geom::OptRect CTRef::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { - SPTRef* item = this->sptref; - +Geom::OptRect SPTRef::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { Geom::OptRect bbox; // find out the ancestor text which holds our layout - SPObject const *parent_text = item; + SPObject const *parent_text = this; + while ( parent_text && !SP_IS_TEXT(parent_text) ) { parent_text = parent_text->parent; } + if (parent_text == NULL) { return bbox; } // get the bbox of our portion of the layout bbox = SP_TEXT(parent_text)->layout.bounds(transform, - sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1); + sp_text_get_length_upto(parent_text, this), sp_text_get_length_upto(this, NULL) - 1); // Add stroke width // FIXME this code is incorrect - if (bbox && type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + if (bbox && type == SPItem::VISUAL_BBOX && !this->style->stroke.isNone()) { double scale = transform.descrim(); - bbox->expandBy(0.5 * item->style->stroke_width.computed * scale); + bbox->expandBy(0.5 * this->style->stroke_width.computed * scale); } + return bbox; } -gchar* CTRef::description() { - SPTRef* item = this->sptref; +gchar* SPTRef::description() { + SPObject *referred = this->getObjectReferredTo(); + + if (this->getObjectReferredTo()) { + char *child_desc; + + if (SP_IS_ITEM(referred)) { + child_desc = SP_ITEM(referred)->description(); + } else { + child_desc = g_strdup(""); + } + + char *ret = g_strdup_printf( + _("Cloned character data%s%s"), + (SP_IS_ITEM(referred) ? _(" from ") : ""), + child_desc); + g_free(child_desc); + + return ret; + } - SPTRef *tref = SP_TREF(item); - - if (tref) - { - SPObject *referred = tref->getObjectReferredTo(); - - if (tref->getObjectReferredTo()) { - char *child_desc; - - if (SP_IS_ITEM(referred)) { - child_desc = SP_ITEM(referred)->description(); - } else { - child_desc = g_strdup(""); - } - - char *ret = g_strdup_printf( - _("Cloned character data%s%s"), - (SP_IS_ITEM(referred) ? _(" from ") : ""), - child_desc); - g_free(child_desc); - return ret; - } - } return g_strdup(_("Orphaned cloned character data")); } -- cgit v1.2.3 From 8073924aacdda310fb7492750f78d5389b3186af Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 22:45:01 +0200 Subject: Merged Item. (bzr r11608.1.81) --- src/sp-tref.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 1929b6820..6c6490ad5 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -63,9 +63,7 @@ static void build_string_from_root(Inkscape::XML::Node *root, Glib::ustring *ret static void sp_tref_href_changed(SPObject *old_ref, SPObject *ref, SPTRef *tref); static void sp_tref_delete_self(SPObject *deleted, SPTRef *self); -SPTRef::SPTRef() : SPItem(), CItem(this) { - delete this->citem; - this->citem = this; +SPTRef::SPTRef() : SPItem() { this->cobject = this; this->stringChild = NULL; @@ -89,7 +87,7 @@ SPTRef::~SPTRef() { } void SPTRef::build(SPDocument *document, Inkscape::XML::Node *repr) { - CItem::build(document, repr); + SPItem::build(document, repr); this->readAttr( "xlink:href" ); this->readAttr( "x" ); @@ -110,7 +108,7 @@ void SPTRef::release() { this->uriOriginalRef->detach(); - CItem::release(); + SPItem::release(); } void SPTRef::set(unsigned int key, const gchar* value) { @@ -147,14 +145,14 @@ void SPTRef::set(unsigned int key, const gchar* value) { this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } else { // default - CItem::set(key, value); + SPItem::set(key, value); } } void SPTRef::update(SPCtx *ctx, guint flags) { debug("0x%p",this); - CItem::update(ctx, flags); + SPItem::update(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -207,7 +205,7 @@ Inkscape::XML::Node* SPTRef::write(Inkscape::XML::Document *xml_doc, Inkscape::X g_free(uri_string); } - CItem::write(xml_doc, repr, flags); + SPItem::write(xml_doc, repr, flags); return repr; } @@ -246,7 +244,7 @@ gchar* SPTRef::description() { char *child_desc; if (SP_IS_ITEM(referred)) { - child_desc = SP_ITEM(referred)->description(); + child_desc = SP_ITEM(referred)->getDetailedDescription(); } else { child_desc = g_strdup(""); } -- cgit v1.2.3 From 27e2102f96a5554bcd5310ec11435d155773b279 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 7 Apr 2013 18:28:22 +0200 Subject: Merge Object and subclasses. Merging of SP- and C-classes complete. (bzr r11608.1.86) --- src/sp-tref.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 6c6490ad5..dc0fac093 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -64,8 +64,6 @@ static void sp_tref_href_changed(SPObject *old_ref, SPObject *ref, SPTRef *tref) static void sp_tref_delete_self(SPObject *deleted, SPTRef *self); SPTRef::SPTRef() : SPItem() { - this->cobject = this; - this->stringChild = NULL; new (&this->attributes) TextTagAttributes; -- cgit v1.2.3 From 8de8047c5e30af8598646d7a66c62dbf290f7c51 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 10 Apr 2013 16:10:04 +0200 Subject: Removed old SPObject factory. (bzr r11608.1.91) --- src/sp-tref.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index dc0fac093..223cf3cec 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -24,7 +24,7 @@ #include "attributes.h" #include "document.h" -#include "sp-object-repr.h" +#include "sp-factory.h" #include "sp-text.h" #include "sp-tspan.h" #include "sp-tref.h" @@ -35,8 +35,6 @@ #include "xml/node.h" #include "xml/repr.h" -#include "sp-factory.h" - namespace { SPObject* createTRef() { return new SPTRef(); -- cgit v1.2.3 From fbb85064cfaaf03cc09bacedb16a8561f61f2b3d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 00:37:18 +0200 Subject: Added prefPaths to contexts; modified SPFactory (bzr r11608.1.94) --- src/sp-tref.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 223cf3cec..87e8498f3 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -405,7 +405,7 @@ void sp_tref_update_text(SPTRef *tref) Inkscape::XML::Document *xml_doc = tref->document->getReprDoc(); Inkscape::XML::Node *newStringRepr = xml_doc->createTextNode(charData.c_str()); - tref->stringChild = SPFactory::instance().createObject(*newStringRepr); //SP_OBJECT(g_object_new(sp_repr_type_lookup(newStringRepr), NULL)); + tref->stringChild = SPFactory::instance().createObject(NodeTraits::getTypeString(*newStringRepr)); // Add this SPString as a child of the tref tref->attach(tref->stringChild, tref->lastChild()); -- cgit v1.2.3 From 127543bae3c0a76770e197c7058a783dea18fe3e Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 31 Jul 2013 23:23:10 +0200 Subject: Removed placement news / explicit destructor calls. (bzr r11608.1.113) --- src/sp-tref.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 87e8498f3..97c446c33 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -64,12 +64,12 @@ static void sp_tref_delete_self(SPObject *deleted, SPTRef *self); SPTRef::SPTRef() : SPItem() { this->stringChild = NULL; - new (&this->attributes) TextTagAttributes; + //new (&this->attributes) TextTagAttributes; this->href = NULL; this->uriOriginalRef = new SPTRefReference(this); - new (&this->_delete_connection) sigc::connection(); - new (&this->_changed_connection) sigc::connection(); + //new (&this->_delete_connection) sigc::connection(); + //new (&this->_changed_connection) sigc::connection(); this->_changed_connection = this->uriOriginalRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_tref_href_changed), this)); @@ -78,8 +78,8 @@ SPTRef::SPTRef() : SPItem() { SPTRef::~SPTRef() { delete this->uriOriginalRef; - this->_delete_connection.~connection(); - this->_changed_connection.~connection(); + //this->_delete_connection.~connection(); + //this->_changed_connection.~connection(); } void SPTRef::build(SPDocument *document, Inkscape::XML::Node *repr) { @@ -94,7 +94,7 @@ void SPTRef::build(SPDocument *document, Inkscape::XML::Node *repr) { } void SPTRef::release() { - this->attributes.~TextTagAttributes(); + //this->attributes.~TextTagAttributes(); this->_delete_connection.disconnect(); this->_changed_connection.disconnect(); -- cgit v1.2.3 From abde5067bcfbb4c0e3ba61c6f69db7925f80600a Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 16 Sep 2013 19:32:58 +0200 Subject: Removed TypeInfo; adjusted Factory to meet code style conventions. (bzr r11608.1.124) --- src/sp-tref.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-tref.cpp') diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 97c446c33..1872cdf7c 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -405,7 +405,7 @@ void sp_tref_update_text(SPTRef *tref) Inkscape::XML::Document *xml_doc = tref->document->getReprDoc(); Inkscape::XML::Node *newStringRepr = xml_doc->createTextNode(charData.c_str()); - tref->stringChild = SPFactory::instance().createObject(NodeTraits::getTypeString(*newStringRepr)); + tref->stringChild = SPFactory::instance().createObject(NodeTraits::get_type_string(*newStringRepr)); // Add this SPString as a child of the tref tref->attach(tref->stringChild, tref->lastChild()); -- cgit v1.2.3