diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2015-04-26 23:12:03 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <mc@M0nst3r.bouyguesbox.fr> | 2015-04-26 23:12:03 +0000 |
| commit | 60bdd590969d1c32c392a8fed15f4ceac4a678d2 (patch) | |
| tree | 87b14c9b5238e99cb319ff9245caa37b8b1d3c6a /src | |
| parent | fix (diff) | |
| download | inkscape-60bdd590969d1c32c392a8fed15f4ceac4a678d2.tar.gz inkscape-60bdd590969d1c32c392a8fed15f4ceac4a678d2.zip | |
Just reread the entire diff against trunk. Given the diff size, i must have forgotten things, but hopefully, there are only very few changes of semantics:
->childList is now in the intuitive order (childList()[0] is now firstChild)
-> sp_selection_paste_impl is now in the opposite order (change is local to selection-chemistry.cpp, and simplify a few things)
-> selection.setReprList now takes the list in the opposite order. It was always the case (the list was always reversed before handing to it)
-> a few comparison functions now work "the c++ way": the C way was to return -1 if a<b, 0 if a==b and 1 if a>b, now they return (bool)(a<b)
(bzr r13922.1.15)
Diffstat (limited to 'src')
| -rw-r--r-- | src/file.cpp | 1 | ||||
| -rw-r--r-- | src/main.cpp | 4 | ||||
| -rw-r--r-- | src/path-chemistry.cpp | 2 | ||||
| -rw-r--r-- | src/selection-chemistry.cpp | 10 | ||||
| -rw-r--r-- | src/selection.cpp | 30 | ||||
| -rw-r--r-- | src/sp-object.h | 1 | ||||
| -rw-r--r-- | src/text-chemistry.cpp | 3 | ||||
| -rw-r--r-- | src/ui/dialog/clonetiler.cpp | 3 | ||||
| -rw-r--r-- | src/ui/dialog/find.cpp | 2 | ||||
| -rw-r--r-- | src/ui/tools/tweak-tool.cpp | 2 |
10 files changed, 27 insertions, 31 deletions
diff --git a/src/file.cpp b/src/file.cpp index 07e41c550..d1dd2bcd6 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1090,7 +1090,6 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) pasted_objects.push_back(obj_copy); } - // Change the selection to the freshly pasted objects Inkscape::Selection *selection = desktop->getSelection(); selection->setReprList(pasted_objects); diff --git a/src/main.cpp b/src/main.cpp index 66452906b..d1ebdc3bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1641,7 +1641,9 @@ static int sp_do_export_png(SPDocument *doc) g_print("Background RRGGBBAA: %08x\n", bgcolor); g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi); - + + reverse(items.begin(),items.end()); + if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : std::vector<SPItem*>()) == 1 ) { diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index b128535bc..bb313ef1a 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -269,7 +269,7 @@ sp_selected_path_break_apart(SPDesktop *desktop) if (l == list) repr->setAttribute("id", id); - reprs.insert(reprs.begin(),repr); + reprs.push_back(repr); Inkscape::GC::release(repr); } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 0100e1040..c1d4f58e4 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -337,10 +337,7 @@ static void sp_selection_copy_impl(std::vector<SPItem*> const &items, std::vecto g_assert_not_reached(); } } - std::vector<Inkscape::XML::Node*> tmp(clip); - for(int i=0;i<tmp.size();i++){ - clip[i]=tmp[tmp.size()-i-1]; - } + reverse(clip.begin(),clip.end()); } // TODO check if parent parameter should be changed to SPItem, of if the code should handle non-items. @@ -1418,7 +1415,6 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) sp_selection_delete_impl(items, false, false); std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip); selection->setReprList(copied); - copied.clear(); if (!temp_clip.empty()) temp_clip.clear(); if (moveto) dt->setCurrentLayer(moveto); if ( !suppressDone ) { @@ -2051,7 +2047,7 @@ std::vector<SPItem*> sp_get_same_style(SPItem *sel, std::vector<SPItem*> &src, S sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT); objects_query_strokewidth (objects, sel_style_for_width); } - bool match_g; + bool match_g; for (std::vector<SPItem*>::const_iterator i=src.begin();i!=src.end();i++) { SPItem *iter = *i; if (iter) { @@ -3186,7 +3182,7 @@ void sp_selection_unsymbol(SPDesktop *desktop) } } - for (std::vector<SPObject*>::const_iterator i=children.begin();i!=children.end();i++){ + for (std::vector<SPObject*>::const_reverse_iterator i=children.rbegin();i!=children.rend();i++){ Inkscape::XML::Node *repr = (*i)->getRepr(); repr->parent()->removeChild(repr); group->addChild(repr,NULL); diff --git a/src/selection.cpp b/src/selection.cpp index 7e8190237..d9266b599 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -42,9 +42,9 @@ namespace Inkscape { Selection::Selection(LayerModel *layers, SPDesktop *desktop) : - _objs(std::list<SPObject*>()), - _objs_vector(std::vector<SPObject*>()), - _objs_set(std::set<SPObject*>()), + _objs(std::list<SPObject*>()), + _objs_vector(std::vector<SPObject*>()), + _objs_set(std::set<SPObject*>()), _reprs(std::vector<XML::Node*>()), _items(std::vector<SPItem*>()), _layers(layers), @@ -281,10 +281,10 @@ void Selection::clear() { } std::vector<SPObject*> const &Selection::list() { - if(!_objs_vector.empty()) + if(!_objs_vector.empty()) return _objs_vector; - for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { + for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { _objs_vector.push_back(*iter); } return _objs_vector; @@ -349,7 +349,7 @@ SPObject *Selection::single() { } SPItem *Selection::singleItem() { - std::vector<SPItem*> const items=itemList(); + std::vector<SPItem*> const items=itemList(); if ( items.size()==1) { return items[0]; } else { @@ -366,7 +366,7 @@ SPItem *Selection::largestItem(Selection::CompareSize compare) { } SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); gdouble max = sml ? 1e18 : 0; SPItem *ist = NULL; @@ -399,7 +399,7 @@ Geom::OptRect Selection::bounds(SPItem::BBoxType type) const Geom::OptRect Selection::geometricBounds() const { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); Geom::OptRect bbox; for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { @@ -410,7 +410,7 @@ Geom::OptRect Selection::geometricBounds() const Geom::OptRect Selection::visualBounds() const { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); Geom::OptRect bbox; for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { @@ -445,7 +445,7 @@ Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const // If we have a selection of multiple items, then the center of the first item // will be returned; this is also the case in SelTrans::centerRequest() boost::optional<Geom::Point> Selection::center() const { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); if (!items.empty()) { SPItem *first = items.back(); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly @@ -461,7 +461,7 @@ boost::optional<Geom::Point> Selection::center() const { } std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferences const *snapprefs) const { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center @@ -514,8 +514,8 @@ SPObject *Selection::_objectForXMLNode(Inkscape::XML::Node *repr) const { } uint Selection::numberOfLayers() { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); - std::set<SPObject*> layers; + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); + std::set<SPObject*> layers; for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPObject *layer = _layers->layerForObject(SP_OBJECT(*iter)); layers.insert(layer); @@ -524,8 +524,8 @@ uint Selection::numberOfLayers() { } guint Selection::numberOfParents() { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); - std::set<SPObject*> parents; + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); + std::set<SPObject*> parents; for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPObject *parent = SP_OBJECT(*iter)->parent; parents.insert(parent); diff --git a/src/sp-object.h b/src/sp-object.h index df773fea7..f5d47be05 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -52,7 +52,6 @@ class SPObject; #include <sigc++/connection.h> #include <sigc++/functors/slot.h> #include <sigc++/signal.h> -#include <list> #include <vector> #include "version.h" diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 5d57ac020..9fc862ad2 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -396,7 +396,7 @@ text_unflow () GSList *old_objs = NULL; std::vector<SPItem*> items = selection->itemList(); - for(std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ if (!SP_IS_FLOWTEXT(*i)) { continue; @@ -452,6 +452,7 @@ text_unflow () } selection->clear(); + reverse(new_objs.begin(),new_objs.end()); selection->setList(new_objs); for (GSList *i = old_objs; i; i = i->next) { SP_OBJECT(i->data)->deleteObject (true); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index b348bdcad..f84a2ffd6 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2113,8 +2113,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) } desktop->getDocument()->ensureUpToDate(); - std::vector<SPItem*> tu2(to_unclump); - for(int i=0;i<tu2.size();i++)to_unclump[i]=tu2[tu2.size()-i-1]; + reverse(to_unclump.begin(),to_unclump.end()); unclump (to_unclump); DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER, diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 173acca93..a8ac42a1b 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -762,7 +762,7 @@ std::vector<SPItem*> &Find::all_items (SPObject *r, std::vector<SPItem*> &l, boo std::vector<SPItem*> &Find::all_selection_items (Inkscape::Selection *s, std::vector<SPItem*> &l, SPObject *ancestor, bool hidden, bool locked) { std::vector<SPItem*> itemlist=s->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + for(std::vector<SPItem*>::const_reverse_iterator i=itemlist.rbegin(); itemlist.rend() != i; i++) { SPObject *obj = *i; SPItem *item = dynamic_cast<SPItem *>(obj); g_assert(item != NULL); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 76c748ae0..76b52f9be 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -378,7 +378,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P std::vector<Inkscape::XML::Node*> to_select; SPDocument *doc = item->document; sp_item_list_to_curves (items, selected, to_select); - SPObject* newObj = doc->getObjectByRepr(to_select.back()); + SPObject* newObj = doc->getObjectByRepr(to_select[0]); item = dynamic_cast<SPItem *>(newObj); g_assert(item != NULL); selection->add(item); |
