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/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 ++++++++++---------- 25 files changed, 223 insertions(+), 254 deletions(-) (limited to 'src/object') 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) -- cgit v1.2.3