summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdrian Boguszewski <adrbogus1@student.pg.gda.pl>2016-07-13 11:36:19 +0000
committerAdrian Boguszewski <adrbogus1@student.pg.gda.pl>2016-07-13 11:36:19 +0000
commitd1947e768272c703674129d5c583204ff2b59251 (patch)
treec1bf1563d0c0837cbab3733c18df0c7c82b18ff4 /src
parentMerged trunk (diff)
downloadinkscape-d1947e768272c703674129d5c583204ff2b59251.tar.gz
inkscape-d1947e768272c703674129d5c583204ff2b59251.zip
Second part of new SPObject children list
(bzr r14954.1.19)
Diffstat (limited to 'src')
-rw-r--r--src/box3d.cpp20
-rw-r--r--src/conn-avoid-ref.cpp18
-rw-r--r--src/desktop-style.cpp25
-rw-r--r--src/document.cpp96
-rw-r--r--src/extension/internal/cairo-render-context.cpp23
-rw-r--r--src/extension/internal/cairo-renderer.cpp8
-rw-r--r--src/extension/internal/emf-print.cpp14
-rw-r--r--src/extension/internal/javafx-out.cpp8
-rw-r--r--src/extension/internal/pov-out.cpp4
-rw-r--r--src/file.cpp16
-rw-r--r--src/filter-chemistry.cpp14
-rw-r--r--src/gradient-chemistry.cpp20
-rw-r--r--src/gradient-drag.cpp4
-rw-r--r--src/helper/pixbuf-ops.cpp4
-rw-r--r--src/helper/png-write.cpp4
-rw-r--r--src/helper/stock-items.cpp30
-rw-r--r--src/id-clash.cpp8
-rw-r--r--src/libnrtype/font-lister.cpp4
-rw-r--r--src/live_effects/lpe-perspective_path.cpp10
-rw-r--r--src/main.cpp4
-rw-r--r--src/object-snapper.cpp8
-rw-r--r--src/object-test.h1
-rw-r--r--src/persp3d.cpp13
-rw-r--r--src/selection-chemistry.cpp43
-rw-r--r--src/sp-clippath.cpp30
-rw-r--r--src/sp-defs.cpp14
-rw-r--r--src/sp-filter.cpp8
-rw-r--r--src/sp-flowdiv.cpp120
-rw-r--r--src/sp-flowregion.cpp53
-rw-r--r--src/sp-flowtext.cpp54
-rw-r--r--src/sp-gradient.cpp41
-rw-r--r--src/sp-hatch.cpp17
-rw-r--r--src/sp-item-group.cpp61
-rw-r--r--src/sp-item.cpp22
-rw-r--r--src/sp-mask.cpp12
-rw-r--r--src/sp-mesh-array.cpp34
-rw-r--r--src/sp-namedview.cpp12
-rw-r--r--src/sp-object-group.cpp8
-rw-r--r--src/sp-object.cpp22
-rw-r--r--src/sp-object.h9
-rw-r--r--src/sp-pattern.cpp30
-rw-r--r--src/sp-root.cpp15
-rw-r--r--src/sp-switch.cpp7
-rw-r--r--src/sp-text.cpp54
-rw-r--r--src/sp-tref.cpp6
-rw-r--r--src/sp-tspan.cpp80
-rw-r--r--src/splivarot.cpp6
-rw-r--r--src/text-chemistry.cpp6
-rw-r--r--src/text-editing.cpp53
-rw-r--r--src/ui/clipboard.cpp4
-rw-r--r--src/ui/dialog/clonetiler.cpp24
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp23
-rw-r--r--src/ui/dialog/find.cpp10
-rw-r--r--src/ui/dialog/font-substitution.cpp2
-rw-r--r--src/ui/dialog/objects.cpp6
-rw-r--r--src/ui/dialog/spellcheck.cpp12
-rw-r--r--src/ui/dialog/symbols.cpp8
-rw-r--r--src/ui/tools/box3d-tool.cpp4
-rw-r--r--src/ui/tools/connector-tool.cpp6
-rw-r--r--src/ui/tools/tweak-tool.cpp16
-rw-r--r--src/widgets/gradient-toolbar.cpp12
-rw-r--r--src/widgets/gradient-vector.cpp28
-rw-r--r--src/widgets/stroke-marker-selector.cpp6
63 files changed, 669 insertions, 665 deletions
diff --git a/src/box3d.cpp b/src/box3d.cpp
index c4c2728e4..0a33ee306 100644
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
@@ -259,8 +259,8 @@ void box3d_position_set(SPBox3D *box)
{
/* This draws the curve and calls requestDisplayUpdate() for each side (the latter is done in
box3d_side_position_set() to avoid update conflicts with the parent box) */
- for ( SPObject *obj = box->firstChild(); obj; obj = obj->getNext() ) {
- Box3DSide *side = dynamic_cast<Box3DSide *>(obj);
+ for (auto& obj: box->_children) {
+ Box3DSide *side = dynamic_cast<Box3DSide *>(&obj);
if (side) {
box3d_side_position_set(side);
}
@@ -275,8 +275,8 @@ Geom::Affine SPBox3D::set_transform(Geom::Affine const &xform) {
gdouble const sw = hypot(ret[0], ret[1]);
gdouble const sh = hypot(ret[2], ret[3]);
- for ( SPObject *child = firstChild(); child; child = child->getNext() ) {
- SPItem *childitem = dynamic_cast<SPItem *>(child);
+ for (auto& child: _children) {
+ SPItem *childitem = dynamic_cast<SPItem *>(&child);
if (childitem) {
// Adjust stroke width
childitem->adjust_stroke(sqrt(fabs(sw * sh)));
@@ -1074,8 +1074,8 @@ box3d_recompute_z_orders (SPBox3D *box) {
static std::map<int, Box3DSide *> box3d_get_sides(SPBox3D *box)
{
std::map<int, Box3DSide *> sides;
- for ( SPObject *obj = box->firstChild(); obj; obj = obj->getNext() ) {
- Box3DSide *side = dynamic_cast<Box3DSide *>(obj);
+ for (auto& obj: box->_children) {
+ Box3DSide *side = dynamic_cast<Box3DSide *>(&obj);
if (side) {
sides[Box3D::face_to_int(side->getFaceId())] = side;
}
@@ -1217,8 +1217,8 @@ static void box3d_extract_boxes_rec(SPObject *obj, std::list<SPBox3D *> &boxes)
if (box) {
boxes.push_back(box);
} else if (dynamic_cast<SPGroup *>(obj)) {
- for ( SPObject *child = obj->firstChild(); child; child = child->getNext() ) {
- box3d_extract_boxes_rec(child, boxes);
+ for (auto& child: obj->_children) {
+ box3d_extract_boxes_rec(&child, boxes);
}
}
}
@@ -1276,8 +1276,8 @@ SPGroup *box3d_convert_to_group(SPBox3D *box)
// create a new group and add the sides (converted to ordinary paths) as its children
Inkscape::XML::Node *grepr = xml_doc->createElement("svg:g");
- for ( SPObject *obj = box->firstChild(); obj; obj = obj->getNext() ) {
- Box3DSide *side = dynamic_cast<Box3DSide *>(obj);
+ for (auto& obj: box->_children) {
+ Box3DSide *side = dynamic_cast<Box3DSide *>(&obj);
if (side) {
Inkscape::XML::Node *repr = box3d_side_convert_to_path(side);
grepr->appendChild(repr);
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp
index 9190fe633..638ba48e3 100644
--- a/src/conn-avoid-ref.cpp
+++ b/src/conn-avoid-ref.cpp
@@ -334,19 +334,19 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item)
std::vector<SPItem *> get_avoided_items(std::vector<SPItem *> &list, SPObject *from, SPDesktop *desktop,
bool initialised)
{
- for (SPObject *child = from->firstChild() ; child != NULL; child = child->next ) {
- if (SP_IS_ITEM(child) &&
- !desktop->isLayer(SP_ITEM(child)) &&
- !SP_ITEM(child)->isLocked() &&
- !desktop->itemIsHidden(SP_ITEM(child)) &&
- (!initialised || SP_ITEM(child)->avoidRef->shapeRef)
+ for (auto& child: from->_children) {
+ if (SP_IS_ITEM(&child) &&
+ !desktop->isLayer(SP_ITEM(&child)) &&
+ !SP_ITEM(&child)->isLocked() &&
+ !desktop->itemIsHidden(SP_ITEM(&child)) &&
+ (!initialised || SP_ITEM(&child)->avoidRef->shapeRef)
)
{
- list.push_back(SP_ITEM(child));
+ list.push_back(SP_ITEM(&child));
}
- if (SP_IS_ITEM(child) && desktop->isLayer(SP_ITEM(child))) {
- list = get_avoided_items(list, child, desktop, initialised);
+ if (SP_IS_ITEM(&child) && desktop->isLayer(SP_ITEM(&child))) {
+ list = get_avoided_items(list, &child, desktop, initialised);
}
}
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 885d17c21..a52ab3d76 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -163,17 +163,17 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
return;
}
- for ( SPObject *child = o->firstChild() ; child ; child = child->getNext() ) {
+ for (auto& child: o->_children) {
if (sp_repr_css_property(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, css);
sp_repr_css_set_property(css_recurse, "opacity", NULL);
- sp_desktop_apply_css_recursive(child, css_recurse, skip_lines);
+ sp_desktop_apply_css_recursive(&child, css_recurse, skip_lines);
sp_repr_css_attr_unref(css_recurse);
} else {
- sp_desktop_apply_css_recursive(child, css, skip_lines);
+ sp_desktop_apply_css_recursive(&child, css, skip_lines);
}
}
}
@@ -1714,10 +1714,11 @@ objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res)
int blendcount = 0;
// determine whether filter is simple (blend and/or blur) or complex
- for(SPObject *primitive_obj = style->getFilter()->children;
- primitive_obj && dynamic_cast<SPFilterPrimitive *>(primitive_obj);
- primitive_obj = primitive_obj->next) {
- SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(primitive_obj);
+ for(auto& primitive_obj: style->getFilter()->_children) {
+ SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj);
+ if (!primitive) {
+ break;
+ }
if (dynamic_cast<SPFeBlend *>(primitive)) {
++blendcount;
} else if (dynamic_cast<SPGaussianBlur *>(primitive)) {
@@ -1730,10 +1731,12 @@ objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res)
// simple filter
if(blurcount == 1 || blendcount == 1) {
- for(SPObject *primitive_obj = style->getFilter()->children;
- primitive_obj && dynamic_cast<SPFilterPrimitive *>(primitive_obj);
- primitive_obj = primitive_obj->next) {
- SPFeBlend *spblend = dynamic_cast<SPFeBlend *>(primitive_obj);
+ for(auto& primitive_obj: style->getFilter()->_children) {
+ SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj);
+ if (!primitive) {
+ break;
+ }
+ SPFeBlend *spblend = dynamic_cast<SPFeBlend *>(&primitive_obj);
if (spblend) {
blend = spblend->blend_mode;
}
diff --git a/src/document.cpp b/src/document.cpp
index 902dabbc3..3dcec4795 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -257,9 +257,9 @@ void SPDocument::setCurrentPersp3D(Persp3D * const persp) {
void SPDocument::getPerspectivesInDefs(std::vector<Persp3D*> &list) const
{
- for (SPObject *i = root->defs->firstChild(); i; i = i->getNext() ) {
- if (SP_IS_PERSP3D(i)) {
- list.push_back(SP_PERSP3D(i));
+ for (auto& i: root->defs->_children) {
+ if (SP_IS_PERSP3D(&i)) {
+ list.push_back(SP_PERSP3D(&i));
}
}
}
@@ -1256,12 +1256,12 @@ static std::vector<SPItem*> &find_items_in_area(std::vector<SPItem*> &s, SPGroup
{
g_return_val_if_fail(SP_IS_GROUP(group), s);
- for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) {
- if ( SP_IS_ITEM(o) ) {
- if (SP_IS_GROUP(o) && (SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) {
- s = find_items_in_area(s, SP_GROUP(o), dkey, area, test, take_insensitive, into_groups);
+ for (auto& o: group->_children) {
+ if ( SP_IS_ITEM(&o) ) {
+ if (SP_IS_GROUP(&o) && (SP_GROUP(&o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) {
+ s = find_items_in_area(s, SP_GROUP(&o), dkey, area, test, take_insensitive, into_groups);
} else {
- SPItem *child = SP_ITEM(o);
+ SPItem *child = SP_ITEM(&o);
Geom::OptRect box = child->desktopVisualBounds();
if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) {
s.push_back(child);
@@ -1278,17 +1278,16 @@ Returns true if an item is among the descendants of group (recursively).
*/
static bool item_is_in_group(SPItem *item, SPGroup *group)
{
- bool inGroup = false;
- for ( SPObject *o = group->firstChild() ; o && !inGroup; o = o->getNext() ) {
- if ( SP_IS_ITEM(o) ) {
- if (SP_ITEM(o) == item) {
- inGroup = true;
- } else if ( SP_IS_GROUP(o) ) {
- inGroup = item_is_in_group(item, SP_GROUP(o));
+ for (auto& o: group->_children) {
+ if ( SP_IS_ITEM(&o) ) {
+ if (SP_ITEM(&o) == item) {
+ return true;
+ } else if (SP_IS_GROUP(&o) && item_is_in_group(item, SP_GROUP(&o))) {
+ return true;
}
}
}
- return inGroup;
+ return false;
}
SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, std::vector<SPItem*> const &list,Geom::Point const &p, bool take_insensitive)
@@ -1299,21 +1298,24 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
- for ( SPObject *o = group->firstChild() ; o && !bottomMost; o = o->getNext() ) {
- if ( SP_IS_ITEM(o) ) {
- SPItem *item = SP_ITEM(o);
+ for (auto& o: group->_children) {
+ if (bottomMost) {
+ break;
+ }
+ if (SP_IS_ITEM(&o)) {
+ SPItem *item = SP_ITEM(&o);
Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey);
arenaitem->drawing().update();
if (arenaitem && arenaitem->pick(p, delta, 1) != NULL
&& (take_insensitive || item->isVisibleAndUnlocked(dkey))) {
- if (find(list.begin(),list.end(),item)!=list.end() ) {
+ if (find(list.begin(), list.end(), item) != list.end()) {
bottomMost = item;
}
}
- if ( !bottomMost && SP_IS_GROUP(o) ) {
+ if (!bottomMost && SP_IS_GROUP(&o)) {
// return null if not found:
- bottomMost = getItemFromListAtPointBottom(dkey, SP_GROUP(o), list, p, take_insensitive);
+ bottomMost = getItemFromListAtPointBottom(dkey, SP_GROUP(&o), list, p, take_insensitive);
}
}
}
@@ -1326,15 +1328,15 @@ The list can be persisted, which improves "find at multiple points" speed.
*/
void SPDocument::build_flat_item_list(unsigned int dkey, SPGroup *group, gboolean into_groups) const
{
- for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) {
- if (!SP_IS_ITEM(o)) {
+ for (auto& o: group->_children) {
+ if (!SP_IS_ITEM(&o)) {
continue;
}
- if (SP_IS_GROUP(o) && (SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) {
- build_flat_item_list(dkey, SP_GROUP(o), into_groups);
+ if (SP_IS_GROUP(&o) && (SP_GROUP(&o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) {
+ build_flat_item_list(dkey, SP_GROUP(&o), into_groups);
} else {
- SPItem *child = SP_ITEM(o);
+ SPItem *child = SP_ITEM(&o);
if (child->isVisibleAndUnlocked(dkey)) {
_node_cache.push_front(child);
@@ -1390,18 +1392,18 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
- for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) {
- if (!SP_IS_ITEM(o)) {
+ for (auto& o: group->_children) {
+ if (!SP_IS_ITEM(&o)) {
continue;
}
- if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER) {
- SPItem *newseen = find_group_at_point(dkey, SP_GROUP(o), p);
+ if (SP_IS_GROUP(&o) && SP_GROUP(&o)->effectiveLayerMode(dkey) == SPGroup::LAYER) {
+ SPItem *newseen = find_group_at_point(dkey, SP_GROUP(&o), p);
if (newseen) {
seen = newseen;
}
}
- if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) {
- SPItem *child = SP_ITEM(o);
+ if (SP_IS_GROUP(&o) && SP_GROUP(&o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) {
+ SPItem *child = SP_ITEM(&o);
Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey);
arenaitem->drawing().update();
@@ -1595,8 +1597,8 @@ static unsigned int count_objects_recursive(SPObject *obj, unsigned int count)
{
count++; // obj itself
- for ( SPObject *i = obj->firstChild(); i; i = i->getNext() ) {
- count = count_objects_recursive(i, count);
+ for (auto& i: obj->_children) {
+ count = count_objects_recursive(&i, count);
}
return count;
@@ -1621,13 +1623,13 @@ static unsigned int objects_in_document(SPDocument *document)
static void vacuum_document_recursive(SPObject *obj)
{
if (SP_IS_DEFS(obj)) {
- for ( SPObject *def = obj->firstChild(); def; def = def->getNext()) {
+ for (auto& def: obj->_children) {
// fixme: some inkscape-internal nodes in the future might not be collectable
- def->requestOrphanCollection();
+ def.requestOrphanCollection();
}
} else {
- for ( SPObject *i = obj->firstChild(); i; i = i->getNext() ) {
- vacuum_document_recursive(i);
+ for (auto& i: obj->_children) {
+ vacuum_document_recursive(&i);
}
}
}
@@ -1755,14 +1757,14 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I
// Prevent duplicates of solid swatches by checking if equivalent swatch already exists
if (src && SP_IS_GRADIENT(src)) {
SPGradient *s_gr = SP_GRADIENT(src);
- for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) {
- if (trg && (src != trg) && SP_IS_GRADIENT(trg)) {
- SPGradient *t_gr = SP_GRADIENT(trg);
+ for (auto& trg: getDefs()->_children) {
+ if (&trg && (src != &trg) && SP_IS_GRADIENT(&trg)) {
+ SPGradient *t_gr = SP_GRADIENT(&trg);
if (t_gr && s_gr->isEquivalent(t_gr)) {
// Change object references to the existing equivalent gradient
- Glib::ustring newid = trg->getId();
+ Glib::ustring newid = trg.getId();
if(newid != defid){ // id could be the same if it is a second paste into the same document
- change_def_references(src, trg);
+ change_def_references(src, &trg);
}
gchar *longid = g_strdup_printf("%s_%9.9d", DuplicateDefString.c_str(), stagger++);
def->setAttribute("id", longid );
@@ -1826,9 +1828,9 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I
id.erase( pos );
// Check that it really is a duplicate
- for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) {
- if( trg && SP_IS_SYMBOL(trg) && src != trg ) {
- std::string id2 = trg->getRepr()->attribute("id");
+ for (auto& trg: getDefs()->_children) {
+ if(&trg && SP_IS_SYMBOL(&trg) && src != &trg ) {
+ std::string id2 = trg.getRepr()->attribute("id");
if( !id.compare( id2 ) ) {
duplicate = true;
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index 5d8b0e076..bedf2fa7f 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -986,13 +986,12 @@ void CairoRenderContext::popState(void)
static bool pattern_hasItemChildren(SPPattern *pat)
{
- bool hasItems = false;
- for ( SPObject *child = pat->firstChild() ; child && !hasItems; child = child->getNext() ) {
- if (SP_IS_ITEM (child)) {
- hasItems = true;
+ for (auto& child: pat->_children) {
+ if (SP_IS_ITEM (&child)) {
+ return true;
}
}
- return hasItems;
+ return false;
}
cairo_pattern_t*
@@ -1087,10 +1086,10 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
// show items and render them
for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) {
if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children
- for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) {
- if (SP_IS_ITEM(child)) {
- SP_ITEM(child)->invoke_show(drawing, dkey, SP_ITEM_REFERENCE_FLAGS);
- _renderer->renderItem(pattern_ctx, SP_ITEM(child));
+ for (auto& child: pat_i->_children) {
+ if (SP_IS_ITEM(&child)) {
+ SP_ITEM(&child)->invoke_show(drawing, dkey, SP_ITEM_REFERENCE_FLAGS);
+ _renderer->renderItem(pattern_ctx, SP_ITEM(&child));
}
}
break; // do not go further up the chain if children are found
@@ -1116,9 +1115,9 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
// hide all items
for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) {
if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children
- for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) {
- if (SP_IS_ITEM(child)) {
- SP_ITEM(child)->invoke_hide(dkey);
+ for (auto& child: pat_i->_children) {
+ if (SP_IS_ITEM(&child)) {
+ SP_ITEM(&child)->invoke_hide(dkey);
}
}
break; // do not go further up the chain if children are found
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index 5dc20ab06..088eaf11d 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -741,8 +741,8 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp)
TRACE(("BEGIN clip\n"));
SPObject const *co = cp;
- for ( SPObject const *child = co->firstChild() ; child; child = child->getNext() ) {
- SPItem const *item = dynamic_cast<SPItem const *>(child);
+ for (auto& child: co->_children) {
+ SPItem const *item = dynamic_cast<SPItem const *>(&child);
if (item) {
// combine transform of the item in clippath and the item using clippath:
@@ -800,8 +800,8 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask)
TRACE(("BEGIN mask\n"));
SPObject const *co = mask;
- for ( SPObject const *child = co->firstChild() ; child; child = child->getNext() ) {
- SPItem const *item = dynamic_cast<SPItem const *>(child);
+ for (auto& child: co->_children) {
+ SPItem const *item = dynamic_cast<SPItem const *>(&child);
if (item) {
// TODO fix const correctness:
renderItem(ctx, const_cast<SPItem*>(item));
diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp
index 9f3b5475f..c0c086c7a 100644
--- a/src/extension/internal/emf-print.cpp
+++ b/src/extension/internal/emf-print.cpp
@@ -1042,8 +1042,12 @@ void PrintEmf::do_clip_if_present(SPStyle const *style){
/* find the clipping path */
Geom::PathVector combined_pathvector;
Geom::Affine tfc; // clipping transform, generally not the same as item transform
- for(item = SP_ITEM(scp->firstChild()); item; item=SP_ITEM(item->getNext())){
- if (SP_IS_GROUP(item)) { // not implemented
+ for (auto& child: scp->_children) {
+ item = SP_ITEM(&child);
+ if (!item) {
+ break;
+ }
+ if (SP_IS_GROUP(item)) { // not implemented
// return sp_group_render(item);
combined_pathvector = merge_PathVector_with_group(combined_pathvector, item, tfc);
} else if (SP_IS_SHAPE(item)) {
@@ -1081,7 +1085,11 @@ Geom::PathVector PrintEmf::merge_PathVector_with_group(Geom::PathVector const &c
new_combined_pathvector = combined_pathvector;
SPGroup *group = SP_GROUP(item);
Geom::Affine tfc = item->transform * transform;
- for(SPItem *item = SP_ITEM(group->firstChild()); item; item=SP_ITEM(item->getNext())){
+ for (auto& child: group->_children) {
+ item = SP_ITEM(&child);
+ if (!item) {
+ break;
+ }
if (SP_IS_GROUP(item)) {
new_combined_pathvector = merge_PathVector_with_group(new_combined_pathvector, item, tfc); // could be endlessly recursive on a badly formed SVG
} else if (SP_IS_SHAPE(item)) {
diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp
index 386bde1d6..51608e4fa 100644
--- a/src/extension/internal/javafx-out.cpp
+++ b/src/extension/internal/javafx-out.cpp
@@ -732,9 +732,9 @@ bool JavaFXOutput::doTreeRecursive(SPDocument *doc, SPObject *obj)
/**
* Descend into children
*/
- for (SPObject *child = obj->firstChild() ; child ; child = child->next)
+ for (auto &child: obj->_children)
{
- if (!doTreeRecursive(doc, child)) {
+ if (!doTreeRecursive(doc, &child)) {
return false;
}
}
@@ -804,9 +804,9 @@ bool JavaFXOutput::doBody(SPDocument *doc, SPObject *obj)
/**
* Descend into children
*/
- for (SPObject *child = obj->firstChild() ; child ; child = child->next)
+ for (auto &child: obj->_children)
{
- if (!doBody(doc, child)) {
+ if (!doBody(doc, &child)) {
return false;
}
}
diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp
index bd2168b68..08f533010 100644
--- a/src/extension/internal/pov-out.cpp
+++ b/src/extension/internal/pov-out.cpp
@@ -479,9 +479,9 @@ bool PovOutput::doTreeRecursive(SPDocument *doc, SPObject *obj)
/**
* Descend into children
*/
- for (SPObject *child = obj->firstChild() ; child ; child = child->next)
+ for (auto &child: obj->_children)
{
- if (!doTreeRecursive(doc, child))
+ if (!doTreeRecursive(doc, &child))
return false;
}
diff --git a/src/file.cpp b/src/file.cpp
index 650ce5d0f..11e5f0a42 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -1204,8 +1204,8 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
// Count the number of top-level items in the imported document.
guint items_count = 0;
- for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext()) {
- if (SP_IS_ITEM(child)) {
+ for (auto& child: doc->getRoot()->_children) {
+ if (SP_IS_ITEM(&child)) {
items_count++;
}
}
@@ -1234,9 +1234,9 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
// Construct a new object representing the imported image,
// and insert it into the current document.
SPObject *new_obj = NULL;
- for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext() ) {
- if (SP_IS_ITEM(child)) {
- Inkscape::XML::Node *newitem = child->getRepr()->duplicate(xml_in_doc);
+ for (auto& child: doc->getRoot()->_children) {
+ if (SP_IS_ITEM(&child)) {
+ Inkscape::XML::Node *newitem = child.getRepr()->duplicate(xml_in_doc);
// convert layers to groups, and make sure they are unlocked
// FIXME: add "preserve layers" mode where each layer from
@@ -1249,10 +1249,10 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
}
// don't lose top-level defs or style elements
- else if (child->getRepr()->type() == Inkscape::XML::ELEMENT_NODE) {
- const gchar *tag = child->getRepr()->name();
+ else if (child.getRepr()->type() == Inkscape::XML::ELEMENT_NODE) {
+ const gchar *tag = child.getRepr()->name();
if (!strcmp(tag, "svg:style")) {
- in_doc->getRoot()->appendChildRepr(child->getRepr()->duplicate(xml_in_doc));
+ in_doc->getRoot()->appendChildRepr(child.getRepr()->duplicate(xml_in_doc));
}
}
}
diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp
index 9298a1ffc..2e99842ec 100644
--- a/src/filter-chemistry.cpp
+++ b/src/filter-chemistry.cpp
@@ -51,8 +51,8 @@ static guint count_filter_hrefs(SPObject *o, SPFilter *filter)
i ++;
}
- for ( SPObject *child = o->firstChild(); child; child = child->getNext() ) {
- i += count_filter_hrefs(child, filter);
+ for (auto& child: o->_children) {
+ i += count_filter_hrefs(&child, filter);
}
return i;
@@ -491,16 +491,14 @@ void remove_filter_gaussian_blur (SPObject *item)
bool filter_is_single_gaussian_blur(SPFilter *filter)
{
- return (filter->firstChild() &&
- (filter->firstChild() == filter->lastChild()) &&
- SP_IS_GAUSSIANBLUR(filter->firstChild()));
+ return (filter->_children.size() == 1 &&
+ SP_IS_GAUSSIANBLUR(&filter->_children.front()));
}
double get_single_gaussian_blur_radius(SPFilter *filter)
{
- if (filter->firstChild() &&
- (filter->firstChild() == filter->lastChild()) &&
- SP_IS_GAUSSIANBLUR(filter->firstChild())) {
+ if (filter->_children.size() == 1 &&
+ SP_IS_GAUSSIANBLUR(&filter->_children.front())) {
SPGaussianBlur *gb = SP_GAUSSIANBLUR(filter->firstChild());
double x = gb->stdDeviation.getNumber();
diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp
index 59d715149..9c46a2efb 100644
--- a/src/gradient-chemistry.cpp
+++ b/src/gradient-chemistry.cpp
@@ -199,8 +199,8 @@ static guint count_gradient_hrefs(SPObject *o, SPGradient *gr)
i ++;
}
- for ( SPObject *child = o->firstChild(); child; child = child->getNext() ) {
- i += count_gradient_hrefs(child, gr);
+ for (auto& child: o->_children) {
+ i += count_gradient_hrefs(&child, gr);
}
return i;
@@ -926,11 +926,11 @@ void sp_item_gradient_reverse_vector(SPItem *item, Inkscape::PaintTarget fill_or
GSList *child_objects = NULL;
std::vector<double> offsets;
double offset;
- for ( SPObject *child = vector->firstChild(); child; child = child->getNext()) {
- child_reprs = g_slist_prepend (child_reprs, child->getRepr());
- child_objects = g_slist_prepend (child_objects, child);
+ for (auto& child: vector->_children) {
+ child_reprs = g_slist_prepend (child_reprs, child.getRepr());
+ child_objects = g_slist_prepend (child_objects, &child);
offset=0;
- sp_repr_get_double(child->getRepr(), "offset", &offset);
+ sp_repr_get_double(child.getRepr(), "offset", &offset);
offsets.push_back(offset);
}
@@ -979,9 +979,9 @@ void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fi
sp_gradient_repr_set_link(gradient->getRepr(), vector);
}
- for ( SPObject *child = vector->firstChild(); child; child = child->getNext()) {
- if (SP_IS_STOP(child)) {
- guint32 color = SP_STOP(child)->get_rgba32();
+ for (auto& child: vector->_children) {
+ if (SP_IS_STOP(&child)) {
+ guint32 color = SP_STOP(&child)->get_rgba32();
//g_message("Stop color %d", color);
gchar c[64];
sp_svg_write_color (c, sizeof(c),
@@ -994,7 +994,7 @@ void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fi
);
SPCSSAttr *css = sp_repr_css_attr_new ();
sp_repr_css_set_property (css, "stop-color", c);
- sp_repr_css_change(child->getRepr(), css, "style");
+ sp_repr_css_change(child.getRepr(), css, "style");
sp_repr_css_attr_unref (css);
}
}
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index 555bde786..b9d1fe109 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -2539,9 +2539,9 @@ void GrDrag::deleteSelected(bool just_one)
// cannot use vector->vector.stops.size() because the vector might be invalidated by deletion of a midstop
// manually count the children, don't know if there already exists a function for this...
int len = 0;
- for ( SPObject *child = (stopinfo->vector)->firstChild() ; child ; child = child->getNext() )
+ for (auto& child: stopinfo->vector->_children)
{
- if ( SP_IS_STOP(child) ) {
+ if ( SP_IS_STOP(&child) ) {
len ++;
}
}
diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp
index 9639096fb..fb1740fc5 100644
--- a/src/helper/pixbuf-ops.cpp
+++ b/src/helper/pixbuf-ops.cpp
@@ -53,8 +53,8 @@ static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dke
// recurse
if (!g_slist_find(list, o)) {
- for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) {
- hide_other_items_recursively(child, list, dkey);
+ for (auto& child: o->_children) {
+ hide_other_items_recursively(&child, list, dkey);
}
}
}
diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp
index 9430feeff..c59db9df6 100644
--- a/src/helper/png-write.cpp
+++ b/src/helper/png-write.cpp
@@ -374,8 +374,8 @@ static void hide_other_items_recursively(SPObject *o, const std::vector<SPItem*>
// recurse
if (list.end()==find(list.begin(),list.end(),o)) {
- for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) {
- hide_other_items_recursively(child, list, dkey);
+ for (auto& child: o->_children) {
+ hide_other_items_recursively(&child, list, dkey);
}
}
}
diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp
index 5a56b89ff..cf10a6c4d 100644
--- a/src/helper/stock-items.cpp
+++ b/src/helper/stock-items.cpp
@@ -204,37 +204,37 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock)
}
SPObject *object = NULL;
if (!strcmp(base, "marker") && !stock) {
- for ( SPObject *child = defs->firstChild(); child; child = child->getNext() )
+ for (auto& child: defs->_children)
{
- if (child->getRepr()->attribute("inkscape:stockid") &&
- !strcmp(name_p, child->getRepr()->attribute("inkscape:stockid")) &&
- SP_IS_MARKER(child))
+ if (child.getRepr()->attribute("inkscape:stockid") &&
+ !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) &&
+ SP_IS_MARKER(&child))
{
- object = child;
+ object = &child;
}
}
}
else if (!strcmp(base,"pattern") && !stock) {
- for ( SPObject *child = defs->firstChild() ; child; child = child->getNext() )
+ for (auto& child: defs->_children)
{
- if (child->getRepr()->attribute("inkscape:stockid") &&
- !strcmp(name_p, child->getRepr()->attribute("inkscape:stockid")) &&
- SP_IS_PATTERN(child))
+ if (child.getRepr()->attribute("inkscape:stockid") &&
+ !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) &&
+ SP_IS_PATTERN(&child))
{
- object = child;
+ object = &child;
}
}
}
else if (!strcmp(base,"gradient") && !stock) {
- for ( SPObject *child = defs->firstChild(); child; child = child->getNext() )
+ for (auto& child: defs->_children)
{
- if (child->getRepr()->attribute("inkscape:stockid") &&
- !strcmp(name_p, child->getRepr()->attribute("inkscape:stockid")) &&
- SP_IS_GRADIENT(child))
+ if (child.getRepr()->attribute("inkscape:stockid") &&
+ !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) &&
+ SP_IS_GRADIENT(&child))
{
- object = child;
+ object = &child;
}
}
diff --git a/src/id-clash.cpp b/src/id-clash.cpp
index 4bd66e858..fecad9eee 100644
--- a/src/id-clash.cpp
+++ b/src/id-clash.cpp
@@ -187,9 +187,9 @@ find_references(SPObject *elem, refmap_type &refmap)
}
// recurse
- for (SPObject *child = elem->firstChild(); child; child = child->getNext() )
+ for (auto& child: elem->_children)
{
- find_references(child, refmap);
+ find_references(&child, refmap);
}
}
@@ -242,9 +242,9 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc,
// recurse
- for (SPObject *child = elem->firstChild(); child; child = child->getNext() )
+ for (auto& child: elem->_children)
{
- change_clashing_ids(imported_doc, current_doc, child, refmap, id_changes);
+ change_clashing_ids(imported_doc, current_doc, &child, refmap, id_changes);
}
}
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index 568a7c8cc..937d67895 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -298,8 +298,8 @@ void FontLister::update_font_list_recursive(SPObject *r, std::list<Glib::ustring
l->push_back(Glib::ustring(font_family));
}
- for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
- update_font_list_recursive(child, l);
+ for (auto& child: r->_children) {
+ update_font_list_recursive(&child, l);
}
}
diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp
index c8cdd7912..c62ead2b3 100644
--- a/src/live_effects/lpe-perspective_path.cpp
+++ b/src/live_effects/lpe-perspective_path.cpp
@@ -107,12 +107,12 @@ void LPEPerspectivePath::refresh(Gtk::Entry* perspective) {
perspectiveID = perspective->get_text();
Persp3D *first = 0;
Persp3D *persp = 0;
- for ( SPObject *child = this->lpeobj->document->getDefs()->firstChild(); child && !persp; child = child->getNext() ) {
- if (SP_IS_PERSP3D(child) && first == 0) {
- first = SP_PERSP3D(child);
+ for (auto& child: lpeobj->document->getDefs()->_children) {
+ if (SP_IS_PERSP3D(&child) && first == 0) {
+ first = SP_PERSP3D(&child);
}
- if (SP_IS_PERSP3D(child) && strcmp(child->getId(), const_cast<const gchar *>(perspectiveID.c_str())) == 0) {
- persp = SP_PERSP3D(child);
+ if (SP_IS_PERSP3D(&child) && strcmp(child.getId(), const_cast<const gchar *>(perspectiveID.c_str())) == 0) {
+ persp = SP_PERSP3D(&child);
break;
}
}
diff --git a/src/main.cpp b/src/main.cpp
index 8cf52127b..db908f640 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1228,8 +1228,8 @@ static int sp_process_file_list(GSList *fl)
std::vector<SPItem*> items;
SPRoot *root = doc->getRoot();
doc->ensureUpToDate();
- for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) {
- SPItem* item = (SPItem*) iter;
+ for (auto& iter: root->_children) {
+ SPItem* item = (SPItem*) &iter;
if (! (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item) || SP_IS_GROUP(item))) {
continue;
}
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 3e559ee7a..580fb5fc7 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -90,9 +90,9 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
Geom::Rect bbox_to_snap_incl = bbox_to_snap; // _incl means: will include the snapper tolerance
bbox_to_snap_incl.expandBy(getSnapperTolerance()); // see?
- for ( SPObject *o = parent->firstChild(); o; o = o->getNext() ) {
+ for (auto& o: parent->_children) {
g_assert(dt != NULL);
- SPItem *item = dynamic_cast<SPItem *>(o);
+ SPItem *item = dynamic_cast<SPItem *>(&o);
if (item && !(dt->itemIsHidden(item) && !clip_or_mask)) {
// Snapping to items in a locked layer is allowed
// Don't snap to hidden objects, unless they're a clipped path or a mask
@@ -100,7 +100,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
std::vector<SPItem const *>::const_iterator i;
if (it != NULL) {
i = it->begin();
- while (i != it->end() && *i != o) {
+ while (i != it->end() && *i != &o) {
++i;
}
}
@@ -122,7 +122,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
}
if (dynamic_cast<SPGroup *>(item)) {
- _findCandidates(o, it, false, bbox_to_snap, clip_or_mask, additional_affine);
+ _findCandidates(&o, it, false, bbox_to_snap, clip_or_mask, additional_affine);
} else {
Geom::OptRect bbox_of_item;
Preferences *prefs = Preferences::get();
diff --git a/src/object-test.h b/src/object-test.h
index 4f0be3251..0af823684 100644
--- a/src/object-test.h
+++ b/src/object-test.h
@@ -115,7 +115,6 @@ public:
prev = next;
next = next->getNext();
}
- TS_ASSERT(child->lastChild() == next);
// Test hrefcount
TS_ASSERT(path->isReferenced());
diff --git a/src/persp3d.cpp b/src/persp3d.cpp
index a48481145..849e332bf 100644
--- a/src/persp3d.cpp
+++ b/src/persp3d.cpp
@@ -215,9 +215,10 @@ Persp3D *persp3d_create_xml_element(SPDocument *document, Persp3DImpl *dup) {//
Persp3D *persp3d_document_first_persp(SPDocument *document)
{
Persp3D *first = 0;
- for ( SPObject *child = document->getDefs()->firstChild(); child && !first; child = child->getNext() ) {
- if (SP_IS_PERSP3D(child)) {
- first = SP_PERSP3D(child);
+ for (auto& child: document->getDefs()->_children) {
+ if (SP_IS_PERSP3D(&child)) {
+ first = SP_PERSP3D(&child);
+ break;
}
}
return first;
@@ -533,9 +534,9 @@ persp3d_print_debugging_info (Persp3D *persp) {
void persp3d_print_debugging_info_all(SPDocument *document)
{
- for ( SPObject *child = document->getDefs()->firstChild(); child; child = child->getNext() ) {
- if (SP_IS_PERSP3D(child)) {
- persp3d_print_debugging_info(SP_PERSP3D(child));
+ for (auto& child: document->getDefs()->_children) {
+ if (SP_IS_PERSP3D(&child)) {
+ persp3d_print_debugging_info(SP_PERSP3D(&child));
}
}
persp3d_print_all_selected();
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 1f34f798d..55f4118b0 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -88,6 +88,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include <map>
#include <cstring>
#include <string>
+#include <boost/range/adaptor/reversed.hpp>
#include "sp-item.h"
#include "box3d.h"
#include "persp3d.h"
@@ -432,8 +433,8 @@ static void add_ids_recursive(std::vector<const gchar *> &ids, SPObject *obj)
ids.push_back(obj->getId());
if (dynamic_cast<SPGroup *>(obj)) {
- for (SPObject *child = obj->firstChild() ; child; child = child->getNext() ) {
- add_ids_recursive(ids, child);
+ for (auto& child: obj->_children) {
+ add_ids_recursive(ids, &child);
}
}
}
@@ -586,20 +587,20 @@ void sp_edit_clear_all(Inkscape::Selection *selection)
*/
std::vector<SPItem*> &get_all_items(std::vector<SPItem*> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector<SPItem*> const &exclude)
{
- for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) {
- SPItem *item = dynamic_cast<SPItem *>(child);
+ for (auto& child: from->_children) {
+ SPItem *item = dynamic_cast<SPItem *>(&child);
if (item &&
!desktop->isLayer(item) &&
(!onlysensitive || !item->isLocked()) &&
(!onlyvisible || !desktop->itemIsHidden(item)) &&
- (exclude.empty() || exclude.end() == std::find(exclude.begin(),exclude.end(),child))
+ (exclude.empty() || exclude.end() == std::find(exclude.begin(), exclude.end(), &child))
)
{
list.insert(list.begin(),item);
}
if (ingroups || (item && desktop->isLayer(item))) {
- list = get_all_items(list, child, desktop, onlyvisible, onlysensitive, ingroups, exclude);
+ list = get_all_items(list, &child, desktop, onlyvisible, onlysensitive, ingroups, exclude);
}
}
@@ -1200,9 +1201,10 @@ take_style_from_item(SPObject *object)
(dynamic_cast<SPText *>(object) && object->children && object->children->next == NULL)) {
// if this is a text with exactly one tspan child, merge the style of that tspan as well
// If this is a group, merge the style of its topmost (last) child with style
- for (SPObject *last_element = object->lastChild(); last_element != NULL; last_element = last_element->getPrev()) {
- if ( last_element->style ) {
- SPCSSAttr *temp = sp_css_attr_from_object(last_element, SP_STYLE_FLAG_IFSET);
+ auto list = object->_children | boost::adaptors::reversed;
+ for (auto& element: list) {
+ if (element.style ) {
+ SPCSSAttr *temp = sp_css_attr_from_object(&element, SP_STYLE_FLAG_IFSET);
if (temp) {
sp_repr_css_merge(css, temp);
sp_repr_css_attr_unref(temp);
@@ -1621,10 +1623,10 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons
} else if (transform_flowtext_with_frame) {
// apply the inverse of the region's transform to the <use> so that the flow remains
// the same (even though the output itself gets transformed)
- for ( SPObject *region = item->firstChild() ; region ; region = region->getNext() ) {
- if (dynamic_cast<SPFlowregion *>(region) || dynamic_cast<SPFlowregionExclude *>(region)) {
- for ( SPObject *item = region->firstChild() ; item ; item = item->getNext() ) {
- SPUse *use = dynamic_cast<SPUse *>(item);
+ for (auto& region: item->_children) {
+ if (dynamic_cast<SPFlowregion *>(&region) || dynamic_cast<SPFlowregionExclude *>(&region)) {
+ for (auto& itm: region._children) {
+ SPUse *use = dynamic_cast<SPUse *>(&itm);
if ( use ) {
use->doWriteTransform(use->getRepr(), use->transform.inverse(), NULL, compensate);
}
@@ -2702,8 +2704,9 @@ sp_selection_unlink(SPDesktop *desktop)
// Get a copy of current selection.
std::vector<SPItem*> new_select;
bool unlinked = false;
- auto items= selection->items();
- for (auto i=boost::rbegin(items);i!=boost::rend(items);++i){
+ std::vector<SPItem *> items(selection->items().begin(), selection->items().end());
+
+ for (auto i=items.rbegin();i!=items.rend();++i){
SPItem *item = *i;
if (dynamic_cast<SPText *>(item)) {
@@ -3432,9 +3435,9 @@ void sp_selection_untile(SPDesktop *desktop)
Geom::Affine pat_transform = basePat->getTransform();
pat_transform *= item->transform;
- for (SPObject *child = pattern->firstChild() ; child != NULL; child = child->next ) {
- if (dynamic_cast<SPItem *>(child)) {
- Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc);
+ for (auto& child: pattern->_children) {
+ if (dynamic_cast<SPItem *>(&child)) {
+ Inkscape::XML::Node *copy = child.getRepr()->duplicate(xml_doc);
SPItem *i = dynamic_cast<SPItem *>(desktop->currentLayer()->appendChildRepr(copy));
// FIXME: relink clones to the new canvas objects
@@ -4100,9 +4103,9 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) {
SPObject *obj = (*it).first; // Group containing the clipped paths or masks
GSList *items_to_move = NULL;
- for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) {
+ for (auto& child: obj->_children) {
// Collect all clipped paths and masks within a single group
- Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc);
+ Inkscape::XML::Node *copy = child.getRepr()->duplicate(xml_doc);
if(copy->attribute("inkscape:original-d") && copy->attribute("inkscape:path-effect"))
{
copy->setAttribute("d", copy->attribute("inkscape:original-d"));
diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp
index 0c07d1b3d..25bf77f00 100644
--- a/src/sp-clippath.cpp
+++ b/src/sp-clippath.cpp
@@ -128,9 +128,9 @@ void SPClipPath::update(SPCtx* ctx, unsigned int flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList *l = NULL;
- for ( SPObject *child = this->firstChild(); child; child = child->getNext()) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse(l);
@@ -167,9 +167,9 @@ void SPClipPath::modified(unsigned int flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList *l = NULL;
- for (SPObject *child = this->firstChild(); child; child = child->getNext()) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse(l);
@@ -200,9 +200,9 @@ Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int
Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing);
display = sp_clippath_view_new_prepend(display, key, ai);
- for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) {
- if (SP_IS_ITEM(child)) {
- Inkscape::DrawingItem *ac = SP_ITEM(child)->invoke_show(drawing, key, SP_ITEM_REFERENCE_FLAGS);
+ for (auto& child: _children) {
+ if (SP_IS_ITEM(&child)) {
+ Inkscape::DrawingItem *ac = SP_ITEM(&child)->invoke_show(drawing, key, SP_ITEM_REFERENCE_FLAGS);
if (ac) {
/* The order is not important in clippath */
@@ -223,9 +223,9 @@ Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int
}
void SPClipPath::hide(unsigned int key) {
- for ( SPObject *child = firstChild() ; child; child = child->getNext() ) {
- if (SP_IS_ITEM(child)) {
- SP_ITEM(child)->invoke_hide(key);
+ for (auto& child: _children) {
+ if (SP_IS_ITEM(&child)) {
+ SP_ITEM(&child)->invoke_hide(key);
}
}
@@ -252,9 +252,9 @@ void SPClipPath::setBBox(unsigned int key, Geom::OptRect const &bbox) {
Geom::OptRect SPClipPath::geometricBounds(Geom::Affine const &transform) {
Geom::OptRect bbox;
- for (SPObject *i = firstChild(); i; i = i->getNext()) {
- if (SP_IS_ITEM(i)) {
- Geom::OptRect tmp = SP_ITEM(i)->geometricBounds(Geom::Affine(SP_ITEM(i)->transform) * transform);
+ for (auto& i: _children) {
+ if (SP_IS_ITEM(&i)) {
+ Geom::OptRect tmp = SP_ITEM(&i)->geometricBounds(Geom::Affine(SP_ITEM(&i)->transform) * transform);
bbox.unionWith(tmp);
}
}
diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp
index dd779c0da..af4ea96d7 100644
--- a/src/sp-defs.cpp
+++ b/src/sp-defs.cpp
@@ -54,9 +54,9 @@ void SPDefs::modified(unsigned int flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList *l = NULL;
- for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse(l);
@@ -79,8 +79,8 @@ Inkscape::XML::Node* SPDefs::write(Inkscape::XML::Document *xml_doc, Inkscape::X
}
GSList *l = NULL;
- for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) {
- Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+ for (auto& child: _children) {
+ Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags);
if (crepr) {
l = g_slist_prepend(l, crepr);
}
@@ -93,8 +93,8 @@ Inkscape::XML::Node* SPDefs::write(Inkscape::XML::Document *xml_doc, Inkscape::X
}
} else {
- for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) {
- child->updateRepr(flags);
+ for (auto& child: _children) {
+ child.updateRepr(flags);
}
}
diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp
index c17c67fc5..da3f12f5f 100644
--- a/src/sp-filter.cpp
+++ b/src/sp-filter.cpp
@@ -268,8 +268,8 @@ Inkscape::XML::Node* SPFilter::write(Inkscape::XML::Document *doc, Inkscape::XML
}
GSList *l = NULL;
- for ( SPObject *child = this->firstChild(); child; child = child->getNext() ) {
- Inkscape::XML::Node *crepr = child->updateRepr(doc, NULL, flags);
+ for (auto& child: _children) {
+ Inkscape::XML::Node *crepr = child.updateRepr(doc, NULL, flags);
if (crepr) {
l = g_slist_prepend (l, crepr);
@@ -282,8 +282,8 @@ Inkscape::XML::Node* SPFilter::write(Inkscape::XML::Document *doc, Inkscape::XML
l = g_slist_remove (l, l->data);
}
} else {
- for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) {
- child->updateRepr(flags);
+ for (auto& child: _children) {
+ child.updateRepr(flags);
}
}
diff --git a/src/sp-flowdiv.cpp b/src/sp-flowdiv.cpp
index 8d9c51ab8..ad04f0d78 100644
--- a/src/sp-flowdiv.cpp
+++ b/src/sp-flowdiv.cpp
@@ -27,9 +27,9 @@ void SPFlowdiv::update(SPCtx *ctx, unsigned int flags) {
childflags &= SP_OBJECT_MODIFIED_CASCADE;
GSList* l = NULL;
- for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse(l);
@@ -65,9 +65,9 @@ void SPFlowdiv::modified(unsigned int flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList *l = NULL;
- for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse (l);
@@ -104,15 +104,15 @@ Inkscape::XML::Node* SPFlowdiv::write(Inkscape::XML::Document *xml_doc, Inkscape
GSList *l = NULL;
- for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
+ for (auto& child: _children) {
Inkscape::XML::Node* c_repr = NULL;
- if ( SP_IS_FLOWTSPAN (child) ) {
- c_repr = child->updateRepr(xml_doc, NULL, flags);
- } else if ( SP_IS_FLOWPARA(child) ) {
- c_repr = child->updateRepr(xml_doc, NULL, flags);
- } else if ( SP_IS_STRING(child) ) {
- c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
+ if ( SP_IS_FLOWTSPAN (&child) ) {
+ c_repr = child.updateRepr(xml_doc, NULL, flags);
+ } else if ( SP_IS_FLOWPARA(&child) ) {
+ c_repr = child.updateRepr(xml_doc, NULL, flags);
+ } else if ( SP_IS_STRING(&child) ) {
+ c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str());
}
if ( c_repr ) {
@@ -126,13 +126,13 @@ Inkscape::XML::Node* SPFlowdiv::write(Inkscape::XML::Document *xml_doc, Inkscape
l = g_slist_remove(l, l->data);
}
} else {
- for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
- if ( SP_IS_FLOWTSPAN (child) ) {
- child->updateRepr(flags);
- } else if ( SP_IS_FLOWPARA(child) ) {
- child->updateRepr(flags);
- } else if ( SP_IS_STRING(child) ) {
- child->getRepr()->setContent(SP_STRING(child)->string.c_str());
+ for (auto& child: _children) {
+ if ( SP_IS_FLOWTSPAN (&child) ) {
+ child.updateRepr(flags);
+ } else if ( SP_IS_FLOWPARA(&child) ) {
+ child.updateRepr(flags);
+ } else if ( SP_IS_STRING(&child) ) {
+ child.getRepr()->setContent(SP_STRING(&child)->string.c_str());
}
}
}
@@ -168,9 +168,9 @@ void SPFlowtspan::update(SPCtx *ctx, unsigned int flags) {
childflags &= SP_OBJECT_MODIFIED_CASCADE;
GSList* l = NULL;
- for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse (l);
@@ -206,9 +206,9 @@ void SPFlowtspan::modified(unsigned int flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList *l = NULL;
- for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse (l);
@@ -242,15 +242,15 @@ Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inksca
GSList *l = NULL;
- for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
+ for (auto& child: _children) {
Inkscape::XML::Node* c_repr = NULL;
- if ( SP_IS_FLOWTSPAN(child) ) {
- c_repr = child->updateRepr(xml_doc, NULL, flags);
- } else if ( SP_IS_FLOWPARA(child) ) {
- c_repr = child->updateRepr(xml_doc, NULL, flags);
- } else if ( SP_IS_STRING(child) ) {
- c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
+ if ( SP_IS_FLOWTSPAN(&child) ) {
+ c_repr = child.updateRepr(xml_doc, NULL, flags);
+ } else if ( SP_IS_FLOWPARA(&child) ) {
+ c_repr = child.updateRepr(xml_doc, NULL, flags);
+ } else if ( SP_IS_STRING(&child) ) {
+ c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str());
}
if ( c_repr ) {
@@ -264,13 +264,13 @@ Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inksca
l = g_slist_remove(l, l->data);
}
} else {
- for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
- if ( SP_IS_FLOWTSPAN(child) ) {
- child->updateRepr(flags);
- } else if ( SP_IS_FLOWPARA(child) ) {
- child->updateRepr(flags);
- } else if ( SP_IS_STRING(child) ) {
- child->getRepr()->setContent(SP_STRING(child)->string.c_str());
+ for (auto& child: _children) {
+ if ( SP_IS_FLOWTSPAN(&child) ) {
+ child.updateRepr(flags);
+ } else if ( SP_IS_FLOWPARA(&child) ) {
+ child.updateRepr(flags);
+ } else if ( SP_IS_STRING(&child) ) {
+ child.getRepr()->setContent(SP_STRING(&child)->string.c_str());
}
}
}
@@ -307,9 +307,9 @@ void SPFlowpara::update(SPCtx *ctx, unsigned int flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList* l = NULL;
- for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse (l);
@@ -343,9 +343,9 @@ void SPFlowpara::modified(unsigned int flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList *l = NULL;
- for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse (l);
@@ -379,15 +379,15 @@ Inkscape::XML::Node *SPFlowpara::write(Inkscape::XML::Document *xml_doc, Inkscap
GSList *l = NULL;
- for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
+ for (auto& child: _children) {
Inkscape::XML::Node* c_repr = NULL;
- if ( SP_IS_FLOWTSPAN(child) ) {
- c_repr = child->updateRepr(xml_doc, NULL, flags);
- } else if ( SP_IS_FLOWPARA(child) ) {
- c_repr = child->updateRepr(xml_doc, NULL, flags);
- } else if ( SP_IS_STRING(child) ) {
- c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
+ if ( SP_IS_FLOWTSPAN(&child) ) {
+ c_repr = child.updateRepr(xml_doc, NULL, flags);
+ } else if ( SP_IS_FLOWPARA(&child) ) {
+ c_repr = child.updateRepr(xml_doc, NULL, flags);
+ } else if ( SP_IS_STRING(&child) ) {
+ c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str());
}
if ( c_repr ) {
@@ -401,13 +401,13 @@ Inkscape::XML::Node *SPFlowpara::write(Inkscape::XML::Document *xml_doc, Inkscap
l = g_slist_remove(l, l->data);
}
} else {
- for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
- if ( SP_IS_FLOWTSPAN(child) ) {
- child->updateRepr(flags);
- } else if ( SP_IS_FLOWPARA(child) ) {
- child->updateRepr(flags);
- } else if ( SP_IS_STRING(child) ) {
- child->getRepr()->setContent(SP_STRING(child)->string.c_str());
+ for (auto& child: _children) {
+ if ( SP_IS_FLOWTSPAN(&child) ) {
+ child.updateRepr(flags);
+ } else if ( SP_IS_FLOWPARA(&child) ) {
+ child.updateRepr(flags);
+ } else if ( SP_IS_STRING(&child) ) {
+ child.getRepr()->setContent(SP_STRING(&child)->string.c_str());
}
}
}
diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp
index 5715e5eb1..71e029072 100644
--- a/src/sp-flowregion.cpp
+++ b/src/sp-flowregion.cpp
@@ -63,9 +63,9 @@ void SPFlowregion::update(SPCtx *ctx, unsigned int flags) {
GSList *l = NULL;
- for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse(l);
@@ -102,9 +102,9 @@ void SPFlowregion::UpdateComputed(void)
}
computed.clear();
- for (SPObject* child = firstChild() ; child ; child = child->getNext() ) {
+ for (auto& child: _children) {
Shape *shape = 0;
- GetDest(child, &shape);
+ GetDest(&child, &shape);
computed.push_back(shape);
}
}
@@ -118,9 +118,9 @@ void SPFlowregion::modified(guint flags) {
GSList *l = NULL;
- for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse(l);
@@ -145,9 +145,9 @@ Inkscape::XML::Node *SPFlowregion::write(Inkscape::XML::Document *xml_doc, Inksc
}
GSList *l = NULL;
- for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) {
- if ( !dynamic_cast<SPTitle *>(child) && !dynamic_cast<SPDesc *>(child) ) {
- Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+ for (auto& child: _children) {
+ if ( !dynamic_cast<SPTitle *>(&child) && !dynamic_cast<SPDesc *>(&child) ) {
+ Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags);
if (crepr) {
l = g_slist_prepend(l, crepr);
@@ -161,10 +161,9 @@ Inkscape::XML::Node *SPFlowregion::write(Inkscape::XML::Document *xml_doc, Inksc
l = g_slist_remove(l, l->data);
}
- } else {
- for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) {
- if ( !dynamic_cast<SPTitle *>(child) && !dynamic_cast<SPDesc *>(child) ) {
- child->updateRepr(flags);
+ for (auto& child: _children) {
+ if ( !dynamic_cast<SPTitle *>(&child) && !dynamic_cast<SPDesc *>(&child) ) {
+ child.updateRepr(flags);
}
}
}
@@ -221,9 +220,9 @@ void SPFlowregionExclude::update(SPCtx *ctx, unsigned int flags) {
GSList *l = NULL;
- for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse (l);
@@ -259,8 +258,8 @@ void SPFlowregionExclude::UpdateComputed(void)
computed = NULL;
}
- for ( SPObject* child = firstChild() ; child ; child = child->getNext() ) {
- GetDest(child, &computed);
+ for (auto& child: _children) {
+ GetDest(&child, &computed);
}
}
@@ -273,9 +272,9 @@ void SPFlowregionExclude::modified(guint flags) {
GSList *l = NULL;
- for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse (l);
@@ -301,8 +300,8 @@ Inkscape::XML::Node *SPFlowregionExclude::write(Inkscape::XML::Document *xml_doc
GSList *l = NULL;
- for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) {
- Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+ for (auto& child: _children) {
+ Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags);
if (crepr) {
l = g_slist_prepend(l, crepr);
@@ -316,8 +315,8 @@ Inkscape::XML::Node *SPFlowregionExclude::write(Inkscape::XML::Document *xml_doc
}
} else {
- for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) {
- child->updateRepr(flags);
+ for (auto& child: _children) {
+ child.updateRepr(flags);
}
}
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index 51fb3ae89..eed882800 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -72,9 +72,9 @@ void SPFlowtext::update(SPCtx* ctx, unsigned int flags) {
GSList *l = NULL;
- for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse(l);
@@ -135,9 +135,9 @@ void SPFlowtext::modified(unsigned int flags) {
}
}
- for ( SPObject *o = this->firstChild() ; o ; o = o->getNext() ) {
- if (dynamic_cast<SPFlowregion *>(o)) {
- region = o;
+ for (auto& o: _children) {
+ if (dynamic_cast<SPFlowregion *>(&o)) {
+ region = &o;
break;
}
}
@@ -223,11 +223,11 @@ Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::X
GSList *l = NULL;
- for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
+ for (auto& child: _children) {
Inkscape::XML::Node *c_repr = NULL;
- if ( dynamic_cast<SPFlowdiv *>(child) || dynamic_cast<SPFlowpara *>(child) || dynamic_cast<SPFlowregion *>(child) || dynamic_cast<SPFlowregionExclude *>(child)) {
- c_repr = child->updateRepr(doc, NULL, flags);
+ if ( dynamic_cast<SPFlowdiv *>(&child) || dynamic_cast<SPFlowpara *>(&child) || dynamic_cast<SPFlowregion *>(&child) || dynamic_cast<SPFlowregionExclude *>(&child)) {
+ c_repr = child.updateRepr(doc, NULL, flags);
}
if ( c_repr ) {
@@ -241,9 +241,9 @@ Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::X
l = g_slist_remove(l, l->data);
}
} else {
- for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- if ( dynamic_cast<SPFlowdiv *>(child) || dynamic_cast<SPFlowpara *>(child) || dynamic_cast<SPFlowregion *>(child) || dynamic_cast<SPFlowregionExclude *>(child)) {
- child->updateRepr(flags);
+ for (auto& child: _children) {
+ if ( dynamic_cast<SPFlowdiv *>(&child) || dynamic_cast<SPFlowpara *>(&child) || dynamic_cast<SPFlowregion *>(&child) || dynamic_cast<SPFlowregionExclude *>(&child)) {
+ child.updateRepr(flags);
}
}
}
@@ -390,8 +390,8 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape,
*pending_line_break_object = NULL;
}
- for (SPObject *child = root->firstChild() ; child ; child = child->getNext() ) {
- SPString *str = dynamic_cast<SPString *>(child);
+ for (auto& child: root->_children) {
+ SPString *str = dynamic_cast<SPString *>(&child);
if (str) {
if (*pending_line_break_object) {
if (dynamic_cast<SPFlowregionbreak *>(*pending_line_break_object))
@@ -402,12 +402,12 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape,
*pending_line_break_object = NULL;
}
if (with_indent) {
- layout.appendText(str->string, root->style, child, &pi);
+ layout.appendText(str->string, root->style, &child, &pi);
} else {
- layout.appendText(str->string, root->style, child);
+ layout.appendText(str->string, root->style, &child);
}
} else {
- SPFlowregion *region = dynamic_cast<SPFlowregion *>(child);
+ SPFlowregion *region = dynamic_cast<SPFlowregion *>(&child);
if (region) {
std::vector<Shape*> const &computed = region->computed;
for (std::vector<Shape*>::const_iterator it = computed.begin() ; it != computed.end() ; ++it) {
@@ -421,8 +421,8 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape,
}
}
//Xml Tree is being directly used while it shouldn't be.
- else if (!dynamic_cast<SPFlowregionExclude *>(child) && !sp_repr_is_meta_element(child->getRepr())) {
- _buildLayoutInput(child, exclusion_shape, shapes, pending_line_break_object);
+ else if (!dynamic_cast<SPFlowregionExclude *>(&child) && !sp_repr_is_meta_element(child.getRepr())) {
+ _buildLayoutInput(&child, exclusion_shape, shapes, pending_line_break_object);
}
}
}
@@ -593,9 +593,9 @@ SPItem *SPFlowtext::get_frame(SPItem const *after)
SPItem *frame = 0;
SPObject *region = 0;
- for (SPObject *o = firstChild() ; o ; o = o->getNext() ) {
- if (dynamic_cast<SPFlowregion *>(o)) {
- region = o;
+ for (auto& o: _children) {
+ if (dynamic_cast<SPFlowregion *>(&o)) {
+ region = &o;
break;
}
}
@@ -603,8 +603,8 @@ SPItem *SPFlowtext::get_frame(SPItem const *after)
if (region) {
bool past = false;
- for (SPObject *o = region->firstChild() ; o ; o = o->getNext() ) {
- SPItem *item = dynamic_cast<SPItem *>(o);
+ for (auto& o: region->_children) {
+ SPItem *item = dynamic_cast<SPItem *>(&o);
if (item) {
if ( (after == NULL) || past ) {
frame = item;
@@ -707,9 +707,9 @@ Geom::Affine SPFlowtext::set_transform (Geom::Affine const &xform)
}
SPObject *region = NULL;
- for ( SPObject *o = this->firstChild() ; o ; o = o->getNext() ) {
- if (dynamic_cast<SPFlowregion *>(o)) {
- region = o;
+ for (auto& o: _children) {
+ if (dynamic_cast<SPFlowregion *>(&o)) {
+ region = &o;
break;
}
}
diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp
index 854d53dc4..abfae1a1f 100644
--- a/src/sp-gradient.cpp
+++ b/src/sp-gradient.cpp
@@ -276,8 +276,8 @@ void SPGradient::build(SPDocument *document, Inkscape::XML::Node *repr)
SPPaintServer::build(document, repr);
- for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) {
- if (SP_IS_STOP(ochild)) {
+ for (auto& ochild: _children) {
+ if (SP_IS_STOP(&ochild)) {
this->has_stops = TRUE;
break;
}
@@ -481,8 +481,8 @@ void SPGradient::remove_child(Inkscape::XML::Node *child)
SPPaintServer::remove_child(child);
this->has_stops = FALSE;
- for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) {
- if (SP_IS_STOP(ochild)) {
+ for (auto& ochild: _children) {
+ if (SP_IS_STOP(&ochild)) {
this->has_stops = TRUE;
break;
}
@@ -536,9 +536,9 @@ void SPGradient::modified(guint flags)
// FIXME: climb up the ladder of hrefs
GSList *l = NULL;
- for (SPObject *child = this->firstChild() ; child; child = child->getNext() ) {
- sp_object_ref(child);
- l = g_slist_prepend(l, child);
+ for (auto& child: _children) {
+ sp_object_ref(&child);
+ l = g_slist_prepend(l, &child);
}
l = g_slist_reverse(l);
@@ -557,10 +557,11 @@ void SPGradient::modified(guint flags)
SPStop* SPGradient::getFirstStop()
{
- SPStop* first = 0;
- for (SPObject *ochild = firstChild(); ochild && !first; ochild = ochild->getNext()) {
- if (SP_IS_STOP(ochild)) {
- first = SP_STOP(ochild);
+ SPStop* first = nullptr;
+ for (auto& ochild: _children) {
+ if (SP_IS_STOP(&ochild)) {
+ first = SP_STOP(&ochild);
+ break;
}
}
return first;
@@ -587,8 +588,8 @@ Inkscape::XML::Node *SPGradient::write(Inkscape::XML::Document *xml_doc, Inkscap
if (flags & SP_OBJECT_WRITE_BUILD) {
GSList *l = NULL;
- for (SPObject *child = this->firstChild(); child; child = child->getNext()) {
- Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+ for (auto& child: _children) {
+ Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags);
if (crepr) {
l = g_slist_prepend(l, crepr);
@@ -915,8 +916,8 @@ bool SPGradient::invalidateArray()
void SPGradient::rebuildVector()
{
gint len = 0;
- for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) {
- if (SP_IS_STOP(child)) {
+ for (auto& child: _children) {
+ if (SP_IS_STOP(&child)) {
len ++;
}
}
@@ -937,9 +938,9 @@ void SPGradient::rebuildVector()
}
}
- for ( SPObject *child = firstChild(); child; child = child->getNext() ) {
- if (SP_IS_STOP(child)) {
- SPStop *stop = SP_STOP(child);
+ for (auto& child: _children) {
+ if (SP_IS_STOP(&child)) {
+ SPStop *stop = SP_STOP(&child);
SPGradientStop gstop;
if (!vector.stops.empty()) {
@@ -1022,8 +1023,8 @@ void SPGradient::rebuildArray()
array.read( SP_MESH( this ) );
has_patches = false;
- for ( SPObject *ro = firstChild() ; ro ; ro = ro->getNext() ) {
- if (SP_IS_MESHROW(ro)) {
+ for (auto& ro: _children) {
+ if (SP_IS_MESHROW(&ro)) {
has_patches = true;
// std::cout << " Has Patches" << std::endl;
break;
diff --git a/src/sp-hatch.cpp b/src/sp-hatch.cpp
index 2d938618c..c06045e8f 100644
--- a/src/sp-hatch.cpp
+++ b/src/sp-hatch.cpp
@@ -233,14 +233,13 @@ void SPHatch::set(unsigned int key, const gchar* value)
bool SPHatch::_hasHatchPatchChildren(SPHatch const *hatch)
{
- bool matched = false;
- for (SPObject const *child = hatch->firstChild(); child && !matched; child = child->getNext() ) {
- SPHatchPath const *hatchPath = dynamic_cast<SPHatchPath const *>(child);
+ for (auto& child: hatch->_children) {
+ SPHatchPath const *hatchPath = dynamic_cast<SPHatchPath const *>(&child);
if (hatchPath) {
- matched = true;
+ return true;
}
}
- return matched;
+ return false;
}
std::vector<SPHatchPath*> SPHatch::hatchPaths()
@@ -249,8 +248,8 @@ std::vector<SPHatchPath*> SPHatch::hatchPaths()
SPHatch *src = chase_hrefs<SPHatch>(this, sigc::ptr_fun(&_hasHatchPatchChildren));
if (src) {
- for (SPObject *child = src->firstChild(); child; child = child->getNext()) {
- SPHatchPath *hatchPath = dynamic_cast<SPHatchPath *>(child);
+ for (auto& child: src->_children) {
+ SPHatchPath *hatchPath = dynamic_cast<SPHatchPath *>(&child);
if (hatchPath) {
list.push_back(hatchPath);
}
@@ -265,8 +264,8 @@ std::vector<SPHatchPath const*> SPHatch::hatchPaths() const
SPHatch const *src = chase_hrefs<SPHatch const>(this, sigc::ptr_fun(&_hasHatchPatchChildren));
if (src) {
- for (SPObject const *child = src->firstChild(); child; child = child->getNext()) {
- SPHatchPath const *hatchPath = dynamic_cast<SPHatchPath const*>(child);
+ for (auto& child: src->_children) {
+ SPHatchPath const *hatchPath = dynamic_cast<SPHatchPath const*>(&child);
if (hatchPath) {
list.push_back(hatchPath);
}
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index d775e306f..7915b0453 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -235,9 +235,9 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape::
l = NULL;
- for (SPObject *child = firstChild(); child; child = child->getNext() ) {
- if ( !dynamic_cast<SPTitle *>(child) && !dynamic_cast<SPDesc *>(child) ) {
- Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+ for (auto& child: _children) {
+ if ( !dynamic_cast<SPTitle *>(&child) && !dynamic_cast<SPDesc *>(&child) ) {
+ Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags);
if (crepr) {
l = g_slist_prepend (l, crepr);
@@ -251,9 +251,9 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape::
l = g_slist_remove (l, l->data);
}
} else {
- for (SPObject *child = firstChild() ; child ; child = child->getNext() ) {
- if ( !dynamic_cast<SPTitle *>(child) && !dynamic_cast<SPDesc *>(child) ) {
- child->updateRepr(flags);
+ for (auto& child: _children) {
+ if ( !dynamic_cast<SPTitle *>(&child) && !dynamic_cast<SPDesc *>(&child) ) {
+ child.updateRepr(flags);
}
}
}
@@ -365,9 +365,9 @@ void SPGroup::hide (unsigned int key) {
void SPGroup::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const {
- for ( SPObject const *o = this->firstChild(); o; o = o->getNext() )
+ for (auto& o: _children)
{
- SPItem const *item = dynamic_cast<SPItem const *>(o);
+ SPItem const *item = dynamic_cast<SPItem const *>(&o);
if (item) {
item->getSnappoints(p, snapprefs);
}
@@ -511,20 +511,21 @@ sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_d
GSList *objects = NULL;
Geom::Affine const g(group->transform);
- for (SPObject *child = group->firstChild() ; child; child = child->getNext() )
- if (SPItem *citem = dynamic_cast<SPItem *>(child))
- sp_item_group_ungroup_handle_clones(citem,g);
-
+ for (auto& child: group->_children) {
+ if (SPItem *citem = dynamic_cast<SPItem *>(&child)) {
+ sp_item_group_ungroup_handle_clones(citem, g);
+ }
+ }
- for (SPObject *child = group->firstChild() ; child; child = child->getNext() ) {
- SPItem *citem = dynamic_cast<SPItem *>(child);
+ for (auto& child: group->_children) {
+ SPItem *citem = dynamic_cast<SPItem *>(&child);
if (citem) {
/* Merging of style */
// this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do
// it here _before_ the new transform is set, so as to use the pre-transform bbox
citem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false);
- child->style->merge( group->style );
+ child.style->merge( group->style );
/*
* fixme: We currently make no allowance for the case where child is cloned
* and the group has any style settings.
@@ -546,9 +547,9 @@ sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_d
* extra complication & maintenance burden and this case is rare.
*/
- child->updateRepr();
+ child.updateRepr();
- Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document());
+ Inkscape::XML::Node *nrepr = child.getRepr()->duplicate(prepr->document());
// Merging transform
Geom::Affine ctrans = citem->transform * g;
@@ -599,7 +600,7 @@ sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_d
items = g_slist_prepend (items, nrepr);
} else {
- Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document());
+ Inkscape::XML::Node *nrepr = child.getRepr()->duplicate(prepr->document());
objects = g_slist_prepend (objects, nrepr);
}
}
@@ -661,9 +662,9 @@ std::vector<SPItem*> sp_item_group_item_list(SPGroup * group)
std::vector<SPItem*> s;
g_return_val_if_fail(group != NULL, s);
- for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) {
- if ( dynamic_cast<SPItem *>(o) ) {
- s.push_back((SPItem*)o);
+ for (auto& o: group->_children) {
+ if ( dynamic_cast<SPItem *>(&o) ) {
+ s.push_back((SPItem*)&o);
}
}
return s;
@@ -734,8 +735,8 @@ void SPGroup::_updateLayerMode(unsigned int display_key) {
void SPGroup::translateChildItems(Geom::Translate const &tr)
{
if ( hasChildren() ) {
- for (SPObject *o = firstChild() ; o ; o = o->getNext() ) {
- SPItem *item = dynamic_cast<SPItem *>(o);
+ for (auto& o: _children) {
+ SPItem *item = dynamic_cast<SPItem *>(&o);
if ( item ) {
sp_item_move_rel(item, tr);
}
@@ -747,14 +748,14 @@ void SPGroup::translateChildItems(Geom::Translate const &tr)
void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bool noRecurse)
{
if ( hasChildren() ) {
- for (SPObject *o = firstChild() ; o ; o = o->getNext() ) {
- if ( SPDefs *defs = dynamic_cast<SPDefs *>(o) ) { // select symbols from defs, ignore clips, masks, patterns
- for (SPObject *defschild = defs->firstChild() ; defschild ; defschild = defschild->getNext() ) {
- SPGroup *defsgroup = dynamic_cast<SPGroup *>(defschild);
+ for (auto& o: _children) {
+ if ( SPDefs *defs = dynamic_cast<SPDefs *>(&o) ) { // select symbols from defs, ignore clips, masks, patterns
+ for (auto& defschild: defs->_children) {
+ SPGroup *defsgroup = dynamic_cast<SPGroup *>(&defschild);
if (defsgroup)
defsgroup->scaleChildItemsRec(sc, p, false);
}
- } else if ( SPItem *item = dynamic_cast<SPItem *>(o) ) {
+ } else if ( SPItem *item = dynamic_cast<SPItem *>(&o) ) {
SPGroup *group = dynamic_cast<SPGroup *>(item);
if (group && !dynamic_cast<SPBox3D *>(item)) {
/* Using recursion breaks clipping because transforms are applied
@@ -870,8 +871,8 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo
gint SPGroup::getItemCount() const {
gint len = 0;
- for (SPObject const *o = this->firstChild() ; o ; o = o->getNext() ) {
- if (dynamic_cast<SPItem const *>(o)) {
+ for (auto& child: _children) {
+ if (dynamic_cast<SPItem const *>(&child)) {
len++;
}
}
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index 258a5cd14..ba57cec8b 100644
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
@@ -705,9 +705,9 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X
// so we need to add any children from the underlying object to the new repr
if (flags & SP_OBJECT_WRITE_BUILD) {
GSList *l = NULL;
- for (SPObject *child = object->firstChild(); child != NULL; child = child->next ) {
- if (dynamic_cast<SPTitle *>(child) || dynamic_cast<SPDesc *>(child)) {
- Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+ for (auto& child: object->_children) {
+ if (dynamic_cast<SPTitle *>(&child) || dynamic_cast<SPDesc *>(&child)) {
+ Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags);
if (crepr) {
l = g_slist_prepend (l, crepr);
}
@@ -719,9 +719,9 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X
l = g_slist_remove (l, l->data);
}
} else {
- for (SPObject *child = object->firstChild() ; child != NULL; child = child->next ) {
- if (dynamic_cast<SPTitle *>(child) || dynamic_cast<SPDesc *>(child)) {
- child->updateRepr(flags);
+ for (auto& child: object->_children) {
+ if (dynamic_cast<SPTitle *>(&child) || dynamic_cast<SPDesc *>(&child)) {
+ child.updateRepr(flags);
}
}
}
@@ -928,12 +928,12 @@ unsigned int SPItem::pos_in_parent() const {
unsigned int pos = 0;
- for ( SPObject *iter = parent->firstChild() ; iter ; iter = iter->next) {
- if (iter == this) {
+ for (auto& iter: parent->_children) {
+ if (&iter == this) {
return pos;
}
- if (dynamic_cast<SPItem *>(iter)) {
+ if (dynamic_cast<SPItem *>(&iter)) {
pos++;
}
}
@@ -1666,8 +1666,8 @@ SPItem const *sp_item_first_item_child(SPObject const *obj)
SPItem *sp_item_first_item_child(SPObject *obj)
{
SPItem *child = 0;
- for ( SPObject *iter = obj->firstChild() ; iter ; iter = iter->next ) {
- SPItem *tmp = dynamic_cast<SPItem *>(iter);
+ for (auto& iter: obj->_children) {
+ SPItem *tmp = dynamic_cast<SPItem *>(&iter);
if ( tmp ) {
child = tmp;
break;
diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp
index a36d8ef29..e643cc9bd 100644
--- a/src/sp-mask.cpp
+++ b/src/sp-mask.cpp
@@ -227,9 +227,9 @@ Inkscape::DrawingItem *SPMask::sp_mask_show(Inkscape::Drawing &drawing, unsigned
Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing);
this->display = sp_mask_view_new_prepend (this->display, key, ai);
- for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) {
- if (SP_IS_ITEM (child)) {
- Inkscape::DrawingItem *ac = SP_ITEM (child)->invoke_show (drawing, key, SP_ITEM_REFERENCE_FLAGS);
+ for (auto& child: _children) {
+ if (SP_IS_ITEM (&child)) {
+ Inkscape::DrawingItem *ac = SP_ITEM (&child)->invoke_show (drawing, key, SP_ITEM_REFERENCE_FLAGS);
if (ac) {
ai->prependChild(ac);
@@ -250,9 +250,9 @@ void SPMask::sp_mask_hide(unsigned int key) {
g_return_if_fail (this != NULL);
g_return_if_fail (SP_IS_MASK (this));
- for ( SPObject *child = this->firstChild(); child; child = child->getNext()) {
- if (SP_IS_ITEM (child)) {
- SP_ITEM(child)->invoke_hide (key);
+ for (auto& child: _children) {
+ if (SP_IS_ITEM (&child)) {
+ SP_ITEM(&child)->invoke_hide (key);
}
}
diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp
index 355150893..20d6d0d85 100644
--- a/src/sp-mesh-array.cpp
+++ b/src/sp-mesh-array.cpp
@@ -632,16 +632,16 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) {
guint max_column = 0;
guint irow = 0; // Corresponds to top of patch being read in.
- for ( SPObject *ro = mg->firstChild() ; ro ; ro = ro->getNext() ) {
+ for (auto& ro: mg->_children) {
- if (SP_IS_MESHROW(ro)) {
+ if (SP_IS_MESHROW(&ro)) {
guint icolumn = 0; // Corresponds to left of patch being read in.
- for ( SPObject *po = ro->firstChild() ; po ; po = po->getNext() ) {
+ for (auto& po: ro._children) {
- if (SP_IS_MESHPATCH(po)) {
+ if (SP_IS_MESHPATCH(&po)) {
- SPMeshpatch *patch = SP_MESHPATCH(po);
+ SPMeshpatch *patch = SP_MESHPATCH(&po);
// std::cout << "SPMeshNodeArray::read: row size: " << nodes.size() << std::endl;
SPMeshPatchI new_patch( &nodes, irow, icolumn ); // Adds new nodes.
@@ -652,15 +652,15 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) {
// Only 'top' side defined for first row.
if( irow != 0 ) ++istop;
- for ( SPObject *so = po->firstChild() ; so ; so = so->getNext() ) {
- if (SP_IS_STOP(so)) {
+ for (auto& so: po._children) {
+ if (SP_IS_STOP(&so)) {
if( istop > 3 ) {
// std::cout << " Mesh Gradient: Too many stops: " << istop << std::endl;
break;
}
- SPStop *stop = SP_STOP(so);
+ SPStop *stop = SP_STOP(&so);
// Handle top of first row.
if( istop == 0 && icolumn == 0 ) {
@@ -848,15 +848,15 @@ void SPMeshNodeArray::write( SPMesh *mg ) {
// First we must delete reprs for old mesh rows and patches.
GSList *descendant_reprs = NULL;
GSList *descendant_objects = NULL;
- for ( SPObject *row = mg->firstChild(); row; row = row->getNext() ) {
- descendant_reprs = g_slist_prepend (descendant_reprs, row->getRepr());
- descendant_objects = g_slist_prepend (descendant_objects, row );
- for ( SPObject *patch = row->firstChild(); patch; patch = patch->getNext() ) {
- descendant_reprs = g_slist_prepend (descendant_reprs, patch->getRepr());
- descendant_objects = g_slist_prepend (descendant_objects, patch );
- for ( SPObject *stop = patch->firstChild(); stop; stop = stop->getNext() ) {
- descendant_reprs = g_slist_prepend (descendant_reprs, stop->getRepr());
- descendant_objects = g_slist_prepend (descendant_objects, stop );
+ for (auto& row: mg->_children) {
+ descendant_reprs = g_slist_prepend (descendant_reprs, row.getRepr());
+ descendant_objects = g_slist_prepend (descendant_objects, &row);
+ for (auto& patch: row._children) {
+ descendant_reprs = g_slist_prepend (descendant_reprs, patch.getRepr());
+ descendant_objects = g_slist_prepend (descendant_objects, &patch);
+ for (auto& stop: patch._children) {
+ descendant_reprs = g_slist_prepend (descendant_reprs, stop.getRepr());
+ descendant_objects = g_slist_prepend (descendant_objects, &stop);
}
}
}
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 616ec3921..173055dbd 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -248,9 +248,9 @@ void SPNamedView::build(SPDocument *document, Inkscape::XML::Node *repr) {
this->readAttr( "inkscape:lockguides" );
/* Construct guideline list */
- for (SPObject *o = this->firstChild() ; o; o = o->getNext() ) {
- if (SP_IS_GUIDE(o)) {
- SPGuide * g = SP_GUIDE(o);
+ for (auto& o: _children) {
+ if (SP_IS_GUIDE(&o)) {
+ SPGuide * g = SP_GUIDE(&o);
this->guides.push_back(g);
//g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL);
g->setColor(this->guidecolor);
@@ -858,9 +858,9 @@ void sp_namedview_update_layers_from_document (SPDesktop *desktop)
}
// if that didn't work out, look for the topmost layer
if (!layer) {
- for ( SPObject *iter = document->getRoot()->firstChild(); iter ; iter = iter->getNext() ) {
- if (desktop->isLayer(iter)) {
- layer = iter;
+ for (auto& iter: document->getRoot()->_children) {
+ if (desktop->isLayer(&iter)) {
+ layer = &iter;
}
}
}
diff --git a/src/sp-object-group.cpp b/src/sp-object-group.cpp
index c3967461e..bfed08218 100644
--- a/src/sp-object-group.cpp
+++ b/src/sp-object-group.cpp
@@ -50,8 +50,8 @@ Inkscape::XML::Node *SPObjectGroup::write(Inkscape::XML::Document *xml_doc, Inks
}
GSList *l = 0;
- for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+ for (auto& child: _children) {
+ Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags);
if (crepr) {
l = g_slist_prepend(l, crepr);
@@ -64,8 +64,8 @@ Inkscape::XML::Node *SPObjectGroup::write(Inkscape::XML::Document *xml_doc, Inks
l = g_slist_remove(l, l->data);
}
} else {
- for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
- child->updateRepr(flags);
+ for (auto& child: _children) {
+ child.updateRepr(flags);
}
}
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index 36957ab49..2babf0441 100644
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
@@ -118,7 +118,7 @@ static gchar *sp_object_get_unique_id(SPObject *object,
*/
SPObject::SPObject()
: cloned(0), uflags(0), mflags(0), hrefcount(0), _total_hrefcount(0),
- document(NULL), parent(NULL), children(NULL), _last_child(NULL),
+ document(NULL), parent(NULL), children(NULL),
next(NULL), id(NULL), repr(NULL), refCount(1),hrefList(std::list<SPObject*>()),
_successor(NULL), _collection_policy(SPObject::COLLECT_WITH_PARENT),
_label(NULL), _default_label(NULL)
@@ -541,9 +541,6 @@ void SPObject::attach(SPObject *object, SPObject *prev)
this->children = object;
}
object->next = next;
- if (!next) {
- this->_last_child = object;
- }
if (!object->xml_space.set)
object->xml_space.value = this->xml_space.value;
}
@@ -576,9 +573,6 @@ void SPObject::reorder(SPObject* obj, SPObject* prev) {
} else {
children = next;
}
- if (!next) {
- _last_child = old_prev;
- }
if (prev) {
next = prev->next;
prev->next = obj;
@@ -587,9 +581,6 @@ void SPObject::reorder(SPObject* obj, SPObject* prev) {
children = obj;
}
obj->next = next;
- if (!next) {
- _last_child = obj;
- }
}
void SPObject::detach(SPObject *object)
@@ -616,9 +607,6 @@ void SPObject::detach(SPObject *object)
} else {
this->children = next;
}
- if (!next) {
- this->_last_child = prev;
- }
object->next = NULL;
object->parent = NULL;
@@ -856,11 +844,9 @@ void SPObject::releaseReferences() {
SPObject *SPObject::getPrev()
{
- SPObject *prev = 0;
- for ( SPObject *obj = parent->firstChild(); obj && !prev; obj = obj->getNext() ) {
- if (obj->getNext() == this) {
- prev = obj;
- }
+ SPObject *prev = nullptr;
+ if (parent && !parent->_children.empty() && &parent->_children.front() != this) {
+ prev = &*(--parent->_children.iterator_to(*this));
}
return prev;
}
diff --git a/src/sp-object.h b/src/sp-object.h
index 6aa006283..2534b2268 100644
--- a/src/sp-object.h
+++ b/src/sp-object.h
@@ -209,7 +209,6 @@ public:
SPDocument *document; /* Document we are part of */
SPObject *parent; /* Our parent (only one allowed) */
SPObject *children; /* Our children */
- SPObject *_last_child; /* Remembered last child */
SPObject *next; /* Next object in linked list */
private:
@@ -314,11 +313,11 @@ public:
bool hasChildren() const { return ( _children.size() > 0 ); }
- SPObject *firstChild() { return children; }
- SPObject const *firstChild() const { return children; }
+ SPObject *firstChild() { return _children.empty() ? nullptr : &_children.front(); }
+ SPObject const *firstChild() const { return _children.empty() ? nullptr : &_children.front(); }
- SPObject *lastChild() { return _last_child; }
- SPObject const *lastChild() const { return _last_child; }
+ SPObject *lastChild() { return _children.empty() ? nullptr : &_children.back(); }
+ SPObject const *lastChild() const { return _children.empty() ? nullptr : &_children.back(); }
enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow };
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp
index 55110f3c5..fde9f90f1 100644
--- a/src/sp-pattern.cpp
+++ b/src/sp-pattern.cpp
@@ -223,8 +223,8 @@ void SPPattern::_getChildren(std::list<SPObject *> &l)
{
for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) {
if (pat_i->firstChild()) { // find the first one with children
- for (SPObject *child = pat_i->firstChild(); child; child = child->getNext()) {
- l.push_back(child);
+ for (auto& child: pat_i->_children) {
+ l.push_back(&child);
}
break; // do not go further up the chain if children are found
}
@@ -319,8 +319,8 @@ guint SPPattern::_countHrefs(SPObject *o) const
i++;
}
- for (SPObject *child = o->firstChild(); child != NULL; child = child->next) {
- i += _countHrefs(child);
+ for (auto& child: o->_children) {
+ i += _countHrefs(&child);
}
return i;
@@ -508,13 +508,13 @@ Geom::OptRect SPPattern::viewbox() const
bool SPPattern::_hasItemChildren() const
{
- bool hasChildren = false;
- for (SPObject const *child = firstChild(); child && !hasChildren; child = child->getNext()) {
- if (SP_IS_ITEM(child)) {
- hasChildren = true;
+ for (auto& child: _children) {
+ if (SP_IS_ITEM(&child)) {
+ return true;
}
}
- return hasChildren;
+
+ return false;
}
bool SPPattern::isValid() const
@@ -558,12 +558,12 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b
Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(drawing);
drawing.setRoot(root);
- for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) {
- if (SP_IS_ITEM(child)) {
+ for (auto& child: shown->_children) {
+ if (SP_IS_ITEM(&child)) {
// for each item in pattern, show it on our drawing, add to the group,
// and connect to the release signal in case the item gets deleted
Inkscape::DrawingItem *cai;
- cai = SP_ITEM(child)->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY);
+ cai = SP_ITEM(&child)->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY);
root->appendChild(cai);
}
}
@@ -654,9 +654,9 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b
// Render drawing to pattern_surface via drawing context, this calls root->render
// which is really DrawingItem->render().
drawing.render(dc, one_tile);
- for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) {
- if (SP_IS_ITEM(child)) {
- SP_ITEM(child)->invoke_hide(dkey);
+ for (auto& child: shown->_children) {
+ if (SP_IS_ITEM(&child)) {
+ SP_ITEM(&child)->invoke_hide(dkey);
}
}
diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index 98eae2159..cfd0ced10 100644
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
@@ -73,9 +73,9 @@ void SPRoot::build(SPDocument *document, Inkscape::XML::Node *repr)
SPGroup::build(document, repr);
// Search for first <defs> node
- for (SPObject *o = this->firstChild() ; o ; o = o->getNext()) {
- if (SP_IS_DEFS(o)) {
- this->defs = SP_DEFS(o);
+ for (auto& o: _children) {
+ if (SP_IS_DEFS(&o)) {
+ this->defs = SP_DEFS(&o);
break;
}
}
@@ -174,9 +174,9 @@ void SPRoot::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
if (co && SP_IS_DEFS(co)) {
// We search for first <defs> node - it is not beautiful, but works
- for (SPObject *c = this->firstChild() ; c ; c = c->getNext()) {
- if (SP_IS_DEFS(c)) {
- this->defs = SP_DEFS(c);
+ for (auto& c: _children) {
+ if (SP_IS_DEFS(&c)) {
+ this->defs = SP_DEFS(&c);
break;
}
}
@@ -189,7 +189,8 @@ void SPRoot::remove_child(Inkscape::XML::Node *child)
SPObject *iter = 0;
// We search for first remaining <defs> node - it is not beautiful, but works
- for (iter = this->firstChild() ; iter ; iter = iter->getNext()) {
+ for (auto& child: _children) {
+ iter = &child;
if (SP_IS_DEFS(iter) && (SPDefs *)iter != this->defs) {
this->defs = (SPDefs *)iter;
break;
diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp
index d2dcde15d..7679cc31e 100644
--- a/src/sp-switch.cpp
+++ b/src/sp-switch.cpp
@@ -32,9 +32,10 @@ SPSwitch::~SPSwitch() {
SPObject *SPSwitch::_evaluateFirst() {
SPObject *first = 0;
- for (SPObject *child = this->firstChild() ; child && !first ; child = child->getNext() ) {
- if (SP_IS_ITEM(child) && sp_item_evaluate(SP_ITEM(child))) {
- first = child;
+ for (auto& child: _children) {
+ if (SP_IS_ITEM(&child) && sp_item_evaluate(SP_ITEM(&child))) {
+ first = &child;
+ break;
}
}
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<SPString *>(child);
+ for (auto& child: root->_children) {
+ SPString *str = dynamic_cast<SPString *>(&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);
diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp
index ba592058b..66866c9f7 100644
--- a/src/sp-tref.cpp
+++ b/src/sp-tref.cpp
@@ -506,9 +506,9 @@ sp_tref_convert_to_tspan(SPObject *obj)
////////////////////
else {
GSList *l = NULL;
- for (SPObject *child = obj->firstChild() ; child != NULL ; child = child->getNext() ) {
- sp_object_ref(child, obj);
- l = g_slist_prepend (l, child);
+ for (auto& child: obj->_children) {
+ sp_object_ref(&child, obj);
+ l = g_slist_prepend (l, &child);
}
l = g_slist_reverse (l);
while (l) {
diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp
index 05f8430ba..23df18503 100644
--- a/src/sp-tspan.cpp
+++ b/src/sp-tspan.cpp
@@ -96,9 +96,9 @@ void SPTSpan::update(SPCtx *ctx, guint flags) {
}
childflags &= SP_OBJECT_MODIFIED_CASCADE;
- for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) {
- if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) {
- ochild->updateDisplay(ctx, childflags);
+ for (auto& ochild: _children) {
+ if ( flags || ( ochild.uflags & SP_OBJECT_MODIFIED_FLAG )) {
+ ochild.updateDisplay(ctx, childflags);
}
}
@@ -128,9 +128,9 @@ void SPTSpan::modified(unsigned int flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
- for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) {
- if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) {
- ochild->emitModified(flags);
+ for (auto& ochild: _children) {
+ if (flags || (ochild.mflags & SP_OBJECT_MODIFIED_FLAG)) {
+ ochild.emitModified(flags);
}
}
}
@@ -175,15 +175,15 @@ Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape::
if ( flags&SP_OBJECT_WRITE_BUILD ) {
GSList *l = NULL;
- for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
+ for (auto& child: _children) {
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) ) {
- //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
- } else if ( SP_IS_STRING(child) ) {
- c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
+ if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) {
+ c_repr = child.updateRepr(xml_doc, NULL, flags);
+ } else if ( SP_IS_TEXTPATH(&child) ) {
+ //c_repr = child.updateRepr(xml_doc, NULL, flags); // shouldn't happen
+ } else if ( SP_IS_STRING(&child) ) {
+ c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str());
}
if ( c_repr ) {
@@ -197,13 +197,13 @@ Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape::
l = g_slist_remove(l, l->data);
}
} else {
- 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) ) {
+ for (auto& child: _children) {
+ if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) {
+ child.updateRepr(flags);
+ } else if ( SP_IS_TEXTPATH(&child) ) {
//c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
- } else if ( SP_IS_STRING(child) ) {
- child->getRepr()->setContent(SP_STRING(child)->string.c_str());
+ } else if ( SP_IS_STRING(&child) ) {
+ child.getRepr()->setContent(SP_STRING(&child)->string.c_str());
}
}
}
@@ -313,9 +313,9 @@ void SPTextPath::update(SPCtx *ctx, guint flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
- for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) {
- if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) {
- ochild->updateDisplay(ctx, flags);
+ for (auto& ochild: _children) {
+ if ( flags || ( ochild.uflags & SP_OBJECT_MODIFIED_FLAG )) {
+ ochild.updateDisplay(ctx, flags);
}
}
@@ -367,9 +367,9 @@ void SPTextPath::modified(unsigned int flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
- for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) {
- if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) {
- ochild->emitModified(flags);
+ for (auto& ochild: _children) {
+ if (flags || (ochild.mflags & SP_OBJECT_MODIFIED_FLAG)) {
+ ochild.emitModified(flags);
}
}
}
@@ -399,15 +399,15 @@ Inkscape::XML::Node* SPTextPath::write(Inkscape::XML::Document *xml_doc, Inkscap
if ( flags & SP_OBJECT_WRITE_BUILD ) {
GSList *l = NULL;
- for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
+ for (auto& child: _children) {
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) ) {
+ if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) {
+ c_repr = child.updateRepr(xml_doc, NULL, flags);
+ } else if ( SP_IS_TEXTPATH(&child) ) {
//c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
- } else if ( SP_IS_STRING(child) ) {
- c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
+ } else if ( SP_IS_STRING(&child) ) {
+ c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str());
}
if ( c_repr ) {
@@ -421,13 +421,13 @@ Inkscape::XML::Node* SPTextPath::write(Inkscape::XML::Document *xml_doc, Inkscap
l = g_slist_remove(l, l->data);
}
} else {
- 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) ) {
- //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
- } else if ( SP_IS_STRING(child) ) {
- child->getRepr()->setContent(SP_STRING(child)->string.c_str());
+ for (auto& child: _children) {
+ if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) {
+ child.updateRepr(flags);
+ } else if ( SP_IS_TEXTPATH(&child) ) {
+ //c_repr = child.updateRepr(xml_doc, NULL, flags); // shouldn't happen
+ } else if ( SP_IS_STRING(&child) ) {
+ child.getRepr()->setContent(SP_STRING(&child)->string.c_str());
}
}
}
@@ -466,8 +466,8 @@ void sp_textpath_to_text(SPObject *tp)
// 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());
+ for (auto& o: tp->_children) {
+ tp_reprs = g_slist_prepend(tp_reprs, o.getRepr());
}
for ( GSList *i = tp_reprs ; i ; i = i->next ) {
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index b1f324be2..4ac9143f0 100644
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
@@ -883,9 +883,9 @@ void item_outline_add_marker_child( SPItem const *item, Geom::Affine marker_tran
// note: a marker child item can be an item group!
if (SP_IS_GROUP(item)) {
// recurse through all childs:
- for (SPObject const *o = item->firstChild() ; o ; o = o->getNext() ) {
- if ( SP_IS_ITEM(o) ) {
- item_outline_add_marker_child(SP_ITEM(o), tr, pathv_in);
+ for (auto& o: item->_children) {
+ if ( SP_IS_ITEM(&o) ) {
+ item_outline_add_marker_child(SP_ITEM(&o), tr, pathv_in);
}
}
} else {
diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp
index 86aee1831..f539652c0 100644
--- a/src/text-chemistry.cpp
+++ b/src/text-chemistry.cpp
@@ -240,9 +240,9 @@ text_remove_all_kerns_recursively(SPObject *o)
g_strfreev(xa_comma);
}
- for (SPObject *i = o->firstChild(); i != NULL; i = i->getNext()) {
- text_remove_all_kerns_recursively(i);
- i->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG);
+ for (auto& i: o->_children) {
+ text_remove_all_kerns_recursively(&i);
+ i.requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG);
}
}
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;
}
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 9871804f5..75c6c5bcc 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -894,8 +894,8 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern)
_copyNode(pattern->getRepr(), _doc, _defs);
// items in the pattern may also use gradients and other patterns, so recurse
- for ( SPObject *child = pattern->firstChild() ; child ; child = child->getNext() ) {
- SPItem *childItem = dynamic_cast<SPItem *>(child);
+ for (auto& child: pattern->_children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&child);
if (childItem) {
_copyUsedDefs(childItem);
}
diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp
index 87c90c460..11af02e3c 100644
--- a/src/ui/dialog/clonetiler.cpp
+++ b/src/ui/dialog/clonetiler.cpp
@@ -2042,12 +2042,12 @@ void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from)
if (!trace_drawing)
return;
- for (SPObject *o = from->firstChild(); o != NULL; o = o->next) {
- SPItem *item = dynamic_cast<SPItem *>(o);
- if (item && clonetiler_is_a_clone_of(o, NULL)) {
+ for (auto& o: from->_children) {
+ SPItem *item = dynamic_cast<SPItem *>(&o);
+ if (item && clonetiler_is_a_clone_of(&o, NULL)) {
item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too!
}
- clonetiler_trace_hide_tiled_clones_recursively (o);
+ clonetiler_trace_hide_tiled_clones_recursively (&o);
}
}
@@ -2123,9 +2123,9 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *)
std::vector<SPItem*> to_unclump; // not including the original
- for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
- if (clonetiler_is_a_clone_of (child, obj)) {
- to_unclump.push_back((SPItem*)child);
+ for (auto& child: parent->_children) {
+ if (clonetiler_is_a_clone_of (&child, obj)) {
+ to_unclump.push_back((SPItem*)&child);
}
}
@@ -2143,8 +2143,8 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj)
guint n = 0;
- for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
- if (clonetiler_is_a_clone_of (child, obj)) {
+ for (auto& child: parent->_children) {
+ if (clonetiler_is_a_clone_of (&child, obj)) {
n ++;
}
}
@@ -2172,9 +2172,9 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d
// remove old tiling
GSList *to_delete = NULL;
- for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
- if (clonetiler_is_a_clone_of (child, obj)) {
- to_delete = g_slist_prepend (to_delete, child);
+ for (auto& child: parent->_children) {
+ if (clonetiler_is_a_clone_of (&child, obj)) {
+ to_delete = g_slist_prepend (to_delete, &child);
}
}
for (GSList *i = to_delete; i; i = i->next) {
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index 78e03e2a0..a60d1ddff 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -103,9 +103,7 @@ static int input_count(const SPFilterPrimitive* prim)
return 2;
else if(SP_IS_FEMERGE(prim)) {
// Return the number of feMergeNode connections plus an extra
- int count = 1;
- for(const SPObject* o = prim->firstChild(); o; o = o->next, ++count){};
- return count;
+ return (int) (prim->_children.size() + 1);
}
else
return 1;
@@ -2343,11 +2341,12 @@ const Gtk::TreeIter FilterEffectsDialog::PrimitiveList::find_result(const Gtk::T
if(SP_IS_FEMERGE(prim)) {
int c = 0;
bool found = false;
- for(const SPObject* o = prim->firstChild(); o; o = o->next, ++c) {
- if(c == attr && SP_IS_FEMERGENODE(o)) {
- image = SP_FEMERGENODE(o)->input;
+ for (auto& o: prim->_children) {
+ if(c == attr && SP_IS_FEMERGENODE(&o)) {
+ image = SP_FEMERGENODE(&o)->input;
found = true;
}
+ ++c;
}
if(!found)
return target;
@@ -2534,21 +2533,23 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton*
if(SP_IS_FEMERGE(prim)) {
int c = 1;
bool handled = false;
- for(SPObject* o = prim->firstChild(); o && !handled; o = o->next, ++c) {
- if(c == _in_drag && SP_IS_FEMERGENODE(o)) {
+ for (auto& o: prim->_children) {
+ if(c == _in_drag && SP_IS_FEMERGENODE(&o)) {
// If input is null, delete it
if(!in_val) {
//XML Tree being used directly here while it shouldn't be.
- sp_repr_unparent(o->getRepr());
+ sp_repr_unparent(o.getRepr());
DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS,
_("Remove merge node"));
(*get_selection()->get_selected())[_columns.primitive] = prim;
+ } else {
+ _dialog.set_attr(&o, SP_ATTR_IN, in_val);
}
- else
- _dialog.set_attr(o, SP_ATTR_IN, in_val);
handled = true;
+ break;
}
+ ++c;
}
// Add new input?
if(!handled && c == _in_drag && in_val) {
diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp
index 013a0ae6a..e156dfa13 100644
--- a/src/ui/dialog/find.cpp
+++ b/src/ui/dialog/find.cpp
@@ -747,14 +747,14 @@ std::vector<SPItem*> &Find::all_items (SPObject *r, std::vector<SPItem*> &l, boo
return l; // we're not interested in metadata
}
- for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
- SPItem *item = dynamic_cast<SPItem *>(child);
- if (item && !child->cloned && !desktop->isLayer(item)) {
+ for (auto& child: r->_children) {
+ SPItem *item = dynamic_cast<SPItem *>(&child);
+ if (item && !child.cloned && !desktop->isLayer(item)) {
if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) {
- l.insert(l.begin(),(SPItem*)child);
+ l.insert(l.begin(),(SPItem*)&child);
}
}
- l = all_items (child, l, hidden, locked);
+ l = all_items (&child, l, hidden, locked);
}
return l;
}
diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp
index f219f3db6..eafe5566a 100644
--- a/src/ui/dialog/font-substitution.cpp
+++ b/src/ui/dialog/font-substitution.cpp
@@ -182,7 +182,7 @@ std::vector<SPItem*> FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli
family = SP_TEXT(parent_text)->layout.getFontFamily(0);
// Add all the spans fonts to the set
gint ii = 0;
- for (SPObject *child = parent_text->firstChild() ; child ; child = child->getNext() ) {
+ for (auto& child: parent_text->_children) {
family = SP_TEXT(parent_text)->layout.getFontFamily(ii);
setFontSpans.insert(family);
ii++;
diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp
index 9d05c73bc..00482c573 100644
--- a/src/ui/dialog/objects.cpp
+++ b/src/ui/dialog/objects.cpp
@@ -1292,9 +1292,9 @@ bool ObjectsPanel::_executeAction()
break;
case BUTTON_COLLAPSE_ALL:
{
- for (SPObject* obj = _document->getRoot()->firstChild(); obj != NULL; obj = obj->next) {
- if (SP_IS_GROUP(obj)) {
- _setCollapsed(SP_GROUP(obj));
+ for (auto& obj: _document->getRoot()->_children) {
+ if (SP_IS_GROUP(&obj)) {
+ _setCollapsed(SP_GROUP(&obj));
}
}
_objectsChanged(_document->getRoot());
diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp
index 6da8acb20..9338a4e8c 100644
--- a/src/ui/dialog/spellcheck.cpp
+++ b/src/ui/dialog/spellcheck.cpp
@@ -234,14 +234,14 @@ GSList *SpellCheck::allTextItems (SPObject *r, GSList *l, bool hidden, bool lock
return l; // we're not interested in metadata
}
- for (SPObject *child = r->firstChild(); child; child = child->next) {
- if (SP_IS_ITEM (child) && !child->cloned && !desktop->isLayer(SP_ITEM(child))) {
- if ((hidden || !desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) {
- if (SP_IS_TEXT(child) || SP_IS_FLOWTEXT(child))
- l = g_slist_prepend (l, child);
+ for (auto& child: r->_children) {
+ if (SP_IS_ITEM (&child) && !child.cloned && !desktop->isLayer(SP_ITEM(&child))) {
+ if ((hidden || !desktop->itemIsHidden(SP_ITEM(&child))) && (locked || !SP_ITEM(&child)->isLocked())) {
+ if (SP_IS_TEXT(&child) || SP_IS_FLOWTEXT(&child))
+ l = g_slist_prepend (l, &child);
}
}
- l = allTextItems (child, l, hidden, locked);
+ l = allTextItems (&child, l, hidden, locked);
}
return l;
}
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index 51d81022f..1fdce34a5 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -658,8 +658,8 @@ GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l)
l = g_slist_prepend (l, r);
}
- for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
- l = symbols_in_doc_recursive( child, l );
+ for (auto& child: r->_children) {
+ l = symbols_in_doc_recursive( &child, l );
}
return l;
@@ -680,8 +680,8 @@ GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l)
l = g_slist_prepend (l, r);
}
- for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
- l = use_in_doc_recursive( child, l );
+ for (auto& child: r->_children) {
+ l = use_in_doc_recursive( &child, l );
}
return l;
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index 27e755add..2adba38c5 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -118,8 +118,8 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) {
SPDefs *defs = document->getDefs();
bool has_persp = false;
- for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) {
- if (SP_IS_PERSP3D(child)) {
+ for (auto& child: defs->_children) {
+ if (SP_IS_PERSP3D(&child)) {
has_persp = true;
break;
}
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index b81a630e2..be8ce6d0c 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -1114,9 +1114,9 @@ void ConnectorTool::_setActiveShape(SPItem *item) {
// The idea here is to try and add a group's children to solidify
// connection handling. We react to path objects with only one node.
- for (SPObject *child = item->firstChild() ; child ; child = child->getNext() ) {
- if (SP_IS_PATH(child) && SP_PATH(child)->nodesInPath() == 1) {
- this->_activeShapeAddKnot((SPItem *) child);
+ for (auto& child: item->_children) {
+ if (SP_IS_PATH(&child) && SP_PATH(&child)->nodesInPath() == 1) {
+ this->_activeShapeAddKnot((SPItem *) &child);
}
}
this->_activeShapeAddKnot(item);
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index 658cf4617..d048c318b 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -385,9 +385,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (dynamic_cast<SPGroup *>(item) && !dynamic_cast<SPBox3D *>(item)) {
GSList *children = NULL;
- for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
- if (dynamic_cast<SPItem *>(static_cast<SPObject *>(child))) {
- children = g_slist_prepend(children, child);
+ for (auto& child: item->_children) {
+ if (dynamic_cast<SPItem *>(static_cast<SPObject *>(&child))) {
+ children = g_slist_prepend(children, &child);
}
}
@@ -832,8 +832,8 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
double offset_l = 0;
double offset_h = 0;
SPObject *child_prev = NULL;
- for (SPObject *child = vector->firstChild(); child; child = child->getNext()) {
- SPStop *stop = dynamic_cast<SPStop *>(child);
+ for (auto& child: vector->_children) {
+ SPStop *stop = dynamic_cast<SPStop *>(&child);
if (!stop) {
continue;
}
@@ -878,7 +878,7 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
}
offset_l = offset_h;
- child_prev = child;
+ child_prev = &child;
}
}
@@ -894,8 +894,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
bool did = false;
if (dynamic_cast<SPGroup *>(item)) {
- for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
- SPItem *childItem = dynamic_cast<SPItem *>(child);
+ for (auto& child: item->_children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&child);
if (childItem) {
if (sp_tweak_color_recursive (mode, childItem, item_at_point,
fill_goal, do_fill,
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index a395d1954..c4b2ed59a 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -720,9 +720,9 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, Tool
static void select_stop_in_list( GtkWidget *combo_box, SPGradient *gradient, SPStop *new_stop, GtkWidget *data, gboolean block)
{
int i = 0;
- for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
- if (SP_IS_STOP(ochild)) {
- if (ochild == new_stop) {
+ for (auto& ochild: gradient->_children) {
+ if (SP_IS_STOP(&ochild)) {
+ if (&ochild == new_stop) {
blocked = block;
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , i);
gr_stop_set_offset(GTK_COMBO_BOX(combo_box), data);
@@ -765,9 +765,9 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S
/* Populate the combobox store */
std::vector<SPObject *> sl;
if ( gradient->hasStops() ) {
- for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
- if (SP_IS_STOP(ochild)) {
- sl.push_back(ochild);
+ for (auto& ochild: gradient->_children) {
+ if (SP_IS_STOP(&ochild)) {
+ sl.push_back(&ochild);
}
}
}
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 97e65141f..813a2d28e 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -363,13 +363,13 @@ unsigned long sp_gradient_to_hhssll(SPGradient *gr)
static GSList *get_all_doc_items(GSList *list, SPObject *from, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude)
{
- for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) {
- if (SP_IS_ITEM(child)) {
- list = g_slist_prepend(list, SP_ITEM(child));
+ for (auto& child: from->_children) {
+ if (SP_IS_ITEM(&child)) {
+ list = g_slist_prepend(list, SP_ITEM(&child));
}
- if (ingroups || SP_IS_ITEM(child)) {
- list = get_all_doc_items(list, child, onlyvisible, onlysensitive, ingroups, exclude);
+ if (ingroups || SP_IS_ITEM(&child)) {
+ list = get_all_doc_items(list, &child, onlyvisible, onlysensitive, ingroups, exclude);
}
}
@@ -525,10 +525,10 @@ static void verify_grad(SPGradient *gradient)
int i = 0;
SPStop *stop = NULL;
/* count stops */
- for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
- if (SP_IS_STOP(ochild)) {
+ for (auto& ochild: gradient->_children) {
+ if (SP_IS_STOP(&ochild)) {
i++;
- stop = SP_STOP(ochild);
+ stop = SP_STOP(&ochild);
}
}
@@ -568,9 +568,9 @@ static void select_stop_in_list( GtkWidget *vb, SPGradient *gradient, SPStop *ne
GtkWidget *combo_box = static_cast<GtkWidget *>(g_object_get_data(G_OBJECT(vb), "combo_box"));
int i = 0;
- for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
- if (SP_IS_STOP(ochild)) {
- if (ochild == new_stop) {
+ for (auto& ochild: gradient->_children) {
+ if (SP_IS_STOP(&ochild)) {
+ if (&ochild == new_stop) {
gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box) , i);
break;
}
@@ -603,9 +603,9 @@ static void update_stop_list( GtkWidget *vb, SPGradient *gradient, SPStop *new_s
/* Populate the combobox store */
GSList *sl = NULL;
if ( gradient->hasStops() ) {
- for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
- if (SP_IS_STOP(ochild)) {
- sl = g_slist_append(sl, ochild);
+ for (auto& ochild: gradient->_children) {
+ if (SP_IS_STOP(&ochild)) {
+ sl = g_slist_append(sl, &ochild);
}
}
}
diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp
index e273faad7..fd7b5f6cd 100644
--- a/src/widgets/stroke-marker-selector.cpp
+++ b/src/widgets/stroke-marker-selector.cpp
@@ -335,10 +335,10 @@ GSList *MarkerComboBox::get_marker_list (SPDocument *source)
return NULL;
}
- for ( SPObject *child = defs->firstChild(); child; child = child->getNext() )
+ for (auto& child: defs->_children)
{
- if (SP_IS_MARKER(child)) {
- ml = g_slist_prepend (ml, child);
+ if (SP_IS_MARKER(&child)) {
+ ml = g_slist_prepend (ml, &child);
}
}
return ml;