diff options
| author | Adrian Boguszewski <adrbogus1@student.pg.gda.pl> | 2016-07-13 11:36:19 +0000 |
|---|---|---|
| committer | Adrian Boguszewski <adrbogus1@student.pg.gda.pl> | 2016-07-13 11:36:19 +0000 |
| commit | d1947e768272c703674129d5c583204ff2b59251 (patch) | |
| tree | c1bf1563d0c0837cbab3733c18df0c7c82b18ff4 /src/text-editing.cpp | |
| parent | Merged trunk (diff) | |
| download | inkscape-d1947e768272c703674129d5c583204ff2b59251.tar.gz inkscape-d1947e768272c703674129d5c583204ff2b59251.zip | |
Second part of new SPObject children list
(bzr r14954.1.19)
Diffstat (limited to 'src/text-editing.cpp')
| -rw-r--r-- | src/text-editing.cpp | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 057523b1e..b03be792b 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -91,8 +91,8 @@ bool sp_te_input_is_empty(SPObject const *item) if (SP_IS_STRING(item)) { empty = SP_STRING(item)->string.empty(); } else { - for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { - if (!sp_te_input_is_empty(child)) { + for (auto& child: item->_children) { + if (!sp_te_input_is_empty(&child)) { empty = false; break; } @@ -237,11 +237,11 @@ unsigned sp_text_get_length(SPObject const *item) length++; } - for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { - if (SP_IS_STRING(child)) { - length += SP_STRING(child)->string.length(); + for (auto& child: item->_children) { + if (SP_IS_STRING(&child)) { + length += SP_STRING(&child)->string.length(); } else { - length += sp_text_get_length(child); + length += sp_text_get_length(&child); } } } @@ -267,22 +267,22 @@ unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto) } // Count the length of the children - for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { - if (upto && child == upto) { + for (auto& child: item->_children) { + if (upto && &child == upto) { // hit upto, return immediately return length; } - if (SP_IS_STRING(child)) { - length += SP_STRING(child)->string.length(); + if (SP_IS_STRING(&child)) { + length += SP_STRING(&child)->string.length(); } else { - if (upto && child->isAncestorOf(upto)) { + if (upto && child.isAncestorOf(upto)) { // upto is below us, recurse and break loop - length += sp_text_get_length_upto(child, upto); + length += sp_text_get_length_upto(&child, upto); return length; } else { // recurse and go to the next sibling - length += sp_text_get_length_upto(child, upto); + length += sp_text_get_length_upto(&child, upto); } } } @@ -323,8 +323,11 @@ to \a item at the same level. */ static unsigned sum_sibling_text_lengths_before(SPObject const *item) { unsigned char_index = 0; - for (SPObject *sibling = item->parent->firstChild() ; sibling && sibling != item ; sibling = sibling->getNext()) { - char_index += sp_text_get_length(sibling); + for (auto& sibling: item->parent->_children) { + if (&sibling == item) { + break; + } + char_index += sp_text_get_length(&sibling); } return char_index; } @@ -857,11 +860,11 @@ static void sp_te_get_ustring_multiline(SPObject const *root, Glib::ustring *str if (*pending_line_break) { *string += '\n'; } - for (SPObject const *child = root->firstChild() ; child ; child = child->getNext()) { - if (SP_IS_STRING(child)) { - *string += SP_STRING(child)->string; + for (auto& child: root->_children) { + if (SP_IS_STRING(&child)) { + *string += SP_STRING(&child)->string; } else { - sp_te_get_ustring_multiline(child, string, pending_line_break); + sp_te_get_ustring_multiline(&child, string, pending_line_break); } } if (!SP_IS_TEXT(root) && !SP_IS_TEXTPATH(root) && is_line_break_object(root)) { @@ -1405,17 +1408,17 @@ static void apply_css_recursive(SPObject *o, SPCSSAttr const *css) { sp_repr_css_change(o->getRepr(), const_cast<SPCSSAttr*>(css), "style"); - for (SPObject *child = o->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: o->_children) { if (sp_repr_css_property(const_cast<SPCSSAttr*>(css), "opacity", NULL) != NULL) { // Unset properties which are accumulating and thus should not be set recursively. // For example, setting opacity 0.5 on a group recursively would result in the visible opacity of 0.25 for an item in the group. SPCSSAttr *css_recurse = sp_repr_css_attr_new(); sp_repr_css_merge(css_recurse, const_cast<SPCSSAttr*>(css)); sp_repr_css_set_property(css_recurse, "opacity", NULL); - apply_css_recursive(child, css_recurse); + apply_css_recursive(&child, css_recurse); sp_repr_css_attr_unref(css_recurse); } else { - apply_css_recursive(child, const_cast<SPCSSAttr*>(css)); + apply_css_recursive(&child, const_cast<SPCSSAttr*>(css)); } } } @@ -1429,7 +1432,7 @@ static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const * { bool passed_start = start_item == NULL ? true : false; Inkscape::XML::Document *xml_doc = common_ancestor->document->getReprDoc(); - + for (SPObject *child = common_ancestor->firstChild() ; child ; child = child->getNext()) { if (start_item == child) { passed_start = true; @@ -2073,8 +2076,8 @@ bool has_visible_text(SPObject *obj) if (SP_IS_STRING(obj) && !SP_STRING(obj)->string.empty()) { hasVisible = true; // maybe we should also check that it's not all whitespace? } else { - for (SPObject const *child = obj->firstChild() ; child ; child = child->getNext()) { - if (has_visible_text(const_cast<SPObject *>(child))) { + for (auto& child: obj->_children) { + if (has_visible_text(const_cast<SPObject *>(&child))) { hasVisible = true; break; } |
