From 217bc5844bedf86a84c099f051e51d6dc8a1966f Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 20 Aug 2012 00:21:00 +0200 Subject: Added "virtual pad" to SPTextPath and SPTSpan. (bzr r11608.1.27) --- src/sp-tspan.cpp | 211 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 154 insertions(+), 57 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 1b1ae3d52..3a83cb70d 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -109,28 +109,42 @@ sp_tspan_class_init(SPTSpanClass *classname) item_class->description = sp_tspan_description; } +CTSpan::CTSpan(SPTSpan* span) : CItem(span) { + this->sptspan = span; +} + +CTSpan::~CTSpan() { +} + static void sp_tspan_init(SPTSpan *tspan) { + tspan->ctspan = new CTSpan(tspan); + tspan->citem = tspan->ctspan; + tspan->cobject = tspan->ctspan; + tspan->role = SP_TSPAN_ROLE_UNSPECIFIED; new (&tspan->attributes) TextTagAttributes; } -static void -sp_tspan_release(SPObject *object) -{ +void CTSpan::onRelease() { + SPTSpan* object = this->sptspan; + SPTSpan *tspan = SP_TSPAN(object); tspan->attributes.~TextTagAttributes(); - if (((SPObjectClass *) tspan_parent_class)->release) - ((SPObjectClass *) tspan_parent_class)->release(object); + CItem::onRelease(); } static void -sp_tspan_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) +sp_tspan_release(SPObject *object) { - //SPTSpan *tspan = SP_TSPAN(object); + ((SPTSpan*)object)->ctspan->onRelease(); +} + +void CTSpan::onBuild(SPDocument *doc, Inkscape::XML::Node *repr) { + SPTSpan* object = this->sptspan; object->readAttr( "x" ); object->readAttr( "y" ); @@ -139,13 +153,18 @@ sp_tspan_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) object->readAttr( "rotate" ); object->readAttr( "sodipodi:role" ); - if (((SPObjectClass *) tspan_parent_class)->build) - ((SPObjectClass *) tspan_parent_class)->build(object, doc, repr); + CItem::onBuild(doc, repr); } static void -sp_tspan_set(SPObject *object, unsigned key, gchar const *value) +sp_tspan_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { + ((SPTSpan*)object)->ctspan->onBuild(doc, repr); +} + +void CTSpan::onSet(unsigned int key, const gchar* value) { + SPTSpan* object = this->sptspan; + SPTSpan *tspan = SP_TSPAN(object); if (tspan->attributes.readSingleAttribute(key, value)) { @@ -160,18 +179,22 @@ sp_tspan_set(SPObject *object, unsigned key, gchar const *value) } break; default: - if (((SPObjectClass *) tspan_parent_class)->set) - (((SPObjectClass *) tspan_parent_class)->set)(object, key, value); + CItem::onSet(key, value); break; } } } -static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags) +static void +sp_tspan_set(SPObject *object, unsigned key, gchar const *value) { - if (((SPObjectClass *) tspan_parent_class)->update) { - ((SPObjectClass *) tspan_parent_class)->update(object, ctx, flags); - } + ((SPTSpan*)object)->ctspan->onSet(key, value); +} + +void CTSpan::onUpdate(SPCtx *ctx, guint flags) { + SPTSpan* object = this->sptspan; + + CItem::onUpdate(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -185,11 +208,20 @@ static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags) } } -static void sp_tspan_modified(SPObject *object, unsigned flags) +static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags) { - if (((SPObjectClass *) tspan_parent_class)->modified) { - ((SPObjectClass *) tspan_parent_class)->modified(object, flags); - } + ((SPTSpan*)object)->ctspan->onUpdate(ctx, flags); +} + +void CTSpan::onModified(unsigned int flags) { + SPTSpan* object = this->sptspan; + + // CPPIFY: This doesn't make no sense. + // CObject::onModified is pure and CItem doesn't override this method. What was the idea behind these lines? +// if (((SPObjectClass *) tspan_parent_class)->modified) { +// ((SPObjectClass *) tspan_parent_class)->modified(object, flags); +// } +// CItem::onModified(flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -203,9 +235,14 @@ static void sp_tspan_modified(SPObject *object, unsigned flags) } } -static Geom::OptRect -sp_tspan_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) +static void sp_tspan_modified(SPObject *object, unsigned flags) { + ((SPTSpan*)object)->ctspan->onModified(flags); +} + +Geom::OptRect CTSpan::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { + SPTSpan* item = this->sptspan; + Geom::OptRect bbox; // find out the ancestor text which holds our layout SPObject const *parent_text = item; @@ -229,9 +266,15 @@ sp_tspan_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxTyp return bbox; } -static Inkscape::XML::Node * -sp_tspan_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Geom::OptRect +sp_tspan_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { + return ((SPTSpan*)item)->ctspan->onBbox(transform, type); +} + +Inkscape::XML::Node* CTSpan::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPTSpan* object = this->sptspan; + SPTSpan *tspan = SP_TSPAN(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { @@ -272,21 +315,31 @@ sp_tspan_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML } } - if (((SPObjectClass *) tspan_parent_class)->write) { - ((SPObjectClass *) tspan_parent_class)->write(object, xml_doc, repr, flags); - } + CItem::onWrite(xml_doc, repr, flags); return repr; } -static char * -sp_tspan_description(SPItem *item) +static Inkscape::XML::Node * +sp_tspan_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - g_return_val_if_fail(SP_IS_TSPAN(item), NULL); + return ((SPTSpan*)object)->ctspan->onWrite(xml_doc, repr, flags); +} + +gchar* CTSpan::onDescription() { + SPTSpan* item = this->sptspan; + + g_return_val_if_fail(SP_IS_TSPAN(item), NULL); return g_strdup(_("Text span")); } +static char * +sp_tspan_description(SPItem *item) +{ + return ((SPTSpan*)item)->ctspan->onDescription(); +} + /*##################################################### # SPTEXTPATH @@ -350,9 +403,21 @@ static void sp_textpath_class_init(SPTextPathClass *classname) sp_object_class->write = sp_textpath_write; } + +CTextPath::CTextPath(SPTextPath* textpath) : CItem(textpath) { + this->sptextpath = textpath; +} + +CTextPath::~CTextPath() { +} + static void sp_textpath_init(SPTextPath *textpath) { + textpath->ctextpath = new CTextPath(textpath); + textpath->citem = textpath->ctextpath; + textpath->cobject = textpath->ctextpath; + new (&textpath->attributes) TextTagAttributes; textpath->startOffset._set = false; @@ -371,9 +436,9 @@ sp_textpath_finalize(GObject *obj) delete textpath->sourcePath; } -static void -sp_textpath_release(SPObject *object) -{ +void CTextPath::onRelease() { + SPTextPath* object = this->sptextpath; + SPTextPath *textpath = SP_TEXTPATH(object); textpath->attributes.~TextTagAttributes(); @@ -381,12 +446,18 @@ sp_textpath_release(SPObject *object) if (textpath->originalPath) delete textpath->originalPath; textpath->originalPath = NULL; - if (((SPObjectClass *) textpath_parent_class)->release) - ((SPObjectClass *) textpath_parent_class)->release(object); + CItem::onRelease(); } -static void sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) +static void +sp_textpath_release(SPObject *object) { + ((SPTextPath*)object)->ctextpath->onRelease(); +} + +void CTextPath::onBuild(SPDocument *doc, Inkscape::XML::Node *repr) { + SPTextPath* object = this->sptextpath; + object->readAttr( "x" ); object->readAttr( "y" ); object->readAttr( "dx" ); @@ -410,14 +481,17 @@ static void sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML:: repr->addChild(rch, NULL); } - if (((SPObjectClass *) textpath_parent_class)->build) { - ((SPObjectClass *) textpath_parent_class)->build(object, doc, repr); - } + CItem::onBuild(doc, repr); } -static void -sp_textpath_set(SPObject *object, unsigned key, gchar const *value) +static void sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { + ((SPTextPath*)object)->ctextpath->onBuild(doc, repr); +} + +void CTextPath::onSet(unsigned int key, const gchar* value) { + SPTextPath* object = this->sptextpath; + SPTextPath *textpath = SP_TEXTPATH(object); if (textpath->attributes.readSingleAttribute(key, value)) { @@ -432,15 +506,21 @@ sp_textpath_set(SPObject *object, unsigned key, gchar const *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) textpath_parent_class)->set) - (((SPObjectClass *) textpath_parent_class)->set)(object, key, value); + CItem::onSet(key, value); break; } } } -static void sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags) +static void +sp_textpath_set(SPObject *object, unsigned key, gchar const *value) { + ((SPTextPath*)object)->ctextpath->onSet(key, value); +} + +void CTextPath::onUpdate(SPCtx *ctx, guint flags) { + SPTextPath* object = this->sptextpath; + SPTextPath *textpath = SP_TEXTPATH(object); textpath->isUpdating = true; @@ -449,9 +529,7 @@ static void sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags) } textpath->isUpdating = false; - if (((SPObjectClass *) textpath_parent_class)->update) { - ((SPObjectClass *) textpath_parent_class)->update(object, ctx, flags); - } + CItem::onUpdate(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -465,6 +543,11 @@ static void sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags) } } +static void sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags) +{ + ((SPTextPath*)object)->ctextpath->onUpdate(ctx, flags); +} + void refresh_textpath_source(SPTextPath* tp) { @@ -486,11 +569,15 @@ void refresh_textpath_source(SPTextPath* tp) } } -static void sp_textpath_modified(SPObject *object, unsigned flags) -{ - if (((SPObjectClass *) textpath_parent_class)->modified) { - ((SPObjectClass *) textpath_parent_class)->modified(object, flags); - } +void CTextPath::onModified(unsigned int flags) { + SPTextPath* object = this->sptextpath; + + // CPPIFY: This doesn't make no sense. + // CObject::onModified is pure and CItem doesn't override this method. What was the idea behind these lines? +// if (((SPObjectClass *) textpath_parent_class)->modified) { +// ((SPObjectClass *) textpath_parent_class)->modified(object, flags); +// } +// CItem::onModified(flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -503,9 +590,15 @@ static void sp_textpath_modified(SPObject *object, unsigned flags) } } } -static Inkscape::XML::Node * -sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) + +static void sp_textpath_modified(SPObject *object, unsigned flags) { + ((SPTextPath*)object)->ctextpath->onModified(flags); +} + +Inkscape::XML::Node* CTextPath::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPTextPath* object = this->sptextpath; + SPTextPath *textpath = SP_TEXTPATH(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { @@ -559,13 +652,17 @@ sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape:: } } - if (((SPObjectClass *) textpath_parent_class)->write) { - ((SPObjectClass *) textpath_parent_class)->write(object, xml_doc, repr, flags); - } + CItem::onWrite(xml_doc, repr, flags); return repr; } +static Inkscape::XML::Node * +sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +{ + return ((SPTextPath*)object)->ctextpath->onWrite(xml_doc, repr, flags); +} + SPItem * sp_textpath_get_path_item(SPTextPath *tp) -- 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-tspan.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 3a83cb70d..e94733dee 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -105,8 +105,8 @@ sp_tspan_class_init(SPTSpanClass *classname) sp_object_class->modified = sp_tspan_modified; sp_object_class->write = sp_tspan_write; - item_class->bbox = sp_tspan_bbox; - item_class->description = sp_tspan_description; +// item_class->bbox = sp_tspan_bbox; +// item_class->description = sp_tspan_description; } CTSpan::CTSpan(SPTSpan* span) : CItem(span) { -- 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-tspan.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index e94733dee..d79177135 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -98,7 +98,7 @@ sp_tspan_class_init(SPTSpanClass *classname) tspan_parent_class = (SPItemClass*)g_type_class_ref(SP_TYPE_ITEM); - sp_object_class->build = sp_tspan_build; + //sp_object_class->build = sp_tspan_build; sp_object_class->release = sp_tspan_release; sp_object_class->set = sp_tspan_set; sp_object_class->update = sp_tspan_update; @@ -395,7 +395,7 @@ static void sp_textpath_class_init(SPTextPathClass *classname) gobject_class->finalize = sp_textpath_finalize; - sp_object_class->build = sp_textpath_build; + //sp_object_class->build = sp_textpath_build; sp_object_class->release = sp_textpath_release; sp_object_class->set = sp_textpath_set; sp_object_class->update = sp_textpath_update; -- 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-tspan.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index d79177135..3950ed863 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -99,11 +99,11 @@ sp_tspan_class_init(SPTSpanClass *classname) tspan_parent_class = (SPItemClass*)g_type_class_ref(SP_TYPE_ITEM); //sp_object_class->build = sp_tspan_build; - sp_object_class->release = sp_tspan_release; - sp_object_class->set = sp_tspan_set; - sp_object_class->update = sp_tspan_update; - sp_object_class->modified = sp_tspan_modified; - sp_object_class->write = sp_tspan_write; +// sp_object_class->release = sp_tspan_release; +// sp_object_class->set = sp_tspan_set; +// sp_object_class->update = sp_tspan_update; +// sp_object_class->modified = sp_tspan_modified; +// sp_object_class->write = sp_tspan_write; // item_class->bbox = sp_tspan_bbox; // item_class->description = sp_tspan_description; @@ -396,11 +396,11 @@ static void sp_textpath_class_init(SPTextPathClass *classname) gobject_class->finalize = sp_textpath_finalize; //sp_object_class->build = sp_textpath_build; - sp_object_class->release = sp_textpath_release; - sp_object_class->set = sp_textpath_set; - sp_object_class->update = sp_textpath_update; - sp_object_class->modified = sp_textpath_modified; - sp_object_class->write = sp_textpath_write; +// sp_object_class->release = sp_textpath_release; +// sp_object_class->set = sp_textpath_set; +// sp_object_class->update = sp_textpath_update; +// sp_object_class->modified = sp_textpath_modified; +// sp_object_class->write = sp_textpath_write; } -- 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-tspan.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 151e54830..fcbda7123 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -74,17 +74,17 @@ sp_tspan_init(SPTSpan *tspan) new (&tspan->attributes) TextTagAttributes; } -void CTSpan::onRelease() { +void CTSpan::release() { SPTSpan* object = this->sptspan; SPTSpan *tspan = SP_TSPAN(object); tspan->attributes.~TextTagAttributes(); - CItem::onRelease(); + CItem::release(); } -void CTSpan::onBuild(SPDocument *doc, Inkscape::XML::Node *repr) { +void CTSpan::build(SPDocument *doc, Inkscape::XML::Node *repr) { SPTSpan* object = this->sptspan; object->readAttr( "x" ); @@ -94,11 +94,11 @@ void CTSpan::onBuild(SPDocument *doc, Inkscape::XML::Node *repr) { object->readAttr( "rotate" ); object->readAttr( "sodipodi:role" ); - CItem::onBuild(doc, repr); + CItem::build(doc, repr); } -void CTSpan::onSet(unsigned int key, const gchar* value) { +void CTSpan::set(unsigned int key, const gchar* value) { SPTSpan* object = this->sptspan; SPTSpan *tspan = SP_TSPAN(object); @@ -115,16 +115,16 @@ void CTSpan::onSet(unsigned int key, const gchar* value) { } break; default: - CItem::onSet(key, value); + CItem::set(key, value); break; } } } -void CTSpan::onUpdate(SPCtx *ctx, guint flags) { +void CTSpan::update(SPCtx *ctx, guint flags) { SPTSpan* object = this->sptspan; - CItem::onUpdate(ctx, flags); + CItem::update(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -138,7 +138,7 @@ void CTSpan::onUpdate(SPCtx *ctx, guint flags) { } } -void CTSpan::onModified(unsigned int flags) { +void CTSpan::modified(unsigned int flags) { SPTSpan* object = this->sptspan; // CItem::onModified(flags); @@ -155,7 +155,7 @@ void CTSpan::onModified(unsigned int flags) { } } -Geom::OptRect CTSpan::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect CTSpan::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { SPTSpan* item = this->sptspan; Geom::OptRect bbox; @@ -181,7 +181,7 @@ Geom::OptRect CTSpan::onBbox(Geom::Affine const &transform, SPItem::BBoxType typ return bbox; } -Inkscape::XML::Node* CTSpan::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node* CTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPTSpan* object = this->sptspan; SPTSpan *tspan = SP_TSPAN(object); @@ -224,12 +224,12 @@ Inkscape::XML::Node* CTSpan::onWrite(Inkscape::XML::Document *xml_doc, Inkscape: } } - CItem::onWrite(xml_doc, repr, flags); + CItem::write(xml_doc, repr, flags); return repr; } -gchar* CTSpan::onDescription() { +gchar* CTSpan::description() { SPTSpan* item = this->sptspan; g_return_val_if_fail(SP_IS_TSPAN(item), NULL); @@ -290,7 +290,7 @@ sp_textpath_finalize(GObject *obj) delete textpath->sourcePath; } -void CTextPath::onRelease() { +void CTextPath::release() { SPTextPath* object = this->sptextpath; SPTextPath *textpath = SP_TEXTPATH(object); @@ -300,10 +300,10 @@ void CTextPath::onRelease() { if (textpath->originalPath) delete textpath->originalPath; textpath->originalPath = NULL; - CItem::onRelease(); + CItem::release(); } -void CTextPath::onBuild(SPDocument *doc, Inkscape::XML::Node *repr) { +void CTextPath::build(SPDocument *doc, Inkscape::XML::Node *repr) { SPTextPath* object = this->sptextpath; object->readAttr( "x" ); @@ -329,10 +329,10 @@ void CTextPath::onBuild(SPDocument *doc, Inkscape::XML::Node *repr) { repr->addChild(rch, NULL); } - CItem::onBuild(doc, repr); + CItem::build(doc, repr); } -void CTextPath::onSet(unsigned int key, const gchar* value) { +void CTextPath::set(unsigned int key, const gchar* value) { SPTextPath* object = this->sptextpath; SPTextPath *textpath = SP_TEXTPATH(object); @@ -349,13 +349,13 @@ void CTextPath::onSet(unsigned int key, const gchar* value) { object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - CItem::onSet(key, value); + CItem::set(key, value); break; } } } -void CTextPath::onUpdate(SPCtx *ctx, guint flags) { +void CTextPath::update(SPCtx *ctx, guint flags) { SPTextPath* object = this->sptextpath; SPTextPath *textpath = SP_TEXTPATH(object); @@ -366,7 +366,7 @@ void CTextPath::onUpdate(SPCtx *ctx, guint flags) { } textpath->isUpdating = false; - CItem::onUpdate(ctx, flags); + CItem::update(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -401,7 +401,7 @@ void refresh_textpath_source(SPTextPath* tp) } } -void CTextPath::onModified(unsigned int flags) { +void CTextPath::modified(unsigned int flags) { SPTextPath* object = this->sptextpath; // CItem::onModified(flags); @@ -418,7 +418,7 @@ void CTextPath::onModified(unsigned int flags) { } } -Inkscape::XML::Node* CTextPath::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node* CTextPath::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPTextPath* object = this->sptextpath; SPTextPath *textpath = SP_TEXTPATH(object); @@ -474,7 +474,7 @@ Inkscape::XML::Node* CTextPath::onWrite(Inkscape::XML::Document *xml_doc, Inksca } } - CItem::onWrite(xml_doc, repr, flags); + CItem::write(xml_doc, repr, flags); return repr; } -- 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-tspan.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index fcbda7123..853966e46 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -65,6 +65,7 @@ static void sp_tspan_init(SPTSpan *tspan) { tspan->ctspan = new CTSpan(tspan); + tspan->typeHierarchy.insert(typeid(SPTSpan)); delete tspan->citem; tspan->citem = tspan->ctspan; @@ -267,6 +268,7 @@ static void sp_textpath_init(SPTextPath *textpath) { textpath->ctextpath = new CTextPath(textpath); + textpath->typeHierarchy.insert(typeid(SPTextPath)); delete textpath->citem; textpath->citem = textpath->ctextpath; -- 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-tspan.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 853966e46..e9cc6f161 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -47,7 +47,7 @@ /*##################################################### # SPTSPAN #####################################################*/ -G_DEFINE_TYPE(SPTSpan, sp_tspan, SP_TYPE_ITEM); +G_DEFINE_TYPE(SPTSpan, sp_tspan, G_TYPE_OBJECT); static void sp_tspan_class_init(SPTSpanClass *classname) @@ -61,9 +61,9 @@ CTSpan::CTSpan(SPTSpan* span) : CItem(span) { CTSpan::~CTSpan() { } -static void -sp_tspan_init(SPTSpan *tspan) -{ +SPTSpan::SPTSpan() : SPItem() { + SPTSpan* tspan = this; + tspan->ctspan = new CTSpan(tspan); tspan->typeHierarchy.insert(typeid(SPTSpan)); @@ -75,6 +75,12 @@ sp_tspan_init(SPTSpan *tspan) new (&tspan->attributes) TextTagAttributes; } +static void +sp_tspan_init(SPTSpan *tspan) +{ + new (tspan) SPTSpan(); +} + void CTSpan::release() { SPTSpan* object = this->sptspan; @@ -247,7 +253,7 @@ static void sp_textpath_finalize(GObject *obj); void refresh_textpath_source(SPTextPath* offset); -G_DEFINE_TYPE(SPTextPath, sp_textpath, SP_TYPE_ITEM); +G_DEFINE_TYPE(SPTextPath, sp_textpath, G_TYPE_OBJECT); static void sp_textpath_class_init(SPTextPathClass *classname) @@ -264,9 +270,9 @@ CTextPath::CTextPath(SPTextPath* textpath) : CItem(textpath) { CTextPath::~CTextPath() { } -static void -sp_textpath_init(SPTextPath *textpath) -{ +SPTextPath::SPTextPath() : SPItem() { + SPTextPath* textpath = this; + textpath->ctextpath = new CTextPath(textpath); textpath->typeHierarchy.insert(typeid(SPTextPath)); @@ -284,6 +290,12 @@ sp_textpath_init(SPTextPath *textpath) textpath->sourcePath->user_unlink = sp_textpath_to_text; } +static void +sp_textpath_init(SPTextPath *textpath) +{ + new (textpath) SPTextPath(); +} + static void sp_textpath_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-tspan.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index e9cc6f161..29786f244 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -43,6 +43,20 @@ #include "xml/repr.h" #include "document.h" +#include "sp-factory.h" + +namespace { + SPObject* createTSpan() { + return new SPTSpan(); + } + + SPObject* createTextPath() { + return new SPTextPath(); + } + + bool tspanRegistered = SPFactory::instance().registerObject("svg:tspan", createTSpan); + bool textPathRegistered = SPFactory::instance().registerObject("svg:textPath", createTextPath); +} /*##################################################### # SPTSPAN -- 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-tspan.cpp | 324 ++++++++++++++++++++++--------------------------------- 1 file changed, 130 insertions(+), 194 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 29786f244..f72fe4c41 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -61,80 +61,48 @@ namespace { /*##################################################### # SPTSPAN #####################################################*/ -G_DEFINE_TYPE(SPTSpan, sp_tspan, G_TYPE_OBJECT); +SPTSpan::SPTSpan() : SPItem(), CItem(this) { + delete this->citem; + this->citem = this; + this->cobject = this; -static void -sp_tspan_class_init(SPTSpanClass *classname) -{ -} - -CTSpan::CTSpan(SPTSpan* span) : CItem(span) { - this->sptspan = span; + this->role = SP_TSPAN_ROLE_UNSPECIFIED; + new (&this->attributes) TextTagAttributes; } -CTSpan::~CTSpan() { +SPTSpan::~SPTSpan() { } -SPTSpan::SPTSpan() : SPItem() { - SPTSpan* tspan = this; +void SPTSpan::build(SPDocument *doc, Inkscape::XML::Node *repr) { + this->readAttr( "x" ); + this->readAttr( "y" ); + this->readAttr( "dx" ); + this->readAttr( "dy" ); + this->readAttr( "rotate" ); + this->readAttr( "sodipodi:role" ); - tspan->ctspan = new CTSpan(tspan); - tspan->typeHierarchy.insert(typeid(SPTSpan)); - - delete tspan->citem; - tspan->citem = tspan->ctspan; - tspan->cobject = tspan->ctspan; - - tspan->role = SP_TSPAN_ROLE_UNSPECIFIED; - new (&tspan->attributes) TextTagAttributes; -} - -static void -sp_tspan_init(SPTSpan *tspan) -{ - new (tspan) SPTSpan(); + CItem::build(doc, repr); } -void CTSpan::release() { - SPTSpan* object = this->sptspan; - - SPTSpan *tspan = SP_TSPAN(object); - - tspan->attributes.~TextTagAttributes(); +void SPTSpan::release() { + this->attributes.~TextTagAttributes(); CItem::release(); } -void CTSpan::build(SPDocument *doc, Inkscape::XML::Node *repr) { - SPTSpan* object = this->sptspan; - - object->readAttr( "x" ); - object->readAttr( "y" ); - object->readAttr( "dx" ); - object->readAttr( "dy" ); - object->readAttr( "rotate" ); - object->readAttr( "sodipodi:role" ); - - CItem::build(doc, repr); -} - - -void CTSpan::set(unsigned int key, const gchar* value) { - SPTSpan* object = this->sptspan; - - SPTSpan *tspan = SP_TSPAN(object); - - if (tspan->attributes.readSingleAttribute(key, value)) { - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +void SPTSpan::set(unsigned int key, const gchar* value) { + if (this->attributes.readSingleAttribute(key, value)) { + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } else { switch (key) { case SP_ATTR_SODIPODI_ROLE: if (value && (!strcmp(value, "line") || !strcmp(value, "paragraph"))) { - tspan->role = SP_TSPAN_ROLE_LINE; + this->role = SP_TSPAN_ROLE_LINE; } else { - tspan->role = SP_TSPAN_ROLE_UNSPECIFIED; + this->role = SP_TSPAN_ROLE_UNSPECIFIED; } break; + default: CItem::set(key, value); break; @@ -142,81 +110,81 @@ void CTSpan::set(unsigned int key, const gchar* value) { } } -void CTSpan::update(SPCtx *ctx, guint flags) { - SPTSpan* object = this->sptspan; - +void SPTSpan::update(SPCtx *ctx, guint flags) { CItem::update(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } + flags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) { + for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) { - ochild->updateDisplay(ctx, flags); + ochild->updateDisplay(ctx, flags); } } } -void CTSpan::modified(unsigned int flags) { - SPTSpan* object = this->sptspan; - +void SPTSpan::modified(unsigned int flags) { // CItem::onModified(flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } + flags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) { + for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) { ochild->emitModified(flags); } } } -Geom::OptRect CTSpan::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { - SPTSpan* item = this->sptspan; - +Geom::OptRect SPTSpan::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); - if (!bbox) return bbox; + bbox = SP_TEXT(parent_text)->layout.bounds(transform, sp_text_get_length_upto(parent_text, this), sp_text_get_length_upto(this, NULL) - 1); + + if (!bbox) { + return bbox; + } // Add stroke width // FIXME this code is incorrect - if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + if (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; } -Inkscape::XML::Node* CTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPTSpan* object = this->sptspan; - - SPTSpan *tspan = SP_TSPAN(object); - +Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:tspan"); } - tspan->attributes.writeTo(repr); + this->attributes.writeTo(repr); if ( flags&SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; - for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { + + for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { Inkscape::XML::Node* c_repr=NULL; + if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); } else if ( SP_IS_TEXTPATH(child) ) { @@ -224,17 +192,19 @@ Inkscape::XML::Node* CTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape::X } else if ( SP_IS_STRING(child) ) { c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); } + if ( c_repr ) { l = g_slist_prepend(l, c_repr); } } + while ( l ) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); Inkscape::GC::release((Inkscape::XML::Node *) l->data); l = g_slist_remove(l, l->data); } } else { - for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { + for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { child->updateRepr(flags); } else if ( SP_IS_TEXTPATH(child) ) { @@ -250,11 +220,7 @@ Inkscape::XML::Node* CTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape::X return repr; } -gchar* CTSpan::description() { - SPTSpan* item = this->sptspan; - - g_return_val_if_fail(SP_IS_TSPAN(item), NULL); - +gchar* SPTSpan::description() { return g_strdup(_("Text span")); } @@ -262,87 +228,39 @@ gchar* CTSpan::description() { /*##################################################### # SPTEXTPATH #####################################################*/ - -static void sp_textpath_finalize(GObject *obj); - void refresh_textpath_source(SPTextPath* offset); -G_DEFINE_TYPE(SPTextPath, sp_textpath, G_TYPE_OBJECT); - -static void -sp_textpath_class_init(SPTextPathClass *classname) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(classname); - gobject_class->finalize = sp_textpath_finalize; -} - - -CTextPath::CTextPath(SPTextPath* textpath) : CItem(textpath) { - this->sptextpath = textpath; -} - -CTextPath::~CTextPath() { -} - -SPTextPath::SPTextPath() : SPItem() { - SPTextPath* textpath = this; - - textpath->ctextpath = new CTextPath(textpath); - textpath->typeHierarchy.insert(typeid(SPTextPath)); +SPTextPath::SPTextPath() : SPItem(), CItem(this) { + delete this->citem; + this->citem = this; + this->cobject = this; - delete textpath->citem; - textpath->citem = textpath->ctextpath; - textpath->cobject = textpath->ctextpath; + new (&this->attributes) TextTagAttributes; - new (&textpath->attributes) TextTagAttributes; + this->startOffset._set = false; + this->originalPath = NULL; + this->isUpdating=false; - textpath->startOffset._set = false; - textpath->originalPath = NULL; - textpath->isUpdating=false; // set up the uri reference - textpath->sourcePath = new SPUsePath(textpath); - textpath->sourcePath->user_unlink = sp_textpath_to_text; + this->sourcePath = new SPUsePath(this); + this->sourcePath->user_unlink = sp_textpath_to_text; } -static void -sp_textpath_init(SPTextPath *textpath) -{ - new (textpath) SPTextPath(); -} - -static void -sp_textpath_finalize(GObject *obj) -{ - SPTextPath *textpath = (SPTextPath *) obj; - - delete textpath->sourcePath; +SPTextPath::~SPTextPath() { + delete this->sourcePath; } -void CTextPath::release() { - SPTextPath* object = this->sptextpath; - - SPTextPath *textpath = SP_TEXTPATH(object); - - textpath->attributes.~TextTagAttributes(); - - if (textpath->originalPath) delete textpath->originalPath; - textpath->originalPath = NULL; - - CItem::release(); -} - -void CTextPath::build(SPDocument *doc, Inkscape::XML::Node *repr) { - SPTextPath* object = this->sptextpath; - - object->readAttr( "x" ); - object->readAttr( "y" ); - object->readAttr( "dx" ); - object->readAttr( "dy" ); - object->readAttr( "rotate" ); - object->readAttr( "startOffset" ); - object->readAttr( "xlink:href" ); +void SPTextPath::build(SPDocument *doc, Inkscape::XML::Node *repr) { + this->readAttr( "x" ); + this->readAttr( "y" ); + this->readAttr( "dx" ); + this->readAttr( "dy" ); + this->readAttr( "rotate" ); + this->readAttr( "startOffset" ); + this->readAttr( "xlink:href" ); bool no_content = true; + for (Inkscape::XML::Node* rch = repr->firstChild() ; rch != NULL; rch = rch->next()) { if ( rch->type() == Inkscape::XML::TEXT_NODE ) { @@ -360,21 +278,29 @@ void CTextPath::build(SPDocument *doc, Inkscape::XML::Node *repr) { CItem::build(doc, repr); } -void CTextPath::set(unsigned int key, const gchar* value) { - SPTextPath* object = this->sptextpath; +void SPTextPath::release() { + this->attributes.~TextTagAttributes(); + + if (this->originalPath) { + delete this->originalPath; + } + + this->originalPath = NULL; - SPTextPath *textpath = SP_TEXTPATH(object); + CItem::release(); +} - if (textpath->attributes.readSingleAttribute(key, value)) { - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +void SPTextPath::set(unsigned int key, const gchar* value) { + if (this->attributes.readSingleAttribute(key, value)) { + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } else { switch (key) { case SP_ATTR_XLINK_HREF: - textpath->sourcePath->link((char*)value); + this->sourcePath->link((char*)value); break; case SP_ATTR_STARTOFFSET: - textpath->startOffset.readOrUnset(value); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->startOffset.readOrUnset(value); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: CItem::set(key, value); @@ -383,25 +309,24 @@ void CTextPath::set(unsigned int key, const gchar* value) { } } -void CTextPath::update(SPCtx *ctx, guint flags) { - SPTextPath* object = this->sptextpath; +void SPTextPath::update(SPCtx *ctx, guint flags) { + this->isUpdating = true; - SPTextPath *textpath = SP_TEXTPATH(object); - - textpath->isUpdating = true; - if ( textpath->sourcePath->sourceDirty ) { - refresh_textpath_source(textpath); + if ( this->sourcePath->sourceDirty ) { + refresh_textpath_source(this); } - textpath->isUpdating = false; + + this->isUpdating = false; CItem::update(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } + flags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) { + for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) { ochild->updateDisplay(ctx, flags); } @@ -411,7 +336,10 @@ void CTextPath::update(SPCtx *ctx, guint flags) { void refresh_textpath_source(SPTextPath* tp) { - if ( tp == NULL ) return; + if ( tp == NULL ) { + return; + } + tp->sourcePath->refresh_source(); tp->sourcePath->sourceDirty=false; @@ -420,60 +348,59 @@ void refresh_textpath_source(SPTextPath* tp) if (tp->originalPath) { delete tp->originalPath; } + tp->originalPath = NULL; tp->originalPath = new Path; tp->originalPath->Copy(tp->sourcePath->originalPath); tp->originalPath->ConvertWithBackData(0.01); - } } -void CTextPath::modified(unsigned int flags) { - SPTextPath* object = this->sptextpath; - +void SPTextPath::modified(unsigned int flags) { // CItem::onModified(flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } + flags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) { + for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) { ochild->emitModified(flags); } } } -Inkscape::XML::Node* CTextPath::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPTextPath* object = this->sptextpath; - - SPTextPath *textpath = SP_TEXTPATH(object); - +Inkscape::XML::Node* SPTextPath::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:textPath"); } - textpath->attributes.writeTo(repr); - if (textpath->startOffset._set) { - if (textpath->startOffset.unit == SVGLength::PERCENT) { + this->attributes.writeTo(repr); + if (this->startOffset._set) { + if (this->startOffset.unit == SVGLength::PERCENT) { Inkscape::SVGOStringStream os; - os << (textpath->startOffset.computed * 100.0) << "%"; - textpath->getRepr()->setAttribute("startOffset", os.str().c_str()); + os << (this->startOffset.computed * 100.0) << "%"; + this->getRepr()->setAttribute("startOffset", os.str().c_str()); } else { /* FIXME: This logic looks rather undesirable if e.g. startOffset is to be in ems. */ - sp_repr_set_svg_double(repr, "startOffset", textpath->startOffset.computed); + sp_repr_set_svg_double(repr, "startOffset", this->startOffset.computed); } } - if ( textpath->sourcePath->sourceHref ) repr->setAttribute("xlink:href", textpath->sourcePath->sourceHref); + if ( this->sourcePath->sourceHref ) { + repr->setAttribute("xlink:href", this->sourcePath->sourceHref); + } - if ( flags&SP_OBJECT_WRITE_BUILD ) { + if ( flags & SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; - for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { + + for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { Inkscape::XML::Node* c_repr=NULL; + if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); } else if ( SP_IS_TEXTPATH(child) ) { @@ -481,17 +408,19 @@ Inkscape::XML::Node* CTextPath::write(Inkscape::XML::Document *xml_doc, Inkscape } else if ( SP_IS_STRING(child) ) { c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); } + if ( c_repr ) { l = g_slist_prepend(l, c_repr); } } + while ( l ) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); Inkscape::GC::release((Inkscape::XML::Node *) l->data); l = g_slist_remove(l, l->data); } } else { - for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { + for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { child->updateRepr(flags); } else if ( SP_IS_TEXTPATH(child) ) { @@ -513,8 +442,10 @@ sp_textpath_get_path_item(SPTextPath *tp) { if (tp && tp->sourcePath) { SPItem *refobj = tp->sourcePath->getObject(); - if (SP_IS_ITEM(refobj)) + + if (SP_IS_ITEM(refobj)) { return (SPItem *) refobj; + } } return NULL; } @@ -525,11 +456,16 @@ sp_textpath_to_text(SPObject *tp) SPObject *text = tp->parent; Geom::OptRect bbox = SP_ITEM(text)->geometricBounds(SP_ITEM(text)->i2doc_affine()); - if (!bbox) return; + + if (!bbox) { + return; + } + Geom::Point xy = bbox->min(); // make a list of textpath children GSList *tp_reprs = NULL; + for (SPObject *o = tp->firstChild() ; o != NULL; o = o->next) { tp_reprs = g_slist_prepend(tp_reprs, o->getRepr()); } -- 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-tspan.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index f72fe4c41..f76fa1b27 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -61,9 +61,7 @@ namespace { /*##################################################### # SPTSPAN #####################################################*/ -SPTSpan::SPTSpan() : SPItem(), CItem(this) { - delete this->citem; - this->citem = this; +SPTSpan::SPTSpan() : SPItem() { this->cobject = this; this->role = SP_TSPAN_ROLE_UNSPECIFIED; @@ -81,13 +79,13 @@ void SPTSpan::build(SPDocument *doc, Inkscape::XML::Node *repr) { this->readAttr( "rotate" ); this->readAttr( "sodipodi:role" ); - CItem::build(doc, repr); + SPItem::build(doc, repr); } void SPTSpan::release() { this->attributes.~TextTagAttributes(); - CItem::release(); + SPItem::release(); } void SPTSpan::set(unsigned int key, const gchar* value) { @@ -104,14 +102,14 @@ void SPTSpan::set(unsigned int key, const gchar* value) { break; default: - CItem::set(key, value); + SPItem::set(key, value); break; } } } void SPTSpan::update(SPCtx *ctx, guint flags) { - CItem::update(ctx, flags); + SPItem::update(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -127,7 +125,7 @@ void SPTSpan::update(SPCtx *ctx, guint flags) { } void SPTSpan::modified(unsigned int flags) { -// CItem::onModified(flags); +// SPItem::onModified(flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -215,7 +213,7 @@ Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape:: } } - CItem::write(xml_doc, repr, flags); + SPItem::write(xml_doc, repr, flags); return repr; } @@ -230,9 +228,7 @@ gchar* SPTSpan::description() { #####################################################*/ void refresh_textpath_source(SPTextPath* offset); -SPTextPath::SPTextPath() : SPItem(), CItem(this) { - delete this->citem; - this->citem = this; +SPTextPath::SPTextPath() : SPItem() { this->cobject = this; new (&this->attributes) TextTagAttributes; @@ -275,7 +271,7 @@ void SPTextPath::build(SPDocument *doc, Inkscape::XML::Node *repr) { repr->addChild(rch, NULL); } - CItem::build(doc, repr); + SPItem::build(doc, repr); } void SPTextPath::release() { @@ -287,7 +283,7 @@ void SPTextPath::release() { this->originalPath = NULL; - CItem::release(); + SPItem::release(); } void SPTextPath::set(unsigned int key, const gchar* value) { @@ -303,7 +299,7 @@ void SPTextPath::set(unsigned int key, const gchar* value) { this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - CItem::set(key, value); + SPItem::set(key, value); break; } } @@ -318,7 +314,7 @@ void SPTextPath::update(SPCtx *ctx, guint flags) { this->isUpdating = false; - CItem::update(ctx, flags); + SPItem::update(ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -358,7 +354,7 @@ void refresh_textpath_source(SPTextPath* tp) } void SPTextPath::modified(unsigned int flags) { -// CItem::onModified(flags); +// SPItem::onModified(flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -431,7 +427,7 @@ Inkscape::XML::Node* SPTextPath::write(Inkscape::XML::Document *xml_doc, Inkscap } } - CItem::write(xml_doc, repr, flags); + SPItem::write(xml_doc, repr, flags); return repr; } -- 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-tspan.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index f76fa1b27..41afb1761 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -62,8 +62,6 @@ namespace { # SPTSPAN #####################################################*/ SPTSpan::SPTSpan() : SPItem() { - this->cobject = this; - this->role = SP_TSPAN_ROLE_UNSPECIFIED; new (&this->attributes) TextTagAttributes; } @@ -229,8 +227,6 @@ gchar* SPTSpan::description() { void refresh_textpath_source(SPTextPath* offset); SPTextPath::SPTextPath() : SPItem() { - this->cobject = this; - new (&this->attributes) TextTagAttributes; this->startOffset._set = false; -- 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-tspan.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 41afb1761..00cdf5722 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -63,7 +63,7 @@ namespace { #####################################################*/ SPTSpan::SPTSpan() : SPItem() { this->role = SP_TSPAN_ROLE_UNSPECIFIED; - new (&this->attributes) TextTagAttributes; + //new (&this->attributes) TextTagAttributes; } SPTSpan::~SPTSpan() { @@ -81,7 +81,7 @@ void SPTSpan::build(SPDocument *doc, Inkscape::XML::Node *repr) { } void SPTSpan::release() { - this->attributes.~TextTagAttributes(); + //this->attributes.~TextTagAttributes(); SPItem::release(); } @@ -227,7 +227,7 @@ gchar* SPTSpan::description() { void refresh_textpath_source(SPTextPath* offset); SPTextPath::SPTextPath() : SPItem() { - new (&this->attributes) TextTagAttributes; + //new (&this->attributes) TextTagAttributes; this->startOffset._set = false; this->originalPath = NULL; @@ -271,7 +271,7 @@ void SPTextPath::build(SPDocument *doc, Inkscape::XML::Node *repr) { } void SPTextPath::release() { - this->attributes.~TextTagAttributes(); + //this->attributes.~TextTagAttributes(); if (this->originalPath) { delete this->originalPath; -- cgit v1.2.3