From dc816bdcc37174e67992520342babb5ade6a9081 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 20 Aug 2012 00:54:02 +0200 Subject: Added "virtual pad" to SPUse. (bzr r11608.1.29) --- src/sp-use.cpp | 170 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 116 insertions(+), 54 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index e39f560c3..eb089612b 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -113,9 +113,20 @@ sp_use_class_init(SPUseClass *classname) item_class->snappoints = sp_use_snappoints; } +CUse::CUse(SPUse* use) : CItem(use) { + this->spuse = use; +} + +CUse::~CUse() { +} + static void sp_use_init(SPUse *use) { + use->cuse = new CUse(use); + use->citem = use->cuse; + use->cobject = use->cuse; + use->x.unset(); use->y.unset(); use->width.unset(SVGLength::PERCENT, 1.0, 1.0); @@ -152,12 +163,10 @@ sp_use_finalize(GObject *obj) use->_transformed_connection.~connection(); } -static void -sp_use_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ - if (((SPObjectClass *) parent_class)->build) { - (* ((SPObjectClass *) parent_class)->build)(object, document, repr); - } +void CUse::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + SPUse* object = this->spuse; + + CItem::onBuild(document, repr); object->readAttr( "x" ); object->readAttr( "y" ); @@ -171,9 +180,14 @@ sp_use_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) } static void -sp_use_release(SPObject *object) +sp_use_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - SPUse *use = SP_USE(object); + ((SPUse*)object)->cuse->onBuild(document, repr); +} + +void CUse::onRelease() { + SPUse *use = this->spuse; + SPUse* object = use; if (use->child) { object->detach(use->child); @@ -189,15 +203,18 @@ sp_use_release(SPObject *object) use->ref->detach(); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); - } + CItem::onRelease(); } static void -sp_use_set(SPObject *object, unsigned key, gchar const *value) +sp_use_release(SPObject *object) { - SPUse *use = SP_USE(object); + ((SPUse*)object)->cuse->onRelease(); +} + +void CUse::onSet(unsigned int key, const gchar* value) { + SPUse *use = this->spuse; + SPUse* object = use; switch (key) { case SP_ATTR_X: @@ -242,25 +259,25 @@ sp_use_set(SPObject *object, unsigned key, gchar const *value) } default: - if (((SPObjectClass *) parent_class)->set) { - ((SPObjectClass *) parent_class)->set(object, key, value); - } + CItem::onSet(key, value); break; } } -static Inkscape::XML::Node * -sp_use_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static void +sp_use_set(SPObject *object, unsigned key, gchar const *value) { - SPUse *use = SP_USE(object); + ((SPUse*)object)->cuse->onSet(key, value); +} + +Inkscape::XML::Node* CUse::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPUse *use = this->spuse; if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:use"); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); - } + CItem::onWrite(xml_doc, repr, flags); sp_repr_set_svg_double(repr, "x", use->x.computed); sp_repr_set_svg_double(repr, "y", use->y.computed); @@ -276,10 +293,15 @@ sp_use_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML:: return repr; } -static Geom::OptRect -sp_use_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) +static Inkscape::XML::Node * +sp_use_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPUse const *use = SP_USE(item); + return ((SPUse*)object)->cuse->onWrite(xml_doc, repr, flags); +} + +Geom::OptRect CUse::onBbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) { + SPUse const *use = this->spuse; + Geom::OptRect bbox; if (use->child && SP_IS_ITEM(use->child)) { @@ -288,16 +310,21 @@ sp_use_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType * Geom::Translate(use->x.computed, use->y.computed) * transform ); - bbox = child->bounds(type, ct); + bbox = child->bounds(bboxtype, ct); } return bbox; } -static void -sp_use_print(SPItem *item, SPPrintContext *ctx) +static Geom::OptRect +sp_use_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { + return ((SPUse*)item)->cuse->onBbox(transform, type); +} + +void CUse::onPrint(SPPrintContext* ctx) { + SPUse *use = this->spuse; + bool translated = false; - SPUse *use = SP_USE(item); if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) { Geom::Affine tp(Geom::Translate(use->x.computed, use->y.computed)); @@ -314,10 +341,14 @@ sp_use_print(SPItem *item, SPPrintContext *ctx) } } -static gchar * -sp_use_description(SPItem *item) +static void +sp_use_print(SPItem *item, SPPrintContext *ctx) { - SPUse *use = SP_USE(item); + ((SPUse*)item)->cuse->onPrint(ctx); +} + +gchar* CUse::onDescription() { + SPUse *use = this->spuse; char *ret; if (use->child) { @@ -341,10 +372,15 @@ sp_use_description(SPItem *item) } } -static Inkscape::DrawingItem * -sp_use_show(SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags) +static gchar * +sp_use_description(SPItem *item) { - SPUse *use = SP_USE(item); + return ((SPUse*)item)->cuse->onDescription(); +} + +Inkscape::DrawingItem* CUse::onShow(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { + SPUse *use = this->spuse; + SPUse* item = use; Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); ai->setPickChildren(false); @@ -363,18 +399,26 @@ sp_use_show(SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned fla return ai; } -static void -sp_use_hide(SPItem *item, unsigned key) +static Inkscape::DrawingItem * +sp_use_show(SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags) { - SPUse *use = SP_USE(item); + return ((SPUse*)item)->cuse->onShow(drawing, key, flags); +} + +void CUse::onHide(unsigned int key) { + SPUse *use = this->spuse; if (use->child) { SP_ITEM(use->child)->invoke_hide(key); } - if (((SPItemClass *) parent_class)->hide) { - ((SPItemClass *) parent_class)->hide(item, key); - } + CItem::onHide(key); +} + +static void +sp_use_hide(SPItem *item, unsigned key) +{ + ((SPUse*)item)->cuse->onHide(key); } /** @@ -569,16 +613,15 @@ sp_use_delete_self(SPObject */*deleted*/, SPUse *self) } } -static void -sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags) -{ +void CUse::onUpdate(SPCtx *ctx, unsigned flags) { + SPUse* object = this->spuse; + SPItem *item = SP_ITEM(object); SPUse *use = SP_USE(object); SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx cctx = *ictx; - if (((SPObjectClass *) (parent_class))->update) - ((SPObjectClass *) (parent_class))->update(object, ctx, flags); + CItem::onUpdate(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -633,8 +676,14 @@ sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags) } static void -sp_use_modified(SPObject *object, guint flags) +sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags) { + ((SPUse*)object)->cuse->onUpdate(ctx, flags); +} + +void CUse::onModified(unsigned int flags) { + SPUse* object = this->spuse; + SPUse *use_obj = SP_USE(object); if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -659,6 +708,12 @@ sp_use_modified(SPObject *object, guint flags) } } +static void +sp_use_modified(SPObject *object, guint flags) +{ + return ((SPUse*)object)->cuse->onModified(flags); +} + SPItem *sp_use_unlink(SPUse *use) { if (!use) { @@ -752,9 +807,9 @@ SPItem *sp_use_get_original(SPUse *use) return ref; } -static void -sp_use_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) -{ +void CUse::onSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { + SPUse* item = this->spuse; + g_assert (item != NULL); g_assert (SP_IS_ITEM(item)); g_assert (SP_IS_USE(item)); @@ -764,10 +819,17 @@ sp_use_snappoints(SPItem const *item, std::vector if (!root) return; - SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(root); - if (item_class.snappoints) { - item_class.snappoints(root, p, snapprefs); - } +// SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(root); +// if (item_class.snappoints) { +// item_class.snappoints(root, p, snapprefs); +// } + root->citem->onSnappoints(p, snapprefs); +} + +static void +sp_use_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) +{ + ((SPUse*)item)->cuse->onSnappoints(p, snapprefs); } -- cgit v1.2.3 From a6ee236472ac07f5719e41bc396163d485757dc6 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 21 Aug 2012 14:41:57 +0200 Subject: Fixed some virtual function calls in SPItem and SPUse that led to crashes as they were not implemented in the base class. (bzr r11608.1.36) --- src/sp-use.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index eb089612b..1abda0d05 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -412,7 +412,12 @@ void CUse::onHide(unsigned int key) { SP_ITEM(use->child)->invoke_hide(key); } - CItem::onHide(key); + // CPPIFY: This doesn't make no sense. + // CItem::onHide is pure. What was the idea behind these lines? +// if (((SPItemClass *) parent_class)->hide) { +// ((SPItemClass *) parent_class)->hide(item, key); +// } +// CItem::onHide(key); } 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-use.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 1abda0d05..a7e3a7b36 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -105,12 +105,12 @@ sp_use_class_init(SPUseClass *classname) sp_object_class->update = sp_use_update; sp_object_class->modified = sp_use_modified; - item_class->bbox = sp_use_bbox; - item_class->description = sp_use_description; - item_class->print = sp_use_print; - item_class->show = sp_use_show; - item_class->hide = sp_use_hide; - item_class->snappoints = sp_use_snappoints; +// item_class->bbox = sp_use_bbox; +// item_class->description = sp_use_description; +// item_class->print = sp_use_print; +// item_class->show = sp_use_show; +// item_class->hide = sp_use_hide; +// item_class->snappoints = sp_use_snappoints; } CUse::CUse(SPUse* use) : CItem(use) { -- 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-use.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index a7e3a7b36..c85029089 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -98,7 +98,7 @@ sp_use_class_init(SPUseClass *classname) gobject_class->finalize = sp_use_finalize; - sp_object_class->build = sp_use_build; + //sp_object_class->build = sp_use_build; sp_object_class->release = sp_use_release; sp_object_class->set = sp_use_set; sp_object_class->write = sp_use_write; -- 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-use.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index c85029089..250ed9565 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -99,11 +99,11 @@ sp_use_class_init(SPUseClass *classname) gobject_class->finalize = sp_use_finalize; //sp_object_class->build = sp_use_build; - sp_object_class->release = sp_use_release; - sp_object_class->set = sp_use_set; - sp_object_class->write = sp_use_write; - sp_object_class->update = sp_use_update; - sp_object_class->modified = sp_use_modified; +// sp_object_class->release = sp_use_release; +// sp_object_class->set = sp_use_set; +// sp_object_class->write = sp_use_write; +// sp_object_class->update = sp_use_update; +// sp_object_class->modified = sp_use_modified; // item_class->bbox = sp_use_bbox; // item_class->description = sp_use_description; -- 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-use.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index c26297195..f3c478194 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -108,10 +108,10 @@ sp_use_finalize(GObject *obj) use->_transformed_connection.~connection(); } -void CUse::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { +void CUse::build(SPDocument *document, Inkscape::XML::Node *repr) { SPUse* object = this->spuse; - CItem::onBuild(document, repr); + CItem::build(document, repr); object->readAttr( "x" ); object->readAttr( "y" ); @@ -124,7 +124,7 @@ void CUse::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { // which will call sp_use_href_changed, and that will take care of the child } -void CUse::onRelease() { +void CUse::release() { SPUse *use = this->spuse; SPUse* object = use; @@ -142,10 +142,10 @@ void CUse::onRelease() { use->ref->detach(); - CItem::onRelease(); + CItem::release(); } -void CUse::onSet(unsigned int key, const gchar* value) { +void CUse::set(unsigned int key, const gchar* value) { SPUse *use = this->spuse; SPUse* object = use; @@ -192,19 +192,19 @@ void CUse::onSet(unsigned int key, const gchar* value) { } default: - CItem::onSet(key, value); + CItem::set(key, value); break; } } -Inkscape::XML::Node* CUse::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node* CUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPUse *use = this->spuse; if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:use"); } - CItem::onWrite(xml_doc, repr, flags); + CItem::write(xml_doc, repr, flags); sp_repr_set_svg_double(repr, "x", use->x.computed); sp_repr_set_svg_double(repr, "y", use->y.computed); @@ -220,7 +220,7 @@ Inkscape::XML::Node* CUse::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::X return repr; } -Geom::OptRect CUse::onBbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) { +Geom::OptRect CUse::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) { SPUse const *use = this->spuse; Geom::OptRect bbox; @@ -236,7 +236,7 @@ Geom::OptRect CUse::onBbox(Geom::Affine const &transform, SPItem::BBoxType bboxt return bbox; } -void CUse::onPrint(SPPrintContext* ctx) { +void CUse::print(SPPrintContext* ctx) { SPUse *use = this->spuse; bool translated = false; @@ -256,7 +256,7 @@ void CUse::onPrint(SPPrintContext* ctx) { } } -gchar* CUse::onDescription() { +gchar* CUse::description() { SPUse *use = this->spuse; char *ret; @@ -289,7 +289,7 @@ gchar* CUse::onDescription() { } } -Inkscape::DrawingItem* CUse::onShow(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { +Inkscape::DrawingItem* CUse::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { SPUse *use = this->spuse; SPUse* item = use; @@ -310,7 +310,7 @@ Inkscape::DrawingItem* CUse::onShow(Inkscape::Drawing &drawing, unsigned int key return ai; } -void CUse::onHide(unsigned int key) { +void CUse::hide(unsigned int key) { SPUse *use = this->spuse; if (use->child) { @@ -513,7 +513,7 @@ sp_use_delete_self(SPObject */*deleted*/, SPUse *self) } } -void CUse::onUpdate(SPCtx *ctx, unsigned flags) { +void CUse::update(SPCtx *ctx, unsigned flags) { SPUse* object = this->spuse; SPItem *item = SP_ITEM(object); @@ -521,7 +521,7 @@ void CUse::onUpdate(SPCtx *ctx, unsigned flags) { SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx cctx = *ictx; - CItem::onUpdate(ctx, flags); + CItem::update(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -575,7 +575,7 @@ void CUse::onUpdate(SPCtx *ctx, unsigned flags) { } } -void CUse::onModified(unsigned int flags) { +void CUse::modified(unsigned int flags) { SPUse* object = this->spuse; SPUse *use_obj = SP_USE(object); @@ -695,7 +695,7 @@ SPItem *sp_use_get_original(SPUse *use) return ref; } -void CUse::onSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { +void CUse::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { SPUse* item = this->spuse; g_assert (item != NULL); @@ -707,7 +707,7 @@ void CUse::onSnappoints(std::vector &p, Inkscape:: if (!root) return; - root->citem->onSnappoints(p, snapprefs); + root->citem->snappoints(p, snapprefs); } -- 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-use.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index f3c478194..c195b34e9 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -67,6 +67,7 @@ static void sp_use_init(SPUse *use) { use->cuse = new CUse(use); + use->typeHierarchy.insert(typeid(SPUse)); delete use->citem; use->citem = use->cuse; -- 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-use.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index c195b34e9..64a167014 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -554,7 +554,7 @@ void CUse::update(SPCtx *ctx, unsigned flags) { flags&=~SP_OBJECT_USER_MODIFIED_FLAG_B; if (use->child) { - g_object_ref(G_OBJECT(use->child)); + sp_object_ref(use->child); if (flags || (use->child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { if (SP_IS_ITEM(use->child)) { SPItem const &chi = *SP_ITEM(use->child); @@ -565,7 +565,7 @@ void CUse::update(SPCtx *ctx, unsigned flags) { use->child->updateDisplay(ctx, flags); } } - g_object_unref(G_OBJECT(use->child)); + sp_object_unref(use->child); } /* As last step set additional transform of arena group */ @@ -595,11 +595,11 @@ void CUse::modified(unsigned int flags) { SPObject *child = use_obj->child; if (child) { - g_object_ref(G_OBJECT(child)); + sp_object_ref(child); if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_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-use.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 64a167014..f146ef1db 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -47,7 +47,7 @@ static void sp_use_delete_self(SPObject *deleted, SPUse *self); //void m_print(gchar *say, Geom::Affine m) //{ g_print("%s %g %g %g %g %g %g\n", say, m[0], m[1], m[2], m[3], m[4], m[5]); } -G_DEFINE_TYPE(SPUse, sp_use, SP_TYPE_ITEM); +G_DEFINE_TYPE(SPUse, sp_use, G_TYPE_OBJECT); static void sp_use_class_init(SPUseClass *classname) @@ -63,9 +63,9 @@ CUse::CUse(SPUse* use) : CItem(use) { CUse::~CUse() { } -static void -sp_use_init(SPUse *use) -{ +SPUse::SPUse() : SPItem() { + SPUse* use = this; + use->cuse = new CUse(use); use->typeHierarchy.insert(typeid(SPUse)); @@ -73,6 +73,8 @@ sp_use_init(SPUse *use) use->citem = use->cuse; use->cobject = use->cuse; + use->child = NULL; + use->x.unset(); use->y.unset(); use->width.unset(SVGLength::PERCENT, 1.0, 1.0); @@ -89,6 +91,12 @@ sp_use_init(SPUse *use) use->_changed_connection = use->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_use_href_changed), use)); } +static void +sp_use_init(SPUse *use) +{ + new (use) SPUse(); +} + static void sp_use_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-use.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index f146ef1db..5b1a1e880 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -47,6 +47,16 @@ static void sp_use_delete_self(SPObject *deleted, SPUse *self); //void m_print(gchar *say, Geom::Affine m) //{ g_print("%s %g %g %g %g %g %g\n", say, m[0], m[1], m[2], m[3], m[4], m[5]); } +#include "sp-factory.h" + +namespace { + SPObject* createUse() { + return new SPUse(); + } + + bool useRegistered = SPFactory::instance().registerObject("svg:use", createUse); +} + G_DEFINE_TYPE(SPUse, sp_use, G_TYPE_OBJECT); static void -- cgit v1.2.3 From 0a7e23844c3a43203de3f5207aecb278e84ee739 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 20:45:20 +0200 Subject: Added virtual destructor to SPObject. Switched to new factory. Replaced some casts. Inkscape seems stable, car.svgz renders correctly to png. (bzr r11608.1.70) --- src/sp-use.cpp | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 5b1a1e880..65c8602df 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -36,6 +36,8 @@ #include "sp-use.h" #include "sp-use-reference.h" +#include "sp-factory.h" + /* fixme: */ static void sp_use_finalize(GObject *obj); @@ -489,11 +491,29 @@ sp_use_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUse *use) SPItem *refobj = use->ref->getObject(); if (refobj) { Inkscape::XML::Node *childrepr = refobj->getRepr(); - GType type = sp_repr_type_lookup(childrepr); - g_return_if_fail(type > G_TYPE_NONE); - if (g_type_is_a(type, SP_TYPE_ITEM)) { - use->child = (SPObject*) g_object_new(type, 0); - use->attach(use->child, use->lastChild()); + +// GType type = sp_repr_type_lookup(childrepr); +// g_return_if_fail(type > G_TYPE_NONE); +// if (g_type_is_a(type, SP_TYPE_ITEM)) { +// use->child = (SPObject*) g_object_new(type, 0); +// use->attach(use->child, use->lastChild()); +// sp_object_unref(use->child, use); +// (use->child)->invoke_build(use->document, childrepr, TRUE); +// +// for (SPItemView *v = item->display; v != NULL; v = v->next) { +// Inkscape::DrawingItem *ai; +// ai = SP_ITEM(use->child)->invoke_show(v->arenaitem->drawing(), v->key, v->flags); +// if (ai) { +// v->arenaitem->prependChild(ai); +// } +// } +// } + + SPObject* obj = SPFactory::instance().createObject(*childrepr); + if (SP_IS_ITEM(obj)) { + use->child = obj; + + use->attach(use->child, use->lastChild()); sp_object_unref(use->child, use); (use->child)->invoke_build(use->document, childrepr, TRUE); @@ -504,8 +524,10 @@ sp_use_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUse *use) v->arenaitem->prependChild(ai); } } - + } else { + delete obj; } + use->_delete_connection = refobj->connectDelete(sigc::bind(sigc::ptr_fun(&sp_use_delete_self), use)); use->_transformed_connection = SP_ITEM(refobj)->connectTransformed(sigc::bind(sigc::ptr_fun(&sp_use_move_compensate), use)); } -- 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-use.cpp | 336 +++++++++++++++++++++++++-------------------------------- 1 file changed, 145 insertions(+), 191 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 65c8602df..8b73844e5 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -39,16 +39,9 @@ #include "sp-factory.h" /* fixme: */ - -static void sp_use_finalize(GObject *obj); - static void sp_use_href_changed(SPObject *old_ref, SPObject *ref, SPUse *use); - static void sp_use_delete_self(SPObject *deleted, SPUse *self); -//void m_print(gchar *say, Geom::Affine m) -//{ g_print("%s %g %g %g %g %g %g\n", say, m[0], m[1], m[2], m[3], m[4], m[5]); } - #include "sp-factory.h" namespace { @@ -59,154 +52,119 @@ namespace { bool useRegistered = SPFactory::instance().registerObject("svg:use", createUse); } -G_DEFINE_TYPE(SPUse, sp_use, G_TYPE_OBJECT); - -static void -sp_use_class_init(SPUseClass *classname) -{ - GObjectClass *gobject_class = (GObjectClass *) classname; - gobject_class->finalize = sp_use_finalize; -} +SPUse::SPUse() : SPItem(), CItem(this) { + delete this->citem; + this->citem = this; + this->cobject = this; -CUse::CUse(SPUse* use) : CItem(use) { - this->spuse = use; -} + this->child = NULL; -CUse::~CUse() { -} + this->x.unset(); + this->y.unset(); + this->width.unset(SVGLength::PERCENT, 1.0, 1.0); + this->height.unset(SVGLength::PERCENT, 1.0, 1.0); + this->href = NULL; -SPUse::SPUse() : SPItem() { - SPUse* use = this; + new (&this->_delete_connection) sigc::connection(); + new (&this->_changed_connection) sigc::connection(); - use->cuse = new CUse(use); - use->typeHierarchy.insert(typeid(SPUse)); + new (&this->_transformed_connection) sigc::connection(); - delete use->citem; - use->citem = use->cuse; - use->cobject = use->cuse; + this->ref = new SPUseReference(this); - use->child = NULL; - - use->x.unset(); - use->y.unset(); - use->width.unset(SVGLength::PERCENT, 1.0, 1.0); - use->height.unset(SVGLength::PERCENT, 1.0, 1.0); - use->href = NULL; - - new (&use->_delete_connection) sigc::connection(); - new (&use->_changed_connection) sigc::connection(); - - new (&use->_transformed_connection) sigc::connection(); - - use->ref = new SPUseReference(use); - - use->_changed_connection = use->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_use_href_changed), use)); -} - -static void -sp_use_init(SPUse *use) -{ - new (use) SPUse(); + this->_changed_connection = this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_use_href_changed), this)); } -static void -sp_use_finalize(GObject *obj) -{ - SPUse *use = reinterpret_cast(obj); - - if (use->child) { - use->detach(use->child); - use->child = NULL; +SPUse::~SPUse() { + if (this->child) { + this->detach(this->child); + this->child = NULL; } - use->ref->detach(); - delete use->ref; - use->ref = 0; + this->ref->detach(); + delete this->ref; + this->ref = 0; - use->_delete_connection.~connection(); - use->_changed_connection.~connection(); + this->_delete_connection.~connection(); + this->_changed_connection.~connection(); - use->_transformed_connection.~connection(); + this->_transformed_connection.~connection(); } -void CUse::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPUse* object = this->spuse; - +void SPUse::build(SPDocument *document, Inkscape::XML::Node *repr) { CItem::build(document, repr); - object->readAttr( "x" ); - object->readAttr( "y" ); - object->readAttr( "width" ); - object->readAttr( "height" ); - object->readAttr( "xlink:href" ); + this->readAttr( "x" ); + this->readAttr( "y" ); + this->readAttr( "width" ); + this->readAttr( "height" ); + this->readAttr( "xlink:href" ); // We don't need to create child here: // reading xlink:href will attach ref, and that will cause the changed signal to be emitted, // which will call sp_use_href_changed, and that will take care of the child } -void CUse::release() { - SPUse *use = this->spuse; - SPUse* object = use; - - if (use->child) { - object->detach(use->child); - use->child = NULL; +void SPUse::release() { + if (this->child) { + this->detach(this->child); + this->child = NULL; } - use->_delete_connection.disconnect(); - use->_changed_connection.disconnect(); - use->_transformed_connection.disconnect(); + this->_delete_connection.disconnect(); + this->_changed_connection.disconnect(); + this->_transformed_connection.disconnect(); - g_free(use->href); - use->href = NULL; + g_free(this->href); + this->href = NULL; - use->ref->detach(); + this->ref->detach(); CItem::release(); } -void CUse::set(unsigned int key, const gchar* value) { - SPUse *use = this->spuse; - SPUse* object = use; - +void SPUse::set(unsigned int key, const gchar* value) { switch (key) { case SP_ATTR_X: - use->x.readOrUnset(value); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->x.readOrUnset(value); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; + case SP_ATTR_Y: - use->y.readOrUnset(value); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->y.readOrUnset(value); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; + case SP_ATTR_WIDTH: - use->width.readOrUnset(value, SVGLength::PERCENT, 1.0, 1.0); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->width.readOrUnset(value, SVGLength::PERCENT, 1.0, 1.0); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; + case SP_ATTR_HEIGHT: - use->height.readOrUnset(value, SVGLength::PERCENT, 1.0, 1.0); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->height.readOrUnset(value, SVGLength::PERCENT, 1.0, 1.0); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_XLINK_HREF: { - if ( value && use->href && ( strcmp(value, use->href) == 0 ) ) { + if ( value && this->href && ( strcmp(value, this->href) == 0 ) ) { /* No change, do nothing. */ } else { - g_free(use->href); - use->href = NULL; + g_free(this->href); + this->href = NULL; + if (value) { // First, set the href field, because sp_use_href_changed will need it. - use->href = g_strdup(value); + this->href = g_strdup(value); // Now do the attaching, which emits the changed signal. try { - use->ref->attach(Inkscape::URI(value)); + this->ref->attach(Inkscape::URI(value)); } catch (Inkscape::BadURIException &e) { g_warning("%s", e.what()); - use->ref->detach(); + this->ref->detach(); } } else { - use->ref->detach(); + this->ref->detach(); } } break; @@ -218,22 +176,20 @@ void CUse::set(unsigned int key, const gchar* value) { } } -Inkscape::XML::Node* CUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPUse *use = this->spuse; - +Inkscape::XML::Node* SPUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:use"); } CItem::write(xml_doc, repr, flags); - sp_repr_set_svg_double(repr, "x", use->x.computed); - sp_repr_set_svg_double(repr, "y", use->y.computed); - sp_repr_set_svg_double(repr, "width", use->width.computed); - sp_repr_set_svg_double(repr, "height", use->height.computed); + sp_repr_set_svg_double(repr, "x", this->x.computed); + sp_repr_set_svg_double(repr, "y", this->y.computed); + sp_repr_set_svg_double(repr, "width", this->width.computed); + sp_repr_set_svg_double(repr, "height", this->height.computed); - if (use->ref->getURI()) { - gchar *uri_string = use->ref->getURI()->toString(); + if (this->ref->getURI()) { + gchar *uri_string = this->ref->getURI()->toString(); repr->setAttribute("xlink:href", uri_string); g_free(uri_string); } @@ -241,35 +197,33 @@ Inkscape::XML::Node* CUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XML return repr; } -Geom::OptRect CUse::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) { - SPUse const *use = this->spuse; - +Geom::OptRect SPUse::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) { Geom::OptRect bbox; - if (use->child && SP_IS_ITEM(use->child)) { - SPItem *child = SP_ITEM(use->child); + if (this->child && SP_IS_ITEM(this->child)) { + SPItem *child = SP_ITEM(this->child); Geom::Affine const ct( child->transform - * Geom::Translate(use->x.computed, - use->y.computed) + * Geom::Translate(this->x.computed, + this->y.computed) * transform ); + bbox = child->bounds(bboxtype, ct); } + return bbox; } -void CUse::print(SPPrintContext* ctx) { - SPUse *use = this->spuse; - +void SPUse::print(SPPrintContext* ctx) { bool translated = false; - if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) { - Geom::Affine tp(Geom::Translate(use->x.computed, use->y.computed)); + if ((this->x._set && this->x.computed != 0) || (this->y._set && this->y.computed != 0)) { + Geom::Affine tp(Geom::Translate(this->x.computed, this->y.computed)); sp_print_bind(ctx, tp, 1.0); translated = true; } - if (use->child && SP_IS_ITEM(use->child)) { - SP_ITEM(use->child)->invoke_print(ctx); + if (this->child && SP_IS_ITEM(this->child)) { + SP_ITEM(this->child)->invoke_print(ctx); } if (translated) { @@ -277,20 +231,19 @@ void CUse::print(SPPrintContext* ctx) { } } -gchar* CUse::description() { - SPUse *use = this->spuse; - +gchar* SPUse::description() { char *ret; - if (use->child) { - if( SP_IS_SYMBOL( use->child ) ) { - //char *symbol_desc = SP_ITEM(use->child)->description(); + if (this->child) { + if( SP_IS_SYMBOL( this->child ) ) { + //char *symbol_desc = SP_ITEM(this->child)->description(); //g_free(symbol_desc); return g_strdup(_("Clone of Symbol")); //return g_strdup_printf(_("Clone of Symbol: %s"), symbol_desc ); } static unsigned recursion_depth = 0; + if (recursion_depth >= 4) { /* TRANSLATORS: Used for statusbar description for long chains: * "Clone of: Clone of: ... in Layer 1". */ @@ -298,44 +251,41 @@ gchar* CUse::description() { /* We could do better, e.g. chasing the href chain until we reach something other than * a , and giving its description. */ } + ++recursion_depth; - char *child_desc = SP_ITEM(use->child)->description(); + char *child_desc = SP_ITEM(this->child)->description(); --recursion_depth; ret = g_strdup_printf(_("Clone of: %s"), child_desc); g_free(child_desc); + return ret; } else { return g_strdup(_("Orphaned clone")); } } -Inkscape::DrawingItem* CUse::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { - SPUse *use = this->spuse; - SPUse* item = use; - +Inkscape::DrawingItem* SPUse::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); ai->setPickChildren(false); - ai->setStyle(item->style); + ai->setStyle(this->style); - if (use->child) { - Inkscape::DrawingItem *ac = SP_ITEM(use->child)->invoke_show(drawing, key, flags); + if (this->child) { + Inkscape::DrawingItem *ac = SP_ITEM(this->child)->invoke_show(drawing, key, flags); if (ac) { ai->prependChild(ac); } - Geom::Translate t(use->x.computed, - use->y.computed); + + Geom::Translate t(this->x.computed, this->y.computed); ai->setChildTransform(t); } return ai; } -void CUse::hide(unsigned int key) { - SPUse *use = this->spuse; - - if (use->child) { - SP_ITEM(use->child)->invoke_hide(key); +void SPUse::hide(unsigned int key) { + if (this->child) { + SP_ITEM(this->child)->invoke_hide(key); } // CItem::onHide(key); @@ -554,11 +504,7 @@ sp_use_delete_self(SPObject */*deleted*/, SPUse *self) } } -void CUse::update(SPCtx *ctx, unsigned flags) { - SPUse* object = this->spuse; - - SPItem *item = SP_ITEM(object); - SPUse *use = SP_USE(object); +void SPUse::update(SPCtx *ctx, unsigned flags) { SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx cctx = *ictx; @@ -567,78 +513,85 @@ void CUse::update(SPCtx *ctx, unsigned flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } + flags &= SP_OBJECT_MODIFIED_CASCADE; if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - for (SPItemView *v = SP_ITEM(object)->display; v != NULL; v = v->next) { + for (SPItemView *v = SP_ITEM(this)->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); - g->setStyle(object->style); + g->setStyle(this->style); } } /* Set up child viewport */ - if (use->x.unit == SVGLength::PERCENT) { - use->x.computed = use->x.value * ictx->viewport.width(); + if (this->x.unit == SVGLength::PERCENT) { + this->x.computed = this->x.value * ictx->viewport.width(); } - if (use->y.unit == SVGLength::PERCENT) { - use->y.computed = use->y.value * ictx->viewport.height(); + + if (this->y.unit == SVGLength::PERCENT) { + this->y.computed = this->y.value * ictx->viewport.height(); } - if (use->width.unit == SVGLength::PERCENT) { - use->width.computed = use->width.value * ictx->viewport.width(); + + if (this->width.unit == SVGLength::PERCENT) { + this->width.computed = this->width.value * ictx->viewport.width(); } - if (use->height.unit == SVGLength::PERCENT) { - use->height.computed = use->height.value * ictx->viewport.height(); + + if (this->height.unit == SVGLength::PERCENT) { + this->height.computed = this->height.value * ictx->viewport.height(); } - cctx.viewport = Geom::Rect::from_xywh(0, 0, use->width.computed, use->height.computed); + + cctx.viewport = Geom::Rect::from_xywh(0, 0, this->width.computed, this->height.computed); cctx.i2vp = Geom::identity(); flags&=~SP_OBJECT_USER_MODIFIED_FLAG_B; - if (use->child) { - sp_object_ref(use->child); - if (flags || (use->child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { - if (SP_IS_ITEM(use->child)) { - SPItem const &chi = *SP_ITEM(use->child); + if (this->child) { + sp_object_ref(this->child); + + if (flags || (this->child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { + if (SP_IS_ITEM(this->child)) { + SPItem const &chi = *SP_ITEM(this->child); cctx.i2doc = chi.transform * ictx->i2doc; cctx.i2vp = chi.transform * ictx->i2vp; - use->child->updateDisplay((SPCtx *)&cctx, flags); + this->child->updateDisplay((SPCtx *)&cctx, flags); } else { - use->child->updateDisplay(ctx, flags); + this->child->updateDisplay(ctx, flags); } } - sp_object_unref(use->child); + + sp_object_unref(this->child); } /* As last step set additional transform of arena group */ - for (SPItemView *v = item->display; v != NULL; v = v->next) { + for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); - Geom::Affine t(Geom::Translate(use->x.computed, use->y.computed)); + Geom::Affine t(Geom::Translate(this->x.computed, this->y.computed)); g->setChildTransform(t); } } -void CUse::modified(unsigned int flags) { - SPUse* object = this->spuse; - - SPUse *use_obj = SP_USE(object); - +void SPUse::modified(unsigned int flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } + flags &= SP_OBJECT_MODIFIED_CASCADE; if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - for (SPItemView *v = SP_ITEM(object)->display; v != NULL; v = v->next) { + for (SPItemView *v = SP_ITEM(this)->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); - g->setStyle(object->style); + g->setStyle(this->style); } } - SPObject *child = use_obj->child; + SPObject *child = this->child; + if (child) { sp_object_ref(child); + if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); } + sp_object_unref(child); } } @@ -660,6 +613,7 @@ SPItem *sp_use_unlink(SPUse *use) // Track the ultimate source of a chain of uses. SPItem *orig = sp_use_root(use); + if (!orig) { return NULL; } @@ -668,8 +622,10 @@ SPItem *sp_use_unlink(SPUse *use) Geom::Affine t = sp_use_get_root_transform(use); Inkscape::XML::Node *copy = NULL; + if (SP_IS_SYMBOL(orig)) { // make a group, copy children copy = xml_doc->createElement("svg:g"); + for (Inkscape::XML::Node *child = orig->getRepr()->firstChild() ; child != NULL; child = child->next()) { Inkscape::XML::Node *newchild = child->duplicate(xml_doc); copy->appendChild(newchild); @@ -722,31 +678,29 @@ SPItem *sp_use_unlink(SPUse *use) // Advertise ourselves as not moving. item->doWriteTransform(item->getRepr(), t, &nomove); } + return item; } SPItem *sp_use_get_original(SPUse *use) { SPItem *ref = NULL; - if (use){ + + if (use) { if (use->ref){ ref = use->ref->getObject(); } } + return ref; } -void CUse::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { - SPUse* item = this->spuse; +void SPUse::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { + SPItem *root = sp_use_root(this); - g_assert (item != NULL); - g_assert (SP_IS_ITEM(item)); - g_assert (SP_IS_USE(item)); - - SPUse *use = SP_USE(item); - SPItem *root = sp_use_root(use); - if (!root) + if (!root) { return; + } root->citem->snappoints(p, snapprefs); } -- 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-use.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 8b73844e5..8fadc0fac 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -52,9 +52,7 @@ namespace { bool useRegistered = SPFactory::instance().registerObject("svg:use", createUse); } -SPUse::SPUse() : SPItem(), CItem(this) { - delete this->citem; - this->citem = this; +SPUse::SPUse() : SPItem() { this->cobject = this; this->child = NULL; @@ -92,7 +90,7 @@ SPUse::~SPUse() { } void SPUse::build(SPDocument *document, Inkscape::XML::Node *repr) { - CItem::build(document, repr); + SPItem::build(document, repr); this->readAttr( "x" ); this->readAttr( "y" ); @@ -120,7 +118,7 @@ void SPUse::release() { this->ref->detach(); - CItem::release(); + SPItem::release(); } void SPUse::set(unsigned int key, const gchar* value) { @@ -171,7 +169,7 @@ void SPUse::set(unsigned int key, const gchar* value) { } default: - CItem::set(key, value); + SPItem::set(key, value); break; } } @@ -181,7 +179,7 @@ Inkscape::XML::Node* SPUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XM repr = xml_doc->createElement("svg:use"); } - CItem::write(xml_doc, repr, flags); + SPItem::write(xml_doc, repr, flags); sp_repr_set_svg_double(repr, "x", this->x.computed); sp_repr_set_svg_double(repr, "y", this->y.computed); @@ -253,7 +251,7 @@ gchar* SPUse::description() { } ++recursion_depth; - char *child_desc = SP_ITEM(this->child)->description(); + char *child_desc = SP_ITEM(this->child)->getDetailedDescription(); --recursion_depth; ret = g_strdup_printf(_("Clone of: %s"), child_desc); @@ -288,7 +286,7 @@ void SPUse::hide(unsigned int key) { SP_ITEM(this->child)->invoke_hide(key); } -// CItem::onHide(key); +// SPItem::onHide(key); } @@ -508,7 +506,7 @@ void SPUse::update(SPCtx *ctx, unsigned flags) { SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx cctx = *ictx; - CItem::update(ctx, flags); + SPItem::update(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -702,7 +700,7 @@ void SPUse::snappoints(std::vector &p, Inkscape::S return; } - root->citem->snappoints(p, snapprefs); + root->snappoints(p, snapprefs); } -- 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-use.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 8fadc0fac..bf9ac7f2e 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -53,8 +53,6 @@ namespace { } SPUse::SPUse() : SPItem() { - this->cobject = this; - this->child = NULL; this->x.unset(); -- 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-use.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index bf9ac7f2e..7c490ce41 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -25,7 +25,7 @@ #include "display/drawing-group.h" #include "attributes.h" #include "document.h" -#include "sp-object-repr.h" +#include "sp-factory.h" #include "sp-flowregion.h" #include "uri.h" #include "print.h" @@ -36,8 +36,6 @@ #include "sp-use.h" #include "sp-use-reference.h" -#include "sp-factory.h" - /* fixme: */ static void sp_use_href_changed(SPObject *old_ref, SPObject *ref, SPUse *use); static void sp_use_delete_self(SPObject *deleted, SPUse *self); -- 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-use.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 7c490ce41..f565cba20 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -453,7 +453,7 @@ sp_use_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUse *use) // } // } - SPObject* obj = SPFactory::instance().createObject(*childrepr); + SPObject* obj = SPFactory::instance().createObject(NodeTraits::getTypeString(*childrepr)); if (SP_IS_ITEM(obj)) { use->child = obj; -- 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-use.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index d923410c8..3822527a3 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -60,10 +60,10 @@ SPUse::SPUse() : SPItem() { this->height.unset(SVGLength::PERCENT, 1.0, 1.0); this->href = NULL; - new (&this->_delete_connection) sigc::connection(); - new (&this->_changed_connection) sigc::connection(); + //new (&this->_delete_connection) sigc::connection(); + //new (&this->_changed_connection) sigc::connection(); - new (&this->_transformed_connection) sigc::connection(); + //new (&this->_transformed_connection) sigc::connection(); this->ref = new SPUseReference(this); @@ -80,10 +80,10 @@ SPUse::~SPUse() { delete this->ref; this->ref = 0; - this->_delete_connection.~connection(); - this->_changed_connection.~connection(); + //this->_delete_connection.~connection(); + //this->_changed_connection.~connection(); - this->_transformed_connection.~connection(); + //this->_transformed_connection.~connection(); } void SPUse::build(SPDocument *document, Inkscape::XML::Node *repr) { -- 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-use.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 159660458..0887ab50e 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -453,7 +453,7 @@ sp_use_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUse *use) // } // } - SPObject* obj = SPFactory::instance().createObject(NodeTraits::getTypeString(*childrepr)); + SPObject* obj = SPFactory::instance().createObject(NodeTraits::get_type_string(*childrepr)); if (SP_IS_ITEM(obj)) { use->child = obj; -- cgit v1.2.3