From 94b74cf00f2d605cb8268d9fe05d0bad78077f1c Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Thu, 10 Jul 2014 15:13:09 -0400 Subject: refresh SPCurve in a cloned clip (Bug 1322940) Fixed bugs: - https://launchpad.net/bugs/1322940 (bzr r13448) --- src/sp-use.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index e8fe3687f..7d908a66a 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -37,6 +37,7 @@ #include "sp-symbol.h" #include "sp-use.h" #include "sp-use-reference.h" +#include "sp-shape.h" namespace { SPObject* createUse() { @@ -176,6 +177,8 @@ Inkscape::XML::Node* SPUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XM g_free(uri_string); } + if (SP_IS_SHAPE(this->child)) + SP_SHAPE(this->child)->set_shape(); // evaluate SPCurve of child return repr; } -- cgit v1.2.3 From 962b4e5a31b1128cdb9dfcccac87e7449a3351f1 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Fri, 25 Jul 2014 17:23:13 -0400 Subject: refresh text objects when clipping (Bug 1339305) Fixed bugs: - https://launchpad.net/bugs/1339305 (bzr r13470) --- src/sp-use.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 7d908a66a..e3fcd252a 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -38,6 +38,8 @@ #include "sp-use.h" #include "sp-use-reference.h" #include "sp-shape.h" +#include "sp-text.h" +#include "sp-flowtext.h" namespace { SPObject* createUse() { @@ -177,8 +179,16 @@ Inkscape::XML::Node* SPUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XM g_free(uri_string); } - if (SP_IS_SHAPE(this->child)) + if (SP_IS_SHAPE(this->child)) { SP_SHAPE(this->child)->set_shape(); // evaluate SPCurve of child + } else if (SP_IS_TEXT(this->child)) { + SP_TEXT(this->child)->rebuildLayout(); // refresh Layout, LP Bug 1339305 + } else if (SP_IS_FLOWTEXT(this->child)) { + if (SP_IS_FLOWREGION(SP_FLOWTEXT(this->child)->firstChild())) + SP_FLOWREGION(SP_FLOWTEXT(this->child)->firstChild())->UpdateComputed(); + SP_FLOWTEXT(this->child)->rebuildLayout(); + } + return repr; } -- cgit v1.2.3 From e179290f049d5c34ae2b9c05fdfeab830b7c39e7 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 10 Nov 2014 09:39:33 -0800 Subject: Removed SP_USE/SP_IS_USE Gtk-ish macros and cleaned affected files. (bzr r13700) --- src/sp-use.cpp | 109 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 45 deletions(-) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index e3fcd252a..2bd6757ff 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -50,10 +50,17 @@ namespace { } SPUse::SPUse() - : SPItem() - , child(NULL) - , href(NULL) - , ref(new SPUseReference(this)) + : SPItem(), + child(NULL), + x(), + y(), + width(), + height(), + href(NULL), + ref(new SPUseReference(this)), + _delete_connection(), + _changed_connection(), + _transformed_connection() { this->x.unset(); this->y.unset(); @@ -179,14 +186,23 @@ Inkscape::XML::Node* SPUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XM g_free(uri_string); } - if (SP_IS_SHAPE(this->child)) { - SP_SHAPE(this->child)->set_shape(); // evaluate SPCurve of child - } else if (SP_IS_TEXT(this->child)) { - SP_TEXT(this->child)->rebuildLayout(); // refresh Layout, LP Bug 1339305 - } else if (SP_IS_FLOWTEXT(this->child)) { - if (SP_IS_FLOWREGION(SP_FLOWTEXT(this->child)->firstChild())) - SP_FLOWREGION(SP_FLOWTEXT(this->child)->firstChild())->UpdateComputed(); - SP_FLOWTEXT(this->child)->rebuildLayout(); + SPShape *shape = dynamic_cast(child); + if (shape) { + shape->set_shape(); // evaluate SPCurve of child + } else { + SPText *text = dynamic_cast(child); + if (text) { + text->rebuildLayout(); // refresh Layout, LP Bug 1339305 + } else { + SPFlowtext *flowtext = dynamic_cast(child); + if (flowtext) { + SPFlowregion *flowregion = dynamic_cast(flowtext->firstChild()); + if (flowregion) { + flowregion->UpdateComputed(); + } + flowtext->rebuildLayout(); + } + } } return repr; @@ -223,18 +239,18 @@ void SPUse::print(SPPrintContext* ctx) { } const char* SPUse::displayName() const { - if (this->child && SP_IS_SYMBOL( this->child )) { + if (dynamic_cast(child)) { return _("Symbol"); + } else { + return _("Clone"); } - - return _("Clone"); } gchar* SPUse::description() const { - if (this->child) { - if( SP_IS_SYMBOL( this->child ) ) { - if (this->child->title()) { - return g_strdup_printf(_("called %s"), Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", this->child->title()))).c_str()); + if (child) { + if ( dynamic_cast(child) ) { + if (child->title()) { + return g_strdup_printf(_("called %s"), Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", child->title()))).c_str()); } else { return g_strdup_printf(_("called %s"), _("Unnamed Symbol")); } @@ -302,12 +318,10 @@ void SPUse::hide(unsigned int key) { SPItem *SPUse::root() { SPItem *orig = this->child; - while (orig && SP_IS_USE(orig)) { - orig = SP_USE(orig)->child; - } - - if (!orig) { - return NULL; + SPUse *use = dynamic_cast(orig); + while (orig && use) { + orig = use->child; + use = dynamic_cast(orig); } return orig; @@ -325,13 +339,16 @@ int SPUse::cloneDepth() const { unsigned depth = 1; SPItem *orig = this->child; - while (orig && SP_IS_USE(orig)) { + while (orig && dynamic_cast(orig)) { ++depth; - orig = SP_USE(orig)->child; + orig = dynamic_cast(orig)->child; } - if (!orig) return -1; - return depth; + if (!orig) { + return -1; + } else { + return depth; + } } /** @@ -345,9 +362,9 @@ Geom::Affine SPUse::get_root_transform() { GSList *chain = NULL; chain = g_slist_prepend(chain, this); - while (SP_IS_USE(orig)) { + while (dynamic_cast(orig)) { chain = g_slist_prepend(chain, orig); - orig = SP_USE(orig)->child; + orig = dynamic_cast(orig)->child; } chain = g_slist_prepend(chain, orig); @@ -357,14 +374,13 @@ Geom::Affine SPUse::get_root_transform() { Geom::Affine t(Geom::identity()); for (GSList *i = chain; i != NULL; i = i->next) { - SPItem *i_tem = SP_ITEM(i->data); + SPItem *i_tem = reinterpret_cast(i->data); // "An additional transformation translate(x,y) is appended to the end (i.e., // right-side) of the transform attribute on the generated 'g', where x and y // represent the values of the x and y attributes on the 'use' element." - http://www.w3.org/TR/SVG11/struct.html#UseElement - if (SP_IS_USE(i_tem)) { - SPUse *i_use = SP_USE(i_tem); - + SPUse *i_use = dynamic_cast(i_tem); + if (i_use) { if ((i_use->x._set && i_use->x.computed != 0) || (i_use->y._set && i_use->y.computed != 0)) { t = t * Geom::Translate(i_use->x._set ? i_use->x.computed : 0, i_use->y._set ? i_use->y.computed : 0); } @@ -405,7 +421,7 @@ void SPUse::move_compensate(Geom::Affine const *mp) { } // never compensate uses which are used in flowtext - if (this->parent && SP_IS_FLOWREGION(this->parent)) { + if (parent && dynamic_cast(parent)) { return; } @@ -462,8 +478,9 @@ void SPUse::href_changed() { SPObject* obj = SPFactory::instance().createObject(NodeTraits::get_type_string(*childrepr)); - if (SP_IS_ITEM(obj)) { - this->child = SP_ITEM(obj); + SPItem *item = dynamic_cast(obj); + if (item) { + child = item; this->attach(this->child, this->lastChild()); sp_object_unref(this->child, this); @@ -495,8 +512,8 @@ void SPUse::href_changed() { void SPUse::delete_self() { // always delete uses which are used in flowtext - if (this->parent && SP_IS_FLOWREGION(this->parent)) { - this->deleteObject(); + if (parent && dynamic_cast(parent)) { + deleteObject(); return; } @@ -547,9 +564,10 @@ void SPUse::update(SPCtx *ctx, unsigned flags) { sp_object_ref(this->child); if (childflags || (this->child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { - SPItem const &chi = *SP_ITEM(this->child); - cctx.i2doc = chi.transform * ictx->i2doc; - cctx.i2vp = chi.transform * ictx->i2vp; + SPItem const *chi = dynamic_cast(child); + g_assert(chi != NULL); + cctx.i2doc = chi->transform * ictx->i2doc; + cctx.i2vp = chi->transform * ictx->i2vp; this->child->updateDisplay((SPCtx *)&cctx, childflags); } @@ -621,7 +639,7 @@ SPItem *SPUse::unlink() { Inkscape::XML::Node *copy = NULL; - if (SP_IS_SYMBOL(orig)) { // make a group, copy children + if (dynamic_cast(orig)) { // make a group, copy children copy = xml_doc->createElement("svg:g"); for (Inkscape::XML::Node *child = orig->getRepr()->firstChild() ; child != NULL; child = child->next()) { @@ -669,7 +687,8 @@ SPItem *SPUse::unlink() { this->setSuccessor(unlinked); sp_object_unref(this, NULL); - SPItem *item = SP_ITEM(unlinked); + SPItem *item = dynamic_cast(unlinked); + g_assert(item != NULL); // Set the accummulated transform. { -- cgit v1.2.3