diff options
| author | Marc Jeanmougin <mc@localhost.localdomain> | 2015-02-27 02:10:36 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <mc@localhost.localdomain> | 2015-02-27 02:10:36 +0000 |
| commit | 9a7fa4d1899d30ec745107823f307b2a0bf3172f (patch) | |
| tree | 216bd7b47a96425af53642e2c3869a70ebfa23e5 /src | |
| parent | should replace buggy pot file (diff) | |
| download | inkscape-9a7fa4d1899d30ec745107823f307b2a0bf3172f.tar.gz inkscape-9a7fa4d1899d30ec745107823f307b2a0bf3172f.zip | |
corrected the casts (hopefully)
(bzr r13922.1.10)
Diffstat (limited to 'src')
85 files changed, 294 insertions, 370 deletions
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index fb9fbd935..eb6694233 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -253,8 +253,8 @@ static std::vector<Geom::Point> approxItemWithPoints(SPItem const *item, const G SPGroup* group = SP_GROUP(item); // consider all first-order children std::vector<SPItem*> itemlist = sp_item_group_item_list(group); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem* child_item = SP_ITEM(*i); + for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); i++) { + SPItem* child_item = *i; std::vector<Geom::Point> child_points = approxItemWithPoints(child_item, item_transform * child_item->transform); poly_points.insert(poly_points.end(), child_points.begin(), child_points.end()); } diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index e1a81f00a..82f66dcdf 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -195,9 +195,9 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_css_attr_unset_uris(css_write); prefs->mergeStyle("/desktop/style", css_write); std::vector<SPItem*> const itemlist = desktop->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { /* last used styles for 3D box faces are stored separately */ - SPObject *obj = reinterpret_cast<SPObject *>(*i); // TODO unsafe until Selection is refactored. + SPObject *obj = reinterpret_cast<SPObject *>(*i); Box3DSide *side = dynamic_cast<Box3DSide *>(obj); if (side) { const char * descr = box3d_side_axes_string(side); @@ -235,8 +235,8 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write css_no_text = sp_css_attr_unset_text(css_no_text); std::vector<SPItem*> const itemlist = desktop->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = reinterpret_cast<SPItem *>(*i); + for (std::vector<SPItem*>::const_iterator 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) if (isTextualItem(item)) { @@ -447,9 +447,9 @@ stroke_average_width (const std::vector<SPItem*> &objects) gdouble avgwidth = 0.0; bool notstroked = true; int n_notstroked = 0; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); - SPItem *item = dynamic_cast<SPItem *>(obj); + SPItem *item = *i; if (!item) { continue; } @@ -514,7 +514,7 @@ objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_re prev[0] = prev[1] = prev[2] = 0.0; bool same_color = true; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i!= objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!obj) { continue; @@ -698,7 +698,7 @@ objects_query_opacity (const std::vector<SPItem*> &objects, SPStyle *style_res) guint opacity_items = 0; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!obj) { continue; @@ -754,7 +754,7 @@ objects_query_strokewidth (const std::vector<SPItem*> &objects, SPStyle *style_r int n_stroked = 0; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!obj) { continue; @@ -828,7 +828,7 @@ objects_query_miterlimit (const std::vector<SPItem*> &objects, SPStyle *style_re gdouble prev_ml = -1; bool same_ml = true; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!dynamic_cast<SPItem *>(obj)) { continue; @@ -887,7 +887,7 @@ objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res bool same_cap = true; int n_stroked = 0; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!dynamic_cast<SPItem *>(obj)) { continue; @@ -941,7 +941,7 @@ objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_re bool same_join = true; int n_stroked = 0; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!dynamic_cast<SPItem *>(obj)) { continue; @@ -1004,7 +1004,7 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r int texts = 0; int no_size = 0; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!isTextualItem(obj)) { @@ -1123,7 +1123,7 @@ objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res int texts = 0; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!isTextualItem(obj)) { @@ -1192,7 +1192,7 @@ objects_query_baselines (const std::vector<SPItem*> &objects, SPStyle *style_res int texts = 0; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!isTextualItem(obj)) { @@ -1280,7 +1280,7 @@ objects_query_fontfamily (const std::vector<SPItem*> &objects, SPStyle *style_re } style_res->font_family.set = FALSE; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl; @@ -1336,7 +1336,7 @@ objects_query_fontspecification (const std::vector<SPItem*> &objects, SPStyle *s } style_res->font_specification.set = FALSE; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl; @@ -1394,7 +1394,7 @@ objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res) bool same_blend = true; guint items = 0; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!obj) { continue; @@ -1484,7 +1484,7 @@ objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res) guint blur_items = 0; guint items = 0; - for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!obj) { continue; diff --git a/src/desktop-style.h b/src/desktop-style.h index 7ca25b9ae..a72f49776 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -13,11 +13,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "selection.h" // SelContainer class ColorRGBA; class SPCSSAttr; class SPDesktop; class SPObject; +class SPItem; class SPStyle; typedef struct _GSList GSList; namespace Inkscape { diff --git a/src/document.cpp b/src/document.cpp index 07ad10505..0582f1a70 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1289,7 +1289,7 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey); if (arenaitem && arenaitem->pick(p, delta, 1) != NULL && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { - if (find(list.begin(),list.end(),item)==list.end() ) { + if (find(list.begin(),list.end(),item)!=list.end() ) { bottomMost = item; } } diff --git a/src/document.h b/src/document.h index 57ff7643c..bc5b2745a 100644 --- a/src/document.h +++ b/src/document.h @@ -27,7 +27,6 @@ #include <glibmm/ustring.h> #include <boost/ptr_container/ptr_list.hpp> #include <vector> -#include "selection.h" namespace Avoid { class Router; diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 90a7810e6..971f0b64a 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -65,7 +65,7 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Imp if (desktop != NULL) { std::vector<SPItem*> selected = desktop->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator x=selected.begin();x!=selected.end();x++){ + for(std::vector<SPItem*>::const_iterator 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 cea6d139f..11c494b18 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -51,7 +51,7 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node const* first_select = NULL; if (!selected.empty()) { - const SPItem * item = SP_ITEM(selected.front()); + const SPItem * item = selected.front(); first_select = item->getRepr(); } diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 95d5c7edc..5c708cf9a 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -691,7 +691,7 @@ void Script::effect(Inkscape::Extension::Effect *module, std::vector<SPItem*> selected = desktop->getSelection()->itemList(); //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(std::vector<SPItem*>::const_iterator 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 64abd6c4d..3a29b3dc0 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -83,8 +83,8 @@ 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++) { - SPItem *item = static_cast<SPItem *>(*i); + for (std::vector<SPItem*>::const_iterator 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")) { diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 257cac161..b80e5ddbb 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -70,7 +70,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View for(std::vector<SPItem*>::iterator item = items.begin(); item != items.end(); ++item) { - SPItem * spitem = static_cast<SPItem*>(*item); + SPItem * spitem = *item; std::vector<Inkscape::XML::Node *> new_items(steps); Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index f614ec745..b30c8892e 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -295,7 +295,7 @@ static void sp_group_render(SPGroup *group, CairoRenderContext *ctx) TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(item->style->opacity.value))); std::vector<SPObject*> l(group->childList(false)); - for(std::vector<SPObject*>::const_iterator x=l.begin();x!=l.end();x++){ + for(std::vector<SPObject*>::const_iterator x = l.begin(); x!= l.end(); x++){ SPObject *o = reinterpret_cast<SPObject *>(*x); SPItem *item = dynamic_cast<SPItem *>(o); if (item) { diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index a5eb7de60..65162af22 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -133,7 +133,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie for(std::vector<SPItem*>::iterator item = items.begin(); item != items.end(); ++item) { - SPItem * spitem = static_cast<SPItem*>(*item); + SPItem * spitem = *item; Inkscape::XML::Node * node = spitem->getRepr(); SPCSSAttr * css = sp_repr_css_attr(node, "style"); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 440c6b822..60d606a02 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -195,7 +195,7 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { - first_select = (selected.front())->getRepr(); + first_select = selected[0]->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index a2de264ab..831a8d030 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -229,8 +229,8 @@ LaTeXTextRenderer::writePostamble() void LaTeXTextRenderer::sp_group_render(SPGroup *group) { std::vector<SPObject*> l = (group->childList(false)); - for(std::vector<SPObject*>::const_iterator x=l.begin();x!=l.end();x++){ - SPObject *o = reinterpret_cast<SPObject *>(*x); + for(std::vector<SPObject*>::const_iterator x = l.begin(); x != l.end(); x++){ + SPObject *o = *x; SPItem *item = dynamic_cast<SPItem *>(o); if (item) { renderItem(item); diff --git a/src/file.cpp b/src/file.cpp index f33e284b2..07e41c550 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1088,7 +1088,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) target_parent->appendChild(obj_copy); Inkscape::GC::release(obj_copy); - pasted_objects.push_back((obj_copy)); + pasted_objects.push_back(obj_copy); } // Change the selection to the freshly pasted objects diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index c89cf6220..9298a1ffc 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -23,9 +23,9 @@ #include "filter-chemistry.h" #include "filter-enums.h" + #include "filters/blend.h" #include "filters/gaussian-blur.h" -#include "selection.h" #include "sp-filter.h" #include "sp-filter-reference.h" #include "svg/css-ostringstream.h" diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index a72423bbb..b59b38475 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -1571,8 +1571,8 @@ void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTa Inkscape::Selection *selection = desktop->getSelection(); const std::vector<SPItem*> list=selection->itemList(); - for (std::vector<SPItem*>::const_iterator i=list.begin();i!=list.end();i++) { - sp_item_gradient_invert_vector_color(SP_ITEM(*i), fill_or_stroke); + for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { + sp_item_gradient_invert_vector_color(*i, fill_or_stroke); } // we did an undoable action @@ -1596,9 +1596,9 @@ void sp_gradient_reverse_selected_gradients(SPDesktop *desktop) 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->itemList(); - for (std::vector<SPItem*>::const_iterator i=list.begin();i!=list.end();i++) { - sp_item_gradient_reverse_vector(SP_ITEM(*i), Inkscape::FOR_FILL); - sp_item_gradient_reverse_vector(SP_ITEM(*i), Inkscape::FOR_STROKE); + for (std::vector<SPItem*>::const_iterator 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 525fc074f..5a49435d4 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2083,8 +2083,8 @@ void GrDrag::updateDraggers() g_return_if_fail(this->selection != NULL); std::vector<SPItem*> list = this->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i=list.begin();i!=list.end();i++) { - SPItem *item = SP_ITEM(*i); + for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { + SPItem *item = *i; SPStyle *style = item->style; if (style && (style->fill.isPaintserver())) { @@ -2152,8 +2152,8 @@ void GrDrag::updateLines() g_return_if_fail(this->selection != NULL); std::vector<SPItem*> list = this->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i=list.begin();i!=list.end();i++) { - SPItem *item = SP_ITEM(*i); + for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { + SPItem *item = *i; SPStyle *style = item->style; @@ -2296,8 +2296,8 @@ void GrDrag::updateLevels() g_return_if_fail (this->selection != NULL); std::vector<SPItem*> list = this->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i=list.begin();i!=list.end();i++) { - SPItem *item = SP_ITEM(*i); + for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { + SPItem *item = *i; Geom::OptRect rect = item->desktopVisualBounds(); if (rect) { // Remember the edges of the bbox and the center axis diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 4d590173a..40994347c 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -89,8 +89,8 @@ struct CheckProgress : TestConvergence { * not connectors in filtered */ void filterConnectors(std::vector<SPItem*> const &items, list<SPItem *> &filtered) { - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = SP_ITEM(*i); + for(std::vector<SPItem*>::const_iterator i = items.begin();i !=items.end(); i++){ + SPItem *item = *i; if(!isConnector(item)) { filtered.push_back(item); } diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 6cdf09180..7a1d391a3 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -506,7 +506,7 @@ static void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &paths, std::vector<double> &stroke_widths){ if (SP_IS_GROUP(lpeitem)) { std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + for ( std::vector<SPItem*>::const_iterator iter = item_list.begin(); iter != item_list.end(); iter++) { SPObject *subitem = static_cast<SPObject *>(*iter); if (SP_IS_LPE_ITEM(subitem)) { collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths); diff --git a/src/main.cpp b/src/main.cpp index c62b9cd25..062edcb98 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1174,9 +1174,6 @@ static int sp_process_file_list(GSList *fl) sp_item_list_to_curves(items, selected, to_select); - items.clear(); - selected.clear(); - to_select.clear(); } if(sp_export_id) { doc->ensureUpToDate(); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 830c3c1db..f9c189c58 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -238,8 +238,8 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER); if (old_pref2) { std::vector<SPItem*> rotationSource=_snapmanager->getRotationCenterSource(); - for ( std::vector<SPItem*>::const_iterator itemlist=rotationSource.begin();itemlist!=rotationSource.end();itemlist++) { - if ((*i).item == reinterpret_cast<SPItem*>(*itemlist)) { + for ( std::vector<SPItem*>::const_iterator itemlist = rotationSource.begin(); itemlist != rotationSource.end(); itemlist++) { + if ((*i).item == *itemlist) { // don't snap to this item's rotation center _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false); break; diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index ae1e0064f..53ad96596 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -45,16 +45,10 @@ using Inkscape::DocumentUndo; -inline bool less_than_objects(SPObject const *first, SPObject const *second) -{ - return sp_repr_compare_position(first->getRepr(), - second->getRepr())<0; -} - inline bool less_than_items(SPItem const *first, SPItem const *second) { return sp_repr_compare_position(first->getRepr(), - second->getRepr())<0; + second->getRepr())>0; } void @@ -77,21 +71,19 @@ sp_selected_path_combine(SPDesktop *desktop) items = sp_degroup_list (items); // descend into any groups in selection std::vector<SPItem*> to_paths; - for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++) { - SPItem *item = (SPItem *) (*i); - if (!dynamic_cast<SPPath *>(item) && !dynamic_cast<SPGroup *>(item)) { - to_paths.push_back(item); + for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++) { + if (!dynamic_cast<SPPath *>(*i) && !dynamic_cast<SPGroup *>(*i)) { + to_paths.push_back(*i); } } std::vector<Inkscape::XML::Node*> converted; bool did = sp_item_list_to_curves(to_paths, items, converted); - to_paths.clear(); - for (std::vector<Inkscape::XML::Node*>::const_iterator i=converted.begin();i!=converted.end();i++) - items.push_back((SPItem*)doc->getObjectByRepr((Inkscape::XML::Node*)(*i))); + for (std::vector<Inkscape::XML::Node*>::const_iterator i = converted.begin(); i != converted.end(); i++) + items.push_back((SPItem*)doc->getObjectByRepr(*i)); items = sp_degroup_list (items); // converting to path may have added more groups, descend again - sort(items.begin(),items.end(),less_than_objects); + sort(items.begin(),items.end(),less_than_items); assert(!items.empty()); // cannot be NULL because of list length check at top of function // remember the position, id, transform and style of the topmost path, they will be assigned to the combined one @@ -109,9 +101,9 @@ sp_selected_path_combine(SPDesktop *desktop) selection->clear(); } - for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ + for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++){ - SPItem *item = (SPItem *) (*i); + SPItem *item = *i; SPPath *path = dynamic_cast<SPPath *>(item); if (!path) { continue; @@ -212,9 +204,9 @@ sp_selected_path_break_apart(SPDesktop *desktop) bool did = false; std::vector<SPItem*> itemlist(selection->itemList()); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); i++){ - SPItem *item = (SPItem *) (*i); + SPItem *item = *i; SPPath *path = dynamic_cast<SPPath *>(item); if (!path) { @@ -277,11 +269,10 @@ sp_selected_path_break_apart(SPDesktop *desktop) if (l == list) repr->setAttribute("id", id); - reprs.push_back(repr); + reprs.insert(reprs.begin(),repr); Inkscape::GC::release(repr); } - //reverse selection->setReprList(reprs); g_slist_free(list); @@ -323,11 +314,8 @@ sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, b did = sp_item_list_to_curves(items, selected, to_select); - items.clear(); selection->setReprList(to_select); selection->addList(selected); - to_select.clear(); - selected.clear(); if (interactive && desktop) { desktop->clearWaitingCursor(); @@ -367,9 +355,9 @@ sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*>& { bool did = false; - for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++){ - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); + SPItem *item = *i; g_assert(item != NULL); SPDocument *document = item->document; @@ -400,7 +388,7 @@ sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*>& Inkscape::XML::Node *repr = box3d_convert_to_group(box)->getRepr(); if (repr) { - to_select.push_back(repr); + to_select.insert(to_select.begin(),repr); did = true; selected.erase(find(selected.begin(),selected.end(),item)); } @@ -418,9 +406,6 @@ sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*>& if (sp_item_list_to_curves(item_list, item_selected, item_to_select)) did = true; - item_list.clear(); - item_to_select.clear(); - item_selected.clear(); continue; } @@ -472,7 +457,7 @@ sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*>& /* Buglet: We don't re-add the (new version of the) object to the selection of any other * desktops where it was previously selected. */ - to_select.push_back(repr); + to_select.insert(to_select.begin(),repr); Inkscape::GC::release(repr); } @@ -628,7 +613,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 (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++){ SPPath *path = dynamic_cast<SPPath *>(static_cast<SPObject *>(*i)); if (!path) { diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index 7cb1694e3..01ce2c47e 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -49,7 +49,7 @@ void removeoverlap(std::vector<SPItem*> const &items, double const xGap, double it != selected.end(); ++it) { - SPItem* item=static_cast<SPItem*>(*it); + SPItem* item = *it; using Geom::X; using Geom::Y; Geom::OptRect item_box((item)->desktopVisualBounds()); if (item_box) { diff --git a/src/selcue.cpp b/src/selcue.cpp index f48378cdc..76eae3fa8 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -104,8 +104,8 @@ void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) int bcount = 0; std::vector<SPItem*> ll=_selection->itemList(); - for (std::vector<SPItem*>::const_iterator l=ll.begin();l!=ll.end();l++) { - SPItem *item = static_cast<SPItem *>(*l); + for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); l++) { + SPItem *item = *l; SPCanvasItem* box = _item_bboxes[bcount ++]; if (box) { @@ -147,8 +147,8 @@ void Inkscape::SelCue::_newItemBboxes() int prefs_bbox = prefs->getBool("/tools/bounding_box"); std::vector<SPItem*> ll=_selection->itemList(); - for (std::vector<SPItem*>::const_iterator l=ll.begin();l!=ll.end();l++) { - SPItem *item = static_cast<SPItem *>(*l); + for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); l++) { + SPItem *item = *l; Geom::OptRect const b = (prefs_bbox == 0) ? item->desktopVisualBounds() : item->desktopGeometricBounds(); @@ -201,7 +201,7 @@ void Inkscape::SelCue::_newTextBaselines() } _text_baselines.clear(); - std::vector<SPItem*> ll=_selection->itemList(); + std::vector<SPItem*> ll = _selection->itemList(); for (std::vector<SPItem*>::const_iterator l=ll.begin();l!=ll.end();l++) { SPItem *item = static_cast<SPItem *>(*l); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 3c91392cf..d6f8b8a37 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -283,8 +283,8 @@ void SelectionHelper::fixSelection(SPDesktop *dt) std::vector<SPItem*> const selList = selection->itemList(); - for( std::vector<SPItem*>::const_reverse_iterator i=selList.rbegin();i!=selList.rend();i++ ) { - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); + for( std::vector<SPItem*>::const_reverse_iterator i = selList.rbegin(); i != selList.rend(); i++ ) { + SPItem *item = *i; if( item && !dt->isLayer(item) && (!item->isLocked())) @@ -303,7 +303,7 @@ void SelectionHelper::fixSelection(SPDesktop *dt) * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t', * then prepends the copy to 'clip'. */ -static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, std::vector<SPItem*> &clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, std::vector<Inkscape::XML::Node*> &clip, Inkscape::XML::Document* xml_doc) { Inkscape::XML::Node *copy = repr->duplicate(xml_doc); @@ -319,31 +319,32 @@ static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t copy->setAttribute("transform", affinestr); g_free(affinestr); - clip.insert(clip.begin(),dynamic_cast<SPItem*>(copy)); + clip.insert(clip.begin(),copy); } -static void sp_selection_copy_impl(std::vector<SPItem*> const &items, std::vector<SPItem*> &clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_impl(std::vector<SPItem*> const &items, std::vector<Inkscape::XML::Node*> &clip, Inkscape::XML::Document* xml_doc) { // Sort items: std::vector<SPItem*> sorted_items(items); sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position); // Copy item reprs: - for (std::vector<SPItem*>::const_iterator i = sorted_items.begin();i!=sorted_items.end();i++) { - SPItem *item = dynamic_cast<SPItem *>(SP_OBJECT(*i)); + for (std::vector<SPItem*>::const_iterator i = sorted_items.begin(); i != sorted_items.end(); i++) { + SPItem *item = *i; if (item) { sp_selection_copy_one(item->getRepr(), item->i2doc_affine(), clip, xml_doc); } else { g_assert_not_reached(); } } - std::vector<SPItem*> tmp(clip); - for(int i=0;i<tmp.size();i++){clip[i]=tmp[tmp.size()-i-1];} - sorted_items.clear(); + std::vector<Inkscape::XML::Node*> tmp(clip); + for(int i=0;i<tmp.size();i++){ + clip[i]=tmp[tmp.size()-i-1]; + } } // TODO check if parent parameter should be changed to SPItem, of if the code should handle non-items. -static std::vector<Inkscape::XML::Node*> sp_selection_paste_impl(SPDocument *doc, SPObject *parent, std::vector<SPItem*> &clip) +static std::vector<Inkscape::XML::Node*> sp_selection_paste_impl(SPDocument *doc, SPObject *parent, std::vector<Inkscape::XML::Node*> &clip) { Inkscape::XML::Document *xml_doc = doc->getReprDoc(); @@ -352,8 +353,8 @@ static std::vector<Inkscape::XML::Node*> sp_selection_paste_impl(SPDocument *doc std::vector<Inkscape::XML::Node*> copied; // add objects to document - for (std::vector<SPItem*>::const_iterator l=clip.begin();l!=clip.end();l++) { - Inkscape::XML::Node *repr = dynamic_cast<Inkscape::XML::Node *>(*l); + for (std::vector<Inkscape::XML::Node*>::const_iterator l = clip.begin(); l != clip.end(); l++) { + Inkscape::XML::Node *repr = *l; Inkscape::XML::Node *copy = repr->duplicate(xml_doc); // premultiply the item transform by the accumulated parent transform in the paste layer @@ -379,11 +380,11 @@ static std::vector<Inkscape::XML::Node*> sp_selection_paste_impl(SPDocument *doc static void sp_selection_delete_impl(std::vector<SPItem*> const &items, bool propagate = true, bool propagate_descendants = true) { - for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { - sp_object_ref(static_cast<SPItem *>(*i), NULL); + for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) { + sp_object_ref(*i, NULL); } - for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { - SPItem *item = static_cast<SPItem *>(*i); + for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) { + SPItem *item = *i; item->deleteObject(propagate, propagate_descendants); sp_object_unref(item, NULL); } @@ -413,7 +414,6 @@ void sp_selection_delete(SPDesktop *desktop) std::vector<SPItem*> selected(selection->itemList()); selection->clear(); sp_selection_delete_impl(selected); - selected.clear(); desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); /* a tool may have set up private information in it's selection context @@ -440,10 +440,6 @@ static void add_ids_recursive(std::vector<const gchar *> &ids, SPObject *obj) } } } -/* -bool sp_repr_compare_position_obj(SPObject* &a,SPObject* &b){ - return sp_repr_compare_position(dynamic_cast<Inkscape::XML::Node*>(a),dynamic_cast<Inkscape::XML::Node*>(b)); -}*/ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) { @@ -476,8 +472,8 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) bool relink_clones = prefs->getBool("/options/relinkclonesonduplicate/value"); const bool fork_livepatheffects = prefs->getBool("/options/forklpeonduplicate/value", true); - for(std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ - Inkscape::XML::Node *old_repr = (*i); + for(std::vector<Inkscape::XML::Node*>::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){ + Inkscape::XML::Node *old_repr = *i; Inkscape::XML::Node *parent = old_repr->parent(); Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); @@ -558,7 +554,7 @@ void sp_edit_clear_all(Inkscape::Selection *selection) g_return_if_fail(group != NULL); std::vector<SPItem*> items = sp_item_group_item_list(group); - for(unsigned int i=0;i<items.size();i++){ + for(unsigned int i = 0; i < items.size(); i++){ reinterpret_cast<SPObject*>(items[i])->deleteObject(); } @@ -644,7 +640,6 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i } } - all_items.clear(); break; } case PREFS_SELECTION_LAYER_RECURSIVE: { @@ -653,17 +648,14 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i break; } default: { - std::vector<SPItem*> x; - items = get_all_items(x, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); + std::vector<SPItem*> x; + items = get_all_items(x, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); break; } } selection->setList(items); - if (!items.empty()) { - items.clear(); - } } void sp_edit_select_all(SPDesktop *desktop) @@ -694,8 +686,8 @@ static void sp_selection_group_impl(std::vector<Inkscape::XML::Node*> p, Inkscap gint topmost = (dynamic_cast<Inkscape::XML::Node *>(p.back()))->position(); Inkscape::XML::Node *topmost_parent = (dynamic_cast<Inkscape::XML::Node *>(p.back()))->parent(); - for(std::vector<Inkscape::XML::Node*>::const_iterator i=p.begin();i!=p.end();i++){ - Inkscape::XML::Node *current = (*i); + for(std::vector<Inkscape::XML::Node*>::const_iterator i = p.begin(); i != p.end(); i++){ + Inkscape::XML::Node *current = *i; if (current->parent() == topmost_parent) { Inkscape::XML::Node *spnew = current->duplicate(xml_doc); @@ -704,7 +696,7 @@ static void sp_selection_group_impl(std::vector<Inkscape::XML::Node*> p, Inkscap Inkscape::GC::release(spnew); topmost --; // only reduce count for those items deleted from topmost_parent } else { // move it to topmost_parent first - std::vector<SPItem*> temp_clip; + std::vector<Inkscape::XML::Node*> temp_clip; // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform @@ -817,7 +809,7 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) // If any of the clones refer to the groups, unlink them and replace them with successors // in the items list. GSList *clones_to_unlink = NULL; - for (std::vector<SPItem*>::const_iterator item = items.begin(); item!=items.end(); item++) { + for (std::vector<SPItem*>::const_iterator item = items.begin(); item != items.end(); item++) { SPUse *use = dynamic_cast<SPUse *>(static_cast<SPItem *>(*item)); SPItem *original = use; @@ -838,13 +830,13 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) for (GSList *item = clones_to_unlink; item; item = item->next) { SPUse *use = static_cast<SPUse *>(item->data); std::vector<SPItem*>::iterator items_node = std::find(items.begin(),items.end(), item->data); - (*items_node) = use->unlink(); + *items_node = use->unlink(); } g_slist_free(clones_to_unlink); // do the actual work - for (std::vector<SPItem*>::iterator item = items.begin(); item!=items.end(); item++) { - SPItem *obj = static_cast<SPItem *>(*item); + for (std::vector<SPItem*>::iterator item = items.begin(); item != items.end(); item++) { + SPItem *obj = *item; // ungroup only the groups marked earlier if (g_slist_find(groups, *item) != NULL) { @@ -852,7 +844,7 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) sp_item_group_ungroup(dynamic_cast<SPGroup *>(obj), children, false); // add the items resulting from ungrouping to the selection new_select.insert(new_select.end(),children.begin(),children.end()); - (*item) = NULL; // zero out the original pointer, which is no longer valid + *item = NULL; // zero out the original pointer, which is no longer valid } else { // if not a group, keep in the selection new_select.push_back(*item); @@ -860,8 +852,6 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } selection->addList(new_select); - new_select.clear(); - items.clear(); DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP, _("Ungroup")); @@ -886,7 +876,6 @@ sp_degroup_list(std::vector<SPItem*> &items) members.clear(); } } - items.clear(); if (has_groups) { // recurse if we unwrapped a group - it may have contained others out = sp_degroup_list(out); @@ -903,13 +892,13 @@ sp_item_list_common_parent_group(std::vector<SPItem*> const items) if (items.empty()) { return NULL; } - SPObject *parent = SP_OBJECT(items.front())->parent; + SPObject *parent = SP_OBJECT(items[0])->parent; // Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor if (!dynamic_cast<SPGroup *>(parent)) { return NULL; } for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();item++) { - if((*item)==items.front())continue; + if((*item)==items[0])continue; if (SP_OBJECT(*item)->parent != parent) { return NULL; } @@ -992,10 +981,7 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) } } } - } else { - rev.clear(); } - DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, //TRANSLATORS: "Raise" means "to raise an object" in the undo history C_("Undo action", "Raise")); @@ -1078,8 +1064,6 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) } } } - } else { - rev.clear(); } DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, @@ -1261,7 +1245,7 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop) } std::vector<SPItem*> list=selection->itemList(); for ( std::vector<SPItem*>::const_iterator itemlist=list.begin();itemlist!=list.end();itemlist++) { - SPItem *item = reinterpret_cast<SPItem*>(*itemlist); + SPItem *item = *itemlist; sp_selection_remove_livepatheffect_impl(item); @@ -1318,7 +1302,7 @@ void sp_selection_paste_size_separately(SPDesktop *desktop, bool apply_x, bool a void sp_selection_change_layer_maintain_clones(std::vector<SPItem*> const &items,SPObject *where) { for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) { - SPItem *item = dynamic_cast<SPItem *>(SP_OBJECT(*i)); + SPItem *item = *i; if (item) { SPItem *oldparent = dynamic_cast<SPItem *>(item->parent); SPItem *newparent = dynamic_cast<SPItem *>(where); @@ -1346,7 +1330,7 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); if (next) { sp_selection_change_layer_maintain_clones(items,next); - std::vector<SPItem*> temp_clip; + std::vector<Inkscape::XML::Node*> temp_clip; sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); sp_selection_delete_impl(items, false, false); next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers @@ -1358,8 +1342,6 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) no_more = true; } selection->setReprList(copied); - copied.clear(); - if (!temp_clip.empty()) temp_clip.clear(); if (next) dt->setCurrentLayer(next); if ( !suppressDone ) { DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT, @@ -1373,7 +1355,6 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers above.")); } - items.clear(); } void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) @@ -1392,7 +1373,7 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); if (next) { sp_selection_change_layer_maintain_clones(items,next); - std::vector<SPItem*> temp_clip; + std::vector<Inkscape::XML::Node*> temp_clip; sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs sp_selection_delete_impl(items, false, false); next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers @@ -1404,8 +1385,6 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) no_more = true; } selection->setReprList( copied); - copied.clear(); - if (!temp_clip.empty()) temp_clip.clear(); if (next) dt->setCurrentLayer(next); if ( !suppressDone ) { DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV, @@ -1434,7 +1413,7 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) if (moveto) { sp_selection_change_layer_maintain_clones(items,moveto); - std::vector<SPItem*> temp_clip; + std::vector<Inkscape::XML::Node*> temp_clip; sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs sp_selection_delete_impl(items, false, false); std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip); @@ -1483,7 +1462,7 @@ selection_contains_both_clone_and_original(Inkscape::Selection *selection) bool clone_with_original = false; std::vector<SPItem*> items = selection->itemList(); for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) { - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*l)); + SPItem *item = *l; if (item) { clone_with_original |= selection_contains_original(item, selection); if (clone_with_original) @@ -1528,7 +1507,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons } std::vector<SPItem*> items = selection->itemList(); for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) { - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*l)); + SPItem *item = *l; if( dynamic_cast<SPRoot *>(item) ) { // An SVG element cannot have a transform. We could change 'x' and 'y' in response @@ -1800,7 +1779,7 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) std::vector<SPItem*> items = selection->itemList(); 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++) { - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*l)); + SPItem *item = *l; if (item) { sp_item_rotate_rel(item, rot_90); } else { @@ -1863,7 +1842,7 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea Inkscape::Selection *selection = desktop->getSelection(); std::vector<SPItem*> items = selection->itemList(); for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { - SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(*sel_iter)); + SPItem *sel = *sel_iter; std::vector<SPItem*> matches = all_list; if (fill && stroke && style) { matches = sp_get_same_style(sel, matches); @@ -1911,7 +1890,7 @@ void sp_select_same_object_type(SPDesktop *desktop) std::vector<SPItem*> items=selection->itemList(); for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { - SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(*sel_iter)); + SPItem *sel = *sel_iter; if (sel) { matches = sp_get_same_object_type(sel, matches); } else { @@ -1938,7 +1917,7 @@ std::vector<SPItem*> sp_get_same_fill_or_stroke_color(SPItem *sel, std::vector<S SPIPaint *sel_paint = (type == SP_FILL_COLOR) ? &(sel->style->fill) : &(sel->style->stroke); for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { - SPItem *iter = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); + SPItem *iter = *i; if (iter) { SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke); match = false; @@ -2033,7 +2012,7 @@ std::vector<SPItem*> sp_get_same_object_type(SPItem *sel, std::vector<SPItem*> & std::vector<SPItem*> matches; for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); + SPItem *item = *i; if (item && item_type_match(sel, item) && !item->cloned) { matches.push_back(item); } @@ -2091,7 +2070,6 @@ std::vector<SPItem*> sp_get_same_style(SPItem *sel, std::vector<SPItem*> &src, S if (sel_style_for_width) { match = (sel_style_for_width->stroke_width.computed == tmp_style.stroke_width.computed); } - objects.clear(); } } match_g = match_g && match; @@ -2579,7 +2557,7 @@ void sp_selection_clone(SPDesktop *desktop) std::vector<Inkscape::XML::Node*> newsel; - for(std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ + for(std::vector<Inkscape::XML::Node*>::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){ Inkscape::XML::Node *sel_repr = *i; Inkscape::XML::Node *parent = sel_repr->parent(); @@ -2631,7 +2609,7 @@ sp_selection_relink(SPDesktop *desktop) bool relinked = false; std::vector<SPItem*> items=selection->itemList(); for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = static_cast<SPItem *>(*i); + SPItem *item = *i; if (dynamic_cast<SPUse *>(item)) { item->getRepr()->setAttribute("xlink:href", newref); @@ -2669,7 +2647,7 @@ sp_selection_unlink(SPDesktop *desktop) bool unlinked = false; std::vector<SPItem*> items=selection->itemList(); for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ - SPItem *item = static_cast<SPItem *>(*i); + SPItem *item = *i; if (dynamic_cast<SPText *>(item)) { SPObject *tspan = sp_tref_convert_to_tspan(item); @@ -2922,7 +2900,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? // bottommost object, after sorting - SPObject *parent = SP_OBJECT(items.front())->parent; + SPObject *parent = SP_OBJECT(items[0])->parent; Geom::Affine parent_transform; { @@ -2976,7 +2954,7 @@ static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) { if (group && !dynamic_cast<SPBox3D *>(item) && !wholegroups) { std::vector<SPItem*> items=sp_item_group_item_list(group); for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ - sp_selection_to_guides_recursive(static_cast<SPItem*>(*i), wholegroups); + sp_selection_to_guides_recursive(*i, wholegroups); } } else { item->convert_to_guides(); @@ -3007,7 +2985,7 @@ void sp_selection_to_guides(SPDesktop *desktop) // Therefore: first convert all, then delete all. for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ - sp_selection_to_guides_recursive(static_cast<SPItem*>(*i), wholegroups); + sp_selection_to_guides_recursive(*i, wholegroups); } if (deleteitems) { @@ -3060,7 +3038,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) std::vector<SPObject*> items(selection->list()); // Keep track of parent, this is where <use> will be inserted. - Inkscape::XML::Node *the_first_repr = reinterpret_cast<SPObject *>( items.front() )->getRepr(); + Inkscape::XML::Node *the_first_repr = items[0]->getRepr(); Inkscape::XML::Node *the_parent_repr = the_first_repr->parent(); // Find out if we have a single group @@ -3068,7 +3046,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) SPGroup *the_group = NULL; Geom::Affine transform; if( items.size() == 1 ) { - SPObject *object = reinterpret_cast<SPObject *>( items.front() ); + SPObject *object = items[0]; the_group = dynamic_cast<SPGroup *>(object); if ( the_group ) { single_group = true; @@ -3125,7 +3103,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) // Move selected items to new <symbol> for (std::vector<SPObject*>::const_iterator i=items.begin();i!=items.end();i++){ - Inkscape::XML::Node *repr = SP_OBJECT(*i)->getRepr(); + Inkscape::XML::Node *repr = (*i)->getRepr(); repr->parent()->removeChild(repr); symbol_repr->addChild(repr,NULL); } @@ -3197,7 +3175,7 @@ void sp_selection_unsymbol(SPDesktop *desktop) // In converting a symbol back to a group we strip out the inserted group (or any other // group that only adds a transform to the symbol content). if( children.size() == 1 ) { - SPObject *object = reinterpret_cast<SPObject *>( children.front() ); + SPObject *object = children[0]; if ( dynamic_cast<SPGroup *>( object ) ) { if( object->getAttribute("style") == NULL || object->getAttribute("class") == NULL ) { @@ -3209,7 +3187,7 @@ void sp_selection_unsymbol(SPDesktop *desktop) } for (std::vector<SPObject*>::const_iterator i=children.begin();i!=children.end();i++){ - Inkscape::XML::Node *repr = SP_OBJECT(*i)->getRepr(); + Inkscape::XML::Node *repr = (*i)->getRepr(); repr->parent()->removeChild(repr); group->addChild(repr,NULL); } @@ -3274,7 +3252,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) sort(items.begin(),items.end(),sp_object_compare_position); // bottommost object, after sorting - SPObject *parent = SP_OBJECT(items.front())->parent; + SPObject *parent = SP_OBJECT(items[0])->parent; Geom::Affine parent_transform; @@ -3288,7 +3266,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) } // remember the position of the first item - gint pos = SP_OBJECT(items.front())->getRepr()->position(); + gint pos = SP_OBJECT(items[0])->getRepr()->position(); // create a list of duplicates std::vector<Inkscape::XML::Node*> repr_copies; @@ -3446,7 +3424,7 @@ void sp_selection_get_export_hints(Inkscape::Selection *selection, Glib::ustring for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();i++){ gchar const *dpi_string; - Inkscape::XML::Node * repr = (*i); + Inkscape::XML::Node *repr = *i; if (filename_search) { const gchar* tmp = repr->attribute("inkscape:export-filename"); @@ -3546,7 +3524,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) // Create the filename. gchar *const basename = g_strdup_printf("%s-%s-%u.png", document->getName(), - SP_OBJECT(items.front())->getRepr()->attribute("id"), + SP_OBJECT(items[0])->getRepr()->attribute("id"), current); // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters, // digits, and a few other chars, with "_" @@ -3755,7 +3733,7 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) Inkscape::GC::release(spnew); topmost --; // only reduce count for those items deleted from topmost_parent } else { // move it to topmost_parent first - std::vector<SPItem*> temp_clip; + std::vector<Inkscape::XML::Node*> temp_clip; // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform @@ -3896,7 +3874,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ } } else if (!topmost) { // topmost item is used as a mask, which is applied to other items in a selection - Inkscape::XML::Node *dup = SP_OBJECT(items.front())->getRepr()->duplicate(xml_doc); + Inkscape::XML::Node *dup = SP_OBJECT(items[0])->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); if (remove_original) { @@ -4060,7 +4038,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ if (remove_original) { // remember referenced mask/clippath, so orphaned masks can be moved back to document - SPItem *item = reinterpret_cast<SPItem *>(*i); + SPItem *item = *i; Inkscape::URIReference *uri_ref = NULL; if (apply_clip_path) { diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index ce0b5d3da..8bcab664b 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -19,7 +19,6 @@ #include <2geom/forward.h> #include "sp-item.h" -#include "selection.h" class SPCSSAttr; class SPDesktop; diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index d86cfa700..441ce6ea6 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -47,7 +47,7 @@ char* collect_terms (const std::vector<SPItem*> &items) bool first = true; for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(*iter)); + SPItem *item = *iter; if (item) { const char *term = item->displayName(); if (term != NULL && g_slist_find (check, term) == NULL) { @@ -66,7 +66,7 @@ static int count_terms (const std::vector<SPItem*> &items) GSList *check = NULL; int count=0; for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(*iter)); + SPItem *item = *iter; if (item) { const char *term = item->displayName(); if (term != NULL && g_slist_find (check, term) == NULL) { @@ -83,7 +83,7 @@ static int count_filtered (const std::vector<SPItem*> &items) { int count=0; for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>((*iter))); + SPItem *item = *iter; if (item) { count += item->isFiltered(); } @@ -127,7 +127,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select if (items.empty()) { // no items _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); } else { - SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(items.front())); + SPItem *item = items[0]; g_assert(item != NULL); SPObject *layer = selection->layers()->layerForObject(item); SPObject *root = selection->layers()->currentRoot(); diff --git a/src/selection.cpp b/src/selection.cpp index fd3b6abae..19e78512b 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -130,7 +130,7 @@ void Selection::_invalidateCachedLists() { void Selection::_clear() { _invalidateCachedLists(); while (!_objs.empty()) { - SPObject *obj=reinterpret_cast<SPObject *>(_objs.front()); + SPObject *obj=_objs.front(); _remove(obj); } } @@ -254,7 +254,7 @@ void Selection::addList(std::vector<SPItem*> const &list) { _invalidateCachedLists(); for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end();iter++ ) { - SPObject *obj = reinterpret_cast<SPObject *>(*iter); + SPObject *obj = *iter; if (includes(obj)) continue; _add (obj); } @@ -297,7 +297,7 @@ std::vector<SPItem*> const &Selection::itemList() { } for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { - SPObject *obj=reinterpret_cast<SPObject *>(*iter); + SPObject *obj=*iter; if (SP_IS_ITEM(obj)) { _items.push_back(SP_ITEM(obj)); } @@ -342,7 +342,7 @@ std::list<SPBox3D *> const Selection::box3DList(Persp3D *persp) { SPObject *Selection::single() { if ( _objs.size() == 1 ) { - return reinterpret_cast<SPObject *>(_objs.front()); + return _objs.front(); } else { return NULL; } @@ -351,7 +351,7 @@ SPObject *Selection::single() { SPItem *Selection::singleItem() { std::vector<SPItem*> const items=itemList(); if ( items.size()==1) { - return reinterpret_cast<SPItem *>(items.front()); + return items[0]; } else { return NULL; } @@ -447,7 +447,7 @@ Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const boost::optional<Geom::Point> Selection::center() const { std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); if (!items.empty()) { - SPItem *first = reinterpret_cast<SPItem*>(items.back()); // from the first item in selection + SPItem *first = items.back(); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly return first->getCenter(); } @@ -467,7 +467,7 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferenc snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center std::vector<Inkscape::SnapCandidatePoint> p; for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *this_item = SP_ITEM(*iter); + SPItem *this_item = *iter; this_item->getSnappoints(p, &snapprefs_dummy); //Include the transformation origin for snapping @@ -482,7 +482,7 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferenc void Selection::_removeObjectDescendants(SPObject *obj) { for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { - SPObject *sel_obj=reinterpret_cast<SPObject *>(*iter); + SPObject *sel_obj= *iter; SPObject *parent = sel_obj->parent; while (parent) { if ( parent == obj ) { diff --git a/src/selection.h b/src/selection.h index 71be6dd6b..9eada3eed 100644 --- a/src/selection.h +++ b/src/selection.h @@ -40,14 +40,6 @@ class Node; } } -/*template<typename T> -const GSList* std_list_to_GS_list(const std::list<T *> list) const -{ - gpointer l=NULL; - for(auto x:list){ - - } -}*/ namespace Inkscape { diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 0a428edf2..61d8a1ab1 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -434,8 +434,7 @@ void Inkscape::SelTrans::ungrab() for (int i = 0; i < 4; i++) sp_canvas_item_hide(_l[i]); } - - if (!_stamp_cache.empty()) { + if(!_stamp_cache.empty()){ _stamp_cache.clear(); } @@ -494,7 +493,7 @@ void Inkscape::SelTrans::ungrab() // we were dragging center; update reprs and commit undoable action std::vector<SPItem*> items=_desktop->selection->itemList(); for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *it = SP_ITEM(*iter); + SPItem *it = *iter; it->updateRepr(); } DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, @@ -535,7 +534,7 @@ void Inkscape::SelTrans::stamp() } for(std::vector<SPItem*>::const_iterator x=l.begin();x!=l.end();x++) { - SPItem *original_item = SP_ITEM(*x); + SPItem *original_item = *x; Inkscape::XML::Node *original_repr = original_item->getRepr(); // remember the position of the item @@ -713,7 +712,7 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa // Unset the center position for all selected items std::vector<SPItem*> items=_desktop->selection->itemList(); for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *it = SP_ITEM(*iter); + SPItem *it = *iter; it->unsetCenter(); it->updateRepr(); _center_is_set = false; // center has changed diff --git a/src/snap.cpp b/src/snap.cpp index c711874d7..31cafafcd 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1055,7 +1055,7 @@ void SnapManager::setupIgnoreSelection(SPDesktop const *desktop, Inkscape::Selection *sel = _desktop->selection; std::vector<SPItem*> const items = sel->itemList(); for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { - _items_to_ignore.push_back(static_cast<SPItem const *>(*i)); + _items_to_ignore.push_back(*i); } } diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index d09699f41..1e478d1c9 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -52,7 +52,7 @@ static bool try_get_intersect_point_with_item_recursive(Geom::PathVector& conn_p double child_pos = 0.0; std::vector<SPItem*> g = sp_item_group_item_list(group); for (std::vector<SPItem*>::const_iterator i = g.begin();i!=g.end();i++) { - SPItem* child_item = SP_ITEM(*i); + SPItem* child_item = *i; try_get_intersect_point_with_item_recursive(conn_pv, child_item, item_transform * child_item->transform, child_pos); if (intersect_pos < child_pos) diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index 76843fd28..74d29a05c 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -48,7 +48,7 @@ void SPDefs::update(SPCtx *ctx, guint flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; std::vector<SPObject*> l(this->childList(true)); for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *child = SP_OBJECT(*i); + SPObject *child = *i; if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->updateDisplay(ctx, flags); } diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 93a979287..5386a4373 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -246,7 +246,7 @@ void SPFilter::update(SPCtx *ctx, guint flags) { childflags &= SP_OBJECT_MODIFIED_CASCADE; std::vector<SPObject*> l(this->childList(true, SPObject::ActionUpdate)); for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *child = SP_OBJECT (*i); + SPObject *child = *i; if( SP_IS_FILTER_PRIMITIVE( child ) ) { child->updateDisplay(ctx, childflags); } diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index d58676235..620c0b70f 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -173,7 +173,7 @@ void SPGroup::update(SPCtx *ctx, unsigned int flags) { childflags &= SP_OBJECT_MODIFIED_CASCADE; std::vector<SPObject*> l=this->childList(true, SPObject::ActionUpdate); for(std::vector<SPObject*> ::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *child = SP_OBJECT (*i); + SPObject *child = *i; if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { SPItem *item = dynamic_cast<SPItem *>(child); @@ -217,7 +217,7 @@ void SPGroup::modified(guint flags) { std::vector<SPObject*> l=this->childList(true); for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *child = SP_OBJECT (*i); + SPObject *child = *i; if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); @@ -289,9 +289,9 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox Geom::OptRect bbox; // TODO CPPIFY: replace this const_cast later - std::vector<SPObject*> l=const_cast<SPGroup*>(this)->childList(false, SPObject::ActionBBox); + std::vector<SPObject*> l = const_cast<SPGroup*>(this)->childList(false, SPObject::ActionBBox); for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *o = SP_OBJECT (*i); + SPObject *o = *i; SPItem *item = dynamic_cast<SPItem *>(o); if (item && !item->isHidden()) { Geom::Affine const ct(item->transform * transform); @@ -305,7 +305,7 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox void SPGroup::print(SPPrintContext *ctx) { std::vector<SPObject*> l=this->childList(false); for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *o = SP_OBJECT (*i); + SPObject *o = *i; SPItem *item = dynamic_cast<SPItem *>(o); if (item) { item->invoke_print(ctx); @@ -359,7 +359,7 @@ Inkscape::DrawingItem *SPGroup::show (Inkscape::Drawing &drawing, unsigned int k void SPGroup::hide (unsigned int key) { std::vector<SPObject*> l=this->childList(false, SPObject::ActionShow); for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *o = SP_OBJECT (*i); + SPObject *o = *i; SPItem *item = dynamic_cast<SPItem *>(o); if (item) { @@ -799,7 +799,7 @@ void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem * Inkscape::DrawingItem *ac = NULL; std::vector<SPObject*> l=this->childList(false, SPObject::ActionShow); for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *o = SP_OBJECT (*i); + SPObject *o = *i; SPItem * child = dynamic_cast<SPItem *>(o); if (child) { ac = child->invoke_show (drawing, key, flags); diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 2258c2133..fc0b6382f 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -15,7 +15,6 @@ #include <map> #include "sp-lpe-item.h" -#include "selection.h"//SelContainer #define SP_GROUP(obj) (dynamic_cast<SPGroup*>((SPObject*)obj)) #define SP_IS_GROUP(obj) (dynamic_cast<const SPGroup*>((SPObject*)obj) != NULL) diff --git a/src/sp-marker.cpp b/src/sp-marker.cpp index 5bb80bd39..9618c5484 100644 --- a/src/sp-marker.cpp +++ b/src/sp-marker.cpp @@ -453,7 +453,7 @@ const gchar *generate_marker(std::vector<Inkscape::XML::Node*> &reprs, Geom::Rec SPObject *mark_object = document->getObjectById(mark_id); for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ - Inkscape::XML::Node *node = (*i); + Inkscape::XML::Node *node = *i; SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node)); Geom::Affine dup_transform; diff --git a/src/sp-object.h b/src/sp-object.h index 8651258bd..df773fea7 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -47,8 +47,6 @@ class SPObject; #define SP_OBJECT_WRITE_ALL (1 << 2) #define SP_OBJECT_WRITE_NO_CHILDREN (1 << 3) - - #include <cassert> #include <stddef.h> #include <sigc++/connection.h> @@ -64,8 +62,6 @@ class SPCSSAttr; class SPStyle; typedef struct _GSList GSList; - - namespace Inkscape { namespace XML { class Node; diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 33d66c5dc..b3aeec7bd 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -427,7 +427,7 @@ const gchar *pattern_tile(const std::vector<Inkscape::XML::Node*> &reprs, Geom:: SPObject *pat_object = document->getObjectById(pat_id); for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ - Inkscape::XML::Node *node = (Inkscape::XML::Node *)(*i); + Inkscape::XML::Node *node = *i; SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); Geom::Affine dup_transform; diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index 2c9427df8..f252438a4 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -112,7 +112,7 @@ void SPSwitch::_reevaluate(bool /*add_to_drawing*/) { std::vector<SPObject*> item_list = _childList(false, SPObject::ActionShow); for ( std::vector<SPObject*>::const_reverse_iterator iter=item_list.rbegin();iter!=item_list.rend();iter++) { - SPObject *o = SP_OBJECT (*iter); + SPObject *o = *iter; if ( !SP_IS_ITEM (o) ) { continue; } @@ -147,7 +147,7 @@ void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem std::vector<SPObject*> l = this->_childList(false, SPObject::ActionShow); for ( std::vector<SPObject*>::const_reverse_iterator iter=l.rbegin();iter!=l.rend();iter++) { - SPObject *o = SP_OBJECT (*iter); + SPObject *o = *iter; if (SP_IS_ITEM (o)) { SPItem * child = SP_ITEM(o); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 6e47dfff3..bc09802f0 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -60,11 +60,6 @@ using Inkscape::DocumentUndo; bool Ancetre(Inkscape::XML::Node *a, Inkscape::XML::Node *who); -//SHOULD DISAPPEAR -bool sp_repr_compare_position_obj(SPObject* &a,SPObject* &b){ - return sp_repr_compare_position(dynamic_cast<Inkscape::XML::Node*>(a),dynamic_cast<Inkscape::XML::Node*>(b)); -} - void sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb=SP_VERB_NONE, const Glib::ustring description=""); void sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset); void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updating); @@ -405,7 +400,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // otherwise bail out for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++) { - SPItem *item = SP_ITEM(*l); + SPItem *item = *l; if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item) && !SP_IS_FLOWTEXT(item)) { boolop_display_error_message(desktop, _("One of the objects is <b>not a path</b>, cannot perform boolean operation.")); @@ -428,7 +423,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool SP_LPE_ITEM(*l)->removeAllPathEffects(true); } - SPCSSAttr *css = sp_repr_css_attr(reinterpret_cast<SPObject *>(il.front())->getRepr(), "style"); + SPCSSAttr *css = sp_repr_css_attr(reinterpret_cast<SPObject *>(il[0])->getRepr(), "style"); gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); if (val && strcmp(val, "nonzero") == 0) { origWind[curOrig]= fill_nonZero; @@ -438,7 +433,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool origWind[curOrig]= fill_nonZero; } - originaux[curOrig] = Path_for_item((SPItem *) (*l), true, true); + originaux[curOrig] = Path_for_item(*l, true, true); if (originaux[curOrig] == NULL || originaux[curOrig]->descr_cmd.size() <= 1) { for (int i = curOrig; i >= 0; i--) delete originaux[i]; @@ -475,7 +470,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool curOrig = 1; for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ - if(*l==il.front())continue; + if(*l==il[0])continue; originaux[curOrig]->ConvertWithBackData(0.1); originaux[curOrig]->Fill(theShape, curOrig); @@ -685,7 +680,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool SPObject *source; if ( bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice ) { if (reverseOrderForOp) { - source = SP_OBJECT(il.front()); + source = SP_OBJECT(il[0]); } else { source = SP_OBJECT(il.back()); } @@ -1159,7 +1154,7 @@ sp_selected_path_outline(SPDesktop *desktop) bool did = false; std::vector<SPItem*> il(selection->itemList()); for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ - SPItem *item = SP_ITEM(*l); + SPItem *item = *l; if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) continue; @@ -1771,7 +1766,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) bool did = false; std::vector<SPItem*> il(selection->itemList()); for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ - SPItem *item = SP_ITEM(*l); + SPItem *item = *l; SPCurve *curve = NULL; if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) @@ -2143,7 +2138,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, desktop->setWaitingCursor(); for (std::vector<SPItem*>::const_iterator l = items.begin(); l != items.end(); l++){ - SPItem *item = SP_ITEM(*l); + SPItem *item = *l; if (!(SP_IS_GROUP(item) || SP_IS_SHAPE(item) || SP_IS_TEXT(item))) continue; diff --git a/src/splivarot.h b/src/splivarot.h index 79b9b98a6..ba314399f 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -10,7 +10,6 @@ #include <2geom/forward.h> #include <2geom/path.h> #include "livarot/Path.h" -#include "sp-object.h"//kill it class SPCurve; class SPDesktop; @@ -19,7 +18,7 @@ class SPItem; namespace Inkscape { class Selection; } -bool sp_repr_compare_position_obj(SPObject* &a,SPObject* &b);//kill it with fire + // boolean operations // work on the current selection // selection has 2 contain exactly 2 items diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 33192a330..eadab90dd 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -46,7 +46,7 @@ flowtext_in_selection(Inkscape::Selection *selection) std::vector<SPItem*> items = selection->itemList(); for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_FLOWTEXT(*i)) - return ((SPItem *) *i); + return *i; } return NULL; } @@ -57,7 +57,7 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection) std::vector<SPItem*> items = selection->itemList(); for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) - return ((SPItem *) *i); + return *i; } return NULL; } @@ -68,7 +68,7 @@ shape_in_selection(Inkscape::Selection *selection) std::vector<SPItem*> items = selection->itemList(); for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_SHAPE(*i)) - return ((SPItem *) *i); + return *i; } return NULL; } @@ -402,7 +402,7 @@ text_unflow () continue; } - SPItem *flowtext = SP_ITEM(*i); + SPItem *flowtext = *i; // we discard transform when unflowing, but we must preserve expansion which is visible as // font size multiplier @@ -482,7 +482,7 @@ flowtext_to_text() std::vector<SPItem*> items(selection->itemList()); for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = (SPItem *) *i; + SPItem *item = *i; if (!SP_IS_FLOWTEXT(item)) continue; diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 88210dc0b..050e223eb 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -69,7 +69,7 @@ void te_update_layout_now_recursive(SPItem *item) if (SP_IS_GROUP(item)) { std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); for(std::vector<SPItem*>::const_iterator i=item_list.begin();i!=item_list.end();i++){ - SPItem* list_item = static_cast<SPItem*>(*i); + SPItem* list_item = *i; te_update_layout_now_recursive(list_item); } } else if (SP_IS_TEXT(item)) diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 4853f127c..91c230920 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -80,7 +80,7 @@ SPImage *Tracer::getSelectedSPImage() { continue; } - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; items.insert(items.begin(), item); } std::vector<SPItem *>::iterator iter; diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 52bc24f5f..a38a52371 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -525,7 +525,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a if (separately) { std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (item) { Geom::OptRect obj_size = item->desktopVisualBounds(); if ( obj_size ) { @@ -581,7 +581,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) sp_selected_to_lpeitems(desktop); std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; _applyPathEffect(item, effectstack); } @@ -664,7 +664,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) // copy the defs used by all items std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (item) { _copyUsedDefs(item); } else { @@ -677,7 +677,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position); for(std::vector<SPItem*>::const_iterator i=sorted_items.begin();i!=sorted_items.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (item) { Inkscape::XML::Node *obj = item->getRepr(); Inkscape::XML::Node *obj_copy = _copyNode(obj, _doc, _root); @@ -706,7 +706,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) // copy style for Paste Style action if (!sorted_items.empty()) { - SPObject *object = static_cast<SPObject *>(sorted_items.front()); + SPObject *object = static_cast<SPObject *>(sorted_items[0]); SPItem *item = dynamic_cast<SPItem *>(object); if (item) { SPCSSAttr *style = take_style_from_item(item); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 34dbd150b..1ee72dcbc 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -151,7 +151,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) for (std::vector<SPItem*>::iterator it(selected.begin()); it != selected.end(); ++it) { - SPItem* item=static_cast<SPItem*> (*it); + SPItem* item= *it; desktop->getDocument()->ensureUpToDate(); if (!sel_as_group) b = (item)->desktopPreferredBounds(); @@ -264,8 +264,8 @@ private : std::vector< BBoxSort > sorted; for (std::vector<SPItem*>::iterator it(selected.begin()); it != selected.end(); - ++it) - {SPItem *item=static_cast<SPItem*>(*it); + ++it){ + SPItem *item = *it; Geom::OptRect bbox = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds(); if (bbox) { sorted.push_back(BBoxSort(item, *bbox, _orientation, _kBegin, _kEnd)); @@ -570,19 +570,19 @@ private : sort(selected.begin(),selected.end(),sort_compare); } std::vector<SPItem*>::iterator it(selected.begin()); - SPItem* item=static_cast<SPItem*>(*it); - Geom::Point p1 = (item)->getCenter(); + SPItem* item = *it; + Geom::Point p1 = item->getCenter(); for (++it ;it != selected.end(); ++it) { - item=static_cast<SPItem*>(*it); - Geom::Point p2 = (item)->getCenter(); + item = *it; + Geom::Point p2 = item->getCenter(); Geom::Point delta = p1 - p2; - sp_item_move_rel((item),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); + sp_item_move_rel(item,Geom::Translate(delta[Geom::X],delta[Geom::Y] )); p1 = p2; } - Geom::Point p2 = static_cast<SPItem*>(selected.front())->getCenter(); + Geom::Point p2 = selected.front()->getCenter(); Geom::Point delta = p1 - p2; - sp_item_move_rel(static_cast<SPItem*>(selected.front()),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); + sp_item_move_rel(selected.front(),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -675,7 +675,7 @@ private : it != selected.end(); ++it) { - SPItem* item=static_cast<SPItem*>(*it); + SPItem* item = *it; desktop->getDocument()->ensureUpToDate(); Geom::OptRect item_box = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds(); if (item_box) { @@ -761,7 +761,7 @@ private : it != selected.end(); ++it) { - SPItem* item=static_cast<SPItem*>(*it); + SPItem* item = *it; if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { Inkscape::Text::Layout const *layout = te_get_layout(item); boost::optional<Geom::Point> pt = layout->baselineAnchorPoint(); @@ -805,7 +805,7 @@ private : it != selected.end(); ++it) { - SPItem* item=static_cast<SPItem*>(*it); + SPItem* item = *it; if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { Inkscape::Text::Layout const *layout = te_get_layout(item); boost::optional<Geom::Point> pt = layout->baselineAnchorPoint(); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 32eed088c..ca3971019 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -819,7 +819,7 @@ void Export::onAreaToggled () const gchar * id = "object"; const std::vector<XML::Node*> reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); for(std::vector<XML::Node*>::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { - Inkscape::XML::Node * repr = (*i); + Inkscape::XML::Node * repr = *i; if (repr->attribute("id")) { id = repr->attribute("id"); break; @@ -1026,7 +1026,7 @@ void Export::onExport () std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); for(std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ - SPItem *item = reinterpret_cast<SPItem *>(*i); + SPItem *item = *i; prog_dlg->set_data("current", GINT_TO_POINTER(n)); prog_dlg->set_data("total", GINT_TO_POINTER(num)); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index a6312140d..45c8ce68a 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -690,7 +690,7 @@ private: void select_svg_element(){ Inkscape::Selection* sel = _desktop->getSelection(); if (sel->isEmpty()) return; - Inkscape::XML::Node* node = sel->reprList().front(); + Inkscape::XML::Node* node = sel->reprList()[0]; if (!node || !node->matchAttributeName("id")) return; std::ostringstream xlikhref; @@ -1547,7 +1547,7 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri std::vector<SPItem*> itemlist=sel->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { - SPItem * item = SP_ITEM(*i); + SPItem * item = *i; SPStyle *style = item->style; g_assert(style != NULL); @@ -1655,7 +1655,7 @@ void FilterEffectsDialog::FilterModifier::remove_filter() if (!SP_IS_ITEM(*i)) { continue; } - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (!item->style) { continue; } diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 283d79c0d..dde040036 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -857,7 +857,7 @@ void Find::onAction() Inkscape::Selection *selection = desktop->getSelection(); selection->clear(); selection->setList(n); - SPObject *obj = reinterpret_cast<SPObject *>(n.front()); + SPObject *obj = reinterpret_cast<SPObject *>(n[0]); SPItem *item = dynamic_cast<SPItem *>(obj); g_assert(item != NULL); scroll_to_show_item(desktop, item); diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h index 61f4463ae..4bcb900b6 100644 --- a/src/ui/dialog/find.h +++ b/src/ui/dialog/find.h @@ -16,7 +16,6 @@ # include <config.h> #endif -#include "selection.h" #include "ui/widget/panel.h" #include "ui/widget/button.h" #include "ui/widget/entry.h" diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index e9a0fc017..1be87d180 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -159,7 +159,7 @@ std::vector<SPItem*> FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli allList = get_all_items(x, doc->getRoot(), desktop, false, false, true, y); for(std::vector<SPItem*>::const_iterator i = allList.begin();i!=allList.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPStyle *style = item->style; Glib::ustring family = ""; diff --git a/src/ui/dialog/font-substitution.h b/src/ui/dialog/font-substitution.h index cdb4e22b4..0818d778c 100644 --- a/src/ui/dialog/font-substitution.h +++ b/src/ui/dialog/font-substitution.h @@ -13,7 +13,8 @@ #define INKSCAPE_UI_FONT_SUBSTITUTION_H #include <glibmm/ustring.h> -#include "selection.h" + +class SPItem; class SPDocument; namespace Inkscape { diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index fa469dc4b..7ca277ea2 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -581,7 +581,7 @@ void GlyphsPanel::insertText() std::vector<SPItem*> itemlist=targetDesktop->selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { - textItem = SP_ITEM(*i); + textItem = *i; break; } } diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 10498b0f9..8bd130c2e 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -172,7 +172,7 @@ void GridArrangeTab::arrange() const std::vector<SPItem*> items = selection ? selection->itemList() : std::vector<SPItem*>(); cnt=0; for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; Geom::OptRect b = item->documentVisualBounds(); if (!b) { continue; diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 6ad3d61ac..e9ee7802d 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -368,7 +368,7 @@ void IconPreviewPanel::refreshPreview() std::vector<SPItem*> const items = sel->itemList(); for(std::vector<SPItem*>::const_iterator i=items.begin();!target && i!=items.end();i++){ - SPItem* item = SP_ITEM( *i); + SPItem* item = *i; gchar const *id = item->getId(); if ( id ) { targetId = id; diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 6e09be2ba..781c6ef93 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -479,7 +479,7 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) { SPItem *item = NULL; std::vector<SPItem*> const items = sel->itemList(); for(std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end();i++){ - item = reinterpret_cast<SPItem *>(*i); + item = *i; if (setOpacity) { _setCompositingValues(item); diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index a68e73caf..af1386e27 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -308,7 +308,7 @@ void PolarArrangeTab::arrange() { if(arrangeOnEllipse) { - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if(arrangeOnFirstEllipse) { @@ -375,7 +375,7 @@ void PolarArrangeTab::arrange() int i = 0; for(std::vector<SPItem*>::const_iterator it=tmp.begin();it!=tmp.end();it++) { - SPItem *item = SP_ITEM(*it); + SPItem *item = *it; // Ignore the reference ellipse if any if(item != referenceEllipse) diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index b677711ff..5fab9fcfc 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -355,7 +355,7 @@ void TagsPanel::_objectsSelected( Selection *sel ) { std::vector<SPObject*> tmp=sel->list(); for(std::vector<SPObject*>::const_iterator i=tmp.begin();i!=tmp.end();i++) { - SPObject *obj = reinterpret_cast<SPObject *>(*i); + SPObject *obj = *i; _store->foreach(sigc::bind<SPObject *>( sigc::mem_fun(*this, &TagsPanel::_checkForSelected), obj)); } _selectedConnection.unblock(); diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 1c1cf5937..9c4790379 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -422,7 +422,7 @@ SPItem *TextEdit::getSelectedTextItem (void) for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) - return SP_ITEM (*i); + return *i; } return NULL; diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 0f81a7e58..459e6e937 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -655,7 +655,7 @@ void Transformation::updatePageTransform(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { if (_check_replace_matrix.get_active()) { - Geom::Affine current (SP_ITEM(selection->itemList().front())->transform); // take from the first item in selection + Geom::Affine current (selection->itemList()[0]->transform); // take from the first item in selection Geom::Affine new_displayed = current; @@ -750,8 +750,8 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - SPItem* item=static_cast<SPItem*>(*it); - Geom::OptRect bbox = (item)->desktopPreferredBounds(); + SPItem* item = *it; + Geom::OptRect bbox = item->desktopPreferredBounds(); if (bbox) { sorted.push_back(BBoxSort(item, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.)); } @@ -775,8 +775,8 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - SPItem* item=static_cast<SPItem*>(*it); - Geom::OptRect bbox = (item)->desktopPreferredBounds(); + SPItem* item = *it; + Geom::OptRect bbox = item->desktopPreferredBounds(); if (bbox) { sorted.push_back(BBoxSort(item, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.)); } @@ -818,7 +818,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) if (prefs->getBool("/dialogs/transformation/applyseparately")) { std::vector<SPItem*> tmp=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; Geom::OptRect bbox_pref = item->desktopPreferredBounds(); Geom::OptRect bbox_geom = item->desktopGeometricBounds(); if (bbox_pref && bbox_geom) { @@ -882,7 +882,7 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection) if (prefs->getBool("/dialogs/transformation/applyseparately")) { std::vector<SPItem*> tmp=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0)); } } else { @@ -902,7 +902,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) if (prefs->getBool("/dialogs/transformation/applyseparately")) { std::vector<SPItem*> items=selection->itemList(); for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (!_units_skew.isAbsolute()) { // percentage double skewX = _scalar_skew_horizontal.getValue("%"); @@ -1004,7 +1004,7 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) if (_check_replace_matrix.get_active()) { std::vector<SPItem*> tmp=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; item->set_item_transform(displayed); SP_OBJECT(item)->updateRepr(); } @@ -1155,7 +1155,7 @@ void Transformation::onReplaceMatrixToggled() double f = _scalar_transform_f.getValue(); Geom::Affine displayed (a, b, c, d, e, f); - Geom::Affine current = SP_ITEM(selection->itemList().front())->transform; // take from the first item in selection + Geom::Affine current = selection->itemList()[0]->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 193dff33c..760d19e89 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -2077,7 +2077,7 @@ void ContextMenu::ImageEdit(void) std::vector<SPItem*> itemlist=_desktop->selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - Inkscape::XML::Node *ir = SP_ITEM(*i)->getRepr(); + Inkscape::XML::Node *ir = (*i)->getRepr(); const gchar *href = ir->attribute("xlink:href"); if (strncmp (href,"file:",5) == 0) { diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 9c6eead16..f48e572df 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1318,7 +1318,7 @@ void cc_selection_set_avoid(bool const set_avoid) std::vector<SPItem*> l = selection->itemList(); for(std::vector<SPItem*>::const_iterator i=l.begin();i!=l.end();i++) { - SPItem *item = SP_ITEM(*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 b61a108f0..adbbb2bd3 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -692,8 +692,8 @@ void EraserTool::set_to_accumulated() { if ( !toWorkOn.empty() ) { if ( eraserMode ) { - for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - SPItem *item = SP_ITEM(*i); + for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); i++){ + SPItem *item = *i; if ( eraserMode ) { Geom::OptRect bbox = item->visualBounds(); @@ -712,7 +712,7 @@ void EraserTool::set_to_accumulated() { // If the item was not completely erased, track the new remainder. std::vector<SPItem*> nowSel(selection->itemList()); for (std::vector<SPItem*>::const_iterator i2 = nowSel.begin();i2!=nowSel.end();i2++) { - remainingItems.push_back(SP_ITEM(*i2)); + remainingItems.push_back(*i2); } } } else { @@ -722,11 +722,11 @@ void EraserTool::set_to_accumulated() { } } else { for (std::vector<SPItem*> ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - sp_object_ref( SP_ITEM(*i), 0 ); + sp_object_ref( *i, 0 ); } for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; item->deleteObject(true); sp_object_unref(item); workDone = true; diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 6f7b220ed..21ad18c26 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -506,7 +506,7 @@ bool GradientTool::root_handler(GdkEvent* event) { } else { std::vector<SPItem*> items=selection->itemList(); for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) { - SPItem *item = SP_ITEM(*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; @@ -890,12 +890,6 @@ bool GradientTool::root_handler(GdkEvent* event) { return ret; } -int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) -{ - return sp_repr_compare_position(((SPItem*)first)->getRepr(), - ((SPItem*)second)->getRepr())<0; -} - static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*state*/, guint32 etime) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; @@ -931,14 +925,14 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta //FIXME: see above sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); - sp_item_set_gradient(SP_ITEM(*i), vector, (SPGradientType) type, fill_or_stroke); + sp_item_set_gradient(*i, vector, (SPGradientType) type, fill_or_stroke); if (type == SP_GRADIENT_TYPE_LINEAR) { - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false); - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_END, 0, pt, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_LG_END, 0, pt, fill_or_stroke, true, false); } else if (type == SP_GRADIENT_TYPE_RADIAL) { - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_R1, 0, pt, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_RG_R1, 0, pt, fill_or_stroke, true, false); } SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -949,7 +943,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 (SP_ITEM(selection->itemList().front()), + ec->_grdrag->grabKnot (selection->itemList()[0], 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); diff --git a/src/ui/tools/gradient-tool.h b/src/ui/tools/gradient-tool.h index 786aed372..6fe3bca9f 100644 --- a/src/ui/tools/gradient-tool.h +++ b/src/ui/tools/gradient-tool.h @@ -18,7 +18,6 @@ #include <stddef.h> #include <sigc++/sigc++.h> #include "ui/tools/tool-base.h" -class SPObject;//kill it #define SP_GRADIENT_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::GradientTool*>((Inkscape::UI::Tools::ToolBase*)obj)) #define SP_IS_GRADIENT_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::GradientTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL) @@ -26,12 +25,12 @@ class SPObject;//kill it namespace Inkscape { namespace UI { namespace Tools { -int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second);//kill it class GradientTool : public ToolBase { public: GradientTool(); virtual ~GradientTool(); + Geom::Point origin; bool cursor_addnode; diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 2b44639c8..5295a16c0 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -444,7 +444,7 @@ bool MeasureTool::root_handler(GdkEvent* event) { std::vector<SPItem*> items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); std::vector<double> intersection_times; for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { - SPItem *item = static_cast<SPItem*>(*i); + SPItem *item = *i; if (SP_IS_SHAPE(item)) { calculate_intersections(desktop, item, lineseg, SP_SHAPE(item)->getCurve(), intersection_times); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 0a34e4855..c8e032089 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -48,7 +48,6 @@ // Mesh specific #include "ui/tools/mesh-tool.h" -#include "ui/tools/gradient-tool.h"//not needed #include "sp-mesh-gradient.h" #include "display/sp-ctrlcurve.h" @@ -478,12 +477,12 @@ 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, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); + sp_mesh_context_split_near_point(this, selection->itemList()[0], this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. std::vector<SPItem*> items=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = SP_ITEM(*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; @@ -932,12 +931,6 @@ bool MeshTool::root_handler(GdkEvent* event) { return ret; } -/* -int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) -{ - return sp_repr_compare_position(((SPItem*)first)->getRepr(), - ((SPItem*)second)->getRepr())<0; -}*/ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/, guint32 /*etime*/) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 25cbf76a4..fbc1a9e6c 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -481,7 +481,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_2BUTTON_PRESS: if (event->button.button == 1) { if (!selection->isEmpty()) { - SPItem *clicked_item = static_cast<SPItem *>(selection->itemList().front()); + SPItem *clicked_item = selection->itemList()[0]; 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 ac41f3a34..d92d326e0 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -553,13 +553,13 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point std::vector<SPItem*> const items(selection->itemList()); for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); + SPItem *item = *i; g_assert(item != NULL); sp_object_ref(item); } for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); + SPItem *item = *i; g_assert(item != NULL); if (is_transform_modes(tc->mode)) { @@ -574,7 +574,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point } for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); + SPItem *item = *i; g_assert(item != NULL); sp_object_unref(item); } diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 6f7764506..8c5e4215e 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -1089,7 +1089,7 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point std::vector<SPItem*> items=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); + SPItem *item = *i; if (is_color_mode (tc->mode)) { if (do_fill || do_stroke || do_opacity) { diff --git a/src/unclump.cpp b/src/unclump.cpp index 29608befa..81c958937 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -173,7 +173,7 @@ static double unclump_average (SPItem *item, std::list<SPItem*> &others) int n = 0; double sum = 0; for (std::list<SPItem*>::const_iterator i = others.begin(); i != others.end();i++) { - SPItem *other = SP_ITEM (*i); + SPItem *other = *i; if (other == item) continue; @@ -197,7 +197,7 @@ static SPItem *unclump_closest (SPItem *item, std::list<SPItem*> &others) SPItem *closest = NULL; for (std::list<SPItem*>::const_iterator i = others.begin(); i != others.end();i++) { - SPItem *other = SP_ITEM (*i); + SPItem *other = *i; if (other == item) continue; @@ -220,7 +220,7 @@ static SPItem *unclump_farest (SPItem *item, std::list<SPItem*> &others) double max = -HUGE_VAL; SPItem *farest = NULL; for (std::list<SPItem*>::const_iterator i = others.begin(); i != others.end();i++) { - SPItem *other = SP_ITEM (*i); + SPItem *other = *i; if (other == item) continue; @@ -260,7 +260,7 @@ unclump_remove_behind (SPItem *item, SPItem *closest, std::list<SPItem*> &rest) std::vector<SPItem*> out; for (std::list<SPItem*>::const_reverse_iterator i = rest.rbegin(); i != rest.rend();i++) { - SPItem *other = SP_ITEM (*i); + SPItem *other = *i; if (other == item) continue; @@ -337,7 +337,7 @@ unclump (std::vector<SPItem*> &items) wh_cache.clear(); for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end();i++) { // for each original/clone x: - SPItem *item = SP_ITEM (*i); + SPItem *item = *i; std::list<SPItem*> nei; diff --git a/src/unclump.h b/src/unclump.h index 407628f3a..461e99d0b 100644 --- a/src/unclump.h +++ b/src/unclump.h @@ -12,7 +12,6 @@ #define SEEN_DIALOGS_UNCLUMP_H typedef struct _GSList GSList; -#include "selection.h" void unclump(std::vector<SPItem*> &items); diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 770845f38..46f895c06 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -258,7 +258,7 @@ VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { std::list<SPBox3D *> sel_boxes; std::vector<SPItem*> itemlist=sel->itemList(); for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast<SPItem *>(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box && this->hasBox(box)) { sel_boxes.push_back(box); @@ -398,7 +398,7 @@ VPDragger::VPsOfSelectedBoxes() { Inkscape::Selection *sel = SP_ACTIVE_DESKTOP->getSelection(); std::vector<SPItem*> itemlist=sel->itemList(); for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast<SPItem *>(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { vp = this->findVPWithBox(box); @@ -581,7 +581,7 @@ VPDrag::updateDraggers () std::vector<SPItem*> itemlist=this->selection->itemList(); for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast<SPItem *>(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { VanishingPoint vp; @@ -614,7 +614,7 @@ VPDrag::updateLines () std::vector<SPItem*> itemlist=this->selection->itemList(); for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast<SPItem *>(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { this->drawLinesForFace (box, Proj::X); diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index cb24bb8aa..71418e238 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -99,7 +99,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v bool modmade = false; std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); @@ -165,7 +165,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) if ( ege_select_one_action_get_active(act) != 0 ) { std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("sodipodi:open", "true"); @@ -176,7 +176,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) } else { std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("sodipodi:open", NULL); @@ -266,7 +266,7 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { n_selected++; repr = item->getRepr(); diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp index 49cf8e6fd..1c99f283d 100644 --- a/src/widgets/connector-toolbar.cpp +++ b/src/widgets/connector-toolbar.cpp @@ -99,7 +99,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl bool modmade = false; std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (Inkscape::UI::Tools::cc_item_is_connector(item)) { item->setAttribute( "inkscape:connector-type", @@ -146,7 +146,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) bool modmade = false; std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (Inkscape::UI::Tools::cc_item_is_connector(item)) { item->setAttribute( "inkscape:connector-curvature", diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index dbb84efba..7d5a89cf5 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -591,11 +591,11 @@ void FillNStroke::updateFromPaint() if ( gr && createSwatch ) { gr->setSwatch(); } - sp_item_set_gradient(SP_ITEM(*i), + sp_item_set_gradient(*i, gr, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); } else { - sp_item_set_gradient(SP_ITEM(*i), vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); + sp_item_set_gradient(*i, vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); } } } else { @@ -608,7 +608,7 @@ void FillNStroke::updateFromPaint() sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(*i)->getRepr(), css, "style"); } - SPGradient *gr = sp_item_set_gradient(SP_ITEM(*i), vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); + SPGradient *gr = sp_item_set_gradient(*i, vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); psel->pushAttrsToGradient( gr ); } } diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 5aa654a80..6743dd23a 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -118,7 +118,7 @@ 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->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - gr_apply_gradient_to_item(SP_ITEM(*i), gr, initialType, initialMode, initialMode); + gr_apply_gradient_to_item(*i, gr, initialType, initialMode, initialMode); } } @@ -220,7 +220,7 @@ void gr_get_dt_selected_gradient(Inkscape::Selection *selection, SPGradient *&gr std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i);// get the items gradient, not the getVector() version + SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; @@ -288,7 +288,7 @@ void gr_read_selection( Inkscape::Selection *selection, // If no selected dragger, read desktop selection std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPStyle *style = item->style; if (style && (style->fill.isPaintserver())) { diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 682c61e77..49fc7b67c 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -89,7 +89,7 @@ void ms_read_selection( Inkscape::Selection *selection, std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPStyle *style = item->style; if (style && (style->fill.isPaintserver())) { @@ -216,7 +216,7 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMeshGradient std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i);// get the items gradient, not the getVector() version + SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 65078af01..2b07dd3b9 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -246,9 +246,9 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - if (SP_IS_RECT(reinterpret_cast<SPItem *>(*i))) { + if (SP_IS_RECT(*i)) { n_selected++; - item = reinterpret_cast<SPItem *>(*i); + item = *i; repr = item->getRepr(); } } diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp index 6f967e8ae..751a60f06 100644 --- a/src/widgets/spiral-toolbar.cpp +++ b/src/widgets/spiral-toolbar.cpp @@ -81,7 +81,7 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr bool modmade = false; std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_SPIRAL(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double( repr, namespaced_name, @@ -197,7 +197,7 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_SPIRAL(item)) { n_selected++; repr = item->getRepr(); diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index 1946dee6e..96005d7df 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -85,7 +85,7 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu Inkscape::Selection *selection = desktop->getSelection(); std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_int(repr,"sodipodi:sides", @@ -130,7 +130,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl Inkscape::Selection *selection = desktop->getSelection(); std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -187,7 +187,7 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("inkscape:flatsided", flat ? "true" : "false" ); @@ -226,7 +226,7 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg Inkscape::Selection *selection = desktop->getSelection(); std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double(repr, "inkscape:rounded", @@ -266,7 +266,7 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl Inkscape::Selection *selection = desktop->getSelection(); std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double(repr, "inkscape:randomized", @@ -369,7 +369,7 @@ sp_star_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl) std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { n_selected++; repr = item->getRepr(); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 65390819b..c05ef93e7 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -477,7 +477,7 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, Inkscape::Selection *selection = spw->desktop->getSelection(); std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*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; } @@ -902,7 +902,7 @@ StrokeStyle::updateLine() return; std::vector<SPItem*> const objects = sel->itemList(); - SPObject * const object = SP_OBJECT(objects.front()); + SPObject * const object = SP_OBJECT(objects[0]); SPStyle * const style = object->style; /* Markers */ @@ -1155,6 +1155,7 @@ StrokeStyle::updateAllMarkers(std::vector<SPItem*> const &objects) for(std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++){ if (!SP_IS_TEXT (*i)) { all_texts = false; + break; } } @@ -1166,7 +1167,7 @@ StrokeStyle::updateAllMarkers(std::vector<SPItem*> const &objects) // We show markers of the first object in the list only // FIXME: use the first in the list that has the marker of each type, if any - SPObject *object = SP_OBJECT(objects.front()); + SPObject *object = SP_OBJECT(objects[0]); for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { // For all three marker types, diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 71915377e..6b0fb34e6 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -368,8 +368,8 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) Inkscape::Selection *selection = desktop->getSelection(); std::vector<SPItem*> itemlist=selection->itemList(); for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - if (SP_IS_TEXT(SP_ITEM(*i))) { - SPItem *item = SP_ITEM(*i); + if (SP_IS_TEXT(*i)) { + SPItem *item = *i; unsigned writing_mode = item->style->writing_mode.value; // below, variable names suggest horizontal move, but we check the writing direction @@ -868,7 +868,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ for(std::vector<SPItem*>::const_iterator 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(SP_ITEM(*i))) { + if( SP_IS_FLOWTEXT(*i)) { isFlow = true; // std::cout << " Found flowed text" << std::endl; break; @@ -1160,7 +1160,7 @@ static void sp_text_toolbox_select_cb( GtkEntry* entry, GtkEntryIconPosition /*p std::vector<SPItem*> x,y; std::vector<SPItem*> allList = get_all_items(x, document->getRoot(), desktop, false, false, true, y); for(std::vector<SPItem*>::const_reverse_iterator i=allList.rbegin();i!=allList.rend();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPStyle *style = item->style; if (style) { |
