From c3603a6d13023cce77d405f4a660a7088a935179 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 19 Aug 2012 23:43:28 +0200 Subject: Added "virtual pad" to SPText. (bzr r11608.1.26) --- src/sp-text.cpp | 180 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 138 insertions(+), 42 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 0b60c1960..d9c4df702 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -132,42 +132,63 @@ sp_text_class_init (SPTextClass *classname) item_class->print = sp_text_print; } +CText::CText(SPText* text) : CItem(text) { + this->sptext = text; +} + +CText::~CText() { +} + static void sp_text_init (SPText *text) { + text->ctext = new CText(text); + text->citem = text->ctext; + text->cobject = text->ctext; + new (&text->layout) Inkscape::Text::Layout; new (&text->attributes) TextTagAttributes; } -static void -sp_text_release (SPObject *object) -{ +void CText::onRelease() { + SPText* object = this->sptext; + SPText *text = SP_TEXT(object); text->attributes.~TextTagAttributes(); text->layout.~Layout(); - if (((SPObjectClass *) text_parent_class)->release) - ((SPObjectClass *) text_parent_class)->release(object); + CItem::onRelease(); } static void -sp_text_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) +sp_text_release (SPObject *object) { + ((SPText*)object)->ctext->onRelease(); +} + +void CText::onBuild(SPDocument *doc, Inkscape::XML::Node *repr) { + SPText* object = this->sptext; + object->readAttr( "x" ); object->readAttr( "y" ); object->readAttr( "dx" ); object->readAttr( "dy" ); object->readAttr( "rotate" ); - if (((SPObjectClass *) text_parent_class)->build) - ((SPObjectClass *) text_parent_class)->build(object, doc, repr); + CItem::onBuild(doc, repr); object->readAttr( "sodipodi:linespacing" ); // has to happen after the styles are read } static void -sp_text_set(SPObject *object, unsigned key, gchar const *value) +sp_text_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { + ((SPText*)object)->ctext->onBuild(doc, repr); +} + +void CText::onSet(unsigned int key, const gchar* value) { + SPText* object = this->sptext; + SPText *text = SP_TEXT (object); if (text->attributes.readSingleAttribute(key, value)) { @@ -186,41 +207,56 @@ sp_text_set(SPObject *object, unsigned key, gchar const *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) text_parent_class)->set) - ((SPObjectClass *) text_parent_class)->set (object, key, value); + CItem::onSet(key, value); break; } } } static void -sp_text_child_added (SPObject *object, Inkscape::XML::Node *rch, Inkscape::XML::Node *ref) +sp_text_set(SPObject *object, unsigned key, gchar const *value) { + ((SPText*)object)->ctext->onSet(key, value); +} + +void CText::onChildAdded(Inkscape::XML::Node *rch, Inkscape::XML::Node *ref) { + SPText* object = this->sptext; + SPText *text = SP_TEXT (object); - if (((SPObjectClass *) text_parent_class)->child_added) - ((SPObjectClass *) text_parent_class)->child_added (object, rch, ref); + CItem::onChildAdded(rch, ref); text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } static void -sp_text_remove_child (SPObject *object, Inkscape::XML::Node *rch) +sp_text_child_added (SPObject *object, Inkscape::XML::Node *rch, Inkscape::XML::Node *ref) { + ((SPText*)object)->ctext->onChildAdded(rch, ref); +} + +void CText::onRemoveChild(Inkscape::XML::Node *rch) { + SPText* object = this->sptext; + SPText *text = SP_TEXT (object); - if (((SPObjectClass *) text_parent_class)->remove_child) - ((SPObjectClass *) text_parent_class)->remove_child (object, rch); + CItem::onRemoveChild(rch); text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } -static void sp_text_update(SPObject *object, SPCtx *ctx, guint flags) +static void +sp_text_remove_child (SPObject *object, Inkscape::XML::Node *rch) { + ((SPText*)object)->ctext->onRemoveChild(rch); +} + +void CText::onUpdate(SPCtx *ctx, guint flags) { + SPText* object = this->sptext; + SPText *text = SP_TEXT (object); - if (((SPObjectClass *) text_parent_class)->update) - ((SPObjectClass *) text_parent_class)->update (object, ctx, flags); + CItem::onUpdate(ctx, flags); guint cflags = (flags & SP_OBJECT_MODIFIED_CASCADE); if (flags & SP_OBJECT_MODIFIED_FLAG) cflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -262,11 +298,20 @@ static void sp_text_update(SPObject *object, SPCtx *ctx, guint flags) } } -static void sp_text_modified(SPObject *object, guint flags) +static void sp_text_update(SPObject *object, SPCtx *ctx, guint flags) { - if (((SPObjectClass *) text_parent_class)->modified) { - ((SPObjectClass *) text_parent_class)->modified (object, flags); - } + ((SPText*)object)->ctext->onUpdate(ctx, flags); +} + +void CText::onModified(guint flags) { + SPText* object = this->sptext; + + // 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 *) text_parent_class)->modified) { +// ((SPObjectClass *) text_parent_class)->modified (object, flags); +// } +// CItem::onModified(flags); guint cflags = (flags & SP_OBJECT_MODIFIED_CASCADE); if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -305,8 +350,14 @@ static void sp_text_modified(SPObject *object, guint flags) } } -static Inkscape::XML::Node *sp_text_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static void sp_text_modified(SPObject *object, guint flags) { + ((SPText*)object)->ctext->onModified(flags); +} + +Inkscape::XML::Node *CText::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPText* object = this->sptext; + SPText *text = SP_TEXT (object); if (flags & SP_OBJECT_WRITE_BUILD) { @@ -357,16 +408,19 @@ static Inkscape::XML::Node *sp_text_write(SPObject *object, Inkscape::XML::Docum text->getRepr()->setAttribute("sodipodi:linespacing", NULL); } - if (((SPObjectClass *) (text_parent_class))->write) { - ((SPObjectClass *) (text_parent_class))->write (object, xml_doc, repr, flags); - } + CItem::onWrite(xml_doc, repr, flags); return repr; } -static Geom::OptRect -sp_text_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) +static Inkscape::XML::Node *sp_text_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + return ((SPText*)object)->ctext->onWrite(xml_doc, repr, flags); +} + +Geom::OptRect CText::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { + SPText* item = this->sptext; + Geom::OptRect bbox = SP_TEXT(item)->layout.bounds(transform); // FIXME this code is incorrect @@ -377,10 +431,15 @@ sp_text_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType return bbox; } - -static Inkscape::DrawingItem * -sp_text_show(SPItem *item, Inkscape::Drawing &drawing, unsigned /* key*/, unsigned /*flags*/) +static Geom::OptRect +sp_text_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { + return ((SPText*)item)->ctext->onBbox(transform, type); +} + +Inkscape::DrawingItem* CText::onShow(Inkscape::Drawing &drawing, unsigned key, unsigned flags) { + SPText* item = this->sptext; + SPText *group = (SPText *) item; Inkscape::DrawingGroup *flowed = new Inkscape::DrawingGroup(drawing); @@ -393,15 +452,29 @@ sp_text_show(SPItem *item, Inkscape::Drawing &drawing, unsigned /* key*/, unsign return flowed; } +static Inkscape::DrawingItem * +sp_text_show(SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags) +{ + return ((SPText*)item)->ctext->onShow(drawing, key, flags); +} + +void CText::onHide(unsigned int key) { + // CPPIFY: This doesn't make no sense. + // CItem::onHide is pure and CLPEItem doesn't override it. What was the idea behind these lines? +// if (((SPItemClass *) text_parent_class)->hide) +// ((SPItemClass *) text_parent_class)->hide (item, key); +// CItem::onHide(key); +} + static void sp_text_hide(SPItem *item, unsigned key) { - if (((SPItemClass *) text_parent_class)->hide) - ((SPItemClass *) text_parent_class)->hide (item, key); + ((SPText*)item)->ctext->onHide(key); } -static char * sp_text_description(SPItem *item) -{ +gchar* CText::onDescription() { + SPText* item = this->sptext; + SPText *text = reinterpret_cast(item); SPStyle *style = text->style; @@ -433,8 +506,14 @@ static char * sp_text_description(SPItem *item) return ret; } -static void sp_text_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) +static char * sp_text_description(SPItem *item) { + return ((SPText*)item)->ctext->onDescription(); +} + +void CText::onSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { + SPText* item = this->sptext; + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE)) { // Choose a point on the baseline for snapping from or to, with the horizontal position // of this point depending on the text alignment (left vs. right) @@ -448,9 +527,14 @@ static void sp_text_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { + ((SPText*)item)->ctext->onSnappoints(p, snapprefs); +} + +Geom::Affine CText::onSetTransform(Geom::Affine const &xform) { + SPText* item = this->sptext; + SPText *text = SP_TEXT(item); // we cannot optimize textpath because changing its fontsize will break its match to the path @@ -497,9 +581,15 @@ sp_text_set_transform (SPItem *item, Geom::Affine const &xform) return ret; } -static void -sp_text_print (SPItem *item, SPPrintContext *ctx) +static Geom::Affine +sp_text_set_transform (SPItem *item, Geom::Affine const &xform) { + return ((SPText*)item)->ctext->onSetTransform(xform); +} + +void CText::onPrint(SPPrintContext *ctx) { + SPText* item = this->sptext; + SPText *group = SP_TEXT (item); Geom::OptRect pbox, bbox, dbox; @@ -511,6 +601,12 @@ sp_text_print (SPItem *item, SPPrintContext *ctx) group->layout.print(ctx,pbox,dbox,bbox,ctm); } +static void +sp_text_print (SPItem *item, SPPrintContext *ctx) +{ + ((SPText*)item)->ctext->onPrint(ctx); +} + /* * Member functions */ -- 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-text.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index d9c4df702..56b76a94f 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -123,13 +123,13 @@ sp_text_class_init (SPTextClass *classname) sp_object_class->modified = sp_text_modified; sp_object_class->write = sp_text_write; - item_class->bbox = sp_text_bbox; - item_class->show = sp_text_show; - item_class->hide = sp_text_hide; - item_class->description = sp_text_description; - item_class->snappoints = sp_text_snappoints; - item_class->set_transform = sp_text_set_transform; - item_class->print = sp_text_print; +// item_class->bbox = sp_text_bbox; +// item_class->show = sp_text_show; +// item_class->hide = sp_text_hide; +// item_class->description = sp_text_description; +// item_class->snappoints = sp_text_snappoints; +// item_class->set_transform = sp_text_set_transform; +// item_class->print = sp_text_print; } CText::CText(SPText* text) : CItem(text) { -- 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-text.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 56b76a94f..0f3ea87dd 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -115,7 +115,7 @@ sp_text_class_init (SPTextClass *classname) text_parent_class = (SPItemClass*)g_type_class_ref (SP_TYPE_ITEM); sp_object_class->release = sp_text_release; - sp_object_class->build = sp_text_build; + //sp_object_class->build = sp_text_build; sp_object_class->set = sp_text_set; sp_object_class->child_added = sp_text_child_added; sp_object_class->remove_child = sp_text_remove_child; -- 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-text.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 0f3ea87dd..fe7138cbe 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -114,14 +114,14 @@ sp_text_class_init (SPTextClass *classname) text_parent_class = (SPItemClass*)g_type_class_ref (SP_TYPE_ITEM); - sp_object_class->release = sp_text_release; - //sp_object_class->build = sp_text_build; - sp_object_class->set = sp_text_set; - sp_object_class->child_added = sp_text_child_added; - sp_object_class->remove_child = sp_text_remove_child; - sp_object_class->update = sp_text_update; - sp_object_class->modified = sp_text_modified; - sp_object_class->write = sp_text_write; +// sp_object_class->release = sp_text_release; +// //sp_object_class->build = sp_text_build; +// sp_object_class->set = sp_text_set; +// sp_object_class->child_added = sp_text_child_added; +// sp_object_class->remove_child = sp_text_remove_child; +// sp_object_class->update = sp_text_update; +// sp_object_class->modified = sp_text_modified; +// sp_object_class->write = sp_text_write; // item_class->bbox = sp_text_bbox; // item_class->show = sp_text_show; -- 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-text.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index ed3792e66..45f159b9d 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -88,17 +88,17 @@ sp_text_init (SPText *text) new (&text->attributes) TextTagAttributes; } -void CText::onRelease() { +void CText::release() { SPText* object = this->sptext; SPText *text = SP_TEXT(object); text->attributes.~TextTagAttributes(); text->layout.~Layout(); - CItem::onRelease(); + CItem::release(); } -void CText::onBuild(SPDocument *doc, Inkscape::XML::Node *repr) { +void CText::build(SPDocument *doc, Inkscape::XML::Node *repr) { SPText* object = this->sptext; object->readAttr( "x" ); @@ -107,12 +107,12 @@ void CText::onBuild(SPDocument *doc, Inkscape::XML::Node *repr) { object->readAttr( "dy" ); object->readAttr( "rotate" ); - CItem::onBuild(doc, repr); + CItem::build(doc, repr); object->readAttr( "sodipodi:linespacing" ); // has to happen after the styles are read } -void CText::onSet(unsigned int key, const gchar* value) { +void CText::set(unsigned int key, const gchar* value) { SPText* object = this->sptext; SPText *text = SP_TEXT (object); @@ -133,39 +133,39 @@ void CText::onSet(unsigned int key, const gchar* value) { object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); break; default: - CItem::onSet(key, value); + CItem::set(key, value); break; } } } -void CText::onChildAdded(Inkscape::XML::Node *rch, Inkscape::XML::Node *ref) { +void CText::child_added(Inkscape::XML::Node *rch, Inkscape::XML::Node *ref) { SPText* object = this->sptext; SPText *text = SP_TEXT (object); - CItem::onChildAdded(rch, ref); + CItem::child_added(rch, ref); text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } -void CText::onRemoveChild(Inkscape::XML::Node *rch) { +void CText::remove_child(Inkscape::XML::Node *rch) { SPText* object = this->sptext; SPText *text = SP_TEXT (object); - CItem::onRemoveChild(rch); + CItem::remove_child(rch); text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } -void CText::onUpdate(SPCtx *ctx, guint flags) { +void CText::update(SPCtx *ctx, guint flags) { SPText* object = this->sptext; SPText *text = SP_TEXT (object); - CItem::onUpdate(ctx, flags); + CItem::update(ctx, flags); guint cflags = (flags & SP_OBJECT_MODIFIED_CASCADE); if (flags & SP_OBJECT_MODIFIED_FLAG) cflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -207,7 +207,7 @@ void CText::onUpdate(SPCtx *ctx, guint flags) { } } -void CText::onModified(guint flags) { +void CText::modified(guint flags) { SPText* object = this->sptext; // CItem::onModified(flags); @@ -249,7 +249,7 @@ void CText::onModified(guint flags) { } } -Inkscape::XML::Node *CText::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node *CText::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPText* object = this->sptext; SPText *text = SP_TEXT (object); @@ -302,12 +302,12 @@ Inkscape::XML::Node *CText::onWrite(Inkscape::XML::Document *xml_doc, Inkscape:: text->getRepr()->setAttribute("sodipodi:linespacing", NULL); } - CItem::onWrite(xml_doc, repr, flags); + CItem::write(xml_doc, repr, flags); return repr; } -Geom::OptRect CText::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { +Geom::OptRect CText::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { SPText* item = this->sptext; Geom::OptRect bbox = SP_TEXT(item)->layout.bounds(transform); @@ -320,7 +320,7 @@ Geom::OptRect CText::onBbox(Geom::Affine const &transform, SPItem::BBoxType type return bbox; } -Inkscape::DrawingItem* CText::onShow(Inkscape::Drawing &drawing, unsigned key, unsigned flags) { +Inkscape::DrawingItem* CText::show(Inkscape::Drawing &drawing, unsigned key, unsigned flags) { SPText* item = this->sptext; SPText *group = (SPText *) item; @@ -336,12 +336,12 @@ Inkscape::DrawingItem* CText::onShow(Inkscape::Drawing &drawing, unsigned key, u } -void CText::onHide(unsigned int key) { +void CText::hide(unsigned int key) { // CItem::onHide(key); } -gchar* CText::onDescription() { +gchar* CText::description() { SPText* item = this->sptext; SPText *text = reinterpret_cast(item); @@ -375,7 +375,7 @@ gchar* CText::onDescription() { return ret; } -void CText::onSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { +void CText::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { SPText* item = this->sptext; if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE)) { @@ -391,7 +391,7 @@ void CText::onSnappoints(std::vector &p, Inkscape: } } -Geom::Affine CText::onSetTransform(Geom::Affine const &xform) { +Geom::Affine CText::set_transform(Geom::Affine const &xform) { SPText* item = this->sptext; SPText *text = SP_TEXT(item); @@ -440,7 +440,7 @@ Geom::Affine CText::onSetTransform(Geom::Affine const &xform) { return ret; } -void CText::onPrint(SPPrintContext *ctx) { +void CText::print(SPPrintContext *ctx) { SPText* item = this->sptext; SPText *group = SP_TEXT (item); -- cgit v1.2.3 From a5d6e692d661f0bf7648e64e8fcb04588bb8f3ab Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 1 Apr 2013 00:07:00 +0200 Subject: Prepared exchange of casting macros. (bzr r11608.1.63) --- src/sp-text.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 45f159b9d..8db9b5be3 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -79,6 +79,7 @@ static void sp_text_init (SPText *text) { text->ctext = new CText(text); + text->typeHierarchy.insert(typeid(SPText)); delete text->citem; text->citem = text->ctext; -- 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-text.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 8db9b5be3..6d9cd105d 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -61,7 +61,7 @@ /*##################################################### # SPTEXT #####################################################*/ -G_DEFINE_TYPE(SPText, sp_text, SP_TYPE_ITEM); +G_DEFINE_TYPE(SPText, sp_text, G_TYPE_OBJECT); static void sp_text_class_init (SPTextClass *classname) @@ -75,9 +75,9 @@ CText::CText(SPText* text) : CItem(text) { CText::~CText() { } -static void -sp_text_init (SPText *text) -{ +SPText::SPText() : SPItem() { + SPText* text = this; + text->ctext = new CText(text); text->typeHierarchy.insert(typeid(SPText)); @@ -89,6 +89,12 @@ sp_text_init (SPText *text) new (&text->attributes) TextTagAttributes; } +static void +sp_text_init (SPText *text) +{ + new (text) SPText(); +} + void CText::release() { SPText* object = this->sptext; -- 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-text.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 6d9cd105d..f35b9bb3b 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -58,6 +58,16 @@ #include "text-editing.h" #include "unit-constants.h" +#include "sp-factory.h" + +namespace { + SPObject* createText() { + return new SPText(); + } + + bool textRegistered = SPFactory::instance().registerObject("svg:text", createText); +} + /*##################################################### # SPTEXT #####################################################*/ -- 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-text.cpp | 280 ++++++++++++++++++++++++-------------------------------- 1 file changed, 121 insertions(+), 159 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index f35b9bb3b..386b49d26 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -71,84 +71,55 @@ namespace { /*##################################################### # SPTEXT #####################################################*/ -G_DEFINE_TYPE(SPText, sp_text, G_TYPE_OBJECT); +SPText::SPText() : SPItem(), CItem(this) { + delete this->citem; + this->citem = this; + this->cobject = this; -static void -sp_text_class_init (SPTextClass *classname) -{ -} - -CText::CText(SPText* text) : CItem(text) { - this->sptext = text; + new (&this->layout) Inkscape::Text::Layout; + new (&this->attributes) TextTagAttributes; } -CText::~CText() { +SPText::~SPText() { } -SPText::SPText() : SPItem() { - SPText* text = this; - - text->ctext = new CText(text); - text->typeHierarchy.insert(typeid(SPText)); +void SPText::build(SPDocument *doc, Inkscape::XML::Node *repr) { + this->readAttr( "x" ); + this->readAttr( "y" ); + this->readAttr( "dx" ); + this->readAttr( "dy" ); + this->readAttr( "rotate" ); - delete text->citem; - text->citem = text->ctext; - text->cobject = text->ctext; - - new (&text->layout) Inkscape::Text::Layout; - new (&text->attributes) TextTagAttributes; -} + CItem::build(doc, repr); -static void -sp_text_init (SPText *text) -{ - new (text) SPText(); + this->readAttr( "sodipodi:linespacing" ); // has to happen after the styles are read } -void CText::release() { - SPText* object = this->sptext; - - SPText *text = SP_TEXT(object); - text->attributes.~TextTagAttributes(); - text->layout.~Layout(); +void SPText::release() { + this->attributes.~TextTagAttributes(); + this->layout.~Layout(); CItem::release(); } -void CText::build(SPDocument *doc, Inkscape::XML::Node *repr) { - SPText* object = this->sptext; - - object->readAttr( "x" ); - object->readAttr( "y" ); - object->readAttr( "dx" ); - object->readAttr( "dy" ); - object->readAttr( "rotate" ); - - CItem::build(doc, repr); - - object->readAttr( "sodipodi:linespacing" ); // has to happen after the styles are read -} - -void CText::set(unsigned int key, const gchar* value) { - SPText* object = this->sptext; - - SPText *text = SP_TEXT (object); - - if (text->attributes.readSingleAttribute(key, value)) { - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +void SPText::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_LINESPACING: // convert deprecated tag to css if (value) { - text->style->line_height.set = TRUE; - text->style->line_height.inherit = FALSE; - text->style->line_height.normal = FALSE; - text->style->line_height.unit = SP_CSS_UNIT_PERCENT; - text->style->line_height.value = text->style->line_height.computed = sp_svg_read_percentage (value, 1.0); + this->style->line_height.set = TRUE; + this->style->line_height.inherit = FALSE; + this->style->line_height.normal = FALSE; + this->style->line_height.unit = SP_CSS_UNIT_PERCENT; + this->style->line_height.value = this->style->line_height.computed = sp_svg_read_percentage (value, 1.0); } - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); + + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); break; + default: CItem::set(key, value); break; @@ -156,54 +127,50 @@ void CText::set(unsigned int key, const gchar* value) { } } -void CText::child_added(Inkscape::XML::Node *rch, Inkscape::XML::Node *ref) { - SPText* object = this->sptext; - - SPText *text = SP_TEXT (object); - +void SPText::child_added(Inkscape::XML::Node *rch, Inkscape::XML::Node *ref) { CItem::child_added(rch, ref); - text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } -void CText::remove_child(Inkscape::XML::Node *rch) { - SPText* object = this->sptext; - - SPText *text = SP_TEXT (object); - +void SPText::remove_child(Inkscape::XML::Node *rch) { CItem::remove_child(rch); - text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } -void CText::update(SPCtx *ctx, guint flags) { - SPText* object = this->sptext; - - SPText *text = SP_TEXT (object); - +void SPText::update(SPCtx *ctx, guint flags) { CItem::update(ctx, flags); guint cflags = (flags & SP_OBJECT_MODIFIED_CASCADE); - if (flags & SP_OBJECT_MODIFIED_FLAG) cflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; + if (flags & SP_OBJECT_MODIFIED_FLAG) { + cflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; + } // Create temporary list of children GSList *l = NULL; - for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child, object); + + for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { + sp_object_ref(child, this); l = g_slist_prepend (l, child); } + l = g_slist_reverse (l); + while (l) { SPObject *child = reinterpret_cast(l->data); // We just built this list, so cast is safe. l = g_slist_remove (l, child); + if (cflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { /* fixme: Do we need transform? */ child->updateDisplay(ctx, cflags); } - sp_object_unref(child, object); + + sp_object_unref(child, this); } + if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG ) ) @@ -211,95 +178,103 @@ void CText::update(SPCtx *ctx, guint flags) { /* fixme: It is not nice to have it here, but otherwise children content changes does not work */ /* fixme: Even now it may not work, as we are delayed */ /* fixme: So check modification flag everywhere immediate state is used */ - text->rebuildLayout(); + this->rebuildLayout(); + + Geom::OptRect paintbox = this->geometricBounds(); - Geom::OptRect paintbox = text->geometricBounds(); - for (SPItemView* v = text->display; v != NULL; v = v->next) { + for (SPItemView* v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); - text->_clearFlow(g); - g->setStyle(object->style); - // pass the bbox of the text object as paintbox (used for paintserver fills) - text->layout.show(g, paintbox); + this->_clearFlow(g); + g->setStyle(this->style); + // pass the bbox of the this this as paintbox (used for paintserver fills) + this->layout.show(g, paintbox); } } } -void CText::modified(guint flags) { - SPText* object = this->sptext; - +void SPText::modified(guint flags) { // CItem::onModified(flags); guint cflags = (flags & SP_OBJECT_MODIFIED_CASCADE); + if (flags & SP_OBJECT_MODIFIED_FLAG) { cflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } // FIXME: all that we need to do here is to call setStyle, to set the changed // style, but there's no easy way to access the drawing glyphs or texts corresponding to a - // text object. Therefore we do here the same as in _update, that is, destroy all items + // text this. Therefore we do here the same as in _update, that is, destroy all items // and create new ones. This is probably quite wasteful. if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) { - SPText *text = SP_TEXT (object); - Geom::OptRect paintbox = text->geometricBounds(); - for (SPItemView* v = text->display; v != NULL; v = v->next) { + Geom::OptRect paintbox = this->geometricBounds(); + + for (SPItemView* v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); - text->_clearFlow(g); - g->setStyle(object->style); - text->layout.show(g, paintbox); + this->_clearFlow(g); + g->setStyle(this->style); + this->layout.show(g, paintbox); } } // Create temporary list of children GSList *l = NULL; - for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child, object); + + for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { + sp_object_ref(child, this); l = g_slist_prepend (l, child); } + l = g_slist_reverse (l); + while (l) { SPObject *child = reinterpret_cast(l->data); // We just built this list, so cast is safe. l = g_slist_remove (l, child); + if (cflags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(cflags); } - sp_object_unref(child, object); + + sp_object_unref(child, this); } } -Inkscape::XML::Node *CText::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPText* object = this->sptext; - - SPText *text = SP_TEXT (object); - +Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if (flags & SP_OBJECT_WRITE_BUILD) { if (!repr) { - repr = xml_doc->createElement("svg:text"); + repr = xml_doc->createElement("svg:this"); } + GSList *l = NULL; - for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { + + for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { continue; } + Inkscape::XML::Node *crepr = NULL; + if (SP_IS_STRING(child)) { crepr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); } else { crepr = child->updateRepr(xml_doc, NULL, flags); } + if (crepr) { l = g_slist_prepend (l, crepr); } } + 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_TITLE(child) || SP_IS_DESC(child)) { continue; } + if (SP_IS_STRING(child)) { child->getRepr()->setContent(SP_STRING(child)->string.c_str()); } else { @@ -308,15 +283,15 @@ Inkscape::XML::Node *CText::write(Inkscape::XML::Document *xml_doc, Inkscape::XM } } - text->attributes.writeTo(repr); + this->attributes.writeTo(repr); // deprecated attribute, but keep it around for backwards compatibility - if (text->style->line_height.set && !text->style->line_height.inherit && !text->style->line_height.normal && text->style->line_height.unit == SP_CSS_UNIT_PERCENT) { + if (this->style->line_height.set && !this->style->line_height.inherit && !this->style->line_height.normal && this->style->line_height.unit == SP_CSS_UNIT_PERCENT) { Inkscape::SVGOStringStream os; - os << (text->style->line_height.value * 100.0) << "%"; - text->getRepr()->setAttribute("sodipodi:linespacing", os.str().c_str()); + os << (this->style->line_height.value * 100.0) << "%"; + this->getRepr()->setAttribute("sodipodi:linespacing", os.str().c_str()); } else { - text->getRepr()->setAttribute("sodipodi:linespacing", NULL); + this->getRepr()->setAttribute("sodipodi:linespacing", NULL); } CItem::write(xml_doc, repr, flags); @@ -324,50 +299,43 @@ Inkscape::XML::Node *CText::write(Inkscape::XML::Document *xml_doc, Inkscape::XM return repr; } -Geom::OptRect CText::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { - SPText* item = this->sptext; - - Geom::OptRect bbox = SP_TEXT(item)->layout.bounds(transform); +Geom::OptRect SPText::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { + Geom::OptRect bbox = SP_TEXT(this)->layout.bounds(transform); // FIXME this code is incorrect - if (bbox && type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + if (bbox && type == SPItem::VISUAL_BBOX && !this->style->stroke.isNone()) { double scale = transform.descrim(); - bbox->expandBy(0.5 * item->style->stroke_width.computed * scale); + bbox->expandBy(0.5 * this->style->stroke_width.computed * scale); } + return bbox; } -Inkscape::DrawingItem* CText::show(Inkscape::Drawing &drawing, unsigned key, unsigned flags) { - SPText* item = this->sptext; - - SPText *group = (SPText *) item; - +Inkscape::DrawingItem* SPText::show(Inkscape::Drawing &drawing, unsigned key, unsigned flags) { Inkscape::DrawingGroup *flowed = new Inkscape::DrawingGroup(drawing); flowed->setPickChildren(false); - flowed->setStyle(group->style); + flowed->setStyle(this->style); // pass the bbox of the text object as paintbox (used for paintserver fills) - group->layout.show(flowed, group->geometricBounds()); + this->layout.show(flowed, this->geometricBounds()); return flowed; } -void CText::hide(unsigned int key) { +void SPText::hide(unsigned int key) { // CItem::onHide(key); } -gchar* CText::description() { - SPText* item = this->sptext; - - SPText *text = reinterpret_cast(item); - SPStyle *style = text->style; +gchar* SPText::description() { + SPStyle *style = this->style; font_instance *tf = font_factory::Default()->FaceFromStyle(style); char name_buf[256]; char *n; + if (tf) { tf->Family(name_buf, sizeof(name_buf)); n = xml_quote_strdup(name_buf); @@ -380,41 +348,38 @@ gchar* CText::description() { GString *xs = SP_PX_TO_METRIC_STRING(style->font_size.computed, sp_desktop_namedview(SP_ACTIVE_DESKTOP)->getDefaultMetric()); char const *trunc = ""; - Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); + Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) this); + if (layout && layout->inputTruncated()) { trunc = _(" [truncated]"); } - char *ret = ( SP_IS_TEXT_TEXTPATH(item) + char *ret = ( SP_IS_TEXT_TEXTPATH(this) ? g_strdup_printf(_("Text on path%s (%s, %s)"), trunc, n, xs->str) : g_strdup_printf(_("Text%s (%s, %s)"), trunc, n, xs->str) ); g_free(n); return ret; } -void CText::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { - SPText* item = this->sptext; - +void SPText::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE)) { // Choose a point on the baseline for snapping from or to, with the horizontal position // of this point depending on the text alignment (left vs. right) - Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); + Inkscape::Text::Layout const *layout = te_get_layout(this); + if (layout != NULL && layout->outputExists()) { boost::optional pt = layout->baselineAnchorPoint(); + if (pt) { - p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2dt_affine(), Inkscape::SNAPSOURCE_TEXT_ANCHOR, Inkscape::SNAPTARGET_TEXT_ANCHOR)); + p.push_back(Inkscape::SnapCandidatePoint((*pt) * this->i2dt_affine(), Inkscape::SNAPSOURCE_TEXT_ANCHOR, Inkscape::SNAPTARGET_TEXT_ANCHOR)); } } } } -Geom::Affine CText::set_transform(Geom::Affine const &xform) { - SPText* item = this->sptext; - - SPText *text = SP_TEXT(item); - +Geom::Affine SPText::set_transform(Geom::Affine const &xform) { // we cannot optimize textpath because changing its fontsize will break its match to the path - if (SP_IS_TEXT_TEXTPATH (text)) + if (SP_IS_TEXT_TEXTPATH (this)) return xform; /* This function takes care of scaling & translation only, we return whatever parts we can't @@ -438,37 +403,34 @@ Geom::Affine CText::set_transform(Geom::Affine const &xform) { ret[3] /= ex; // Adjust x/y, dx/dy - text->_adjustCoordsRecursive (item, xform * ret.inverse(), ex); + this->_adjustCoordsRecursive (this, xform * ret.inverse(), ex); // Adjust font size - text->_adjustFontsizeRecursive (item, ex); + this->_adjustFontsizeRecursive (this, ex); // Adjust stroke width - item->adjust_stroke_width_recursive (ex); + this->adjust_stroke_width_recursive (ex); // Adjust pattern fill - item->adjust_pattern(xform * ret.inverse()); + this->adjust_pattern(xform * ret.inverse()); // Adjust gradient fill - item->adjust_gradient(xform * ret.inverse()); + this->adjust_gradient(xform * ret.inverse()); - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); return ret; } -void CText::print(SPPrintContext *ctx) { - SPText* item = this->sptext; - - SPText *group = SP_TEXT (item); +void SPText::print(SPPrintContext *ctx) { Geom::OptRect pbox, bbox, dbox; + pbox = this->geometricBounds(); + bbox = this->desktopVisualBounds(); + dbox = Geom::Rect::from_xywh(Geom::Point(0,0), this->document->getDimensions()); - pbox = item->geometricBounds(); - bbox = item->desktopVisualBounds(); - dbox = Geom::Rect::from_xywh(Geom::Point(0,0), item->document->getDimensions()); - Geom::Affine const ctm (item->i2dt_affine()); + Geom::Affine const ctm (this->i2dt_affine()); - group->layout.print(ctx,pbox,dbox,bbox,ctm); + this->layout.print(ctx,pbox,dbox,bbox,ctm); } /* -- 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-text.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 386b49d26..c59093ae9 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -71,9 +71,7 @@ namespace { /*##################################################### # SPTEXT #####################################################*/ -SPText::SPText() : SPItem(), CItem(this) { - delete this->citem; - this->citem = this; +SPText::SPText() : SPItem() { this->cobject = this; new (&this->layout) Inkscape::Text::Layout; @@ -90,7 +88,7 @@ void SPText::build(SPDocument *doc, Inkscape::XML::Node *repr) { this->readAttr( "dy" ); this->readAttr( "rotate" ); - CItem::build(doc, repr); + SPItem::build(doc, repr); this->readAttr( "sodipodi:linespacing" ); // has to happen after the styles are read } @@ -99,7 +97,7 @@ void SPText::release() { this->attributes.~TextTagAttributes(); this->layout.~Layout(); - CItem::release(); + SPItem::release(); } void SPText::set(unsigned int key, const gchar* value) { @@ -121,27 +119,27 @@ void SPText::set(unsigned int key, const gchar* value) { break; default: - CItem::set(key, value); + SPItem::set(key, value); break; } } } void SPText::child_added(Inkscape::XML::Node *rch, Inkscape::XML::Node *ref) { - CItem::child_added(rch, ref); + SPItem::child_added(rch, ref); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } void SPText::remove_child(Inkscape::XML::Node *rch) { - CItem::remove_child(rch); + SPItem::remove_child(rch); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } void SPText::update(SPCtx *ctx, guint flags) { - CItem::update(ctx, flags); + SPItem::update(ctx, flags); guint cflags = (flags & SP_OBJECT_MODIFIED_CASCADE); @@ -193,7 +191,7 @@ void SPText::update(SPCtx *ctx, guint flags) { } void SPText::modified(guint flags) { -// CItem::onModified(flags); +// SPItem::onModified(flags); guint cflags = (flags & SP_OBJECT_MODIFIED_CASCADE); @@ -294,7 +292,7 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X this->getRepr()->setAttribute("sodipodi:linespacing", NULL); } - CItem::write(xml_doc, repr, flags); + SPItem::write(xml_doc, repr, flags); return repr; } @@ -324,7 +322,7 @@ Inkscape::DrawingItem* SPText::show(Inkscape::Drawing &drawing, unsigned key, un void SPText::hide(unsigned int key) { -// CItem::onHide(key); +// SPItem::onHide(key); } -- 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-text.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index c59093ae9..89d1f6510 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -72,8 +72,6 @@ namespace { # SPTEXT #####################################################*/ SPText::SPText() : SPItem() { - this->cobject = this; - new (&this->layout) Inkscape::Text::Layout; new (&this->attributes) TextTagAttributes; } -- 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-text.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 89d1f6510..3771238e0 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -72,8 +72,8 @@ namespace { # SPTEXT #####################################################*/ SPText::SPText() : SPItem() { - new (&this->layout) Inkscape::Text::Layout; - new (&this->attributes) TextTagAttributes; + //new (&this->layout) Inkscape::Text::Layout; + //new (&this->attributes) TextTagAttributes; } SPText::~SPText() { @@ -92,8 +92,8 @@ void SPText::build(SPDocument *doc, Inkscape::XML::Node *repr) { } void SPText::release() { - this->attributes.~TextTagAttributes(); - this->layout.~Layout(); + //this->attributes.~TextTagAttributes(); + //this->layout.~Layout(); SPItem::release(); } -- cgit v1.2.3 From eb3598e7e27619c759ef33bb9ec4ffb8898523de Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 20 Sep 2013 00:45:16 -0400 Subject: Refactor status-bar text for multiple items, was very broken Fixed bugs: - https://launchpad.net/bugs/1199192 (bzr r12550) --- src/sp-text.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 85137e58d..afd4e304e 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -321,6 +321,9 @@ void SPText::hide(unsigned int key) { // SPItem::onHide(key); } +const char* SPText::display_name() { + return _("Text"); +} gchar* SPText::description() { SPStyle *style = this->style; @@ -350,8 +353,8 @@ gchar* SPText::description() { } char *ret = ( SP_IS_TEXT_TEXTPATH(this) - ? g_strdup_printf(_("Text on path%s (%s, %s)"), trunc, n, xs->str) - : g_strdup_printf(_("Text%s (%s, %s)"), trunc, n, xs->str) ); + ? g_strdup_printf(_("on path%s (%s, %s)"), trunc, n, xs->str) + : g_strdup_printf(_("%s (%s, %s)"), trunc, n, xs->str) ); g_free(n); return ret; } -- cgit v1.2.3