diff options
62 files changed, 356 insertions, 338 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 6fab01f16..885d17c21 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -194,8 +194,8 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_repr_css_merge(css_write, css); sp_css_attr_unset_uris(css_write); prefs->mergeStyle("/desktop/style", css_write); - std::vector<SPItem*> const itemlist = desktop->selection->items(); - for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i!= itemlist.end(); ++i) { + auto itemlist = desktop->selection->items(); + for (auto i = itemlist.begin(); i!= itemlist.end(); ++i) { /* last used styles for 3D box faces are stored separately */ SPObject *obj = *i; Box3DSide *side = dynamic_cast<Box3DSide *>(obj); @@ -234,8 +234,8 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_repr_css_merge(css_no_text, css); css_no_text = sp_css_attr_unset_text(css_no_text); - std::vector<SPItem*> const itemlist = desktop->selection->items(); - for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i!= itemlist.end(); ++i) { + auto itemlist = desktop->selection->items(); + for (auto i = itemlist.begin(); i!= itemlist.end(); ++i) { SPItem *item = *i; // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) @@ -1917,7 +1917,8 @@ sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property) // otherwise, do querying and averaging over selection if (desktop->selection != NULL) { - return sp_desktop_query_style_from_list (desktop->selection->items(), style, property); + std::vector<SPItem *> vec(desktop->selection->items().begin(), desktop->selection->items().end()); + return sp_desktop_query_style_from_list (vec, style, property); } return QUERY_STYLE_NOTHING; diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 2b0183d4b..73376bd91 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -58,8 +58,8 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Imp sp_namedview_document_from_window(desktop); if (desktop != NULL) { - std::vector<SPItem*> selected = desktop->getSelection()->items(); - for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); ++x){ + auto selected = desktop->getSelection()->items(); + for(auto x = selected.begin(); x != selected.end(); ++x){ Glib::ustring selected_id; selected_id = (*x)->getId(); _selected.insert(_selected.end(), selected_id); diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index eb1213a84..6139ed367 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -46,10 +46,10 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *) view)->getSelection()->items(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node const* first_select = NULL; if (!selected.empty()) { - const SPItem * item = selected[0]; + const SPItem * item = selected.front(); first_select = item->getRepr(); } diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 0acc99aed..459b1a196 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -689,9 +689,9 @@ void Script::effect(Inkscape::Extension::Effect *module, return; } - std::vector<SPItem*> selected = + auto selected = desktop->getSelection()->items(); //desktop should not be NULL since doc was checked and desktop is a casted pointer - for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); ++x){ + for(auto x = selected.begin(); x != selected.end(); ++x){ Glib::ustring selected_id; selected_id += "--id="; selected_id += (*x)->getId(); diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index 707cd763d..472c2db91 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -65,8 +65,8 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems(NULL) { SPDesktop *desktop = (SPDesktop*)view; - const std::vector<SPItem*> selectedItemList = desktop->selection->items(); - int selectCount = selectedItemList.size(); + auto selectedItemList = desktop->selection->items(); + int selectCount = (int) boost::distance(selectedItemList); // Init the data-holders _nodes = new Inkscape::XML::Node*[selectCount]; @@ -78,7 +78,7 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems = new SPItem*[selectCount]; // Loop through selected items - for (std::vector<SPItem*>::const_iterator i = selectedItemList.begin(); i != selectedItemList.end(); ++i) { + for (auto i = selectedItemList.begin(); i != selectedItemList.end(); ++i) { SPItem *item = *i; Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(item->getRepr()); if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) @@ -235,7 +235,7 @@ ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::Vie { SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *) view)->getSelection()->items(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { first_select = (selected.front())->getRepr(); diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 6dc788f17..4f66b39fc 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -62,7 +62,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); // TODO need to properly refcount the items, at least - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); selection->clear(); for(std::vector<SPItem*>::iterator item = items.begin(); diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index acfcaed0e..0907845f8 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -125,7 +125,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie Inkscape::Selection * selection = ((SPDesktop *)document)->selection; // TODO need to properly refcount the items, at least - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index fd1b311a8..9e730f5e5 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -180,10 +180,10 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View { SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *) view)->getSelection()->items(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { - first_select = selected[0]->getRepr(); + first_select = selected.front()->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/extension/plugins/grid2/grid.cpp b/src/extension/plugins/grid2/grid.cpp index c938d1ec4..233d4e522 100644 --- a/src/extension/plugins/grid2/grid.cpp +++ b/src/extension/plugins/grid2/grid.cpp @@ -186,10 +186,10 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View { SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *) view)->getSelection()->items(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { - first_select = selected[0]->getRepr(); + first_select = selected.front()->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 698cf5012..59d715149 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -1570,8 +1570,8 @@ void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTa { Inkscape::Selection *selection = desktop->getSelection(); - const std::vector<SPItem*> list= selection->items(); - for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); ++i) { + auto list= selection->items(); + for (auto i = list.begin(); i != list.end(); ++i) { sp_item_gradient_invert_vector_color(*i, fill_or_stroke); } @@ -1595,8 +1595,8 @@ void sp_gradient_reverse_selected_gradients(SPDesktop *desktop) if (drag && !drag->selected.empty()) { drag->selected_reverse_vector(); } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) - const std::vector<SPItem*> list= selection->items(); - for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); ++i) { + auto list= selection->items(); + for (auto i = list.begin(); i != list.end(); ++i) { sp_item_gradient_reverse_vector(*i, Inkscape::FOR_FILL); sp_item_gradient_reverse_vector(*i, Inkscape::FOR_STROKE); } diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 3d1cefd4f..555bde786 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2070,8 +2070,8 @@ void GrDrag::updateDraggers() this->draggers.clear(); g_return_if_fail(this->selection != NULL); - std::vector<SPItem*> list = this->selection->items(); - for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); ++i) { + auto list = this->selection->items(); + for (auto i = list.begin(); i != list.end(); ++i) { SPItem *item = *i; SPStyle *style = item->style; @@ -2138,8 +2138,8 @@ void GrDrag::updateLines() g_return_if_fail(this->selection != NULL); - std::vector<SPItem*> list = this->selection->items(); - for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); ++i) { + auto list = this->selection->items(); + for (auto i = list.begin(); i != list.end(); ++i) { SPItem *item = *i; SPStyle *style = item->style; @@ -2282,8 +2282,8 @@ void GrDrag::updateLevels() g_return_if_fail (this->selection != NULL); - std::vector<SPItem*> list = this->selection->items(); - for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); ++i) { + auto list = this->selection->items(); + for (auto i = list.begin(); i != list.end(); ++i) { SPItem *item = *i; Geom::OptRect rect = item->desktopVisualBounds(); if (rect) { diff --git a/src/object-set.cpp b/src/object-set.cpp index 1240e5198..07f9ea0c8 100644 --- a/src/object-set.cpp +++ b/src/object-set.cpp @@ -200,11 +200,11 @@ SPItem *ObjectSet::largestItem(CompareSize compare) { } SPItem *ObjectSet::_sizeistItem(bool sml, CompareSize compare) { - std::vector<SPItem*> const items = const_cast<ObjectSet *>(this)->items(); + auto items = this->items(); gdouble max = sml ? 1e18 : 0; SPItem *ist = NULL; - for ( std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i) { + for (auto i = items.begin(); i != items.end(); ++i) { Geom::OptRect obox = SP_ITEM(*i)->desktopPreferredBounds(); if (!obox || obox.empty()) { continue; @@ -227,13 +227,6 @@ SPItem *ObjectSet::_sizeistItem(bool sml, CompareSize compare) { SPObjectRange ObjectSet::objects() { return SPObjectRange(container.get<random_access>().begin(), container.get<random_access>().end()); } -std::vector<SPItem*> ObjectSet::items() { - std::vector<SPObject *> tmp = std::vector<SPObject *>(container.begin(), container.end()); - std::vector<SPItem*> result; - std::remove_if(tmp.begin(), tmp.end(), [](SPObject* o){return !SP_IS_ITEM(o);}); - std::transform(tmp.begin(), tmp.end(), std::back_inserter(result), [](SPObject* o){return SP_ITEM(o);}); - return result; -} Inkscape::XML::Node *ObjectSet::singleRepr() { SPObject *obj = single(); @@ -255,10 +248,10 @@ Geom::OptRect ObjectSet::bounds(SPItem::BBoxType type) const Geom::OptRect ObjectSet::geometricBounds() const { - std::vector<SPItem*> const items = const_cast<ObjectSet *>(this)->items(); + auto items = const_cast<ObjectSet *>(this)->items(); Geom::OptRect bbox; - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + for (auto iter = items.begin(); iter != items.end(); ++iter) { bbox.unionWith(SP_ITEM(*iter)->desktopGeometricBounds()); } return bbox; @@ -266,10 +259,10 @@ Geom::OptRect ObjectSet::geometricBounds() const Geom::OptRect ObjectSet::visualBounds() const { - std::vector<SPItem*> const items = const_cast<ObjectSet *>(this)->items(); + auto items = const_cast<ObjectSet *>(this)->items(); Geom::OptRect bbox; - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + for (auto iter = items.begin(); iter != items.end(); ++iter) { bbox.unionWith(SP_ITEM(*iter)->desktopVisualBounds()); } return bbox; @@ -287,10 +280,10 @@ Geom::OptRect ObjectSet::preferredBounds() const Geom::OptRect ObjectSet::documentBounds(SPItem::BBoxType type) const { Geom::OptRect bbox; - std::vector<SPItem*> const items = const_cast<ObjectSet *>(this)->items(); + auto items = const_cast<ObjectSet *>(this)->items(); if (items.empty()) return bbox; - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + for (auto iter = items.begin(); iter != items.end(); ++iter) { SPItem *item = SP_ITEM(*iter); bbox |= item->documentBounds(type); } @@ -301,7 +294,7 @@ Geom::OptRect ObjectSet::documentBounds(SPItem::BBoxType type) const // If we have a selection of multiple items, then the center of the first item // will be returned; this is also the case in SelTrans::centerRequest() boost::optional<Geom::Point> ObjectSet::center() const { - std::vector<SPItem*> const items = const_cast<ObjectSet *>(this)->items(); + auto items = const_cast<ObjectSet *>(this)->items(); if (!items.empty()) { SPItem *first = items.back(); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly diff --git a/src/object-set.h b/src/object-set.h index ea6534350..0f06e373b 100644 --- a/src/object-set.h +++ b/src/object-set.h @@ -178,7 +178,11 @@ public: SPObjectRange objects(); /** Returns the list of selected SPItems. */ - std::vector<SPItem*> items(); + SPItemRange items() { + return SPItemRange(container.get<random_access>() + | boost::adaptors::filtered(is_item()) + | boost::adaptors::transformed(object_to_item())); + }; /** Returns a list of the xml nodes of all selected objects. */ XMLNodeRange xmlNodes() { diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 37d242b6b..868d06161 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -57,7 +57,7 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo) Inkscape::Selection *selection = desktop->getSelection(); SPDocument *doc = desktop->getDocument(); - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); if (items.size() < 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine.")); @@ -203,7 +203,7 @@ sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo) bool did = false; - std::vector<SPItem*> itemlist(selection->items()); + std::vector<SPItem*> itemlist(selection->items().begin(), selection->items().end()); for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); ++i){ SPItem *item = *i; @@ -303,7 +303,7 @@ sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, b desktop->setWaitingCursor(); } - std::vector<SPItem*> selected(selection->items()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); std::vector<Inkscape::XML::Node*> to_select; selection->clear(); std::vector<SPItem*> items(selected); @@ -334,7 +334,7 @@ void sp_selected_to_lpeitems(SPDesktop *desktop) return; } - std::vector<SPItem*> selected(selection->items()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); std::vector<Inkscape::XML::Node*> to_select; selection->clear(); std::vector<SPItem*> items(selected); @@ -603,7 +603,7 @@ void sp_selected_path_reverse(SPDesktop *desktop) { Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> items = selection->items(); + auto items = selection->items(); if (items.empty()) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse.")); @@ -617,7 +617,7 @@ sp_selected_path_reverse(SPDesktop *desktop) bool did = false; desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); - for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); ++i){ + for (auto i = items.begin(); i != items.end(); ++i){ SPPath *path = dynamic_cast<SPPath *>(*i); if (!path) { diff --git a/src/selcue.cpp b/src/selcue.cpp index 13248a553..a807b0119 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -96,15 +96,15 @@ void Inkscape::SelCue::_updateItemBboxes(Inkscape::Preferences *prefs) void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) { - const std::vector<SPItem*> items = _selection->items(); - if (_item_bboxes.size() != items.size()) { + auto items = _selection->items(); + if (_item_bboxes.size() != boost::distance(items)) { _newItemBboxes(); return; } int bcount = 0; - std::vector<SPItem*> ll= _selection->items(); - for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); ++l) { + auto ll= _selection->items(); + for (auto l = ll.begin(); l != ll.end(); ++l) { SPItem *item = *l; SPCanvasItem* box = _item_bboxes[bcount ++]; @@ -146,8 +146,8 @@ void Inkscape::SelCue::_newItemBboxes() int prefs_bbox = prefs->getBool("/tools/bounding_box"); - std::vector<SPItem*> ll= _selection->items(); - for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); ++l) { + auto ll= _selection->items(); + for (auto l = ll.begin(); l != ll.end(); ++l) { SPItem *item = *l; Geom::OptRect const b = (prefs_bbox == 0) ? @@ -201,8 +201,8 @@ void Inkscape::SelCue::_newTextBaselines() } _text_baselines.clear(); - std::vector<SPItem*> ll = _selection->items(); - for (std::vector<SPItem*>::const_iterator l=ll.begin();l!=ll.end();++l) { + auto ll = _selection->items(); + for (auto l=ll.begin();l!=ll.end();++l) { SPItem *item = *l; SPCanvasItem* baseline_point = NULL; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 82f89c03a..4b5c3f921 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -282,9 +282,9 @@ void SelectionHelper::fixSelection(SPDesktop *dt) std::vector<SPItem*> items ; - std::vector<SPItem*> const selList = selection->items(); + auto selList = selection->items(); - for( std::vector<SPItem*>::const_reverse_iterator i = selList.rbegin(); i != selList.rend(); ++i ) { + for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { SPItem *item = *i; if( item && !dt->isLayer(item) && @@ -409,7 +409,7 @@ void sp_selection_delete(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Nothing</b> was deleted.")); return; } - std::vector<SPItem*> selected(selection->items()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); selection->clear(); sp_selection_delete_impl(selected); desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -624,7 +624,7 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i std::vector<SPItem*> exclude; if (invert) { - exclude = selection->items(); + exclude.insert(exclude.end(), selection->items().begin(), selection->items().end()); } if (force_all_layers) @@ -798,9 +798,8 @@ void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDeskto selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("<b>No objects selected</b> to pop out of group.")); return; } - std::vector<SPItem*> selection_list = selection->items(); - std::vector<SPItem*>::const_iterator item = selection_list.begin(); // leaving this because it will be useful for + auto item = selection->items().begin(); // leaving this because it will be useful for // future implementation of complex pop ungrouping SPItem *obj = *item; SPItem *parent_group = static_cast<SPItem*>(obj->parent); @@ -831,10 +830,10 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } // first check whether there is anything to ungroup - std::vector<SPItem*> old_select = selection->items(); + auto old_select = selection->items(); std::vector<SPItem*> new_select; GSList *groups = NULL; - for (std::vector<SPItem*>::const_iterator item = old_select.begin(); item!=old_select.end(); ++item) { + for (auto item = old_select.begin(); item!=old_select.end(); ++item) { SPItem *obj = *item; if (dynamic_cast<SPGroup *>(obj)) { groups = g_slist_prepend(groups, obj); @@ -847,7 +846,7 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) return; } - std::vector<SPItem*> items(old_select); + std::vector<SPItem*> items(old_select.begin(), old_select.end()); selection->clear(); // If any of the clones refer to the groups, unlink them and replace them with successors @@ -983,7 +982,8 @@ bool sp_item_repr_compare_position_bool(SPObject const *first, SPObject const *s void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) { - std::vector<SPItem*> items= selection->items(); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); + if (items.empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise.")); return; @@ -1040,7 +1040,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto return; } - std::vector<SPItem*> items = selection->items(); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { @@ -1062,7 +1062,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) { - std::vector<SPItem*> items = selection->items(); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); if (items.empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower.")); return; @@ -1124,7 +1124,7 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des return; } - std::vector<SPItem*> items = selection->items(); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { @@ -1287,8 +1287,8 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from.")); return; } - std::vector<SPItem*> list= selection->items(); - for ( std::vector<SPItem*>::const_iterator itemlist=list.begin();itemlist!=list.end();++itemlist) { + auto list= selection->items(); + for (auto itemlist=list.begin();itemlist!=list.end();++itemlist) { SPItem *item = *itemlist; sp_selection_remove_livepatheffect_impl(item); @@ -1368,7 +1368,7 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) return; } - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); bool no_more = false; // Set to true, if no more layers above SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); @@ -1412,7 +1412,7 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) return; } - const std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); bool no_more = false; // Set to true, if no more layers below SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); @@ -1455,7 +1455,7 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) return; } - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); if (moveto) { selection->clear(); @@ -1506,8 +1506,8 @@ static bool selection_contains_both_clone_and_original(Inkscape::Selection *selection) { bool clone_with_original = false; - std::vector<SPItem*> items = selection->items(); - for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;++l) { + auto items = selection->items(); + for (auto l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; if (item) { clone_with_original |= selection_contains_original(item, selection); @@ -1551,8 +1551,8 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons persp3d_apply_affine_transformation(transf_persp, affine); } - std::vector<SPItem*> items = selection->items(); - for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;++l) { + auto items = selection->items(); + for (auto l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; if( dynamic_cast<SPRoot *>(item) ) { @@ -1822,9 +1822,9 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) if (selection->isEmpty()) return; - std::vector<SPItem*> items = selection->items(); + auto items = selection->items(); Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw - for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;++l) { + for (auto l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; if (item) { sp_item_rotate_rel(item, rot_90); @@ -1886,7 +1886,7 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea std::vector<SPItem*> all_matches; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> items = selection->items(); + auto items = selection->items(); std::vector<SPItem*> tmp; for (std::vector<SPItem*>::const_iterator iter=all_list.begin();iter!=all_list.end();++iter) { @@ -1896,7 +1896,7 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea } all_list=tmp; - for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();++sel_iter) { + for (auto sel_iter=items.begin();sel_iter!=items.end();++sel_iter) { SPItem *sel = *sel_iter; std::vector<SPItem*> matches = all_list; if (fill && stroke && style) { @@ -1943,8 +1943,8 @@ void sp_select_same_object_type(SPDesktop *desktop) Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> items= selection->items(); - for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();++sel_iter) { + auto items= selection->items(); + for (auto sel_iter=items.begin();sel_iter!=items.end();++sel_iter) { SPItem *sel = *sel_iter; if (sel) { matches = sp_get_same_object_type(sel, matches); @@ -2456,7 +2456,8 @@ sp_selection_item_next(SPDesktop *desktop) root = desktop->currentRoot(); } - SPItem *item=next_item_from_list<Forward>(desktop, selection->items(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); + std::vector<SPItem *> vec(selection->items().begin(), selection->items().end()); + SPItem *item=next_item_from_list<Forward>(desktop, vec, root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); if (item) { selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer); @@ -2486,7 +2487,8 @@ sp_selection_item_prev(SPDesktop *desktop) root = desktop->currentRoot(); } - SPItem *item=next_item_from_list<ListReverse>(desktop, selection->items(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); + std::vector<SPItem *> vec(selection->items().begin(), selection->items().end()); + SPItem *item=next_item_from_list<ListReverse>(desktop, vec, root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); if (item) { selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer); @@ -2662,8 +2664,8 @@ sp_selection_relink(SPDesktop *desktop) // Get a copy of current selection. bool relinked = false; - std::vector<SPItem*> items= selection->items(); - for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= selection->items(); + for (auto i=items.begin();i!=items.end();++i){ SPItem *item = *i; if (dynamic_cast<SPUse *>(item)) { @@ -2700,8 +2702,8 @@ sp_selection_unlink(SPDesktop *desktop) // Get a copy of current selection. std::vector<SPItem*> new_select; bool unlinked = false; - std::vector<SPItem*> items= selection->items(); - for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();++i){ + auto items= selection->items(); + for (auto i=boost::rbegin(items);i!=boost::rend(items);++i){ SPItem *item = *i; if (dynamic_cast<SPText *>(item)) { @@ -2767,8 +2769,8 @@ sp_select_clone_original(SPDesktop *desktop) // Check if other than two objects are selected - std::vector<SPItem*> items= selection->items(); - if (items.size() != 1 || !item) { + auto items= selection->items(); + if (boost::distance(items) != 1 || !item) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error); return; } @@ -2865,8 +2867,8 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop) Inkscape::SVGOStringStream os; SPObject * firstItem = NULL; - std::vector<SPItem*> items= selection->items(); - for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= selection->items(); + for (auto i=items.begin();i!=items.end();++i){ if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) { if (firstItem) { os << "|"; @@ -2950,12 +2952,12 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) Geom::Point center( *c - corner ); // As defined by rotation center center[Geom::Y] = -center[Geom::Y]; - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? // bottommost object, after sorting - SPObject *parent = items[0]->parent; + SPObject *parent = items.front()->parent; Geom::Affine parent_transform; { @@ -3024,7 +3026,7 @@ void sp_selection_to_guides(SPDesktop *desktop) SPDocument *doc = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); // we need to copy the list because it gets reset when objects are deleted - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); if (items.empty()) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides.")); @@ -3302,7 +3304,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) move_p[Geom::Y] = -move_p[Geom::Y]; Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); - std::vector<SPItem*> items (selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); sort(items.begin(),items.end(),sp_object_compare_position_bool); @@ -3407,7 +3409,7 @@ void sp_selection_untile(SPDesktop *desktop) bool did = false; - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();++i){ SPItem *item = *i; @@ -3564,7 +3566,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) } // List of the items to show; all others will be hidden - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); // Sort items so that the topmost comes last sort(items.begin(),items.end(),sp_item_repr_compare_position_bool); @@ -3875,7 +3877,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ if ( apply_to_layer && is_empty) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from.")); return; - } else if (!apply_to_layer && ( is_empty || selection->items().size()==1 )) { + } else if (!apply_to_layer && ( is_empty || boost::distance(selection->items())==1 )) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and <b>object(s)</b> to apply clippath or mask to.")); return; } @@ -3890,7 +3892,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ doc->ensureUpToDate(); - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); sort(items.begin(),items.end(),sp_object_compare_position_bool); @@ -4052,7 +4054,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; std::map<SPObject*,SPItem*> referenced_objects; - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); selection->clear(); GSList *items_to_ungroup = NULL; diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 93808ed54..dda209a83 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -122,7 +122,7 @@ void SelectionDescriber::_selectionModified(Inkscape::Selection *selection, guin } void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { - std::vector<SPItem*> const items = selection->items(); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); if (items.empty()) { // no items _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); diff --git a/src/selection.cpp b/src/selection.cpp index 94b64a7bc..09eaf6c0e 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -136,8 +136,8 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferenc if (snapprefs != NULL){ SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center - std::vector<SPItem*> const items = const_cast<Selection *>(this)->items(); - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + auto items = const_cast<Selection *>(this)->items(); + for (auto iter = items.begin(); iter != items.end(); ++iter) { SPItem *this_item = *iter; this_item->getSnappoints(p, &snapprefs_dummy); @@ -162,9 +162,9 @@ SPObject *Selection::_objectForXMLNode(Inkscape::XML::Node *repr) const { } size_t Selection::numberOfLayers() { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->items(); + auto items = this->items(); std::set<SPObject*> layers; - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + for (auto iter = items.begin(); iter != items.end(); ++iter) { SPObject *layer = _layers->layerForObject(*iter); layers.insert(layer); } @@ -173,9 +173,9 @@ size_t Selection::numberOfLayers() { } size_t Selection::numberOfParents() { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->items(); + auto items = this->items(); std::set<SPObject*> parents; - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + for (auto iter = items.begin(); iter != items.end(); ++iter) { SPObject *parent = (*iter)->parent; parents.insert(parent); } diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 9fa6172ed..f6cb9166c 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -240,8 +240,8 @@ void Inkscape::SelTrans::setCenter(Geom::Point const &p) _center_is_set = true; // Write the new center position into all selected items - std::vector<SPItem*> items= _desktop->selection->items(); - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + auto items= _desktop->selection->items(); + for (auto iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = SP_ITEM(*iter); it->setCenter(p); // only set the value; updating repr and document_done will be done once, on ungrab @@ -270,8 +270,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s return; } - std::vector<SPItem*> items= _desktop->selection->items(); - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + auto items= _desktop->selection->items(); + for (auto iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = static_cast<SPItem*>(sp_object_ref(*iter, NULL)); _items.push_back(it); _items_const.push_back(it); @@ -492,8 +492,8 @@ void Inkscape::SelTrans::ungrab() if (_center_is_set) { // we were dragging center; update reprs and commit undoable action - std::vector<SPItem*> items= _desktop->selection->items(); - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + auto items= _desktop->selection->items(); + for (auto iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = *iter; it->updateRepr(); } @@ -529,8 +529,8 @@ void Inkscape::SelTrans::stamp() l = _stamp_cache; } else { /* Build cache */ - l = selection->items(); - sort(l.begin(),l.end(),sp_object_compare_position_bool); + l.insert(l.end(), selection->items().begin(), selection->items().end()); + sort(l.begin(), l.end(), sp_object_compare_position_bool); _stamp_cache = l; } @@ -621,7 +621,8 @@ void Inkscape::SelTrans::_updateVolatileState() return; } - _strokewidth = stroke_average_width (selection->items()); + std::vector<SPItem *> vec(selection->items().begin(), selection->items().end()); + _strokewidth = stroke_average_width(vec); } void Inkscape::SelTrans::_showHandles(SPSelTransType type) @@ -711,8 +712,8 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa case HANDLE_CENTER: if (state & GDK_SHIFT_MASK) { // Unset the center position for all selected items - std::vector<SPItem*> items= _desktop->selection->items(); - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + auto items = _desktop->selection->items(); + for (auto iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = *iter; it->unsetCenter(); it->updateRepr(); @@ -1287,7 +1288,7 @@ gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) // items will share a single center. While dragging that single center, it should never snap to the // centers of any of the selected objects. Therefore we will have to pass the list of selected items // to the snapper, to avoid self-snapping of the rotation center - std::vector<SPItem*> items = const_cast<Selection *>(_selection)->items(); + std::vector<SPItem *> items(_selection->items().begin(), _selection->items().end()); SnapManager &m = _desktop->namedview->snap_manager; m.setup(_desktop); m.setRotationCenterSource(items); diff --git a/src/snap.cpp b/src/snap.cpp index d1d15ca0c..87fc9cb84 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -708,8 +708,8 @@ void SnapManager::setupIgnoreSelection(SPDesktop const *desktop, _items_to_ignore.clear(); Inkscape::Selection *sel = _desktop->selection; - std::vector<SPItem*> const items = sel->items(); - for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i) { + auto items = sel->items(); + for (auto i=items.begin();i!=items.end();++i) { _items_to_ignore.push_back(*i); } } diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 09d74a010..b1f324be2 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -335,7 +335,7 @@ void sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb, const Glib::ustring description) { SPDocument *doc = selection->layers()->getDocument(); - std::vector<SPItem*> il= selection->items(); + std::vector<SPItem*> il(selection->items().begin(), selection->items().end()); // allow union on a single object for the purpose of removing self overlapse (svn log, revision 13334) if ( (il.size() < 2) && (bop != bool_op_union)) { @@ -1157,7 +1157,7 @@ sp_selected_path_outline(SPDesktop *desktop) bool scale_stroke = prefs->getBool("/options/transform/stroke", true); prefs->setBool("/options/transform/stroke", true); bool did = false; - std::vector<SPItem*> il(selection->items()); + std::vector<SPItem*> il(selection->items().begin(), selection->items().end()); for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = *l; @@ -1771,7 +1771,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) } bool did = false; - std::vector<SPItem*> il(selection->items()); + std::vector<SPItem*> il(selection->items().begin(), selection->items().end()); for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = *l; SPCurve *curve = NULL; @@ -2196,7 +2196,7 @@ sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool ju return; } - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); bool didSomething = sp_selected_path_simplify_items(desktop, selection, items, threshold, diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 5565464a1..86aee1831 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -43,8 +43,8 @@ using Inkscape::DocumentUndo; static SPItem * flowtext_in_selection(Inkscape::Selection *selection) { - std::vector<SPItem*> items = selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ if (SP_IS_FLOWTEXT(*i)) return *i; } @@ -54,8 +54,8 @@ flowtext_in_selection(Inkscape::Selection *selection) static SPItem * text_or_flowtext_in_selection(Inkscape::Selection *selection) { - std::vector<SPItem*> items = selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) return *i; } @@ -65,8 +65,8 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection) static SPItem * shape_in_selection(Inkscape::Selection *selection) { - std::vector<SPItem*> items = selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ if (SP_IS_SHAPE(*i)) return *i; } @@ -87,7 +87,7 @@ text_put_on_path() Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); - if (!text || !shape || selection->items().size() != 2) { + if (!text || !shape || boost::distance(selection->items()) != 2) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a text and a path</b> to put text on path.")); return; } @@ -196,8 +196,8 @@ text_remove_from_path() } bool did = false; - std::vector<SPItem*> items(selection->items()); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ SPObject *obj = *i; if (SP_IS_TEXT_TEXTPATH(obj)) { @@ -214,7 +214,8 @@ text_remove_from_path() } else { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Remove text from path")); - selection->setList(selection->items()); // reselect to update statusbar description + std::vector<SPItem *> vec(selection->items().begin(), selection->items().end()); + selection->setList(vec); // reselect to update statusbar description } } @@ -260,8 +261,8 @@ text_remove_all_kerns() bool did = false; - std::vector<SPItem*> items = selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ SPObject *obj = *i; if (!SP_IS_TEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_FLOWTEXT(obj)) { @@ -296,7 +297,7 @@ text_flow_into_shape() SPItem *text = text_or_flowtext_in_selection(selection); SPItem *shape = shape_in_selection(selection); - if (!text || !shape || selection->items().size() < 2) { + if (!text || !shape || boost::distance(selection->items()) < 2) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a text</b> and one or more <b>paths or shapes</b> to flow text into frame.")); return; } @@ -320,8 +321,8 @@ text_flow_into_shape() g_return_if_fail(SP_IS_FLOWREGION(object)); /* Add clones */ - std::vector<SPItem*> items = selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ SPItem *item = *i; if (SP_IS_SHAPE(item)){ Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); @@ -387,7 +388,7 @@ text_unflow () Inkscape::Selection *selection = desktop->getSelection(); - if (!flowtext_in_selection(selection) || selection->items().size() < 1) { + if (!flowtext_in_selection(selection) || boost::distance(selection->items()) < 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a flowed text</b> to unflow it.")); return; } @@ -395,8 +396,8 @@ text_unflow () std::vector<SPItem*> new_objs; GSList *old_objs = NULL; - std::vector<SPItem*> items = selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ if (!SP_IS_FLOWTEXT(*i)) { continue; @@ -480,7 +481,7 @@ flowtext_to_text() bool did = false; std::vector<Inkscape::XML::Node*> reprs; - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ SPItem *item = *i; diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index f0fa61b89..52e99886a 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -65,7 +65,7 @@ SPImage *Tracer::getSelectedSPImage() if (sioxEnabled) { SPImage *img = NULL; - std::vector<SPItem*> const list = sel->items(); + auto list = sel->items(); std::vector<SPItem *> items; sioxShapes.clear(); @@ -74,7 +74,7 @@ SPImage *Tracer::getSelectedSPImage() them as bottom-to-top so that we can discover the image and any SPItems above it */ - for (std::vector<SPItem*>::const_iterator i=list.begin() ; list.end()!=i ; ++i) + for (auto i=list.begin() ; list.end()!=i ; ++i) { if (!SP_IS_ITEM(*i)) { diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index b1a946db2..9871804f5 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -522,8 +522,8 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a // resize each object in the selection if (separately) { - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (item) { Geom::OptRect obj_size = item->desktopVisualBounds(); @@ -578,8 +578,8 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) desktop->doc()->importDefs(tempdoc); // make sure all selected items are converted to paths first (i.e. rectangles) sp_selected_to_lpeitems(desktop); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; _applyPathEffect(item, effectstack); } @@ -661,9 +661,9 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) { // copy the defs used by all items - std::vector<SPItem*> itemlist= selection->items(); + auto itemlist= selection->items(); cloned_elements.clear(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (item) { _copyUsedDefs(item); @@ -674,7 +674,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) // copy the representation of the items std::vector<SPObject*> sorted_items; - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) + for(auto i=itemlist.begin();i!=itemlist.end();++i) sorted_items.push_back(*i); sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position_bool); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index b7b5b96cd..03003f137 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -133,7 +133,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups"); - std::vector<SPItem*> selected(selection->items()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); if (selected.empty()) return; const Coeffs &a = _allCoeffs[index]; @@ -293,7 +293,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector<SPItem*> selected(selection->items()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); if (selected.empty()) return; //Check 2 or more selected objects @@ -499,7 +499,9 @@ private : // xGap and yGap are the minimum space required between bounding rectangles. double const xGap = removeOverlapXGap.get_value(); double const yGap = removeOverlapYGap.get_value(); - removeoverlap(_dialog.getDesktop()->getSelection()->items(), xGap, yGap); + auto tmp = _dialog.getDesktop()->getSelection()->items(); + std::vector<SPItem *> vec(tmp.begin(), tmp.end()); + removeoverlap(vec, xGap, yGap); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -530,8 +532,9 @@ private : int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - graphlayout(_dialog.getDesktop()->getSelection()->items()); - + auto tmp = _dialog.getDesktop()->getSelection()->items(); + std::vector<SPItem *> vec(tmp.begin(), tmp.end()); + graphlayout(vec); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -590,7 +593,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector<SPItem*> selected(selection->items()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); if (selected.empty()) return; //Check 2 or more selected objects @@ -656,7 +659,8 @@ private : Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - std::vector<SPItem*> x(_dialog.getDesktop()->getSelection()->items()); + auto tmp = _dialog.getDesktop()->getSelection()->items(); + std::vector<SPItem*> x(tmp.begin(), tmp.end()); unclump (x); // restore compensation setting @@ -687,7 +691,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector<SPItem*> selected(selection->items()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); if (selected.empty()) return; //Check 2 or more selected objects @@ -785,7 +789,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector<SPItem*> selected(selection->items()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); //Check 2 or more selected objects if (selected.size() < 2) return; diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 7ce937de7..87c90c460 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1376,7 +1376,7 @@ void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, Gtk return; } - if (selection->items().size() > 1) { + if (boost::distance(selection->items()) > 1) { gtk_widget_set_sensitive (buttons, FALSE); gtk_label_set_markup (GTK_LABEL(status), _("<small>More than one object selected.</small>")); return; @@ -2113,7 +2113,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || selection->items().size() > 1) { + if (selection->isEmpty() || boost::distance(selection->items()) > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to unclump.")); return; } @@ -2162,7 +2162,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || selection->items().size() > 1) { + if (selection->isEmpty() || boost::distance(selection->items()) > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove.")); return; } @@ -2240,7 +2240,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) } // Check if more than one object is selected. - if (selection->items().size() > 1) { + if (boost::distance(selection->items()) > 1) { desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, <b>group</b> them and <b>clone the group</b>.")); return; } diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index dbee80af9..4ab007408 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -608,7 +608,7 @@ void Export::onBatchClicked () void Export::updateCheckbuttons () { - gint num = SP_ACTIVE_DESKTOP->getSelection()->items().size(); + gint num = (gint) boost::distance(SP_ACTIVE_DESKTOP->getSelection()->items()); if (num >= 2) { batch_export.set_sensitive(true); batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num)); @@ -1015,7 +1015,7 @@ void Export::onExport () if (batch_export.get_active ()) { // Batch export of selected objects - gint num = (desktop->getSelection()->items()).size(); + gint num = (gint) boost::distance(desktop->getSelection()->items()); gint n = 0; if (num < 1) { @@ -1029,8 +1029,8 @@ void Export::onExport () gint export_count = 0; - std::vector<SPItem*> itemlist= desktop->getSelection()->items(); - for(std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i = itemlist.begin();i!=itemlist.end() && !interrupted ;++i){ SPItem *item = *i; prog_dlg->set_data("current", GINT_TO_POINTER(n)); @@ -1070,12 +1070,13 @@ void Export::onExport () MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE, _("Exporting file <b>%s</b>..."), safeFile), desktop); std::vector<SPItem*> x; + std::vector<SPItem*> selected(desktop->getSelection()->items().begin(), desktop->getSelection()->items().end()); if (!sp_export_png_file (doc, path.c_str(), *area, width, height, dpi, dpi, nv->pagecolor, onProgressCallback, (void*)prog_dlg, TRUE, // overwrite without asking - hide ? (desktop->getSelection()->items()) : x + hide ? selected : x )) { gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); @@ -1160,12 +1161,13 @@ void Export::onExport () /* Do export */ std::vector<SPItem*> x; + std::vector<SPItem*> selected(desktop->getSelection()->items().begin(), desktop->getSelection()->items().end()); ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(), Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, nv->pagecolor, onProgressCallback, (void*)prog_dlg, FALSE, - hide ? (desktop->getSelection()->items()) : x + hide ? selected : x ); if (status == EXPORT_ERROR) { gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str()); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index ccba5a278..78e03e2a0 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1474,8 +1474,8 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel) } std::set<SPObject*> used; - std::vector<SPItem*> itemlist= sel->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { + auto itemlist= sel->items(); + for(auto i=itemlist.begin(); itemlist.end() != i; ++i) { SPObject *obj = *i; SPStyle *style = obj->style; if (!style || !SP_IS_ITEM(obj)) { @@ -1555,8 +1555,8 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri if((*iter)[_columns.sel] == 1) filter = 0; - std::vector<SPItem*> itemlist= sel->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { + auto itemlist= sel->items(); + for(auto i=itemlist.begin(); itemlist.end() != i; ++i) { SPItem * item = *i; SPStyle *style = item->style; g_assert(style != NULL); diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 8424dd7f5..013a0ae6a 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -761,8 +761,8 @@ std::vector<SPItem*> &Find::all_items (SPObject *r, std::vector<SPItem*> &l, boo std::vector<SPItem*> &Find::all_selection_items (Inkscape::Selection *s, std::vector<SPItem*> &l, SPObject *ancestor, bool hidden, bool locked) { - std::vector<SPItem*> itemlist= s->items(); - for(std::vector<SPItem*>::const_reverse_iterator i=itemlist.rbegin(); itemlist.rend() != i; ++i) { + auto itemlist= s->items(); + for(auto i=boost::rbegin(itemlist); boost::rend(itemlist) != i; ++i) { SPObject *obj = *i; SPItem *item = dynamic_cast<SPItem *>(obj); g_assert(item != NULL); diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 30b0f8df7..b6bfbaf15 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -578,8 +578,8 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop) void GlyphsPanel::insertText() { SPItem *textItem = 0; - std::vector<SPItem*> itemlist= targetDesktop->selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { + auto itemlist= targetDesktop->selection->items(); + for(auto i=itemlist.begin(); itemlist.end() != i; ++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { textItem = *i; break; @@ -688,8 +688,8 @@ void GlyphsPanel::selectionModifiedCB(guint flags) void GlyphsPanel::calcCanInsert() { int items = 0; - std::vector<SPItem*> itemlist= targetDesktop->selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { + auto itemlist= targetDesktop->selection->items(); + for(auto i=itemlist.begin(); itemlist.end() != i; ++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { ++items; } diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index ddcc20cb7..742e9eeb0 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -163,7 +163,11 @@ void GridArrangeTab::arrange() desktop->getDocument()->ensureUpToDate(); Inkscape::Selection *selection = desktop->getSelection(); - const std::vector<SPItem*> items = selection ? selection->items() : std::vector<SPItem*>(); + std::vector<SPItem*> items; + if (selection) { + items.insert(items.end(), selection->items().begin(), selection->items().end()); + } + for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end(); ++i){ SPItem *item = *i; Geom::OptRect b = item->documentVisualBounds(); @@ -192,7 +196,7 @@ void GridArrangeTab::arrange() // require the sorting done before we can calculate row heights etc. g_return_if_fail(selection); - std::vector<SPItem*> sorted(selection->items()); + std::vector<SPItem*> sorted(selection->items().begin(), selection->items().end()); sort(sorted.begin(),sorted.end(),sp_compare_y_position); sort(sorted.begin(),sorted.end(),sp_compare_x_position); @@ -368,8 +372,7 @@ void GridArrangeTab::on_row_spinbutton_changed() Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail( selection ); - std::vector<SPItem*> const items = selection->items(); - int selcount = items.size(); + int selcount = (int) boost::distance(selection->items()); double PerCol = ceil(selcount / NoOfColsSpinner.get_value()); NoOfRowsSpinner.set_value(PerCol); @@ -394,7 +397,7 @@ void GridArrangeTab::on_col_spinbutton_changed() Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail(selection); - int selcount = selection->items().size(); + int selcount = (int) boost::distance(selection->items()); double PerRow = ceil(selcount / NoOfRowsSpinner.get_value()); NoOfColsSpinner.set_value(PerRow); @@ -531,7 +534,10 @@ void GridArrangeTab::updateSelection() updating = true; SPDesktop *desktop = Parent->getDesktop(); Inkscape::Selection *selection = desktop ? desktop->selection : 0; - std::vector<SPItem*> const items = selection ? selection->items() : std::vector<SPItem*>(); + std::vector<SPItem*> items; + if (selection) { + items.insert(items.end(), selection->items().begin(), selection->items().end()); + } if (!items.empty()) { int selcount = items.size(); @@ -602,7 +608,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) g_return_if_fail( selection ); int selcount = 1; if (!selection->isEmpty()) { - selcount = selection->items().size(); + selcount = (int) boost::distance(selection->items()); } diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 173a964e9..a675b573b 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -362,8 +362,8 @@ void IconPreviewPanel::refreshPreview() if ( sel ) { //g_message("found a selection to play with"); - std::vector<SPItem*> const items = sel->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();!target && i!=items.end();++i){ + auto items = sel->items(); + for(auto i=items.begin();!target && i!=items.end();++i){ SPItem* item = *i; gchar const *id = item->getId(); if ( id ) { diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index df32f73cf..9d05c73bc 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -478,8 +478,8 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); SPItem *item = NULL; - std::vector<SPItem*> const items = sel->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end(); ++i){ + auto items = sel->items(); + for(auto i=items.begin(); i!=items.end(); ++i){ item = *i; if (setOpacity) { diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index ed62e26b0..b3e3aab3a 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -372,8 +372,8 @@ void PixelArtDialogImpl::vectorize() return; } - std::vector<SPItem*> const items = desktop->selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end();++i){ + auto items = desktop->selection->items(); + for(auto i=items.begin(); i!=items.end();++i){ if ( !SP_IS_IMAGE(*i) ) continue; diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index c160c269f..f3db80633 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -297,7 +297,7 @@ static void moveToPoint(int anchor, SPItem *item, Geom::Point p) void PolarArrangeTab::arrange() { Inkscape::Selection *selection = parent->getDesktop()->getSelection(); - const std::vector<SPItem*> tmp(selection->items()); + const std::vector<SPItem*> tmp(selection->items().begin(), selection->items().end()); SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active(); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 2573719ac..5d640f74c 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -123,7 +123,7 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr ) bool shown = false; if ( desktop && desktop->doc() ) { Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> const items = selection->items(); + std::vector<SPItem*> const items(selection->items().begin(), selection->items().end()); if (!items.empty()) { SPStyle query( desktop->doc() ); int result = objects_query_fillstroke((items), &query, true); diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 98b0f9502..53641c0de 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -646,8 +646,8 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) if (col == _tree.get_column(COL_ADD - 1) && down_at_add) { if (SP_IS_TAG(obj)) { bool wasadded = false; - std::vector<SPItem*> items= _desktop->selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= _desktop->selection->items(); + for(auto i=items.begin();i!=items.end();++i){ SPObject *newobj = *i; bool addchild = true; for ( SPObject *child = obj->children; child != NULL; child = child->next) { diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 355bd16d1..374cea4c2 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -443,8 +443,8 @@ SPItem *TextEdit::getSelectedTextItem (void) if (!SP_ACTIVE_DESKTOP) return NULL; - std::vector<SPItem*> tmp= SP_ACTIVE_DESKTOP->getSelection()->items(); - for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i) + auto tmp= SP_ACTIVE_DESKTOP->getSelection()->items(); + for(auto i=tmp.begin();i!=tmp.end();++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) return *i; @@ -461,8 +461,8 @@ unsigned TextEdit::getSelectedTextCount (void) unsigned int items = 0; - std::vector<SPItem*> tmp= SP_ACTIVE_DESKTOP->getSelection()->items(); - for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i) + auto tmp= SP_ACTIVE_DESKTOP->getSelection()->items(); + for(auto i=tmp.begin();i!=tmp.end();++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) ++items; @@ -568,11 +568,11 @@ void TextEdit::onApply() SPDesktop *desktop = SP_ACTIVE_DESKTOP; unsigned items = 0; - const std::vector<SPItem*> item_list = desktop->getSelection()->items(); + auto item_list = desktop->getSelection()->items(); SPCSSAttr *css = fillTextStyle (); sp_desktop_set_style(desktop, css, true); - for(std::vector<SPItem*>::const_iterator i=item_list.begin();i!=item_list.end();++i){ + for(auto i=item_list.begin();i!=item_list.end();++i){ // apply style to the reprs of all text objects in the selection if (SP_IS_TEXT (*i)) { diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index f11ac1ebe..d4a0ffd68 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -650,7 +650,7 @@ void Transformation::updatePageTransform(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { if (_check_replace_matrix.get_active()) { - Geom::Affine current (selection->items()[0]->transform); // take from the first item in selection + Geom::Affine current (selection->items().front()->transform); // take from the first item in selection Geom::Affine new_displayed = current; @@ -735,7 +735,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (_check_move_relative.get_active()) { // shift each object relatively to the previous one - std::vector<SPItem*> selected(selection->items()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); if (selected.empty()) return; if (fabs(x) > 1e-6) { @@ -810,8 +810,8 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) bool transform_stroke = prefs->getBool("/options/transform/stroke", true); bool preserve = prefs->getBool("/options/preservetransform/value", false); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector<SPItem*> tmp= selection->items(); - for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){ + auto tmp= selection->items(); + for(auto i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; Geom::OptRect bbox_pref = item->desktopPreferredBounds(); Geom::OptRect bbox_geom = item->desktopGeometricBounds(); @@ -874,8 +874,8 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection) } if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector<SPItem*> tmp= selection->items(); - for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){ + auto tmp= selection->items(); + for(auto i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0)); } @@ -894,8 +894,8 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector<SPItem*> items= selection->items(); - for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i = items.begin();i!=items.end();++i){ SPItem *item = *i; if (!_units_skew.isAbsolute()) { // percentage @@ -996,8 +996,8 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) } if (_check_replace_matrix.get_active()) { - std::vector<SPItem*> tmp= selection->items(); - for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){ + auto tmp = selection->items(); + for(auto i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; item->set_item_transform(displayed); item->updateRepr(); @@ -1149,7 +1149,7 @@ void Transformation::onReplaceMatrixToggled() double f = _scalar_transform_f.getValue(); Geom::Affine displayed (a, b, c, d, e, f); - Geom::Affine current = selection->items()[0]->transform; // take from the first item in selection + Geom::Affine current = selection->items().front()->transform; // take from the first item in selection Geom::Affine new_displayed; if (_check_replace_matrix.get_active()) { diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 7bbf588a7..bcf055654 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -2096,8 +2096,8 @@ void ContextMenu::ImageEdit(void) } #endif - std::vector<SPItem*> itemlist= _desktop->selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= _desktop->selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ Inkscape::XML::Node *ir = (*i)->getRepr(); const gchar *href = ir->attribute("xlink:href"); diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 52ddd589c..b81a630e2 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1306,8 +1306,8 @@ void cc_selection_set_avoid(bool const set_avoid) int changes = 0; - std::vector<SPItem*> l = selection->items(); - for(std::vector<SPItem*>::const_iterator i=l.begin();i!=l.end(); ++i) { + auto l = selection->items(); + for(auto i=l.begin();i!=l.end(); ++i) { SPItem *item = *i; char const *value = (set_avoid) ? "true" : NULL; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index a81161ea9..534123e90 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -692,7 +692,7 @@ void EraserTool::set_to_accumulated() { } } } else { - toWorkOn = selection->items(); + toWorkOn.insert(toWorkOn.end(), selection->items().begin(), selection->items().end()); } wasSelection = true; } @@ -744,7 +744,7 @@ void EraserTool::set_to_accumulated() { } if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - std::vector<SPItem*> nowSel(selection->items()); + std::vector<SPItem*> nowSel(selection->items().begin(), selection->items().end()); for (std::vector<SPItem*>::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) { remainingItems.push_back(*i2); } diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index e2bb0dc07..18fdf2f36 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -106,7 +106,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) { if (selection == NULL) { return; } - guint n_obj = selection->items().size(); + guint n_obj = (guint) boost::distance(selection->items()); if (!drag->isNonEmpty() || selection->isEmpty()) return; @@ -494,8 +494,8 @@ bool GradientTool::root_handler(GdkEvent* event) { // always resets selection to the single object under cursor sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->items().front()), this->mousepoint_doc, event->button.time); } else { - std::vector<SPItem*> items= selection->items(); - for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();++i) { + auto items= selection->items(); + for (auto i = items.begin();i!=items.end();++i) { SPItem *item = *i; SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -897,7 +897,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta } else { // Starting from empty space: // Sort items so that the topmost comes last - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); @@ -907,8 +907,8 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - std::vector<SPItem*> itemlist = selection->items(); - for (std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end();++i) { + auto itemlist = selection->items(); + for (auto i = itemlist.begin();i!=itemlist.end();++i) { //FIXME: see above sp_repr_css_change_recursive((*i)->getRepr(), css, "style"); @@ -931,7 +931,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta ec->_grdrag->local_change = true; // give the grab out-of-bounds values of xp/yp because we're already dragging // and therefore are already out of tolerance - ec->_grdrag->grabKnot (selection->items()[0], + ec->_grdrag->grabKnot (selection->items().front(), type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1, -1, // ignore number (though it is always 1) fill_or_stroke, 99999, 99999, etime); @@ -940,7 +940,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta // status text; we do not track coords because this branch is run once, not all the time // during drag - int n_objects = selection->items().size(); + int n_objects = (int) boost::distance(selection->items()); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle", "<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects), diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index ebcac2279..91aebbc9d 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -396,8 +396,8 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection) SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup(); gchar *arc_length; double lengthval; - std::vector<SPItem*> items= selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= selection->items(); + for(auto i=items.begin();i!=items.end();++i){ if (SP_IS_PATH(*i)) { path = SP_PATH(*i); curve = path->getCurve(); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 9aaa0c14e..a1997756b 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -103,7 +103,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { return; } - guint n_obj = selection->items().size(); + guint n_obj = (guint) boost::distance(selection->items()); if (!drag->isNonEmpty() || selection->isEmpty()) { return; @@ -467,11 +467,11 @@ bool MeshTool::root_handler(GdkEvent* event) { if (over_line) { // We take the first item in selection, because with doubleclick, the first click // always resets selection to the single object under cursor - sp_mesh_context_split_near_point(this, selection->items()[0], this->mousepoint_doc, event->button.time); + sp_mesh_context_split_near_point(this, selection->items().front(), this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. - std::vector<SPItem*> items= selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= selection->items(); + for(auto i=items.begin();i!=items.end();++i){ SPItem *item = *i; SPGradientType new_type = SP_GRADIENT_TYPE_MESH; Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -945,7 +945,7 @@ static void sp_mesh_end_drag(MeshTool &rc) { } else { // Starting from empty space: // Sort items so that the topmost comes last - std::vector<SPItem*> items(selection->items()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); @@ -955,8 +955,8 @@ static void sp_mesh_end_drag(MeshTool &rc) { SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - std::vector<SPItem*> items= selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= selection->items(); + for(auto i=items.begin();i!=items.end();++i){ //FIXME: see above sp_repr_css_change_recursive((*i)->getRepr(), css, "style"); @@ -972,7 +972,7 @@ static void sp_mesh_end_drag(MeshTool &rc) { // status text; we do not track coords because this branch is run once, not all the time // during drag - int n_objects = selection->items().size(); + int n_objects = (int) boost::distance(selection->items()); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle", "<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects), diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index f7a725794..736dafa50 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -407,8 +407,8 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::set<ShapeRecord> shapes; - std::vector<SPItem*> items= sel->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= sel->items(); + for(auto i=items.begin();i!=items.end();++i){ SPObject *obj = *i; if (SP_IS_ITEM(obj)) { @@ -443,8 +443,9 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { } } + std::vector<SPItem *> vec(sel->items().begin(), sel->items().end()); _previous_selection = _current_selection; - _current_selection = sel->items(); + _current_selection = vec; this->_multipath->setItems(shapes); this->update_tip(NULL); diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 676a41eaa..034358c37 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -477,7 +477,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_2BUTTON_PRESS: if (event->button.button == 1) { if (!selection->isEmpty()) { - SPItem *clicked_item = selection->items()[0]; + SPItem *clicked_item = selection->items().front(); if (dynamic_cast<SPGroup *>(clicked_item) && !dynamic_cast<SPBox3D *>(clicked_item)) { // enter group if it's not a 3D box desktop->setCurrentLayer(clicked_item); diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 4f36a827f..5d804a9bd 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -210,7 +210,7 @@ void SprayTool::update_cursor(bool /*with_shift*/) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = desktop->selection->items().size(); + num = (guint) boost::distance(desktop->selection->items()); sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected")); @@ -591,7 +591,7 @@ static bool fit_item(SPDesktop *desktop, if (selection->isEmpty()) { return false; } - std::vector<SPItem*> const items_selected(selection->items()); + std::vector<SPItem*> const items_selected(selection->items().begin(), selection->items().end()); std::vector<SPItem*> items_down_erased; for (std::vector<SPItem*>::const_iterator i=items_down.begin(); i!=items_down.end(); ++i) { SPItem *item_down = *i; @@ -1002,8 +1002,8 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *unionResult = NULL; // Previous union int i=1; - std::vector<SPItem*> items= selection->items(); - for(std::vector<SPItem*>::const_iterator it=items.begin();it!=items.end(); ++it){ + auto items= selection->items(); + for(auto it=items.begin();it!=items.end(); ++it){ SPItem *item1 = *it; if (i == 1) { parent_item = item1; @@ -1170,7 +1170,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point double move_standard_deviation = get_move_standard_deviation(tc); { - std::vector<SPItem*> const items(selection->items()); + std::vector<SPItem*> const items(selection->items().begin(), selection->items().end()); for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; @@ -1299,7 +1299,7 @@ bool SprayTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = desktop->selection->items().size(); + num = boost::distance(desktop->selection->items() ); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to spray.")); diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 6da6526bc..aa355f584 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -1157,8 +1157,9 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, SPItem *item = 0; if (select_under) { - SPItem *selected_at_point = desktop->getItemFromListAtPointBottom( - desktop->selection->items(), p); + auto tmp = desktop->selection->items(); + std::vector<SPItem *> vec(tmp.begin(), tmp.end()); + SPItem *selected_at_point = desktop->getItemFromListAtPointBottom(vec, p); item = desktop->getItemAtPoint(p, into_groups, selected_at_point); if (item == NULL) { // we may have reached bottom, flip over to the top item = desktop->getItemAtPoint(p, into_groups, NULL); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 4da8060e2..658cf4617 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -153,7 +153,7 @@ void TweakTool::update_cursor (bool with_shift) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = desktop->selection->items().size(); + num = (guint) boost::distance(desktop->selection->items()); sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected")); @@ -1076,8 +1076,8 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point double move_force = get_move_force(tc); double color_force = MIN(sqrt(path_force)/20.0, 1); - std::vector<SPItem*> items= selection->items(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){ + auto items= selection->items(); + for(auto i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; if (is_color_mode (tc->mode)) { @@ -1185,7 +1185,7 @@ bool TweakTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = desktop->selection->items().size(); + num = (guint) boost::distance(desktop->selection->items()); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to tweak.")); diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index a6be353f8..8158a76a9 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -258,8 +258,8 @@ VanishingPoint::set_pos(Proj::Pt2 const &pt) { std::list<SPBox3D *> VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { std::list<SPBox3D *> sel_boxes; - std::vector<SPItem*> itemlist= sel->items(); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist= sel->items(); + for (auto i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box && this->hasBox(box)) { @@ -397,8 +397,8 @@ VPDragger::VPsOfSelectedBoxes() { VanishingPoint *vp; // FIXME: Should we take the selection from the parent VPDrag? I guess it shouldn't make a difference. Inkscape::Selection *sel = SP_ACTIVE_DESKTOP->getSelection(); - std::vector<SPItem*> itemlist= sel->items(); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist= sel->items(); + for (auto i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { @@ -575,8 +575,8 @@ VPDrag::updateDraggers () g_return_if_fail (this->selection != NULL); - std::vector<SPItem*> itemlist= this->selection->items(); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist= this->selection->items(); + for (auto i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { @@ -607,8 +607,8 @@ VPDrag::updateLines () g_return_if_fail (this->selection != NULL); - std::vector<SPItem*> itemlist= this->selection->items(); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist= this->selection->items(); + for (auto i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { @@ -625,11 +625,11 @@ VPDrag::updateBoxHandles () // FIXME: Is there a way to update the knots without accessing the // (previously) statically linked function KnotHolder::update_knots? - std::vector<SPItem*> sel = selection->items(); + auto sel = selection->items(); if (sel.empty()) return; // no selection - if (sel.size() > 1) { + if (boost::distance(sel) > 1) { // Currently we only show handles if a single box is selected return; } diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index 5db714f85..826ad2ced 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -97,8 +97,8 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v gchar* namespaced_name = g_strconcat("sodipodi:", value_name, NULL); bool modmade = false; - std::vector<SPItem*> itemlist= desktop->getSelection()->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { @@ -163,8 +163,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) bool modmade = false; if ( ege_select_one_action_get_active(act) != 0 ) { - std::vector<SPItem*> itemlist= desktop->getSelection()->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -174,8 +174,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) } } } else { - std::vector<SPItem*> itemlist= desktop->getSelection()->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -264,8 +264,8 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb purge_repr_listener( tbl, tbl ); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { n_selected++; diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp index 54b4be547..648ea0951 100644 --- a/src/widgets/connector-toolbar.cpp +++ b/src/widgets/connector-toolbar.cpp @@ -97,8 +97,8 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl gchar *value = is_orthog ? orthog_str : polyline_str ; bool modmade = false; - std::vector<SPItem*> itemlist= desktop->getSelection()->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (Inkscape::UI::Tools::cc_item_is_connector(item)) { @@ -144,8 +144,8 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) g_ascii_dtostr(value, G_ASCII_DTOSTR_BUF_SIZE, newValue); bool modmade = false; - std::vector<SPItem*> itemlist= desktop->getSelection()->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (Inkscape::UI::Tools::cc_item_is_connector(item)) { @@ -227,7 +227,9 @@ static void sp_connector_graph_layout(void) int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - graphlayout(SP_ACTIVE_DESKTOP->getSelection()->items()); + auto tmp = SP_ACTIVE_DESKTOP->getSelection()->items(); + std::vector<SPItem *> vec(tmp.begin(), tmp.end()); + graphlayout(vec); prefs->setInt("/options/clonecompensation/value", saved_compensation); diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index 8c3a0a0a8..713eaf4cf 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -476,7 +476,7 @@ void FillNStroke::updateFromPaint() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> const items = selection->items(); + std::vector<SPItem*> const items(selection->items().begin(), selection->items().end()); switch (psel->mode) { case SPPaintSelector::MODE_EMPTY: diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index ab345b73f..a395d1954 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -116,8 +116,8 @@ void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient } // If no drag or no dragger selected, act on selection - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ gr_apply_gradient_to_item(*i, gr, initialType, initialMode, initialMode); } } @@ -216,8 +216,8 @@ void gr_get_dt_selected_gradient(Inkscape::Selection *selection, SPGradient *&gr { SPGradient *gradient = 0; - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; @@ -284,8 +284,8 @@ void gr_read_selection( Inkscape::Selection *selection, } // If no selected dragger, read desktop selection - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; SPStyle *style = item->style; diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 5d326253c..7100a915b 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -89,8 +89,8 @@ void ms_read_selection( Inkscape::Selection *selection, bool first = true; ms_type = SP_MESH_TYPE_COONS; - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; SPStyle *style = item->style; @@ -216,8 +216,8 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMesh *&ms_sel { SPMesh *gradient = 0; - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index 34cebbe1b..e4fa04365 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -240,8 +240,8 @@ static void sp_pencil_tb_defaults(GtkWidget * /*widget*/, GObject *obj) static void sp_simplify_flatten(GtkWidget * /*widget*/, GObject *obj) { SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(obj, "desktop")); - std::vector<SPItem *> selected = desktop->getSelection()->items(); - for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){ + auto selected = desktop->getSelection()->items(); + for (auto it(selected.begin()); it != selected.end(); ++it){ SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it); if (lpeitem && lpeitem->hasPathEffect()){ PathEffectList lpelist = lpeitem->getEffectList(); @@ -285,8 +285,8 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb gtk_adjustment_get_value(adj)); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(tbl, "desktop")); - std::vector<SPItem *> selected = desktop->getSelection()->items(); - for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){ + auto selected = desktop->getSelection()->items(); + for (auto it(selected.begin()); it != selected.end(); ++it){ SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it); if (lpeitem && lpeitem->hasPathEffect()){ Inkscape::LivePathEffect::Effect* simplify = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 2ee38608b..51d4b1d57 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -106,8 +106,8 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ if (SP_IS_RECT(*i)) { if (gtk_adjustment_get_value(adj) != 0) { (SP_RECT(*i)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, "px")); @@ -243,8 +243,8 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO } purge_repr_listener( tbl, tbl ); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ if (SP_IS_RECT(*i)) { n_selected++; item = *i; diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp index 8f5f10bf8..966be284f 100644 --- a/src/widgets/spiral-toolbar.cpp +++ b/src/widgets/spiral-toolbar.cpp @@ -79,8 +79,8 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr gchar* namespaced_name = g_strconcat("sodipodi:", value_name.data(), NULL); bool modmade = false; - std::vector<SPItem*> itemlist= desktop->getSelection()->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ SPItem *item = *i; if (SP_IS_SPIRAL(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -195,8 +195,8 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, purge_repr_listener( tbl, tbl ); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ SPItem *item = *i; if (SP_IS_SPIRAL(item)) { n_selected++; diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index fc8757162..561134970 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -83,8 +83,8 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -128,8 +128,8 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -185,8 +185,8 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d gtk_action_set_visible( prop_action, !flat ); } - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -224,8 +224,8 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -264,8 +264,8 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -367,8 +367,8 @@ sp_star_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl) purge_repr_listener( tbl, tbl ); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { n_selected++; diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 7ed2c3180..9597d036a 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -515,8 +515,8 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, //spw->updateMarkerHist(which); Inkscape::Selection *selection = spw->desktop->getSelection(); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) { // can't set marker to rect, until it's converted to using <path> continue; @@ -988,7 +988,7 @@ StrokeStyle::updateLine() if (!sel || sel->isEmpty()) return; - std::vector<SPItem*> const objects = sel->items(); + std::vector<SPItem*> const objects(sel->items().begin(), sel->items().end()); SPObject * const object = objects[0]; SPStyle * const style = object->style; @@ -1044,7 +1044,7 @@ StrokeStyle::scaleLine() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> items= selection->items(); + auto items= selection->items(); /* TODO: Create some standardized method */ SPCSSAttr *css = sp_repr_css_attr_new(); @@ -1064,7 +1064,7 @@ StrokeStyle::scaleLine() int ndash; dashSelector->get_dash(&ndash, &dash, &offset); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + for(auto i=items.begin();i!=items.end();++i){ /* Set stroke width */ double width; if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 3d08b04f1..0431499aa 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -378,8 +378,8 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) // move the x of all texts to preserve the same bbox Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT(*i)) { SPItem *item = *i; @@ -560,8 +560,8 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) // Only need to save for undo if a text item has been changed. Inkscape::Selection *selection = desktop->getSelection(); bool modmade = false; - std::vector<SPItem*> itemlist= selection->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT (*i)) { modmade = true; } @@ -625,7 +625,7 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) SPDesktop *desktop = SP_ACTIVE_DESKTOP; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist= selection->items(); + auto itemlist = selection->items(); // Convert between units if ((unit->abbr == "" || unit->abbr == "em") && old_unit == SP_CSS_UNIT_EX) { @@ -644,7 +644,7 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) // Convert absolute to relative... for the moment use average font-size double font_size = 0; int count = 0; - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT (*i)) { double doc_scale = Geom::Affine((*i)->i2dt_affine()).descrim(); font_size += (*i)->style->font_size.computed * doc_scale; @@ -673,7 +673,7 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) // Convert relative to absolute... for the moment use average font-size double font_size = 0; int count = 0; - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT (*i)) { double doc_scale = Geom::Affine((*i)->i2dt_affine()).descrim(); font_size += (*i)->style->font_size.computed * doc_scale; @@ -716,7 +716,7 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) // Only need to save for undo if a text item has been changed. bool modmade = false; - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT (*i)) { modmade = true; } @@ -1120,8 +1120,8 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ // Only flowed text can be justified, only normal text can be kerned... // Find out if we have flowed text now so we can use it several places gboolean isFlow = false; - std::vector<SPItem*> itemlist= SP_ACTIVE_DESKTOP->getSelection()->items(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + auto itemlist= SP_ACTIVE_DESKTOP->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ // const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId(); // std::cout << " " << id << std::endl; if( SP_IS_FLOWTEXT(*i)) { |
