From d1947e768272c703674129d5c583204ff2b59251 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 13 Jul 2016 13:36:19 +0200 Subject: Second part of new SPObject children list (bzr r14954.1.19) --- src/sp-text.cpp | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 4afc38524..5126ae094 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -155,9 +155,9 @@ void SPText::update(SPCtx *ctx, guint flags) { // Create temporary list of children GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child, this); - l = g_slist_prepend (l, child); + for (auto& child: _children) { + sp_object_ref(&child, this); + l = g_slist_prepend (l, &child); } l = g_slist_reverse (l); @@ -235,9 +235,9 @@ void SPText::modified(guint flags) { // Create temporary list of children GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child, this); - l = g_slist_prepend (l, child); + for (auto& child: _children) { + sp_object_ref(&child, this); + l = g_slist_prepend (l, &child); } l = g_slist_reverse (l); @@ -262,17 +262,17 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + for (auto& child: _children) { + 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()); + if (SP_IS_STRING(&child)) { + crepr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } else { - crepr = child->updateRepr(xml_doc, NULL, flags); + crepr = child.updateRepr(xml_doc, NULL, flags); } if (crepr) { @@ -286,15 +286,15 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X l = g_slist_remove (l, l->data); } } else { - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + for (auto& child: _children) { + if (SP_IS_TITLE(&child) || SP_IS_DESC(&child)) { continue; } - if (SP_IS_STRING(child)) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + if (SP_IS_STRING(&child)) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } else { - child->updateRepr(flags); + child.updateRepr(flags); } } } @@ -606,16 +606,16 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio } } - for (SPObject *child = root->firstChild() ; child ; child = child->getNext() ) { - SPString *str = dynamic_cast(child); + for (auto& child: root->_children) { + SPString *str = dynamic_cast(&child); if (str) { Glib::ustring const &string = str->string; // std::cout << " Appending: >" << string << "<" << std::endl; - layout.appendText(string, root->style, child, &optional_attrs, child_attrs_offset + length); + layout.appendText(string, root->style, &child, &optional_attrs, child_attrs_offset + length); length += string.length(); - } else if (!sp_repr_is_meta_element(child->getRepr())) { + } else if (!sp_repr_is_meta_element(child.getRepr())) { /* ^^^^ XML Tree being directly used here while it shouldn't be.*/ - length += _buildLayoutInput(child, optional_attrs, child_attrs_offset + length, in_textpath); + length += _buildLayoutInput(&child, optional_attrs, child_attrs_offset + length, in_textpath); } } @@ -628,9 +628,9 @@ void SPText::rebuildLayout() Inkscape::Text::Layout::OptionalTextTagAttrs optional_attrs; _buildLayoutInput(this, optional_attrs, 0, false); layout.calculateFlow(); - for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TEXTPATH(child)) { - SPTextPath const *textpath = SP_TEXTPATH(child); + for (auto& child: _children) { + if (SP_IS_TEXTPATH(&child)) { + SPTextPath const *textpath = SP_TEXTPATH(&child); if (textpath->originalPath != NULL) { //g_print("%s", layout.dumpAsText().c_str()); layout.fitToPathAlign(textpath->startOffset, *textpath->originalPath); @@ -640,9 +640,9 @@ void SPText::rebuildLayout() //g_print("%s", layout.dumpAsText().c_str()); // set the x,y attributes on role:line spans - for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TSPAN(child)) { - SPTSpan *tspan = SP_TSPAN(child); + for (auto& child: _children) { + if (SP_IS_TSPAN(&child)) { + SPTSpan *tspan = SP_TSPAN(&child); if ( (tspan->role != SP_TSPAN_ROLE_UNSPECIFIED) && tspan->attributes.singleXYCoordinates() ) { Inkscape::Text::Layout::iterator iter = layout.sourceToIterator(tspan); -- cgit v1.2.3 From 9e210a6d1333c3366681547e3e81593ef69ff73e Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 12:56:49 +0200 Subject: Last part of new SPObject children list (bzr r14954.1.20) --- src/sp-text.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 5126ae094..193289c2b 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -676,9 +676,9 @@ void SPText::_adjustFontsizeRecursive(SPItem *item, double ex, bool is_root) item->updateRepr(); } - for (SPObject *o = item->children; o != NULL; o = o->next) { - if (SP_IS_ITEM(o)) - _adjustFontsizeRecursive(SP_ITEM(o), ex, false); + for(auto& o: item->_children) { + if (SP_IS_ITEM(&o)) + _adjustFontsizeRecursive(SP_ITEM(&o), ex, false); } } @@ -695,9 +695,9 @@ void SPText::_adjustCoordsRecursive(SPItem *item, Geom::Affine const &m, double SP_TREF(item)->attributes.transform(m, ex, ex, is_root); } - for (SPObject *o = item->children; o != NULL; o = o->next) { - if (SP_IS_ITEM(o)) - _adjustCoordsRecursive(SP_ITEM(o), m, ex, false); + for(auto& o: item->_children) { + if (SP_IS_ITEM(&o)) + _adjustCoordsRecursive(SP_ITEM(&o), m, ex, false); } } -- cgit v1.2.3 From 24d3f50003ca3cec6a03a7f5267cc4fe5588c69f Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 13:17:21 +0200 Subject: Renamed children list in SPObject (bzr r14954.1.21) --- src/sp-text.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 193289c2b..e52869942 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -155,7 +155,7 @@ void SPText::update(SPCtx *ctx, guint flags) { // Create temporary list of children GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child, this); l = g_slist_prepend (l, &child); } @@ -235,7 +235,7 @@ void SPText::modified(guint flags) { // Create temporary list of children GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child, this); l = g_slist_prepend (l, &child); } @@ -262,7 +262,7 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_TITLE(&child) || SP_IS_DESC(&child)) { continue; } @@ -286,7 +286,7 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X l = g_slist_remove (l, l->data); } } else { - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_TITLE(&child) || SP_IS_DESC(&child)) { continue; } @@ -606,7 +606,7 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio } } - for (auto& child: root->_children) { + for (auto& child: root->children) { SPString *str = dynamic_cast(&child); if (str) { Glib::ustring const &string = str->string; @@ -628,7 +628,7 @@ void SPText::rebuildLayout() Inkscape::Text::Layout::OptionalTextTagAttrs optional_attrs; _buildLayoutInput(this, optional_attrs, 0, false); layout.calculateFlow(); - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_TEXTPATH(&child)) { SPTextPath const *textpath = SP_TEXTPATH(&child); if (textpath->originalPath != NULL) { @@ -640,7 +640,7 @@ void SPText::rebuildLayout() //g_print("%s", layout.dumpAsText().c_str()); // set the x,y attributes on role:line spans - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_TSPAN(&child)) { SPTSpan *tspan = SP_TSPAN(&child); if ( (tspan->role != SP_TSPAN_ROLE_UNSPECIFIED) @@ -676,7 +676,7 @@ void SPText::_adjustFontsizeRecursive(SPItem *item, double ex, bool is_root) item->updateRepr(); } - for(auto& o: item->_children) { + for(auto& o: item->children) { if (SP_IS_ITEM(&o)) _adjustFontsizeRecursive(SP_ITEM(&o), ex, false); } @@ -695,7 +695,7 @@ void SPText::_adjustCoordsRecursive(SPItem *item, Geom::Affine const &m, double SP_TREF(item)->attributes.transform(m, ex, ex, is_root); } - for(auto& o: item->_children) { + for(auto& o: item->children) { if (SP_IS_ITEM(&o)) _adjustCoordsRecursive(SP_ITEM(&o), m, ex, false); } -- cgit v1.2.3 From f35bb1f74a0ffeb5c6477a25e3c4cde87a97bcf1 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 12:06:06 +0200 Subject: Removed unused includes, decrease compilation time (bzr r15025) --- src/sp-text.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 4afc38524..2e1d4993d 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -29,17 +29,14 @@ #include #include "svg/svg.h" -#include "svg/stringstream.h" #include "display/drawing-text.h" #include "attributes.h" #include "document.h" #include "preferences.h" #include "desktop.h" #include "sp-namedview.h" -#include "style.h" #include "inkscape.h" #include "xml/quote.h" -#include "xml/repr.h" #include "mod360.h" #include "sp-title.h" #include "sp-desc.h" @@ -52,9 +49,7 @@ #include "text-editing.h" // For SVG 2 text flow -#include "livarot/Path.h" #include "livarot/Shape.h" -#include "sp-shape.h" #include "display/curve.h" /*##################################################### -- cgit v1.2.3 From 43b49e325db73cc19b1731db6c69545664ee8fbe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 13:26:17 +0200 Subject: Reverted changes to r15024 after many building problems (bzr r15027) --- src/sp-text.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 2e1d4993d..4afc38524 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -29,14 +29,17 @@ #include #include "svg/svg.h" +#include "svg/stringstream.h" #include "display/drawing-text.h" #include "attributes.h" #include "document.h" #include "preferences.h" #include "desktop.h" #include "sp-namedview.h" +#include "style.h" #include "inkscape.h" #include "xml/quote.h" +#include "xml/repr.h" #include "mod360.h" #include "sp-title.h" #include "sp-desc.h" @@ -49,7 +52,9 @@ #include "text-editing.h" // For SVG 2 text flow +#include "livarot/Path.h" #include "livarot/Shape.h" +#include "sp-shape.h" #include "display/curve.h" /*##################################################### -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/sp-text.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 4afc38524..2e1d4993d 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -29,17 +29,14 @@ #include #include "svg/svg.h" -#include "svg/stringstream.h" #include "display/drawing-text.h" #include "attributes.h" #include "document.h" #include "preferences.h" #include "desktop.h" #include "sp-namedview.h" -#include "style.h" #include "inkscape.h" #include "xml/quote.h" -#include "xml/repr.h" #include "mod360.h" #include "sp-title.h" #include "sp-desc.h" @@ -52,9 +49,7 @@ #include "text-editing.h" // For SVG 2 text flow -#include "livarot/Path.h" #include "livarot/Shape.h" -#include "sp-shape.h" #include "display/curve.h" /*##################################################### -- cgit v1.2.3 From 4f0e9e1e2b91c661060f1dcd45deb3dc53c72093 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 29 Aug 2016 14:30:41 +0200 Subject: Don't write out sodipodi:line-spacing. Don't read if 'line-height' already set. Partial fix for #1590141. (bzr r15085) --- src/sp-text.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 9beb812f5..b066ca3de 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -93,14 +93,16 @@ void SPText::set(unsigned int key, const gchar* value) { } else { switch (key) { case SP_ATTR_SODIPODI_LINESPACING: - // convert deprecated tag to css - if (value) { + // convert deprecated tag to css... but only if 'line-height' missing. + if (value && !this->style->line_height.set) { 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); } + // Remove deprecated attribute + this->getRepr()->setAttribute("sodipodi:linespacing", NULL); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); break; @@ -297,15 +299,6 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X this->attributes.writeTo(repr); this->rebuildLayout(); // copied from update(), see LP Bug 1339305 - // deprecated attribute, but keep it around for backwards compatibility - 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 << (this->style->line_height.value * 100.0) << "%"; - this->getRepr()->setAttribute("sodipodi:linespacing", os.str().c_str()); - } else { - this->getRepr()->setAttribute("sodipodi:linespacing", NULL); - } - // SVG 2 Auto-wrapped text if( this->width.computed > 0.0 ) { sp_repr_set_svg_double(repr, "width", this->width.computed); -- cgit v1.2.3