From 169dff19d4da8d76e69b8e896aa25b0013639c03 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Wed, 2 Jan 2019 10:41:30 +0100 Subject: modernize loops --- src/attribute-rel-util.cpp | 13 +- src/attribute-sort-util.cpp | 24 ++- src/conditions.cpp | 4 +- src/desktop-style.cpp | 62 ++----- src/device-manager.cpp | 38 ++--- src/display/cairo-utils.cpp | 12 +- src/display/canvas-arena.cpp | 4 +- src/display/canvas-temporary-item-list.cpp | 7 +- src/display/curve.cpp | 16 +- src/display/drawing-group.cpp | 38 ++--- src/display/drawing-item.cpp | 18 +- src/display/drawing-shape.cpp | 24 +-- src/display/drawing-text.cpp | 16 +- src/display/drawing.cpp | 9 +- src/display/nr-filter-gaussian.cpp | 2 +- src/display/nr-filter-merge.cpp | 11 +- src/display/nr-filter-slot.cpp | 4 +- src/display/nr-filter-turbulence.cpp | 4 +- src/display/nr-filter.cpp | 26 +-- src/display/sp-canvas.cpp | 16 +- src/document-subset.cpp | 24 ++- src/document.cpp | 8 +- src/event-log.cpp | 30 ++-- src/extension/extension.cpp | 10 +- src/extension/implementation/script.cpp | 4 +- src/extension/implementation/xslt.cpp | 8 +- src/extension/internal/bluredge.cpp | 5 +- src/extension/internal/cairo-render-context.cpp | 13 +- src/extension/internal/emf-print.cpp | 20 +-- src/extension/internal/filter/filter.cpp | 6 +- src/extension/internal/gimpgrad.cpp | 4 +- src/extension/internal/javafx-out.cpp | 6 +- src/extension/internal/latex-pstricks.cpp | 4 +- src/extension/internal/pdfinput/pdf-parser.cpp | 8 +- src/extension/internal/pdfinput/svg-builder.cpp | 9 +- src/extension/internal/pov-out.cpp | 16 +- src/extension/internal/svg.cpp | 12 +- src/extension/internal/wmf-print.cpp | 10 +- src/extension/param/float.cpp | 2 +- src/extension/param/parameter.cpp | 5 +- src/extension/param/string.cpp | 2 +- src/file.cpp | 8 +- src/gradient-chemistry.cpp | 4 +- src/gradient-drag.cpp | 56 +++---- src/helper/geom-pathstroke.cpp | 8 +- src/helper/geom-pathvectorsatellites.cpp | 38 ++--- src/helper/geom.cpp | 38 ++--- src/id-clash.cpp | 9 +- src/inkscape.cpp | 42 ++--- src/io/resource-manager.cpp | 10 +- src/io/stream/inkscapestream.cpp | 4 +- src/knot.cpp | 8 +- src/knotholder.cpp | 32 ++-- src/layer-manager.cpp | 9 +- src/layer-model.cpp | 8 +- src/libnrtype/FontFactory.cpp | 4 +- src/libnrtype/FontInstance.cpp | 4 +- src/libnrtype/Layout-TNG-Compute.cpp | 6 +- src/libnrtype/Layout-TNG-Input.cpp | 10 +- src/libnrtype/Layout-TNG-OutIter.cpp | 22 +-- src/libnrtype/Layout-TNG-Output.cpp | 26 +-- src/libnrtype/font-lister.cpp | 10 +- src/line-snapper.cpp | 10 +- src/livarot/Path.cpp | 32 ++-- src/livarot/PathConversion.cpp | 16 +- src/livarot/PathCutting.cpp | 32 ++-- src/livarot/ShapeRaster.cpp | 3 +- src/livarot/ShapeSweep.cpp | 182 ++++++++++----------- src/livarot/float-line.cpp | 20 +-- src/livarot/int-line.cpp | 26 +-- src/livarot/sweep-event.cpp | 6 +- src/live_effects/effect.cpp | 32 ++-- src/live_effects/lpe-bool.cpp | 8 +- src/live_effects/lpe-bspline.cpp | 58 ++++--- src/live_effects/lpe-clone-original.cpp | 5 +- src/live_effects/lpe-copy_rotate.cpp | 15 +- src/live_effects/lpe-curvestitch.cpp | 4 +- src/live_effects/lpe-dash-stroke.cpp | 36 ++-- src/live_effects/lpe-embrodery-stitch-ordering.cpp | 108 ++++++------ src/live_effects/lpe-embrodery-stitch.cpp | 10 +- src/live_effects/lpe-extrude.cpp | 8 +- src/live_effects/lpe-fill-between-many.cpp | 30 ++-- src/live_effects/lpe-fill-between-strokes.cpp | 16 +- src/live_effects/lpe-fillet-chamfer.cpp | 8 +- src/live_effects/lpe-interpolate_points.cpp | 10 +- src/live_effects/lpe-jointype.cpp | 4 +- src/live_effects/lpe-knot.cpp | 42 ++--- src/live_effects/lpe-measure-segments.cpp | 23 ++- src/live_effects/lpe-mirror_symmetry.cpp | 29 ++-- src/live_effects/lpe-offset.cpp | 8 +- src/live_effects/lpe-patternalongpath.cpp | 7 +- src/live_effects/lpe-perspective-envelope.cpp | 26 +-- src/live_effects/lpe-powerstroke.cpp | 8 +- src/live_effects/lpe-pts2ellipse.cpp | 6 +- src/live_effects/lpe-recursiveskeleton.cpp | 3 +- src/live_effects/lpe-rough-hatches.cpp | 38 ++--- src/live_effects/lpe-roughen.cpp | 19 +-- src/live_effects/lpe-ruler.cpp | 6 +- src/live_effects/lpe-show_handles.cpp | 34 ++-- src/live_effects/lpe-simplify.cpp | 20 +-- src/live_effects/lpe-sketch.cpp | 3 +- src/live_effects/lpe-spiro.cpp | 16 +- src/live_effects/lpe-taperstroke.cpp | 3 +- src/live_effects/lpe-transform_2pts.cpp | 14 +- src/live_effects/lpe-vonkoch.cpp | 24 +-- src/live_effects/parameter/originalitemarray.cpp | 13 +- src/live_effects/parameter/originalpatharray.cpp | 13 +- src/live_effects/parameter/path.cpp | 4 +- .../parameter/powerstrokepointarray.cpp | 26 +-- src/live_effects/parameter/satellitesarray.cpp | 8 +- src/live_effects/spiro.cpp | 8 +- src/main-cmdlineact.cpp | 7 +- src/object-snapper.cpp | 14 +- src/object/box3d.cpp | 18 +- src/object/color-profile.cpp | 18 +- src/object/filters/convolvematrix.cpp | 8 +- src/object/object-set.cpp | 13 +- src/object/persp3d.cpp | 55 +++---- src/object/sp-conn-end-pair.cpp | 20 +-- src/object/sp-conn-end.cpp | 3 +- src/object/sp-flowregion.cpp | 8 +- src/object/sp-flowtext.cpp | 6 +- src/object/sp-gradient.cpp | 20 +-- src/object/sp-guide.cpp | 4 +- src/object/sp-hatch-path.cpp | 26 +-- src/object/sp-hatch.cpp | 71 ++++---- src/object/sp-item-group.cpp | 10 +- src/object/sp-item.cpp | 6 +- src/object/sp-lpe-item.cpp | 37 ++--- src/object/sp-marker.cpp | 10 +- src/object/sp-mesh-array.cpp | 27 ++- src/object/sp-namedview.cpp | 20 +-- src/object/sp-object.cpp | 4 +- src/object/sp-path.cpp | 8 +- src/object/sp-pattern.cpp | 11 +- src/object/sp-polygon.cpp | 4 +- src/object/sp-shape.cpp | 30 ++-- src/object/sp-text.cpp | 40 +++-- src/path-chemistry.cpp | 3 +- src/satisfied-guide-cns.cpp | 4 +- src/selcue.cpp | 16 +- src/selection-chemistry.cpp | 61 ++++--- src/selection-describer.cpp | 9 +- src/selection.cpp | 12 +- src/seltrans.cpp | 52 +++--- src/snap-preferences.cpp | 4 +- src/snap.cpp | 23 ++- src/snapped-curve.cpp | 10 +- src/snapped-line.cpp | 6 +- src/splivarot.cpp | 7 +- src/style-internal.cpp | 16 +- src/style.cpp | 16 +- src/svg/svg-color.cpp | 4 +- src/svg/svg-path.cpp | 8 +- src/text-editing.cpp | 2 +- src/trace/imagemap.cpp | 4 +- src/trace/potrace/inkscape-potrace.cpp | 3 +- src/trace/quantize.cpp | 26 +-- src/trace/trace.cpp | 3 +- src/transf_mat_3x4.cpp | 4 +- src/ui/cache/svg_preview_cache.cpp | 7 +- src/ui/clipboard.cpp | 33 ++-- src/ui/contextmenu.cpp | 22 +-- src/ui/control-manager.cpp | 6 +- src/ui/dialog/align-and-distribute.cpp | 37 ++--- src/ui/dialog/clonetiler.cpp | 4 +- src/ui/dialog/color-item.cpp | 18 +- src/ui/dialog/document-metadata.cpp | 8 +- src/ui/dialog/document-properties.cpp | 16 +- src/ui/dialog/export.cpp | 12 +- src/ui/dialog/filedialog.cpp | 6 +- src/ui/dialog/filedialogimpl-gtkmm.cpp | 19 +-- src/ui/dialog/filter-effects-dialog.cpp | 53 +++--- src/ui/dialog/find.cpp | 36 ++-- src/ui/dialog/font-substitution.cpp | 3 +- src/ui/dialog/glyphs.cpp | 32 ++-- src/ui/dialog/grid-arrange-tab.cpp | 3 +- src/ui/dialog/icon-preview.cpp | 6 +- src/ui/dialog/inkscape-preferences.cpp | 15 +- src/ui/dialog/input.cpp | 60 ++++--- src/ui/dialog/layers.cpp | 24 +-- src/ui/dialog/objects.cpp | 27 ++- src/ui/dialog/polar-arrange-tab.cpp | 12 +- src/ui/dialog/spellcheck.cpp | 26 +-- src/ui/dialog/styledialog.cpp | 11 +- src/ui/dialog/swatches.cpp | 54 +++--- src/ui/dialog/symbols.cpp | 4 +- src/ui/dialog/tags.cpp | 36 ++-- src/ui/dialog/template-load-tab.cpp | 28 ++-- src/ui/dialog/template-widget.cpp | 4 +- src/ui/dialog/transformation.cpp | 14 +- src/ui/interface.cpp | 4 +- src/ui/tool/control-point-selection.cpp | 88 +++++----- src/ui/tool/multi-path-manipulator.cpp | 71 ++++---- src/ui/tool/node.cpp | 10 +- src/ui/tool/path-manipulator.cpp | 137 ++++++++-------- src/ui/tool/transform-handle-set.cpp | 14 +- src/ui/toolbar/calligraphy-toolbar.cpp | 23 ++- src/ui/toolbar/gradient-toolbar.cpp | 8 +- src/ui/toolbar/mesh-toolbar.cpp | 18 +- src/ui/toolbar/paintbucket-toolbar.cpp | 3 +- src/ui/toolbar/pencil-toolbar.cpp | 4 +- src/ui/toolbar/select-toolbar.cpp | 26 ++- src/ui/toolbar/text-toolbar.cpp | 4 +- src/ui/toolbar/tweak-toolbar.cpp | 4 +- src/ui/tools/connector-tool.cpp | 16 +- src/ui/tools/flood-tool.cpp | 3 +- src/ui/tools/measure-tool.cpp | 47 +++--- src/ui/tools/mesh-tool.cpp | 3 +- src/ui/tools/node-tool.cpp | 18 +- src/ui/tools/spray-tool.cpp | 12 +- src/ui/tools/text-tool.cpp | 13 +- src/ui/tools/tweak-tool.cpp | 4 +- src/ui/uxmanager.cpp | 8 +- src/ui/widget/color-icc-selector.cpp | 14 +- src/ui/widget/color-notebook.cpp | 4 +- src/ui/widget/color-scales.cpp | 4 +- src/ui/widget/dash-selector.cpp | 4 +- src/ui/widget/font-selector.cpp | 4 +- src/ui/widget/ink-select-one-action.cpp | 12 +- src/ui/widget/selected-style.cpp | 4 +- src/ui/widget/unit-menu.cpp | 4 +- src/ui/widget/unit-tracker.cpp | 4 +- src/unicoderange.cpp | 7 +- src/util/ege-tags.cpp | 8 +- src/util/units.cpp | 10 +- src/util/ziptool.cpp | 24 +-- src/vanishing-point.cpp | 72 ++++---- src/verbs.cpp | 29 ++-- src/widgets/desktop-widget.cpp | 4 +- src/widgets/ege-paint-def.cpp | 12 +- src/widgets/fill-style.cpp | 42 ++--- src/widgets/gradient-selector.cpp | 32 ++-- src/widgets/stroke-marker-selector.cpp | 5 +- src/widgets/toolbox.cpp | 8 +- src/xml/composite-node-observer.cpp | 35 ++-- src/xml/repr-io.cpp | 10 +- src/xml/simple-node.cpp | 4 +- 238 files changed, 2025 insertions(+), 2286 deletions(-) (limited to 'src') diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp index d0efe0234..7b727ea14 100644 --- a/src/attribute-rel-util.cpp +++ b/src/attribute-rel-util.cpp @@ -129,9 +129,8 @@ void sp_attribute_clean_element(Node *repr, unsigned int flags) { } // Do actual deleting (done after so as not to perturb List iterator). - for( std::set::const_iterator iter_d = attributesToDelete.begin(); - iter_d != attributesToDelete.end(); ++iter_d ) { - repr->setAttribute( (*iter_d).c_str(), nullptr, false ); + for(const auto & iter_d : attributesToDelete) { + repr->setAttribute( iter_d.c_str(), nullptr, false ); } } @@ -268,8 +267,8 @@ void sp_attribute_clean_style(Node* repr, SPCSSAttr *css, unsigned int flags) { } // End loop over style properties // Delete unneeded style properties. Do this at the end so as to not perturb List iterator. - for( std::set::const_iterator iter_d = toDelete.begin(); iter_d != toDelete.end(); ++iter_d ) { - sp_repr_css_set_property( css, (*iter_d).c_str(), nullptr ); + for(const auto & iter_d : toDelete) { + sp_repr_css_set_property( css, iter_d.c_str(), nullptr ); } } @@ -304,8 +303,8 @@ void sp_attribute_purge_default_style(SPCSSAttr *css, unsigned int flags) { } // End loop over style properties // Delete unneeded style properties. Do this at the end so as to not perturb List iterator. - for( std::set::const_iterator iter_d = toDelete.begin(); iter_d != toDelete.end(); ++iter_d ) { - sp_repr_css_set_property( css, (*iter_d).c_str(), nullptr ); + for(const auto & iter_d : toDelete) { + sp_repr_css_set_property( css, iter_d.c_str(), nullptr ); } } diff --git a/src/attribute-sort-util.cpp b/src/attribute-sort-util.cpp index 6dad86007..0e6203ce9 100644 --- a/src/attribute-sort-util.cpp +++ b/src/attribute-sort-util.cpp @@ -110,18 +110,16 @@ void sp_attribute_sort_element(Node *repr) { std::sort(my_list.begin(), my_list.end(), cmp); // Delete all attributes. //for (auto it: my_list) { - for (std::vector >::iterator it = my_list.begin(); - it != my_list.end(); ++it) { + for (auto & it : my_list) { // Removing "inkscape:label" results in crash when Layers dialog is open. - if (it->first != "inkscape:label") { - repr->setAttribute( it->first.c_str(), nullptr, false ); + if (it.first != "inkscape:label") { + repr->setAttribute( it.first.c_str(), nullptr, false ); } } // Insert all attributes in proper order - for (std::vector >::iterator it = my_list.begin(); - it != my_list.end(); ++it) { - if (it->first != "inkscape:label") { - repr->setAttribute( it->first.c_str(), it->second.c_str(), false ); + for (auto & it : my_list) { + if (it.first != "inkscape:label") { + repr->setAttribute( it.first.c_str(), it.second.c_str(), false ); } } } @@ -197,14 +195,12 @@ void sp_attribute_sort_style(Node* repr, SPCSSAttr *css) { std::sort(my_list.begin(), my_list.end(), cmp); // Delete all attributes. //for (auto it: my_list) { - for (std::vector >::iterator it = my_list.begin(); - it != my_list.end(); ++it) { - sp_repr_css_set_property( css, it->first.c_str(), nullptr ); + for (auto & it : my_list) { + sp_repr_css_set_property( css, it.first.c_str(), nullptr ); } // Insert all attributes in proper order - for (std::vector >::iterator it = my_list.begin(); - it != my_list.end(); ++it) { - sp_repr_css_set_property( css, it->first.c_str(), it->second.c_str() ); + for (auto & it : my_list) { + sp_repr_css_set_property( css, it.first.c_str(), it.second.c_str() ); } } diff --git a/src/conditions.cpp b/src/conditions.cpp index 38349f592..57f63181d 100644 --- a/src/conditions.cpp +++ b/src/conditions.cpp @@ -265,8 +265,8 @@ static bool evaluateRequiredFeatures(SPItem const */*item*/, gchar const *value) return false; } - for ( unsigned int i = 0 ; i < parts.size() ; i++ ) { - if (!evaluateSingleFeature(parts[i].c_str())) { + for (auto & part : parts) { + if (!evaluateSingleFeature(part.c_str())) { return false; } } diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 46ef82469..d008b0b68 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -449,8 +449,7 @@ stroke_average_width (const std::vector &objects) gdouble avgwidth = 0.0; bool notstroked = true; int n_notstroked = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPItem *item = *i; + for (auto item : objects) { if (!item) { continue; } @@ -515,8 +514,7 @@ objects_query_fillstroke (const std::vector &objects, SPStyle *style_re prev[0] = prev[1] = prev[2] = 0.0; bool same_color = true; - for (std::vector::const_iterator i = objects.begin(); i!= objects.end(); ++i) { - SPObject *obj = *i; + for (auto obj : objects) { if (!obj) { continue; } @@ -695,8 +693,7 @@ objects_query_opacity (const std::vector &objects, SPStyle *style_res) guint opacity_items = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; + for (auto obj : objects) { if (!obj) { continue; } @@ -751,8 +748,7 @@ objects_query_strokewidth (const std::vector &objects, SPStyle *style_r int n_stroked = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; + for (auto obj : objects) { if (!obj) { continue; } @@ -825,8 +821,7 @@ objects_query_miterlimit (const std::vector &objects, SPStyle *style_re gdouble prev_ml = -1; bool same_ml = true; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; + for (auto obj : objects) { if (!dynamic_cast(obj)) { continue; } @@ -883,8 +878,7 @@ objects_query_strokecap (const std::vector &objects, SPStyle *style_res bool same_cap = true; int n_stroked = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; + for (auto obj : objects) { if (!dynamic_cast(obj)) { continue; } @@ -934,8 +928,7 @@ objects_query_strokejoin (const std::vector &objects, SPStyle *style_re bool same_join = true; int n_stroked = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; + for (auto obj : objects) { if (!dynamic_cast(obj)) { continue; } @@ -986,8 +979,7 @@ objects_query_paintorder (const std::vector &objects, SPStyle *style_re bool same_order = true; int n_order = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; + for (auto obj : objects) { if (!dynamic_cast(obj)) { continue; } @@ -1057,9 +1049,7 @@ objects_query_fontnumbers (const std::vector &objects, SPStyle *style_r int texts = 0; int no_size = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; - + for (auto obj : objects) { if (!isTextualItem(obj)) { continue; } @@ -1234,9 +1224,7 @@ objects_query_fontstyle (const std::vector &objects, SPStyle *style_res int texts = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; - + for (auto obj : objects) { if (!isTextualItem(obj)) { continue; } @@ -1309,9 +1297,7 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ numeric_res->value = 0; asian_res->value = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; - + for (auto obj : objects) { if (!isTextualItem(obj)) { continue; } @@ -1391,9 +1377,7 @@ objects_query_writing_modes (const std::vector &objects, SPStyle *style int texts = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; - + for (auto obj : objects) { if (!isTextualItem(obj)) { continue; } @@ -1444,9 +1428,7 @@ objects_query_fontfeaturesettings (const std::vector &objects, SPStyle } style_res->font_feature_settings.set = FALSE; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; - + for (auto obj : objects) { // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!isTextualItem(obj)) { continue; @@ -1512,9 +1494,7 @@ objects_query_baselines (const std::vector &objects, SPStyle *style_res int texts = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; - + for (auto obj : objects) { if (!isTextualItem(obj)) { continue; } @@ -1600,9 +1580,7 @@ objects_query_fontfamily (const std::vector &objects, SPStyle *style_re } style_res->font_family.set = FALSE; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; - + for (auto obj : objects) { // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!isTextualItem(obj)) { continue; @@ -1656,9 +1634,7 @@ objects_query_fontspecification (const std::vector &objects, SPStyle *s } style_res->font_specification.set = FALSE; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; - + for (auto obj : objects) { // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!isTextualItem(obj)) { continue; @@ -1714,8 +1690,7 @@ objects_query_blend (const std::vector &objects, SPStyle *style_res) bool same_blend = true; guint items = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; + for (auto obj : objects) { if (!obj) { continue; } @@ -1807,8 +1782,7 @@ objects_query_blur (const std::vector &objects, SPStyle *style_res) guint blur_items = 0; guint items = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { - SPObject *obj = *i; + for (auto obj : objects) { if (!obj) { continue; } diff --git a/src/device-manager.cpp b/src/device-manager.cpp index c896a04ab..165ad6c4e 100644 --- a/src/device-manager.cpp +++ b/src/device-manager.cpp @@ -125,8 +125,8 @@ static std::map &getAxisToString() static std::map mapping; if (!init) { init = true; - for (std::map::iterator it = getStringToAxis().begin(); it != getStringToAxis().end(); ++it) { - mapping.insert(std::make_pair(it->second, it->first)); + for (auto & it : getStringToAxis()) { + mapping.insert(std::make_pair(it.second, it.first)); } } return mapping; @@ -151,8 +151,8 @@ static std::map &getModeToString() static std::map mapping; if (!init) { init = true; - for (std::map::iterator it = getStringToMode().begin(); it != getStringToMode().end(); ++it) { - mapping.insert(std::make_pair(it->second, it->first)); + for (auto & it : getStringToMode()) { + mapping.insert(std::make_pair(it.second, it.first)); } } return mapping; @@ -357,17 +357,17 @@ void DeviceManagerImpl::loadConfig() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - for (std::list >::iterator it = devices.begin(); it != devices.end(); ++it) { - if ((*it)->getSource() != Gdk::SOURCE_MOUSE) { - Glib::ustring path = "/devices/" + (*it)->getId(); + for (auto & device : devices) { + if (device->getSource() != Gdk::SOURCE_MOUSE) { + Glib::ustring path = "/devices/" + device->getId(); Gdk::InputMode mode = Gdk::MODE_DISABLED; Glib::ustring val = prefs->getString(path + "/mode"); if (getStringToMode().find(val) != getStringToMode().end()) { mode = getStringToMode()[val]; } - if ((*it)->getMode() != mode) { - setMode( (*it)->getId(), mode ); + if (device->getMode() != mode) { + setMode( device->getId(), mode ); } // @@ -379,7 +379,7 @@ void DeviceManagerImpl::loadConfig() Glib::ustring name = parts[i]; if (getStringToAxis().find(name) != getStringToAxis().end()) { Gdk::AxisUse use = getStringToAxis()[name]; - setAxisUse( (*it)->getId(), i, use ); + setAxisUse( device->getId(), i, use ); } } } @@ -393,7 +393,7 @@ void DeviceManagerImpl::loadConfig() guint key = 0; GdkModifierType mods = static_cast(0); gtk_accelerator_parse( keyStr.c_str(), &key, &mods ); - setKey( (*it)->getId(), i, key, static_cast(mods) ); + setKey( device->getId(), i, key, static_cast(mods) ); } } } @@ -405,28 +405,28 @@ void DeviceManagerImpl::saveConfig() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - for (std::list >::iterator it = devices.begin(); it != devices.end(); ++it) { - if ((*it)->getSource() != Gdk::SOURCE_MOUSE) { - Glib::ustring path = "/devices/" + (*it)->getId(); + for (auto & it : devices) { + if (it->getSource() != Gdk::SOURCE_MOUSE) { + Glib::ustring path = "/devices/" + it->getId(); - prefs->setString( path + "/mode", getModeToString()[(*it)->getMode()].c_str() ); + prefs->setString( path + "/mode", getModeToString()[it->getMode()].c_str() ); Glib::ustring tmp; - for (gint i = 0; i < (*it)->getNumAxes(); ++i) { + for (gint i = 0; i < it->getNumAxes(); ++i) { if (i > 0) { tmp += ";"; } - Glib::RefPtr device = (*it)->getDevice(); + Glib::RefPtr device = it->getDevice(); tmp += getAxisToString()[device->get_axis_use(i)]; } prefs->setString( path + "/axes", tmp ); tmp = ""; - for (gint i = 0; i < (*it)->getNumKeys(); ++i) { + for (gint i = 0; i < it->getNumKeys(); ++i) { if (i > 0) { tmp += ";"; } - Glib::RefPtr device = (*it)->getDevice(); + Glib::RefPtr device = it->getDevice(); guint keyval; Gdk::ModifierType modifiers; device->get_key(i, keyval, modifiers); diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 397d6d4b4..6dd343298 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -760,8 +760,8 @@ feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Affine const & tran Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c.toSBasis(), 0.1); // recurse to convert the new path resulting from the sbasis to svgd - for (Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) { - feed_curve_to_cairo(cr, *iter, trans, view, optimize_stroke); + for (const auto & iter : sbasis_path) { + feed_curve_to_cairo(cr, iter, trans, view, optimize_stroke); } } } @@ -845,8 +845,8 @@ feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Affi if (pathv.empty()) return; - for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) { - feed_path_to_cairo(ct, *it, trans, area, optimize_stroke, stroke_width); + for(const auto & it : pathv) { + feed_path_to_cairo(ct, it, trans, area, optimize_stroke, stroke_width); } } @@ -858,8 +858,8 @@ feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv) if (pathv.empty()) return; - for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) { - feed_path_to_cairo(ct, *it); + for(const auto & it : pathv) { + feed_path_to_cairo(ct, it); } } diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index fb20ccfe3..83693ea20 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -54,8 +54,8 @@ struct CachePrefObserver : public Inkscape::Preferences::Observer { { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); std::vector v = prefs->getAllEntries(observed_path); - for (unsigned i=0; iaddObserver(*this); } diff --git a/src/display/canvas-temporary-item-list.cpp b/src/display/canvas-temporary-item-list.cpp index ad112cdbb..caa960969 100644 --- a/src/display/canvas-temporary-item-list.cpp +++ b/src/display/canvas-temporary-item-list.cpp @@ -26,8 +26,7 @@ TemporaryItemList::TemporaryItemList(SPDesktop *desktop) TemporaryItemList::~TemporaryItemList() { // delete all items in list so the timeouts are removed - for ( std::list::iterator it = itemlist.begin(); it != itemlist.end(); ++it ) { - TemporaryItem * tempitem = *it; + for (auto tempitem : itemlist) { delete tempitem; } itemlist.clear(); @@ -49,8 +48,8 @@ TemporaryItemList::delete_item( TemporaryItem * tempitem ) { // check if the item is in the list, if so, delete it. (in other words, don't wait for the item to delete itself) bool in_list = false; - for ( std::list::iterator it = itemlist.begin(); it != itemlist.end(); ++it ) { - if ( *it == tempitem ) { + for (auto & it : itemlist) { + if ( it == tempitem ) { in_list = true; break; } diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 3391864ae..331701f27 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -158,9 +158,9 @@ SPCurve::split() const { std::list l; - for (Geom::PathVector::const_iterator path_it = _pathv.begin(); path_it != _pathv.end(); ++path_it) { + for (const auto & path_it : _pathv) { Geom::PathVector newpathv; - newpathv.push_back(*path_it); + newpathv.push_back(path_it); SPCurve * newcurve = new SPCurve(newpathv); l.push_back(newcurve); } @@ -327,8 +327,8 @@ SPCurve::is_closed() const return false; } - for (Geom::PathVector::const_iterator it = _pathv.begin(); it != _pathv.end(); ++it) { - if ( ! it->closed() ) { + for (const auto & it : _pathv) { + if ( ! it.closed() ) { return false; } } @@ -531,8 +531,8 @@ SPCurve::append(SPCurve const *curve2, _pathv.push_back( (*it) ); } } else { - for (Geom::PathVector::const_iterator it = curve2->_pathv.begin(); it != curve2->_pathv.end(); ++it) { - _pathv.push_back( (*it) ); + for (const auto & it : curve2->_pathv) { + _pathv.push_back( it ); } } } @@ -658,10 +658,10 @@ size_t SPCurve::nodes_in_path() const { size_t nr = 0; - for(Geom::PathVector::const_iterator it = _pathv.begin(); it != _pathv.end(); ++it) { + for(const auto & it : _pathv) { // if the path does not have any segments, it is a naked moveto, // and therefore any path has at least one valid node - size_t psize = std::max(1, it->size_closed()); + size_t psize = std::max(1, it.size_closed()); nr += psize; } diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index 3a2eeb018..0d6a2edfc 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -73,14 +73,14 @@ DrawingGroup::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u if (_child_transform) { child_ctx.ctm = *_child_transform * ctx.ctm; } - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->update(area, child_ctx, flags, reset); + for (auto & i : _children) { + i.update(area, child_ctx, flags, reset); } if (beststate & STATE_BBOX) { _bbox = Geom::OptIntRect(); - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - if (i->visible()) { - _bbox.unionWith(outline ? i->geometricBounds() : i->visualBounds()); + for (auto & i : _children) { + if (i.visible()) { + _bbox.unionWith(outline ? i.geometricBounds() : i.visualBounds()); } } } @@ -92,23 +92,23 @@ DrawingGroup::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne { if (stop_at == nullptr) { // normal rendering - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->setAntialiasing(_antialias); - i->render(dc, area, flags, stop_at); + for (auto & i : _children) { + i.setAntialiasing(_antialias); + i.render(dc, area, flags, stop_at); } } else { // background rendering - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - if (&*i == stop_at) return RENDER_OK; // do not render the stop_at item at all - if (i->isAncestorOf(stop_at)) { + for (auto & i : _children) { + if (&i == stop_at) return RENDER_OK; // do not render the stop_at item at all + if (i.isAncestorOf(stop_at)) { // render its ancestors without masks, opacity or filters - i->setAntialiasing(_antialias); - i->render(dc, area, flags | RENDER_FILTER_BACKGROUND, stop_at); + i.setAntialiasing(_antialias); + i.render(dc, area, flags | RENDER_FILTER_BACKGROUND, stop_at); // stop further rendering return RENDER_OK; } else { - i->setAntialiasing(_antialias); - i->render(dc, area, flags, stop_at); + i.setAntialiasing(_antialias); + i.render(dc, area, flags, stop_at); } } } @@ -118,16 +118,16 @@ DrawingGroup::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne void DrawingGroup::_clipItem(DrawingContext &dc, Geom::IntRect const &area) { - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->clip(dc, area); + for (auto & i : _children) { + i.clip(dc, area); } } DrawingItem * DrawingGroup::_pickItem(Geom::Point const &p, double delta, unsigned flags) { - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingItem *picked = i->pick(p, delta, flags); + for (auto & i : _children) { + DrawingItem *picked = i.pick(p, delta, flags); if (picked) { return _pick_children ? picked : this; } diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index d3729da94..6777be5cc 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -254,9 +254,9 @@ DrawingItem::clearChildren() // prevent children from referencing the parent during deletion // this way, children won't try to remove themselves from a list // from which they have already been removed by clear_and_dispose - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->_parent = NULL; - i->_child_type = CHILD_ORPHAN; + for (auto & i : _children) { + i._parent = NULL; + i._child_type = CHILD_ORPHAN; } _children.clear_and_dispose(DeleteDisposer()); _markForUpdate(STATE_ALL, false); @@ -418,8 +418,8 @@ void DrawingItem::setChildrenStyle(SPStyle* context_style) { _context_style = context_style; - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->setChildrenStyle( context_style ); + for (auto & i : _children) { + i.setChildrenStyle( context_style ); } } @@ -1053,8 +1053,8 @@ DrawingItem::recursivePrintTree( unsigned level ) std::cout << " "; } std::cout << name() << std::endl; - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->recursivePrintTree( level+1 ); + for (auto & i : _children) { + i.recursivePrintTree( level+1 ); } } @@ -1105,8 +1105,8 @@ DrawingItem::_invalidateFilterBackground(Geom::IntRect const &area) _cache->markDirty(area); } - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->_invalidateFilterBackground(area); + for (auto & i : _children) { + i._invalidateFilterBackground(area); } } diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index e1379a884..20544e1be 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -84,8 +84,8 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u unsigned beststate = STATE_ALL; // update markers - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->update(area, ctx, flags, reset); + for (auto & i : _children) { + i.update(area, ctx, flags, reset); } if (!(flags & STATE_RENDER)) { @@ -100,8 +100,8 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u } } if (beststate & STATE_BBOX) { - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - _bbox.unionWith(i->geometricBounds()); + for (auto & i : _children) { + _bbox.unionWith(i.geometricBounds()); } } } @@ -146,8 +146,8 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u } if (beststate & STATE_BBOX) { - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - _bbox.unionWith(i->geometricBounds()); + for (auto & i : _children) { + _bbox.unionWith(i.geometricBounds()); } } return STATE_ALL; @@ -206,8 +206,8 @@ void DrawingShape::_renderMarkers(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { // marker rendering - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->render(dc, area, flags, stop_at); + for (auto & i : _children) { + i.render(dc, area, flags, stop_at); } } @@ -289,8 +289,8 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne } // Handle different paint orders - for (unsigned i = 0; i < NRStyle::PAINT_ORDER_LAYERS; ++i) { - switch (_nrstyle.paint_order_layer[i]) { + for (auto & i : _nrstyle.paint_order_layer) { + switch (i) { case NRStyle::PAINT_ORDER_FILL: _renderFill(dc); break; @@ -412,8 +412,8 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, unsigned flags) } // if not picked on the shape itself, try its markers - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingItem *ret = i->pick(p, delta, flags & ~PICK_STICKY); + for (auto & i : _children) { + DrawingItem *ret = i.pick(p, delta, flags & ~PICK_STICKY); if (ret) { _last_pick = this; return this; diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index d809e8dcb..9d81d736d 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -446,8 +446,8 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are dc.setSource(rgba); dc.setTolerance(0.5); // low quality, but good enough for outline mode - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingGlyphs *g = dynamic_cast(&*i); + for (auto & i : _children) { + DrawingGlyphs *g = dynamic_cast(&i); if (!g) throw InvalidItemException(); Inkscape::DrawingContext::Save save(dc); @@ -512,9 +512,9 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are double leftmost = DBL_MAX; bool first_y = true; double start_y = 0.0; - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + for (auto & i : _children) { - DrawingGlyphs *g = dynamic_cast(&*i); + DrawingGlyphs *g = dynamic_cast(&i); if (!g) throw InvalidItemException(); if (!invset) { @@ -576,8 +576,8 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are } // accumulate the path that represents the glyphs - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingGlyphs *g = dynamic_cast(&*i); + for (auto & i : _children) { + DrawingGlyphs *g = dynamic_cast(&i); if (!g) throw InvalidItemException(); Inkscape::DrawingContext::Save save(dc); @@ -678,8 +678,8 @@ void DrawingText::_clipItem(DrawingContext &dc, Geom::IntRect const &/*area*/) } } - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingGlyphs *g = dynamic_cast(&*i); + for (auto & i : _children) { + DrawingGlyphs *g = dynamic_cast(&i); if (!g) { throw InvalidItemException(); } diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp index 3b41fc4c0..511de780a 100644 --- a/src/display/drawing.cpp +++ b/src/display/drawing.cpp @@ -146,10 +146,9 @@ void Drawing::setCacheLimit(Geom::OptIntRect const &r) { _cache_limit = r; - for (std::set::iterator i = _cached_items.begin(); - i != _cached_items.end(); ++i) + for (auto _cached_item : _cached_items) { - (*i)->_markForUpdate(DrawingItem::STATE_CACHE, false); + _cached_item->_markForUpdate(DrawingItem::STATE_CACHE, false); } } void @@ -234,8 +233,8 @@ Drawing::_pickItemsForCaching() std::set_difference(_cached_items.begin(), _cached_items.end(), to_cache.begin(), to_cache.end(), std::inserter(to_uncache, to_uncache.end())); - for (std::set::iterator j = to_uncache.begin(); j != to_uncache.end(); ++j) { - (*j)->setCached(false); + for (auto j : to_uncache) { + j->setCached(false); } } diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 3a1e4a621..d1dd976bb 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -482,7 +482,7 @@ gaussian_pass_IIR(Geom::Dim2 d, double deviation, cairo_surface_t *src, cairo_su // Compute filter calcFilter(deviation, bf); - for(size_t i=0; i::iterator i = _input_image.begin(); i != _input_image.end(); ++i) { - cairo_surface_t *in = slot.getcairo(*i); + for (int & i : _input_image) { + cairo_surface_t *in = slot.getcairo(i); if (cairo_surface_get_content(in) == CAIRO_CONTENT_COLOR_ALPHA) { out = ink_cairo_surface_create_identical(in); set_cairo_surface_ci( out, ci_fp ); @@ -60,8 +60,8 @@ void FilterMerge::render_cairo(FilterSlot &slot) } cairo_t *out_ct = cairo_create(out); - for (std::vector::iterator i = _input_image.begin(); i != _input_image.end(); ++i) { - cairo_surface_t *in = slot.getcairo(*i); + for (int & i : _input_image) { + cairo_surface_t *in = slot.getcairo(i); set_cairo_surface_ci( in, ci_fp ); cairo_set_source_surface(out_ct, in, 0, 0); @@ -86,8 +86,7 @@ double FilterMerge::complexity(Geom::Affine const &) bool FilterMerge::uses_background() { - for (unsigned int i = 0; i < _input_image.size(); ++i) { - int input = _input_image[i]; + for (int input : _input_image) { if (input == NR_FILTER_BACKGROUNDIMAGE || input == NR_FILTER_BACKGROUNDALPHA) { return true; } diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 91a55639f..4d9dc239d 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -59,8 +59,8 @@ FilterSlot::FilterSlot(DrawingItem *item, DrawingContext *bgdc, FilterSlot::~FilterSlot() { - for (SlotMap::iterator i = _slots.begin(); i != _slots.end(); ++i) { - cairo_surface_destroy(i->second); + for (auto & _slot : _slots) { + cairo_surface_destroy(_slot.second); } } diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index e1b6fbfd3..91a71abcd 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -128,8 +128,8 @@ public: double y = p[Geom::Y] * _baseFreq[Geom::Y]; double ratio = 1.0; - for (int k = 0; k < 4; ++k) - pixel[k] = 0.0; + for (double & k : pixel) + k = 0.0; for(int octave = 0; octave < _octaves; ++octave) { diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index c6bbf3b81..eec7c1aa6 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -145,8 +145,8 @@ int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &graphic, D units.set_paraller(false); Geom::Affine pbtrans = units.get_matrix_display2pb(); - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - if (!_primitive[i]->can_handle_affine(pbtrans)) { + for (auto & i : _primitive) { + if (!i->can_handle_affine(pbtrans)) { units.set_paraller(true); break; } @@ -157,8 +157,8 @@ int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &graphic, D slot.set_blurquality(blurquality); slot.set_device_scale(graphic.surface()->device_scale()); - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - _primitive[i]->render_cairo(slot); + for (auto & i : _primitive) { + i->render_cairo(slot); } Geom::Point origin = graphic.targetLogicalBounds().min(); @@ -185,8 +185,8 @@ void Filter::set_primitive_units(SPFilterUnits unit) { } void Filter::area_enlarge(Geom::IntRect &bbox, Inkscape::DrawingItem const *item) const { - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - if (_primitive[i]) _primitive[i]->area_enlarge(bbox, item->ctm()); + for (auto i : _primitive) { + if (i) i->area_enlarge(bbox, item->ctm()); } /* @@ -279,9 +279,9 @@ Geom::OptRect Filter::filter_effect_area(Geom::OptRect const &bbox) double Filter::complexity(Geom::Affine const &ctm) { double factor = 1.0; - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - if (_primitive[i]) { - double f = _primitive[i]->complexity(ctm); + for (auto & i : _primitive) { + if (i) { + double f = i->complexity(ctm); factor += (f - 1.0); } } @@ -290,8 +290,8 @@ double Filter::complexity(Geom::Affine const &ctm) bool Filter::uses_background() { - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - if (_primitive[i] && _primitive[i]->uses_background()) { + for (auto & i : _primitive) { + if (i && i->uses_background()) { return true; } } @@ -374,8 +374,8 @@ FilterPrimitive *Filter::get_primitive(int handle) { void Filter::clear_primitives() { - for (unsigned i = 0 ; i < _primitive.size() ; i++) { - delete _primitive[i]; + for (auto & i : _primitive) { + delete i; } _primitive.clear(); } diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 331528654..e7ac1ab9b 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -827,8 +827,8 @@ void SPCanvasGroup::update(SPCanvasItem *item, Geom::Affine const &affine, unsig SPCanvasGroup *group = SP_CANVAS_GROUP(item); Geom::OptRect bounds; - for (auto it = group->items.begin(); it != group->items.end(); ++it) { - SPCanvasItem *i = &(*it); + for (auto & item : group->items) { + SPCanvasItem *i = &item; sp_canvas_item_invoke_update (i, affine, flags); @@ -863,8 +863,8 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac *actual_item = nullptr; double dist = 0.0; - for (auto it = group->items.begin(); it != group->items.end(); ++it) { - SPCanvasItem *child = &(*it); + for (auto & it : group->items) { + SPCanvasItem *child = ⁢ if ((child->x1 <= x2) && (child->y1 <= y2) && (child->x2 >= x1) && (child->y2 >= y1)) { SPCanvasItem *point_item = nullptr; // cater for incomplete item implementations @@ -897,8 +897,8 @@ void SPCanvasGroup::render(SPCanvasItem *item, SPCanvasBuf *buf) { SPCanvasGroup *group = SP_CANVAS_GROUP(item); - for (auto it = group->items.begin(); it != group->items.end(); ++it) { - SPCanvasItem *child = &(*it); + for (auto & item : group->items) { + SPCanvasItem *child = &item; if (child->visible) { if ((child->x1 < buf->rect.right()) && (child->y1 < buf->rect.bottom()) && @@ -916,8 +916,8 @@ void SPCanvasGroup::viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_ { SPCanvasGroup *group = SP_CANVAS_GROUP(item); - for (auto it = group->items.begin(); it != group->items.end(); ++it) { - SPCanvasItem *child = &(*it); + for (auto & item : group->items) { + SPCanvasItem *child = &item; if (child->visible) { if (SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed) { SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed(child, new_area); diff --git a/src/document-subset.cpp b/src/document-subset.cpp index 713af9aa7..8cbd9bc45 100644 --- a/src/document-subset.cpp +++ b/src/document-subset.cpp @@ -130,12 +130,11 @@ struct DocumentSubset::Relations : public GC::Managed, Relations() { records[nullptr]; } ~Relations() override { - for ( Map::iterator iter=records.begin() - ; iter != records.end() ; ++iter ) + for (auto & iter : records) { - if ((*iter).first) { - sp_object_unref((*iter).first); - Record &record=(*iter).second; + if (iter.first) { + sp_object_unref(iter.first); + Record &record=iter.second; record.release_connection.disconnect(); record.position_changed_connection.disconnect(); } @@ -199,10 +198,9 @@ private: Record *record=get(obj); if (record) { Siblings &children=record->children; - for ( Siblings::iterator iter=children.begin() - ; iter != children.end() ; ++iter ) + for (auto & iter : children) { - _doRemoveSubtree(*iter); + _doRemoveSubtree(iter); } _doRemove(obj); } @@ -248,10 +246,9 @@ void DocumentSubset::Relations::addOne(SPObject *obj) { std::back_insert_iterator(children), obj ); - for ( Siblings::iterator iter=children.begin() - ; iter != children.end() ; ++iter ) + for (auto & iter : children) { - Record *child_record=get(*iter); + Record *child_record=get(iter); g_assert( child_record != nullptr ); child_record->parent = obj; } @@ -283,10 +280,9 @@ void DocumentSubset::Relations::remove(SPObject *obj, bool subtree) { siblings.insert(siblings.begin()+index, children.begin(), children.end()); - for ( Siblings::iterator iter=children.begin() - ; iter != children.end() ; ++iter) + for (auto & iter : children) { - Record *child_record=get(*iter); + Record *child_record=get(iter); g_assert( child_record != nullptr ); child_record->parent = record->parent; } diff --git a/src/document.cpp b/src/document.cpp index 753de44da..a2d7a32cb 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -234,8 +234,8 @@ Persp3D *SPDocument::getCurrentPersp3D() { // Check if current_persp3d is still valid std::vector plist; getPerspectivesInDefs(plist); - for (unsigned int i = 0; i < plist.size(); ++i) { - if (current_persp3d == plist[i]) + for (auto & i : plist) { + if (current_persp3d == i) return current_persp3d; } @@ -1839,8 +1839,8 @@ void SPDocument::importDefs(SPDocument *source) prevent_id_clashes(source, this); - for (std::vector::iterator defs = defsNodes.begin(); defs != defsNodes.end(); ++defs) { - importDefsNode(source, const_cast(*defs), target_defs); + for (auto & defsNode : defsNodes) { + importDefsNode(source, const_cast(defsNode), target_defs); } } diff --git a/src/event-log.cpp b/src/event-log.cpp index a3ee8cd12..0df1043dd 100644 --- a/src/event-log.cpp +++ b/src/event-log.cpp @@ -119,32 +119,32 @@ public: void collapseRow(Gtk::TreeModel::Path const &path) { std::vector > blockers; - for (std::vector::iterator it(_connections.begin()); it != _connections.end(); ++it) + for (auto & _connection : _connections) { - addBlocker(blockers, &(*it->_callback_connections)[Inkscape::EventLog::CALLB_SELECTION_CHANGE]); - addBlocker(blockers, &(*it->_callback_connections)[Inkscape::EventLog::CALLB_COLLAPSE]); + addBlocker(blockers, &(*_connection._callback_connections)[Inkscape::EventLog::CALLB_SELECTION_CHANGE]); + addBlocker(blockers, &(*_connection._callback_connections)[Inkscape::EventLog::CALLB_COLLAPSE]); } - for (std::vector::iterator it(_connections.begin()); it != _connections.end(); ++it) + for (auto & _connection : _connections) { - it->_event_list_view->collapse_row(path); + _connection._event_list_view->collapse_row(path); } } void selectRow(Gtk::TreeModel::Path const &path) { std::vector > blockers; - for (std::vector::iterator it(_connections.begin()); it != _connections.end(); ++it) + for (auto & _connection : _connections) { - addBlocker(blockers, &(*it->_callback_connections)[Inkscape::EventLog::CALLB_SELECTION_CHANGE]); - addBlocker(blockers, &(*it->_callback_connections)[Inkscape::EventLog::CALLB_EXPAND]); + addBlocker(blockers, &(*_connection._callback_connections)[Inkscape::EventLog::CALLB_SELECTION_CHANGE]); + addBlocker(blockers, &(*_connection._callback_connections)[Inkscape::EventLog::CALLB_EXPAND]); } - for (std::vector::iterator it(_connections.begin()); it != _connections.end(); ++it) + for (auto & _connection : _connections) { - it->_event_list_view->expand_to_path(path); - it->_event_list_selection->select(path); - it->_event_list_view->scroll_to_row(path); + _connection._event_list_view->expand_to_path(path); + _connection._event_list_selection->select(path); + _connection._event_list_view->scroll_to_row(path); } } @@ -152,10 +152,10 @@ public: { if (eventListStore) { std::vector > blockers; - for (std::vector::iterator it(_connections.begin()); it != _connections.end(); ++it) + for (auto & _connection : _connections) { - addBlocker(blockers, &(*it->_callback_connections)[Inkscape::EventLog::CALLB_SELECTION_CHANGE]); - addBlocker(blockers, &(*it->_callback_connections)[Inkscape::EventLog::CALLB_EXPAND]); + addBlocker(blockers, &(*_connection._callback_connections)[Inkscape::EventLog::CALLB_SELECTION_CHANGE]); + addBlocker(blockers, &(*_connection._callback_connections)[Inkscape::EventLog::CALLB_EXPAND]); } eventListStore->clear(); diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index 73ae9c3c8..6b95d96a7 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -147,8 +147,8 @@ Extension::~Extension () delete param; } - for (unsigned int i = 0 ; i < _deps.size(); i++) { - delete _deps[i]; + for (auto & _dep : _deps) { + delete _dep; } _deps.clear(); @@ -284,11 +284,11 @@ Extension::check () retval = false; } - for (unsigned int i = 0 ; i < _deps.size(); i++) { - if (_deps[i]->check() == FALSE) { + for (auto & _dep : _deps) { + if (_dep->check() == FALSE) { // std::cout << "Failed: " << *(_deps[i]) << std::endl; printFailure(Glib::ustring(_("a dependency was not met."))); - error_file << *_deps[i] << std::endl; + error_file << *_dep << std::endl; retval = false; } } diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 82b6b577a..9ff9c0bc2 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -841,8 +841,8 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newr } // Unparent (delete) - for (unsigned int i = 0; i < delete_list.size(); i++) { - sp_repr_unparent(delete_list[i]); + for (auto & i : delete_list) { + sp_repr_unparent(i); } attribs.clear(); oldroot->mergeFrom(newroot, "id", true, true); diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp index 7d4bff11a..7841a6506 100644 --- a/src/extension/implementation/xslt.cpp +++ b/src/extension/implementation/xslt.cpp @@ -195,12 +195,12 @@ void XSLT::save(Inkscape::Extension::Output *module, SPDocument *doc, gchar cons const char * xslt_params[max_parameters+1] ; int count = 0; - for(std::list::iterator t=params.begin(); t != params.end(); ++t) { - std::size_t pos = t->find("="); + for(auto & param : params) { + std::size_t pos = param.find("="); std::ostringstream parameter; std::ostringstream value; - parameter << t->substr(2,pos-2); - value << t->substr(pos+1); + parameter << param.substr(2,pos-2); + value << param.substr(pos+1); xslt_params[count++] = g_strdup_printf("%s", parameter.str().c_str()); xslt_params[count++] = g_strdup_printf("'%s'", value.str().c_str()); } diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 42fb067b6..23a337ff7 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -66,10 +66,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View std::vector items(selection->items().begin(), selection->items().end()); selection->clear(); - for(std::vector::iterator item = items.begin(); - item != items.end(); ++item) { - SPItem * spitem = *item; - + for(auto spitem : items) { std::vector new_items(steps); Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node * new_group = xml_doc->createElement("svg:g"); diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index ff375dcb9..db0a6867e 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1229,8 +1229,7 @@ CairoRenderContext::_createHatchPainter(SPPaintServer const *const paintserver, std::vector children(evil->hatchPaths()); for (int i = 0; i < overflow_steps; i++) { - for (std::vector::iterator iter = children.begin(); iter != children.end(); ++iter) { - SPHatchPath *path = *iter; + for (auto path : children) { _renderer->renderHatchPath(pattern_ctx, *path, dkey); } pattern_ctx->transform(overflow_transform); @@ -1698,18 +1697,18 @@ unsigned int CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont * /*font*/, unsigned int num_invalid_glyphs = 0; unsigned int i = 0; // is a counter for indexing the glyphs array, only counts the valid glyphs - for (std::vector::const_iterator it_info = glyphtext.begin() ; it_info != glyphtext.end() ; ++it_info) { + for (const auto & it_info : glyphtext) { // skip glyphs which are PANGO_GLYPH_EMPTY (0x0FFFFFFF) // or have the PANGO_GLYPH_UNKNOWN_FLAG (0x10000000) set - if (it_info->index == 0x0FFFFFFF || it_info->index & 0x10000000) { + if (it_info.index == 0x0FFFFFFF || it_info.index & 0x10000000) { TRACE(("INVALID GLYPH found\n")); g_message("Invalid glyph found, continuing..."); num_invalid_glyphs++; continue; } - glyphs[i].index = it_info->index; - glyphs[i].x = it_info->x; - glyphs[i].y = it_info->y; + glyphs[i].index = it_info.index; + glyphs[i].x = it_info.x; + glyphs[i].y = it_info.y; i++; } diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 41f44e738..1c294fcb7 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -1398,9 +1398,9 @@ unsigned int PrintEmf::fill( Dashes converted to line segments will "open" a closed path. */ bool all_closed = true; - for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { - for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { - if (pit->end_default() != pit->end_closed()) { + for (const auto & pit : pathv) { + for (Geom::Path::const_iterator cit = pit.begin(); cit != pit.end_open(); ++cit) { + if (pit.end_default() != pit.end_closed()) { all_closed = false; } } @@ -1447,8 +1447,8 @@ unsigned int PrintEmf::stroke( double tlength; // length of tmp_pathpw double slength = 0.0; // start of gragment double elength; // end of gragment - for (unsigned int i = 0; i < pathv.size(); i++) { - tmp_pathpw.concat(pathv[i].toPwSb()); + for (const auto & i : pathv) { + tmp_pathpw.concat(i.toPwSb()); } tlength = length(tmp_pathpw, 0.1); tmp_pathpw2 = arc_length_parametrization(tmp_pathpw); @@ -1507,11 +1507,11 @@ bool PrintEmf::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff int curves = 0; char *rec = nullptr; - for (Geom::PathVector::iterator pit = pv.begin(); pit != pv.end(); ++pit) { + for (auto & pit : pv) { moves++; nodes++; - for (Geom::Path::iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { + for (Geom::Path::iterator cit = pit.begin(); cit != pit.end_open(); ++cit) { nodes++; if (is_straight_curve(*cit)) { @@ -1532,11 +1532,11 @@ bool PrintEmf::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff /** * For all Subpaths in the */ - for (Geom::PathVector::iterator pit = pv.begin(); pit != pv.end(); ++pit) { + for (auto & pit : pv) { using Geom::X; using Geom::Y; - Geom::Point p0 = pit->initialPoint(); + Geom::Point p0 = pit.initialPoint(); p0[X] = (p0[X] * PX2WORLD); p0[Y] = (p0[Y] * PX2WORLD); @@ -1551,7 +1551,7 @@ bool PrintEmf::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff /** * For all segments in the subpath */ - for (Geom::Path::iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { + for (Geom::Path::iterator cit = pit.begin(); cit != pit.end_open(); ++cit) { if (is_straight_curve(*cit)) { //Geom::Point p0 = cit->initialPoint(); Geom::Point p1 = cit->finalPoint(); diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 0859bb6ff..cbc93d0ba 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -130,10 +130,8 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); - for(std::vector::iterator item = items.begin(); - item != items.end(); ++item) { - SPItem * spitem = *item; - Inkscape::XML::Node * node = spitem->getRepr(); + for(auto spitem : items) { + Inkscape::XML::Node * node = spitem->getRepr(); SPCSSAttr * css = sp_repr_css_attr(node, "style"); gchar const * filter = sp_repr_css_property(css, "filter", nullptr); diff --git a/src/extension/internal/gimpgrad.cpp b/src/extension/internal/gimpgrad.cpp index b5a95441c..0ecef60c8 100644 --- a/src/extension/internal/gimpgrad.cpp +++ b/src/extension/internal/gimpgrad.cpp @@ -183,7 +183,7 @@ GimpGrad::open (Inkscape::Extension::Input */*module*/, gchar const *filename) while (fgets(tempstr, 1024, gradient) != nullptr) { double dbls[3 + 4 + 4]; gchar *p = tempstr; - for (unsigned i = 0; i < G_N_ELEMENTS(dbls); ++i) { + for (double & dbl : dbls) { gchar *end = nullptr; double const xi = g_ascii_strtod(p, &end); if (!end || end == p || !g_ascii_isspace(*end)) { @@ -192,7 +192,7 @@ GimpGrad::open (Inkscape::Extension::Input */*module*/, gchar const *filename) if (xi < 0 || 1 < xi) { goto error; } - dbls[i] = xi; + dbl = xi; p = end + 1; } diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 1c592d354..1b0e9150d 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -312,9 +312,8 @@ bool JavaFXOutput::doGradient(SPGradient *grad, const String &id) { out(" stops:\n"); out(" [\n"); - for (unsigned int i = 0 ; igetDefaultColor(&backdropColor); } else { //~ need to get the parent or default color space (?) - for (int i = 0; i < gfxColorMaxComps; ++i) { - backdropColor.c[i] = 0; + for (int & i : backdropColor.c) { + i = 0; } } } diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 373df6a39..7247536e9 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -121,9 +121,8 @@ void SvgBuilder::_init() { // Fill _availableFontNames (Bug LP #179589) (code cfr. FontLister) std::vector families; font_factory::Default()->GetUIFamilies(families); - for ( std::vector::iterator iter = families.begin(); - iter != families.end(); ++iter ) { - _availableFontNames.emplace_back(pango_font_family_get_name(*iter)); + for (auto & familie : families) { + _availableFontNames.emplace_back(pango_font_family_get_name(familie)); } _transp_group_stack = nullptr; @@ -956,9 +955,7 @@ std::string SvgBuilder::_BestMatchingFont(std::string PDFname) double bestMatch = 0; std::string bestFontname = "Arial"; - for (guint i = 0; i < _availableFontNames.size(); i++) { - std::string fontname = _availableFontNames[i]; - + for (auto fontname : _availableFontNames) { // At least the first word of the font name should match. size_t minMatch = fontname.find(" "); if (minMatch == std::string::npos) { diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index 7ee8cd235..1b298882b 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -522,12 +522,12 @@ bool PovOutput::doTree(SPDocument *doc) out("#end\n"); out("\n\n"); out("#declare %s = union {\n", id.c_str()); - for (unsigned i = 0 ; i < povShapes.size() ; i++) + for (auto & povShape : povShapes) { - out(" object { %s\n", povShapes[i].id.c_str()); + out(" object { %s\n", povShape.id.c_str()); out(" texture { \n"); - if (povShapes[i].color.length()>0) - out(" pigment { %s }\n", povShapes[i].color.c_str()); + if (povShape.color.length()>0) + out(" pigment { %s }\n", povShape.color.c_str()); else out(" pigment { rgb <0,0,0> }\n"); out(" finish { %s_Finish }\n", pfx); @@ -551,12 +551,12 @@ bool PovOutput::doTree(SPDocument *doc) out("\n\n"); out("#declare %s_Z = union {\n", pfx); - for (unsigned i = 0 ; i < povShapes.size() ; i++) + for (auto & povShape : povShapes) { - out(" object { %s\n", povShapes[i].id.c_str()); + out(" object { %s\n", povShape.id.c_str()); out(" texture { \n"); - if (povShapes[i].color.length()>0) - out(" pigment { %s }\n", povShapes[i].color.c_str()); + if (povShape.color.length()>0) + out(" pigment { %s }\n", povShape.color.c_str()); else out(" pigment { rgb <0,0,0> }\n"); out(" finish { %s_Finish }\n", pfx); diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index 29e5b0e3e..99f893cd3 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -72,8 +72,8 @@ static void pruneExtendedNamespaces( Inkscape::XML::Node *repr ) } } // Can't change the set we're iterating over while we are iterating. - for ( std::vector::iterator it = attrsRemoved.begin(); it != attrsRemoved.end(); ++it ) { - repr->setAttribute(*it, nullptr); + for (auto & it : attrsRemoved) { + repr->setAttribute(it, nullptr); } } @@ -85,8 +85,8 @@ static void pruneExtendedNamespaces( Inkscape::XML::Node *repr ) pruneExtendedNamespaces(child); } } - for ( std::vector::iterator it = nodesRemoved.begin(); it != nodesRemoved.end(); ++it ) { - repr->removeChild(*it); + for (auto & it : nodesRemoved) { + repr->removeChild(it); } } } @@ -108,8 +108,8 @@ static void pruneProprietaryGarbage( Inkscape::XML::Node *repr ) pruneProprietaryGarbage(child); } } - for ( std::vector::iterator it = nodesRemoved.begin(); it != nodesRemoved.end(); ++it ) { - repr->removeChild(*it); + for (auto & it : nodesRemoved) { + repr->removeChild(it); } } } diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index 1604a8d48..7d13e218a 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -833,9 +833,9 @@ unsigned int PrintWmf::fill( Dashes converted to line segments will "open" a closed path. */ bool all_closed = true; - for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { - for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { - if (pit->end_default() != pit->end_closed()) { + for (const auto & pit : pathv) { + for (Geom::Path::const_iterator cit = pit.begin(); cit != pit.end_open(); ++cit) { + if (pit.end_default() != pit.end_closed()) { all_closed = false; } } @@ -881,8 +881,8 @@ unsigned int PrintWmf::stroke( double tlength; // length of tmp_pathpw double slength = 0.0; // start of gragment double elength; // end of gragment - for (unsigned int i = 0; i < pathv.size(); i++) { - tmp_pathpw.concat(pathv[i].toPwSb()); + for (const auto & i : pathv) { + tmp_pathpw.concat(i.toPwSb()); } tlength = length(tmp_pathpw, 0.1); tmp_pathpw2 = arc_length_parametrization(tmp_pathpw); diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 2886ad792..661c533ca 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -16,7 +16,7 @@ #include "xml/node.h" #include "extension/extension.h" #include "preferences.h" -#include "float.h" +#include "./float.h" namespace Inkscape { namespace Extension { diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index a1afd6b18..1a60ef32e 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -24,15 +24,14 @@ #include "bool.h" #include "color.h" -#include "color.h" #include "description.h" #include "enum.h" -#include "float.h" +#include "./float.h" #include "int.h" #include "notebook.h" #include "parameter.h" #include "radiobutton.h" -#include "string.h" +#include "./string.h" #include "extension/extension.h" diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp index 6a3de1d04..c1986cf92 100644 --- a/src/extension/param/string.cpp +++ b/src/extension/param/string.cpp @@ -15,7 +15,7 @@ #include "xml/node.h" #include "extension/extension.h" -#include "string.h" +#include "./string.h" #include "preferences.h" #include diff --git a/src/file.cpp b/src/file.cpp index 7cc962d38..9e57c0658 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -539,9 +539,9 @@ sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d //# Iterate through filenames if more than 1 if (flist.size() > 1) { - for (unsigned int i = 0; i < flist.size(); i++) + for (const auto & i : flist) { - fileName = flist[i]; + fileName = i; Glib::ustring newFileName = Glib::filename_to_utf8(fileName); if ( newFileName.size() > 0 ) @@ -1372,9 +1372,9 @@ sp_file_import(Gtk::Window &parentWindow) //# Iterate through filenames if more than 1 if (flist.size() > 1) { - for (unsigned int i = 0; i < flist.size(); i++) + for (const auto & i : flist) { - fileName = flist[i]; + fileName = i; Glib::ustring newFileName = Glib::filename_to_utf8(fileName); if (!newFileName.empty()) diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 8b3ff4d8a..10adb8af8 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -1641,8 +1641,8 @@ void sp_gradient_unset_swatch(SPDesktop *desktop, std::string id) if (doc) { const std::vector gradients = doc->getResourceList("gradient"); - for (std::vector::const_iterator i = gradients.begin(); i != gradients.end(); ++i) { - SPGradient* grad = SP_GRADIENT(*i); + for (auto gradient : gradients) { + SPGradient* grad = SP_GRADIENT(gradient); if ( id == grad->getId() ) { grad->setSwatch(false); DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index bb895ab72..0a19f8e26 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -150,8 +150,7 @@ static int gr_drag_style_query(SPStyle *style, int property, gpointer data) cf[0] = cf[1] = cf[2] = cf[3] = 0; int count = 0; - for(std::set::const_iterator it = drag->selected.begin(); it != drag->selected.end(); ++it) { //for all selected draggers - GrDragger *d = *it; + for(auto d : drag->selected) { //for all selected draggers for(std::vector::const_iterator it2 = d->draggables.begin(); it2 != d->draggables.end(); ++it2 ) { //for all draggables of dragger GrDraggable *draggable = *it2; @@ -300,8 +299,7 @@ bool GrDrag::styleSet( const SPCSSAttr *css ) return false; } - for(std::set::const_iterator it = selected.begin(); it != selected.end(); ++it) { //for all selected draggers - GrDragger *d = *it; + for(auto d : selected) { //for all selected draggers for(std::vector::const_iterator it2 = d->draggables.begin(); it2 != d->draggables.end(); ++it2 ) { //for all draggables of dragger GrDraggable *draggable = *it2; local_change = true; @@ -323,8 +321,7 @@ guint32 GrDrag::getColor() int count = 0; - for(std::set::const_iterator it = selected.begin(); it != selected.end(); ++it) { //for all selected draggers - GrDragger *d = *it; + for(auto d : selected) { //for all selected draggers for(std::vector::const_iterator it2 = d->draggables.begin(); it2 != d->draggables.end(); ++it2 ) { //for all draggables of dragger GrDraggable *draggable = *it2; @@ -1944,8 +1941,8 @@ GrDragger::isSelected() */ void GrDrag::deselect_all() { - for (std::set::const_iterator it = selected.begin(); it != selected.end(); ++it ) - (*it)->deselect(); + for (auto it : selected) + it->deselect(); selected.clear(); } @@ -1976,8 +1973,8 @@ void GrDrag::selectByCoords(std::vector coords) { for (std::vector::const_iterator l = this->draggers.begin(); l != this->draggers.end(); ++l) { GrDragger *d = *l; - for (guint k = 0; k < coords.size(); k++) { - if (Geom::L2 (d->point - coords[k]) < 1e-4) { + for (auto coord : coords) { + if (Geom::L2 (d->point - coord) < 1e-4) { setSelected (d, true, true); } } @@ -2230,45 +2227,45 @@ void GrDrag::addDraggersMesh(SPMeshGradient *mg, SPItem *item, Inkscape::PaintTa return; } - for( guint i = 0; i < nodes.size(); ++i ) { - for( guint j = 0; j < nodes[i].size(); ++j ) { + for(auto & node : nodes) { + for( guint j = 0; j < node.size(); ++j ) { // std::cout << " Draggers: " << i << " " << j << " " << nodes[i][j]->node_type << std::endl; - switch ( nodes[i][j]->node_type ) { + switch ( node[j]->node_type ) { case MG_NODE_TYPE_CORNER: { - mg->array.corners.push_back( nodes[i][j] ); + mg->array.corners.push_back( node[j] ); GrDraggable *corner = new GrDraggable (item, POINT_MG_CORNER, icorner, fill_or_stroke); addDragger ( corner ); - nodes[i][j]->draggable = icorner; + node[j]->draggable = icorner; ++icorner; break; } case MG_NODE_TYPE_HANDLE: { - mg->array.handles.push_back( nodes[i][j] ); + mg->array.handles.push_back( node[j] ); GrDraggable *handle = new GrDraggable (item, POINT_MG_HANDLE, ihandle, fill_or_stroke); GrDragger* dragger = addDragger ( handle ); - if( !show_handles || !nodes[i][j]->set ) { + if( !show_handles || !node[j]->set ) { dragger->knot->hide(); } - nodes[i][j]->draggable = ihandle; + node[j]->draggable = ihandle; ++ihandle; break; } case MG_NODE_TYPE_TENSOR: { - mg->array.tensors.push_back( nodes[i][j] ); + mg->array.tensors.push_back( node[j] ); GrDraggable *tensor = new GrDraggable (item, POINT_MG_TENSOR, itensor, fill_or_stroke); GrDragger* dragger = addDragger ( tensor ); - if( !show_handles || !nodes[i][j]->set ) { + if( !show_handles || !node[j]->set ) { dragger->knot->hide(); } - nodes[i][j]->draggable = itensor; + node[j]->draggable = itensor; ++itensor; break; } @@ -2305,12 +2302,12 @@ void GrDrag::refreshDraggersMesh(SPMeshGradient *mg, SPItem *item, Inkscape::Pai guint ihandle = 0; guint itensor = 0; - for( guint i = 0; i < nodes.size(); ++i ) { - for( guint j = 0; j < nodes[i].size(); ++j ) { + for(auto & node : nodes) { + for( guint j = 0; j < node.size(); ++j ) { // std::cout << " Draggers: " << i << " " << j << " " << nodes[i][j]->node_type << std::endl; - switch ( nodes[i][j]->node_type ) { + switch ( node[j]->node_type ) { case MG_NODE_TYPE_CORNER: // Do nothing, corners are always shown. @@ -2322,7 +2319,7 @@ void GrDrag::refreshDraggersMesh(SPMeshGradient *mg, SPItem *item, Inkscape::Pai if (dragger) { Geom::Point pk = getGradientCoords( item, POINT_MG_HANDLE, ihandle, fill_or_stroke); dragger->knot->moveto(pk); - if( !show_handles || !nodes[i][j]->set ) { + if( !show_handles || !node[j]->set ) { dragger->knot->hide(); } else { dragger->knot->show(); @@ -2341,7 +2338,7 @@ void GrDrag::refreshDraggersMesh(SPMeshGradient *mg, SPItem *item, Inkscape::Pai if (dragger) { Geom::Point pk = getGradientCoords( item, POINT_MG_TENSOR, itensor, fill_or_stroke); dragger->knot->moveto(pk); - if( !show_handles || !nodes[i][j]->set ) { + if( !show_handles || !node[j]->set ) { dragger->knot->hide(); } else { dragger->knot->show(); @@ -2733,9 +2730,7 @@ void GrDrag::selected_move(double x, double y, bool write_repr, bool scale_radia bool did = false; - for(std::set::const_iterator it = selected.begin(); it != selected.end(); ++it) { - GrDragger *d = *it; - + for(auto d : selected) { if (!d->isA(POINT_LG_MID) && !d->isA(POINT_RG_MID1) && !d->isA(POINT_RG_MID2)) { // if this is an endpoint, @@ -2745,8 +2740,7 @@ void GrDrag::selected_move(double x, double y, bool write_repr, bool scale_radia if (d->isA(POINT_RG_R1) || d->isA(POINT_RG_R2) || (d->isA(POINT_RG_FOCUS) && !d->isA(POINT_RG_CENTER))) { bool skip_radius_with_center = false; - for(std::set::const_iterator di = selected.begin(); di != selected.end(); ++di) { - GrDragger *d_new = *di; + for(auto d_new : selected) { if (d_new->isA (( d->draggables[0])->item, POINT_RG_CENTER, 0, diff --git a/src/helper/geom-pathstroke.cpp b/src/helper/geom-pathstroke.cpp index d1ed7898d..a073db506 100644 --- a/src/helper/geom-pathstroke.cpp +++ b/src/helper/geom-pathstroke.cpp @@ -972,15 +972,15 @@ void offset_curve(Geom::Path& res, Geom::Curve const* current, double width, dou } default: { Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(current->toSBasis(), tolerance); - for (size_t i = 0; i < sbasis_path.size(); ++i) - offset_curve(res, &sbasis_path[i], width, tolerance); + for (const auto & i : sbasis_path) + offset_curve(res, &i, width, tolerance); break; } } } else { Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(current->toSBasis(), 0.1); - for (size_t i = 0; i < sbasis_path.size(); ++i) - offset_curve(res, &sbasis_path[i], width, tolerance); + for (const auto & i : sbasis_path) + offset_curve(res, &i, width, tolerance); } } diff --git a/src/helper/geom-pathvectorsatellites.cpp b/src/helper/geom-pathvectorsatellites.cpp index 2516181cb..92936813d 100644 --- a/src/helper/geom-pathvectorsatellites.cpp +++ b/src/helper/geom-pathvectorsatellites.cpp @@ -43,8 +43,8 @@ void PathVectorSatellites::setSatellites(Satellites satellites) size_t PathVectorSatellites::getTotalSatellites() { size_t counter = 0; - for (size_t i = 0; i < _satellites.size(); ++i) { - for (size_t j = 0; j < _satellites[i].size(); ++j) { + for (auto & _satellite : _satellites) { + for (size_t j = 0; j < _satellite.size(); ++j) { counter++; } } @@ -68,12 +68,12 @@ std::pair PathVectorSatellites::getIndexData(size_t index) void PathVectorSatellites::setSelected(std::vector selected) { size_t counter = 0; - for (size_t i = 0; i < _satellites.size(); ++i) { - for (size_t j = 0; j < _satellites[i].size(); ++j) { + for (auto & _satellite : _satellites) { + for (size_t j = 0; j < _satellite.size(); ++j) { if (find (selected.begin(), selected.end(), counter) != selected.end()) { - _satellites[i][j].setSelected(true); + _satellite[j].setSelected(true); } else { - _satellites[i][j].setSelected(false); + _satellite[j].setSelected(false); } counter++; } @@ -82,19 +82,19 @@ void PathVectorSatellites::setSelected(std::vector selected) void PathVectorSatellites::updateSteps(size_t steps, bool apply_no_radius, bool apply_with_radius, bool only_selected) { - for (size_t i = 0; i < _satellites.size(); ++i) { - for (size_t j = 0; j < _satellites[i].size(); ++j) { - if ((!apply_no_radius && _satellites[i][j].amount == 0) || - (!apply_with_radius && _satellites[i][j].amount != 0)) + for (auto & _satellite : _satellites) { + for (size_t j = 0; j < _satellite.size(); ++j) { + if ((!apply_no_radius && _satellite[j].amount == 0) || + (!apply_with_radius && _satellite[j].amount != 0)) { continue; } if (only_selected) { - if (_satellites[i][j].selected) { - _satellites[i][j].steps = steps; + if (_satellite[j].selected) { + _satellite[j].steps = steps; } } else { - _satellites[i][j].steps = steps; + _satellite[j].steps = steps; } } } @@ -205,13 +205,13 @@ void PathVectorSatellites::recalculateForNewPathVector(Geom::PathVector const pa //TODO evaluate fix on nodes at same position size_t number_nodes = pathv.nodes().size(); size_t previous_number_nodes = _pathvector.nodes().size(); - for (size_t i = 0; i < pathv.size(); i++) { + for (const auto & i : pathv) { std::vector path_satellites; - size_t count = pathv[i].size_default(); - if ( pathv[i].closed()) { - const Geom::Curve &closingline = pathv[i].back_closed(); + size_t count = i.size_default(); + if ( i.closed()) { + const Geom::Curve &closingline = i.back_closed(); if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - count = pathv[i].size_open(); + count = i.size_open(); } } for (size_t j = 0; j < count; j++) { @@ -225,7 +225,7 @@ void PathVectorSatellites::recalculateForNewPathVector(Geom::PathVector const pa } } for (size_t l = 0; l < count2; l++) { - if (Geom::are_near(_pathvector[k][l].initialPoint(), pathv[i][j].initialPoint())) + if (Geom::are_near(_pathvector[k][l].initialPoint(), i[j].initialPoint())) { path_satellites.push_back(_satellites[k][l]); found = true; diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index e1d48580c..801a9c6f1 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -154,11 +154,11 @@ bounds_exact_transformed(Geom::PathVector const & pv, Geom::Affine const & t) Geom::Point initial = pv.front().initialPoint() * t; Geom::Rect bbox(initial, initial); // obtain well defined bbox as starting point to unionWith - for (Geom::PathVector::const_iterator it = pv.begin(); it != pv.end(); ++it) { - bbox.expandTo(it->initialPoint() * t); + for (const auto & it : pv) { + bbox.expandTo(it.initialPoint() * t); // don't loop including closing segment, since that segment can never increase the bbox - for (Geom::Path::const_iterator cit = it->begin(); cit != it->end_open(); ++cit) { + for (Geom::Path::const_iterator cit = it.begin(); cit != it.end_open(); ++cit) { Geom::Curve const &c = *cit; unsigned order = 0; @@ -395,8 +395,8 @@ geom_curve_bbox_wind_distance(Geom::Curve const & c, Geom::Affine const &m, Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c.toSBasis(), 0.1); //recurse to convert the new path resulting from the sbasis to svgd - for (Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) { - geom_curve_bbox_wind_distance(*iter, m, pt, bbox, wind, dist, tolerance, viewbox, p0); + for (const auto & iter : sbasis_path) { + geom_curve_bbox_wind_distance(iter, m, pt, bbox, wind, dist, tolerance, viewbox, p0); } } } @@ -423,13 +423,13 @@ pathv_matrix_point_bbox_wind_distance (Geom::PathVector const & pathv, Geom::Aff Geom::Point p_start(0,0); bool start_set = false; - for (Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) { + for (const auto & it : pathv) { if (start_set) { // this is a new subpath if (wind && (p0 != p_start)) // for correct fill picking, each subpath must be closed geom_line_wind_distance (p0[X], p0[Y], p_start[X], p_start[Y], pt, wind, dist); } - p0 = it->initialPoint() * m; + p0 = it.initialPoint() * m; p_start = p0; start_set = true; if (bbox) { @@ -437,7 +437,7 @@ pathv_matrix_point_bbox_wind_distance (Geom::PathVector const & pathv, Geom::Aff } // loop including closing segment if path is closed - for (Geom::Path::const_iterator cit = it->begin(); cit != it->end_default(); ++cit) { + for (Geom::Path::const_iterator cit = it.begin(); cit != it.end_default(); ++cit) { geom_curve_bbox_wind_distance(*cit, m, pt, bbox, wind, dist, tolerance, viewbox, p0); } } @@ -459,12 +459,12 @@ pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv ) { Geom::PathVector output; - for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { + for (const auto & pit : pathv) { output.push_back( Geom::Path() ); output.back().setStitching(true); - output.back().start( pit->initialPoint() ); + output.back().start( pit.initialPoint() ); - for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { + for (Geom::Path::const_iterator cit = pit.begin(); cit != pit.end_open(); ++cit) { if (is_straight_curve(*cit)) { Geom::LineSegment l(cit->initialPoint(), cit->finalPoint()); output.back().append(l); @@ -482,7 +482,7 @@ pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv ) } } - output.back().close( pit->closed() ); + output.back().close( pit.closed() ); } return output; @@ -557,19 +557,19 @@ pathv_to_cubicbezier( Geom::PathVector const &pathv) { Geom::PathVector output; double cubicGap = 0.01; - for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { + for (const auto & pit : pathv) { output.push_back( Geom::Path() ); - output.back().start( pit->initialPoint() ); - output.back().close( pit->closed() ); + output.back().start( pit.initialPoint() ); + output.back().close( pit.closed() ); bool end_open = false; - if (pit->closed()) { - const Geom::Curve &closingline = pit->back_closed(); + if (pit.closed()) { + const Geom::Curve &closingline = pit.back_closed(); if (!are_near(closingline.initialPoint(), closingline.finalPoint())) { end_open = true; } } - Geom::Path pitCubic = (Geom::Path)(*pit); - if(end_open && pit->closed()){ + Geom::Path pitCubic = (Geom::Path)pit; + if(end_open && pit.closed()){ pitCubic.close(false); pitCubic.appendNew( pitCubic.initialPoint() ); pitCubic.close(true); diff --git a/src/id-clash.cpp b/src/id-clash.cpp index 98c693e50..75154391b 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -103,8 +103,7 @@ find_references(SPObject *elem, refmap_type &refmap) if (!std::strcmp(repr_elem->name(), "inkscape:clipboard")) { SPCSSAttr *css = sp_repr_css_attr(repr_elem, "style"); if (css) { - for (unsigned i = 0; i < NUM_CLIPBOARD_PROPERTIES; ++i) { - const char *attr = clipboard_properties[i]; + for (auto attr : clipboard_properties) { const gchar *value = sp_repr_css_property(css, attr, nullptr); if (value) { auto uri = extract_uri(value); @@ -120,8 +119,7 @@ find_references(SPObject *elem, refmap_type &refmap) } /* check for xlink:href="#..." and similar */ - for (unsigned i = 0; i < NUM_HREF_LIKE_ATTRIBUTES; ++i) { - const char *attr = href_like_attributes[i]; + for (auto attr : href_like_attributes) { const gchar *val = repr_elem->attribute(attr); if (val && val[0] == '#') { std::string id(val+1); @@ -171,8 +169,7 @@ find_references(SPObject *elem, refmap_type &refmap) } /* check for other url(#...) references */ - for (unsigned i = 0; i < NUM_OTHER_URL_PROPERTIES; ++i) { - const char *attr = other_url_properties[i]; + for (auto attr : other_url_properties) { const gchar *value = repr_elem->attribute(attr); if (value) { auto uri = extract_uri(value); diff --git a/src/inkscape.cpp b/src/inkscape.cpp index acac67649..c63bc854c 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -244,11 +244,9 @@ int Application::autosave() int pid = ::getpid(); SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Autosaving documents...")); - for (std::map::iterator iter = _document_set.begin(); - iter != _document_set.end(); - ++iter) { + for (auto & iter : _document_set) { - SPDocument *doc = iter->first; + SPDocument *doc = iter.first; ++docnum; @@ -715,9 +713,9 @@ Application::crash_handler (int /*signum*/) inkscapedir }; FILE *file = nullptr; - for(size_t i=0; i::iterator r = _desktops->begin(), e = _desktops->end(); r != e; ++r) { - if ((*r)->dkey == dkey){ - return *r; + for (auto & _desktop : *_desktops) { + if (_desktop->dkey == dkey){ + return _desktop; } } return nullptr; @@ -1023,9 +1021,9 @@ Application::maximum_dkey() { unsigned int dkey = 0; - for (std::vector::iterator r = _desktops->begin(), e = _desktops->end(); r != e; ++r) { - if ((*r)->dkey > dkey){ - dkey = (*r)->dkey; + for (auto & _desktop : *_desktops) { + if (_desktop->dkey > dkey){ + dkey = _desktop->dkey; } } return dkey; @@ -1146,12 +1144,10 @@ Application::add_document (SPDocument *document) // try to insert the pair into the list if (!(_document_set.insert(std::make_pair(document, 1)).second)) { //insert failed, this key (document) is already in the list - for (std::map::iterator iter = _document_set.begin(); - iter != _document_set.end(); - ++iter) { - if (iter->first == document) { + for (auto & iter : _document_set) { + if (iter.first == document) { // found this document in list, increase its count - iter->second ++; + iter.second ++; } } } else { @@ -1228,8 +1224,7 @@ Application::sole_desktop_for_document(SPDesktop const &desktop) { if (!document) { return false; } - for ( std::vector::iterator iter = _desktops->begin(), e = _desktops->end() ; iter != e; ++iter ) { - SPDesktop *other_desktop = *iter; + for (auto other_desktop : *_desktops) { SPDocument *other_document = other_desktop->doc(); if ( other_document == document && other_desktop != &desktop ) { return false; @@ -1268,8 +1263,7 @@ Application::action_context_for_document(SPDocument *doc) { // If there are desktops, check them first to see if the document is bound to one of them if (_desktops != nullptr) { - for (std::vector::iterator iter = _desktops->begin(), e = _desktops->end() ; iter != e ; ++iter) { - SPDesktop *desktop = *iter; + for (auto desktop : *_desktops) { if (desktop->doc() == doc) { return Inkscape::ActionContext(desktop); } @@ -1293,8 +1287,8 @@ Application::action_context_for_document(SPDocument *doc) void Application::refresh_display () { - for (std::vector::iterator l = _desktops->begin(), e = _desktops->end(); l != e; ++l) { - (*l)->requestRedraw(); + for (auto & _desktop : *_desktops) { + _desktop->requestRedraw(); } } diff --git a/src/io/resource-manager.cpp b/src/io/resource-manager.cpp index ada60390e..48ef6ff76 100644 --- a/src/io/resource-manager.cpp +++ b/src/io/resource-manager.cpp @@ -260,8 +260,8 @@ std::map ResourceManagerImpl::locateLinks(Glib::us Glib::RefPtr recentMgr = Gtk::RecentManager::get_default(); std::vector< Glib::RefPtr > recentItems = recentMgr->get_items(); - for ( std::vector< Glib::RefPtr >::iterator it = recentItems.begin(); it != recentItems.end(); ++it ) { - Glib::ustring uri = (*it)->get_uri(); + for (auto & recentItem : recentItems) { + Glib::ustring uri = recentItem->get_uri(); std::string scheme = Glib::uri_parse_scheme(uri); if ( scheme == "file" ) { try { @@ -278,11 +278,11 @@ std::map ResourceManagerImpl::locateLinks(Glib::us } // At the moment we expect this list to contain file:// references, or simple relative or absolute paths. - for ( std::vector::const_iterator it = brokenLinks.begin(); it != brokenLinks.end(); ++it ) { + for (const auto & brokenLink : brokenLinks) { // TODO debug g_message("========{%s}", it->c_str()); std::string uri; - if ( extractFilepath( *it, uri ) || reconstructFilepath( *it, uri ) ) { + if ( extractFilepath( brokenLink, uri ) || reconstructFilepath( brokenLink, uri ) ) { // We were able to get some path. Check it std::string origPath = uri; @@ -315,7 +315,7 @@ std::map ResourceManagerImpl::locateLinks(Glib::us bool isAbsolute = Glib::path_is_absolute( uri ); Glib::ustring replacement = isAbsolute ? Glib::filename_to_uri( uri ) : Glib::filename_to_utf8( uri ); - result[*it] = replacement; + result[brokenLink] = replacement; } } } diff --git a/src/io/stream/inkscapestream.cpp b/src/io/stream/inkscapestream.cpp index 56ef7854e..bc6dc1d7f 100644 --- a/src/io/stream/inkscapestream.cpp +++ b/src/io/stream/inkscapestream.cpp @@ -508,8 +508,8 @@ Writer &BasicWriter::writeUString(const Glib::ustring &str) */ Writer &BasicWriter::writeStdString(const std::string &str) { - for (auto it = str.begin(); it != str.end(); ++it) { - put(*it); + for (char it : str) { + put(it); } return *this; } diff --git a/src/knot.cpp b/src/knot.cpp index caec9c829..dcf654b2d 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -159,10 +159,10 @@ SPKnot::~SPKnot() { this->item = nullptr; } - for (gint i = 0; i < SP_KNOT_VISIBLE_STATES; i++) { - if (this->cursor[i]) { - g_object_unref(this->cursor[i]); - this->cursor[i] = nullptr; + for (auto & i : this->cursor) { + if (i) { + g_object_unref(i); + i = nullptr; } } diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 5793afeee..56ed1493d 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -79,10 +79,10 @@ KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFun KnotHolder::~KnotHolder() { sp_object_unref(item); - for (std::list::iterator i = entity.begin(); i != entity.end(); ++i) + for (auto & i : entity) { - delete (*i); - (*i) = NULL; + delete i; + i = NULL; } entity.clear(); // is this necessary? sizeUpdatedConn.disconnect(); @@ -98,16 +98,14 @@ void KnotHolder::updateControlSizes() { ControlManager &mgr = ControlManager::getManager(); - for (std::list::iterator it = entity.begin(); it != entity.end(); ++it) { - KnotHolderEntity *e = *it; + for (auto e : entity) { mgr.updateItem(e->knot->item); } } void KnotHolder::update_knots() { - for (std::list::iterator i = entity.begin(); i != entity.end(); ++i) { - KnotHolderEntity *e = *i; + for (auto e : entity) { e->update_knot(); } } @@ -116,8 +114,8 @@ void KnotHolder::update_knots() * Returns true if at least one of the KnotHolderEntities has the mouse hovering above it. */ bool KnotHolder::knot_mouseover() const { - for (std::list::const_iterator i = entity.begin(); i != entity.end(); ++i) { - const SPKnot *knot = (*i)->knot; + for (auto i : entity) { + const SPKnot *knot = i->knot; if (knot && (knot->flags & SP_KNOT_MOUSEOVER)) { return true; @@ -133,8 +131,7 @@ KnotHolder::knot_mousedown_handler(SPKnot *knot, guint state) if (!(state & GDK_SHIFT_MASK)) { unselect_knots(); } - for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { - KnotHolderEntity *e = *i; + for(auto e : this->entity) { if (!(state & GDK_SHIFT_MASK)) { e->knot->selectKnot(false); } @@ -153,8 +150,7 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) { SPItem *saved_item = this->item; - for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { - KnotHolderEntity *e = *i; + for(auto e : this->entity) { if (e->knot == knot) // no need to test whether knot_click exists since it's virtual now e->knot_click(state); @@ -208,8 +204,8 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) void KnotHolder::transform_selected(Geom::Affine transform){ - for (std::list::iterator i = entity.begin(); i != entity.end(); ++i) { - SPKnot *knot = (*i)->knot; + for (auto & i : entity) { + SPKnot *knot = i->knot; if (knot->flags & SP_KNOT_SELECTED) { knot_moved_handler(knot, knot->pos * transform , 0); knot->selectKnot(true); @@ -227,8 +223,7 @@ KnotHolder::unselect_knots(){ if (shape_editor && shape_editor->has_knotholder()) { KnotHolder * knotholder = shape_editor->knotholder; if (knotholder) { - for(std::list::iterator i = knotholder->entity.begin(); i != knotholder->entity.end(); ++i) { - KnotHolderEntity *e = *i; + for(auto e : knotholder->entity) { if (e->knot->flags & SP_KNOT_SELECTED) { e->knot->selectKnot(false); } @@ -250,8 +245,7 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) // this was a local change and the knotholder does not need to be recreated: this->local_change = TRUE; - for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { - KnotHolderEntity *e = *i; + for(auto e : this->entity) { if (e->knot == knot) { Geom::Point const q = p * item->i2dt_affine().inverse() * _edit_transform.inverse(); e->knot_set(q, e->knot->drag_origin * item->i2dt_affine().inverse() * _edit_transform.inverse(), state); diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp index 18bf8d8a2..8c78a7de6 100644 --- a/src/layer-manager.cpp +++ b/src/layer-manager.cpp @@ -301,16 +301,15 @@ void LayerManager::_rebuild() { if ( !includes(layer) ) { layersToAdd.insert(SP_GROUP(layer)); } - for ( std::set::iterator it = additional.begin(); it != additional.end(); ++it ) { - if ( !includes(*it) ) { - layersToAdd.insert(*it); + for (auto it : additional) { + if ( !includes(it) ) { + layersToAdd.insert(it); } } } } - for ( std::set::iterator it = layersToAdd.begin(); it != layersToAdd.end(); ++it ) { - SPGroup* layer = *it; + for (auto layer : layersToAdd) { // Filter out objects in the middle of being deleted // Such may have been the cause of bug 1339397. diff --git a/src/layer-model.cpp b/src/layer-model.cpp index 5b064543f..82f93e94b 100644 --- a/src/layer-model.cpp +++ b/src/layer-model.cpp @@ -155,8 +155,8 @@ void LayerModel::toggleLockOtherLayers(SPObject *object) { item->setLocked(false); } - for ( std::vector::iterator it = layers.begin(); it != layers.end(); ++it ) { - SP_ITEM(*it)->setLocked(othersLocked); + for (auto & layer : layers) { + SP_ITEM(layer)->setLocked(othersLocked); } } @@ -187,8 +187,8 @@ void LayerModel::toggleLayerSolo(SPObject *object) { item->setHidden(false); } - for ( std::vector::iterator it = layers.begin(); it != layers.end(); ++it ) { - SP_ITEM(*it)->setHidden(othersShowing); + for (auto & layer : layers) { + SP_ITEM(layer)->setHidden(othersShowing); } } diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 27f8b57d0..583078803 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -461,8 +461,8 @@ void font_factory::GetUIFamilies(std::vector& out) std::sort(sorted.begin(), sorted.end(), ustringPairSort); - for (size_t i = 0; i < sorted.size(); ++i) { - out.push_back(sorted[i].first); + for (auto & i : sorted) { + out.push_back(i.first); } } diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index c2abfb3f2..0c1d0f5ed 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -525,8 +525,8 @@ void font_instance::LoadGlyph(int glyph_id) if ( doAdd ) { Geom::PathVector pv = path_builder.peek(); // close all paths - for (Geom::PathVector::iterator i = pv.begin(); i != pv.end(); ++i) { - i->close(); + for (auto & i : pv) { + i.close(); } if ( !pv.empty() ) { n_g.pathvector = new Geom::PathVector(pv); diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp index 938763656..b69cad982 100644 --- a/src/libnrtype/Layout-TNG-Compute.cpp +++ b/src/libnrtype/Layout-TNG-Compute.cpp @@ -1709,10 +1709,10 @@ bool Layout::Calculator::_buildChunksInScanRun(ParagraphInfo const ¶, // Recalculate line_box_height after backing out chunks *line_height = line_height_saved; for (std::vector::const_iterator it_chunk = chunk_info->begin() ; it_chunk != chunk_info->end() ; it_chunk++) { - for (std::vector::const_iterator it_span = it_chunk->broken_spans.begin() ; it_span != it_chunk->broken_spans.end() ; it_span++) { - FontMetrics span_height = it_span->start.iter_span->line_height; + for (const auto & broken_span : it_chunk->broken_spans) { + FontMetrics span_height = broken_span.start.iter_span->line_height; TRACE((" brokenspan line_height: %f\n", span_height.emSize() )); - span_height.computeEffective( it_span->start.iter_span->line_height_multiplier ); + span_height.computeEffective( broken_span.start.iter_span->line_height_multiplier ); line_height->max( span_height ); } } diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp index a20fdde53..b523649e7 100644 --- a/src/libnrtype/Layout-TNG-Input.cpp +++ b/src/libnrtype/Layout-TNG-Input.cpp @@ -30,8 +30,8 @@ namespace Text { void Layout::_clearInputObjects() { - for(std::vector::iterator it = _input_stream.begin() ; it != _input_stream.end() ; ++it) { - delete *it; + for(auto & it : _input_stream) { + delete it; } _input_stream.clear(); @@ -72,9 +72,9 @@ void Layout::appendText(Glib::ustring const &text, if (!optional_attributes->rotate.empty() && optional_attributes_offset >= optional_attributes->rotate.size()) { SVGLength last_rotate; last_rotate = 0.f; - for (std::vector::const_iterator it = optional_attributes->rotate.begin() ; it != optional_attributes->rotate.end() ; ++it) - if (it->_set) - last_rotate = *it; + for (auto it : optional_attributes->rotate) + if (it._set) + last_rotate = it; new_source->rotate.resize(1, last_rotate); } new_source->textLength._set = optional_attributes->textLength._set; diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp index d565bb923..77cedaa61 100644 --- a/src/libnrtype/Layout-TNG-OutIter.cpp +++ b/src/libnrtype/Layout-TNG-OutIter.cpp @@ -97,20 +97,20 @@ Layout::iterator Layout::getNearestCursorPositionTo(double x, double y) const local_y = x; } // stage 1: - for (unsigned span_index = 0 ; span_index < _spans.size() ; span_index++) { + for (const auto & _span : _spans) { double span_left, span_right; - if (_spans[span_index].x_start < _spans[span_index].x_end) { - span_left = _spans[span_index].x_start; - span_right = _spans[span_index].x_end; + if (_span.x_start < _span.x_end) { + span_left = _span.x_start; + span_right = _span.x_end; } else { - span_left = _spans[span_index].x_end; - span_right = _spans[span_index].x_start; + span_left = _span.x_end; + span_right = _span.x_start; } - if ( local_x >= _chunks[_spans[span_index].in_chunk].left_x + span_left - && local_x <= _chunks[_spans[span_index].in_chunk].left_x + span_right - && local_y >= _spans[span_index].line(this).baseline_y + _spans[span_index].baseline_shift - _spans[span_index].line_height.ascent - && local_y <= _spans[span_index].line(this).baseline_y + _spans[span_index].baseline_shift + _spans[span_index].line_height.descent) { - return _cursorXOnLineToIterator(_chunks[_spans[span_index].in_chunk].in_line, local_x); + if ( local_x >= _chunks[_span.in_chunk].left_x + span_left + && local_x <= _chunks[_span.in_chunk].left_x + span_right + && local_y >= _span.line(this).baseline_y + _span.baseline_shift - _span.line_height.ascent + && local_y <= _span.line(this).baseline_y + _span.baseline_shift + _span.line_height.descent) { + return _cursorXOnLineToIterator(_chunks[_span.in_chunk].in_line, local_x); } } diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 014c2c521..6ff52f2a7 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -91,8 +91,8 @@ void Layout::_clearOutputObjects() _paragraphs.clear(); _lines.clear(); _chunks.clear(); - for (std::vector::iterator it_span = _spans.begin() ; it_span != _spans.end() ; ++it_span) - if (it_span->font) it_span->font->Unref(); + for (auto & _span : _spans) + if (_span.font) _span.font->Unref(); _spans.clear(); _characters.clear(); _glyphs.clear(); @@ -755,10 +755,10 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path) Path::cut_position *end_otp = const_cast(path).CurvilignToPosition(1, &end_offset, unused); if (end_otp != nullptr && end_otp[0].piece >= 0) { bool on_same_subpath = true; - for (size_t i = 0 ; i < path.pts.size() ; i++) { - if (path.pts[i].piece <= start_otp[0].piece) continue; - if (path.pts[i].piece >= end_otp[0].piece) break; - if (path.pts[i].isMoveTo == polyline_moveto) { + for (const auto & pt : path.pts) { + if (pt.piece <= start_otp[0].piece) continue; + if (pt.piece >= end_otp[0].piece) break; + if (pt.isMoveTo == polyline_moveto) { on_same_subpath = false; break; } @@ -809,9 +809,9 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path) char_index = next_cluster_char_index; } - for (unsigned span_index = 0 ; span_index < _spans.size() ; span_index++) { - _spans[span_index].x_start += offset; - _spans[span_index].x_end += offset; + for (auto & _span : _spans) { + _span.x_start += offset; + _span.x_end += offset; } _path_fitted = &path; @@ -847,11 +847,11 @@ void Layout::transform(Geom::Affine const &transform) { // this is all massively oversimplified // I can't actually think of anybody who'll want to use it at the moment, so it'll stay simple - for (unsigned glyph_index = 0 ; glyph_index < _glyphs.size() ; glyph_index++) { - Geom::Point point(_glyphs[glyph_index].x, _glyphs[glyph_index].y); + for (auto & _glyph : _glyphs) { + Geom::Point point(_glyph.x, _glyph.y); point *= transform; - _glyphs[glyph_index].x = point[0]; - _glyphs[glyph_index].y = point[1]; + _glyph.x = point[0]; + _glyph.y = point[1]; } } diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 739b0b14b..9c9e07ad2 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -74,8 +74,8 @@ FontLister::FontLister() font_factory::Default()->GetUIFamilies(familyVector); // Traverse through the family names and set up the list store - for (size_t i = 0; i < familyVector.size(); ++i) { - const char* displayName = sp_font_family_get_name(familyVector[i]); + for (auto & i : familyVector) { + const char* displayName = sp_font_family_get_name(i); if (displayName == nullptr || *displayName == '\0') { continue; @@ -90,7 +90,7 @@ FontLister::FontLister() // ever decides to use this font (*treeModelIter)[FontList.styles] = NULL; // store the pango representation for generating the style - (*treeModelIter)[FontList.pango_family] = familyVector[i]; + (*treeModelIter)[FontList.pango_family] = i; (*treeModelIter)[FontList.onSystem] = true; } } @@ -1139,9 +1139,7 @@ void font_lister_cell_data_func2(GtkCellLayout * /*cell_layout*/, /* See if font-family on system */ std::vector tokens = Glib::Regex::split_simple("\\s*,\\s*", family); - for (size_t i = 0; i < tokens.size(); ++i) { - - Glib::ustring token = tokens[i]; + for (auto token : tokens) { GtkTreeIter iter; gboolean valid; diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index bc47efff0..f3be46578 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -58,15 +58,15 @@ void Inkscape::LineSnapper::freeSnap(IntermSnapResults &isr, // For this we need to know where the origin is located of the line that is currently being rotated, std::vector > const origins_and_vectors = p.getOriginsAndVectors(); // Now we will iterate over all the origins and vectors and see which of these will get use a tangential or perpendicular snap - for (std::vector >::const_iterator it_origin_or_vector = origins_and_vectors.begin(); it_origin_or_vector != origins_and_vectors.end(); ++it_origin_or_vector) { - if ((*it_origin_or_vector).second) { // if "second" is true then "first" is a vector, otherwise it's a point + for (const auto & origins_and_vector : origins_and_vectors) { + if (origins_and_vector.second) { // if "second" is true then "first" is a vector, otherwise it's a point // When snapping a line with a constant vector (constant direction) to a guide or grid line, // then either all points will be perpendicular/tangential or none at all. This is not very useful continue; } //Geom::Point origin_doc = _snapmanager->getDesktop()->dt2doc((*it_origin_or_vector).first); // "first" contains a Geom::Point, denoting either a point - Geom::Point origin = (*it_origin_or_vector).first; // "first" contains a Geom::Point, denoting either a point + Geom::Point origin = origins_and_vector.first; // "first" contains a Geom::Point, denoting either a point // We won't try to snap tangentially; a line being tangential to another line can be achieved by snapping both its endpoints // individually to the other line. There's no need to have an explicit tangential snap here, that would be redundant @@ -104,9 +104,9 @@ void Inkscape::LineSnapper::constrainedSnap(IntermSnapResults &isr, /* Get the lines that we will try to snap to */ const LineList lines = _getSnapLines(pp); - for (LineList::const_iterator i = lines.begin(); i != lines.end(); ++i) { + for (const auto & line : lines) { Geom::Point const point_on_line = c.hasPoint() ? c.getPoint() : pp; - Geom::Line gridguide_line(i->second, i->second + Geom::rot90(i->first)); + Geom::Line gridguide_line(line.second, line.second + Geom::rot90(line.first)); if (c.isCircular()) { // Find the intersections between the line and the circular constraint diff --git a/src/livarot/Path.cpp b/src/livarot/Path.cpp index c046a1af1..b0f19fddb 100644 --- a/src/livarot/Path.cpp +++ b/src/livarot/Path.cpp @@ -32,8 +32,8 @@ Path::Path() Path::~Path() { - for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) { - delete *i; + for (auto & i : descr_cmd) { + delete i; } } @@ -51,8 +51,8 @@ void Path::Affiche() void Path::Reset() { - for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) { - delete *i; + for (auto & i : descr_cmd) { + delete i; } descr_cmd.clear(); @@ -65,8 +65,8 @@ void Path::Copy(Path * who) { ResetPoints(); - for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) { - delete *i; + for (auto & i : descr_cmd) { + delete i; } descr_cmd.clear(); @@ -699,8 +699,8 @@ void Path::PointAndTangentAt(int piece, double at, Geom::Point &pos, Geom::Point void Path::Transform(const Geom::Affine &trans) { - for (std::vector::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) { - (*i)->transform(trans); + for (auto & i : descr_cmd) { + i->transform(trans); } } @@ -710,12 +710,12 @@ void Path::FastBBox(double &l,double &t,double &r,double &b) bool empty = true; Geom::Point lastP(0, 0); - for (int i = 0; i < int(descr_cmd.size()); i++) { - int const typ = descr_cmd[i]->getType(); + for (auto & i : descr_cmd) { + int const typ = i->getType(); switch ( typ ) { case descr_lineto: { - PathDescrLineTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrLineTo *nData = dynamic_cast(i); if ( empty ) { l = r = nData->p[Geom::X]; t = b = nData->p[Geom::Y]; @@ -740,7 +740,7 @@ void Path::FastBBox(double &l,double &t,double &r,double &b) case descr_moveto: { - PathDescrMoveTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrMoveTo *nData = dynamic_cast(i); if ( empty ) { l = r = nData->p[Geom::X]; t = b = nData->p[Geom::Y]; @@ -765,7 +765,7 @@ void Path::FastBBox(double &l,double &t,double &r,double &b) case descr_arcto: { - PathDescrArcTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrArcTo *nData = dynamic_cast(i); if ( empty ) { l = r = nData->p[Geom::X]; t = b = nData->p[Geom::Y]; @@ -790,7 +790,7 @@ void Path::FastBBox(double &l,double &t,double &r,double &b) case descr_cubicto: { - PathDescrCubicTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrCubicTo *nData = dynamic_cast(i); if ( empty ) { l = r = nData->p[Geom::X]; t = b = nData->p[Geom::Y]; @@ -853,7 +853,7 @@ bezier-paths used by True-Type fonts." case descr_bezierto: { - PathDescrBezierTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrBezierTo *nData = dynamic_cast(i); if ( empty ) { l = r = nData->p[Geom::X]; t = b = nData->p[Geom::Y]; @@ -878,7 +878,7 @@ bezier-paths used by True-Type fonts." case descr_interm_bezier: { - PathDescrIntermBezierTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrIntermBezierTo *nData = dynamic_cast(i); if ( empty ) { l = r = nData->p[Geom::X]; t = b = nData->p[Geom::Y]; diff --git a/src/livarot/PathConversion.cpp b/src/livarot/PathConversion.cpp index 88a8c5660..dfea8755d 100644 --- a/src/livarot/PathConversion.cpp +++ b/src/livarot/PathConversion.cpp @@ -1297,8 +1297,8 @@ void Path::Fill(Shape* dest, int pathID, bool justAdd, bool closeIfNeeded, bool if ( back ) { { // invert && back && !weighted - for (int i = 0; i < int(pts.size()); i++) { - dest->AddPoint(pts[i].p); + for (auto & pt : pts) { + dest->AddPoint(pt.p); } int lastM = 0; int curP = 1; @@ -1381,8 +1381,8 @@ void Path::Fill(Shape* dest, int pathID, bool justAdd, bool closeIfNeeded, bool { // invert && !back && !weighted - for (int i = 0; i < int(pts.size()); i++) { - dest->AddPoint(pts[i].p); + for (auto & pt : pts) { + dest->AddPoint(pt.p); } int lastM = 0; int curP = 1; @@ -1437,8 +1437,8 @@ void Path::Fill(Shape* dest, int pathID, bool justAdd, bool closeIfNeeded, bool if ( back ) { { // !invert && back && !weighted - for (int i = 0; i < int(pts.size()); i++) { - dest->AddPoint(pts[i].p); + for (auto & pt : pts) { + dest->AddPoint(pt.p); } int lastM = 0; @@ -1512,8 +1512,8 @@ void Path::Fill(Shape* dest, int pathID, bool justAdd, bool closeIfNeeded, bool } else { { // !invert && !back && !weighted - for (int i = 0;i < int(pts.size()); i++) { - dest->AddPoint(pts[i].p); + for (auto & pt : pts) { + dest->AddPoint(pt.p); } int lastM = 0; diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index baf9bd71d..34263bc58 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -63,8 +63,8 @@ void Path::DashPolylineFromStyle(SPStyle *style, float scale, float min_len) double dlen = 0.0; // Find total length - for (unsigned i = 0; i < style->stroke_dasharray.values.size(); i++) { - dlen += style->stroke_dasharray.values[i].value * scale; + for (auto & value : style->stroke_dasharray.values) { + dlen += value.value * scale; } if (dlen >= min_len) { // Extract out dash pattern (relative positions) @@ -411,8 +411,8 @@ void Path::AddCurve(Geom::Curve const &c) Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c.toSBasis(), 0.1); //recurse to convert the new path resulting from the sbasis to svgd - for(Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) { - AddCurve(*iter); + for(const auto & iter : sbasis_path) { + AddCurve(iter); } } } @@ -435,8 +435,8 @@ void Path::LoadPath(Geom::Path const &path, Geom::Affine const &tr, bool doTran MoveTo( pathtr.initialPoint() ); - for(Geom::Path::const_iterator cit = pathtr.begin(); cit != pathtr.end(); ++cit) { - AddCurve(*cit); + for(const auto & cit : pathtr) { + AddCurve(cit); } if (pathtr.closed()) { @@ -463,8 +463,8 @@ void Path::LoadPathVector(Geom::PathVector const &pv, Geom::Affine const &tr, b LoadPath(*it, tr, doTransformation, true); } } else { - for(Geom::PathVector::const_iterator it = pv.begin(); it != pv.end(); ++it) { - LoadPath(*it, tr, doTransformation, true); + for(const auto & it : pv) { + LoadPath(it, tr, doTransformation, true); } } } @@ -527,8 +527,8 @@ Path** Path::SubPaths(int &outNb,bool killNoSurf) Path** res=nullptr; Path* curAdd=nullptr; - for (int i=0;igetType(); + for (auto & i : descr_cmd) { + int const typ = i->getType(); switch ( typ ) { case descr_moveto: if ( curAdd ) { @@ -549,7 +549,7 @@ Path** Path::SubPaths(int &outNb,bool killNoSurf) curAdd=new Path; curAdd->SetBackData(false); { - PathDescrMoveTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrMoveTo *nData = dynamic_cast(i); curAdd->MoveTo(nData->p); } break; @@ -560,31 +560,31 @@ Path** Path::SubPaths(int &outNb,bool killNoSurf) break; case descr_lineto: { - PathDescrLineTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrLineTo *nData = dynamic_cast(i); curAdd->LineTo(nData->p); } break; case descr_cubicto: { - PathDescrCubicTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrCubicTo *nData = dynamic_cast(i); curAdd->CubicTo(nData->p,nData->start,nData->end); } break; case descr_arcto: { - PathDescrArcTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrArcTo *nData = dynamic_cast(i); curAdd->ArcTo(nData->p,nData->rx,nData->ry,nData->angle,nData->large,nData->clockwise); } break; case descr_bezierto: { - PathDescrBezierTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrBezierTo *nData = dynamic_cast(i); curAdd->BezierTo(nData->p); } break; case descr_interm_bezier: { - PathDescrIntermBezierTo *nData = dynamic_cast(descr_cmd[i]); + PathDescrIntermBezierTo *nData = dynamic_cast(i); curAdd->IntermBezierTo(nData->p); } break; diff --git a/src/livarot/ShapeRaster.cpp b/src/livarot/ShapeRaster.cpp index 292b0a7f1..7aa300ed0 100644 --- a/src/livarot/ShapeRaster.cpp +++ b/src/livarot/ShapeRaster.cpp @@ -1978,8 +1978,7 @@ void Shape::_countUpDownTotalDegree2(int P, *upEdge = -1; *downEdge = -1; - for (int i = 0; i < 2; i++) { - int const j = getPoint(P).incidentEdge[i]; + for (int j : getPoint(P).incidentEdge) { Shape::dg_arete const &e = getEdge(j); if ( P == std::max(e.st, e.en) ) { *upEdge = j; diff --git a/src/livarot/ShapeSweep.cpp b/src/livarot/ShapeSweep.cpp index df78195cc..3b5ed72ec 100644 --- a/src/livarot/ShapeSweep.cpp +++ b/src/livarot/ShapeSweep.cpp @@ -277,35 +277,35 @@ Shape::ConvertToShape (Shape * a, FillRule directed, bool invert) curSh = neSh; } - for (unsigned int i = 0; i < chgts.size(); i++) + for (auto & chgt : chgts) { - chgts[i].ptNo = pData[chgts[i].ptNo].newInd; - if (chgts[i].type == 0) + chgt.ptNo = pData[chgt.ptNo].newInd; + if (chgt.type == 0) { - if (chgts[i].src->getEdge(chgts[i].bord).st < - chgts[i].src->getEdge(chgts[i].bord).en) + if (chgt.src->getEdge(chgt.bord).st < + chgt.src->getEdge(chgt.bord).en) { - chgts[i].src->swsData[chgts[i].bord].stPt = - chgts[i].ptNo; + chgt.src->swsData[chgt.bord].stPt = + chgt.ptNo; } else { - chgts[i].src->swsData[chgts[i].bord].enPt = - chgts[i].ptNo; + chgt.src->swsData[chgt.bord].enPt = + chgt.ptNo; } } - else if (chgts[i].type == 1) + else if (chgt.type == 1) { - if (chgts[i].src->getEdge(chgts[i].bord).st > - chgts[i].src->getEdge(chgts[i].bord).en) + if (chgt.src->getEdge(chgt.bord).st > + chgt.src->getEdge(chgt.bord).en) { - chgts[i].src->swsData[chgts[i].bord].stPt = - chgts[i].ptNo; + chgt.src->swsData[chgt.bord].stPt = + chgt.ptNo; } else { - chgts[i].src->swsData[chgts[i].bord].enPt = - chgts[i].ptNo; + chgt.src->swsData[chgt.bord].enPt = + chgt.ptNo; } } } @@ -590,31 +590,31 @@ Shape::ConvertToShape (Shape * a, FillRule directed, bool invert) curSh = neSh; } - for (unsigned int i = 0; i < chgts.size(); i++) + for (auto & chgt : chgts) { - chgts[i].ptNo = pData[chgts[i].ptNo].newInd; - if (chgts[i].type == 0) + chgt.ptNo = pData[chgt.ptNo].newInd; + if (chgt.type == 0) { - if (chgts[i].src->getEdge(chgts[i].bord).st < - chgts[i].src->getEdge(chgts[i].bord).en) + if (chgt.src->getEdge(chgt.bord).st < + chgt.src->getEdge(chgt.bord).en) { - chgts[i].src->swsData[chgts[i].bord].stPt = chgts[i].ptNo; + chgt.src->swsData[chgt.bord].stPt = chgt.ptNo; } else { - chgts[i].src->swsData[chgts[i].bord].enPt = chgts[i].ptNo; + chgt.src->swsData[chgt.bord].enPt = chgt.ptNo; } } - else if (chgts[i].type == 1) + else if (chgt.type == 1) { - if (chgts[i].src->getEdge(chgts[i].bord).st > - chgts[i].src->getEdge(chgts[i].bord).en) + if (chgt.src->getEdge(chgt.bord).st > + chgt.src->getEdge(chgt.bord).en) { - chgts[i].src->swsData[chgts[i].bord].stPt = chgts[i].ptNo; + chgt.src->swsData[chgt.bord].stPt = chgt.ptNo; } else { - chgts[i].src->swsData[chgts[i].bord].enPt = chgts[i].ptNo; + chgt.src->swsData[chgt.bord].enPt = chgt.ptNo; } } } @@ -1078,35 +1078,35 @@ Shape::Booleen (Shape * a, Shape * b, BooleanOp mod,int cutPathID) curSh = neSh; } - for (unsigned int i = 0; i < chgts.size(); i++) + for (auto & chgt : chgts) { - chgts[i].ptNo = pData[chgts[i].ptNo].newInd; - if (chgts[i].type == 0) + chgt.ptNo = pData[chgt.ptNo].newInd; + if (chgt.type == 0) { - if (chgts[i].src->getEdge(chgts[i].bord).st < - chgts[i].src->getEdge(chgts[i].bord).en) + if (chgt.src->getEdge(chgt.bord).st < + chgt.src->getEdge(chgt.bord).en) { - chgts[i].src->swsData[chgts[i].bord].stPt = - chgts[i].ptNo; + chgt.src->swsData[chgt.bord].stPt = + chgt.ptNo; } else { - chgts[i].src->swsData[chgts[i].bord].enPt = - chgts[i].ptNo; + chgt.src->swsData[chgt.bord].enPt = + chgt.ptNo; } } - else if (chgts[i].type == 1) + else if (chgt.type == 1) { - if (chgts[i].src->getEdge(chgts[i].bord).st > - chgts[i].src->getEdge(chgts[i].bord).en) + if (chgt.src->getEdge(chgt.bord).st > + chgt.src->getEdge(chgt.bord).en) { - chgts[i].src->swsData[chgts[i].bord].stPt = - chgts[i].ptNo; + chgt.src->swsData[chgt.bord].stPt = + chgt.ptNo; } else { - chgts[i].src->swsData[chgts[i].bord].enPt = - chgts[i].ptNo; + chgt.src->swsData[chgt.bord].enPt = + chgt.ptNo; } } } @@ -1408,31 +1408,31 @@ Shape::Booleen (Shape * a, Shape * b, BooleanOp mod,int cutPathID) } /* FIXME: this kind of code seems to appear frequently */ - for (unsigned int i = 0; i < chgts.size(); i++) + for (auto & chgt : chgts) { - chgts[i].ptNo = pData[chgts[i].ptNo].newInd; - if (chgts[i].type == 0) + chgt.ptNo = pData[chgt.ptNo].newInd; + if (chgt.type == 0) { - if (chgts[i].src->getEdge(chgts[i].bord).st < - chgts[i].src->getEdge(chgts[i].bord).en) + if (chgt.src->getEdge(chgt.bord).st < + chgt.src->getEdge(chgt.bord).en) { - chgts[i].src->swsData[chgts[i].bord].stPt = chgts[i].ptNo; + chgt.src->swsData[chgt.bord].stPt = chgt.ptNo; } else { - chgts[i].src->swsData[chgts[i].bord].enPt = chgts[i].ptNo; + chgt.src->swsData[chgt.bord].enPt = chgt.ptNo; } } - else if (chgts[i].type == 1) + else if (chgt.type == 1) { - if (chgts[i].src->getEdge(chgts[i].bord).st > - chgts[i].src->getEdge(chgts[i].bord).en) + if (chgt.src->getEdge(chgt.bord).st > + chgt.src->getEdge(chgt.bord).en) { - chgts[i].src->swsData[chgts[i].bord].stPt = chgts[i].ptNo; + chgt.src->swsData[chgt.bord].stPt = chgt.ptNo; } else { - chgts[i].src->swsData[chgts[i].bord].enPt = chgts[i].ptNo; + chgt.src->swsData[chgt.bord].enPt = chgt.ptNo; } } } @@ -2724,14 +2724,14 @@ void Shape::CheckAdjacencies (int lastPointNo, int lastChgtPt, Shape * /*shapeHead*/, int /*edgeHead*/) { - for (unsigned int cCh = 0; cCh < chgts.size(); cCh++) + for (auto & chgt : chgts) { - int chLeN = chgts[cCh].ptNo; - int chRiN = chgts[cCh].ptNo; - if (chgts[cCh].src) + int chLeN = chgt.ptNo; + int chRiN = chgt.ptNo; + if (chgt.src) { - Shape *lS = chgts[cCh].src; - int lB = chgts[cCh].bord; + Shape *lS = chgt.src; + int lB = chgt.bord; int lftN = lS->swsData[lB].leftRnd; int rgtN = lS->swsData[lB].rightRnd; if (lftN < chLeN) @@ -2754,10 +2754,10 @@ Shape::CheckAdjacencies (int lastPointNo, int lastChgtPt, Shape * /*shapeHead*/, lS->swsData[lB].rightRnd = n; } } - if (chgts[cCh].osrc) + if (chgt.osrc) { - Shape *rS = chgts[cCh].osrc; - int rB = chgts[cCh].obord; + Shape *rS = chgt.osrc; + int rB = chgt.obord; int lftN = rS->swsData[rB].leftRnd; int rgtN = rS->swsData[rB].rightRnd; if (lftN < chLeN) @@ -2780,12 +2780,12 @@ Shape::CheckAdjacencies (int lastPointNo, int lastChgtPt, Shape * /*shapeHead*/, rS->swsData[rB].rightRnd = n; } } - if (chgts[cCh].lSrc) + if (chgt.lSrc) { - if (chgts[cCh].lSrc->swsData[chgts[cCh].lBrd].leftRnd < lastChgtPt) + if (chgt.lSrc->swsData[chgt.lBrd].leftRnd < lastChgtPt) { - Shape *nSrc = chgts[cCh].lSrc; - int nBrd = chgts[cCh].lBrd /*,nNo=chgts[cCh].ptNo */ ; + Shape *nSrc = chgt.lSrc; + int nBrd = chgt.lBrd /*,nNo=chgts[cCh].ptNo */ ; bool hit; do @@ -2849,12 +2849,12 @@ Shape::CheckAdjacencies (int lastPointNo, int lastChgtPt, Shape * /*shapeHead*/, } } - if (chgts[cCh].rSrc) + if (chgt.rSrc) { - if (chgts[cCh].rSrc->swsData[chgts[cCh].rBrd].leftRnd < lastChgtPt) + if (chgt.rSrc->swsData[chgt.rBrd].leftRnd < lastChgtPt) { - Shape *nSrc = chgts[cCh].rSrc; - int nBrd = chgts[cCh].rBrd /*,nNo=chgts[cCh].ptNo */ ; + Shape *nSrc = chgt.rSrc; + int nBrd = chgt.rBrd /*,nNo=chgts[cCh].ptNo */ ; bool hit; do { @@ -3043,35 +3043,35 @@ Shape::CheckEdges (int lastPointNo, int lastChgtPt, Shape * a, Shape * b, BooleanOp mod) { - for (unsigned int cCh = 0; cCh < chgts.size(); cCh++) + for (auto & chgt : chgts) { - if (chgts[cCh].type == 0) + if (chgt.type == 0) { - Shape *lS = chgts[cCh].src; - int lB = chgts[cCh].bord; - lS->swsData[lB].curPoint = chgts[cCh].ptNo; + Shape *lS = chgt.src; + int lB = chgt.bord; + lS->swsData[lB].curPoint = chgt.ptNo; } } - for (unsigned int cCh = 0; cCh < chgts.size(); cCh++) + for (auto & chgt : chgts) { // int chLeN=chgts[cCh].ptNo; // int chRiN=chgts[cCh].ptNo; - if (chgts[cCh].src) + if (chgt.src) { - Shape *lS = chgts[cCh].src; - int lB = chgts[cCh].bord; + Shape *lS = chgt.src; + int lB = chgt.bord; Avance (lastPointNo, lastChgtPt, lS, lB, a, b, mod); } - if (chgts[cCh].osrc) + if (chgt.osrc) { - Shape *rS = chgts[cCh].osrc; - int rB = chgts[cCh].obord; + Shape *rS = chgt.osrc; + int rB = chgt.obord; Avance (lastPointNo, lastChgtPt, rS, rB, a, b, mod); } - if (chgts[cCh].lSrc) + if (chgt.lSrc) { - Shape *nSrc = chgts[cCh].lSrc; - int nBrd = chgts[cCh].lBrd; + Shape *nSrc = chgt.lSrc; + int nBrd = chgt.lBrd; while (nSrc->swsData[nBrd].leftRnd >= lastChgtPt /*&& nSrc->swsData[nBrd].doneTo < lastChgtPt */ ) { @@ -3088,10 +3088,10 @@ Shape::CheckEdges (int lastPointNo, int lastChgtPt, Shape * a, Shape * b, nBrd = node->bord; } } - if (chgts[cCh].rSrc) + if (chgt.rSrc) { - Shape *nSrc = chgts[cCh].rSrc; - int nBrd = chgts[cCh].rBrd; + Shape *nSrc = chgt.rSrc; + int nBrd = chgt.rBrd; while (nSrc->swsData[nBrd].rightRnd >= lastChgtPt /*&& nSrc->swsData[nBrd].doneTo < lastChgtPt */ ) { diff --git a/src/livarot/float-line.cpp b/src/livarot/float-line.cpp index 6a5e4f931..9a19729cf 100644 --- a/src/livarot/float-line.cpp +++ b/src/livarot/float-line.cpp @@ -546,16 +546,16 @@ void FloatLigne::Flatten() void FloatLigne::Affiche() { printf("%lu : \n", (long unsigned int) bords.size()); - for (int i = 0; i < int(bords.size()); i++) { - printf("(%f %f %f %i) ",bords[i].pos,bords[i].val,bords[i].pente,(bords[i].start?1:0)); // localization ok + for (auto & bord : bords) { + printf("(%f %f %f %i) ",bord.pos,bord.val,bord.pente,(bord.start?1:0)); // localization ok } printf("\n"); printf("%lu : \n", (long unsigned int) runs.size()); - for (int i = 0; i < int(runs.size()); i++) { + for (auto & run : runs) { printf("(%f %f -> %f %f / %f)", - runs[i].st, runs[i].vst, runs[i].en, runs[i].ven, runs[i].pente); // localization ok + run.st, run.vst, run.en, run.ven, run.pente); // localization ok } printf("\n"); @@ -627,8 +627,7 @@ void FloatLigne::Min(FloatLigne *a, float tresh, bool addIt) float lastStart=0; float lastEnd = 0; - for (int i = 0; i < int(a->runs.size()); i++) { - float_ligne_run runA = a->runs[i]; + for (auto runA : a->runs) { if ( runA.vst <= tresh ) { if ( runA.ven <= tresh ) { if ( startExists ) { @@ -717,8 +716,7 @@ void FloatLigne::Split(FloatLigne *a, float tresh, FloatLigne *over) return; } - for (int i = 0; i < int(a->runs.size()); i++) { - float_ligne_run runA = a->runs[i]; + for (auto runA : a->runs) { if ( runA.vst >= tresh ) { if ( runA.ven >= tresh ) { if ( over ) { @@ -761,8 +759,7 @@ void FloatLigne::Max(FloatLigne *a, float tresh, bool addIt) bool startExists = false; float lastStart = 0; float lastEnd = 0; - for (int i = 0; i < int(a->runs.size()); i++) { - float_ligne_run runA = a->runs[i]; + for (auto runA : a->runs) { if ( runA.vst >= tresh ) { if ( runA.ven >= tresh ) { if ( startExists ) { @@ -850,8 +847,7 @@ void FloatLigne::Over(FloatLigne *a, float tresh) float lastStart = 0; float lastEnd = 0; - for (int i = 0; i < int(a->runs.size()); i++) { - float_ligne_run runA = a->runs[i]; + for (auto runA : a->runs) { if ( runA.vst >= tresh ) { if ( runA.ven >= tresh ) { if ( startExists ) { diff --git a/src/livarot/int-line.cpp b/src/livarot/int-line.cpp index c37e28cfd..ff874752d 100644 --- a/src/livarot/int-line.cpp +++ b/src/livarot/int-line.cpp @@ -830,8 +830,8 @@ void IntLigne::Copy(FloatLigne* a) // since the float_ligne_runs are non-overlapping, when a single-pixel run intersects with another runs, // it must intersect with the single-pixel run created for the end of that run. so instead of creating a new // int_ligne_run, we just add the coverage to that run. - for (int i = 0; i < int(a->runs.size()); i++) { - float_ligne_run runA = a->runs[i]; + for (auto & run : a->runs) { + float_ligne_run runA = run; float curStF = floor(runA.st); float curEnF = floor(runA.en); int curSt = (int) curStF; @@ -886,42 +886,42 @@ void IntLigne::Copy(FloatLigne* a) if ( pixExists ) { if ( curPos < curSt ) { AddRun(curPos,curPos+1,lastSurf,lastSurf); - lastSurf=0.5*(msv+a->runs[i].vst)*(miStF-a->runs[i].st); + lastSurf=0.5*(msv+run.vst)*(miStF-run.st); AddRun(curSt,curSt+1,lastSurf,lastSurf); } else { - lastSurf+=0.5*(msv+a->runs[i].vst)*(miStF-a->runs[i].st); + lastSurf+=0.5*(msv+run.vst)*(miStF-run.st); AddRun(curSt,curSt+1,lastSurf,lastSurf); } pixExists=false; } else { - lastSurf=0.5*(msv+a->runs[i].vst)*(miStF-a->runs[i].st); + lastSurf=0.5*(msv+run.vst)*(miStF-run.st); AddRun(curSt,curSt+1,lastSurf,lastSurf); } } else if ( pixExists ) { if ( curPos < curSt ) { AddRun(curPos,curPos+1,lastSurf,lastSurf); - lastSurf=0.5*(a->runs[i].ven+a->runs[i].vst)*(a->runs[i].en-a->runs[i].st); + lastSurf=0.5*(run.ven+run.vst)*(run.en-run.st); curPos=curSt; } else { - lastSurf += 0.5 * (a->runs[i].ven+a->runs[i].vst)*(a->runs[i].en-a->runs[i].st); + lastSurf += 0.5 * (run.ven+run.vst)*(run.en-run.st); } } else { - lastSurf=0.5*(a->runs[i].ven+a->runs[i].vst)*(a->runs[i].en-a->runs[i].st); + lastSurf=0.5*(run.ven+run.vst)*(run.en-run.st); curPos=curSt; pixExists=true; } } else if ( pixExists ) { if ( curPos < curSt ) { AddRun(curPos,curPos+1,lastSurf,lastSurf); - lastSurf = 0.5 * (msv+a->runs[i].vst) * (miStF-a->runs[i].st); + lastSurf = 0.5 * (msv+run.vst) * (miStF-run.st); AddRun(curSt,curSt+1,lastSurf,lastSurf); } else { - lastSurf += 0.5 * (msv+a->runs[i].vst) * (miStF-a->runs[i].st); + lastSurf += 0.5 * (msv+run.vst) * (miStF-run.st); AddRun(curSt,curSt+1,lastSurf,lastSurf); } pixExists=false; } else { - lastSurf = 0.5 * (msv+a->runs[i].vst) * (miStF-a->runs[i].st); + lastSurf = 0.5 * (msv+run.vst) * (miStF-run.st); AddRun(curSt,curSt+1,lastSurf,lastSurf); } if ( miEx ) { @@ -933,14 +933,14 @@ void IntLigne::Copy(FloatLigne* a) } if ( enEx ) { if ( curEn > curSt ) { - lastSurf=0.5*(mev+a->runs[i].ven)*(a->runs[i].en-curEnF); + lastSurf=0.5*(mev+run.ven)*(run.en-curEnF); pixExists=true; curPos=curEn; } else if ( ! stEx ) { if ( pixExists ) { AddRun(curPos,curPos+1,lastSurf,lastSurf); } - lastSurf=0.5*(mev+a->runs[i].ven)*(a->runs[i].en-curEnF); + lastSurf=0.5*(mev+run.ven)*(run.en-curEnF); pixExists=true; curPos=curEn; } diff --git a/src/livarot/sweep-event.cpp b/src/livarot/sweep-event.cpp index db08bb2fa..bb9e4e7fc 100644 --- a/src/livarot/sweep-event.cpp +++ b/src/livarot/sweep-event.cpp @@ -38,9 +38,9 @@ SweepEvent *SweepEventQueue::add(SweepTree *iLeft, SweepTree *iRight, Geom::Poin events[n].MakeNew (iLeft, iRight, px, itl, itr); SweepTree *t[2] = { iLeft, iRight }; - for (int i = 0; i < 2; i++) { - Shape *s = t[i]->src; - Shape::dg_arete const &e = s->getEdge(t[i]->bord); + for (auto & i : t) { + Shape *s = i->src; + Shape::dg_arete const &e = s->getEdge(i->bord); int const n = std::max(e.st, e.en); s->pData[n].pending++;; } diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index d55f777e5..92f5a781a 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -446,9 +446,7 @@ Effect::isNodePointSelected(Geom::Point const &nodePoint) const if (selectedNodesPoints.size() > 0) { using Geom::X; using Geom::Y; - for (std::vector::const_iterator i = selectedNodesPoints.begin(); - i != selectedNodesPoints.end(); ++i) { - Geom::Point p = *i; + for (auto p : selectedNodesPoints) { Geom::Affine transformCoordinate = sp_lpe_item->i2dt_affine(); Geom::Point p2(nodePoint[X],nodePoint[Y]); p2 *= transformCoordinate; @@ -467,9 +465,7 @@ Effect::processObjects(LPEAction lpe_action) if (!document) { return; } - for (std::vector::iterator el_it = items.begin(); - el_it != items.end(); ++el_it) { - Glib::ustring id = *el_it; + for (auto id : items) { if (id.empty()) { return; } @@ -621,20 +617,20 @@ Effect::doEffect_path (Geom::PathVector const & path_in) if ( !concatenate_before_pwd2 ) { // default behavior - for (unsigned int i=0; i < path_in.size(); i++) { - Geom::Piecewise > pwd2_in = path_in[i].toPwSb(); + for (const auto & i : path_in) { + Geom::Piecewise > pwd2_in = i.toPwSb(); Geom::Piecewise > pwd2_out = doEffect_pwd2(pwd2_in); Geom::PathVector path = Geom::path_from_piecewise( pwd2_out, LPE_CONVERSION_TOLERANCE); // add the output path vector to the already accumulated vector: - for (unsigned int j=0; j < path.size(); j++) { - path_out.push_back(path[j]); + for (const auto & j : path) { + path_out.push_back(j); } } } else { // concatenate the path into possibly discontinuous pwd2 Geom::Piecewise > pwd2_in; - for (unsigned int i=0; i < path_in.size(); i++) { - pwd2_in.concat( path_in[i].toPwSb() ); + for (const auto & i : path_in) { + pwd2_in.concat( i.toPwSb() ); } Geom::Piecewise > pwd2_out = doEffect_pwd2(pwd2_in); path_out = Geom::path_from_piecewise( pwd2_out, LPE_CONVERSION_TOLERANCE); @@ -716,8 +712,8 @@ Effect::addHandles(KnotHolder *knotholder, SPItem *item) { addKnotHolderEntities(knotholder, item); // add handles provided by the effect's parameters (if any) - for (std::vector::iterator p = param_vector.begin(); p != param_vector.end(); ++p) { - (*p)->addKnotHolderEntities(knotholder, item); + for (auto & p : param_vector) { + p->addKnotHolderEntities(knotholder, item); } } @@ -736,8 +732,8 @@ Effect::getCanvasIndicators(SPLPEItem const* lpeitem) addCanvasIndicators(lpeitem, hp_vec); // add indicators provided by the effect's parameters - for (std::vector::iterator p = param_vector.begin(); p != param_vector.end(); ++p) { - (*p)->addCanvasIndicators(lpeitem, hp_vec); + for (auto & p : param_vector) { + p->addCanvasIndicators(lpeitem, hp_vec); } return hp_vec; @@ -1006,8 +1002,8 @@ Effect::providesKnotholder() const } // otherwise: are there any parameters that have knotholderentities? - for (std::vector::const_iterator p = param_vector.begin(); p != param_vector.end(); ++p) { - if ((*p)->providesKnotHolderEntities()) { + for (auto p : param_vector) { + if (p->providesKnotHolderEntities()) { return true; } } diff --git a/src/live_effects/lpe-bool.cpp b/src/live_effects/lpe-bool.cpp index 6ff27b0aa..7644f3b8e 100644 --- a/src/live_effects/lpe-bool.cpp +++ b/src/live_effects/lpe-bool.cpp @@ -254,11 +254,11 @@ sp_pathvector_boolop_slice_intersect(Geom::PathVector const &pathva, Geom::PathV // Create an array of bools which states which pieces are in std::vector inside_flags(result_path->descr_cmd.size(), false); - for (std::vector::iterator itPiece = inside_pieces.begin(); itPiece != inside_pieces.end(); ++itPiece) { - inside_flags[ itPiece->piece ] = true; + for (auto & inside_piece : inside_pieces) { + inside_flags[ inside_piece.piece ] = true; // also enable the element -1 to get the MoveTo - if (itPiece->piece >= 1) { - inside_flags[ itPiece->piece - 1 ] = true; + if (inside_piece.piece >= 1) { + inside_flags[ inside_piece.piece - 1 ] = true; } } diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index e6d4315e3..a3f8dbc30 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -189,17 +189,16 @@ void sp_bspline_do_effect(SPCurve *curve, double helper_size) Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); - path_it != original_pathv.end(); ++path_it) { - if (path_it->empty()) { + for (const auto & path_it : original_pathv) { + if (path_it.empty()) { continue; } if (!prefs->getBool("/tools/nodes/show_outline", true)){ - hp.push_back(*path_it); + hp.push_back(path_it); } - Geom::Path::const_iterator curve_it1 = path_it->begin(); - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); - Geom::Path::const_iterator curve_endit = path_it->end_default(); + Geom::Path::const_iterator curve_it1 = path_it.begin(); + Geom::Path::const_iterator curve_it2 = ++(path_it.begin()); + Geom::Path::const_iterator curve_endit = path_it.end_default(); SPCurve *curve_n = new SPCurve(); Geom::Point previousNode(0, 0); Geom::Point node(0, 0); @@ -211,8 +210,8 @@ void sp_bspline_do_effect(SPCurve *curve, double helper_size) Geom::D2 sbasis_helper; Geom::CubicBezier const *cubic = nullptr; curve_n->moveto(curve_it1->initialPoint()); - if (path_it->closed()) { - const Geom::Curve &closingline = path_it->back_closed(); + if (path_it.closed()) { + const Geom::Curve &closingline = path_it.back_closed(); // the closing line segment is always of type // Geom::LineSegment. if (are_near(closingline.initialPoint(), closingline.finalPoint())) { @@ -220,7 +219,7 @@ void sp_bspline_do_effect(SPCurve *curve, double helper_size) // *exact* zero length, which goes wrong for relative coordinates and // rounding errors... // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); + curve_endit = path_it.end_open(); } } while (curve_it1 != curve_endit) { @@ -264,13 +263,13 @@ void sp_bspline_do_effect(SPCurve *curve, double helper_size) out->reset(); delete out; } - if (path_it->closed() && curve_it2 == curve_endit) { + if (path_it.closed() && curve_it2 == curve_endit) { SPCurve *start = new SPCurve(); - start->moveto(path_it->begin()->initialPoint()); - start->lineto(path_it->begin()->finalPoint()); + start->moveto(path_it.begin()->initialPoint()); + start->lineto(path_it.begin()->finalPoint()); Geom::D2 sbasis_start = start->first_segment()->toSBasis(); SPCurve *line_helper = new SPCurve(); - cubic = dynamic_cast(&*path_it->begin()); + cubic = dynamic_cast(&*path_it.begin()); if (cubic) { line_helper->moveto(sbasis_start.valueAt( Geom::nearest_time((*cubic)[1], *start->first_segment()))); @@ -301,7 +300,7 @@ void sp_bspline_do_effect(SPCurve *curve, double helper_size) curve_n->move_endpoints(node, node); } else if ( curve_it2 == curve_endit) { curve_n->curveto(point_at1, point_at2, curve_it1->finalPoint()); - curve_n->move_endpoints(path_it->begin()->initialPoint(), curve_it1->finalPoint()); + curve_n->move_endpoints(path_it.begin()->initialPoint(), curve_it1->finalPoint()); } else { SPCurve *line_helper = new SPCurve(); line_helper->moveto(point_at2); @@ -323,7 +322,7 @@ void sp_bspline_do_effect(SPCurve *curve, double helper_size) ++curve_it1; ++curve_it2; } - if (path_it->closed()) { + if (path_it.closed()) { curve_n->closepath_current(); } curve->append(curve_n, false); @@ -359,15 +358,14 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount) Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); - for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); - path_it != original_pathv.end(); ++path_it) { + for (const auto & path_it : original_pathv) { - if (path_it->empty()) { + if (path_it.empty()) { continue; } - Geom::Path::const_iterator curve_it1 = path_it->begin(); - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); - Geom::Path::const_iterator curve_endit = path_it->end_default(); + Geom::Path::const_iterator curve_it1 = path_it.begin(); + Geom::Path::const_iterator curve_it2 = ++(path_it.begin()); + Geom::Path::const_iterator curve_endit = path_it.end_default(); SPCurve *curve_n = new SPCurve(); Geom::Point point_at0(0, 0); @@ -378,8 +376,8 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount) Geom::D2 sbasis_out; Geom::CubicBezier const *cubic = nullptr; curve_n->moveto(curve_it1->initialPoint()); - if (path_it->closed()) { - const Geom::Curve &closingline = path_it->back_closed(); + if (path_it.closed()) { + const Geom::Curve &closingline = path_it.back_closed(); // the closing line segment is always of type // Geom::LineSegment. if (are_near(closingline.initialPoint(), closingline.finalPoint())) { @@ -387,7 +385,7 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount) // *exact* zero length, which goes wrong for relative coordinates and // rounding errors... // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); + curve_endit = path_it.end_open(); } } while (curve_it1 != curve_endit) { @@ -461,13 +459,13 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount) ++curve_it1; ++curve_it2; } - if (path_it->closed()) { - curve_n->move_endpoints(path_it->begin()->initialPoint(), - path_it->begin()->initialPoint()); + if (path_it.closed()) { + curve_n->move_endpoints(path_it.begin()->initialPoint(), + path_it.begin()->initialPoint()); } else { - curve_n->move_endpoints(path_it->begin()->initialPoint(), point_at3); + curve_n->move_endpoints(path_it.begin()->initialPoint(), point_at3); } - if (path_it->closed()) { + if (path_it.closed()) { curve_n->closepath_current(); } curve->append(curve_n, false); diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index 2ce860061..1ea2770ba 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -74,10 +74,9 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, const gchar * if ( SP_IS_GROUP(origin) && SP_IS_GROUP(dest) && SP_GROUP(origin)->getItemCount() == SP_GROUP(dest)->getItemCount() ) { std::vector< SPObject * > childs = origin->childList(true); size_t index = 0; - for (std::vector::iterator obj_it = childs.begin(); - obj_it != childs.end(); ++obj_it) { + for (auto & child : childs) { SPObject *dest_child = dest->nthChild(index); - cloneAttrbutes((*obj_it), dest_child, attributes, style_attributes); + cloneAttrbutes(child, dest_child, attributes, style_attributes); index++; } } diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 3632d3a62..be0165776 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -200,10 +200,9 @@ LPECopyRotate::cloneD(SPObject *orig, SPObject *dest, Geom::Affine transform, bo if ( SP_IS_GROUP(orig) && SP_IS_GROUP(dest) && SP_GROUP(orig)->getItemCount() == SP_GROUP(dest)->getItemCount() ) { std::vector< SPObject * > childs = orig->childList(true); size_t index = 0; - for (std::vector::iterator obj_it = childs.begin(); - obj_it != childs.end(); ++obj_it) { + for (auto & child : childs) { SPObject *dest_child = dest->nthChild(index); - cloneD(*obj_it, dest_child, transform, reset); + cloneD(child, dest_child, transform, reset); index++; } return; @@ -251,8 +250,7 @@ LPECopyRotate::createPathBase(SPObject *elemref) { container->setAttribute("transform", prev->attribute("transform")); std::vector const item_list = sp_item_group_item_list(group); Inkscape::XML::Node *previous = nullptr; - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - SPObject *sub_item = *iter; + for (auto sub_item : item_list) { Inkscape::XML::Node *resultnode = createPathBase(sub_item); container->addChild(resultnode, previous); previous = resultnode; @@ -427,12 +425,11 @@ LPECopyRotate::split(Geom::PathVector &path_on, Geom::Path const ÷r) int position = 0; Geom::Crossings cs = crossings(original,divider); std::vector crossed; - for(unsigned int i = 0; i < cs.size(); i++) { - crossed.push_back(cs[i].ta); + for(auto & c : cs) { + crossed.push_back(c.ta); } std::sort(crossed.begin(), crossed.end()); - for (unsigned int i = 0; i < crossed.size(); i++) { - double time_end = crossed[i]; + for (double time_end : crossed) { if (time_start == time_end || time_end - time_start < Geom::EPSILON) { continue; } diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index 254065da8..aa7a39b77 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -159,8 +159,8 @@ LPECurveStitch::resetDefaults(SPItem const* item) // calculate bounding box: (isn't there a simpler way?) Piecewise > pwd2; Geom::PathVector temppath = sp_svg_read_pathv( item->getRepr()->attribute("inkscape:original-d")); - for (unsigned int i=0; i < temppath.size(); i++) { - pwd2.concat( temppath[i].toPwSb() ); + for (const auto & i : temppath) { + pwd2.concat( i.toPwSb() ); } D2 > d2pw = make_cuts_independent(pwd2); OptInterval bndsX = bounds_exact(d2pw[0]); diff --git a/src/live_effects/lpe-dash-stroke.cpp b/src/live_effects/lpe-dash-stroke.cpp index e55fdae7f..1972b583c 100644 --- a/src/live_effects/lpe-dash-stroke.cpp +++ b/src/live_effects/lpe-dash-stroke.cpp @@ -77,15 +77,15 @@ Geom::PathVector LPEDashStroke::doEffect_path(Geom::PathVector const & path_in){ Geom::PathVector const pv = pathv_to_linear_and_cubic_beziers(path_in); Geom::PathVector result; - for (Geom::PathVector::const_iterator path_it = pv.begin(); path_it != pv.end(); ++path_it) { - if (path_it->empty()) { + for (const auto & path_it : pv) { + if (path_it.empty()) { continue; } - Geom::Path::const_iterator curve_it1 = path_it->begin(); - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); - Geom::Path::const_iterator curve_endit = path_it->end_default(); - if (path_it->closed()) { - const Geom::Curve &closingline = path_it->back_closed(); + Geom::Path::const_iterator curve_it1 = path_it.begin(); + Geom::Path::const_iterator curve_it2 = ++(path_it.begin()); + Geom::Path::const_iterator curve_endit = path_it.end_default(); + if (path_it.closed()) { + const Geom::Curve &closingline = path_it.back_closed(); // the closing line segment is always of type // Geom::LineSegment. if (are_near(closingline.initialPoint(), closingline.finalPoint())) { @@ -93,7 +93,7 @@ LPEDashStroke::doEffect_path(Geom::PathVector const & path_in){ // *exact* zero length, which goes wrong for relative coordinates and // rounding errors... // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); + curve_endit = path_it.end_open(); } } size_t numberdashes_fixed = numberdashes; @@ -118,7 +118,7 @@ LPEDashStroke::doEffect_path(Geom::PathVector const & path_in){ double holepercent = globalhole/numberholes; double dashsize_fixed = 0; double holesize_fixed = 0; - Geom::Piecewise > pwd2 = (*path_it).toPwSb(); + Geom::Piecewise > pwd2 = path_it.toPwSb(); double lenght_pwd2 = length (pwd2); double minlenght = lenght_pwd2; if(unifysegment) { @@ -132,15 +132,15 @@ LPEDashStroke::doEffect_path(Geom::PathVector const & path_in){ ++curve_it1; ++curve_it2; } - curve_it1 = path_it->begin(); - curve_it2 = ++(path_it->begin()); - curve_endit = path_it->end_default(); + curve_it1 = path_it.begin(); + curve_it2 = ++(path_it.begin()); + curve_endit = path_it.end_default(); } size_t p_index = 0; size_t start_index = result.size(); if(splitsegments) { while (curve_it1 != curve_endit) { - Geom::Path segment = (*path_it).portion(p_index, p_index + 1); + Geom::Path segment = path_it.portion(p_index, p_index + 1); if(unifysegment) { double integral; double fractional = modf((*curve_it1).length()/(dashsize_fixed + holesize_fixed), &integral); @@ -222,7 +222,7 @@ LPEDashStroke::doEffect_path(Geom::PathVector const & path_in){ } } if (curve_it2 == curve_endit) { - if (path_it->closed()) { + if (path_it.closed()) { Geom::Path end = result[result.size()-1]; end.setFinal(result[start_index].initialPoint()); end.append(result[start_index]); @@ -243,7 +243,7 @@ LPEDashStroke::doEffect_path(Geom::PathVector const & path_in){ } else { end = timeAtLength(dashsize,pwd2); } - result.push_back((*path_it).portion(start, end)); + result.push_back(path_it.portion(start, end)); double startsize = dashsize + holesize; if (halfextreme) { startsize = (dashsize/2.0) + holesize; @@ -251,14 +251,14 @@ LPEDashStroke::doEffect_path(Geom::PathVector const & path_in){ double endsize = startsize + dashsize; start = timeAtLength(startsize,pwd2); end = timeAtLength(endsize,pwd2); - while (start < (*path_it).size() && start > 0) { - result.push_back((*path_it).portion(start, end)); + while (start < path_it.size() && start > 0) { + result.push_back(path_it.portion(start, end)); startsize = endsize + holesize; endsize = startsize + dashsize; start = timeAtLength(startsize,pwd2); end = timeAtLength(endsize,pwd2); } - if (path_it->closed()) { + if (path_it.closed()) { Geom::Path end = result[result.size()-1]; end.setFinal(result[start_index].initialPoint()); end.append(result[start_index]); diff --git a/src/live_effects/lpe-embrodery-stitch-ordering.cpp b/src/live_effects/lpe-embrodery-stitch-ordering.cpp index 5761c4701..1c3548420 100644 --- a/src/live_effects/lpe-embrodery-stitch-ordering.cpp +++ b/src/live_effects/lpe-embrodery-stitch-ordering.cpp @@ -175,8 +175,8 @@ void OrderingOriginal(std::vector &infos) void OrderingZigZag(std::vector &infos, bool revfirst) { - for (std::vector::iterator it = infos.begin(); it != infos.end(); ++it) { - it->reverse = (it->index & 1) == (revfirst ? 0 : 1); + for (auto & info : infos) { + info.reverse = (info.index & 1) == (revfirst ? 0 : 1); } } @@ -260,32 +260,32 @@ void OrderingPoint::FindNearest2(const std::vector &infos) nearest[0] = nullptr; nearest[1] = nullptr; - for (std::vector::const_iterator it = infos.begin(); it != infos.end(); ++it) { - Coord dist = distance(point, (*it)->beg.point); + for (auto info : infos) { + Coord dist = distance(point, info->beg.point); if (dist < dist1) { - if (&(*it)->beg != this && &(*it)->end != this) { + if (&info->beg != this && &info->end != this) { if (dist < dist0) { nearest[1] = nearest[0]; - nearest[0] = &(*it)->beg; + nearest[0] = &info->beg; dist1 = dist0; dist0 = dist; } else { - nearest[1] = &(*it)->beg; + nearest[1] = &info->beg; dist1 = dist; } } } - dist = distance(point, (*it)->end.point); + dist = distance(point, info->end.point); if (dist < dist1) { - if (&(*it)->beg != this && &(*it)->end != this) { + if (&info->beg != this && &info->end != this) { if (dist < dist0) { nearest[1] = nearest[0]; - nearest[0] = &(*it)->end; + nearest[0] = &info->end; dist1 = dist0; dist0 = dist; } else { - nearest[1] = &(*it)->end; + nearest[1] = &info->end; dist1 = dist; } } @@ -403,14 +403,14 @@ bool OrderingGroupNeighbor::Compare(const OrderingGroupNeighbor &a, const Orderi OrderingGroupNeighbor *OrderingGroupPoint::FindNearestUnused() { - for (std::vector::iterator it = nearest.begin(); it != nearest.end(); ++it) { - if (!it->point->used) { + for (auto & it : nearest) { + if (!it.point->used) { DebugTrace1TSP(("Nearest: group %d, size %d, point %d, nghb %d, xFrom %.4lf, yFrom %.4lf, xTo %.4lf, yTo %.4lf, dist %.4lf", it->point->group->index, it->point->group->items.size(), it->point->indexInGroup, it - nearest.begin(), point.x(), 297 - point.y(), it->point->point.x(), 297 - it->point->point.y(), it->distance)); - return &*it; + return ⁢ } } @@ -641,11 +641,11 @@ bool FindShortestReconnect(std::vector &segments, std::vector::iterator it = allconnections.begin(); it != allconnections.end(); it++) { - if ((*it)->Distance() > length) { - if (!contains(connections, *it)) { - longestOutside = *it; - length = (*it)->Distance(); + for (auto & allconnection : allconnections) { + if (allconnection->Distance() > length) { + if (!contains(connections, allconnection)) { + longestOutside = allconnection; + length = allconnection->Distance(); } } } @@ -662,13 +662,13 @@ bool FindShortestReconnect(std::vector &segments, std::vector::iterator it = segments.begin(); it != segments.end(); it++) { - it->endbit = nEndBits++; - if (it->nEndPoints == 4) { - it->swapbit = nSwapBits++; + for (auto & segment : segments) { + segment.endbit = nEndBits++; + if (segment.nEndPoints == 4) { + segment.swapbit = nSwapBits++; } else { // bit 32 should always be 0 - it->swapbit = 31; + segment.swapbit = 31; } } @@ -702,14 +702,14 @@ bool FindShortestReconnect(std::vector &segments, std::vector::iterator it = permutation.begin(); it != permutation.end(); it++) { - OrderingGroupPoint *thisbeg = segments[*it].GetBeginPoint(iSwap, iEnd); + for (int & it : permutation) { + OrderingGroupPoint *thisbeg = segments[it].GetBeginPoint(iSwap, iEnd); Coord length = Geom::distance(thisbeg->point, prevend->point); lengthTotal += length; if (length > lengthLongest) { lengthLongest = length; } - prevend = segments[*it].GetEndPoint(iSwap, iEnd); + prevend = segments[it].GetEndPoint(iSwap, iEnd); } lengthTotal -= lengthLongest; @@ -723,11 +723,11 @@ bool FindShortestReconnect(std::vector &segments, std::vector::iterator it = permutation.begin(); it != permutation.end(); it++) { - OrderingGroupPoint *thisbeg = segments[*it].GetBeginPoint(iSwap, iEnd); + for (int & it : permutation) { + OrderingGroupPoint *thisbeg = segments[it].GetBeginPoint(iSwap, iEnd); DebugTrace2TSP(("IMP 0F=%d %d %.6lf", thisbeg->group->index, thisbeg->indexInGroup, Geom::distance(thisbeg->point, prevend->point))); DebugTrace2TSP(("IMP 0T=%d %d %.6lf", prevend->group->index, prevend->indexInGroup, Geom::distance(thisbeg->point, prevend->point))); - prevend = segments[*it].GetEndPoint(iSwap, iEnd); + prevend = segments[it].GetEndPoint(iSwap, iEnd); } } @@ -768,9 +768,9 @@ bool FindShortestReconnect(std::vector &segments, std::vector::iterator it = connections.begin(); it != connections.end(); ++it) { - if ((*it)->Distance() > (*longestConnect)->Distance()) { - *longestConnect = *it; + for (auto & connection : connections) { + if (connection->Distance() > (*longestConnect)->Distance()) { + *longestConnect = connection; } } DebugTrace2TSP(("LONG =%d %d %.6lf", (*longestConnect)->points[0]->group->index, (*longestConnect)->points[0]->indexInGroup, (*longestConnect)->Distance())); @@ -783,10 +783,10 @@ bool FindShortestReconnect(std::vector &segments, std::vector &groups, std::vector &connections, OrderingGroupConnection *longestConnection) { - for (std::vector::iterator it = connections.begin(); it != connections.end(); it++) { + for (auto & connection : connections) { for (int i = 0; i < 2; i++) { - OrderingGroupPoint *pnt = (*it)->points[i]; - assert(pnt->connection == *it); + OrderingGroupPoint *pnt = connection->points[i]; + assert(pnt->connection == connection); assert(pnt->connection->points[pnt->indexInConnection] == pnt); assert(pnt->group->endpoints[pnt->indexInGroup] == pnt); } @@ -872,8 +872,8 @@ void OrderGroups(std::vector *groups, const int nDims) } // Initialize the endpoints for all groups - for (std::vector::iterator it = groups->begin(); it != groups->end(); ++it) { - (*it)->SetEndpoints(); + for (auto & group : *groups) { + group->SetEndpoints(); } // Find the neighboring points for all end points of all groups and sort by distance @@ -1048,9 +1048,9 @@ void OrderingAdvanced(std::vector &infos, int nDims) ) // Make sure the nearest points are mutual - for (std::vector::iterator it = infoex.begin(); it != infoex.end(); ++it) { - (*it)->beg.EnforceMutual(); - (*it)->end.EnforceMutual(); + for (auto & it : infoex) { + it->beg.EnforceMutual(); + it->end.EnforceMutual(); } DebugTraceGrouping( @@ -1062,9 +1062,9 @@ void OrderingAdvanced(std::vector &infos, int nDims) ) // Make sure the nearest points for begin and end lead to the same sub-path (same index) - for (std::vector::iterator it = infoex.begin(); it != infoex.end(); ++it) { - (*it)->beg.EnforceSymmetric((*it)->end); - (*it)->end.EnforceSymmetric((*it)->beg); + for (auto & it : infoex) { + it->beg.EnforceSymmetric(it->end); + it->end.EnforceSymmetric(it->beg); } DebugTraceGrouping( @@ -1085,10 +1085,10 @@ void OrderingAdvanced(std::vector &infos, int nDims) std::vector result; result.reserve(infos.size()); int nUngrouped = 0; - for (std::vector::iterator it = infoex.begin(); it != infoex.end(); ++it) { - if (!(*it)->grouped) { + for (auto & it : infoex) { + if (!it->grouped) { groups.push_back(new OrderingGroup(groups.size())); - groups.back()->items.push_back(*it); + groups.back()->items.push_back(it); nUngrouped++; } } @@ -1105,17 +1105,17 @@ void OrderingAdvanced(std::vector &infos, int nDims) OrderGroups(&groups, nDims); // Copy grouped lines to output - for (std::vector::iterator itGroup = groups.begin(); itGroup != groups.end(); ++itGroup) { - for (unsigned int iItem = 0; iItem < (*itGroup)->items.size(); iItem++) { - unsigned int iItemRev = (*itGroup)->revItemList ? (*itGroup)->items.size() - 1 - iItem : iItem; - OrderingInfoEx *item = (*itGroup)->items[iItemRev]; + for (auto & group : groups) { + for (unsigned int iItem = 0; iItem < group->items.size(); iItem++) { + unsigned int iItemRev = group->revItemList ? group->items.size() - 1 - iItem : iItem; + OrderingInfoEx *item = group->items[iItemRev]; // If revItems is false, even items shall have reverse=false // In this case ( ( iItem & 1 ) == 0 )== true, revItems=false, (true==false) == false - bool reverse = ((iItem & 1) == 0) == (*itGroup)->revItems; + bool reverse = ((iItem & 1) == 0) == group->revItems; if (!reverse) { - for (std::vector::iterator itOrig = item->origIndices.begin(); itOrig != item->origIndices.end(); ++itOrig) { - result.push_back(infos[*itOrig]); + for (int & origIndice : item->origIndices) { + result.push_back(infos[origIndice]); result.back().reverse = false; } } else { diff --git a/src/live_effects/lpe-embrodery-stitch.cpp b/src/live_effects/lpe-embrodery-stitch.cpp index a0350fec5..4435c3463 100644 --- a/src/live_effects/lpe-embrodery-stitch.cpp +++ b/src/live_effects/lpe-embrodery-stitch.cpp @@ -333,11 +333,11 @@ PathVector LPEEmbroderyStitch::doEffect_path(PathVector const &path_in) } if (show_stitches) { - for (std::vector< D2 >::iterator it = pwStitch.segs.begin(); it != pwStitch.segs.end(); ++it) { + for (auto & seg : pwStitch.segs) { // Create anew piecewise with just one segment Piecewise > pwOne; pwOne.push_cut(0); - pwOne.push_seg(*it); + pwOne.push_seg(seg); pwOne.push_cut(1); // make piecewise equidistant in time @@ -360,11 +360,11 @@ PathVector LPEEmbroderyStitch::doEffect_path(PathVector const &path_in) } } else { PathVector pathv = path_from_piecewise(pwStitch, LPE_CONVERSION_TOLERANCE); - for (size_t ipv = 0; ipv < pathv.size(); ipv++) { + for (const auto & ipv : pathv) { if (connect_with_previous) { - path_out.back().append(pathv[ipv]); + path_out.back().append(ipv); } else { - path_out.push_back(pathv[ipv]); + path_out.push_back(ipv); } } } diff --git a/src/live_effects/lpe-extrude.cpp b/src/live_effects/lpe-extrude.cpp index 8cc9b7468..57e5ca2ce 100644 --- a/src/live_effects/lpe-extrude.cpp +++ b/src/live_effects/lpe-extrude.cpp @@ -83,13 +83,13 @@ LPEExtrude::doEffect_pwd2 (Geom::Piecewise > const & pwd2 // connecting lines should be put at cusps Piecewise > deriv = derivative(pwd2_in); std::vector cusps; // = roots(deriv); - for (unsigned i = 0; i < cusps.size() ; ++i) { - pwd2_out.concat( connector + pwd2_in.valueAt(cusps[i]) ); + for (double cusp : cusps) { + pwd2_out.concat( connector + pwd2_in.valueAt(cusp) ); } // connecting lines should be put where the tangent of the path equals the extrude_vector in direction std::vector rts = roots(dot(deriv, rot90(extrude_vector.getVector()))); - for (unsigned i = 0; i < rts.size() ; ++i) { - pwd2_out.concat( connector + pwd2_in.valueAt(rts[i]) ); + for (double rt : rts) { + pwd2_out.concat( connector + pwd2_in.valueAt(rt) ); } return pwd2_out; } diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp index 6eb5750f0..c5121c37a 100644 --- a/src/live_effects/lpe-fill-between-many.cpp +++ b/src/live_effects/lpe-fill-between-many.cpp @@ -80,22 +80,21 @@ void LPEFillBetweenMany::doEffect (SPCurve * curve) selection = desktop->selection; } if (!autoreverse) { - for (std::vector::iterator iter = linked_paths._vector.begin(); - iter != linked_paths._vector.end(); ++iter) { + for (auto & iter : linked_paths._vector) { SPObject *obj; - if ((*iter)->ref.isAttached() && (obj = (*iter)->ref.getObject()) && SP_IS_ITEM(obj) && - !(*iter)->_pathvector.empty() && (*iter)->visibled) { + if (iter->ref.isAttached() && (obj = iter->ref.getObject()) && SP_IS_ITEM(obj) && + !iter->_pathvector.empty() && iter->visibled) { Geom::Path linked_path; - if ((*iter)->_pathvector.front().closed() && linked_paths._vector.size() > 1) { + if (iter->_pathvector.front().closed() && linked_paths._vector.size() > 1) { continue; } if (obj && transf != Geom::identity() && selection && !selection->includes(obj->getRepr())) { SP_ITEM(obj)->doWriteTransform(transf); } - if ((*iter)->reversed) { - linked_path = (*iter)->_pathvector.front().reversed(); + if (iter->reversed) { + linked_path = iter->_pathvector.front().reversed(); } else { - linked_path = (*iter)->_pathvector.front(); + linked_path = iter->_pathvector.front(); } if (!res_pathv.empty() && join) { if (!are_near(res_pathv.front().finalPoint(), linked_path.initialPoint(), 0.01) || !fuse) { @@ -142,26 +141,25 @@ void LPEFillBetweenMany::doEffect (SPCurve * curve) unsigned int counter2 = 0; unsigned int added = 0; PathAndDirectionAndVisible *nearest = nullptr; - for (std::vector::iterator iter2 = linked_paths._vector.begin(); - iter2 != linked_paths._vector.end(); ++iter2) { + for (auto & iter2 : linked_paths._vector) { SPObject *obj2; - if ((*iter2)->ref.isAttached() && (obj2 = (*iter2)->ref.getObject()) && SP_IS_ITEM(obj2) && - !(*iter2)->_pathvector.empty() && (*iter2)->visibled) { + if (iter2->ref.isAttached() && (obj2 = iter2->ref.getObject()) && SP_IS_ITEM(obj2) && + !iter2->_pathvector.empty() && iter2->visibled) { if (obj == obj2 || std::find(done.begin(), done.end(), counter2) != done.end()) { counter2++; continue; } - if ((*iter2)->_pathvector.front().closed() && linked_paths._vector.size() > 1) { + if (iter2->_pathvector.front().closed() && linked_paths._vector.size() > 1) { counter2++; continue; } - Geom::Point start = (*iter2)->_pathvector.front().initialPoint(); - Geom::Point end = (*iter2)->_pathvector.front().finalPoint(); + Geom::Point start = iter2->_pathvector.front().initialPoint(); + Geom::Point end = iter2->_pathvector.front().finalPoint(); Geom::Coord distance_iter = std::min(Geom::distance(current, end), Geom::distance(current, start)); if (distance > distance_iter) { distance = distance_iter; - nearest = (*iter2); + nearest = iter2; added = counter2; } counter2++; diff --git a/src/live_effects/lpe-fill-between-strokes.cpp b/src/live_effects/lpe-fill-between-strokes.cpp index 3b00b2d03..262a5f9d0 100644 --- a/src/live_effects/lpe-fill-between-strokes.cpp +++ b/src/live_effects/lpe-fill-between-strokes.cpp @@ -60,13 +60,13 @@ void LPEFillBetweenStrokes::doEffect (SPCurve * curve) Geom::PathVector second_pathv = second_path.get_pathvector(); Geom::PathVector result_linked_pathv; Geom::PathVector result_second_pathv; - for (Geom::PathVector::iterator iter = linked_pathv.begin(); iter != linked_pathv.end(); ++iter) + for (auto & iter : linked_pathv) { - result_linked_pathv.push_back((*iter)); + result_linked_pathv.push_back(iter); } - for (Geom::PathVector::iterator iter = second_pathv.begin(); iter != second_pathv.end(); ++iter) + for (auto & iter : second_pathv) { - result_second_pathv.push_back((*iter)); + result_second_pathv.push_back(iter); } if ( !result_linked_pathv.empty() && !result_second_pathv.empty() && !result_linked_pathv.front().closed() ) { @@ -104,9 +104,9 @@ void LPEFillBetweenStrokes::doEffect (SPCurve * curve) } Geom::PathVector linked_pathv = linked_path.get_pathvector(); Geom::PathVector result_pathv; - for (Geom::PathVector::iterator iter = linked_pathv.begin(); iter != linked_pathv.end(); ++iter) + for (auto & iter : linked_pathv) { - result_pathv.push_back((*iter)); + result_pathv.push_back(iter); } if ( !result_pathv.empty() ) { if (close) { @@ -122,9 +122,9 @@ void LPEFillBetweenStrokes::doEffect (SPCurve * curve) } Geom::PathVector second_pathv = second_path.get_pathvector(); Geom::PathVector result_pathv; - for (Geom::PathVector::iterator iter = second_pathv.begin(); iter != second_pathv.end(); ++iter) + for (auto & iter : second_pathv) { - result_pathv.push_back((*iter)); + result_pathv.push_back(iter); } if ( !result_pathv.empty() ) { if (close) { diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 0574b5b4b..e0aada95b 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -109,12 +109,12 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) if (it != gchar_map_to_satellite_type.end()) { satellite_type = it->second; } - for (Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - if (path_it->empty()) { + for (const auto & path_it : pathv) { + if (path_it.empty()) { continue; } std::vector subpath_satellites; - for (Geom::Path::const_iterator curve_it = path_it->begin(); curve_it != path_it->end(); ++curve_it) { + for (Geom::Path::const_iterator curve_it = path_it.begin(); curve_it != path_it.end(); ++curve_it) { //Maybe we want this satellites... //if (curve_it->isDegenerate()) { // continue @@ -131,7 +131,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) //so maybe in the future we can need this last satellite in other effects //don't remove for this effect because _pathvector_satellites class has methods when the path is modified //and we want one method for all uses - if (!path_it->closed()) { + if (!path_it.closed()) { Satellite satellite(satellite_type); satellite.setSteps(chamfer_steps); satellite.setAmount(power); diff --git a/src/live_effects/lpe-interpolate_points.cpp b/src/live_effects/lpe-interpolate_points.cpp index d1e94a392..6748aae37 100644 --- a/src/live_effects/lpe-interpolate_points.cpp +++ b/src/live_effects/lpe-interpolate_points.cpp @@ -53,18 +53,18 @@ LPEInterpolatePoints::doEffect_path (Geom::PathVector const & path_in) Geom::PathVector path_out; std::unique_ptr interpolator( Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())) ); - for(Geom::PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) { - if (path_it->empty()) + for(const auto & path_it : path_in) { + if (path_it.empty()) continue; - if (path_it->closed()) { + if (path_it.closed()) { g_warning("Interpolate points LPE currently ignores whether path is closed or not."); } std::vector pts; - pts.push_back(path_it->initialPoint()); + pts.push_back(path_it.initialPoint()); - for (Geom::Path::const_iterator it = path_it->begin(), e = path_it->end_default(); it != e; ++it) { + for (Geom::Path::const_iterator it = path_it.begin(), e = path_it.end_default(); it != e; ++it) { pts.push_back((*it).finalPoint()); } diff --git a/src/live_effects/lpe-jointype.cpp b/src/live_effects/lpe-jointype.cpp index ad3fcb9f6..df39fe0d0 100644 --- a/src/live_effects/lpe-jointype.cpp +++ b/src/live_effects/lpe-jointype.cpp @@ -168,8 +168,8 @@ void LPEJoinType::doOnRemove(SPLPEItem const* lpeitem) Geom::PathVector LPEJoinType::doEffect_path(Geom::PathVector const & path_in) { Geom::PathVector ret; - for (size_t i = 0; i < path_in.size(); ++i) { - Geom::PathVector tmp = Inkscape::outline(path_in[i], line_width, + for (const auto & i : path_in) { + Geom::PathVector tmp = Inkscape::outline(i, line_width, (attempt_force_join ? std::numeric_limits::max() : miter_limit), static_cast(linejoin_type.get_value()), static_cast(linecap_type.get_value())); diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index f16c11bb2..d48dbd765 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -79,10 +79,10 @@ std::vector complementOf(Geom::Interval I, std::vector I1i = intersect(domain.at(i),I1); + for (auto i : domain){ + boost::optional I1i = intersect(i,I1); if (I1i && !I1i->isSingular()) ret.push_back(I1i.get()); - boost::optional I2i = intersect(domain.at(i),I2); + boost::optional I2i = intersect(i,I2); if (I2i && !I2i->isSingular()) ret.push_back(I2i.get()); } } @@ -119,8 +119,8 @@ findShadowedTime(Geom::Path const &patha, std::vector const &pt_and times_i.insert(times_i.end(), temptimes.begin(), temptimes.end() ); temptimes = roots(f[X]+3*width); times_i.insert(times_i.end(), temptimes.begin(), temptimes.end() ); - for (unsigned k=0; k::iterator m=cuts.begin(); m!=cuts.end(); ++m ){ - if ( ((*this)[m->second].i == i) && ((*this)[m->second].ti == m->first) ){ - (*this)[m->second].ni = count; + for (auto & cut : cuts){ + if ( ((*this)[cut.second].i == i) && ((*this)[cut.second].ti == cut.first) ){ + (*this)[cut.second].ni = count; }else{ - (*this)[m->second].nj = count; + (*this)[cut.second].nj = count; } count++; } @@ -412,7 +412,7 @@ LPEKnot::doEffect_path (Geom::PathVector const &path_in) return path_in; } Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(path_in); - for (unsigned comp=0; compgetInt("/options/svgoutput/numericprecision"); prefs->setInt("/options/svgoutput/numericprecision", 4); // I think this is enough for minor differences for (i0=0; i0setInt("/options/svgoutput/numericprecision", precision); @@ -556,8 +556,8 @@ collectPathsAndWidths (SPLPEItem const *lpeitem, Geom::PathVector &paths, std::v SPCurve * c = SP_SHAPE(lpeitem)->getCurve(); if (c) { Geom::PathVector subpaths = pathv_to_linear_and_cubic_beziers(c->get_pathvector()); - for (unsigned i=0; istyle->stroke_width.computed); } diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index 827f4b5ac..8768547e8 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -740,8 +740,8 @@ std::vector< Point > transformNodes(std::vector< Point > nodes, Geom::Affine transform) { std::vector< Point > result; - for ( std::vector::iterator iter = nodes.begin(); iter != nodes.end(); ++iter ) { - Geom::Point point = (*iter); + for (auto & node : nodes) { + Geom::Point point = node; result.push_back(point * transform); } return result; @@ -758,8 +758,7 @@ getNodes(SPItem * item, Geom::Affine transform, bool onbbox, bool centers, bool //TODO handle clones/use if (group) { std::vector const item_list = sp_item_group_item_list(group); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - SPItem *sub_item = *iter; + for (auto sub_item : item_list) { std::vector< Point > nodes = transformNodes(getNodes(sub_item, sub_item->transform, onbbox, centers, bboxonly), transform); current_nodes.insert(current_nodes.end(), nodes.begin(), nodes.end()); } @@ -849,8 +848,8 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) Geom::OptRect bbox = sp_lpe_item->geometricBounds(sp_lpe_item->transform); Geom::Point pojpoint = Geom::Point(); double maxdistance = -std::numeric_limits::max(); - for ( std::vector::iterator iter = nodes.begin(); iter != nodes.end(); ++iter ) { - Geom::Point point = (*iter); + for (auto & node : nodes) { + Geom::Point point = node; point *= Geom::Translate(mid).inverse(); point *= Geom::Rotate(angle).inverse(); point *= Geom::Translate(mid); @@ -858,9 +857,9 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) maxdistance = point[Geom::X]; } } - for (std::vector::iterator iter = linked_items._vector.begin(); iter != linked_items._vector.end(); ++iter) { + for (auto & iter : linked_items._vector) { SPObject *obj; - if ((*iter)->ref.isAttached() && (*iter)->actived && (obj = (*iter)->ref.getObject()) && SP_IS_ITEM(obj)) { + if (iter->ref.isAttached() && iter->actived && (obj = iter->ref.getObject()) && SP_IS_ITEM(obj)) { SPItem * item = dynamic_cast(obj); if (item) { Geom::Affine affinetransform_sub = i2anc_affine(SP_OBJECT(item), SP_OBJECT(document->getRoot())); @@ -874,8 +873,8 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) } } - for ( std::vector::iterator iter = nodes.begin(); iter != nodes.end(); ++iter ) { - Geom::Point point = (*iter); + for (auto & node : nodes) { + Geom::Point point = node; double dproj = Inkscape::Util::Quantity::convert(distance_projection, display_unit.c_str(), unit.get_abbreviation()); Geom::Coord xpos = maxdistance + dproj; result.emplace_back(xpos, point[Geom::Y]); @@ -885,8 +884,8 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) Geom::Point prevpoint(0,0); size_t counter = 0; bool started = false; - for ( std::vector::iterator iter = result.begin(); iter != result.end(); ++iter ) { - Geom::Point point = (*iter); + for (auto & iter : result) { + Geom::Point point = iter; if (Geom::are_near(prevpoint, point)){ continue; } diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index f5359ab85..55565adb4 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -282,10 +282,9 @@ LPEMirrorSymmetry::cloneD(SPObject *orig, SPObject *dest, bool reset) if ( SP_IS_GROUP(orig) && SP_IS_GROUP(dest) && SP_GROUP(orig)->getItemCount() == SP_GROUP(dest)->getItemCount() ) { std::vector< SPObject * > childs = orig->childList(true); size_t index = 0; - for (std::vector::iterator obj_it = childs.begin(); - obj_it != childs.end(); ++obj_it) { + for (auto & child : childs) { SPObject *dest_child = dest->nthChild(index); - cloneD(*obj_it, dest_child, reset); + cloneD(child, dest_child, reset); index++; } return; @@ -322,8 +321,7 @@ LPEMirrorSymmetry::createPathBase(SPObject *elemref) { container->setAttribute("transform", prev->attribute("transform")); std::vector const item_list = sp_item_group_item_list(group); Inkscape::XML::Node *previous = nullptr; - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - SPObject *sub_item = *iter; + for (auto sub_item : item_list) { Inkscape::XML::Node *resultnode = createPathBase(sub_item); container->addChild(resultnode, previous); previous = resultnode; @@ -471,24 +469,23 @@ LPEMirrorSymmetry::doEffect_path (Geom::PathVector const & path_in) Geom::Point gap = dir * split_gap; path_out *= Geom::Translate(gap); } else if (fuse_paths && !discard_orig_path) { - for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); - path_it != original_pathv.end(); ++path_it) + for (const auto & path_it : original_pathv) { - if (path_it->empty()) { + if (path_it.empty()) { continue; } Geom::PathVector tmp_pathvector; double time_start = 0.0; int position = 0; bool end_open = false; - if (path_it->closed()) { - const Geom::Curve &closingline = path_it->back_closed(); + if (path_it.closed()) { + const Geom::Curve &closingline = path_it.back_closed(); if (!are_near(closingline.initialPoint(), closingline.finalPoint())) { end_open = true; } } - Geom::Path original = *path_it; - if (end_open && path_it->closed()) { + Geom::Path original = path_it; + if (end_open && path_it.closed()) { original.close(false); original.appendNew( original.initialPoint() ); original.close(true); @@ -505,8 +502,8 @@ LPEMirrorSymmetry::doEffect_path (Geom::PathVector const & path_in) divider.appendNew(e); Geom::Crossings cs = crossings(original, divider); std::vector crossed; - for(unsigned int i = 0; i < cs.size(); i++) { - crossed.push_back(cs[i].ta); + for(auto & c : cs) { + crossed.push_back(c.ta); } std::sort(crossed.begin(), crossed.end()); for (unsigned int i = 0; i < crossed.size(); i++) { @@ -571,8 +568,8 @@ LPEMirrorSymmetry::doEffect_path (Geom::PathVector const & path_in) tmp_pathvector.clear(); } } else if (!fuse_paths || discard_orig_path) { - for (size_t i = 0; i < original_pathv.size(); ++i) { - path_out.push_back(original_pathv[i] * m); + for (const auto & i : original_pathv) { + path_out.push_back(i * m); } } return path_out; diff --git a/src/live_effects/lpe-offset.cpp b/src/live_effects/lpe-offset.cpp index e8a1e7df7..b67ff49e8 100644 --- a/src/live_effects/lpe-offset.cpp +++ b/src/live_effects/lpe-offset.cpp @@ -132,8 +132,8 @@ sp_get_outer(Geom::PathVector pathvector) Geom::OptRect bbox; Geom::Path ret; Geom::PathVector ret_pv; - for (Geom::PathVector::iterator path_it = pathvector.begin(); path_it != pathvector.end(); ++path_it) { - Geom::Path iter = (*path_it); + for (auto & path_it : pathvector) { + Geom::Path iter = path_it; if (iter.empty()) { continue; } @@ -157,8 +157,8 @@ sp_get_inner(Geom::PathVector pathvector) Geom::PathVector ret_pv; Geom::PathVector outer = sp_get_outer(pathvector); Geom::OptRect bbox = outer.boundsFast(); - for (Geom::PathVector::iterator path_it = pathvector.begin(); path_it != pathvector.end(); ++path_it) { - Geom::Path iter = (*path_it); + for (auto & path_it : pathvector) { + Geom::Path iter = path_it; if (iter.empty()) { continue; } diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 57a3c3875..081c87990 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -184,8 +184,7 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise > con std::vector > > paths_in; paths_in = split_at_discontinuities(pwd2_in); - for (unsigned idx = 0; idx < paths_in.size(); idx++){ - Geom::Piecewise > path_i = paths_in[idx]; + for (auto path_i : paths_in){ Piecewise x = x0; Piecewise y = y0; Piecewise > uskeleton = arc_length_parametrization(path_i,2, 0.1); @@ -257,8 +256,8 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise > con } if (fuse_tolerance > 0){ pre_output = fuse_nearby_ends(pre_output, fuse_tolerance); - for (unsigned i=0; iempty()) + if (path_it.empty()) continue; //Itreadores SPCurve *nCurve = new SPCurve(); - Geom::Path::const_iterator curve_it1 = path_it->begin(); - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); - Geom::Path::const_iterator curve_endit = path_it->end_default(); + Geom::Path::const_iterator curve_it1 = path_it.begin(); + Geom::Path::const_iterator curve_it2 = ++(path_it.begin()); + Geom::Path::const_iterator curve_endit = path_it.end_default(); - if (path_it->closed()) { + if (path_it.closed()) { const Geom::Curve &closingline = - path_it->back_closed(); + path_it.back_closed(); if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - curve_endit = path_it->end_open(); + curve_endit = path_it.end_open(); } } if(deform_type == DEFORMATION_PERSPECTIVE) { @@ -287,7 +287,7 @@ void LPEPerspectiveEnvelope::doEffect(SPCurve *curve) } } //y cerramos la curva - if (path_it->closed()) { + if (path_it.closed()) { nCurve->move_endpoints(point_at3, point_at3); nCurve->closepath_current(); } diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 37e91ab42..79d147a69 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -593,8 +593,8 @@ LPEPowerStroke::doEffect_path (Geom::PathVector const & path_in) return path_out; } std::vector ts; - for (std::vector::iterator tsp = ts_no_scale.begin(); tsp != ts_no_scale.end(); ++tsp) { - Geom::Point p = Geom::Point((*tsp)[Geom::X], (*tsp)[Geom::Y] * scale_width); + for (auto & tsp : ts_no_scale) { + Geom::Point p = Geom::Point(tsp[Geom::X], tsp[Geom::Y] * scale_width); ts.push_back(p); } if (sort_points) { @@ -640,8 +640,8 @@ LPEPowerStroke::doEffect_path (Geom::PathVector const & path_in) // instead of the heavily compressed coordinate system of (segment_no offset, Y) in which the knots are stored double pwd2_in_arclength = length(pwd2_in); double xcoord_scaling = pwd2_in_arclength / ts.back()[Geom::X]; - for (std::size_t i = 0, e = ts.size(); i < e; ++i) { - ts[i][Geom::X] *= xcoord_scaling; + for (auto & t : ts) { + t[Geom::X] *= xcoord_scaling; } Geom::Path strokepath = interpolator->interpolateToPath(ts); diff --git a/src/live_effects/lpe-pts2ellipse.cpp b/src/live_effects/lpe-pts2ellipse.cpp index e1c87f2dd..0d3f70314 100644 --- a/src/live_effects/lpe-pts2ellipse.cpp +++ b/src/live_effects/lpe-pts2ellipse.cpp @@ -261,11 +261,11 @@ LPEPts2Ellipse::doEffect_path (Geom::PathVector const & path_in) // from: extension/internal/odf.cpp // get all points std::vector pts; - for(PathVector::const_iterator pit = path_in.begin(); pit!= path_in.end(); ++pit) { + for(const auto & pit : path_in) { // extract first point of this path - pts.push_back(pit->initialPoint()); + pts.push_back(pit.initialPoint()); // iterate over all curves - for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end(); ++cit) { + for (Geom::Path::const_iterator cit = pit.begin(); cit != pit.end(); ++cit) { pts.push_back(cit->finalPoint()); } } diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index b21738855..0a67cdbbc 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -73,8 +73,7 @@ LPERecursiveSkeleton::doEffect_pwd2 (Geom::Piecewise > co std::vector > > skeleton = split_at_discontinuities(output); output.clear(); - for (unsigned idx = 0; idx < skeleton.size(); idx++){ - Piecewise > path_i = skeleton[idx]; + for (auto path_i : skeleton){ Piecewise x = x0; Piecewise y = y0; Piecewise > uskeleton = arc_length_parametrization(path_i,2,.1); diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index de62b263d..b93e0a94e 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -88,13 +88,13 @@ public: Piecewise > const &f, Piecewise const &dx){ - for (unsigned i=0; i0 ); + lc.pt = f.valueAt(time[j]); + lc.t = time[j]; + lc.sign = ( dx.valueAt(time[j])>0 ); lc.used = false; lcs.push_back(lc); } @@ -429,24 +429,24 @@ Piecewise > LPERoughHatches::smoothSnake(std::vector > const &linearSnake){ Piecewise > result; - for (unsigned comp=0; comp=2){ - Point last_pt = linearSnake[comp][0]; + for (const auto & comp : linearSnake){ + if (comp.size()>=2){ + Point last_pt = comp[0]; //Point last_top = linearSnake[comp][0]; //Point last_bot = linearSnake[comp][0]; - Point last_hdle = linearSnake[comp][0]; - Point last_top_hdle = linearSnake[comp][0]; - Point last_bot_hdle = linearSnake[comp][0]; + Point last_hdle = comp[0]; + Point last_top_hdle = comp[0]; + Point last_bot_hdle = comp[0]; Geom::Path res_comp(last_pt); Geom::Path res_comp_top(last_pt); Geom::Path res_comp_bot(last_pt); unsigned i=1; //bool is_top = true;//Inversion here; due to downward y? - bool is_top = ( linearSnake[comp][0][Y] < linearSnake[comp][1][Y] ); + bool is_top = ( comp[0][Y] < comp[1][Y] ); - while( i+1 > const &linearSnake i+=2; is_top = !is_top; } - if ( i(last_top_hdle,linearSnake[comp][i],linearSnake[comp][i]); - res_comp_bot.appendNew(last_bot_hdle,linearSnake[comp][i],linearSnake[comp][i]); + res_comp_top.appendNew(last_top_hdle,comp[i],comp[i]); + res_comp_bot.appendNew(last_bot_hdle,comp[i],comp[i]); }else{ - res_comp.appendNew(last_hdle,linearSnake[comp][i],linearSnake[comp][i]); + res_comp.appendNew(last_hdle,comp[i],comp[i]); } } if ( fat_output.get_value() ){ diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 9008230d4..14c95ca45 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -198,20 +198,19 @@ void LPERoughen::doEffect(SPCurve *curve) { Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); curve->reset(); - for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); - path_it != original_pathv.end(); ++path_it) { - if (path_it->empty()) + for (const auto & path_it : original_pathv) { + if (path_it.empty()) continue; - Geom::Path::const_iterator curve_it1 = path_it->begin(); - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); - Geom::Path::const_iterator curve_endit = path_it->end_default(); + Geom::Path::const_iterator curve_it1 = path_it.begin(); + Geom::Path::const_iterator curve_it2 = ++(path_it.begin()); + Geom::Path::const_iterator curve_endit = path_it.end_default(); SPCurve *nCurve = new SPCurve(); Geom::Point prev(0, 0); Geom::Point last_move(0, 0); nCurve->moveto(curve_it1->initialPoint()); - if (path_it->closed()) { - const Geom::Curve &closingline = path_it->back_closed(); + if (path_it.closed()) { + const Geom::Curve &closingline = path_it.back_closed(); // the closing line segment is always of type // Geom::LineSegment. if (are_near(closingline.initialPoint(), closingline.finalPoint())) { @@ -219,7 +218,7 @@ void LPERoughen::doEffect(SPCurve *curve) // *exact* zero length, which goes wrong for relative coordinates and // rounding errors... // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); + curve_endit = path_it.end_open(); } } while (curve_it1 != curve_endit) { @@ -265,7 +264,7 @@ void LPERoughen::doEffect(SPCurve *curve) ++curve_it1; ++curve_it2; } - if (path_it->closed()) { + if (path_it.closed()) { if(handles == HM_SMOOTH && curve_it1 == curve_endit){ SPCurve *out = new SPCurve(); nCurve = nCurve->create_reverse(); diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index 0b7443de2..75052ad33 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -146,11 +146,11 @@ LPERuler::doEffect_pwd2 (Geom::Piecewise > const & pwd2_i } std::vector > roots = multi_roots(arclength, s_cuts); std::vector t_cuts; - for (unsigned v=0; v0) - t_cuts.push_back(roots[v][0]); + if(root.size()>0) + t_cuts.push_back(root[0]); } //draw the marks for (size_t i = 0; i < t_cuts.size(); i++) { diff --git a/src/live_effects/lpe-show_handles.cpp b/src/live_effects/lpe-show_handles.cpp index ccf0f80dd..c40f07501 100644 --- a/src/live_effects/lpe-show_handles.cpp +++ b/src/live_effects/lpe-show_handles.cpp @@ -88,8 +88,8 @@ Geom::PathVector LPEShowHandles::doEffect_path (Geom::PathVector const & path_in Geom::PathVector path_out; Geom::PathVector original_pathv = pathv_to_linear_and_cubic_beziers(path_in); if(original_path) { - for (unsigned int i=0; i < path_in.size(); i++) { - path_out.push_back(path_in[i]); + for (const auto & i : path_in) { + path_out.push_back(i); } } if(!outline_path.empty()) { @@ -100,8 +100,8 @@ Geom::PathVector LPEShowHandles::doEffect_path (Geom::PathVector const & path_in if (shape_curve) { Geom::PathVector original_curve = shape_curve->get_pathvector(); if(original_path) { - for (unsigned int i=0; i < original_curve.size(); i++) { - path_out.push_back(original_curve[i]); + for (const auto & i : original_curve) { + path_out.push_back(i); } } original_pathv.insert(original_pathv.end(), original_curve.begin(), original_curve.end()); @@ -111,8 +111,8 @@ Geom::PathVector LPEShowHandles::doEffect_path (Geom::PathVector const & path_in } else { generateHelperPath(original_pathv); } - for (unsigned int i=0; i < outline_path.size(); i++) { - path_out.push_back(outline_path[i]); + for (const auto & i : outline_path) { + path_out.push_back(i); } return path_out; @@ -126,33 +126,33 @@ LPEShowHandles::generateHelperPath(Geom::PathVector result) } Geom::CubicBezier const *cubic = nullptr; - for (Geom::PathVector::iterator path_it = result.begin(); path_it != result.end(); ++path_it) { + for (auto & path_it : result) { //Si está vacío... - if (path_it->empty()) { + if (path_it.empty()) { continue; } //Itreadores - Geom::Path::iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + Geom::Path::iterator curve_it1 = path_it.begin(); // incoming curve + Geom::Path::iterator curve_it2 = ++(path_it.begin()); // outgoing curve + Geom::Path::iterator curve_endit = path_it.end_default(); // this determines when the loop has to stop - if (path_it->closed()) { + if (path_it.closed()) { // if the path is closed, maybe we have to stop a bit earlier because the // closing line segment has zerolength. - Geom::Curve const &closingline = path_it->back_closed(); // the closing line segment is always of type + Geom::Curve const &closingline = path_it.back_closed(); // the closing line segment is always of type // Geom::LineSegment. if (are_near(closingline.initialPoint(), closingline.finalPoint())) { // closingline.isDegenerate() did not work, because it only checks for // *exact* zero length, which goes wrong for relative coordinates and // rounding errors... // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); + curve_endit = path_it.end_open(); } } if(nodes) { Geom::NodeType nodetype = Geom::NODE_CUSP; - if(path_it->closed()) { - nodetype = Geom::get_nodetype(path_it->finalCurve(), *curve_it1); + if(path_it.closed()) { + nodetype = Geom::get_nodetype(path_it.finalCurve(), *curve_it1); } drawNode(curve_it1->initialPoint(), nodetype); } @@ -170,7 +170,7 @@ LPEShowHandles::generateHelperPath(Geom::PathVector result) } } } - if(nodes && (curve_it2 != curve_endit || !path_it->closed())) { + if(nodes && (curve_it2 != curve_endit || !path_it.closed())) { Geom::NodeType nodetype = Geom::get_nodetype(*curve_it1, *curve_it2); drawNode(curve_it1->finalPoint(), nodetype); } diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index d589f16d1..56647e4e2 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -155,27 +155,27 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) } Geom::PathVector tmp_path; Geom::CubicBezier const *cubic = nullptr; - for (Geom::PathVector::iterator path_it = result.begin(); path_it != result.end(); ++path_it) { - if (path_it->empty()) { + for (auto & path_it : result) { + if (path_it.empty()) { continue; } - Geom::Path::iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::iterator curve_it2 = ++(path_it->begin());// outgoing curve - Geom::Path::iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + Geom::Path::iterator curve_it1 = path_it.begin(); // incoming curve + Geom::Path::iterator curve_it2 = ++(path_it.begin());// outgoing curve + Geom::Path::iterator curve_endit = path_it.end_default(); // this determines when the loop has to stop SPCurve *nCurve = new SPCurve(); - if (path_it->closed()) { + if (path_it.closed()) { // if the path is closed, maybe we have to stop a bit earlier because the // closing line segment has zerolength. const Geom::Curve &closingline = - path_it->back_closed(); // the closing line segment is always of type + path_it.back_closed(); // the closing line segment is always of type // Geom::LineSegment. if (are_near(closingline.initialPoint(), closingline.finalPoint())) { // closingline.isDegenerate() did not work, because it only checks for // *exact* zero length, which goes wrong for relative coordinates and // rounding errors... // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); + curve_endit = path_it.end_open(); } } if(helper_size > 0) { @@ -199,7 +199,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) point_at2 = (*cubic)[2]; } - if(path_it->closed() && curve_it2 == curve_endit) { + if(path_it.closed() && curve_it2 == curve_endit) { point_at4 = start; } if(curve_it2 != curve_endit) { @@ -240,7 +240,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) ++curve_it1; ++curve_it2; } - if (path_it->closed()) { + if (path_it.closed()) { nCurve->closepath_current(); } tmp_path.push_back(nCurve->get_pathvector()[0]); diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index 7d0a4a505..594751967 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -214,9 +214,8 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise > const & pwd2_ std::vector > > pieces_in = split_at_discontinuities (pwd2_in); //work separately on each component. - for (unsigned pieceidx = 0; pieceidx < pieces_in.size(); pieceidx++){ + for (auto piece : pieces_in){ - Piecewise > piece = pieces_in[pieceidx]; Piecewise piecelength = arcLengthSb(piece,.1); double piece_total_length = piecelength.segs.back().at1()-piecelength.segs.front().at0(); pathlength.concat(piecelength + total_length); diff --git a/src/live_effects/lpe-spiro.cpp b/src/live_effects/lpe-spiro.cpp index 06173d011..e0464a2a0 100644 --- a/src/live_effects/lpe-spiro.cpp +++ b/src/live_effects/lpe-spiro.cpp @@ -47,13 +47,13 @@ void sp_spiro_do_effect(SPCurve *curve){ Spiro::spiro_cp *path = g_new (Spiro::spiro_cp, len); int ip = 0; - for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { - if (path_it->empty()) + for(const auto & path_it : original_pathv) { + if (path_it.empty()) continue; // start of path { - Geom::Point p = path_it->initialPoint(); + Geom::Point p = path_it.initialPoint(); path[ip].x = p[X]; path[ip].y = p[Y]; path[ip].ty = '{' ; // for closed paths, this is overwritten @@ -61,9 +61,9 @@ void sp_spiro_do_effect(SPCurve *curve){ } // midpoints - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + Geom::Path::const_iterator curve_it1 = path_it.begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = ++(path_it.begin()); // outgoing curve + Geom::Path::const_iterator curve_endit = path_it.end_default(); // this determines when the loop has to stop while ( curve_it2 != curve_endit ) { @@ -103,9 +103,9 @@ void sp_spiro_do_effect(SPCurve *curve){ Geom::Point p = curve_it1->finalPoint(); path[ip].x = p[X]; path[ip].y = p[Y]; - if (path_it->closed()) { + if (path_it.closed()) { // curve_it1 points to the (visually) closing segment. determine the match between first and this last segment (the closing node) - Geom::NodeType nodetype = Geom::get_nodetype(*curve_it1, path_it->front()); + Geom::NodeType nodetype = Geom::get_nodetype(*curve_it1, path_it.front()); switch (nodetype) { case Geom::NODE_NONE: // can't happen! but if it does, it means the path isn't closed :-) path[ip].ty = '}'; diff --git a/src/live_effects/lpe-taperstroke.cpp b/src/live_effects/lpe-taperstroke.cpp index db1d36cbb..cc8e21014 100644 --- a/src/live_effects/lpe-taperstroke.cpp +++ b/src/live_effects/lpe-taperstroke.cpp @@ -405,8 +405,7 @@ Piecewise > stretch_along(Piecewise > pwd2_in, Geom::Path std::vector > > paths_in; paths_in = split_at_discontinuities(pwd2_in); - for (unsigned idx = 0; idx < paths_in.size(); idx++) { - Piecewise > path_i = paths_in[idx]; + for (auto path_i : paths_in) { Piecewise x = x0; Piecewise y = y0; Piecewise > uskeleton = arc_length_parametrization(path_i,2,.1); diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index 640e1b146..adb3d6fd4 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -207,8 +207,8 @@ size_t LPETransform2Pts::nodeCount(Geom::PathVector pathvector) const { size_t n = 0; - for (Geom::PathVector::iterator it = pathvector.begin(); it != pathvector.end(); ++it) { - n += it->size_closed(); + for (auto & it : pathvector) { + n += it.size_closed(); } return n; } @@ -217,8 +217,8 @@ Geom::Point LPETransform2Pts::pointAtNodeIndex(Geom::PathVector pathvector, size_t index) const { size_t n = 0; - for (Geom::PathVector::iterator pv_it = pathvector.begin(); pv_it != pathvector.end(); ++pv_it) { - for (Geom::Path::iterator curve_it = pv_it->begin(); curve_it != pv_it->end_closed(); ++curve_it) { + for (auto & pv_it : pathvector) { + for (Geom::Path::iterator curve_it = pv_it.begin(); curve_it != pv_it.end_closed(); ++curve_it) { if(index == n) { return curve_it->initialPoint(); } @@ -232,10 +232,10 @@ Geom::Path LPETransform2Pts::pathAtNodeIndex(Geom::PathVector pathvector, size_t index) const { size_t n = 0; - for (Geom::PathVector::iterator pv_it = pathvector.begin(); pv_it != pathvector.end(); ++pv_it) { - for (Geom::Path::iterator curve_it = pv_it->begin(); curve_it != pv_it->end_closed(); ++curve_it) { + for (auto & pv_it : pathvector) { + for (Geom::Path::iterator curve_it = pv_it.begin(); curve_it != pv_it.end_closed(); ++curve_it) { if(index == n) { - return *pv_it; + return pv_it; } n++; } diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index f52645849..aa0f46ecc 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -98,18 +98,18 @@ LPEVonKoch::doEffect_path (Geom::PathVector const & path_in) m0 = m0.inverse(); std::vector transforms; - for (unsigned i=0; i=2){ - Point p = generating_path[i].pointAt(1); - Point u = generating_path[i].pointAt(2)-p; - Point v = p-generating_path[i].pointAt(0); + }else if(i.size()>=2){ + Point p = i.pointAt(1); + Point u = i.pointAt(2)-p; + Point v = p-i.pointAt(0); if (similar_only.get_value()){ int sign = (u[X]*v[Y]-u[Y]*v[X]>=0?1:-1); v[X] = -u[Y]*sign; @@ -127,8 +127,8 @@ LPEVonKoch::doEffect_path (Geom::PathVector const & path_in) //Do nothing if the output is too complex... int path_in_complexity = 0; - for (unsigned k = 0; k < path_in.size(); k++){ - path_in_complexity+=path_in[k].size(); + for (const auto & k : path_in){ + path_in_complexity+=k.size(); } double complexity = std::pow(transforms.size(), nbgenerations) * path_in_complexity; if (drawall.get_value()){ @@ -156,9 +156,9 @@ LPEVonKoch::doEffect_path (Geom::PathVector const & path_in) path_out = Geom::PathVector(); complexity = 0; } - for (unsigned j = 0; jhref << "," << ((*iter)->actived ? "1" : "0"); } - for (auto i=itemsid.begin();i!=itemsid.end();++i) { - Glib::ustring itemid = *i; + for (auto itemid : itemsid) { // add '#' at start to make it an uri. itemid.insert(itemid.begin(), '#'); @@ -423,13 +422,13 @@ gchar * OriginalItemArrayParam::param_getSVGValue() const { Inkscape::SVGOStringStream os; bool foundOne = false; - for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { + for (auto iter : _vector) { if (foundOne) { os << "|"; } else { foundOne = true; } - os << (*iter)->href << "," << ((*iter)->actived ? "1" : "0"); + os << iter->href << "," << (iter->actived ? "1" : "0"); } return g_strdup(os.str().c_str()); } @@ -441,9 +440,9 @@ gchar * OriginalItemArrayParam::param_getDefaultSVGValue() const void OriginalItemArrayParam::update() { - for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { - SPObject *linked_obj = (*iter)->ref.getObject(); - linked_modified(linked_obj, SP_OBJECT_MODIFIED_FLAG, *iter); + for (auto & iter : _vector) { + SPObject *linked_obj = iter->ref.getObject(); + linked_modified(linked_obj, SP_OBJECT_MODIFIED_FLAG, iter); } } diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index 21b02cc7c..0f62ed5f9 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -333,8 +333,7 @@ OriginalPathArrayParam::on_link_button_click() } os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0") << "," << ((*iter)->visibled ? "1" : "0"); } - for (auto i=pathsid.begin();i!=pathsid.end();++i) { - Glib::ustring pathid = *i; + for (auto pathid : pathsid) { // add '#' at start to make it an uri. pathid.insert(pathid.begin(), '#'); @@ -512,13 +511,13 @@ gchar * OriginalPathArrayParam::param_getSVGValue() const { Inkscape::SVGOStringStream os; bool foundOne = false; - for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { + for (auto iter : _vector) { if (foundOne) { os << "|"; } else { foundOne = true; } - os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0") << "," << ((*iter)->visibled ? "1" : "0"); + os << iter->href << "," << (iter->reversed ? "1" : "0") << "," << (iter->visibled ? "1" : "0"); } return g_strdup(os.str().c_str()); } @@ -530,9 +529,9 @@ gchar * OriginalPathArrayParam::param_getDefaultSVGValue() const void OriginalPathArrayParam::update() { - for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { - SPObject *linked_obj = (*iter)->ref.getObject(); - linked_modified(linked_obj, SP_OBJECT_MODIFIED_FLAG, *iter); + for (auto & iter : _vector) { + SPObject *linked_obj = iter->ref.getObject(); + linked_modified(linked_obj, SP_OBJECT_MODIFIED_FLAG, iter); } } diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 788c8b288..b8d2f4476 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -385,8 +385,8 @@ PathParam::ensure_pwd2() { if (must_recalculate_pwd2) { _pwd2.clear(); - for (unsigned int i=0; i < _pathvector.size(); i++) { - _pwd2.concat( _pathvector[i].toPwSb() ); + for (const auto & i : _pathvector) { + _pwd2.concat( i.toPwSb() ); } must_recalculate_pwd2 = false; diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 08e17ed93..a39c872cd 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -69,19 +69,19 @@ PowerStrokePointArrayParam::recalculate_controlpoints_for_new_pwd2(Geom::Piecewi if (last_pwd2.size() > pwd2_in.size()) { // Path has become shorter: rescale offsets double factor = (double)pwd2_in.size() / (double)last_pwd2.size(); - for (unsigned int i = 0; i < _vector.size(); ++i) { - _vector[i][Geom::X] *= factor; + for (auto & i : _vector) { + i[Geom::X] *= factor; } } else if (last_pwd2.size() < pwd2_in.size()) { // Path has become longer: probably node added, maintain position of knots Geom::Piecewise > normal = rot90(unitVector(derivative(pwd2_in))); - for (unsigned int i = 0; i < _vector.size(); ++i) { - Geom::Point pt = _vector[i]; + for (auto & i : _vector) { + Geom::Point pt = i; Geom::Point position = last_pwd2.valueAt(pt[Geom::X]) + pt[Geom::Y] * last_pwd2_normal.valueAt(pt[Geom::X]); double t = nearest_time(position, pwd2_in); double offset = dot(position - pwd2_in.valueAt(t), normal.valueAt(t)); - _vector[i] = Geom::Point(t, offset); + i = Geom::Point(t, offset); } } @@ -96,11 +96,11 @@ PowerStrokePointArrayParam::reverse_controlpoints(bool write) std::vector controlpoints; if (!last_pwd2.empty()) { Geom::Piecewise > const & pwd2_in_reverse = reverse(last_pwd2); - for (unsigned int i = 0; i < _vector.size(); ++i) { - Geom::Point control_pos = last_pwd2.valueAt(_vector[i][Geom::X]); + for (auto & i : _vector) { + Geom::Point control_pos = last_pwd2.valueAt(i[Geom::X]); double new_pos = Geom::nearest_time(control_pos, pwd2_in_reverse); - controlpoints.emplace_back(new_pos,_vector[i][Geom::Y]); - _vector[i][Geom::X] = new_pos; + controlpoints.emplace_back(new_pos,i[Geom::Y]); + i[Geom::X] = new_pos; } if (write) { write_to_SVG(); @@ -235,8 +235,8 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) vec.erase(vec.begin() + _index); _pparam->param_set_and_write_new_value(vec); // shift knots down one index - for(std::list::iterator ent = parent_holder->entity.begin(); ent != parent_holder->entity.end(); ++ent) { - PowerStrokePointArrayParamKnotHolderEntity *pspa_ent = dynamic_cast(*ent); + for(auto & ent : parent_holder->entity) { + PowerStrokePointArrayParamKnotHolderEntity *pspa_ent = dynamic_cast(ent); if ( pspa_ent && pspa_ent->_pparam == this->_pparam ) { // check if the knotentity belongs to this powerstrokepointarray parameter if (pspa_ent->_index > this->_index) { --pspa_ent->_index; @@ -254,8 +254,8 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) _pparam->param_set_and_write_new_value(vec); // shift knots up one index - for(std::list::iterator ent = parent_holder->entity.begin(); ent != parent_holder->entity.end(); ++ent) { - PowerStrokePointArrayParamKnotHolderEntity *pspa_ent = dynamic_cast(*ent); + for(auto & ent : parent_holder->entity) { + PowerStrokePointArrayParamKnotHolderEntity *pspa_ent = dynamic_cast(ent); if ( pspa_ent && pspa_ent->_pparam == this->_pparam ) { // check if the knotentity belongs to this powerstrokepointarray parameter if (pspa_ent->_index > this->_index) { ++pspa_ent->_index; diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index aa1644597..a82df2d27 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -158,10 +158,10 @@ void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul, Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/transform/rectcorners", true)) { - for (size_t i = 0; i < _vector.size(); ++i) { - for (size_t j = 0; j < _vector[i].size(); ++j) { - if (!_vector[i][j].is_time && _vector[i][j].amount > 0) { - _vector[i][j].amount = _vector[i][j].amount * ((postmul.expansionX() + postmul.expansionY()) / 2); + for (auto & i : _vector) { + for (size_t j = 0; j < i.size(); ++j) { + if (!i[j].is_time && i[j].amount > 0) { + i[j].amount = i[j].amount * ((postmul.expansionX() + postmul.expansionY()) / 2); } } } diff --git a/src/live_effects/spiro.cpp b/src/live_effects/spiro.cpp index 54bc021c7..4c129bafd 100644 --- a/src/live_effects/spiro.cpp +++ b/src/live_effects/spiro.cpp @@ -672,11 +672,11 @@ spiro_iter(spiro_seg *s, bandmat *m, int *perm, double *v, const int n) for (int i = 0; i < nmat; i++) { v[i] = 0.; - for (int j = 0; j < 11; j++) { - m[i].a[j] = 0.; + for (double & j : m[i].a) { + j = 0.; } - for (int j = 0; j < 5; j++) { - m[i].al[j] = 0.; + for (double & j : m[i].al) { + j = 0.; } } diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index fa050d632..dbe855536 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -92,8 +92,7 @@ CmdLineAction::doIt (ActionContext const & context) { bool CmdLineAction::doList (ActionContext const & context) { bool hasActions = !_list.empty(); - for (std::list::iterator i = _list.begin(); i != _list.end(); ++i) { - CmdLineAction * entry = *i; + for (auto entry : _list) { entry->doIt(context); } return hasActions; @@ -106,9 +105,7 @@ CmdLineAction::idle () { // We're going to assume one desktop per document, because no one // should have had time to make more at this point. - for (std::list::iterator i = desktops.begin(); - i != desktops.end(); ++i) { - SPDesktop * desktop = *i; + for (auto desktop : desktops) { //Inkscape::UI::View::View * view = dynamic_cast(desktop); doList(ActionContext(desktop)); } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 702ef4dd8..bc16a1590 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -588,8 +588,8 @@ bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::ve return false; } - for (std::vector::const_iterator i = unselected_nodes->begin(); i != unselected_nodes->end(); ++i) { - if (Geom::L2(point - (*i).getPoint()) < 1e-4) { + for (const auto & unselected_node : *unselected_nodes) { + if (Geom::L2(point - unselected_node.getPoint()) < 1e-4) { return true; } } @@ -819,9 +819,9 @@ void Inkscape::ObjectSnapper::_snapPathsTangPerp(bool snap_tang, bool snap_perp, // or we need to know the vector of the guide which is currently being translated std::vector > const origins_and_vectors = p.getOriginsAndVectors(); // Now we will iterate over all the origins and vectors and see which of these will get use a tangential or perpendicular snap - for (std::vector >::const_iterator it_origin_or_vector = origins_and_vectors.begin(); it_origin_or_vector != origins_and_vectors.end(); ++it_origin_or_vector) { - Geom::Point origin_or_vector_doc = dt->dt2doc((*it_origin_or_vector).first); // "first" contains a Geom::Point, denoting either a point or vector - if ((*it_origin_or_vector).second) { // if "second" is true then "first" is a vector, otherwise it's a point + for (const auto & origins_and_vector : origins_and_vectors) { + Geom::Point origin_or_vector_doc = dt->dt2doc(origins_and_vector.first); // "first" contains a Geom::Point, denoting either a point or vector + if (origins_and_vector.second) { // if "second" is true then "first" is a vector, otherwise it's a point // So we have a vector, which tells us what tangential or perpendicular direction we're looking for if (curve->degreesOfFreedom() <= 2) { // A LineSegment has order one, and therefore 2 DOF // When snapping to a point of a line segment that has a specific tangential or normal vector, then either all point @@ -839,7 +839,7 @@ void Inkscape::ObjectSnapper::_snapPathsTangPerp(bool snap_tang, bool snap_perp, std::vector ts; if (snap_tang) { // Find all points that lead to a tangential snap - if ((*it_origin_or_vector).second) { // if "second" is true then "first" is a vector, otherwise it's a point + if (origins_and_vector.second) { // if "second" is true then "first" is a vector, otherwise it's a point ts = find_tangents_by_vector(origin_or_vector_doc, curve->toSBasis()); } else { ts = find_tangents(origin_or_vector_doc, curve->toSBasis()); @@ -852,7 +852,7 @@ void Inkscape::ObjectSnapper::_snapPathsTangPerp(bool snap_tang, bool snap_perp, } if (snap_perp) { // Find all points that lead to a perpendicular snap - if ((*it_origin_or_vector).second) { + if (origins_and_vector.second) { ts = find_normals_by_vector(origin_or_vector_doc, curve->toSBasis()); } else { ts = find_normals(origin_or_vector_doc, curve->toSBasis()); diff --git a/src/object/box3d.cpp b/src/object/box3d.cpp index 2de71f686..26ac9de8a 100644 --- a/src/object/box3d.cpp +++ b/src/object/box3d.cpp @@ -49,8 +49,8 @@ SPBox3D::SPBox3D() : SPGroup() { this->persp_ref = new Persp3DReference(this); /* we initialize the z-orders to zero so that they are updated during dragging */ - for (int i = 0; i < 6; ++i) { - z_orders[i] = 0; + for (int & z_order : z_orders) { + z_order = 0; } } @@ -62,8 +62,8 @@ void SPBox3D::build(SPDocument *document, Inkscape::XML::Node *repr) { my_counter = counter++; /* we initialize the z-orders to zero so that they are updated during dragging */ - for (int i = 0; i < 6; ++i) { - z_orders[i] = 0; + for (int & z_order : z_orders) { + z_order = 0; } // TODO: Create/link to the correct perspective @@ -1051,9 +1051,9 @@ box3d_recompute_z_orders (SPBox3D *box) { // TODO: If there are still errors in z-orders of everted boxes, we need to choose a variable corner // instead of the hard-coded corner #3 in the computations above Box3D::Axis ev = box3d_everted_directions(box); - for (int i = 0; i < 3; ++i) { - if (ev & Box3D::axes[i]) { - box3d_swap_sides(z_orders, Box3D::axes[i]); + for (auto & axe : Box3D::axes) { + if (ev & axe) { + box3d_swap_sides(z_orders, axe); } } @@ -1090,8 +1090,8 @@ box3d_set_z_orders (SPBox3D *box) { if (box3d_recompute_z_orders (box)) { std::map sides = box3d_get_sides(box); std::map::iterator side; - for (unsigned int i = 0; i < 6; ++i) { - side = sides.find(box->z_orders[i]); + for (int z_order : box->z_orders) { + side = sides.find(z_order); if (side != sides.end()) { ((*side).second)->lowerToBottom(); } diff --git a/src/object/color-profile.cpp b/src/object/color-profile.cpp index 9cfac23cf..9b7d25d98 100644 --- a/src/object/color-profile.cpp +++ b/src/object/color-profile.cpp @@ -668,9 +668,9 @@ std::vector Inkscape::CMSSystem::getDisplayNames() loadProfiles(); std::vector result; - for ( std::vector::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) { - if ( it->getClass() == cmsSigDisplayClass && it->getSpace() == cmsSigRgbData ) { - result.push_back( it->getName() ); + for (auto & knownProfile : knownProfiles) { + if ( knownProfile.getClass() == cmsSigDisplayClass && knownProfile.getSpace() == cmsSigRgbData ) { + result.push_back( knownProfile.getName() ); } } std::sort(result.begin(), result.end()); @@ -683,9 +683,9 @@ std::vector Inkscape::CMSSystem::getSoftproofNames() loadProfiles(); std::vector result; - for ( std::vector::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) { - if ( it->getClass() == cmsSigOutputClass ) { - result.push_back( it->getName() ); + for (auto & knownProfile : knownProfiles) { + if ( knownProfile.getClass() == cmsSigOutputClass ) { + result.push_back( knownProfile.getName() ); } } std::sort(result.begin(), result.end()); @@ -698,9 +698,9 @@ Glib::ustring Inkscape::CMSSystem::getPathForProfile(Glib::ustring const& name) loadProfiles(); Glib::ustring result; - for ( std::vector::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) { - if ( name == it->getName() ) { - result = it->getPath(); + for (auto & knownProfile : knownProfiles) { + if ( name == knownProfile.getName() ) { + result = knownProfile.getPath(); break; } } diff --git a/src/object/filters/convolvematrix.cpp b/src/object/filters/convolvematrix.cpp index 5310db738..9b299b243 100644 --- a/src/object/filters/convolvematrix.cpp +++ b/src/object/filters/convolvematrix.cpp @@ -137,8 +137,8 @@ void SPFeConvolveMatrix::set(SPAttributeEnum key, gchar const *value) { if (! this->divisorIsSet) { this->divisor = 0; - for (unsigned int i = 0; i< this->kernelMatrix.size(); i++) { - this->divisor += this->kernelMatrix[i]; + for (double i : this->kernelMatrix) { + this->divisor += i; } if (this->divisor == 0) { @@ -158,8 +158,8 @@ void SPFeConvolveMatrix::set(SPAttributeEnum key, gchar const *value) { if (read_num == 0) { // This should actually be an error, but given our UI it is more useful to simply set divisor to the default. if (this->kernelMatrixIsSet) { - for (unsigned int i = 0; i< this->kernelMatrix.size(); i++) { - read_num += this->kernelMatrix[i]; + for (double i : this->kernelMatrix) { + read_num += i; } } diff --git a/src/object/object-set.cpp b/src/object/object-set.cpp index aebd0804b..bf41bb092 100644 --- a/src/object/object-set.cpp +++ b/src/object/object-set.cpp @@ -333,8 +333,8 @@ boost::optional ObjectSet::center() const { std::list const ObjectSet::perspList() { std::list pl; - for (std::list::iterator i = _3dboxes.begin(); i != _3dboxes.end(); ++i) { - Persp3D *persp = box3d_get_perspective(*i); + for (auto & _3dboxe : _3dboxes) { + Persp3D *persp = box3d_get_perspective(_3dboxe); if (std::find(pl.begin(), pl.end(), persp) == pl.end()) pl.push_back(persp); } @@ -344,8 +344,7 @@ std::list const ObjectSet::perspList() { std::list const ObjectSet::box3DList(Persp3D *persp) { std::list boxes; if (persp) { - for (std::list::iterator i = _3dboxes.begin(); i != _3dboxes.end(); ++i) { - SPBox3D *box = *i; + for (auto box : _3dboxes) { if (persp == box3d_get_perspective(box)) { boxes.push_back(box); } @@ -359,8 +358,7 @@ std::list const ObjectSet::box3DList(Persp3D *persp) { void ObjectSet::_add3DBoxesRecursively(SPObject *obj) { std::list boxes = box3d_extract_boxes(obj); - for (std::list::iterator i = boxes.begin(); i != boxes.end(); ++i) { - SPBox3D *box = *i; + for (auto box : boxes) { _3dboxes.push_back(box); } } @@ -368,8 +366,7 @@ void ObjectSet::_add3DBoxesRecursively(SPObject *obj) { void ObjectSet::_remove3DBoxesRecursively(SPObject *obj) { std::list boxes = box3d_extract_boxes(obj); - for (std::list::iterator i = boxes.begin(); i != boxes.end(); ++i) { - SPBox3D *box = *i; + for (auto box : boxes) { std::list::iterator b = std::find(_3dboxes.begin(), _3dboxes.end(), box); if (b == _3dboxes.end()) { g_print ("Warning! Trying to remove unselected box from selection.\n"); diff --git a/src/object/persp3d.cpp b/src/object/persp3d.cpp index fa6196a46..3646f2df1 100644 --- a/src/object/persp3d.cpp +++ b/src/object/persp3d.cpp @@ -357,8 +357,8 @@ persp3d_toggle_VP (Persp3D *persp, Proj::Axis axis, bool set_undo) { /* toggle VPs for the same axis in all perspectives of a given list */ void persp3d_toggle_VPs (std::list p, Proj::Axis axis) { - for (std::list::iterator i = p.begin(); i != p.end(); ++i) { - persp3d_toggle_VP((*i), axis, false); + for (auto & i : p) { + persp3d_toggle_VP(i, axis, false); } DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_CONTEXT_3DBOX, _("Toggle multiple vanishing points")); @@ -423,8 +423,8 @@ persp3d_has_box (Persp3D *persp, SPBox3D *box) { // FIXME: For some reason, std::find() does not seem to compare pointers "correctly" (or do we need to // provide a proper comparison function?), so we manually traverse the list. - for (std::vector::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) { - if ((*i) == box) { + for (auto & boxe : persp_impl->boxes) { + if (boxe == box) { return true; } } @@ -437,8 +437,8 @@ persp3d_update_box_displays (Persp3D *persp) { if (persp_impl->boxes.empty()) return; - for (std::vector::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) { - box3d_position_set(*i); + for (auto & boxe : persp_impl->boxes) { + box3d_position_set(boxe); } } @@ -452,9 +452,9 @@ persp3d_update_box_reprs (Persp3D *persp) { if (persp_impl->boxes.empty()) return; - for (std::vector::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) { - (*i)->updateRepr(SP_OBJECT_WRITE_EXT); - box3d_set_z_orders(*i); + for (auto & boxe : persp_impl->boxes) { + boxe->updateRepr(SP_OBJECT_WRITE_EXT); + box3d_set_z_orders(boxe); } } @@ -464,8 +464,8 @@ persp3d_update_z_orders (Persp3D *persp) { if (persp_impl->boxes.empty()) return; - for (std::vector::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) { - box3d_set_z_orders(*i); + for (auto & boxe : persp_impl->boxes) { + box3d_set_z_orders(boxe); } } @@ -477,8 +477,8 @@ persp3d_list_of_boxes(Persp3D *persp) { Persp3DImpl *persp_impl = persp->perspective_impl; std::list bx_lst; - for (std::vector::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) { - bx_lst.push_back(*i); + for (auto & boxe : persp_impl->boxes) { + bx_lst.push_back(boxe); } return bx_lst; } @@ -500,9 +500,9 @@ persp3d_absorb(Persp3D *persp1, Persp3D *persp2) { // otherwise the loop below gets confused when perspectives are reattached. std::list boxes_of_persp2 = persp3d_list_of_boxes(persp2); - for (std::list::iterator i = boxes_of_persp2.begin(); i != boxes_of_persp2.end(); ++i) { - box3d_switch_perspectives((*i), persp2, persp1, true); - (*i)->updateRepr(SP_OBJECT_WRITE_EXT); // so that undo/redo can do its job properly + for (auto & i : boxes_of_persp2) { + box3d_switch_perspectives(i, persp2, persp1, true); + i->updateRepr(SP_OBJECT_WRITE_EXT); // so that undo/redo can do its job properly } } @@ -528,8 +528,8 @@ persp3d_has_all_boxes_in_selection (Persp3D *persp, Inkscape::ObjectSet *set) { std::list selboxes = set->box3DList(); - for (std::vector::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) { - if (std::find(selboxes.begin(), selboxes.end(), *i) == selboxes.end()) { + for (auto & boxe : persp_impl->boxes) { + if (std::find(selboxes.begin(), selboxes.end(), boxe) == selboxes.end()) { // we have an unselected box in the perspective return false; } @@ -544,9 +544,9 @@ persp3d_print_debugging_info (Persp3D *persp) { Persp3DImpl *persp_impl = persp->perspective_impl; g_print ("=== Info for Persp3D %d ===\n", persp_impl->my_counter); gchar * cstr; - for (int i = 0; i < 4; ++i) { - cstr = persp3d_get_VP(persp, Proj::axes[i]).coord_string(); - g_print (" VP %s: %s\n", Proj::string_from_axis(Proj::axes[i]), cstr); + for (auto & axe : Proj::axes) { + cstr = persp3d_get_VP(persp, axe).coord_string(); + g_print (" VP %s: %s\n", Proj::string_from_axis(axe), cstr); g_free(cstr); } cstr = persp3d_get_VP(persp, Proj::W).coord_string(); @@ -554,8 +554,8 @@ persp3d_print_debugging_info (Persp3D *persp) { g_free(cstr); g_print (" Boxes: "); - for (std::vector::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) { - g_print ("%d (%d) ", (*i)->my_counter, box3d_get_perspective(*i)->perspective_impl->my_counter); + for (auto & boxe : persp_impl->boxes) { + g_print ("%d (%d) ", boxe->my_counter, box3d_get_perspective(boxe)->perspective_impl->my_counter); } g_print ("\n"); g_print ("========================\n"); @@ -578,13 +578,12 @@ persp3d_print_all_selected() { std::list sel_persps = SP_ACTIVE_DESKTOP->getSelection()->perspList(); - for (std::list::iterator j = sel_persps.begin(); j != sel_persps.end(); ++j) { - Persp3D *persp = SP_PERSP3D(*j); + for (auto & sel_persp : sel_persps) { + Persp3D *persp = SP_PERSP3D(sel_persp); Persp3DImpl *persp_impl = persp->perspective_impl; g_print (" %s (%d): ", persp->getRepr()->attribute("id"), persp->perspective_impl->my_counter); - for (std::vector::iterator i = persp_impl->boxes.begin(); - i != persp_impl->boxes.end(); ++i) { - g_print ("%d ", (*i)->my_counter); + for (auto & boxe : persp_impl->boxes) { + g_print ("%d ", boxe->my_counter); } g_print ("\n"); } diff --git a/src/object/sp-conn-end-pair.cpp b/src/object/sp-conn-end-pair.cpp index a47736129..2f60e9a9e 100644 --- a/src/object/sp-conn-end-pair.cpp +++ b/src/object/sp-conn-end-pair.cpp @@ -45,21 +45,21 @@ SPConnEndPair::SPConnEndPair(SPPath *const owner) SPConnEndPair::~SPConnEndPair() { - for (unsigned handle_ix = 0; handle_ix < 2; ++handle_ix) { - delete this->_connEnd[handle_ix]; - this->_connEnd[handle_ix] = nullptr; + for (auto & handle_ix : this->_connEnd) { + delete handle_ix; + handle_ix = nullptr; } } void SPConnEndPair::release() { - for (unsigned handle_ix = 0; handle_ix < 2; ++handle_ix) { - this->_connEnd[handle_ix]->_changed_connection.disconnect(); - this->_connEnd[handle_ix]->_delete_connection.disconnect(); - this->_connEnd[handle_ix]->_transformed_connection.disconnect(); - g_free(this->_connEnd[handle_ix]->href); - this->_connEnd[handle_ix]->href = nullptr; - this->_connEnd[handle_ix]->ref.detach(); + for (auto & handle_ix : this->_connEnd) { + handle_ix->_changed_connection.disconnect(); + handle_ix->_delete_connection.disconnect(); + handle_ix->_transformed_connection.disconnect(); + g_free(handle_ix->href); + handle_ix->href = nullptr; + handle_ix->ref.detach(); } // If the document is being destroyed then the router instance diff --git a/src/object/sp-conn-end.cpp b/src/object/sp-conn-end.cpp index 90e6f4039..dab25bfc0 100644 --- a/src/object/sp-conn-end.cpp +++ b/src/object/sp-conn-end.cpp @@ -87,8 +87,7 @@ static bool try_get_intersect_point_with_item_recursive(Geom::PathVector& conn_p for (Geom::CrossingSet::const_iterator i = cross.begin(); i != cross.end(); ++i) { const Geom::Crossings& cr = *i; - for (Geom::Crossings::const_iterator i = cr.begin(); i != cr.end(); ++i) { - const Geom::Crossing& cr_pt = *i; + for (const auto & cr_pt : cr) { if ( intersect_pos < cr_pt.ta) intersect_pos = cr_pt.ta; } diff --git a/src/object/sp-flowregion.cpp b/src/object/sp-flowregion.cpp index c7e6a0422..f1accf2ad 100644 --- a/src/object/sp-flowregion.cpp +++ b/src/object/sp-flowregion.cpp @@ -35,8 +35,8 @@ SPFlowregion::SPFlowregion() : SPItem() { } SPFlowregion::~SPFlowregion() { - for (std::vector::iterator it = this->computed.begin() ; it != this->computed.end() ; ++it) { - delete *it; + for (auto & it : this->computed) { + delete it; } } @@ -97,8 +97,8 @@ void SPFlowregion::update(SPCtx *ctx, unsigned int flags) { void SPFlowregion::UpdateComputed() { - for (std::vector::iterator it = computed.begin() ; it != computed.end() ; ++it) { - delete *it; + for (auto & it : computed) { + delete it; } computed.clear(); diff --git a/src/object/sp-flowtext.cpp b/src/object/sp-flowtext.cpp index 1cfe39361..0db7ab192 100644 --- a/src/object/sp-flowtext.cpp +++ b/src/object/sp-flowtext.cpp @@ -406,12 +406,12 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, SPFlowregion *region = dynamic_cast(&child); if (region) { std::vector const &computed = region->computed; - for (std::vector::const_iterator it = computed.begin() ; it != computed.end() ; ++it) { + for (auto it : computed) { shapes->push_back(Shape()); if (exclusion_shape->hasEdges()) { - shapes->back().Booleen(*it, const_cast(exclusion_shape), bool_op_diff); + shapes->back().Booleen(it, const_cast(exclusion_shape), bool_op_diff); } else { - shapes->back().Copy(*it); + shapes->back().Copy(it); } layout.appendWrapShape(&shapes->back()); } diff --git a/src/object/sp-gradient.cpp b/src/object/sp-gradient.cpp index eb9b551cb..97d29aead 100644 --- a/src/object/sp-gradient.cpp +++ b/src/object/sp-gradient.cpp @@ -896,13 +896,13 @@ SPGradient::repr_write_vector() /* We have to be careful, as vector may be our own, so construct repr list at first */ std::vector l; - for (guint i = 0; i < vector.stops.size(); i++) { + for (auto & stop : vector.stops) { Inkscape::CSSOStringStream os; Inkscape::XML::Node *child = xml_doc->createElement("svg:stop"); - sp_repr_set_css_double(child, "offset", vector.stops[i].offset); + sp_repr_set_css_double(child, "offset", stop.offset); /* strictly speaking, offset an SVG rather than a CSS one, but exponents make no * sense for offset proportions. */ - os << "stop-color:" << vector.stops[i].color.toString() << ";stop-opacity:" << vector.stops[i].opacity; + os << "stop-color:" << stop.color.toString() << ";stop-opacity:" << stop.opacity; child->setAttribute("style", os.str().c_str()); /* Order will be reversed here */ l.push_back(child); @@ -1134,12 +1134,11 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp, // add stops if (!SP_IS_MESHGRADIENT(gr)) { - for (std::vector::iterator i = gr->vector.stops.begin(); - i != gr->vector.stops.end(); ++i) + for (auto & stop : gr->vector.stops) { // multiply stop opacity by paint opacity - cairo_pattern_add_color_stop_rgba(cp, i->offset, - i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity * opacity); + cairo_pattern_add_color_stop_rgba(cp, stop.offset, + stop.color.v.c[0], stop.color.v.c[1], stop.color.v.c[2], stop.opacity * opacity); } } @@ -1162,11 +1161,10 @@ SPGradient::create_preview_pattern(double width) pat = cairo_pattern_create_linear(0, 0, width, 0); - for (std::vector::iterator i = vector.stops.begin(); - i != vector.stops.end(); ++i) + for (auto & stop : vector.stops) { - cairo_pattern_add_color_stop_rgba(pat, i->offset, - i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity); + cairo_pattern_add_color_stop_rgba(pat, stop.offset, + stop.color.v.c[0], stop.color.v.c[1], stop.color.v.c[2], stop.opacity); } } else { diff --git a/src/object/sp-guide.cpp b/src/object/sp-guide.cpp index e569a9878..3ed107b81 100644 --- a/src/object/sp-guide.cpp +++ b/src/object/sp-guide.cpp @@ -249,8 +249,8 @@ SPGuide *SPGuide::createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::P void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list > &pts) { - for (std::list >::iterator i = pts.begin(); i != pts.end(); ++i) { - SPGuide::createSPGuide(doc, (*i).first, (*i).second); + for (auto & pt : pts) { + SPGuide::createSPGuide(doc, pt.first, pt.second); } } diff --git a/src/object/sp-hatch-path.cpp b/src/object/sp-hatch-path.cpp index c2fbc7ed0..2b04ef7cf 100644 --- a/src/object/sp-hatch-path.cpp +++ b/src/object/sp-hatch-path.cpp @@ -71,9 +71,9 @@ void SPHatchPath::build(SPDocument* doc, Inkscape::XML::Node* repr) void SPHatchPath::release() { - for (ViewIterator iter = _display.begin(); iter != _display.end(); ++iter) { - delete iter->arenaitem; - iter->arenaitem = nullptr; + for (auto & iter : _display) { + delete iter.arenaitem; + iter.arenaitem = nullptr; } SPObject::release(); @@ -130,15 +130,15 @@ void SPHatchPath::update(SPCtx* ctx, unsigned int flags) double const aw = (ictx) ? 1.0 / ictx->i2vp.descrim() : 1.0; style->stroke_width.computed = style->stroke_width.value * aw; - for (ViewIterator iter = _display.begin(); iter != _display.end(); ++iter) { - iter->arenaitem->setStyle(style); + for (auto & iter : _display) { + iter.arenaitem->setStyle(style); } } } if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG)) { - for (ViewIterator iter = _display.begin(); iter != _display.end(); ++iter) { - _updateView(*iter); + for (auto & iter : _display) { + _updateView(iter); } } } @@ -178,9 +178,9 @@ void SPHatchPath::hide(unsigned int key) void SPHatchPath::setStripExtents(unsigned int key, Geom::OptInterval const &extents) { - for (ViewIterator iter = _display.begin(); iter != _display.end(); ++iter) { - if (iter->key == key) { - iter->extents = extents; + for (auto & iter : _display) { + if (iter.key == key) { + iter.extents = extents; break; } } @@ -209,9 +209,9 @@ Geom::Interval SPHatchPath::bounds() const SPCurve *SPHatchPath::calculateRenderCurve(unsigned key) const { - for (ConstViewIterator iter = _display.begin(); iter != _display.end(); ++iter) { - if (iter->key == key) { - return _calculateRenderCurve(*iter); + for (const auto & iter : _display) { + if (iter.key == key) { + return _calculateRenderCurve(iter); } } g_assert_not_reached(); diff --git a/src/object/sp-hatch.cpp b/src/object/sp-hatch.cpp index 3ed0e7072..ae91b4dd2 100644 --- a/src/object/sp-hatch.cpp +++ b/src/object/sp-hatch.cpp @@ -90,13 +90,12 @@ void SPHatch::release() } std::vector children(hatchPaths()); - for (ViewIterator view_iter = _display.begin(); view_iter != _display.end(); ++view_iter) { - for (ChildIterator child_iter = children.begin(); child_iter != children.end(); ++child_iter) { - SPHatchPath *child = *child_iter; - child->hide(view_iter->key); + for (auto & view_iter : _display) { + for (auto child : children) { + child->hide(view_iter.key); } - delete view_iter->arenaitem; - view_iter->arenaitem = nullptr; + delete view_iter.arenaitem; + view_iter.arenaitem = nullptr; } if (ref) { @@ -116,13 +115,13 @@ void SPHatch::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) SPHatchPath *path_child = dynamic_cast(document->getObjectByRepr(child)); if (path_child) { - for (ViewIterator iter = _display.begin(); iter != _display.end(); ++iter) { - Geom::OptInterval extents = _calculateStripExtents(iter->bbox); - Inkscape::DrawingItem *ac = path_child->show(iter->arenaitem->drawing(), iter->key, extents); + for (auto & iter : _display) { + Geom::OptInterval extents = _calculateStripExtents(iter.bbox); + Inkscape::DrawingItem *ac = path_child->show(iter.arenaitem->drawing(), iter.key, extents); path_child->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); if (ac) { - iter->arenaitem->prependChild(ac); + iter.arenaitem->prependChild(ac); } } } @@ -292,14 +291,12 @@ void SPHatch::update(SPCtx* ctx, unsigned int flags) std::vector children(hatchPaths()); - for (ChildIterator iter = children.begin(); iter != children.end(); ++iter) { - SPHatchPath* child = *iter; - + for (auto child : children) { sp_object_ref(child, nullptr); - for (ViewIterator view_iter = _display.begin(); view_iter != _display.end(); ++view_iter) { - Geom::OptInterval strip_extents = _calculateStripExtents(view_iter->bbox); - child->setStripExtents(view_iter->key, strip_extents); + for (auto & view_iter : _display) { + Geom::OptInterval strip_extents = _calculateStripExtents(view_iter.bbox); + child->setStripExtents(view_iter.key, strip_extents); } if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { @@ -310,8 +307,8 @@ void SPHatch::update(SPCtx* ctx, unsigned int flags) sp_object_unref(child, nullptr); } - for (ViewIterator iter = _display.begin(); iter != _display.end(); ++iter) { - _updateView(*iter); + for (auto & iter : _display) { + _updateView(iter); } } @@ -325,9 +322,7 @@ void SPHatch::modified(unsigned int flags) std::vector children(hatchPaths()); - for (ChildIterator iter = children.begin(); iter != children.end(); ++iter) { - SPObject *child = *iter; - + for (auto child : children) { sp_object_ref(child, nullptr); if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { @@ -368,19 +363,17 @@ void SPHatch::_onRefChanged(SPObject *old_ref, SPObject *ref) } if (old_shown != new_shown) { - for (ViewIterator iter = _display.begin(); iter != _display.end(); ++iter) { - Geom::OptInterval extents = _calculateStripExtents(iter->bbox); + for (auto & iter : _display) { + Geom::OptInterval extents = _calculateStripExtents(iter.bbox); - for (ChildIterator child_iter = oldhatchPaths.begin(); child_iter != oldhatchPaths.end(); ++child_iter) { - SPHatchPath *child = *child_iter; - child->hide(iter->key); + for (auto child : oldhatchPaths) { + child->hide(iter.key); } - for (ChildIterator child_iter = newhatchPaths.begin(); child_iter != newhatchPaths.end(); ++child_iter) { - SPHatchPath *child = *child_iter; - Inkscape::DrawingItem *cai = child->show(iter->arenaitem->drawing(), iter->key, extents); + for (auto child : newhatchPaths) { + Inkscape::DrawingItem *cai = child->show(iter.arenaitem->drawing(), iter.key, extents); child->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); if (cai) { - iter->arenaitem->appendChild(cai); + iter.arenaitem->appendChild(cai); } } @@ -517,8 +510,7 @@ Inkscape::DrawingPattern *SPHatch::show(Inkscape::Drawing &drawing, unsigned int std::vector children(hatchPaths()); Geom::OptInterval extents = _calculateStripExtents(bbox); - for (ChildIterator iter = children.begin(); iter != children.end(); ++iter) { - SPHatchPath *child = *iter; + for (auto child : children) { Inkscape::DrawingItem *cai = child->show(drawing, key, extents); if (cai) { ai->appendChild(cai); @@ -535,8 +527,7 @@ void SPHatch::hide(unsigned int key) { std::vector children(hatchPaths()); - for (ChildIterator iter = children.begin(); iter != children.end(); ++iter) { - SPHatchPath *child = *iter; + for (auto child : children) { child->hide(key); } @@ -571,9 +562,9 @@ Geom::Interval SPHatch::bounds() const SPHatch::RenderInfo SPHatch::calculateRenderInfo(unsigned key) const { RenderInfo info; - for (ConstViewIterator iter = _display.begin(); iter != _display.end(); ++iter) { - if (iter->key == key) { - return _calculateRenderInfo(*iter); + for (const auto & iter : _display) { + if (iter.key == key) { + return _calculateRenderInfo(iter); } } g_assert_not_reached(); @@ -703,9 +694,9 @@ cairo_pattern_t* SPHatch::pattern_new(cairo_t * /*base_ct*/, Geom::OptRect const void SPHatch::setBBox(unsigned int key, Geom::OptRect const &bbox) { - for (ViewIterator iter = _display.begin(); iter != _display.end(); ++iter) { - if (iter->key == key) { - iter->bbox = bbox; + for (auto & iter : _display) { + if (iter.key == key) { + iter.bbox = bbox; break; } } diff --git a/src/object/sp-item-group.cpp b/src/object/sp-item-group.cpp index fead94274..c6b6f7340 100644 --- a/src/object/sp-item-group.cpp +++ b/src/object/sp-item-group.cpp @@ -896,8 +896,7 @@ void SPGroup::update_patheffect(bool write) { #endif std::vector const item_list = sp_item_group_item_list(this); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - SPObject *sub_item = *iter; + for (auto sub_item : item_list) { if (sub_item) { SPLPEItem *lpe_item = dynamic_cast(sub_item); if (lpe_item) { @@ -908,9 +907,9 @@ void SPGroup::update_patheffect(bool write) { this->resetClipPathAndMaskLPE(); if (hasPathEffect() && pathEffectsEnabled()) { - for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) + for (auto & it : *this->path_effect_list) { - LivePathEffectObject *lpeobj = (*it)->lpeobject; + LivePathEffectObject *lpeobj = it->lpeobject; if (lpeobj) { Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe(); if (lpe) { @@ -927,8 +926,7 @@ static void sp_group_perform_patheffect(SPGroup *group, SPGroup *top_group, Inkscape::LivePathEffect::Effect *lpe, bool write) { std::vector const item_list = sp_item_group_item_list(group); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - SPObject *sub_item = *iter; + for (auto sub_item : item_list) { SPGroup *sub_group = dynamic_cast(sub_item); if (sub_group) { sp_group_perform_patheffect(sub_group, top_group, lpe, write); diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp index cbfd126f9..5157ff7eb 100644 --- a/src/object/sp-item.cpp +++ b/src/object/sp-item.cpp @@ -1298,9 +1298,9 @@ void SPItem::adjust_stroke( gdouble ex ) style->stroke_width.set = TRUE; if ( !style->stroke_dasharray.values.empty() ) { - for (unsigned i = 0; i < style->stroke_dasharray.values.size(); i++) { - style->stroke_dasharray.values[i].value *= ex; - style->stroke_dasharray.values[i].computed *= ex; + for (auto & value : style->stroke_dasharray.values) { + value.value *= ex; + value.computed *= ex; } style->stroke_dashoffset.value *= ex; style->stroke_dashoffset.computed *= ex; diff --git a/src/object/sp-lpe-item.cpp b/src/object/sp-lpe-item.cpp index 47296cc06..f3dd5f05b 100755 --- a/src/object/sp-lpe-item.cpp +++ b/src/object/sp-lpe-item.cpp @@ -76,10 +76,9 @@ void SPLPEItem::build(SPDocument *document, Inkscape::XML::Node *repr) { void SPLPEItem::release() { // disconnect all modified listeners: - for (std::list::iterator mod_it = this->lpe_modified_connection_list->begin(); - mod_it != this->lpe_modified_connection_list->end(); ++mod_it) + for (auto & mod_it : *this->lpe_modified_connection_list) { - mod_it->disconnect(); + mod_it.disconnect(); } delete this->lpe_modified_connection_list; @@ -103,11 +102,9 @@ void SPLPEItem::set(SPAttributeEnum key, gchar const* value) { sp_lpe_item_enable_path_effects(this, false); // disconnect all modified listeners: - for ( std::list::iterator mod_it = this->lpe_modified_connection_list->begin(); - mod_it != this->lpe_modified_connection_list->end(); - ++mod_it) + for (auto & mod_it : *this->lpe_modified_connection_list) { - mod_it->disconnect(); + mod_it.disconnect(); } this->lpe_modified_connection_list->clear(); @@ -199,9 +196,9 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip if (this->hasPathEffect() && this->pathEffectsEnabled()) { size_t path_effect_list_size = this->path_effect_list->size(); - for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) + for (auto & it : *this->path_effect_list) { - LivePathEffectObject *lpeobj = (*it)->lpeobject; + LivePathEffectObject *lpeobj = it->lpeobject; if (!lpeobj) { /** \todo Investigate the cause of this. * For example, this happens when copy pasting an object with LPE applied. Probably because the object is pasted while the effect is not yet pasted to defs, and cannot be found. @@ -749,9 +746,9 @@ bool SPLPEItem::hasPathEffectOnClipOrMask(SPLPEItem * shape) const return false; } - for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) + for (auto & it : *this->path_effect_list) { - LivePathEffectObject *lpeobj = (*it)->lpeobject; + LivePathEffectObject *lpeobj = it->lpeobject; if (!lpeobj) { continue; } @@ -1044,9 +1041,9 @@ static std::string patheffectlist_svg_string(PathEffectList const & list) { HRefList hreflist; - for (PathEffectList::const_iterator it = list.begin(); it != list.end(); ++it) + for (auto it : list) { - hreflist.push_back( std::string((*it)->lpeobject_href) ); // C++11: use emplace_back + hreflist.push_back( std::string(it->lpeobject_href) ); // C++11: use emplace_back } return hreflist_svg_string(hreflist); @@ -1064,7 +1061,7 @@ static std::string hreflist_svg_string(HRefList const & list) std::string r; bool semicolon_first = false; - for (HRefList::const_iterator it = list.begin(); it != list.end(); ++it) + for (const auto & it : list) { if (semicolon_first) { r += ';'; @@ -1072,7 +1069,7 @@ static std::string hreflist_svg_string(HRefList const & list) semicolon_first = true; - r += (*it); + r += it; } return r; @@ -1111,9 +1108,9 @@ Inkscape::LivePathEffect::Effect* SPLPEItem::getCurrentLPE() bool SPLPEItem::setCurrentPathEffect(Inkscape::LivePathEffect::LPEObjectReference* lperef) { - for (PathEffectList::iterator it = path_effect_list->begin(); it != path_effect_list->end(); ++it) { - if ((*it)->lpeobject_repr == lperef->lpeobject_repr) { - this->current_path_effect = (*it); // current_path_effect should always be a pointer from the path_effect_list ! + for (auto & it : *path_effect_list) { + if (it->lpeobject_repr == lperef->lpeobject_repr) { + this->current_path_effect = it; // current_path_effect should always be a pointer from the path_effect_list ! return true; } } @@ -1170,9 +1167,9 @@ bool SPLPEItem::forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users) std::vector old_lpeobjs, new_lpeobjs; PathEffectList effect_list = this->getEffectList(); - for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it) + for (auto & it : effect_list) { - LivePathEffectObject *lpeobj = (*it)->lpeobject; + LivePathEffectObject *lpeobj = it->lpeobject; if (lpeobj) { LivePathEffectObject *forked_lpeobj = lpeobj->fork_private_if_necessary(nr_of_allowed_users); if (forked_lpeobj != lpeobj) { diff --git a/src/object/sp-marker.cpp b/src/object/sp-marker.cpp index a29179c30..22d06a247 100644 --- a/src/object/sp-marker.cpp +++ b/src/object/sp-marker.cpp @@ -36,8 +36,8 @@ public: SPMarkerView() = default;; ~SPMarkerView() { - for (unsigned int i = 0; i < items.size(); ++i) { - delete items[i]; + for (auto & item : items) { + delete item; } items.clear(); } @@ -218,9 +218,9 @@ void SPMarker::update(SPCtx *ctx, guint flags) { // As last step set additional transform of drawing group std::map::iterator it; for (it = views_map.begin(); it != views_map.end(); ++it) { - for (unsigned i = 0 ; i < it->second.items.size() ; ++i) { - if (it->second.items[i]) { - Inkscape::DrawingGroup *g = dynamic_cast(it->second.items[i]); + for (auto & item : it->second.items) { + if (item) { + Inkscape::DrawingGroup *g = dynamic_cast(item); g->setChildTransform(this->c2p); } } diff --git a/src/object/sp-mesh-array.cpp b/src/object/sp-mesh-array.cpp index 231af48ff..6d3826567 100644 --- a/src/object/sp-mesh-array.cpp +++ b/src/object/sp-mesh-array.cpp @@ -897,8 +897,8 @@ bool SPMeshNodeArray::read( SPMeshGradient *mg_in ) { } // Insure we have a true array. - for( guint i = 0; i < nodes.size(); ++i ) { - nodes[ i ].resize( max_column * 3 + 1 ); + for(auto & node : nodes) { + node.resize( max_column * 3 + 1 ); } // Set node edge. @@ -1459,10 +1459,10 @@ void SPMeshNodeArray::create( SPMeshGradient *mg, SPItem *item, Geom::OptRect bb */ void SPMeshNodeArray::clear() { - for( guint i = 0; i < nodes.size(); ++i ) { - for( guint j = 0; j < nodes[i].size(); ++j ) { - if( nodes[i][j] ) { - delete nodes[i][j]; + for(auto & node : nodes) { + for( guint j = 0; j < node.size(); ++j ) { + if( node[j] ) { + delete node[j]; } } } @@ -1514,9 +1514,9 @@ class SPMeshSmoothCorner { public: SPMeshSmoothCorner() { - for( unsigned i = 0; i < 3; ++i ) { + for(auto & i : g) { for( unsigned j = 0; j < 4; ++j ) { - g[i][j] = 0; + i[j] = 0; } } } @@ -2143,9 +2143,8 @@ guint SPMeshNodeArray::color_smooth( std::vector corners ) { guint ncols = patch_columns() * 3 + 1; guint nrows = patch_rows() * 3 + 1; - for( guint i = 0; i < corners.size(); ++i ) { + for(unsigned int corner : corners) { - guint corner = corners[i]; // std::cout << "SPMeshNodeArray::color_smooth: " << i << " " << corner << std::endl; // Node row & col @@ -2319,9 +2318,7 @@ guint SPMeshNodeArray::color_pick( std::vector icorners, SPItem* item ) { // } // Do picking - for( guint i = 0; i < icorners.size(); ++i ) { - - guint corner = icorners[i]; + for(unsigned int corner : icorners) { SPMeshNode* n = corners[ corner ]; @@ -2788,8 +2785,8 @@ SPCurve * SPMeshNodeArray::outline_path() { void SPMeshNodeArray::transform(Geom::Affine const &m) { for (int i = 0; i < nodes[0].size(); ++i) { - for (int j = 0; j < nodes.size(); ++j) { - nodes[j][i]->p *= m; + for (auto & node : nodes) { + node[i]->p *= m; } } } diff --git a/src/object/sp-namedview.cpp b/src/object/sp-namedview.cpp index 3af242eee..cc1e185a8 100644 --- a/src/object/sp-namedview.cpp +++ b/src/object/sp-namedview.cpp @@ -910,8 +910,8 @@ void SPNamedView::hide(SPDesktop const *desktop) { g_assert(desktop != nullptr); g_assert(std::find(views.begin(),views.end(),desktop)!=views.end()); - for(std::vector::iterator it=this->guides.begin();it!=this->guides.end();++it ) { - (*it)->hideSPGuide(desktop->getCanvas()); + for(auto & guide : this->guides) { + guide->hideSPGuide(desktop->getCanvas()); } views.erase(std::remove(views.begin(),views.end(),desktop),views.end()); } @@ -922,8 +922,8 @@ void SPNamedView::activateGuides(void* desktop, bool active) g_assert(std::find(views.begin(),views.end(),desktop)!=views.end()); SPDesktop *dt = static_cast(desktop); - for(std::vector::iterator it=this->guides.begin();it!=this->guides.end();++it ) { - (*it)->sensitize(dt->getCanvas(), active); + for(auto & guide : this->guides) { + guide->sensitize(dt->getCanvas(), active); } } @@ -1166,8 +1166,8 @@ Inkscape::CanvasGrid * sp_namedview_get_first_enabled_grid(SPNamedView *namedvie } void SPNamedView::translateGuides(Geom::Translate const &tr) { - for(std::vector::iterator it=this->guides.begin();it!=this->guides.end();++it ) { - SPGuide &guide = *(*it); + for(auto & it : this->guides) { + SPGuide &guide = *it; Geom::Point point_on_line = guide.getPoint(); point_on_line *= tr; guide.moveto(point_on_line, true); @@ -1175,14 +1175,14 @@ void SPNamedView::translateGuides(Geom::Translate const &tr) { } void SPNamedView::translateGrids(Geom::Translate const &tr) { - for(std::vector::iterator it=this->grids.begin();it!=this->grids.end();++it ) { - (*it)->setOrigin((*it)->origin * tr); + for(auto & grid : this->grids) { + grid->setOrigin(grid->origin * tr); } } void SPNamedView::scrollAllDesktops(double dx, double dy, bool is_scrolling) { - for(std::vector::iterator it=this->views.begin();it!=this->views.end();++it ) { - (*it)->scroll_relative_in_svg_coords(dx, dy, is_scrolling); + for(auto & view : this->views) { + view->scroll_relative_in_svg_coords(dx, dy, is_scrolling); } } diff --git a/src/object/sp-object.cpp b/src/object/sp-object.cpp index aa446bf8b..7d1ee38a3 100644 --- a/src/object/sp-object.cpp +++ b/src/object/sp-object.cpp @@ -519,8 +519,8 @@ void SPObject::cropToObject(SPObject *except) } } } - for (std::size_t i = 0; i < toDelete.size(); ++i) { - (toDelete[i])->deleteObject(true, true); + for (auto & i : toDelete) { + i->deleteObject(true, true); } } diff --git a/src/object/sp-path.cpp b/src/object/sp-path.cpp index 0ff31f823..379b1bfdf 100644 --- a/src/object/sp-path.cpp +++ b/src/object/sp-path.cpp @@ -62,9 +62,9 @@ gchar* SPPath::description() const { Glib::ustring s; PathEffectList effect_list = this->getEffectList(); - for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it) + for (auto & it : effect_list) { - LivePathEffectObject *lpeobj = (*it)->lpeobject; + LivePathEffectObject *lpeobj = it->lpeobject; if (!lpeobj || !lpeobj->get_lpe()) { break; @@ -94,8 +94,8 @@ void SPPath::convert_to_guides() const { Geom::Affine const i2dt(this->i2dt_affine()); Geom::PathVector const & pv = this->_curve->get_pathvector(); - for(Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) { - for(Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_default(); ++cit) { + for(const auto & pit : pv) { + for(Geom::Path::const_iterator cit = pit.begin(); cit != pit.end_default(); ++cit) { // only add curves for straight line segments if( is_straight_curve(*cit) ) { diff --git a/src/object/sp-pattern.cpp b/src/object/sp-pattern.cpp index db4366d63..a7035e98e 100644 --- a/src/object/sp-pattern.cpp +++ b/src/object/sp-pattern.cpp @@ -245,9 +245,7 @@ void SPPattern::update(SPCtx *ctx, unsigned int flags) std::list l; _getChildren(l); - for (SPObjectIterator it = l.begin(); it != l.end(); ++it) { - SPObject *child = *it; - + for (auto child : l) { sp_object_ref(child, nullptr); if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { @@ -271,9 +269,7 @@ void SPPattern::modified(unsigned int flags) std::list l; _getChildren(l); - for (SPObjectIterator it = l.begin(); it != l.end(); ++it) { - SPObject *child = *it; - + for (auto child : l) { sp_object_ref(child, nullptr); if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { @@ -402,8 +398,7 @@ const gchar *SPPattern::produce(const std::vector &reprs, const gchar *pat_id = repr->attribute("id"); SPObject *pat_object = document->getObjectById(pat_id); - for (NodePtrIterator i = reprs.begin(); i != reprs.end(); ++i) { - Inkscape::XML::Node *node = *i; + for (auto node : reprs) { SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); Geom::Affine dup_transform; diff --git a/src/object/sp-polygon.cpp b/src/object/sp-polygon.cpp index a528b99cd..ac47fca8b 100644 --- a/src/object/sp-polygon.cpp +++ b/src/object/sp-polygon.cpp @@ -44,8 +44,8 @@ static gchar *sp_svg_write_polygon(Geom::PathVector const & pathv) { Inkscape::SVGOStringStream os; - for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { - for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_default(); ++cit) { + for (const auto & pit : pathv) { + for (Geom::Path::const_iterator cit = pit.begin(); cit != pit.end_default(); ++cit) { if ( is_straight_curve(*cit) ) { os << cit->finalPoint()[0] << "," << cit->finalPoint()[1] << " "; diff --git a/src/object/sp-shape.cpp b/src/object/sp-shape.cpp index e73cb2679..d615980c0 100644 --- a/src/object/sp-shape.cpp +++ b/src/object/sp-shape.cpp @@ -48,8 +48,8 @@ static void sp_shape_update_marker_view (SPShape *shape, Inkscape::DrawingItem *ai); SPShape::SPShape() : SPLPEItem() { - for ( int i = 0 ; i < SP_MARKER_LOC_QTY ; i++ ) { - this->_marker[i] = nullptr; + for (auto & i : this->_marker) { + i = nullptr; } this->_curve = nullptr; @@ -920,8 +920,8 @@ int SPShape::numberOfMarkers(int type) const { { if ( this->_marker[SP_MARKER_LOC] ) { guint n = 0; - for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - n += path_it->size_default() + 1; + for(const auto & path_it : pathv) { + n += path_it.size_default() + 1; } return n; } else { @@ -936,8 +936,8 @@ int SPShape::numberOfMarkers(int type) const { { if ( this->_marker[SP_MARKER_LOC_MID] ) { guint n = 0; - for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - n += path_it->size_default() + 1; + for(const auto & path_it : pathv) { + n += path_it.size_default() + 1; } n = (n > 1) ? (n - 2) : 0; // Minus the start and end marker, but never negative. // A path or polyline may have only one point. @@ -1178,16 +1178,16 @@ void SPShape::snappoints(std::vector &p, Inkscape: } } - for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { + for(const auto & path_it : pathv) { if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP)) { // Add the first point of the path - p.emplace_back(path_it->initialPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP); + p.emplace_back(path_it.initialPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP); } - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_it1 = path_it.begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = ++(path_it.begin()); // outgoing curve - while (curve_it1 != path_it->end_default()) + while (curve_it1 != path_it.end_default()) { // For each path: consider midpoints of line segments for snapping if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT)) { @@ -1196,8 +1196,8 @@ void SPShape::snappoints(std::vector &p, Inkscape: } } - if (curve_it2 == path_it->end_default()) { // Test will only pass for the last iteration of the while loop - if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && !path_it->closed()) { + if (curve_it2 == path_it.end_default()) { // Test will only pass for the last iteration of the while loop + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && !path_it.closed()) { // Add the last point of the path, but only for open paths // (for closed paths the first and last point will coincide) p.emplace_back((*curve_it1).finalPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP); @@ -1245,11 +1245,11 @@ void SPShape::snappoints(std::vector &p, Inkscape: Geom::Crossings cs; try { - cs = self_crossings(*path_it); // This can be slow! + cs = self_crossings(path_it); // This can be slow! if (!cs.empty()) { // There might be multiple intersections... for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); ++i) { - Geom::Point p_ix = (*path_it).pointAt((*i).ta); + Geom::Point p_ix = path_it.pointAt((*i).ta); p.emplace_back(p_ix * i2dt, Inkscape::SNAPSOURCE_PATH_INTERSECTION, Inkscape::SNAPTARGET_PATH_INTERSECTION); } } diff --git a/src/object/sp-text.cpp b/src/object/sp-text.cpp index c12d007ed..ff8bd9af7 100644 --- a/src/object/sp-text.cpp +++ b/src/object/sp-text.cpp @@ -476,8 +476,7 @@ void SPText::_buildLayoutInit() // Extract out shapes (a comma separated list of urls) Glib::ustring shapeInside_value = style->shape_inside.value; std::vector shapes_url = Glib::Regex::split_simple(" ", shapeInside_value); - for (unsigned int i=0; i shapes_url = Glib::Regex::split_simple(" ", shapeSubtract_value); - for(unsigned int i=0; iheight(); double const em = style->font_size.computed; double const ex = em * 0.5; - for(std::vector::iterator it = attr_vector->begin(); it != attr_vector->end(); ++it) { + for(auto & it : *attr_vector) { if( update_x ) - it->update( em, ex, w ); + it.update( em, ex, w ); if( update_y ) - it->update( em, ex, h ); + it.update( em, ex, h ); } } return true; @@ -1169,17 +1167,17 @@ void TextTagAttributes::writeTo(Inkscape::XML::Node *node) const void TextTagAttributes::update( double em, double ex, double w, double h ) { - for(std::vector::iterator it = attributes.x.begin(); it != attributes.x.end(); ++it) { - it->update( em, ex, w ); + for(auto & it : attributes.x) { + it.update( em, ex, w ); } - for(std::vector::iterator it = attributes.y.begin(); it != attributes.y.end(); ++it) { - it->update( em, ex, h ); + for(auto & it : attributes.y) { + it.update( em, ex, h ); } - for(std::vector::iterator it = attributes.dx.begin(); it != attributes.dx.end(); ++it) { - it->update( em, ex, w ); + for(auto & it : attributes.dx) { + it.update( em, ex, w ); } - for(std::vector::iterator it = attributes.dy.begin(); it != attributes.dy.end(); ++it) { - it->update( em, ex, h ); + for(auto & it : attributes.dy) { + it.update( em, ex, h ); } } @@ -1199,9 +1197,9 @@ void TextTagAttributes::writeSingleAttributeVector(Inkscape::XML::Node *node, gc Glib::ustring string; // FIXME: this has no concept of unset values because sp_svg_length_list_read() can't read them back in - for (std::vector::const_iterator it = attr_vector.begin() ; it != attr_vector.end() ; ++it) { + for (auto it : attr_vector) { if (!string.empty()) string += ' '; - string += it->write(); + string += it.write(); } node->setAttribute(key, string.c_str()); } @@ -1440,10 +1438,10 @@ void TextTagAttributes::transform(Geom::Affine const &matrix, double scale_x, do attributes.y[i] = point[Geom::Y]; } } - for (std::vector::iterator it = attributes.dx.begin() ; it != attributes.dx.end() ; ++it) - *it = it->computed * scale_x; - for (std::vector::iterator it = attributes.dy.begin() ; it != attributes.dy.end() ; ++it) - *it = it->computed * scale_y; + for (auto & it : attributes.dx) + it = it.computed * scale_x; + for (auto & it : attributes.dy) + it = it.computed * scale_y; } double TextTagAttributes::getDx(unsigned index) diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 56c93289d..8efd27be8 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -368,8 +368,7 @@ bool sp_item_list_to_curves(const std::vector &items, std::vector& selected, std::vector &to_select, bool skip_all_lpeitems) { bool did = false; - for (std::vector::const_iterator i = items.begin(); i != items.end(); ++i){ - SPItem *item = *i; + for (auto item : items){ g_assert(item != nullptr); SPDocument *document = item->document; diff --git a/src/satisfied-guide-cns.cpp b/src/satisfied-guide-cns.cpp index 5c560a672..5eb2a1dfb 100644 --- a/src/satisfied-guide-cns.cpp +++ b/src/satisfied-guide-cns.cpp @@ -22,8 +22,8 @@ void satisfied_guide_cns(SPDesktop const &desktop, std::vector &cns) { SPNamedView const &nv = *desktop.getNamedView(); - for(std::vector::const_iterator it = nv.guides.begin(); it != nv.guides.end(); ++it) { - SPGuide &g = *(*it); + for(auto guide : nv.guides) { + SPGuide &g = *guide; for (unsigned int i = 0; i < snappoints.size(); ++i) { if (Geom::are_near(g.getDistanceFrom(snappoints[i].getPoint()), 0, 1e-2)) { cns.emplace_back(&g, i); diff --git a/src/selcue.cpp b/src/selcue.cpp index 72d72daf5..e10b70a96 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -65,13 +65,13 @@ Inkscape::SelCue::~SelCue() _sel_changed_connection.disconnect(); _sel_modified_connection.disconnect(); - for (std::vector::iterator i = _item_bboxes.begin(); i != _item_bboxes.end(); ++i) { - sp_canvas_item_destroy(*i); + for (auto & _item_bboxe : _item_bboxes) { + sp_canvas_item_destroy(_item_bboxe); } _item_bboxes.clear(); - for (std::vector::iterator i = _text_baselines.begin(); i != _text_baselines.end(); ++i) { - sp_canvas_item_destroy(*i); + for (auto & _text_baseline : _text_baselines) { + sp_canvas_item_destroy(_text_baseline); } _text_baselines.clear(); } @@ -132,8 +132,8 @@ void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) void Inkscape::SelCue::_newItemBboxes() { - for (std::vector::iterator i = _item_bboxes.begin(); i != _item_bboxes.end(); ++i) { - sp_canvas_item_destroy(*i); + for (auto & _item_bboxe : _item_bboxes) { + sp_canvas_item_destroy(_item_bboxe); } _item_bboxes.clear(); @@ -197,8 +197,8 @@ void Inkscape::SelCue::_newItemBboxes() void Inkscape::SelCue::_newTextBaselines() { - for (std::vector::iterator i = _text_baselines.begin(); i != _text_baselines.end(); ++i) { - sp_canvas_item_destroy(*i); + for (auto & _text_baseline : _text_baselines) { + sp_canvas_item_destroy(_text_baseline); } _text_baselines.clear(); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 2f77e1093..ed4c23bbc 100755 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -372,11 +372,10 @@ static std::vector sp_selection_paste_impl(SPDocument *doc static void sp_selection_delete_impl(std::vector const &items, bool propagate = true, bool propagate_descendants = true) { - for (std::vector::const_iterator i = items.begin(); i != items.end(); ++i) { - sp_object_ref(*i, nullptr); + for (auto item : items) { + sp_object_ref(item, nullptr); } - for (std::vector::const_iterator i = items.begin(); i != items.end(); ++i) { - SPItem *item = *i; + for (auto item : items) { item->deleteObject(propagate, propagate_descendants); sp_object_unref(item, nullptr); } @@ -586,8 +585,8 @@ void sp_edit_clear_all(Inkscape::Selection *selection) g_return_if_fail(group != nullptr); std::vector items = sp_item_group_item_list(group); - for(unsigned int i = 0; i < items.size(); i++){ - items[i]->deleteObject(); + for(auto & item : items){ + item->deleteObject(); } DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, @@ -862,19 +861,19 @@ static void ungroup_impl(ObjectSet *set) } // do the actual work - for (std::vector::iterator item = items.begin(); item != items.end(); ++item) { - SPItem *obj = *item; + for (auto & item : items) { + SPItem *obj = item; // ungroup only the groups marked earlier - if (groups.find(*item) != groups.end()) { + if (groups.find(item) != groups.end()) { std::vector children; sp_item_group_ungroup(dynamic_cast(obj), children, false); // add the items resulting from ungrouping to the selection new_select.insert(new_select.end(),children.begin(),children.end()); - *item = NULL; // zero out the original pointer, which is no longer valid + item = NULL; // zero out the original pointer, which is no longer valid } else { // if not a group, keep in the selection - new_select.push_back(*item); + new_select.push_back(item); } } @@ -960,8 +959,8 @@ enclose_items(std::vector const &items) g_assert(!items.empty()); Geom::OptRect r; - for (std::vector::const_iterator i = items.begin();i!=items.end();++i) { - r.unionWith((*i)->documentVisualBounds()); + for (auto item : items) { + r.unionWith(item->documentVisualBounds()); } return r; } @@ -1389,8 +1388,7 @@ void ObjectSet::pasteSizeSeparately(bool apply_x, bool apply_y) */ void sp_selection_change_layer_maintain_clones(std::vector const &items,SPObject *where) { - for (std::vector::const_iterator i = items.begin(); i != items.end(); ++i) { - SPItem *item = *i; + for (auto item : items) { if (item) { SPItem *oldparent = dynamic_cast(item->parent); SPItem *newparent = dynamic_cast(where); @@ -1586,8 +1584,8 @@ void ObjectSet::applyAffine(Geom::Affine const &affine, bool set_i2d, bool compe Persp3D *persp; Persp3D *transf_persp; std::list plist = perspList(); - for (std::list::iterator i = plist.begin(); i != plist.end(); ++i) { - persp = (Persp3D *) (*i); + for (auto & i : plist) { + persp = (Persp3D *) i; if (!persp3d_has_all_boxes_in_selection (persp, this)) { std::list selboxes = box3DList(persp); @@ -1595,8 +1593,8 @@ void ObjectSet::applyAffine(Geom::Affine const &affine, bool set_i2d, bool compe // create a new perspective as a copy of the current one and link the selected boxes to it transf_persp = persp3d_create_xml_element (persp->document, persp->perspective_impl); - for (std::list::iterator b = selboxes.begin(); b != selboxes.end(); ++b) - box3d_switch_perspectives(*b, persp, transf_persp); + for (auto & selboxe : selboxes) + box3d_switch_perspectives(selboxe, persp, transf_persp); } else { transf_persp = persp; } @@ -2448,8 +2446,7 @@ SPItem *next_item_from_list(SPDesktop *desktop, std::vector const &item SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) { SPObject *current=root; - for(std::vector::const_iterator i = items.begin();i!=items.end();++i) { - SPItem *item = *i; + for(auto item : items) { if ( root->isAncestorOf(item) && ( !only_in_viewport || desktop->isWithinViewport(item) ) ) { @@ -4041,10 +4038,10 @@ void ObjectSet::setClipGroup() SPItem *item = reinterpret_cast(*i); std::vector mask_items_dup; std::map dup_transf; - for (auto it = mask_items.begin(); it != mask_items.end(); ++it) { - Inkscape::XML::Node *dup = ((*it).first)->duplicate(xml_doc); + for (auto & mask_item : mask_items) { + Inkscape::XML::Node *dup = (mask_item.first)->duplicate(xml_doc); mask_items_dup.push_back(dup); - dup_transf[dup] = (*it).second; + dup_transf[dup] = mask_item.second; } Inkscape::XML::Node *current = SP_OBJECT(*i)->getRepr(); @@ -4081,9 +4078,9 @@ void ObjectSet::setClipGroup() // inverted object transform should be applied to a mask object, // as mask is calculated in user space (after applying transform) - for (auto it = mask_items_dup.begin(); it != mask_items_dup.end(); ++it) { - SPItem *clip_item = SP_ITEM(doc->getObjectByRepr(*it)); - clip_item->doWriteTransform(dup_transf[*it]); + for (auto & it : mask_items_dup) { + SPItem *clip_item = SP_ITEM(doc->getObjectByRepr(it)); + clip_item->doWriteTransform(dup_transf[it]); clip_item->doWriteTransform(clip_item->transform * item->i2doc_affine().inverse()); } @@ -4169,8 +4166,8 @@ void ObjectSet::unsetMask(const bool apply_clip_path, const bool skip_undo) { } // restore mask objects into a document - for ( std::map::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { - SPObject *obj = (*it).first; // Group containing the clipped paths or masks + for (auto & referenced_object : referenced_objects) { + SPObject *obj = referenced_object.first; // Group containing the clipped paths or masks std::vector items_to_move; for (auto& child: obj->children) { // Collect all clipped paths and masks within a single group @@ -4193,8 +4190,8 @@ void ObjectSet::unsetMask(const bool apply_clip_path, const bool skip_undo) { } // remember parent and position of the item to which the clippath/mask was applied - Inkscape::XML::Node *parent = ((*it).second)->getRepr()->parent(); - gint pos = ((*it).second)->getRepr()->position(); + Inkscape::XML::Node *parent = (referenced_object.second)->getRepr()->parent(); + gint pos = (referenced_object.second)->getRepr()->position(); // Iterate through all clipped paths / masks for (auto i=items_to_move.rbegin();i!=items_to_move.rend();++i) { @@ -4209,7 +4206,7 @@ void ObjectSet::unsetMask(const bool apply_clip_path, const bool skip_undo) { // transform mask, so it is moved the same spot where mask was applied Geom::Affine transform(mask_item->transform); - transform *= (*it).second->transform; + transform *= referenced_object.second->transform; mask_item->doWriteTransform(transform); } } diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 841e8e095..b2b4b2d04 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -42,8 +42,7 @@ char* collect_terms (const std::vector &items) std::stringstream ss; bool first = true; - for ( std::vector::const_iterator iter=items.begin();iter!=items.end();++iter ) { - SPItem *item = *iter; + for (auto item : items) { if (item && item->displayName()) { Glib::ustring term(item->displayName()); if (term != "" && (check.insert(term).second)) { @@ -60,8 +59,7 @@ static int count_terms (const std::vector &items) { std::set check; int count=0; - for ( std::vector::const_iterator iter=items.begin();iter!=items.end();++iter ) { - SPItem *item = *iter; + for (auto item : items) { if (item && item->displayName()) { Glib::ustring term(item->displayName()); if (term != "" && (check.insert(term).second)) { @@ -76,8 +74,7 @@ static int count_terms (const std::vector &items) static int count_filtered (const std::vector &items) { int count=0; - for ( std::vector::const_iterator iter=items.begin();iter!=items.end();++iter ) { - SPItem *item = *iter; + for (auto item : items) { if (item) { count += item->isFiltered(); } diff --git a/src/selection.cpp b/src/selection.cpp index 09d212b76..4a5ccf60b 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -217,8 +217,8 @@ Selection::setBackup () if(tool){ Inkscape::UI::ControlPointSelection *cps = tool->_selected_nodes; std::list points_list = cps->_points_list; - for (std::list::iterator i = points_list.begin(); i != points_list.end(); ++i) { - Inkscape::UI::Node *node = dynamic_cast(*i); + for (auto & i : points_list) { + Inkscape::UI::Node *node = dynamic_cast(i); if (node) { std::string id = node->nodeList().subpathList().pm().item()->getId(); @@ -282,14 +282,14 @@ Selection::restoreBackup() Inkscape::UI::Node * node = dynamic_cast(*points_list.begin()); if (node) { Inkscape::UI::SubpathList sp = node->nodeList().subpathList(); - for (std::vector > >::iterator l = _seldata.begin(); l != _seldata.end(); ++l) { - SPPath * path = dynamic_cast(document->getObjectById(l->first)); + for (auto & l : _seldata) { + SPPath * path = dynamic_cast(document->getObjectById(l.first)); gint sp_count = 0; for (Inkscape::UI::SubpathList::iterator j = sp.begin(); j != sp.end(); ++j, ++sp_count) { - if(sp_count == l->second.first) { + if(sp_count == l.second.first) { gint nt_count = 0; for (Inkscape::UI::NodeList::iterator k = (*j)->begin(); k != (*j)->end(); ++k, ++nt_count) { - if(nt_count == l->second.second) { + if(nt_count == l.second.second) { cps->insert(k.ptr()); break; } diff --git a/src/seltrans.cpp b/src/seltrans.cpp index a5bf7a710..4ad4f2154 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -160,9 +160,9 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : sp_canvas_item_hide(_grip); sp_canvas_item_hide(_norm); - for (int i = 0; i < 4; i++) { - _l[i] = ControlManager::getManager().createControlLine(desktop->getControls()); - sp_canvas_item_hide(_l[i]); + for (auto & i : _l) { + i = ControlManager::getManager().createControlLine(desktop->getControls()); + sp_canvas_item_hide(i); } _sel_changed_connection = _selection->connectChanged( @@ -183,9 +183,9 @@ Inkscape::SelTrans::~SelTrans() _sel_changed_connection.disconnect(); _sel_modified_connection.disconnect(); - for (int i = 0; i < NUMHANDS; i++) { - knot_unref(knots[i]); - knots[i] = nullptr; + for (auto & knot : knots) { + knot_unref(knot); + knot = nullptr; } if (_norm) { @@ -196,15 +196,15 @@ Inkscape::SelTrans::~SelTrans() sp_canvas_item_destroy(_grip); _grip = nullptr; } - for (int i = 0; i < 4; i++) { - if (_l[i]) { - sp_canvas_item_destroy(_l[i]); - _l[i] = nullptr; + for (auto & i : _l) { + if (i) { + sp_canvas_item_destroy(i); + i = nullptr; } } - for (unsigned i = 0; i < _items.size(); i++) { - sp_object_unref(_items[i], nullptr); + for (auto & _item : _items) { + sp_object_unref(_item, nullptr); } _items.clear(); @@ -330,8 +330,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s bool c2 = prefs->getBool("/options/snapclosestonly/value", false); if (translating && (c1 || c2)) { // Get the bounding box points for each item in the selection - for (unsigned i = 0; i < _items.size(); i++) { - Geom::OptRect b = _items[i]->desktopBounds(_snap_bbox_type); + for (auto & _item : _items) { + Geom::OptRect b = _item->desktopBounds(_snap_bbox_type); getBBoxPoints(b, &_bbox_points, false, c, emp, mp); } } else { @@ -369,8 +369,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s } if (_show == SHOW_OUTLINE) { - for (int i = 0; i < 4; i++) - sp_canvas_item_show(_l[i]); + for (auto & i : _l) + sp_canvas_item_show(i); } _updateHandles(); @@ -425,16 +425,16 @@ void Inkscape::SelTrans::ungrab() Inkscape::Selection *selection = _desktop->getSelection(); _updateVolatileState(); - for (unsigned i = 0; i < _items.size(); i++) { - sp_object_unref(_items[i], nullptr); + for (auto & _item : _items) { + sp_object_unref(_item, nullptr); } sp_canvas_item_hide(_norm); sp_canvas_item_hide(_grip); if (_show == SHOW_OUTLINE) { - for (int i = 0; i < 4; i++) - sp_canvas_item_hide(_l[i]); + for (auto & i : _l) + sp_canvas_item_hide(i); } if(!_stamp_cache.empty()){ _stamp_cache.clear(); @@ -589,8 +589,8 @@ void Inkscape::SelTrans::stamp() void Inkscape::SelTrans::_updateHandles() { - for (int i = 0; i < NUMHANDS; i++) - knots[i]->hide(); + for (auto & knot : knots) + knot->hide(); if ( !_show_handles || _empty ) return; @@ -772,8 +772,8 @@ void Inkscape::SelTrans::handleNewEvent(SPKnot *knot, Geom::Point *position, gui // in case items have been unhooked from the document, don't // try to continue processing events for them. - for (unsigned int i = 0; i < _items.size(); i++) { - if ( !_items[i]->document ) { + for (auto & _item : _items) { + if ( !_item->document ) { return; } } @@ -1598,8 +1598,8 @@ void Inkscape::SelTrans::_keepClosestPointOnly(Geom::Point const &p) _all_snap_sources_sorted.insert(_all_snap_sources_sorted.end(), _bbox_points.begin(), _bbox_points.end()); // Calculate and store the distance to the reference point for each snap candidate point - for(std::vector::iterator i = _all_snap_sources_sorted.begin(); i != _all_snap_sources_sorted.end(); ++i) { - (*i).setDistance(Geom::L2((*i).getPoint() - p)); + for(auto & i : _all_snap_sources_sorted) { + i.setDistance(Geom::L2(i.getPoint() - p)); } // Sort them ascending, using the distance calculated above as the single criteria diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index e38ffea7f..876293aca 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -25,8 +25,8 @@ Inkscape::SnapPreferences::SnapPreferences() : g_assert((SNAPTARGET_DATUMS_CATEGORY != 0) && !(SNAPTARGET_DATUMS_CATEGORY & (SNAPTARGET_DATUMS_CATEGORY - 1))); g_assert((SNAPTARGET_OTHERS_CATEGORY != 0) && !(SNAPTARGET_OTHERS_CATEGORY & (SNAPTARGET_OTHERS_CATEGORY - 1))); - for (int n = 0; n < SNAPTARGET_MAX_ENUM_VALUE; n++) { - _active_snap_targets[n] = -1; + for (int & _active_snap_target : _active_snap_targets) { + _active_snap_target = -1; } } diff --git a/src/snap.cpp b/src/snap.cpp index f018911c6..55c67b0ff 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -70,8 +70,8 @@ SnapManager::SnapperList SnapManager::getGridSnappers() const SnapperList s; if (_desktop && _desktop->gridsEnabled() && snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID)) { - for(std::vector::const_iterator it = _named_view->grids.begin(); it != _named_view->grids.end(); ++it) { - s.push_back((*it)->snapper); + for(auto grid : _named_view->grids) { + s.push_back(grid->snapper); } } @@ -132,8 +132,8 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const IntermSnapResults isr; SnapperList const snappers = getSnappers(); - for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); ++i) { - (*i)->freeSnap(isr, p, bbox_to_snap, &_items_to_ignore, _unselected_nodes); + for (auto snapper : snappers) { + snapper->freeSnap(isr, p, bbox_to_snap, &_items_to_ignore, _unselected_nodes); } return findBestSnap(p, isr, false, false, to_paths_only); @@ -173,8 +173,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c // Cannot use getGridSnappers() because we need both the grids AND their snappers // Therefore we iterate through all grids manually - for (std::vector::const_iterator it = _named_view->grids.begin(); it != _named_view->grids.end(); ++it) { - Inkscape::CanvasGrid *grid = (*it); + for (auto grid : _named_view->grids) { const Inkscape::Snapper* snapper = grid->snapper; if (snapper && snapper->ThisSnapperMightSnap()) { // To find the nearest multiple of the grid pitch for a given translation t, we @@ -257,8 +256,8 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint IntermSnapResults isr; SnapperList const snappers = getSnappers(); - for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); ++i) { - (*i)->constrainedSnap(isr, p, bbox_to_snap, constraint, &_items_to_ignore, _unselected_nodes); + for (auto snapper : snappers) { + snapper->constrainedSnap(isr, p, bbox_to_snap, constraint, &_items_to_ignore, _unselected_nodes); } result = findBestSnap(p, isr, true); @@ -300,10 +299,10 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi // Project the mouse pointer on each of the constraints std::vector projections; - for (std::vector::const_iterator c = constraints.begin(); c != constraints.end(); ++c) { + for (const auto & constraint : constraints) { // Project the mouse pointer onto the constraint; In case we don't snap then we will // return the projection onto the constraint, such that the constraint is always enforced - Geom::Point pp = (*c).projection(p.getPoint()); + Geom::Point pp = constraint.projection(p.getPoint()); projections.push_back(pp); } @@ -341,8 +340,8 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi result.setPoint(cc.projection(result.getPoint())); } else { // Try to snap along the closest constraint - for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); ++i) { - (*i)->constrainedSnap(isr, p, bbox_to_snap, cc, &_items_to_ignore,_unselected_nodes); + for (auto snapper : snappers) { + snapper->constrainedSnap(isr, p, bbox_to_snap, cc, &_items_to_ignore,_unselected_nodes); } result = findBestSnap(p, isr, true); } diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp index f63541582..2d58ddb34 100644 --- a/src/snapped-curve.cpp +++ b/src/snapped-curve.cpp @@ -220,12 +220,12 @@ bool getClosestIntersectionCL(std::list const &curve_lis { bool success = false; - for (std::list::const_iterator i = curve_list.begin(); i != curve_list.end(); ++i) { - if ((*i).getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes, + for (const auto & i : curve_list) { + if (i.getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes, // as this would require two bboxes two be flashed in the snap indicator - for (std::list::const_iterator j = line_list.begin(); j != line_list.end(); ++j) { - if ((*j).getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes - Inkscape::SnappedPoint sp = (*i).intersect(*j, p, dt2doc); + for (const auto & j : line_list) { + if (j.getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes + Inkscape::SnappedPoint sp = i.intersect(j, p, dt2doc); if (sp.getAtIntersection()) { // if it's the first point bool const c1 = !success; diff --git a/src/snapped-line.cpp b/src/snapped-line.cpp index c2dc37da0..5224117f6 100644 --- a/src/snapped-line.cpp +++ b/src/snapped-line.cpp @@ -264,9 +264,9 @@ bool getClosestIntersectionSL(std::list const &list1, std { bool success = false; - for (std::list::const_iterator i = list1.begin(); i != list1.end(); ++i) { - for (std::list::const_iterator j = list2.begin(); j != list2.end(); ++j) { - Inkscape::SnappedPoint sp = (*i).intersect(*j); + for (const auto & i : list1) { + for (const auto & j : list2) { + Inkscape::SnappedPoint sp = i.intersect(j); if (sp.getAtIntersection()) { // if it's the first point bool const c1 = !success; diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 82b7326f8..38b5c7f89 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -913,8 +913,8 @@ void item_outline_add_marker_child( SPItem const *item, Geom::Affine marker_tran Geom::PathVector* marker_pathv = item_outline(item); if (marker_pathv) { - for (unsigned int j=0; j < marker_pathv->size(); j++) { - pathv_in->push_back((*marker_pathv)[j] * tr); + for (const auto & j : *marker_pathv) { + pathv_in->push_back(j * tr); } delete marker_pathv; } @@ -1183,8 +1183,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop, bool legacy) return false; } std::vector const item_list = sp_item_group_item_list(group); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - SPItem *subitem = *iter; + for (auto subitem : item_list) { sp_item_path_outline(subitem, desktop, legacy); } } else { diff --git a/src/style-internal.cpp b/src/style-internal.cpp index 37371e18d..a1c2935be 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -599,8 +599,8 @@ const Glib::ustring SPIFontVariationSettings::toString() const { Inkscape::CSSOStringStream os; - for (auto it=axes.begin(); it!=axes.end(); ++it){ - os << it->first << "=" << it->second << ","; + for (const auto & axe : axes){ + os << axe.first << "=" << axe.second << ","; } std::string string = os.str(); // Glib::ustring doesn't have pop_back() @@ -806,9 +806,9 @@ SPILigatures::read( gchar const *str ) { } else { // We need to parse in order std::vector tokens = Glib::Regex::split_simple("\\s+", str ); - for( unsigned i = 0; i < tokens.size(); ++i ) { + for(auto & token : tokens) { for (unsigned j = 0; enums[j].key; ++j ) { - if (tokens[i].compare( enums[j].key ) == 0 ) { + if (token.compare( enums[j].key ) == 0 ) { set = true; inherit = false; if( enums[j].value < SP_CSS_FONT_VARIANT_LIGATURES_NOCOMMON ) { @@ -863,9 +863,9 @@ SPINumeric::read( gchar const *str ) { } else { // We need to parse in order std::vector tokens = Glib::Regex::split_simple("\\s+", str ); - for( unsigned i = 0; i < tokens.size(); ++i ) { + for(auto & token : tokens) { for (unsigned j = 0; enums[j].key; ++j ) { - if (tokens[i].compare( enums[j].key ) == 0 ) { + if (token.compare( enums[j].key ) == 0 ) { set = true; inherit = false; value |= enums[j].value; @@ -945,9 +945,9 @@ SPIEastAsian::read( gchar const *str ) { } else { // We need to parse in order std::vector tokens = Glib::Regex::split_simple("\\s+", str ); - for( unsigned i = 0; i < tokens.size(); ++i ) { + for(auto & token : tokens) { for (unsigned j = 0; enums[j].key; ++j ) { - if (tokens[i].compare( enums[j].key ) == 0 ) { + if (token.compare( enums[j].key ) == 0 ) { set = true; inherit = false; diff --git a/src/style.cpp b/src/style.cpp index b11a92749..bf14d66ce 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -650,8 +650,8 @@ SPStyle::readFromPrefs(Glib::ustring const &path) { Inkscape::XML::Node *tempnode = tempdoc->createElement("prefs"); std::vector attrs = prefs->getAllEntries(path); - for (std::vector::iterator i = attrs.begin(); i != attrs.end(); ++i) { - tempnode->setAttribute(i->getEntryName().data(), i->getString().data()); + for (auto & attr : attrs) { + tempnode->setAttribute(attr.getEntryName().data(), attr.getString().data()); } read( nullptr, tempnode ); @@ -1627,9 +1627,9 @@ css_font_family_quote(Glib::ustring &val) std::vector tokens = Glib::Regex::split_simple("\\s*,\\s*", val ); val.erase(); - for( unsigned i=0; i < tokens.size(); ++i ) { - css_quote( tokens[i] ); - val += tokens[i] + ", "; + for(auto & token : tokens) { + css_quote( token ); + val += token + ", "; } if( val.size() > 1 ) val.erase( val.size() - 2 ); // Remove trailing ", " @@ -1664,9 +1664,9 @@ css_font_family_unquote(Glib::ustring &val) std::vector tokens = Glib::Regex::split_simple("\\s*,\\s*", val ); val.erase(); - for( unsigned i=0; i < tokens.size(); ++i ) { - css_unquote( tokens[i] ); - val += tokens[i] + ", "; + for(auto & token : tokens) { + css_unquote( token ); + val += token + ", "; } if( val.size() > 1 ) val.erase( val.size() - 2 ); // Remove trailing ", " diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp index fd3615d0d..be919ca54 100644 --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@ -505,8 +505,8 @@ sp_svg_create_color_hash() { std::map colors; - for (unsigned i = 0 ; i < G_N_ELEMENTS(sp_svg_color_named) ; i++) { - colors[sp_svg_color_named[i].name] = sp_svg_color_named[i].rgb; + for (const auto & i : sp_svg_color_named) { + colors[i.name] = i.rgb; } return colors; } diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 6867cfd96..1414d6972 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -89,8 +89,8 @@ static void sp_svg_write_curve(Inkscape::SVG::PathString & str, Geom::Curve cons Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c->toSBasis(), 0.1); //recurse to convert the new path resulting from the sbasis to svgd - for(Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) { - sp_svg_write_curve(str, &(*iter)); + for(const auto & iter : sbasis_path) { + sp_svg_write_curve(str, &iter); } } } @@ -110,8 +110,8 @@ static void sp_svg_write_path(Inkscape::SVG::PathString & str, Geom::Path const gchar * sp_svg_write_path(Geom::PathVector const &p) { Inkscape::SVG::PathString str; - for(Geom::PathVector::const_iterator pit = p.begin(); pit != p.end(); ++pit) { - sp_svg_write_path(str, *pit); + for(const auto & pit : p) { + sp_svg_write_path(str, pit); } return g_strdup(str.c_str()); diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 145e5a4b4..98c566e8b 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -1241,7 +1241,7 @@ sp_te_adjust_line_height (SPObject *object, double amount, double average, bool // Always set if top level true. // Also set if line_height is set to a non-zero value. if (top_level || - (style->line_height.set && !style->line_height.inherit && (!(style->line_height.computed) == 0))){ + (style->line_height.set && !style->line_height.inherit && ((!((style->line_height.computed)) == 0)))){ // Scale default values if (!style->line_height.set || style->line_height.inherit || style->line_height.normal) { diff --git a/src/trace/imagemap.cpp b/src/trace/imagemap.cpp index cd4690944..796575a44 100644 --- a/src/trace/imagemap.cpp +++ b/src/trace/imagemap.cpp @@ -442,8 +442,8 @@ IndexedMap *IndexedMapCreate(int width, int height) RGB rgb; rgb.r = rgb.g = rgb.b = 0; - for (int i=0; i<256 ; i++){ - me->clut[i] = rgb; + for (auto & i : me->clut){ + i = rgb; } return me; diff --git a/src/trace/potrace/inkscape-potrace.cpp b/src/trace/potrace/inkscape-potrace.cpp index 4b50b1e1d..092fba634 100644 --- a/src/trace/potrace/inkscape-potrace.cpp +++ b/src/trace/potrace/inkscape-potrace.cpp @@ -119,9 +119,8 @@ struct Point */ static bool hasPoint(std::vector &points, double x, double y) { - for (unsigned int i=0; i *pool) node->ref = nullptr; node->parent = nullptr; node->nchild = 0; - for (int i = 0; i < 8; i++) node->child[i] = nullptr; + for (auto & i : node->child) i = nullptr; node->mi = 0; return node; } @@ -185,8 +185,8 @@ inline void ocnodeFree(pool *pool, Ocnode *node) { static void octreeDelete(pool *pool, Ocnode *node) { if (!node) return; - for (int i = 0; i < 8; i++) - octreeDelete(pool, node->child[i]); + for (auto & i : node->child) + octreeDelete(pool, i); ocnodeFree(pool, node); } @@ -375,16 +375,16 @@ static void ocnodeStrip(pool *pool, Ocnode **ref, int *count, unsigned l node->nleaf = 0; node->mi = 0; Ocnode **lonelychild = nullptr; - for (int i = 0; i < 8; i++) if (node->child[i]) + for (auto & i : node->child) if (i) { - ocnodeStrip(pool, &node->child[i], count, lvl); - if (node->child[i]) + ocnodeStrip(pool, &i, count, lvl); + if (i) { - lonelychild = &node->child[i]; + lonelychild = &i; node->nchild++; - node->nleaf += node->child[i]->nleaf; - if (!node->mi || node->mi > node->child[i]->mi) - node->mi = node->child[i]->mi; + node->nleaf += i->nleaf; + if (!node->mi || node->mi > i->mi) + node->mi = i->mi; } } // tree adjustments @@ -501,9 +501,9 @@ static void octreeIndex(Ocnode *node, RGB *rgbpal, int *index) (*index)++; } else - for (int i = 0; i < 8; i++) - if (node->child[i]) - octreeIndex(node->child[i], rgbpal, index); + for (auto & i : node->child) + if (i) + octreeIndex(i, rgbpal, index); } /** diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 41380443c..9c4702fdc 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -510,9 +510,8 @@ void Tracer::traceThread() long totalNodeCount = 0L; - for (unsigned int i=0 ; icreateElement("svg:path"); diff --git a/src/transf_mat_3x4.cpp b/src/transf_mat_3x4.cpp index c5071da2a..7af2d86c5 100644 --- a/src/transf_mat_3x4.cpp +++ b/src/transf_mat_3x4.cpp @@ -159,10 +159,10 @@ TransfMat3x4::copy_tmat(double rhs[3][4]) { void TransfMat3x4::print () const { g_print ("Transformation matrix:\n"); - for (int i = 0; i < 3; ++i) { + for (const auto & i : tmat) { g_print (" "); for (int j = 0; j < 4; ++j) { - g_print ("%8.2f ", tmat[i][j]); + g_print ("%8.2f ", i[j]); } g_print ("\n"); } diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index 7262b7dbe..ca1d14854 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -72,11 +72,10 @@ SvgPreview::SvgPreview() SvgPreview::~SvgPreview() { - for (std::map::iterator i = _pixmap_cache.begin(); - i != _pixmap_cache.end(); ++i) + for (auto & i : _pixmap_cache) { - g_object_unref(i->second); - i->second = NULL; + g_object_unref(i.second); + i.second = NULL; } } diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 7f9e4b872..733d6e8d1 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -676,16 +676,14 @@ std::vector ClipboardManagerImpl::getElementsOfType(SPDesktop *de types.push_back((Glib::ustring)"svg:use"); types.push_back((Glib::ustring)"svg:g"); types.push_back((Glib::ustring)"svg:image"); - for (auto i=types.begin();i!=types.end();++i) { - Glib::ustring type_elem = *i; + for (auto type_elem : types) { std::vector reprs_found = sp_repr_lookup_name_many(root, type_elem.c_str(), maxdepth); // unlimited search depth reprs.insert(reprs.end(), reprs_found.begin(), reprs_found.end()); } } else { reprs = sp_repr_lookup_name_many(root, type, maxdepth); } - for (auto i=reprs.begin();i!=reprs.end();++i) { - Inkscape::XML::Node const * node = *i; + for (auto node : reprs) { result.emplace_back(node->attribute("id")); } if ( result.empty() ) { @@ -721,12 +719,12 @@ void ClipboardManagerImpl::_copySelection(ObjectSet *selection) //remove already copied elements from cloned_elements std::vectortr; - for(std::set::iterator it = cloned_elements.begin();it!=cloned_elements.end();++it){ - if(std::find(sorted_items.begin(),sorted_items.end(),*it)!=sorted_items.end()) - tr.push_back(*it); + for(auto cloned_element : cloned_elements){ + if(std::find(sorted_items.begin(),sorted_items.end(),cloned_element)!=sorted_items.end()) + tr.push_back(cloned_element); } - for(std::vector::iterator it = tr.begin();it!=tr.end();++it){ - cloned_elements.erase(*it); + for(auto & it : tr){ + cloned_elements.erase(it); } sorted_items.insert(sorted_items.end(),cloned_elements.begin(),cloned_elements.end()); @@ -830,9 +828,9 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) // For shapes, copy all of the shape's markers SPShape *shape = dynamic_cast(item); if (shape) { - for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { - if (shape->_marker[i]) { - _copyNode(shape->_marker[i]->getRepr(), _doc, _defs); + for (auto & i : shape->_marker) { + if (i) { + _copyNode(i->getRepr(), _doc, _defs); } } } @@ -887,8 +885,8 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) SPLPEItem *lpeitem = dynamic_cast(item); if (lpeitem) { if (lpeitem->hasPathEffect()) { - for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it){ - LivePathEffectObject *lpeobj = (*it)->lpeobject; + for (auto & it : *lpeitem->path_effect_list){ + LivePathEffectObject *lpeobj = it->lpeobject; if (lpeobj) { _copyNode(lpeobj->getRepr(), _doc, _defs); } @@ -1388,11 +1386,10 @@ Glib::ustring ClipboardManagerImpl::_getBestTarget() g_message("End clipboard targets\n"); //*/ - for (std::list::iterator i = _preferred_targets.begin() ; - i != _preferred_targets.end() ; ++i) + for (auto & _preferred_target : _preferred_targets) { - if ( std::find(targets.begin(), targets.end(), *i) != targets.end() ) { - return *i; + if ( std::find(targets.begin(), targets.end(), _preferred_target) != targets.end() ) { + return _preferred_target; } } #ifdef _WIN32 diff --git a/src/ui/contextmenu.cpp b/src/ui/contextmenu.cpp index 7d57e78a8..486af0dda 100644 --- a/src/ui/contextmenu.cpp +++ b/src/ui/contextmenu.cpp @@ -93,11 +93,11 @@ ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) : std::vector< SPItem * > down_items = _desktop->getDocument()->getItemsPartiallyInBox( _desktop->dkey, b, true, true, true, true); bool has_down_hidden = false; bool has_down_locked = false; - for(std::vector< SPItem * >::iterator down = down_items.begin(); down != down_items.end(); ++down){ - if((*down)->isHidden()) { + for(auto & down_item : down_items){ + if(down_item->isHidden()) { has_down_hidden = true; } - if((*down)->isLocked()) { + if(down_item->isLocked()) { has_down_locked = true; } } @@ -216,10 +216,10 @@ void ContextMenu::HideSelected() void ContextMenu::UnLockBelow(std::vector items) { _desktop->selection->clear(); - for(auto i=items.begin();i!=items.end(); ++i) { - if ((*i)->isLocked()) { - (*i)->setLocked(false); - _desktop->selection->add(*i); + for(auto & item : items) { + if (item->isLocked()) { + item->setLocked(false); + _desktop->selection->add(item); } } } @@ -227,10 +227,10 @@ void ContextMenu::UnLockBelow(std::vector items) void ContextMenu::UnHideBelow(std::vector items) { _desktop->selection->clear(); - for(auto i=items.begin();i!=items.end(); ++i) { - if ((*i)->isHidden()) { - (*i)->setHidden(false); - _desktop->selection->add(*i); + for(auto & item : items) { + if (item->isHidden()) { + item->setHidden(false); + _desktop->selection->add(item); } } } diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp index 7ce30e63f..d97405f7a 100644 --- a/src/ui/control-manager.cpp +++ b/src/ui/control-manager.cpp @@ -204,10 +204,10 @@ void ControlManagerImpl::setControlSize(int size, bool force) } else if (force || (size != _size)) { _size = size; - for (std::vector::iterator it = _itemList.begin(); it != _itemList.end(); ++it) + for (auto & it : _itemList) { - if (*it) { - updateItem(*it); + if (it) { + updateItem(it); } } diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 0bae88103..b43afe179 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -190,11 +190,9 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) //Move each item in the selected list separately bool changed = false; - for (std::vector::iterator it(selected.begin()); - it != selected.end(); ++it) + for (auto item : selected) { - SPItem* item= *it; - desktop->getDocument()->ensureUpToDate(); + desktop->getDocument()->ensureUpToDate(); if (!sel_as_group) b = (item)->desktopPreferredBounds(); if (b && (!focus || (item) != focus)) { @@ -316,10 +314,7 @@ private : Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getBool("/tools/bounding_box"); std::vector< BBoxSort > sorted; - for (std::vector::iterator it(selected.begin()); - it != selected.end(); - ++it){ - SPItem *item = *it; + for (auto item : selected){ Geom::OptRect bbox = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds(); if (bbox) { sorted.emplace_back(item, *bbox, _orientation, kBegin, kEnd); @@ -713,12 +708,9 @@ private : int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - for (std::vector::iterator it(selected.begin()); - it != selected.end(); - ++it) + for (auto item : selected) { - SPItem* item = *it; - desktop->getDocument()->ensureUpToDate(); + desktop->getDocument()->ensureUpToDate(); Geom::OptRect item_box = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds(); if (item_box) { // find new center, staying within bbox @@ -793,12 +785,9 @@ private : std::vector sorted; - for (std::vector::iterator it(selected.begin()); - it != selected.end(); - ++it) + for (auto item : selected) { - SPItem* item = *it; - if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { + if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { Inkscape::Text::Layout const *layout = te_get_layout(item); boost::optional pt = layout->baselineAnchorPoint(); if (pt) { @@ -881,12 +870,9 @@ private : ref_point = b->min(); } - for (std::vector::iterator it(selected.begin()); - it != selected.end(); - ++it) + for (auto item : selected) { - SPItem* item = *it; - if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { + if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { Inkscape::Text::Layout const *layout = te_get_layout(item); boost::optional pt = layout->baselineAnchorPoint(); if (pt) { @@ -1151,9 +1137,8 @@ AlignAndDistribute::AlignAndDistribute() AlignAndDistribute::~AlignAndDistribute() { - for (std::list::iterator it = _actionList.begin(); - it != _actionList.end(); ++it) { - delete *it; + for (auto & it : _actionList) { + delete it; } _toolChangeConn.disconnect(); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index e179d3692..550e20b45 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -142,9 +142,7 @@ CloneTiler::CloneTiler () : GTK_CELL_RENDERER(cell_list->data), "markup", 0, NULL); - for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { - SymGroups const &sg = sym_groups[j]; - + for (const auto & sg : sym_groups) { // Add the description of the symgroup to a new row combo->append(sg.label); } diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index ad355f8d2..acec954fe 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -416,22 +416,22 @@ void ColorItem::_updatePreviews() } } - for ( std::vector::iterator it = _listeners.begin(); it != _listeners.end(); ++it ) { + for (auto & _listener : _listeners) { guint r = def.getR(); guint g = def.getG(); guint b = def.getB(); - if ( (*it)->_linkIsTone ) { - r = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * r) ) / 100; - g = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * g) ) / 100; - b = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * b) ) / 100; + if ( _listener->_linkIsTone ) { + r = ( (_listener->_linkPercent * _listener->_linkGray) + ((100 - _listener->_linkPercent) * r) ) / 100; + g = ( (_listener->_linkPercent * _listener->_linkGray) + ((100 - _listener->_linkPercent) * g) ) / 100; + b = ( (_listener->_linkPercent * _listener->_linkGray) + ((100 - _listener->_linkPercent) * b) ) / 100; } else { - r = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * r) ) / 100; - g = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * g) ) / 100; - b = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * b) ) / 100; + r = ( (_listener->_linkPercent * 255) + ((100 - _listener->_linkPercent) * r) ) / 100; + g = ( (_listener->_linkPercent * 255) + ((100 - _listener->_linkPercent) * g) ) / 100; + b = ( (_listener->_linkPercent * 255) + ((100 - _listener->_linkPercent) * b) ) / 100; } - (*it)->def.setRGB( r, g, b ); + _listener->def.setRGB( r, g, b ); } diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index 8513e94a6..c93572a1a 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -98,8 +98,8 @@ DocumentMetadata::~DocumentMetadata() Inkscape::XML::Node *repr = getDesktop()->getNamedView()->getRepr(); repr->removeListenerByData (this); - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) - delete (*it); + for (auto & it : _rdflist) + delete it; } void @@ -172,8 +172,8 @@ void DocumentMetadata::update() //-----------------------------------------------------------meta pages /* update the RDF entities */ - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) - (*it)->update (SP_ACTIVE_DOCUMENT); + for (auto & it : _rdflist) + it->update (SP_ACTIVE_DOCUMENT); _licensor.update (SP_ACTIVE_DOCUMENT); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 3153e2ac5..ba101921b 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -199,8 +199,8 @@ DocumentProperties::~DocumentProperties() Inkscape::XML::Node *root = getDesktop()->getDocument()->getRoot()->getRepr(); root->removeListenerByData (this); - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) - delete (*it); + for (auto & it : _rdflist) + delete it; } //======================================================================== @@ -1495,8 +1495,8 @@ void DocumentProperties::update() //-----------------------------------------------------------meta pages /* update the RDF entities */ - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) - (*it)->update (SP_ACTIVE_DOCUMENT); + for (auto & it : _rdflist) + it->update (SP_ACTIVE_DOCUMENT); _licensor.update (SP_ACTIVE_DOCUMENT); @@ -1540,16 +1540,16 @@ void DocumentProperties::on_response (int id) void DocumentProperties::load_default_metadata() { /* Get the data RDF entities data from preferences*/ - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) { - (*it)->load_from_preferences (); + for (auto & it : _rdflist) { + it->load_from_preferences (); } } void DocumentProperties::save_default_metadata() { /* Save these RDF entities to preferences*/ - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) { - (*it)->save_to_preferences (SP_ACTIVE_DOCUMENT); + for (auto & it : _rdflist) { + it->save_to_preferences (SP_ACTIVE_DOCUMENT); } } diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 95b85471f..e59db92f4 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -332,13 +332,13 @@ Export::Export () : Gtk::Label *label_advanced = Gtk::manage(new Gtk::Label(_("Advanced"),true)); expander.set_label_widget(*label_advanced); const char* const modes_list[]={"Gray_1", "Gray_2","Gray_4","Gray_8","Gray_16","RGB_8","RGB_16","GrayAlpha_8","GrayAlpha_16","RGBA_8","RGBA_16"}; - for(int i=0; i<11; ++i) - bitdepth_cb.append(modes_list[i]); + for(auto i : modes_list) + bitdepth_cb.append(i); bitdepth_cb.set_active_text("RGBA_8"); bitdepth_cb.set_hexpand(); const char* const zlist[]={"Z_NO_COMPRESSION","Z_BEST_SPEED","2","3","4","5","Z_DEFAULT_COMPRESSION","7","8","Z_BEST_COMPRESSION"}; - for(int i=0; i<10; ++i) - zlib_compression.append(zlist[i]); + for(auto i : zlist) + zlib_compression.append(i); zlib_compression.set_active_text("Z_DEFAULT_COMPRESSION"); pHYs_adj = Gtk::Adjustment::create(0, 0, 100000, 0.1, 1.0, 0); pHYs_sb.set_adjustment(pHYs_adj); @@ -346,8 +346,8 @@ Export::Export () : pHYs_sb.set_tooltip_text( _("Will force-set the physical dpi for the png file. Set this to 72 if you're planning to work on your png with Photoshop") ); zlib_compression.set_hexpand(); const char* const antialising_list[] = {"CAIRO_ANTIALIAS_NONE","CAIRO_ANTIALIAS_FAST","CAIRO_ANTIALIAS_GOOD (default)","CAIRO_ANTIALIAS_BEST"}; - for(int i=0; i<4; ++i) - antialiasing_cb.append(antialising_list[i]); + for(auto i : antialising_list) + antialiasing_cb.append(i); antialiasing_cb.set_active_text(antialising_list[2]); auto table = new Gtk::Grid(); gtk_container_add(GTK_CONTAINER(expander.gobj()), (GtkWidget*)(table->gobj())); diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index 683a66106..f98e129eb 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -64,13 +64,11 @@ bool hasSuffix(const Glib::ustring &str, const Glib::ustring &ext) bool isValidImageFile(const Glib::ustring &fileName) { std::vectorformats = Gdk::Pixbuf::get_formats(); - for (unsigned int i=0; iextensions = format.get_extensions(); - for (unsigned int j=0; j &result) return; } std::vector children = parent->get_children(); - for (unsigned int i = 0; i < children.size(); ++i) { - Gtk::Widget *child = children[i]; + for (auto child : children) { GtkWidget *wid = child->gobj(); if (GTK_IS_ENTRY(wid)) result.push_back(dynamic_cast(child)); @@ -102,8 +100,7 @@ void findExpanderWidgets(Gtk::Container *parent, std::vector &r if (!parent) return; std::vector children = parent->get_children(); - for (unsigned int i = 0; i < children.size(); ++i) { - Gtk::Widget *child = children[i]; + for (auto child : children) { GtkWidget *wid = child->gobj(); if (GTK_IS_EXPANDER(wid)) result.push_back(dynamic_cast(child)); @@ -742,11 +739,8 @@ void FileOpenDialogImplGtk::createFilterMenu() Inkscape::Extension::DB::InputList extension_list; Inkscape::Extension::db.get_input_list(extension_list); - for (Inkscape::Extension::DB::InputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); ++current_item) + for (auto imod : extension_list) { - Inkscape::Extension::Input *imod = *current_item; - // FIXME: would be nice to grey them out instead of not listing them if (imod->deactivated()) continue; @@ -1091,10 +1085,7 @@ void FileSaveDialogImplGtk::createFileTypeMenu() Inkscape::Extension::db.get_output_list(extension_list); knownExtensions.clear(); - for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); ++current_item) { - Inkscape::Extension::Output *omod = *current_item; - + for (auto omod : extension_list) { // FIXME: would be nice to grey them out instead of not listing them if (omod->deactivated()) continue; diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index d49f6d08c..8a246de62 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -215,8 +215,8 @@ public: ~MultiSpinButton() override { - for(unsigned i = 0; i < _spins.size(); ++i) - delete _spins[i]; + for(auto & _spin : _spins) + delete _spin; } std::vector& get_spinbuttons() @@ -391,10 +391,9 @@ public: std::vector get_values() const { std::vector vec; - for(Gtk::TreeIter iter = _model->children().begin(); - iter != _model->children().end(); ++iter) { + for(const auto & iter : _model->children()) { for(unsigned c = 0; c < _tree.get_columns().size(); ++c) - vec.push_back((*iter)[_columns.cols[c]]); + vec.push_back(iter[_columns.cols[c]]); } return vec; } @@ -402,12 +401,11 @@ public: void set_values(const std::vector& v) { unsigned i = 0; - for(Gtk::TreeIter iter = _model->children().begin(); - iter != _model->children().end(); ++iter) { + for(const auto & iter : _model->children()) { for(unsigned c = 0; c < _tree.get_columns().size(); ++c) { if(i >= v.size()) return; - (*iter)[_columns.cols[c]] = v[i]; + iter[_columns.cols[c]] = v[i]; ++i; } } @@ -418,10 +416,9 @@ public: // use SVGOStringStream to output SVG-compatible doubles Inkscape::SVGOStringStream os; - for(Gtk::TreeIter iter = _model->children().begin(); - iter != _model->children().end(); ++iter) { + for(const auto & iter : _model->children()) { for(unsigned c = 0; c < _tree.get_columns().size(); ++c) { - os << (*iter)[_columns.cols[c]] << " "; + os << iter[_columns.cols[c]] << " "; } } @@ -451,8 +448,8 @@ private: MatrixColumns() { cols.resize(5); - for(unsigned i = 0; i < cols.size(); ++i) - add(cols[i]); + for(auto & col : cols) + add(col); } std::vector > cols; }; @@ -754,8 +751,8 @@ public: { for(int i = 0; i < _max_types; ++i) { delete _groups[i]; - for(unsigned j = 0; j < _attrwidgets[i].size(); ++j) - delete _attrwidgets[i][j]; + for(auto & j : _attrwidgets[i]) + delete j; } } @@ -764,15 +761,15 @@ public: { if(t != _current_type) { type(t); - for(unsigned i = 0; i < _groups.size(); ++i) - _groups[i]->hide(); + for(auto & _group : _groups) + _group->hide(); } if(t >= 0) { _groups[t]->show(); // Do not use show_all(), it shows children than should be hidden } _dialog.set_attrs_locked(true); - for(unsigned i = 0; i < _attrwidgets[_current_type].size(); ++i) - _attrwidgets[_current_type][i]->set_from_attribute(ob); + for(auto & i : _attrwidgets[_current_type]) + i->set_from_attribute(ob); _dialog.set_attrs_locked(false); } @@ -908,8 +905,8 @@ public: MultiSpinButton* msb = new MultiSpinButton(lo, hi, step_inc, climb, digits, attrs, default_values, tips); add_widget(msb, label); - for(unsigned i = 0; i < msb->get_spinbuttons().size(); ++i) - add_attr_widget(msb->get_spinbuttons()[i]); + for(auto & i : msb->get_spinbuttons()) + add_attr_widget(i); return msb; } MultiSpinButton* add_multispinbutton(double def1, double def2, double def3, const SPAttributeEnum attr1, const SPAttributeEnum attr2, @@ -933,8 +930,8 @@ public: MultiSpinButton* msb = new MultiSpinButton(lo, hi, step_inc, climb, digits, attrs, default_values, tips); add_widget(msb, label); - for(unsigned i = 0; i < msb->get_spinbuttons().size(); ++i) - add_attr_widget(msb->get_spinbuttons()[i]); + for(auto & i : msb->get_spinbuttons()) + add_attr_widget(i); return msb; } @@ -1565,9 +1562,9 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri void FilterEffectsDialog::FilterModifier::update_counts() { - for(Gtk::TreeModel::iterator i = _model->children().begin(); i != _model->children().end(); ++i) { - SPFilter* f = SP_FILTER((*i)[_columns.filter]); - (*i)[_columns.count] = f->getRefCount(); + for(const auto & i : _model->children()) { + SPFilter* f = SP_FILTER(i[_columns.filter]); + i[_columns.count] = f->getRefCount(); } } @@ -3074,8 +3071,8 @@ void FilterEffectsDialog::update_settings_view() //First Tab std::vector vect1 = _settings_tab1.get_children(); - for(unsigned int i=0; ihide(); + for(auto & i : vect1) + i->hide(); _empty_settings.show(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 020292217..a00069d96 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -288,12 +288,12 @@ Find::Find() check_searchin_property.signal_clicked().connect(sigc::mem_fun(*this, &Find::onSearchinProperty)); check_alltypes.signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleAlltypes)); - for(size_t i = 0; i < checkProperties.size(); i++) { - checkProperties[i]->signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleCheck)); + for(auto & checkPropertie : checkProperties) { + checkPropertie->signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleCheck)); } - for(size_t i = 0; i < checkTypes.size(); i++) { - checkTypes[i]->signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleCheck)); + for(auto & checkType : checkTypes) { + checkType->signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleCheck)); } onSearchinText(); @@ -577,11 +577,11 @@ bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool cas vFontTokenNames.emplace_back("-inkscape-font-specification:"); std::vector vStyleTokens = Glib::Regex::split_simple(";", item_style); - for(size_t i=0; igetRepr()->setAttribute("style", new_item_style.data()); @@ -968,8 +968,8 @@ void Find::onToggleCheck () propertyok = true; } else { - for(size_t i = 0; i < checkProperties.size(); i++) { - if (checkProperties[i]->get_active()) { + for(auto & checkPropertie : checkProperties) { + if (checkPropertie->get_active()) { propertyok = true; } } @@ -990,8 +990,8 @@ void Find::onToggleCheck () void Find::onToggleAlltypes () { bool all =check_alltypes.get_active(); - for(size_t i = 0; i < checkTypes.size(); i++) { - checkTypes[i]->set_sensitive(!all); + for(auto & checkType : checkTypes) { + checkType->set_sensitive(!all); } onToggleCheck(); @@ -1011,8 +1011,8 @@ void Find::onSearchinProperty () void Find::searchinToggle(bool on) { - for(size_t i = 0; i < checkProperties.size(); i++) { - checkProperties[i]->set_sensitive(on); + for(auto & checkPropertie : checkProperties) { + checkPropertie->set_sensitive(on); } } diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index 549c3d665..bf371588a 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -200,8 +200,7 @@ std::vector FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli // CSS font fallbacks can have more that one font listed, split the font list std::vector vFonts = Glib::Regex::split_simple("," , fonts); bool fontFound = false; - for(size_t i=0; iattach( *Gtk::manage(label), 0, row, 1, 1); scriptCombo = Gtk::manage(new Gtk::ComboBoxText()); - for (std::map::iterator it = getScriptToName().begin(); it != getScriptToName().end(); ++it) + for (auto & it : getScriptToName()) { - scriptCombo->append(it->second); + scriptCombo->append(it.second); } scriptCombo->set_active_text(getScriptToName()[G_UNICODE_SCRIPT_INVALID_CODE]); @@ -379,8 +379,8 @@ GlyphsPanel::GlyphsPanel() : table->attach( *Gtk::manage(label), 0, row, 1, 1); rangeCombo = Gtk::manage(new Gtk::ComboBoxText()); - for ( std::vector::iterator it = getRanges().begin(); it != getRanges().end(); ++it ) { - rangeCombo->append(it->second); + for (auto & it : getRanges()) { + rangeCombo->append(it.second); } rangeCombo->set_active_text(getRanges()[1].second); @@ -463,12 +463,12 @@ GlyphsPanel::GlyphsPanel() : GlyphsPanel::~GlyphsPanel() { - for (std::vector::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { - it->disconnect(); + for (auto & instanceConn : instanceConns) { + instanceConn.disconnect(); } instanceConns.clear(); - for (std::vector::iterator it = desktopConns.begin(); it != desktopConns.end(); ++it) { - it->disconnect(); + for (auto & desktopConn : desktopConns) { + desktopConn.disconnect(); } desktopConns.clear(); } @@ -484,8 +484,8 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop) { if (targetDesktop != desktop) { if (targetDesktop) { - for (std::vector::iterator it = desktopConns.begin(); it != desktopConns.end(); ++it) { - it->disconnect(); + for (auto & desktopConn : desktopConns) { + desktopConn.disconnect(); } desktopConns.clear(); } @@ -655,9 +655,9 @@ void GlyphsPanel::rebuild() GUnicodeScript script = G_UNICODE_SCRIPT_INVALID_CODE; Glib::ustring scriptName = scriptCombo->get_active_text(); std::map items = getScriptToName(); - for (std::map::iterator it = items.begin(); it != items.end(); ++it) { - if (scriptName == it->second) { - script = it->first; + for (auto & item : items) { + if (scriptName == item.second) { + script = item.first; break; } } @@ -685,12 +685,12 @@ void GlyphsPanel::rebuild() GlyphColumns *columns = getColumns(); store->clear(); - for (std::vector::iterator it = present.begin(); it != present.end(); ++it) + for (unsigned int & it : present) { Gtk::ListStore::iterator row = store->append(); Glib::ustring tmp; - tmp += *it; - (*row)[columns->code] = *it; + tmp += it; + (*row)[columns->code] = it; (*row)[columns->name] = tmp; } diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index ba3df005e..2bef67d42 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -198,8 +198,7 @@ cnt=0; const std::vector sizes(sorted); - for (std::vector::const_iterator i = sizes.begin();i!=sizes.end(); ++i) { - SPItem *item = *i; + for (auto item : sizes) { Geom::OptRect b = item->documentVisualBounds(); if (b) { width = b->dimensions()[Geom::X]; diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index e3f157a2b..bec6298d5 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -111,9 +111,9 @@ IconPreviewPanel::IconPreviewPanel() : std::vector pref_sizes = prefs->getAllDirs("/iconpreview/sizes/default"); std::vector rawSizes; - for (std::vector::iterator i = pref_sizes.begin(); i != pref_sizes.end(); ++i) { - if (prefs->getBool(*i + "/show", true)) { - int sizeVal = prefs->getInt(*i + "/value", -1); + for (auto & pref_size : pref_sizes) { + if (prefs->getBool(pref_size + "/show", true)) { + int sizeVal = prefs->getInt(pref_size + "/value", -1); if (sizeVal > 0) { rawSizes.push_back(sizeVal); } diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 2a6cb9ebe..e2be3d431 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1385,9 +1385,9 @@ void InkscapePreferences::initPageIO() gint index = 0; _cms_display_profile.append(_("")); index++; - for ( std::vector::iterator it = names.begin(); it != names.end(); ++it ) { - _cms_display_profile.append( *it ); - Glib::ustring path = CMSSystem::getPathForProfile(*it); + for (auto & name : names) { + _cms_display_profile.append( name ); + Glib::ustring path = CMSSystem::getPathForProfile(name); if ( !path.empty() && path == current ) { _cms_display_profile.set_active(index); } @@ -1400,9 +1400,9 @@ void InkscapePreferences::initPageIO() names = ::Inkscape::CMSSystem::getSoftproofNames(); current = prefs->getString("/options/softproof/uri"); index = 0; - for ( std::vector::iterator it = names.begin(); it != names.end(); ++it ) { - _cms_proof_profile.append( *it ); - Glib::ustring path = CMSSystem::getPathForProfile(*it); + for (auto & name : names) { + _cms_proof_profile.append( name ); + Glib::ustring path = CMSSystem::getPathForProfile(name); if ( !path.empty() && path == current ) { _cms_proof_profile.set_active(index); } @@ -2114,9 +2114,8 @@ void InkscapePreferences::onKBListKeyboardShortcuts() std::vectorverbs = Inkscape::Verb::getList(); - for (unsigned int i = 0; i < verbs.size(); i++) { + for (auto verb : verbs) { - Inkscape::Verb* verb = verbs[i]; if (!verb) { continue; } diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index b1578d6dc..080a4de12 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -624,9 +624,9 @@ InputDialogImpl::InputDialogImpl() : { guint col = 0; guint row = 1; - for ( guint num = 0; num < G_N_ELEMENTS(testButtons); num++ ) { - testButtons[num].set(getPix(PIX_BUTTONS_NONE)); - imageTable.attach(testButtons[num], col, row, 1, 1); + for (auto & testButton : testButtons) { + testButton.set(getPix(PIX_BUTTONS_NONE)); + imageTable.attach(testButton, col, row, 1, 1); col++; if (col > 7) { col = 0; @@ -635,9 +635,9 @@ InputDialogImpl::InputDialogImpl() : } col = 0; - for ( guint num = 0; num < G_N_ELEMENTS(testAxes); num++ ) { - testAxes[num].set(getPix(PIX_AXIS_NONE)); - imageTable.attach(testAxes[num], col * 2, row, 2, 1); + for (auto & testAxe : testAxes) { + testAxe.set(getPix(PIX_AXIS_NONE)); + imageTable.attach(testAxe, col * 2, row, 2, 1); col++; if (col > 3) { col = 0; @@ -678,14 +678,14 @@ InputDialogImpl::InputDialogImpl() : axisTable.attach(devAxesCount, 1, rowNum, 1, 1); rowNum++; - for ( guint barNum = 0; barNum < static_cast(G_N_ELEMENTS(axesValues)); barNum++ ) { + for (auto & axesValue : axesValues) { lbl = Gtk::manage(new Gtk::Label(_("axis:"))); lbl->set_hexpand(); axisTable.attach(*lbl, 0, rowNum, 1, 1); - axesValues[barNum].set_hexpand(); - axisTable.attach(axesValues[barNum], 1, rowNum, 1, 1); - axesValues[barNum].set_sensitive(false); + axesValue.set_hexpand(); + axisTable.attach(axesValue, 1, rowNum, 1, 1); + axesValue.set_sensitive(false); rowNum++; @@ -760,9 +760,9 @@ static Glib::ustring getCommon( std::list const &names ) while ( match ) { if ( names.begin()->length() > pos ) { gunichar ch = (*names.begin())[pos]; - for ( std::list::const_iterator it = names.begin(); it != names.end(); ++it ) { - if ( (pos >= it->length()) - || ((*it)[pos] != ch) ) { + for (const auto & name : names) { + if ( (pos >= name.length()) + || (name[pos] != ch) ) { match = false; break; } @@ -810,8 +810,7 @@ void InputDialogImpl::setupTree( Glib::RefPtr store, Gtk::TreeIt std::set consumed; // Phase 1 - figure out which tablets are present - for ( std::list >::iterator it = devList.begin(); it != devList.end(); ++it ) { - Glib::RefPtr dev = *it; + for (auto dev : devList) { if ( dev ) { if ( dev->getSource() != Gdk::SOURCE_MOUSE ) { consumed.insert( dev->getId() ); @@ -827,28 +826,28 @@ void InputDialogImpl::setupTree( Glib::RefPtr store, Gtk::TreeIt } // Phase 2 - build a UI for the present devices - for ( std::list::iterator it = tablets.begin(); it != tablets.end(); ++it ) { + for (auto & it : tablets) { tablet = store->prepend(/*row.children()*/); Gtk::TreeModel::Row childrow = *tablet; - if ( it->name.empty() ) { + if ( it.name.empty() ) { // Check to see if we can derive one std::list names; - for ( std::list >::iterator it2 = it->devices.begin(); it2 != it->devices.end(); ++it2 ) { + for ( std::list >::iterator it2 = it.devices.begin(); it2 != it.devices.end(); ++it2 ) { names.push_back( (*it2)->getName() ); } Glib::ustring common = getCommon(names); if ( !common.empty() ) { - it->name = common; + it.name = common; } } - childrow[getCols().description] = it->name.empty() ? _("Tablet") : it->name ; + childrow[getCols().description] = it.name.empty() ? _("Tablet") : it.name ; childrow[getCols().thumbnail] = getPix(PIX_TABLET); // Check if there is an eraser we can link to a pen - for ( std::list >::iterator it2 = it->devices.begin(); it2 != it->devices.end(); ++it2 ) { + for ( std::list >::iterator it2 = it.devices.begin(); it2 != it.devices.end(); ++it2 ) { Glib::RefPtr dev = *it2; if ( dev->getSource() == Gdk::SOURCE_PEN ) { - for ( std::list >::iterator it3 = it->devices.begin(); it3 != it->devices.end(); ++it3 ) { + for ( std::list >::iterator it3 = it.devices.begin(); it3 != it.devices.end(); ++it3 ) { Glib::RefPtr dev2 = *it3; if ( dev2->getSource() == Gdk::SOURCE_ERASER ) { DeviceManager::getManager().setLinkedTo(dev->getId(), dev2->getId()); @@ -859,7 +858,7 @@ void InputDialogImpl::setupTree( Glib::RefPtr store, Gtk::TreeIt } } - for ( std::list >::iterator it2 = it->devices.begin(); it2 != it->devices.end(); ++it2 ) { + for ( std::list >::iterator it2 = it.devices.begin(); it2 != it.devices.end(); ++it2 ) { Glib::RefPtr dev = *it2; Gtk::TreeModel::Row deviceRow = *(store->append(childrow.children())); deviceRow[getCols().description] = dev->getName(); @@ -888,8 +887,7 @@ void InputDialogImpl::setupTree( Glib::RefPtr store, Gtk::TreeIt } } - for ( std::list >::iterator it = devList.begin(); it != devList.end(); ++it ) { - Glib::RefPtr dev = *it; + for (auto dev : devList) { if ( dev && (consumed.find( dev->getId() ) == consumed.end()) ) { Gtk::TreeModel::Row deviceRow = *(store->prepend(/*row.children()*/)); deviceRow[getCols().description] = dev->getName(); @@ -1188,9 +1186,9 @@ void InputDialogImpl::handleDeviceChange(Glib::RefPtr device) stores.push_back(deviceStore); stores.push_back(cfgPanel.confDeviceStore); - for (std::vector >::iterator it = stores.begin(); it != stores.end(); ++it) { + for (auto & store : stores) { Gtk::TreeModel::iterator deviceIter; - (*it)->foreach_iter( sigc::bind( + store->foreach_iter( sigc::bind( sigc::ptr_fun(&InputDialogImpl::findDevice), device->getId(), &deviceIter) ); @@ -1572,10 +1570,10 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev ) } } if ( !dev ) { - for ( gint i = 0; i < static_cast(G_N_ELEMENTS(axesValues)); i++ ) { - axesValues[i].set_fraction(0.0); - axesValues[i].set_text(""); - axesValues[i].set_sensitive(false); + for (auto & axesValue : axesValues) { + axesValue.set_fraction(0.0); + axesValue.set_text(""); + axesValue.set_sensitive(false); } } } diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 46c733bf5..79bf767c7 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -480,14 +480,14 @@ void LayersPanel::_checkTreeSelection() } - for ( std::vector::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( sensitive ); + for (auto & it : _watching) { + it->set_sensitive( sensitive ); } - for ( std::vector::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonTop ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( sensitiveNonTop ); } - for ( std::vector::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonBottom ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( sensitiveNonBottom ); } } @@ -927,14 +927,14 @@ LayersPanel::LayersPanel() : - for ( std::vector::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watching) { + it->set_sensitive( false ); } - for ( std::vector::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( false ); } - for ( std::vector::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( false ); } setDesktop( targetDesktop ); diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 2954ea418..9e115a2d6 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -661,14 +661,14 @@ void ObjectsPanel::_checkTreeSelection() bool sensitiveNonTop = true; bool sensitiveNonBottom = true; - for ( std::vector::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( sensitive ); + for (auto & it : _watching) { + it->set_sensitive( sensitive ); } - for ( std::vector::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonTop ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( sensitiveNonTop ); } - for ( std::vector::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonBottom ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( sensitiveNonBottom ); } } @@ -1478,9 +1478,8 @@ void ObjectsPanel::_highlightPickerColorMod() guint32 rgba = color.toRGBA32( alpha ); //Set the highlight color for all items in the _highlight_target (all selected items) - for (std::vector::iterator iter = _highlight_target.begin(); iter != _highlight_target.end(); ++iter) + for (auto target : _highlight_target) { - SPItem * target = *iter; target->setHighlightColor(rgba); target->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); } @@ -1929,14 +1928,14 @@ ObjectsPanel::ObjectsPanel() : // ------------------------------------------------------- //Set initial sensitivity of buttons - for ( std::vector::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watching) { + it->set_sensitive( false ); } - for ( std::vector::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( false ); } - for ( std::vector::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( false ); } //Set up the color selection dialog diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 821e75ea8..de026b8d5 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -269,13 +269,11 @@ void PolarArrangeTab::arrange() bool arrangeOnFirstEllipse = arrangeOnEllipse && arrangeOnFirstCircleRadio.get_active(); int count = 0; - for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();++i) + for(auto item : tmp) { if(arrangeOnEllipse) { - SPItem *item = *i; - - if(arrangeOnFirstEllipse) + if(arrangeOnFirstEllipse) { // The first selected ellipse is actually the last one in the list if(SP_IS_GENERICELLIPSE(item)) @@ -338,11 +336,9 @@ void PolarArrangeTab::arrange() Geom::Point realCenter = Geom::Point(cx, cy) * transformation; int i = 0; - for(std::vector::const_iterator it=tmp.begin();it!=tmp.end(); ++it) + for(auto item : tmp) { - SPItem *item = *it; - - // Ignore the reference ellipse if any + // Ignore the reference ellipse if any if(item != referenceEllipse) { float angle = calcAngle(arcBeg, arcEnd, count, i); diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 2f485bcce..cffd284a1 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -498,8 +498,8 @@ SpellCheck::nextWord() // skip words containing digits if (_prefs->getInt(_prefs_path + "ignorenumbers") != 0) { bool digits = false; - for (unsigned int i = 0; i < _word.size(); i++) { - if (g_unichar_isdigit(_word[i])) { + for (unsigned int i : _word) { + if (g_unichar_isdigit(i)) { digits = true; break; } @@ -512,8 +512,8 @@ SpellCheck::nextWord() // skip ALL-CAPS words if (_prefs->getInt(_prefs_path + "ignoreallcaps") != 0) { bool allcaps = true; - for (unsigned int i = 0; i < _word.size(); i++) { - if (!g_unichar_isupper(_word[i])) { + for (unsigned int i : _word) { + if (!g_unichar_isupper(i)) { allcaps = false; break; } @@ -564,15 +564,15 @@ SpellCheck::nextWord() if (points.size() >= 4) { // we may not have a single quad if this is a clipped part of text on path; in that case skip drawing the rect Geom::Point tl, br; tl = br = points.front(); - for (unsigned i = 0 ; i < points.size() ; i ++) { - if (points[i][Geom::X] < tl[Geom::X]) - tl[Geom::X] = points[i][Geom::X]; - if (points[i][Geom::Y] < tl[Geom::Y]) - tl[Geom::Y] = points[i][Geom::Y]; - if (points[i][Geom::X] > br[Geom::X]) - br[Geom::X] = points[i][Geom::X]; - if (points[i][Geom::Y] > br[Geom::Y]) - br[Geom::Y] = points[i][Geom::Y]; + for (auto & point : points) { + if (point[Geom::X] < tl[Geom::X]) + tl[Geom::X] = point[Geom::X]; + if (point[Geom::Y] < tl[Geom::Y]) + tl[Geom::Y] = point[Geom::Y]; + if (point[Geom::X] > br[Geom::X]) + br[Geom::X] = point[Geom::X]; + if (point[Geom::Y] > br[Geom::Y]) + br[Geom::Y] = point[Geom::Y]; } // expand slightly diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index f3a44f690..3fad9962e 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -853,8 +853,7 @@ void StyleDialog::_selectObjects(int eventX, int eventY) Gtk::TreeModel::Children children = row.children(); std::vector objVec = row[_mColumns._colObj]; - for (unsigned i = 0; i < objVec.size(); ++i) { - SPObject *obj = objVec[i]; + for (auto obj : objVec) { getDesktop()->selection->add(obj); } } @@ -1292,13 +1291,11 @@ void StyleDialog::_selectRow() SPObject *obj = selection->objects().back(); Gtk::TreeModel::Children children = _store->children(); - for(Gtk::TreeModel::Children::iterator iter = children.begin(); - iter != children.end(); ++iter) { + for(auto row : children) { - Gtk::TreeModel::Row row = *iter; std::vector objVec = row[_mColumns._colObj]; - for (unsigned i = 0; i < objVec.size(); ++i) { - if (obj->getId() == objVec[i]->getId()) { + for (auto & i : objVec) { + if (obj->getId() == i->getId()) { _treeView.get_selection()->select(row); _updateCSSPanel(); return; diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index fabbf720b..7884e39f0 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -317,8 +317,8 @@ bool colorItemHandleButtonPress(GdkEventButton* event, UI::Widget::Preview *prev if ( user_data ) { ColorItem* item = reinterpret_cast(user_data); bool show = swp && (swp->getSelectedIndex() == 0); - for ( std::vector::iterator it = popupExtras.begin(); it != popupExtras.end(); ++ it) { - gtk_widget_set_sensitive(*it, show); + for (auto & popupExtra : popupExtras) { + gtk_widget_set_sensitive(popupExtra, show); } bounceTarget = item; @@ -625,9 +625,9 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : first = docPalettes[nullptr]; } else { std::vector pages = _getSwatchSets(); - for ( std::vector::iterator iter = pages.begin(); iter != pages.end(); ++iter ) { - if ( (*iter)->_name == targetName ) { - first = *iter; + for (auto & page : pages) { + if ( page->_name == targetName ) { + first = page; break; } index++; @@ -649,8 +649,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : int i = 0; std::vector swatchSets = _getSwatchSets(); - for ( std::vector::iterator it = swatchSets.begin(); it != swatchSets.end(); ++it) { - SwatchPage* curr = *it; + for (auto curr : swatchSets) { Gtk::RadioMenuItem* single = Gtk::manage(new Gtk::RadioMenuItem(groupOne, curr->_name)); if ( curr == first ) { hotItem = single; @@ -1076,15 +1075,13 @@ bool DocTrack::handleTimerCB() double now = timer->elapsed(); std::vector needCallback; - for (std::vector::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it) { - DocTrack *track = *it; + for (auto track : docTrackings) { if ( track->updatePending && ( (now - track->lastGradientUpdate) >= DOC_UPDATE_THREASHOLD) ) { needCallback.push_back(track); } } - for (std::vector::iterator it = needCallback.begin(); it != needCallback.end(); ++it) { - DocTrack *track = *it; + for (auto track : needCallback) { if ( std::find(docTrackings.begin(), docTrackings.end(), track) != docTrackings.end() ) { // Just in case one gets deleted while we are looping // Note: calling handleDefsModified will call queueUpdateIfNeeded and thus update the time and flag. SwatchesPanel::handleDefsModified(track->doc); @@ -1097,8 +1094,7 @@ bool DocTrack::handleTimerCB() bool DocTrack::queueUpdateIfNeeded( SPDocument *doc ) { bool deferProcessing = false; - for (std::vector::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it) { - DocTrack *track = *it; + for (auto track : docTrackings) { if ( track->doc == doc ) { double now = timer->elapsed(); double elapsed = now - track->lastGradientUpdate; @@ -1193,10 +1189,8 @@ static void recalcSwatchContents(SPDocument* doc, if ( !newList.empty() ) { std::reverse(newList.begin(), newList.end()); - for ( std::vector::iterator it = newList.begin(); it != newList.end(); ++it ) + for (auto grad : newList) { - SPGradient* grad = *it; - cairo_surface_t *preview = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PREVIEW_PIXBUF_WIDTH, VBLOCK); cairo_t *ct = cairo_create(preview); @@ -1235,22 +1229,22 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) std::map tmpGrads; recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads); - for (std::map::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { - it->first->setPattern(it->second); - cairo_pattern_destroy(it->second); + for (auto & tmpPrev : tmpPrevs) { + tmpPrev.first->setPattern(tmpPrev.second); + cairo_pattern_destroy(tmpPrev.second); } - for (std::map::iterator it = tmpGrads.begin(); it != tmpGrads.end(); ++it) { - it->first->setGradient(it->second); + for (auto & tmpGrad : tmpGrads) { + tmpGrad.first->setGradient(tmpGrad.second); } docPalette->_colors.swap(tmpColors); // Figure out which SwatchesPanel instances are affected and update them. - for (std::map::iterator it = docPerPanel.begin(); it != docPerPanel.end(); ++it) { - if (it->second == document) { - SwatchesPanel* swp = it->first; + for (auto & it : docPerPanel) { + if (it.second == document) { + SwatchesPanel* swp = it.first; std::vector pages = swp->_getSwatchSets(); SwatchPage* curr = pages[swp->_currentIndex]; if (curr == docPalette) { @@ -1292,8 +1286,8 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) } } - for (std::map::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { - cairo_pattern_destroy(it->second); + for (auto & tmpPrev : tmpPrevs) { + cairo_pattern_destroy(tmpPrev.second); } } } @@ -1385,8 +1379,8 @@ void SwatchesPanel::_updateFromSelection() } } - for ( boost::ptr_vector::iterator it = docPalette->_colors.begin(); it != docPalette->_colors.end(); ++it ) { - ColorItem* item = &*it; + for (auto & _color : docPalette->_colors) { + ColorItem* item = &_color; bool isFill = (fillId == item->def.descr); bool isStroke = (strokeId == item->def.descr); item->setState( isFill, isStroke ); @@ -1406,8 +1400,8 @@ void SwatchesPanel::_rebuild() _holder->freezeUpdates(); // TODO restore once 'clear' works _holder->addPreview(_clear); _holder->addPreview(_remove); - for ( boost::ptr_vector::iterator it = curr->_colors.begin(); it != curr->_colors.end(); ++it) { - _holder->addPreview(&*it); + for (auto & _color : curr->_colors) { + _holder->addPreview(&_color); } _holder->thawUpdates(); } diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index ec49a2317..fa76fc31a 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -393,8 +393,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : SymbolsDialog::~SymbolsDialog() { - for (std::vector::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { - it->disconnect(); + for (auto & instanceConn : instanceConns) { + instanceConn.disconnect(); } idleconn.disconnect(); instanceConns.clear(); diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 4ed279444..67f196770 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -239,8 +239,7 @@ bool TagsPanel::_executeAction() { std::vector todelete; _tree.get_selection()->selected_foreach_iter(sigc::bind*>(sigc::mem_fun(*this, &TagsPanel::_checkForDeleted), &todelete)); - for (std::vector::iterator iter = todelete.begin(); iter != todelete.end(); ++iter) { - SPObject * obj = *iter; + for (auto obj : todelete) { if (obj && obj->parent && obj->getRepr() && obj->parent->getRepr()) { //obj->parent->getRepr()->removeChild(obj->getRepr()); obj->deleteObject(true, true); @@ -501,14 +500,14 @@ void TagsPanel::_checkTreeSelection() // } - for ( std::vector::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( sensitive ); + for (auto & it : _watching) { + it->set_sensitive( sensitive ); } - for ( std::vector::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonTop ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( sensitiveNonTop ); } - for ( std::vector::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonBottom ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( sensitiveNonBottom ); } } @@ -537,8 +536,7 @@ bool TagsPanel::_handleKeyEvent(GdkEventKey *event) std::vector todelete; _tree.get_selection()->selected_foreach_iter(sigc::bind*>(sigc::mem_fun(*this, &TagsPanel::_checkForDeleted), &todelete)); if (!todelete.empty()) { - for (std::vector::iterator iter = todelete.begin(); iter != todelete.end(); ++iter) { - SPObject * obj = *iter; + for (auto obj : todelete) { if (obj && obj->parent && obj->getRepr() && obj->parent->getRepr()) { //obj->parent->getRepr()->removeChild(obj->getRepr()); obj->deleteObject(true, true); @@ -652,8 +650,7 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) // FIXME unnecessary use of XML tree _tree.get_selection()->selected_foreach_iter(sigc::bind*>(sigc::mem_fun(*this, &TagsPanel::_checkForDeleted), &todelete)); if (!todelete.empty()) { - for (std::vector::iterator iter = todelete.begin(); iter != todelete.end(); ++iter) { - SPObject * tobj = *iter; + for (auto tobj : todelete) { if (tobj && tobj->parent && tobj->getRepr() && tobj->parent->getRepr()) { //tobj->parent->getRepr()->removeChild(tobj->getRepr()); tobj->deleteObject(true, true); @@ -788,9 +785,8 @@ bool TagsPanel::_handleDragDrop(const Glib::RefPtr& /*context* void TagsPanel::_doTreeMove( ) { if (_dnd_target) { - for (std::vector::iterator iter = _dnd_source.begin(); iter != _dnd_source.end(); ++iter) + for (auto src : _dnd_source) { - SPTag *src = *iter; if (src != _dnd_target) { src->moveTo(_dnd_target, _dnd_into); } @@ -1009,14 +1005,14 @@ TagsPanel::TagsPanel() : - for ( std::vector::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watching) { + it->set_sensitive( false ); } - for ( std::vector::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( false ); } - for ( std::vector::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( false ); } setDesktop( targetDesktop ); diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index c4b5b5254..ed38c27cd 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -99,8 +99,8 @@ void TemplateLoadTab::_initKeywordsList() { _keywords_combo.append(_("All")); - for (std::set::iterator it = _keywords.begin() ; it != _keywords.end() ; ++it){ - _keywords_combo.append(*it); + for (const auto & _keyword : _keywords){ + _keywords_combo.append(_keyword); } } @@ -147,36 +147,36 @@ void TemplateLoadTab::_refreshTemplatesList() switch (_current_search_type){ case ALL :{ - for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { + for (auto & it : _tdata) { Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; - row[_columns.textValue] = it->first; + row[_columns.textValue] = it.first; } break; } case LIST_KEYWORD: { - for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword.lowercase()) != 0){ + for (auto & it : _tdata) { + if (it.second.keywords.count(_current_keyword.lowercase()) != 0){ Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; - row[_columns.textValue] = it->first; + row[_columns.textValue] = it.first; } } break; } case USER_SPECIFIED : { - for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword.lowercase()) != 0 || - it->second.display_name.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || - it->second.author.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || - it->second.short_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || - it->second.long_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos ) + for (auto & it : _tdata) { + if (it.second.keywords.count(_current_keyword.lowercase()) != 0 || + it.second.display_name.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it.second.author.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it.second.short_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it.second.long_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos ) { Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; - row[_columns.textValue] = it->first; + row[_columns.textValue] = it.first; } } break; diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 532ac2cdb..be94b79c0 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -128,8 +128,8 @@ void TemplateWidget::_displayTemplateDetails() message += _("Description: ") + _current_template.long_description + "\n\n"; if (!_current_template.keywords.empty()){ message += _("Keywords: "); - for (std::set::iterator it = _current_template.keywords.begin(); it != _current_template.keywords.end(); ++it) - message += *it + " "; + for (const auto & keyword : _current_template.keywords) + message += keyword + " "; message += "\n\n"; } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 7edacc4ce..50631a16b 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -655,12 +655,9 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (fabs(x) > 1e-6) { std::vector< BBoxSort > sorted; - for (std::vector::iterator it(selected.begin()); - it != selected.end(); - ++it) + for (auto item : selected) { - SPItem* item = *it; - Geom::OptRect bbox = item->desktopPreferredBounds(); + Geom::OptRect bbox = item->desktopPreferredBounds(); if (bbox) { sorted.emplace_back(item, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.); } @@ -680,12 +677,9 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) } if (fabs(y) > 1e-6) { std::vector< BBoxSort > sorted; - for (std::vector::iterator it(selected.begin()); - it != selected.end(); - ++it) + for (auto item : selected) { - SPItem* item = *it; - Geom::OptRect bbox = item->desktopPreferredBounds(); + Geom::OptRect bbox = item->desktopPreferredBounds(); if (bbox) { sorted.emplace_back(item, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.); } diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 0ca0f0ec6..61398a788 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -209,8 +209,8 @@ sp_create_window(SPViewWidget *vw, bool editable) } int pos = nui_drop_target_entries; - for (std::vector::iterator it = types.begin() ; it != types.end() ; ++it) { - completeDropTargets[pos].target = g_strdup((*it).c_str()); + for (auto & type : types) { + completeDropTargets[pos].target = g_strdup(type.c_str()); completeDropTargets[pos].flags = 0; completeDropTargets[pos].info = IMAGE_DATA; pos++; diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index 915ed2a78..fc069e5bf 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -136,8 +136,8 @@ void ControlPointSelection::clear() /** Select all points that this selection can contain. */ void ControlPointSelection::selectAll() { - for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { - insert(*i, false); + for (auto _all_point : _all_points) { + insert(_all_point, false); } std::vector out(_all_points.begin(), _all_points.end()); if (!out.empty()) @@ -147,10 +147,10 @@ void ControlPointSelection::selectAll() void ControlPointSelection::selectArea(Geom::Rect const &r) { std::vector out; - for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { - if (r.contains(**i)) { - insert(*i, false); - out.push_back(*i); + for (auto _all_point : _all_points) { + if (r.contains(*_all_point)) { + insert(_all_point, false); + out.push_back(_all_point); } } if (!out.empty()) @@ -160,14 +160,14 @@ void ControlPointSelection::selectArea(Geom::Rect const &r) void ControlPointSelection::invertSelection() { std::vector in, out; - for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { - if ((*i)->selected()) { - in.push_back(*i); - erase(*i); + for (auto _all_point : _all_points) { + if (_all_point->selected()) { + in.push_back(_all_point); + erase(_all_point); } else { - out.push_back(*i); - insert(*i, false); + out.push_back(_all_point); + insert(_all_point, false); } } if (!in.empty()) @@ -181,21 +181,21 @@ void ControlPointSelection::spatialGrow(SelectableControlPoint *origin, int dir) Geom::Point p = origin->position(); double best_dist = grow ? HUGE_VAL : 0; SelectableControlPoint *match = nullptr; - for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { - bool selected = (*i)->selected(); + for (auto _all_point : _all_points) { + bool selected = _all_point->selected(); if (grow && !selected) { - double dist = Geom::distance((*i)->position(), p); + double dist = Geom::distance(_all_point->position(), p); if (dist < best_dist) { best_dist = dist; - match = *i; + match = _all_point; } } if (!grow && selected) { - double dist = Geom::distance((*i)->position(), p); + double dist = Geom::distance(_all_point->position(), p); // use >= to also deselect the origin node when it's the last one selected if (dist >= best_dist) { best_dist = dist; - match = *i; + match = _all_point; } } } @@ -209,8 +209,7 @@ void ControlPointSelection::spatialGrow(SelectableControlPoint *origin, int dir) /** Transform all selected control points by the given affine transformation. */ void ControlPointSelection::transform(Geom::Affine const &m) { - for (iterator i = _points.begin(); i != _points.end(); ++i) { - SelectableControlPoint *cur = *i; + for (auto cur : _points) { cur->transform(m); } _updateBounds(); @@ -230,8 +229,8 @@ void ControlPointSelection::align(Geom::Dim2 axis) Geom::OptInterval bound; - for (iterator i = _points.begin(); i != _points.end(); ++i) { - bound.unionWith(Geom::OptInterval((*i)->position()[d])); + for (auto _point : _points) { + bound.unionWith(Geom::OptInterval(_point->position()[d])); } if (!bound) { return; } @@ -257,10 +256,10 @@ void ControlPointSelection::align(Geom::Dim2 axis) return; } - for (iterator i = _points.begin(); i != _points.end(); ++i) { - Geom::Point pos = (*i)->position(); + for (auto _point : _points) { + Geom::Point pos = _point->position(); pos[d] = new_coord; - (*i)->move(pos); + _point->move(pos); } } @@ -276,9 +275,9 @@ void ControlPointSelection::distribute(Geom::Dim2 d) Geom::OptInterval bound; // first we insert all points into a multimap keyed by the aligned coord to sort them // simultaneously we compute the extent of selection - for (iterator i = _points.begin(); i != _points.end(); ++i) { - Geom::Point pos = (*i)->position(); - sm.insert(std::make_pair(pos[d], (*i))); + for (auto _point : _points) { + Geom::Point pos = _point->position(); + sm.insert(std::make_pair(pos[d], _point)); bound.unionWith(Geom::OptInterval(pos[d])); } @@ -345,13 +344,13 @@ void ControlPointSelection::_pointGrabbed(SelectableControlPoint *point) double maxdist = 0; Geom::Affine m; m.setIdentity(); - for (iterator i = _points.begin(); i != _points.end(); ++i) { - _original_positions.insert(std::make_pair(*i, (*i)->position())); - _last_trans.insert(std::make_pair(*i, m)); - double dist = Geom::distance(*_grabbed_point, **i); + for (auto _point : _points) { + _original_positions.insert(std::make_pair(_point, _point->position())); + _last_trans.insert(std::make_pair(_point, m)); + double dist = Geom::distance(*_grabbed_point, *_point); if (dist > maxdist) { maxdist = dist; - _farthest_point = *i; + _farthest_point = _point; } } } @@ -362,8 +361,7 @@ void ControlPointSelection::_pointDragged(Geom::Point &new_pos, GdkEventMotion * double fdist = Geom::distance(_original_positions[_grabbed_point], _original_positions[_farthest_point]); if (held_only_alt(*event) && fdist > 0) { // Sculpting - for (iterator i = _points.begin(); i != _points.end(); ++i) { - SelectableControlPoint *cur = (*i); + for (auto cur : _points) { Geom::Affine trans; trans.setIdentity(); double dist = Geom::distance(_original_positions[cur], _original_positions[_grabbed_point]); @@ -410,8 +408,7 @@ void ControlPointSelection::_pointDragged(Geom::Point &new_pos, GdkEventMotion * } } else { Geom::Point delta = new_pos - _grabbed_point->position(); - for (iterator i = _points.begin(); i != _points.end(); ++i) { - SelectableControlPoint *cur = (*i); + for (auto cur : _points) { cur->move(_original_positions[cur] + abs_delta); } _handles->rotationCenter().move(_handles->rotationCenter().position() + delta); @@ -461,8 +458,7 @@ void ControlPointSelection::_updateBounds() { _rot_radius = boost::none; _bounds = Geom::OptRect(); - for (iterator i = _points.begin(); i != _points.end(); ++i) { - SelectableControlPoint *cur = (*i); + for (auto cur : _points) { Geom::Point p = cur->position(); if (!_bounds) { _bounds = Geom::Rect(p, p); @@ -719,8 +715,8 @@ bool ControlPointSelection::event(Inkscape::UI::Tools::ToolBase * /*event_contex void ControlPointSelection::getOriginalPoints(std::vector &pts) { pts.clear(); - for (iterator i = _points.begin(); i != _points.end(); ++i) { - pts.emplace_back(_original_positions[*i], SNAPSOURCE_NODE_HANDLE); + for (auto _point : _points) { + pts.emplace_back(_original_positions[_point], SNAPSOURCE_NODE_HANDLE); } } @@ -728,9 +724,9 @@ void ControlPointSelection::getUnselectedPoints(std::vectorallPoints(); - for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - if (!(*i)->selected()) { - Node *n = static_cast(*i); + for (auto node : nodes) { + if (!node->selected()) { + Node *n = static_cast(node); pts.push_back(n->snapCandidatePoint()); } } @@ -739,8 +735,8 @@ void ControlPointSelection::getUnselectedPoints(std::vectorposition())); + for (auto _point : _points) { + _original_positions.insert(std::make_pair(_point, _point->position())); } } diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index b107ab359..08114ac03 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -58,8 +58,8 @@ void find_join_iterators(ControlPointSelection &sel, IterPairList &pairs) IterSet join_iters; // find all endnodes in selection - for (ControlPointSelection::iterator i = sel.begin(); i != sel.end(); ++i) { - Node *node = dynamic_cast(*i); + for (auto i : sel) { + Node *node = dynamic_cast(i); if (!node) continue; NodeList::iterator iter = NodeList::get_iterator(node); if (!iter.next() || !iter.prev()) join_iters.insert(iter); @@ -181,8 +181,7 @@ void MultiPathManipulator::setItems(std::set const &s) } // add newly selected items - for (std::set::iterator i = shapes.begin(); i != shapes.end(); ++i) { - ShapeRecord const &r = *i; + for (const auto & r : shapes) { if (!SP_IS_PATH(r.item) && !IS_LIVEPATHEFFECT(r.item)) continue; std::shared_ptr newpm(new PathManipulator(*this, (SPPath*) r.item, r.edit_transform, _getOutlineColor(r.role, r.item), r.lpe_key)); @@ -297,8 +296,8 @@ void MultiPathManipulator::setNodeType(NodeType type) // When all selected nodes are already cusp, retract their handles bool retract_handles = (type == NODE_CUSP); - for (ControlPointSelection::iterator i = _selection.begin(); i != _selection.end(); ++i) { - Node *node = dynamic_cast(*i); + for (auto i : _selection) { + Node *node = dynamic_cast(i); if (node) { retract_handles &= (node->type() == NODE_CUSP); node->setType(type); @@ -306,8 +305,8 @@ void MultiPathManipulator::setNodeType(NodeType type) } if (retract_handles) { - for (ControlPointSelection::iterator i = _selection.begin(); i != _selection.end(); ++i) { - Node *node = dynamic_cast(*i); + for (auto i : _selection) { + Node *node = dynamic_cast(i); if (node) { node->front()->retract(); node->back()->retract(); @@ -371,37 +370,37 @@ void MultiPathManipulator::joinNodes() } find_join_iterators(_selection, joins); - for (IterPairList::iterator i = joins.begin(); i != joins.end(); ++i) { - bool same_path = prepare_join(*i); - NodeList &sp_first = NodeList::get(i->first); - NodeList &sp_second = NodeList::get(i->second); - i->first->setType(NODE_CUSP, false); + for (auto & join : joins) { + bool same_path = prepare_join(join); + NodeList &sp_first = NodeList::get(join.first); + NodeList &sp_second = NodeList::get(join.second); + join.first->setType(NODE_CUSP, false); Geom::Point joined_pos, pos_handle_front, pos_handle_back; - pos_handle_front = *i->second->front(); - pos_handle_back = *i->first->back(); + pos_handle_front = *join.second->front(); + pos_handle_back = *join.first->back(); // When we encounter the mouseover node, we unset the iterator - it will be invalidated - if (i->first == preserve_pos) { - joined_pos = *i->first; + if (join.first == preserve_pos) { + joined_pos = *join.first; preserve_pos = NodeList::iterator(); - } else if (i->second == preserve_pos) { - joined_pos = *i->second; + } else if (join.second == preserve_pos) { + joined_pos = *join.second; preserve_pos = NodeList::iterator(); } else { - joined_pos = Geom::middle_point(*i->first, *i->second); + joined_pos = Geom::middle_point(*join.first, *join.second); } // if the handles aren't degenerate, don't move them - i->first->move(joined_pos); - Node *joined_node = i->first.ptr(); - if (!i->second->front()->isDegenerate()) { + join.first->move(joined_pos); + Node *joined_node = join.first.ptr(); + if (!join.second->front()->isDegenerate()) { joined_node->front()->setPosition(pos_handle_front); } - if (!i->first->back()->isDegenerate()) { + if (!join.first->back()->isDegenerate()) { joined_node->back()->setPosition(pos_handle_back); } - sp_second.erase(i->second); + sp_second.erase(join.second); if (same_path) { sp_first.setClosed(true); @@ -409,7 +408,7 @@ void MultiPathManipulator::joinNodes() sp_first.splice(sp_first.end(), sp_second); sp_second.kill(); } - _selection.insert(i->first.ptr()); + _selection.insert(join.first.ptr()); } if (joins.empty()) { @@ -441,12 +440,12 @@ void MultiPathManipulator::joinSegments() IterPairList joins; find_join_iterators(_selection, joins); - for (IterPairList::iterator i = joins.begin(); i != joins.end(); ++i) { - bool same_path = prepare_join(*i); - NodeList &sp_first = NodeList::get(i->first); - NodeList &sp_second = NodeList::get(i->second); - i->first->setType(NODE_CUSP, false); - i->second->setType(NODE_CUSP, false); + for (auto & join : joins) { + bool same_path = prepare_join(join); + NodeList &sp_first = NodeList::get(join.first); + NodeList &sp_second = NodeList::get(join.second); + join.first->setType(NODE_CUSP, false); + join.second->setType(NODE_CUSP, false); if (same_path) { sp_first.setClosed(true); } else { @@ -510,9 +509,9 @@ void MultiPathManipulator::move(Geom::Point const &delta) void MultiPathManipulator::showOutline(bool show) { - for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) { + for (auto & i : _mmap) { // always show outlines for clipping paths and masks - i->second->showOutline(show || i->first.role != SHAPE_ROLE_NORMAL); + i.second->showOutline(show || i.first.role != SHAPE_ROLE_NORMAL); } _show_outline = show; } @@ -759,8 +758,8 @@ bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, G break; case GDK_MOTION_NOTIFY: combine_motion_events(_desktop->canvas, event->motion, 0); - for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) { - if (i->second->event(event_context, event)) return true; + for (auto & i : _mmap) { + if (i.second->event(event_context, event)) return true; } break; default: break; diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 4321963b9..78c359609 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -381,8 +381,8 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) //if the snap adjustment is activated and it is not bspline if (snap && !_pm()._isBSpline()) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); - for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - Node *n = static_cast(*i); + for (auto node : nodes) { + Node *n = static_cast(node); unselected.push_back(n->snapCandidatePoint()); } sm.setupIgnoreSelection(_desktop, true, &unselected); @@ -1225,9 +1225,9 @@ void Node::dragged(Geom::Point &new_pos, GdkEventMotion *event) // Build the list of unselected nodes. typedef ControlPointSelection::Set Set; Set &nodes = _selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - if (!(*i)->selected()) { - Node *n = static_cast(*i); + for (auto node : nodes) { + if (!node->selected()) { + Node *n = static_cast(node); Inkscape::SnapCandidatePoint p(n->position(), n->_snapSourceType(), n->_snapTargetType()); unselected.push_back(p); } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index a2390f3a9..83c177297 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -220,8 +220,8 @@ void PathManipulator::clear() /** Select all nodes in subpaths that have something selected. */ void PathManipulator::selectSubpaths() { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - NodeList::iterator sp_start = (*i)->begin(), sp_end = (*i)->end(); + for (auto & _subpath : _subpaths) { + NodeList::iterator sp_start = _subpath->begin(), sp_end = _subpath->end(); for (NodeList::iterator j = sp_start; j != sp_end; ++j) { if (j->selected()) { // if at least one of the nodes from this subpath is selected, @@ -237,11 +237,11 @@ void PathManipulator::selectSubpaths() /** Invert selection in the selected subpaths. */ void PathManipulator::invertSelectionInSubpaths() { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if (j->selected()) { // found selected node - invert selection in this subpath - for (NodeList::iterator k = (*i)->begin(); k != (*i)->end(); ++k) { + for (NodeList::iterator k = _subpath->begin(); k != _subpath->end(); ++k) { if (k->selected()) _selection.erase(k.ptr()); else _selection.insert(k.ptr()); } @@ -257,8 +257,8 @@ void PathManipulator::insertNodes() { if (_num_selected < 2) return; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { NodeList::iterator k = j.next(); if (k && j->selected() && k->selected()) { j = subdivideSegment(j, 0.5); @@ -312,11 +312,11 @@ void PathManipulator::insertNodeAtExtremum(ExtremumType extremum) double sign = (extremum == EXTR_MIN_X || extremum == EXTR_MIN_Y) ? -1. : 1.; Geom::Dim2 dim = (extremum == EXTR_MIN_X || extremum == EXTR_MAX_X) ? Geom::X : Geom::Y; - for (SubpathList::iterator subp = _subpaths.begin(); subp != _subpaths.end(); ++subp) { + for (auto & _subpath : _subpaths) { Geom::Coord extrvalue = - Geom::infinity(); std::vector< std::pair > extremum_vector; - for (NodeList::iterator first = (*subp)->begin(); first != (*subp)->end(); ++first) { + for (NodeList::iterator first = _subpath->begin(); first != _subpath->end(); ++first) { NodeList::iterator second = first.next(); if (second && first->selected() && second->selected()) { add_or_replace_if_extremum(extremum_vector, extrvalue, sign * first->position()[dim], first, 0.); @@ -331,19 +331,19 @@ void PathManipulator::insertNodeAtExtremum(ExtremumType extremum) // and determine extremum Geom::Bezier deriv1d = derivative(temp1d); std::vector rs = deriv1d.roots(); - for (std::vector::iterator it = rs.begin(); it != rs.end(); ++it) { - add_or_replace_if_extremum(extremum_vector, extrvalue, sign * temp1d.valueAt(*it), first, *it); + for (double & r : rs) { + add_or_replace_if_extremum(extremum_vector, extrvalue, sign * temp1d.valueAt(r), first, r); } } } } - for (unsigned i = 0; i < extremum_vector.size(); ++i) { + for (auto & i : extremum_vector) { // don't insert node at the start or end of a segment, i.e. round values for extr_t - double t = extremum_vector[i].second; + double t = i.second; if ( !Geom::are_near(t - std::floor(t+0.5),0.) ) // std::floor(t+0.5) is another way of writing round(t) { - _selection.insert( subdivideSegment(extremum_vector[i].first, t).ptr() ); + _selection.insert( subdivideSegment(i.first, t).ptr() ); } } } @@ -356,8 +356,8 @@ void PathManipulator::duplicateNodes() { if (_num_selected == 0) return; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if (j->selected()) { NodeList::iterator k = j.next(); Node *n = new Node(_multi_path_manipulator._path_data.node_data, *j); @@ -372,7 +372,7 @@ void PathManipulator::duplicateNodes() n->front()->setPosition(*j->front()); j->front()->retract(); j->setType(NODE_CUSP, false); - (*i)->insert(k, n); + _subpath->insert(k, n); if (k) { // We need to manually call the selection change callback to refresh @@ -399,11 +399,10 @@ void PathManipulator::weldNodes(NodeList::iterator preserve_pos) hideDragPoint(); bool pos_valid = preserve_pos; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - SubpathPtr sp = *i; + for (auto sp : _subpaths) { unsigned num_selected = 0, num_unselected = 0; - for (NodeList::iterator j = sp->begin(); j != sp->end(); ++j) { - if (j->selected()) ++num_selected; + for (auto & j : *sp) { + if (j.selected()) ++num_selected; else ++num_unselected; } if (num_selected < 2) continue; @@ -474,11 +473,10 @@ void PathManipulator::weldSegments() if (_num_selected < 2) return; hideDragPoint(); - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - SubpathPtr sp = *i; + for (auto sp : _subpaths) { unsigned num_selected = 0, num_unselected = 0; - for (NodeList::iterator j = sp->begin(); j != sp->end(); ++j) { - if (j->selected()) ++num_selected; + for (auto & j : *sp) { + if (j.selected()) ++num_selected; else ++num_unselected; } @@ -588,8 +586,8 @@ void PathManipulator::deleteNodes(bool keep_shape) // If there are less than 2 unselected nodes in an open subpath or no unselected nodes // in a closed one, delete entire subpath. unsigned num_unselected = 0, num_selected = 0; - for (NodeList::iterator j = sp->begin(); j != sp->end(); ++j) { - if (j->selected()) ++num_selected; + for (auto & j : *sp) { + if (j.selected()) ++num_selected; else ++num_unselected; } if (num_selected == 0) { @@ -709,8 +707,8 @@ void PathManipulator::deleteSegments() SubpathPtr sp = *i; bool has_unselected = false; unsigned num_selected = 0; - for (NodeList::iterator j = sp->begin(); j != sp->end(); ++j) { - if (j->selected()) { + for (auto & j : *sp) { + if (j.selected()) { ++num_selected; } else { has_unselected = true; @@ -779,16 +777,16 @@ void PathManipulator::deleteSegments() * will be reversed. Otherwise all subpaths will be reversed. */ void PathManipulator::reverseSubpaths(bool selected_only) { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { + for (auto & _subpath : _subpaths) { if (selected_only) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if (j->selected()) { - (*i)->reverse(); + _subpath->reverse(); break; // continue with the next subpath } } } else { - (*i)->reverse(); + _subpath->reverse(); } } } @@ -797,8 +795,8 @@ void PathManipulator::reverseSubpaths(bool selected_only) void PathManipulator::setSegmentType(SegmentType type) { if (_num_selected == 0) return; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { NodeList::iterator k = j.next(); if (!(k && j->selected() && k->selected())) continue; switch (type) { @@ -908,8 +906,8 @@ void PathManipulator::showHandles(bool show) { if (show == _show_handles) return; if (show) { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if (!j->selected()) continue; j->showHandles(true); if (j.prev()) j.prev()->showHandles(true); @@ -917,8 +915,8 @@ void PathManipulator::showHandles(bool show) } } } else { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { j->showHandles(false); } } @@ -953,8 +951,8 @@ void PathManipulator::setLiveObjects(bool set) void PathManipulator::updateHandles() { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { j->updateHandles(); } } @@ -964,8 +962,8 @@ void PathManipulator::setControlsTransform(Geom::Affine const &tnew) { Geom::Affine delta = _i2d_transform.inverse() * _edit_transform.inverse() * tnew * _i2d_transform; _edit_transform = tnew; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { j->transform(delta); } } @@ -1068,8 +1066,8 @@ NodeList::iterator PathManipulator::extremeNode(NodeList::iterator origin, bool double extr_dist = closest ? HUGE_VAL : -HUGE_VAL; if (_num_selected == 0 && !search_unselected) return match; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if(j->selected()) { if (!search_selected) continue; } else { @@ -1098,8 +1096,8 @@ void PathManipulator::_externalChange(unsigned type) // ugly: stored offsets of selected nodes in a vector // vector should be specialized so that it takes only 1 bit per value std::vector selpos; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { selpos.push_back(j->selected()); } } @@ -1107,8 +1105,8 @@ void PathManipulator::_externalChange(unsigned type) _createControlPointsFromGeometry(); - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if (curpos >= size) goto end_restore; if (selpos[curpos]) _selection.insert(j.ptr()); ++curpos; @@ -1123,8 +1121,8 @@ void PathManipulator::_externalChange(unsigned type) _i2d_transform = _path->i2dt_affine(); _d2i_transform = _i2d_transform.inverse(); i2d_change *= _i2d_transform; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { j->transform(i2d_change); } } @@ -1160,22 +1158,22 @@ void PathManipulator::_createControlPointsFromGeometry() pathv *= (_edit_transform * _i2d_transform); // in this loop, we know that there are no zero-segment subpaths - for (Geom::PathVector::iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { + for (auto & pit : pathv) { // prepare new subpath SubpathPtr subpath(new NodeList(_subpaths)); _subpaths.push_back(subpath); - Node *previous_node = new Node(_multi_path_manipulator._path_data.node_data, pit->initialPoint()); + Node *previous_node = new Node(_multi_path_manipulator._path_data.node_data, pit.initialPoint()); subpath->push_back(previous_node); - bool closed = pit->closed(); + bool closed = pit.closed(); - for (Geom::Path::iterator cit = pit->begin(); cit != pit->end(); ++cit) { + for (Geom::Path::iterator cit = pit.begin(); cit != pit.end(); ++cit) { Geom::Point pos = cit->finalPoint(); Node *current_node; // if the closing segment is degenerate and the path is closed, we need to move // the handle of the first node instead of creating a new one - if (closed && cit == --(pit->end())) { + if (closed && cit == --(pit.end())) { current_node = subpath->begin().get_pointer(); } else { /* regardless of segment type, create a new node at the end @@ -1197,7 +1195,7 @@ void PathManipulator::_createControlPointsFromGeometry() previous_node = current_node; } // If the path is closed, make the list cyclic - if (pit->closed()) subpath->setClosed(true); + if (pit.closed()) subpath->setClosed(true); } // we need to set the nodetypes after all the handles are in place, @@ -1224,14 +1222,14 @@ void PathManipulator::_createControlPointsFromGeometry() nodetype_string.append(nodetype_len - nodetype_string.size(), 'b'); } std::string::iterator tsi = nodetype_string.begin(); - for (std::list::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { j->setType(Node::parse_nodetype(*tsi++), false); } - if ((*i)->closed()) { + if (_subpath->closed()) { // STUPIDITY ALERT: it seems we need to use the duplicate type symbol instead of // the first one to remain backward compatible. - (*i)->begin()->setType(Node::parse_nodetype(*tsi++), false); + _subpath->begin()->setType(Node::parse_nodetype(*tsi++), false); } } } @@ -1419,12 +1417,12 @@ std::string PathManipulator::_createTypeString() { // precondition: no single-node subpaths std::stringstream tstr; - for (std::list::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { tstr << j->type(); } // nodestring format peculiarity: first node is counted twice for closed paths - if ((*i)->closed()) tstr << (*i)->begin()->type(); + if (_subpath->closed()) tstr << _subpath->begin()->type(); } return tstr.str(); } @@ -1448,8 +1446,7 @@ void PathManipulator::_updateOutline() // of little 'harpoons' that show the direction of the subpaths. auto rot_scale_w2d = Geom::Rotate(210.0 / 180.0 * M_PI) * Geom::Scale(10.0) * _desktop->w2d(); Geom::PathVector arrows; - for (Geom::PathVector::iterator i = pv.begin(); i != pv.end(); ++i) { - Geom::Path &path = *i; + for (auto & path : pv) { for (Geom::Path::iterator j = path.begin(); j != path.end_default(); ++j) { Geom::Point at = j->pointAt(0.5); Geom::Point ut = j->unitTangentAt(0.5); @@ -1600,8 +1597,8 @@ bool PathManipulator::_handleClicked(Handle *h, GdkEventButton *event) } void PathManipulator::_selectionChangedM(std::vector pvec, bool selected) { - for (size_t n = 0, e = pvec.size(); n < e; ++n) { - _selectionChanged(pvec[n], selected); + for (auto & n : pvec) { + _selectionChanged(n, selected); } } @@ -1650,8 +1647,8 @@ void PathManipulator::_selectionChanged(SelectableControlPoint *p, bool selected void PathManipulator::_removeNodesFromSelection() { // remove this manipulator's nodes from selection - for (std::list::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { _selection.erase(j.get_pointer()); } } diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 781675a99..c1d6692bc 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -154,8 +154,8 @@ bool TransformHandle::grabbed(GdkEventMotion *) _all_snap_sources_sorted = _snap_points; // Calculate and store the distance to the reference point for each snap candidate point - for(std::vector::iterator i = _all_snap_sources_sorted.begin(); i != _all_snap_sources_sorted.end(); ++i) { - (*i).setDistance(Geom::L2((*i).getPoint() - _origin)); + for(auto & i : _all_snap_sources_sorted) { + i.setDistance(Geom::L2(i.getPoint() - _origin)); } // Sort them ascending, using the distance calculated above as the single criteria @@ -724,8 +724,8 @@ TransformHandleSet::TransformHandleSet(SPDesktop *d, SPCanvasGroup *th_group) TransformHandleSet::~TransformHandleSet() { - for (unsigned i = 0; i < 17; ++i) { - delete _handles[i]; + for (auto & _handle : _handles) { + delete _handle; } } @@ -844,9 +844,9 @@ void TransformHandleSet::_updateVisibility(bool v) _center->setVisible(show_rotate /*&& bp[Geom::X] > handle_size[Geom::X] && bp[Geom::Y] > handle_size[Geom::Y]*/); } else { - for (unsigned i = 0; i < 17; ++i) { - if (_handles[i] != _active) - _handles[i]->setVisible(false); + for (auto & _handle : _handles) { + if (_handle != _active) + _handle->setVisible(false); } } diff --git a/src/ui/toolbar/calligraphy-toolbar.cpp b/src/ui/toolbar/calligraphy-toolbar.cpp index 85afa9872..2a9d7b0d9 100644 --- a/src/ui/toolbar/calligraphy-toolbar.cpp +++ b/src/ui/toolbar/calligraphy-toolbar.cpp @@ -74,8 +74,8 @@ void update_presets_list(GObject *tbl) bool match = true; std::vector preset = prefs->getAllEntries(*i); - for (std::vector::iterator j = preset.begin(); j != preset.end(); ++j) { - Glib::ustring entry_name = j->getEntryName(); + for (auto & j : preset) { + Glib::ustring entry_name = j.getEntryName(); if (entry_name == "id" || entry_name == "name") { continue; } @@ -83,7 +83,7 @@ void update_presets_list(GObject *tbl) void *widget = g_object_get_data(tbl, entry_name.data()); if (widget) { if (GTK_IS_ADJUSTMENT(widget)) { - double v = j->getDouble(); + double v = j.getDouble(); GtkAdjustment* adj = static_cast(widget); //std::cout << "compared adj " << attr_name << gtk_adjustment_get_value(adj) << " to " << v << "\n"; if (fabs(gtk_adjustment_get_value(adj) - v) > 1e-6) { @@ -91,7 +91,7 @@ void update_presets_list(GObject *tbl) break; } } else if (GTK_IS_TOGGLE_ACTION(widget)) { - bool v = j->getBool(); + bool v = j.getBool(); GtkToggleAction* toggle = static_cast(widget); //std::cout << "compared toggle " << attr_name << gtk_toggle_action_get_active(toggle) << " to " << v << "\n"; if ( static_cast(gtk_toggle_action_get_active(toggle)) != v ) { @@ -218,9 +218,9 @@ static void sp_dcc_build_presets_list(GObject *tbl) std::vector presets = get_presets_list(); int ii=1; - for (std::vector::iterator i = presets.begin(); i != presets.end(); ++i) { + for (auto & preset : presets) { GtkTreeIter iter; - Glib::ustring preset_name = prefs->getString(*i + "/name"); + Glib::ustring preset_name = prefs->getString(preset + "/name"); if (!preset_name.empty()) { row = *(store->append()); @@ -303,8 +303,7 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl) g_free(profile_id); } - for (unsigned i = 0; i < G_N_ELEMENTS(widget_names); ++i) { - gchar const *const widget_name = widget_names[i]; + for (auto widget_name : widget_names) { void *widget = g_object_get_data(tbl, widget_name); if (widget) { if (GTK_IS_ADJUSTMENT(widget)) { @@ -351,8 +350,8 @@ static void sp_ddc_change_profile(GObject* tbl, int mode) std::vector preset = prefs->getAllEntries(preset_path); // Shouldn't this be std::map? - for (std::vector::iterator i = preset.begin(); i != preset.end(); ++i) { - Glib::ustring entry_name = i->getEntryName(); + for (auto & i : preset) { + Glib::ustring entry_name = i.getEntryName(); if (entry_name == "id" || entry_name == "name") { continue; } @@ -360,11 +359,11 @@ static void sp_ddc_change_profile(GObject* tbl, int mode) if (widget) { if (GTK_IS_ADJUSTMENT(widget)) { GtkAdjustment* adj = static_cast(widget); - gtk_adjustment_set_value(adj, i->getDouble()); + gtk_adjustment_set_value(adj, i.getDouble()); //std::cout << "set adj " << attr_name << " to " << v << "\n"; } else if (GTK_IS_TOGGLE_ACTION(widget)) { GtkToggleAction* toggle = static_cast(widget); - gtk_toggle_action_set_active(toggle, i->getBool()); + gtk_toggle_action_set_active(toggle, i.getBool()); //std::cout << "set toggle " << attr_name << " to " << v << "\n"; } else { g_warning("Unknown widget type for preset: %s\n", entry_name.data()); diff --git a/src/ui/toolbar/gradient-toolbar.cpp b/src/ui/toolbar/gradient-toolbar.cpp index be23d9e98..cf14be7c3 100644 --- a/src/ui/toolbar/gradient-toolbar.cpp +++ b/src/ui/toolbar/gradient-toolbar.cpp @@ -608,14 +608,10 @@ static void select_stop_by_draggers(SPGradient *gradient, ToolBase *ev, GObject int selected = -1; // For all selected draggers - for(auto i = drag->selected.begin(); i != drag->selected.end(); ++i) { - - GrDragger *dragger = *i; + for(auto dragger : drag->selected) { // For all draggables of dragger - for(auto j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { - - GrDraggable *draggable = *j; + for(auto draggable : dragger->draggables) { if (draggable->point_type != POINT_RG_FOCUS) { n++; diff --git a/src/ui/toolbar/mesh-toolbar.cpp b/src/ui/toolbar/mesh-toolbar.cpp index af0e1e5ea..6dad5a189 100644 --- a/src/ui/toolbar/mesh-toolbar.cpp +++ b/src/ui/toolbar/mesh-toolbar.cpp @@ -117,16 +117,16 @@ void ms_read_selection( Inkscape::Selection *selection, // Read desktop selection, taking into account fill/stroke toggles std::vector meshes = ms_get_dt_selected_gradients( selection ); - for (auto i = meshes.begin(); i != meshes.end(); ++i) { + for (auto & meshe : meshes) { if (first) { - ms_selected = (*i); - ms_type = (*i)->type; + ms_selected = meshe; + ms_type = meshe->type; first = false; } else { - if (ms_selected != (*i)) { + if (ms_selected != meshe) { ms_selected_multi = true; } - if (ms_type != (*i)->type) { + if (ms_type != meshe->type) { ms_type_multi = true; } } @@ -261,10 +261,10 @@ static void ms_type_changed( GObject *tbl, int mode ) std::vector meshes = ms_get_dt_selected_gradients(selection); SPMeshType type = (SPMeshType) mode; - for (auto i = meshes.begin(); i != meshes.end(); ++i) { - (*i)->type = type; - (*i)->type_set = true; - (*i)->updateRepr(); + for (auto & meshe : meshes) { + meshe->type = type; + meshe->type_set = true; + meshe->updateRepr(); } if (!meshes.empty() ) { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,_("Set mesh type")); diff --git a/src/ui/toolbar/paintbucket-toolbar.cpp b/src/ui/toolbar/paintbucket-toolbar.cpp index b23c9561a..81a240262 100644 --- a/src/ui/toolbar/paintbucket-toolbar.cpp +++ b/src/ui/toolbar/paintbucket-toolbar.cpp @@ -95,8 +95,7 @@ static void paintbucket_defaults(GtkWidget *, GObject *tbl) {"offset", 0.0} }; - for (unsigned i = 0; i < G_N_ELEMENTS(key_values); ++i) { - KeyValue const &kv = key_values[i]; + for (auto kv : key_values) { GtkAdjustment* adj = static_cast(g_object_get_data(tbl, kv.key)); if ( adj ) { gtk_adjustment_set_value(adj, kv.value); diff --git a/src/ui/toolbar/pencil-toolbar.cpp b/src/ui/toolbar/pencil-toolbar.cpp index 8002969ee..52cc32637 100644 --- a/src/ui/toolbar/pencil-toolbar.cpp +++ b/src/ui/toolbar/pencil-toolbar.cpp @@ -442,8 +442,8 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb guint curve_length = sp_shape->getCurve()->get_segment_count(); std::vector ts = lpe_powerstroke->offset_points.data(); double factor = (double)curve_length/ (double)previous_curve_length; - for (size_t i = 0; i < ts.size(); i++) { - ts[i][Geom::X] = ts[i][Geom::X] * factor; + for (auto & t : ts) { + t[Geom::X] = t[Geom::X] * factor; } lpe_powerstroke->offset_points.param_setValue(ts); } diff --git a/src/ui/toolbar/select-toolbar.cpp b/src/ui/toolbar/select-toolbar.cpp index 9da07b43d..0e1ad9c1b 100644 --- a/src/ui/toolbar/select-toolbar.cpp +++ b/src/ui/toolbar/select-toolbar.cpp @@ -84,15 +84,15 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) if (unit->type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) { double const val = unit->factor * 100; - for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { - GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); + for (auto i : keyval) { + GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), i.key)); gtk_adjustment_set_value(a, val); - tracker->setFullVal( a, keyval[i].val ); + tracker->setFullVal( a, i.val ); } } else { - for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { - GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); - gtk_adjustment_set_value(a, Quantity::convert(keyval[i].val, "px", unit)); + for (auto i : keyval) { + GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), i.key)); + gtk_adjustment_set_value(a, Quantity::convert(i.val, "px", unit)); } } } @@ -123,10 +123,9 @@ sp_selection_layout_widget_change_selection(SPWidget *spw, Inkscape::Selection * gboolean setActive = (selection && !selection->isEmpty()); std::vector *contextActions = reinterpret_cast *>(g_object_get_data(G_OBJECT(spw), "contextActions")); if ( contextActions ) { - for ( std::vector::iterator iter = contextActions->begin(); - iter != contextActions->end(); ++iter) { - if ( setActive != gtk_action_is_sensitive(*iter) ) { - gtk_action_set_sensitive( *iter, setActive ); + for (auto & contextAction : *contextActions) { + if ( setActive != gtk_action_is_sensitive(contextAction) ) { + gtk_action_set_sensitive( contextAction, setActive ); } } } @@ -536,10 +535,9 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb // Update now. sp_selection_layout_widget_update(SP_WIDGET(spw), SP_ACTIVE_DESKTOP ? SP_ACTIVE_DESKTOP->getSelection() : nullptr); - for ( std::vector::iterator iter = contextActions->begin(); - iter != contextActions->end(); ++iter) { - if ( gtk_action_is_sensitive(*iter) ) { - gtk_action_set_sensitive( *iter, FALSE ); + for (auto & contextAction : *contextActions) { + if ( gtk_action_is_sensitive(contextAction) ) { + gtk_action_set_sensitive( contextAction, FALSE ); } } diff --git a/src/ui/toolbar/text-toolbar.cpp b/src/ui/toolbar/text-toolbar.cpp index 341188fb2..fc3e8cd7d 100644 --- a/src/ui/toolbar/text-toolbar.cpp +++ b/src/ui/toolbar/text-toolbar.cpp @@ -1416,9 +1416,9 @@ static void sp_text_set_sizes(GtkListStore* model_size, int unit) // Array must be same length as SPCSSUnit in style.h float ratios[] = {1, 1, 1, 10, 4, 40, 100, 16, 8, 0.16}; - for( unsigned int i = 0; i < G_N_ELEMENTS(sizes); ++i ) { + for(int i : sizes) { GtkTreeIter iter; - Glib::ustring size = Glib::ustring::format(sizes[i] / (float)ratios[unit]); + Glib::ustring size = Glib::ustring::format(i / (float)ratios[unit]); gtk_list_store_append( model_size, &iter ); gtk_list_store_set( model_size, &iter, 0, size.c_str(), -1 ); } diff --git a/src/ui/toolbar/tweak-toolbar.cpp b/src/ui/toolbar/tweak-toolbar.cpp index 3b275601e..47a90910a 100644 --- a/src/ui/toolbar/tweak-toolbar.cpp +++ b/src/ui/toolbar/tweak-toolbar.cpp @@ -80,8 +80,8 @@ static void sp_tweak_mode_changed( GObject *tbl, int mode ) static gchar const* names[] = {"tweak_doh", "tweak_dos", "tweak_dol", "tweak_doo", "tweak_channels_label"}; bool flag = ((mode == Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT) || (mode == Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER)); - for (size_t i = 0; i < G_N_ELEMENTS(names); ++i) { - GtkAction *act = GTK_ACTION(g_object_get_data( tbl, names[i] )); + for (auto & name : names) { + GtkAction *act = GTK_ACTION(g_object_get_data( tbl, name )); if (act) { gtk_action_set_visible(act, flag); } diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 95b13f92c..5a1654e2f 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -190,11 +190,11 @@ ConnectorTool::~ConnectorTool() { this->sel_changed_connection.disconnect(); - for (int i = 0; i < 2; ++i) { + for (auto & i : this->endpt_handle) { if (this->endpt_handle[1]) { //g_object_unref(this->endpt_handle[i]); - knot_unref(this->endpt_handle[i]); - this->endpt_handle[i] = nullptr; + knot_unref(i); + i = nullptr; } } @@ -313,8 +313,8 @@ static void cc_clear_active_knots(SPKnotList k) { // Hide the connection points if they exist. if (k.size()) { - for (SPKnotList::iterator it = k.begin(); it != k.end(); ++it) { - it->first->hide(); + for (auto & it : k) { + it.first->hide(); } } } @@ -335,9 +335,9 @@ void ConnectorTool::cc_clear_active_conn() } // Hide the endpoint handles. - for (int i = 0; i < 2; ++i) { - if (this->endpt_handle[i]) { - this->endpt_handle[i]->hide(); + for (auto & i : this->endpt_handle) { + if (i) { + i->hide(); } } } diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 37091ea01..6db530917 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -392,8 +392,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double offset = prefs->getDouble("/tools/paintbucket/offset", 0.0); - for (unsigned int i=0 ; icreateElement("svg:path"); diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index eee108bc0..f8c8517c9 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -383,16 +383,16 @@ MeasureTool::~MeasureTool() /* unref should call destroy */ knot_unref(this->knot_start); knot_unref(this->knot_end); - for (size_t idx = 0; idx < measure_tmp_items.size(); ++idx) { - sp_canvas_item_destroy(measure_tmp_items[idx]); + for (auto & measure_tmp_item : measure_tmp_items) { + sp_canvas_item_destroy(measure_tmp_item); } measure_tmp_items.clear(); - for (size_t idx = 0; idx < measure_item.size(); ++idx) { - sp_canvas_item_destroy(measure_item[idx]); + for (auto & idx : measure_item) { + sp_canvas_item_destroy(idx); } measure_item.clear(); - for (size_t idx = 0; idx < measure_phantom_items.size(); ++idx) { - sp_canvas_item_destroy(measure_phantom_items[idx]); + for (auto & measure_phantom_item : measure_phantom_items) { + sp_canvas_item_destroy(measure_phantom_item); } measure_phantom_items.clear(); } @@ -594,8 +594,8 @@ bool MeasureTool::root_handler(GdkEvent* event) } else { SPDesktop *desktop = SP_ACTIVE_DESKTOP; //Inkscape::Util::Unit const * unit = desktop->getNamedView()->getDisplayUnit(); - for (size_t idx = 0; idx < measure_item.size(); ++idx) { - sp_canvas_item_destroy(measure_item[idx]); + for (auto & idx : measure_item) { + sp_canvas_item_destroy(idx); } measure_item.clear(); ret = TRUE; @@ -757,12 +757,12 @@ void MeasureTool::toPhantom() return; } SPDocument *doc = desktop->getDocument(); - for (size_t idx = 0; idx < measure_phantom_items.size(); ++idx) { - sp_canvas_item_destroy(measure_phantom_items[idx]); + for (auto & measure_phantom_item : measure_phantom_items) { + sp_canvas_item_destroy(measure_phantom_item); } measure_phantom_items.clear(); - for (size_t idx = 0; idx < measure_tmp_items.size(); ++idx) { - sp_canvas_item_destroy(measure_tmp_items[idx]); + for (auto & measure_tmp_item : measure_tmp_items) { + sp_canvas_item_destroy(measure_tmp_item); } measure_tmp_items.clear(); showCanvasItems(false, false, true); @@ -1029,8 +1029,8 @@ void MeasureTool::reset() { this->knot_start->hide(); this->knot_end->hide(); - for (size_t idx = 0; idx < measure_tmp_items.size(); ++idx) { - sp_canvas_item_destroy(measure_tmp_items[idx]); + for (auto & measure_tmp_item : measure_tmp_items) { + sp_canvas_item_destroy(measure_tmp_item); } measure_tmp_items.clear(); } @@ -1148,8 +1148,8 @@ void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; Inkscape::Util::Unit const * unit = desktop->getNamedView()->getDisplayUnit(); - for (size_t idx = 0; idx < measure_item.size(); ++idx) { - sp_canvas_item_destroy(measure_item[idx]); + for (auto & idx : measure_item) { + sp_canvas_item_destroy(idx); } measure_item.clear(); @@ -1247,8 +1247,8 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, writeMeasurePoint(start_p, true); writeMeasurePoint(end_p, false); //clear previous canvas items, we'll draw new ones - for (size_t idx = 0; idx < measure_tmp_items.size(); ++idx) { - sp_canvas_item_destroy(measure_tmp_items[idx]); + for (auto & measure_tmp_item : measure_tmp_items) { + sp_canvas_item_destroy(measure_tmp_item); } measure_tmp_items.clear(); //TODO:Calculate the measure area for current length and origin @@ -1334,8 +1334,8 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, std::vector intersections; std::sort(intersection_times.begin(), intersection_times.end()); - for (std::vector::iterator iter_t = intersection_times.begin(); iter_t != intersection_times.end(); ++iter_t) { - intersections.push_back(lineseg[0].pointAt(*iter_t)); + for (double & intersection_time : intersection_times) { + intersections.push_back(lineseg[0].pointAt(intersection_time)); } if(!show_in_between && intersection_times.size() > 1) { @@ -1363,9 +1363,7 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, int precision = prefs->getInt("/tools/measure/precision", 2); // Adjust positions repositionOverlappingLabels(placements, desktop, windowNormal, fontsize, precision); - for (std::vector::iterator it = placements.begin(); it != placements.end(); ++it) { - LabelPlacement &place = *it; - + for (auto & place : placements) { setMeasureCanvasText(false, precision, place.lengthVal * scale, fontsize, unit_name, place.end, 0x0000007f, TEXT_ANCHOR_CENTER, to_item, to_phantom, measure_repr); } Geom::Point angleDisplayPt = calcAngleDisplayAnchor(desktop, angle, baseAngle, @@ -1438,8 +1436,7 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, } // call-out lines - for (std::vector::iterator it = placements.begin(); it != placements.end(); ++it) { - LabelPlacement &place = *it; + for (auto & place : placements) { setMeasureCanvasControlLine(place.start, place.end, to_item, to_phantom, CTLINE_SECONDARY, measure_repr); } diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 9dde149d9..a6faed5fa 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -316,8 +316,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) // Get list of selected draggers for each mesh. // For all selected draggers (a dragger may include draggerables from different meshes). - for (std::set::const_iterator i = drag->selected.begin(); i != drag->selected.end(); ++i) { - GrDragger *dragger = *i; + for (auto dragger : drag->selected) { // For all draggables of dragger (a draggable corresponds to a unique mesh). for (std::vector::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end() ; ++j) { GrDraggable *d = *j; diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 99f5e4bcf..52632098f 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -302,8 +302,8 @@ void sp_update_helperpath() { Inkscape::UI::ControlPointSelection *selectionNodes = nt->_selected_nodes; std::vector selectedNodesPositions; - for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) { - Inkscape::UI::Node *n = dynamic_cast(*i); + for (auto selectionNode : *selectionNodes) { + Inkscape::UI::Node *n = dynamic_cast(selectionNode); selectedNodesPositions.push_back(n->position()); } lpe->setSelectedNodePoints(selectedNodesPositions); @@ -311,8 +311,8 @@ void sp_update_helperpath() { SPCurve *c = new SPCurve(); SPCurve *cc = new SPCurve(); std::vector cs = lpe->getCanvasIndicators(SP_LPE_ITEM(selection->singleItem())); - for (std::vector::iterator p = cs.begin(); p != cs.end(); ++p) { - cc->set_pathvector(*p); + for (auto & p : cs) { + cc->set_pathvector(p); c->append(cc, false); cc->reset(); } @@ -441,9 +441,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { } } - for (std::set::iterator i = shapes.begin(); i != shapes.end(); ++i) { - ShapeRecord const &r = *i; - + for (const auto & r : shapes) { if ((SP_IS_SHAPE(r.item) || SP_IS_TEXT(r.item) || SP_IS_GROUP(r.item) || SP_IS_OBJECTGROUP(r.item)) && this->_shape_editors.find(r.item) == this->_shape_editors.end()) { @@ -674,9 +672,9 @@ void NodeTool::update_tip(GdkEvent *event) { // of a line going through them relative to the X axis. Inkscape::UI::ControlPointSelection::Set &selection_nodes = this->_selected_nodes->allPoints(); std::vector positions; - for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection_nodes.begin(); i != selection_nodes.end(); ++i) { - if ((*i)->selected()) { - Inkscape::UI::Node *n = dynamic_cast(*i); + for (auto selection_node : selection_nodes) { + if (selection_node->selected()) { + Inkscape::UI::Node *n = dynamic_cast(selection_node); positions.push_back(n->position()); } } diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 91dedd742..907b04a9a 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -584,8 +584,7 @@ static bool fit_item(SPDesktop *desktop, double bbox_top = bbox_down->top(); gchar const * item_down_sharp = g_strdup_printf("#%s", item_down->getId()); items_down_erased.push_back(item_down); - for (std::vector::const_iterator j=items_selected.begin(); j!=items_selected.end(); ++j) { - SPItem *item_selected = *j; + for (auto item_selected : items_selected) { gchar const * spray_origin; if(!item_selected->getAttribute("inkscape:spray-origin")){ spray_origin = g_strdup_printf("#%s", item_selected->getId()); @@ -1143,14 +1142,12 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point { std::vector const items(set->items().begin(), set->items().end()); - for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ - SPItem *item = *i; + for(auto item : items){ g_assert(item != nullptr); sp_object_ref(item); } - for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ - SPItem *item = *i; + for(auto item : items){ g_assert(item != nullptr); if (sp_spray_recursive(desktop , set @@ -1193,8 +1190,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point } } - for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ - SPItem *item = *i; + for(auto item : items){ g_assert(item != nullptr); sp_object_unref(item); } diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 4de0dc81f..f27f37300 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -244,10 +244,9 @@ void TextTool::finish() { this->frame = nullptr; } - for (std::vector::iterator it = this->text_selection_quads.begin() ; - it != this->text_selection_quads.end() ; ++it) { - sp_canvas_item_hide(*it); - sp_canvas_item_destroy(*it); + for (auto & text_selection_quad : this->text_selection_quads) { + sp_canvas_item_hide(text_selection_quad); + sp_canvas_item_destroy(text_selection_quad); } this->text_selection_quads.clear(); @@ -1702,9 +1701,9 @@ static void sp_text_context_update_text_selection(TextTool *tc) // the selection update (can't do both atomically, alas) if (!tc->desktop) return; - for (std::vector::iterator it = tc->text_selection_quads.begin() ; it != tc->text_selection_quads.end() ; ++it) { - sp_canvas_item_hide(*it); - sp_canvas_item_destroy(*it); + for (auto & text_selection_quad : tc->text_selection_quads) { + sp_canvas_item_hide(text_selection_quad); + sp_canvas_item_destroy(text_selection_quad); } tc->text_selection_quads.clear(); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index cbc3dfd99..d8db9ceaf 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -1083,9 +1083,7 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point // auto items= selection->items(); std::vector items(selection->items().begin(), selection->items().end()); - for(auto i=items.begin();i!=items.end(); ++i){ - SPItem *item = *i; - + for(auto item : items){ if (is_color_mode (tc->mode)) { if (do_fill || do_stroke || do_opacity) { if (sp_tweak_color_recursive (tc->mode, item, item_at_point, diff --git a/src/ui/uxmanager.cpp b/src/ui/uxmanager.cpp index 28f84dd63..8c52dafa0 100644 --- a/src/ui/uxmanager.cpp +++ b/src/ui/uxmanager.cpp @@ -151,9 +151,7 @@ gint UXManagerImpl::getDefaultTask( SPDesktop *desktop ) void UXManagerImpl::setTask(SPDesktop* dt, gint val) { - for (vector::iterator it = dtws.begin(); it != dtws.end(); ++it) { - SPDesktopWidget* dtw = *it; - + for (auto dtw : dtws) { gboolean notDone = Inkscape::Preferences::get()->getBool("/options/workarounds/dynamicnotdone", false); if (dtw->desktop == dt) { @@ -217,9 +215,7 @@ void UXManagerImpl::connectToDesktop( vector const & toolboxes, SPD vector& tracked = tracker.boxes; tracker.destroyConn = desktop->connectDestroy(&desktopDestructHandler); - for (vector::const_iterator it = toolboxes.begin(); it != toolboxes.end(); ++it ) { - GtkWidget* toolbox = *it; - + for (auto toolbox : toolboxes) { ToolboxFactory::setToolboxDesktop( toolbox, desktop ); if (find(tracked.begin(), tracked.end(), toolbox) == tracked.end()) { tracked.push_back(toolbox); diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp index 8d9f4a51c..f55dc5176 100644 --- a/src/ui/widget/color-icc-selector.cpp +++ b/src/ui/widget/color-icc-selector.cpp @@ -186,9 +186,9 @@ std::vector colorspace::getColorSpaceInfo(uint32_t space) sets[cmsSigCmyData].push_back(Component(_("_M:"), _("Magenta"), 1)); sets[cmsSigCmyData].push_back(Component(_("_Y:"), _("Yellow"), 1)); - for (std::map >::iterator it = sets.begin(); it != sets.end(); ++it) { - knownColorspaces.insert(it->first); - maxColorspaceComponentCount = std::max(maxColorspaceComponentCount, it->second.size()); + for (auto & set : sets) { + knownColorspaces.insert(set.first); + maxColorspaceComponentCount = std::max(maxColorspaceComponentCount, set.second.size()); } } @@ -806,10 +806,10 @@ void ColorICCSelectorImpl::_setProfile(SVGICCColor *profile) profChanged = true; } - for (size_t i = 0; i < _compUI.size(); i++) { - gtk_widget_hide(_compUI[i]._label); - _compUI[i]._slider->hide(); - gtk_widget_hide(_compUI[i]._btn); + for (auto & i : _compUI) { + gtk_widget_hide(i._label); + i._slider->hide(); + gtk_widget_hide(i._btn); } if (profile) { diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp index 88573f137..f635b0665 100644 --- a/src/ui/widget/color-notebook.cpp +++ b/src/ui/widget/color-notebook.cpp @@ -289,8 +289,8 @@ void ColorNotebook::_updateICCButtons() if (prof && CMSSystem::isPrintColorSpace(prof)) { gtk_widget_show(GTK_WIDGET(_box_toomuchink)); double ink_sum = 0; - for (unsigned int i = 0; i < color.icc->colors.size(); i++) { - ink_sum += color.icc->colors[i]; + for (double i : color.icc->colors) { + ink_sum += i; } /* Some literature states that when the sum of paint values exceed 320%, it is considered to be a satured diff --git a/src/ui/widget/color-scales.cpp b/src/ui/widget/color-scales.cpp index e10b9f6a5..1229801d1 100644 --- a/src/ui/widget/color-scales.cpp +++ b/src/ui/widget/color-scales.cpp @@ -266,8 +266,8 @@ void ColorScales::setScaled(GtkAdjustment *a, gfloat v, bool constrained) void ColorScales::_setRangeLimit(gdouble upper) { _rangeLimit = upper; - for (gint i = 0; i < static_cast(G_N_ELEMENTS(_a)); i++) { - gtk_adjustment_set_upper(_a[i], upper); + for (auto & i : _a) { + gtk_adjustment_set_upper(i, upper); } } diff --git a/src/ui/widget/dash-selector.cpp b/src/ui/widget/dash-selector.cpp index 59149fb7c..81e7881b6 100644 --- a/src/ui/widget/dash-selector.cpp +++ b/src/ui/widget/dash-selector.cpp @@ -114,8 +114,8 @@ void DashSelector::init_dashes() { SPStyle style; dashes = g_new (double *, dash_prefs.size() + 2); // +1 for custom slot, +1 for terminator slot - for (std::vector::iterator i = dash_prefs.begin(); i != dash_prefs.end(); ++i) { - style.readFromPrefs( *i ); + for (auto & dash_pref : dash_prefs) { + style.readFromPrefs( dash_pref ); if (!style.stroke_dasharray.values.empty()) { dashes[pos] = g_new (double, style.stroke_dasharray.values.size() + 1); diff --git a/src/ui/widget/font-selector.cpp b/src/ui/widget/font-selector.cpp index 5c1905752..207d508df 100644 --- a/src/ui/widget/font-selector.cpp +++ b/src/ui/widget/font-selector.cpp @@ -122,9 +122,9 @@ FontSelector::set_sizes () // PX PT PC MM CM IN EM EX % double ratios[] = {1, 1, 1, 10, 4, 40, 100, 16, 8, 0.16}; - for (unsigned int i = 0; i < G_N_ELEMENTS(sizes); ++i) + for (int i : sizes) { - double size = sizes[i]/ratios[unit]; + double size = i/ratios[unit]; size_combobox.append( Glib::ustring::format(size) ); } } diff --git a/src/ui/widget/ink-select-one-action.cpp b/src/ui/widget/ink-select-one-action.cpp index 7cff5f0be..95f38b511 100644 --- a/src/ui/widget/ink-select-one-action.cpp +++ b/src/ui/widget/ink-select-one-action.cpp @@ -105,9 +105,7 @@ Gtk::Widget* InkSelectOneAction::create_menu_item_vfunc() { Gtk::RadioButton::Group group; int index = 0; auto children = _store->children(); - for (auto iter = children.begin(); iter != children.end(); ++iter) { - Gtk::TreeModel::Row row = *iter; - + for (auto row : children) { InkSelectOneActionColumns columns; Glib::ustring label = row[columns.col_label ]; Glib::ustring icon = row[columns.col_icon ]; @@ -159,9 +157,7 @@ Gtk::Widget* InkSelectOneAction::create_tool_item_vfunc() { Gtk::RadioAction::Group group; int index = 0; auto children = _store->children(); - for (auto iter = children.begin(); iter != children.end(); ++iter) { - Gtk::TreeModel::Row row = *iter; - + for (auto row : children) { InkSelectOneActionColumns columns; Glib::ustring label = row[columns.col_label ]; Glib::ustring icon = row[columns.col_icon ]; @@ -217,8 +213,8 @@ Gtk::Widget* InkSelectOneAction::create_tool_item_vfunc() { } std::vector cells = _combobox->get_cells(); - for (auto iter = cells.begin(); iter!= cells.end(); ++iter) { - _combobox->add_attribute (**iter, "sensitive", columns.col_sensitive); + for (auto & cell : cells) { + _combobox->add_attribute (*cell, "sensitive", columns.col_sensitive); } _combobox->set_active (_active); diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 92c460c03..149b70f6f 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1128,8 +1128,8 @@ void SelectedStyle::opacity_1() {_opacity_sb.set_value(100);} void SelectedStyle::on_opacity_menu (Gtk::Menu *menu) { Glib::ListHandle children = menu->get_children(); - for (Glib::ListHandle::iterator iter = children.begin(); iter != children.end(); ++iter) { - menu->remove(*(*iter)); + for (auto iter : children) { + menu->remove(*iter); } { diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index 7be848aac..938851265 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -30,8 +30,8 @@ bool UnitMenu::setUnitType(UnitType unit_type) // Expand the unit widget with unit entries from the unit table UnitTable::UnitMap m = unit_table.units(unit_type); - for (UnitTable::UnitMap::iterator i = m.begin(); i != m.end(); ++i) { - append(i->first); + for (auto & i : m) { + append(i.first); } _type = unit_type; set_active_text(unit_table.primary(unit_type)); diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index 9a4ff8268..4114ed378 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -45,9 +45,9 @@ UnitTracker::UnitTracker(UnitType unit_type) : _store = Gtk::ListStore::create(columns); Gtk::TreeModel::Row row; - for (UnitTable::UnitMap::iterator m_iter = m.begin(); m_iter != m.end(); ++m_iter) { + for (auto & m_iter : m) { - Glib::ustring unit = m_iter->first; + Glib::ustring unit = m_iter.first; row = *(_store->append()); row[columns.col_label ] = unit; diff --git a/src/unicoderange.cpp b/src/unicoderange.cpp index a6137f640..ca1a3f67c 100644 --- a/src/unicoderange.cpp +++ b/src/unicoderange.cpp @@ -70,8 +70,8 @@ int UnicodeRange::add_range(gchar* val){ } bool UnicodeRange::contains(gchar unicode){ - for(unsigned int i=0;iunichars.size();i++){ - if (static_cast(unicode) == this->unichars[i]){ + for(unsigned int unichar : this->unichars){ + if (static_cast(unicode) == unichar){ return true; } } @@ -88,8 +88,7 @@ bool UnicodeRange::contains(gchar unicode){ } bool found; - for(unsigned int i=0;irange.size();i++){ - Urange r = this->range[i]; + for(auto r : this->range){ if (r.end){ if (unival >= hex2int(r.start) && unival <= hex2int(r.end)) return true; } else { diff --git a/src/util/ege-tags.cpp b/src/util/ege-tags.cpp index c37a9d2fe..f8acab82b 100644 --- a/src/util/ege-tags.cpp +++ b/src/util/ege-tags.cpp @@ -105,12 +105,12 @@ bool TagSet::addTag(Tag const& tag) if (tag.key == it->key) { present = true; - for ( std::vector