Merge lp:~mc.../inkscape/SelContainer into lp:~inkscape.dev/inkscape/trunk
- SelContainer
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 14074 |
Proposed branch: | lp:~mc.../inkscape/SelContainer |
Merge into: | lp:~inkscape.dev/inkscape/trunk |
Diff against target: |
8772 lines (+1576/-1810) 114 files modified
AUTHORS (+1/-0) src/conn-avoid-ref.cpp (+3/-2) src/desktop-style.cpp (+60/-61) src/desktop-style.h (+16/-15) src/desktop.cpp (+1/-1) src/desktop.h (+1/-1) src/document.cpp (+17/-17) src/document.h (+4/-4) src/extension/execution-env.cpp (+3/-5) src/extension/implementation/implementation.cpp (+3/-5) src/extension/implementation/script.cpp (+3/-4) src/extension/internal/bitmap/imagemagick.cpp (+7/-11) src/extension/internal/bluredge.cpp (+2/-4) src/extension/internal/cairo-renderer.cpp (+3/-5) src/extension/internal/filter/filter.cpp (+2/-4) src/extension/internal/grid.cpp (+3/-6) src/extension/internal/latex-text-renderer.cpp (+3/-5) src/file.cpp (+2/-5) src/gradient-chemistry.cpp (+7/-5) src/gradient-drag.cpp (+9/-8) src/graphlayout.cpp (+5/-5) src/graphlayout.h (+2/-2) src/helper/png-write.cpp (+6/-6) src/helper/png-write.h (+4/-3) src/live_effects/lpe-knot.cpp (+3/-3) src/main.cpp (+13/-15) src/object-snapper.cpp (+3/-2) src/object-test.h (+2/-1) src/path-chemistry.cpp (+57/-72) src/path-chemistry.h (+1/-1) src/removeoverlap.cpp (+6/-7) src/removeoverlap.h (+1/-1) src/selcue.cpp (+11/-8) src/selection-chemistry.cpp (+415/-518) src/selection-chemistry.h (+5/-4) src/selection-describer.cpp (+17/-17) src/selection.cpp (+83/-89) src/selection.h (+15/-11) src/seltrans.cpp (+27/-28) src/seltrans.h (+1/-1) src/snap.cpp (+7/-7) src/snap.h (+4/-4) src/sp-conn-end.cpp (+3/-2) src/sp-defs.cpp (+3/-5) src/sp-filter.cpp (+3/-5) src/sp-item-group.cpp (+32/-53) src/sp-item-group.h (+6/-4) src/sp-lpe-item.cpp (+15/-15) src/sp-marker.cpp (+3/-3) src/sp-marker.h (+1/-1) src/sp-object.cpp (+3/-3) src/sp-object.h (+3/-2) src/sp-pattern.cpp (+3/-3) src/sp-pattern.h (+1/-1) src/sp-switch.cpp (+11/-13) src/sp-switch.h (+1/-1) src/splivarot.cpp (+44/-57) src/text-chemistry.cpp (+37/-47) src/text-editing.cpp (+3/-4) src/trace/trace.cpp (+4/-4) src/ui/clipboard.cpp (+17/-16) src/ui/dialog/align-and-distribute.cpp (+41/-45) src/ui/dialog/clonetiler.cpp (+7/-9) src/ui/dialog/export.cpp (+15/-13) src/ui/dialog/filter-effects-dialog.cpp (+12/-15) src/ui/dialog/find.cpp (+48/-48) src/ui/dialog/find.h (+5/-5) src/ui/dialog/font-substitution.cpp (+11/-17) src/ui/dialog/font-substitution.h (+3/-2) src/ui/dialog/glyphs.cpp (+7/-5) src/ui/dialog/grid-arrange-tab.cpp (+34/-35) src/ui/dialog/icon-preview.cpp (+3/-5) src/ui/dialog/object-attributes.cpp (+1/-1) src/ui/dialog/objects.cpp (+4/-4) src/ui/dialog/pixelartdialog.cpp (+4/-4) src/ui/dialog/polar-arrange-tab.cpp (+5/-9) src/ui/dialog/print.cpp (+1/-1) src/ui/dialog/svg-fonts-dialog.cpp (+2/-2) src/ui/dialog/swatches.cpp (+3/-3) src/ui/dialog/tags.cpp (+6/-5) src/ui/dialog/text-edit.cpp (+12/-14) src/ui/dialog/transformation.cpp (+24/-20) src/ui/interface.cpp (+7/-10) src/ui/tools/connector-tool.cpp (+3/-5) src/ui/tools/eraser-tool.cpp (+13/-20) src/ui/tools/gradient-tool.cpp (+19/-18) src/ui/tools/lpe-tool.cpp (+4/-4) src/ui/tools/measure-tool.cpp (+3/-3) src/ui/tools/mesh-tool.cpp (+14/-13) src/ui/tools/node-tool.cpp (+4/-6) src/ui/tools/select-tool.cpp (+2/-3) src/ui/tools/spray-tool.cpp (+12/-20) src/ui/tools/text-tool.cpp (+3/-4) src/ui/tools/tool-base.cpp (+2/-4) src/ui/tools/tweak-tool.cpp (+11/-14) src/ui/widget/object-composite-settings.cpp (+2/-1) src/ui/widget/style-subject.cpp (+19/-21) src/ui/widget/style-subject.h (+8/-7) src/unclump.cpp (+32/-35) src/unclump.h (+1/-1) src/vanishing-point.cpp (+15/-11) src/widgets/arc-toolbar.cpp (+12/-21) src/widgets/connector-toolbar.cpp (+6/-10) src/widgets/fill-style.cpp (+16/-16) src/widgets/gradient-toolbar.cpp (+9/-6) src/widgets/mesh-toolbar.cpp (+6/-4) src/widgets/rect-toolbar.cpp (+9/-9) src/widgets/spiral-toolbar.cpp (+6/-10) src/widgets/star-toolbar.cpp (+18/-20) src/widgets/stroke-style.cpp (+15/-15) src/widgets/stroke-style.h (+1/-1) src/widgets/text-toolbar.cpp (+17/-17) src/xml/repr-util.cpp (+6/-6) src/xml/repr.h (+2/-1) |
To merge this branch: | bzr merge lp:~mc.../inkscape/SelContainer |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alex Valavanis | Needs Fixing | ||
Liam P. White (community) | Approve | ||
Review via email: mp+250681@code.launchpad.net |
Commit message
Description of the change
Hi all,
This branch is a proposal to replace a lot of GSLists with std::vectors, more specifically in all the places that deal with the selection.
Basically, selection-
Mc (mc...) wrote : | # |
> I added some fancy new diff comments that should help show where things need
> fixing.
Thanks a lot for your comments !
I actually meant to change the semantics of SPObject::childList : It used to return a GSList, whose *last* element was the first child, and to be reversed in many places.
Now it returns a vector whose *first* element is the first child, so that allows us to actually simplify a lot of things (use push_back instead of insert in all the places that deals with childList)
I'll try to apply your comments as soon as i can.
Krzysztof Kosinski (tweenk) wrote : | # |
Converting Selection to a vector is not the best thing to do. Selection
should be a data structure equivalent to Java's LinkedHashSet, because the
most common operation is lookup (whether something is in the selection) and
we also need to remember the selection's order for purposes such as Boolean
operations.
Regards, Krzysztof
2015-02-24 12:08 GMT+01:00 Mc <email address hidden>:
> > I added some fancy new diff comments that should help show where things
> need
> > fixing.
>
> Thanks a lot for your comments !
>
> I actually meant to change the semantics of SPObject::childList : It used
> to return a GSList, whose *last* element was the first child, and to be
> reversed in many places.
>
> Now it returns a vector whose *first* element is the first child, so that
> allows us to actually simplify a lot of things (use push_back instead of
> insert in all the places that deals with childList)
>
> I'll try to apply your comments as soon as i can.
> --
> https:/
> You are subscribed to branch lp:inkscape.
>
Mc (mc...) wrote : | # |
This is not contradictory: since only the selection object needs to be able to do the lookups, this data structure can be internal to Selection, and does not need to be whatever is sent to anyone who calls itemList() (I don't really favor introducing iteration over boost objects everywhere just for that, stl is enough for stuff out of the selection class (ie: iterate) )
(I actually also added a std::set to make lookups logarithmic, alongside with the vectors change. I agree that it could be made one container, internally to the selection class, but vector+set prevents to do the copying from the boost thing)
> Converting Selection to a vector is not the best thing to do. Selection
> should be a data structure equivalent to Java's LinkedHashSet, because the
> most common operation is lookup (whether something is in the selection) and
> we also need to remember the selection's order for purposes such as Boolean
> operations.
>
> Regards, Krzysztof
Krzysztof Kosinski (tweenk) wrote : | # |
Some more comments.
1. Please follow the coding style.
https:/
2. I don't really understand what you mean by "introducing iteration over boost objects".
3. While simply replacing GSList with vectors is an obvious improvement, I think the correct approach is to make a new data structure, that will encapsulate what we mean by a selection of objects (a list of unique items none of which is a descendant of any other), but which will not be tied to the GUI concept of selection. One could use Boost MultiIndex for this. Then you would return this structure (or references to it) instead of std::vector. The new structure could be a template called SelectionSet, with typedefs SelectionSet<
Liam P. White (liampwhite) wrote : | # |
> I would not be opposed to incorporating the simple GSList -> vector change first and introducing selection sets later.
Then let's do that.
- 13932. By Marc Jeanmougin <email address hidden>
-
corrected the casts (hopefully)
- 13933. By Marc Jeanmougin <email address hidden>
-
more cast cleanup
- 13934. By Marc Jeanmougin <email address hidden>
-
merge
- 13935. By Marc Jeanmougin <email address hidden>
-
merging
- 13936. By Marc Jeanmougin <email address hidden>
-
fix
- 13937. By Marc Jeanmougin <email address hidden>
-
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) - 13938. By Marc Jeanmougin <email address hidden>
-
removed a few "using Inkscape:
:Util:: GSListConstIter ator" - 13939. By Marc Jeanmougin <email address hidden>
-
removed a few useless SP_OBJECT() casts
- 13940. By Marc Jeanmougin <email address hidden>
-
merge with trunk
Liam P. White (liampwhite) wrote : | # |
Approving for merge — may need some small post-merge cleanups but otherwise don't see any issues obstructing merge at this point.
Alex Valavanis (valavanisalex) wrote : | # |
This introduces a build failure if using --enable-dbusapi configuration flag. This is because the src/extension/
Preview Diff
1 | === modified file 'AUTHORS' | |||
2 | --- AUTHORS 2014-05-12 22:02:09 +0000 | |||
3 | +++ AUTHORS 2015-04-29 21:03:59 +0000 | |||
4 | @@ -80,6 +80,7 @@ | |||
5 | 80 | Jean-Olivier Irisson | 80 | Jean-Olivier Irisson |
6 | 81 | Bob Jamison | 81 | Bob Jamison |
7 | 82 | Ted Janeczko | 82 | Ted Janeczko |
8 | 83 | Marc Jeanmougin | ||
9 | 83 | jEsuSdA | 84 | jEsuSdA |
10 | 84 | Lauris Kaplinski | 85 | Lauris Kaplinski |
11 | 85 | Lynn Kerby | 86 | Lynn Kerby |
12 | 86 | 87 | ||
13 | === modified file 'src/conn-avoid-ref.cpp' | |||
14 | --- src/conn-avoid-ref.cpp 2014-12-21 21:58:32 +0000 | |||
15 | +++ src/conn-avoid-ref.cpp 2015-04-29 21:03:59 +0000 | |||
16 | @@ -252,8 +252,9 @@ | |||
17 | 252 | { | 252 | { |
18 | 253 | SPGroup* group = SP_GROUP(item); | 253 | SPGroup* group = SP_GROUP(item); |
19 | 254 | // consider all first-order children | 254 | // consider all first-order children |
22 | 255 | for (GSList const* i = sp_item_group_item_list(group); i != NULL; i = i->next) { | 255 | std::vector<SPItem*> itemlist = sp_item_group_item_list(group); |
23 | 256 | SPItem* child_item = SP_ITEM(i->data); | 256 | for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); i++) { |
24 | 257 | SPItem* child_item = *i; | ||
25 | 257 | std::vector<Geom::Point> child_points = approxItemWithPoints(child_item, item_transform * child_item->transform); | 258 | std::vector<Geom::Point> child_points = approxItemWithPoints(child_item, item_transform * child_item->transform); |
26 | 258 | poly_points.insert(poly_points.end(), child_points.begin(), child_points.end()); | 259 | poly_points.insert(poly_points.end(), child_points.begin(), child_points.end()); |
27 | 259 | } | 260 | } |
28 | 260 | 261 | ||
29 | === modified file 'src/desktop-style.cpp' | |||
30 | --- src/desktop-style.cpp 2015-02-22 18:04:11 +0000 | |||
31 | +++ src/desktop-style.cpp 2015-04-29 21:03:59 +0000 | |||
32 | @@ -194,10 +194,10 @@ | |||
33 | 194 | sp_repr_css_merge(css_write, css); | 194 | sp_repr_css_merge(css_write, css); |
34 | 195 | sp_css_attr_unset_uris(css_write); | 195 | sp_css_attr_unset_uris(css_write); |
35 | 196 | prefs->mergeStyle("/desktop/style", css_write); | 196 | prefs->mergeStyle("/desktop/style", css_write); |
38 | 197 | 197 | std::vector<SPItem*> const itemlist = desktop->selection->itemList(); | |
39 | 198 | for (const GSList *i = desktop->selection->itemList(); i != NULL; i = i->next) { | 198 | for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { |
40 | 199 | /* last used styles for 3D box faces are stored separately */ | 199 | /* last used styles for 3D box faces are stored separately */ |
42 | 200 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); // TODO unsafe until Selection is refactored. | 200 | SPObject *obj = *i; |
43 | 201 | Box3DSide *side = dynamic_cast<Box3DSide *>(obj); | 201 | Box3DSide *side = dynamic_cast<Box3DSide *>(obj); |
44 | 202 | if (side) { | 202 | if (side) { |
45 | 203 | const char * descr = box3d_side_axes_string(side); | 203 | const char * descr = box3d_side_axes_string(side); |
46 | @@ -234,8 +234,9 @@ | |||
47 | 234 | sp_repr_css_merge(css_no_text, css); | 234 | sp_repr_css_merge(css_no_text, css); |
48 | 235 | css_no_text = sp_css_attr_unset_text(css_no_text); | 235 | css_no_text = sp_css_attr_unset_text(css_no_text); |
49 | 236 | 236 | ||
52 | 237 | for (GSList const *i = desktop->selection->itemList(); i != NULL; i = i->next) { | 237 | std::vector<SPItem*> const itemlist = desktop->selection->itemList(); |
53 | 238 | SPItem *item = reinterpret_cast<SPItem *>(i->data); | 238 | for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { |
54 | 239 | SPItem *item = *i; | ||
55 | 239 | 240 | ||
56 | 240 | // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) | 241 | // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) |
57 | 241 | if (isTextualItem(item)) { | 242 | if (isTextualItem(item)) { |
58 | @@ -438,18 +439,16 @@ | |||
59 | 438 | /** Determine average stroke width, simple method */ | 439 | /** Determine average stroke width, simple method */ |
60 | 439 | // see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually | 440 | // see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually |
61 | 440 | gdouble | 441 | gdouble |
63 | 441 | stroke_average_width (GSList const *objects) | 442 | stroke_average_width (const std::vector<SPItem*> &objects) |
64 | 442 | { | 443 | { |
66 | 443 | if (g_slist_length ((GSList *) objects) == 0) | 444 | if (objects.empty()) |
67 | 444 | return Geom::infinity(); | 445 | return Geom::infinity(); |
68 | 445 | 446 | ||
69 | 446 | gdouble avgwidth = 0.0; | 447 | gdouble avgwidth = 0.0; |
70 | 447 | bool notstroked = true; | 448 | bool notstroked = true; |
71 | 448 | int n_notstroked = 0; | 449 | int n_notstroked = 0; |
76 | 449 | 450 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { | |
77 | 450 | for (GSList const *l = objects; l != NULL; l = l->next) { | 451 | SPItem *item = *i; |
74 | 451 | SPObject *obj = reinterpret_cast<SPObject *>(l->data); | ||
75 | 452 | SPItem *item = dynamic_cast<SPItem *>(obj); | ||
78 | 453 | if (!item) { | 452 | if (!item) { |
79 | 454 | continue; | 453 | continue; |
80 | 455 | } | 454 | } |
81 | @@ -471,7 +470,7 @@ | |||
82 | 471 | if (notstroked) | 470 | if (notstroked) |
83 | 472 | return Geom::infinity(); | 471 | return Geom::infinity(); |
84 | 473 | 472 | ||
86 | 474 | return avgwidth / (g_slist_length ((GSList *) objects) - n_notstroked); | 473 | return avgwidth / (objects.size() - n_notstroked); |
87 | 475 | } | 474 | } |
88 | 476 | 475 | ||
89 | 477 | static bool vectorsClose( std::vector<double> const &lhs, std::vector<double> const &rhs ) | 476 | static bool vectorsClose( std::vector<double> const &lhs, std::vector<double> const &rhs ) |
90 | @@ -492,9 +491,9 @@ | |||
91 | 492 | * Write to style_res the average fill or stroke of list of objects, if applicable. | 491 | * Write to style_res the average fill or stroke of list of objects, if applicable. |
92 | 493 | */ | 492 | */ |
93 | 494 | int | 493 | int |
95 | 495 | objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill) | 494 | objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_res, bool const isfill) |
96 | 496 | { | 495 | { |
98 | 497 | if (g_slist_length(objects) == 0) { | 496 | if (objects.empty()) { |
99 | 498 | /* No objects, set empty */ | 497 | /* No objects, set empty */ |
100 | 499 | return QUERY_STYLE_NOTHING; | 498 | return QUERY_STYLE_NOTHING; |
101 | 500 | } | 499 | } |
102 | @@ -514,8 +513,8 @@ | |||
103 | 514 | prev[0] = prev[1] = prev[2] = 0.0; | 513 | prev[0] = prev[1] = prev[2] = 0.0; |
104 | 515 | bool same_color = true; | 514 | bool same_color = true; |
105 | 516 | 515 | ||
108 | 517 | for (GSList const *i = objects; i != NULL; i = i->next) { | 516 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i!= objects.end(); i++) { |
109 | 518 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 517 | SPObject *obj = *i; |
110 | 519 | if (!obj) { | 518 | if (!obj) { |
111 | 520 | continue; | 519 | continue; |
112 | 521 | } | 520 | } |
113 | @@ -674,7 +673,7 @@ | |||
114 | 674 | } | 673 | } |
115 | 675 | 674 | ||
116 | 676 | // Not color | 675 | // Not color |
118 | 677 | if (g_slist_length(objects) > 1) { | 676 | if (objects.size() > 1) { |
119 | 678 | return QUERY_STYLE_MULTIPLE_SAME; | 677 | return QUERY_STYLE_MULTIPLE_SAME; |
120 | 679 | } else { | 678 | } else { |
121 | 680 | return QUERY_STYLE_SINGLE; | 679 | return QUERY_STYLE_SINGLE; |
122 | @@ -685,9 +684,9 @@ | |||
123 | 685 | * Write to style_res the average opacity of a list of objects. | 684 | * Write to style_res the average opacity of a list of objects. |
124 | 686 | */ | 685 | */ |
125 | 687 | int | 686 | int |
127 | 688 | objects_query_opacity (GSList *objects, SPStyle *style_res) | 687 | objects_query_opacity (const std::vector<SPItem*> &objects, SPStyle *style_res) |
128 | 689 | { | 688 | { |
130 | 690 | if (g_slist_length(objects) == 0) { | 689 | if (objects.empty()) { |
131 | 691 | /* No objects, set empty */ | 690 | /* No objects, set empty */ |
132 | 692 | return QUERY_STYLE_NOTHING; | 691 | return QUERY_STYLE_NOTHING; |
133 | 693 | } | 692 | } |
134 | @@ -698,8 +697,8 @@ | |||
135 | 698 | guint opacity_items = 0; | 697 | guint opacity_items = 0; |
136 | 699 | 698 | ||
137 | 700 | 699 | ||
140 | 701 | for (GSList const *i = objects; i != NULL; i = i->next) { | 700 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
141 | 702 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 701 | SPObject *obj = *i; |
142 | 703 | if (!obj) { | 702 | if (!obj) { |
143 | 704 | continue; | 703 | continue; |
144 | 705 | } | 704 | } |
145 | @@ -739,9 +738,9 @@ | |||
146 | 739 | * Write to style_res the average stroke width of a list of objects. | 738 | * Write to style_res the average stroke width of a list of objects. |
147 | 740 | */ | 739 | */ |
148 | 741 | int | 740 | int |
150 | 742 | objects_query_strokewidth (GSList *objects, SPStyle *style_res) | 741 | objects_query_strokewidth (const std::vector<SPItem*> &objects, SPStyle *style_res) |
151 | 743 | { | 742 | { |
153 | 744 | if (g_slist_length(objects) == 0) { | 743 | if (objects.empty()) { |
154 | 745 | /* No objects, set empty */ | 744 | /* No objects, set empty */ |
155 | 746 | return QUERY_STYLE_NOTHING; | 745 | return QUERY_STYLE_NOTHING; |
156 | 747 | } | 746 | } |
157 | @@ -754,8 +753,8 @@ | |||
158 | 754 | 753 | ||
159 | 755 | int n_stroked = 0; | 754 | int n_stroked = 0; |
160 | 756 | 755 | ||
163 | 757 | for (GSList const *i = objects; i != NULL; i = i->next) { | 756 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
164 | 758 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 757 | SPObject *obj = *i; |
165 | 759 | if (!obj) { | 758 | if (!obj) { |
166 | 760 | continue; | 759 | continue; |
167 | 761 | } | 760 | } |
168 | @@ -815,9 +814,9 @@ | |||
169 | 815 | * Write to style_res the average miter limit of a list of objects. | 814 | * Write to style_res the average miter limit of a list of objects. |
170 | 816 | */ | 815 | */ |
171 | 817 | int | 816 | int |
173 | 818 | objects_query_miterlimit (GSList *objects, SPStyle *style_res) | 817 | objects_query_miterlimit (const std::vector<SPItem*> &objects, SPStyle *style_res) |
174 | 819 | { | 818 | { |
176 | 820 | if (g_slist_length(objects) == 0) { | 819 | if (objects.empty()) { |
177 | 821 | /* No objects, set empty */ | 820 | /* No objects, set empty */ |
178 | 822 | return QUERY_STYLE_NOTHING; | 821 | return QUERY_STYLE_NOTHING; |
179 | 823 | } | 822 | } |
180 | @@ -828,8 +827,8 @@ | |||
181 | 828 | gdouble prev_ml = -1; | 827 | gdouble prev_ml = -1; |
182 | 829 | bool same_ml = true; | 828 | bool same_ml = true; |
183 | 830 | 829 | ||
186 | 831 | for (GSList const *i = objects; i != NULL; i = i->next) { | 830 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
187 | 832 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 831 | SPObject *obj = *i; |
188 | 833 | if (!dynamic_cast<SPItem *>(obj)) { | 832 | if (!dynamic_cast<SPItem *>(obj)) { |
189 | 834 | continue; | 833 | continue; |
190 | 835 | } | 834 | } |
191 | @@ -875,9 +874,9 @@ | |||
192 | 875 | * Write to style_res the stroke cap of a list of objects. | 874 | * Write to style_res the stroke cap of a list of objects. |
193 | 876 | */ | 875 | */ |
194 | 877 | int | 876 | int |
196 | 878 | objects_query_strokecap (GSList *objects, SPStyle *style_res) | 877 | objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res) |
197 | 879 | { | 878 | { |
199 | 880 | if (g_slist_length(objects) == 0) { | 879 | if (objects.empty()) { |
200 | 881 | /* No objects, set empty */ | 880 | /* No objects, set empty */ |
201 | 882 | return QUERY_STYLE_NOTHING; | 881 | return QUERY_STYLE_NOTHING; |
202 | 883 | } | 882 | } |
203 | @@ -887,8 +886,8 @@ | |||
204 | 887 | bool same_cap = true; | 886 | bool same_cap = true; |
205 | 888 | int n_stroked = 0; | 887 | int n_stroked = 0; |
206 | 889 | 888 | ||
209 | 890 | for (GSList const *i = objects; i != NULL; i = i->next) { | 889 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
210 | 891 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 890 | SPObject *obj = *i; |
211 | 892 | if (!dynamic_cast<SPItem *>(obj)) { | 891 | if (!dynamic_cast<SPItem *>(obj)) { |
212 | 893 | continue; | 892 | continue; |
213 | 894 | } | 893 | } |
214 | @@ -929,9 +928,9 @@ | |||
215 | 929 | * Write to style_res the stroke join of a list of objects. | 928 | * Write to style_res the stroke join of a list of objects. |
216 | 930 | */ | 929 | */ |
217 | 931 | int | 930 | int |
219 | 932 | objects_query_strokejoin (GSList *objects, SPStyle *style_res) | 931 | objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_res) |
220 | 933 | { | 932 | { |
222 | 934 | if (g_slist_length(objects) == 0) { | 933 | if (objects.empty()) { |
223 | 935 | /* No objects, set empty */ | 934 | /* No objects, set empty */ |
224 | 936 | return QUERY_STYLE_NOTHING; | 935 | return QUERY_STYLE_NOTHING; |
225 | 937 | } | 936 | } |
226 | @@ -941,8 +940,8 @@ | |||
227 | 941 | bool same_join = true; | 940 | bool same_join = true; |
228 | 942 | int n_stroked = 0; | 941 | int n_stroked = 0; |
229 | 943 | 942 | ||
232 | 944 | for (GSList const *i = objects; i != NULL; i = i->next) { | 943 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
233 | 945 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 944 | SPObject *obj = *i; |
234 | 946 | if (!dynamic_cast<SPItem *>(obj)) { | 945 | if (!dynamic_cast<SPItem *>(obj)) { |
235 | 947 | continue; | 946 | continue; |
236 | 948 | } | 947 | } |
237 | @@ -984,7 +983,7 @@ | |||
238 | 984 | * Write to style_res the average font size and spacing of objects. | 983 | * Write to style_res the average font size and spacing of objects. |
239 | 985 | */ | 984 | */ |
240 | 986 | int | 985 | int |
242 | 987 | objects_query_fontnumbers (GSList *objects, SPStyle *style_res) | 986 | objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_res) |
243 | 988 | { | 987 | { |
244 | 989 | bool different = false; | 988 | bool different = false; |
245 | 990 | 989 | ||
246 | @@ -1004,8 +1003,8 @@ | |||
247 | 1004 | int texts = 0; | 1003 | int texts = 0; |
248 | 1005 | int no_size = 0; | 1004 | int no_size = 0; |
249 | 1006 | 1005 | ||
252 | 1007 | for (GSList const *i = objects; i != NULL; i = i->next) { | 1006 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
253 | 1008 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 1007 | SPObject *obj = *i; |
254 | 1009 | 1008 | ||
255 | 1010 | if (!isTextualItem(obj)) { | 1009 | if (!isTextualItem(obj)) { |
256 | 1011 | continue; | 1010 | continue; |
257 | @@ -1116,15 +1115,15 @@ | |||
258 | 1116 | * Write to style_res the average font style of objects. | 1115 | * Write to style_res the average font style of objects. |
259 | 1117 | */ | 1116 | */ |
260 | 1118 | int | 1117 | int |
262 | 1119 | objects_query_fontstyle (GSList *objects, SPStyle *style_res) | 1118 | objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res) |
263 | 1120 | { | 1119 | { |
264 | 1121 | bool different = false; | 1120 | bool different = false; |
265 | 1122 | bool set = false; | 1121 | bool set = false; |
266 | 1123 | 1122 | ||
267 | 1124 | int texts = 0; | 1123 | int texts = 0; |
268 | 1125 | 1124 | ||
271 | 1126 | for (GSList const *i = objects; i != NULL; i = i->next) { | 1125 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
272 | 1127 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 1126 | SPObject *obj = *i; |
273 | 1128 | 1127 | ||
274 | 1129 | if (!isTextualItem(obj)) { | 1128 | if (!isTextualItem(obj)) { |
275 | 1130 | continue; | 1129 | continue; |
276 | @@ -1173,7 +1172,7 @@ | |||
277 | 1173 | * Write to style_res the baseline numbers. | 1172 | * Write to style_res the baseline numbers. |
278 | 1174 | */ | 1173 | */ |
279 | 1175 | static int | 1174 | static int |
281 | 1176 | objects_query_baselines (GSList *objects, SPStyle *style_res) | 1175 | objects_query_baselines (const std::vector<SPItem*> &objects, SPStyle *style_res) |
282 | 1177 | { | 1176 | { |
283 | 1178 | bool different = false; | 1177 | bool different = false; |
284 | 1179 | 1178 | ||
285 | @@ -1192,8 +1191,8 @@ | |||
286 | 1192 | 1191 | ||
287 | 1193 | int texts = 0; | 1192 | int texts = 0; |
288 | 1194 | 1193 | ||
291 | 1195 | for (GSList const *i = objects; i != NULL; i = i->next) { | 1194 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
292 | 1196 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 1195 | SPObject *obj = *i; |
293 | 1197 | 1196 | ||
294 | 1198 | if (!isTextualItem(obj)) { | 1197 | if (!isTextualItem(obj)) { |
295 | 1199 | continue; | 1198 | continue; |
296 | @@ -1269,7 +1268,7 @@ | |||
297 | 1269 | * Write to style_res the average font family of objects. | 1268 | * Write to style_res the average font family of objects. |
298 | 1270 | */ | 1269 | */ |
299 | 1271 | int | 1270 | int |
301 | 1272 | objects_query_fontfamily (GSList *objects, SPStyle *style_res) | 1271 | objects_query_fontfamily (const std::vector<SPItem*> &objects, SPStyle *style_res) |
302 | 1273 | { | 1272 | { |
303 | 1274 | bool different = false; | 1273 | bool different = false; |
304 | 1275 | int texts = 0; | 1274 | int texts = 0; |
305 | @@ -1280,8 +1279,8 @@ | |||
306 | 1280 | } | 1279 | } |
307 | 1281 | style_res->font_family.set = FALSE; | 1280 | style_res->font_family.set = FALSE; |
308 | 1282 | 1281 | ||
311 | 1283 | for (GSList const *i = objects; i != NULL; i = i->next) { | 1282 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
312 | 1284 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 1283 | SPObject *obj = *i; |
313 | 1285 | 1284 | ||
314 | 1286 | // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl; | 1285 | // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl; |
315 | 1287 | if (!isTextualItem(obj)) { | 1286 | if (!isTextualItem(obj)) { |
316 | @@ -1325,7 +1324,7 @@ | |||
317 | 1325 | } | 1324 | } |
318 | 1326 | 1325 | ||
319 | 1327 | static int | 1326 | static int |
321 | 1328 | objects_query_fontspecification (GSList *objects, SPStyle *style_res) | 1327 | objects_query_fontspecification (const std::vector<SPItem*> &objects, SPStyle *style_res) |
322 | 1329 | { | 1328 | { |
323 | 1330 | bool different = false; | 1329 | bool different = false; |
324 | 1331 | int texts = 0; | 1330 | int texts = 0; |
325 | @@ -1336,8 +1335,8 @@ | |||
326 | 1336 | } | 1335 | } |
327 | 1337 | style_res->font_specification.set = FALSE; | 1336 | style_res->font_specification.set = FALSE; |
328 | 1338 | 1337 | ||
331 | 1339 | for (GSList const *i = objects; i != NULL; i = i->next) { | 1338 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
332 | 1340 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 1339 | SPObject *obj = *i; |
333 | 1341 | 1340 | ||
334 | 1342 | // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl; | 1341 | // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl; |
335 | 1343 | if (!isTextualItem(obj)) { | 1342 | if (!isTextualItem(obj)) { |
336 | @@ -1385,7 +1384,7 @@ | |||
337 | 1385 | } | 1384 | } |
338 | 1386 | 1385 | ||
339 | 1387 | static int | 1386 | static int |
341 | 1388 | objects_query_blend (GSList *objects, SPStyle *style_res) | 1387 | objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res) |
342 | 1389 | { | 1388 | { |
343 | 1390 | const int empty_prev = -2; | 1389 | const int empty_prev = -2; |
344 | 1391 | const int complex_filter = 5; | 1390 | const int complex_filter = 5; |
345 | @@ -1394,8 +1393,8 @@ | |||
346 | 1394 | bool same_blend = true; | 1393 | bool same_blend = true; |
347 | 1395 | guint items = 0; | 1394 | guint items = 0; |
348 | 1396 | 1395 | ||
351 | 1397 | for (GSList const *i = objects; i != NULL; i = i->next) { | 1396 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
352 | 1398 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 1397 | SPObject *obj = *i; |
353 | 1399 | if (!obj) { | 1398 | if (!obj) { |
354 | 1400 | continue; | 1399 | continue; |
355 | 1401 | } | 1400 | } |
356 | @@ -1471,9 +1470,9 @@ | |||
357 | 1471 | * Write to style_res the average blurring of a list of objects. | 1470 | * Write to style_res the average blurring of a list of objects. |
358 | 1472 | */ | 1471 | */ |
359 | 1473 | int | 1472 | int |
361 | 1474 | objects_query_blur (GSList *objects, SPStyle *style_res) | 1473 | objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res) |
362 | 1475 | { | 1474 | { |
364 | 1476 | if (g_slist_length(objects) == 0) { | 1475 | if (objects.empty()) { |
365 | 1477 | /* No objects, set empty */ | 1476 | /* No objects, set empty */ |
366 | 1478 | return QUERY_STYLE_NOTHING; | 1477 | return QUERY_STYLE_NOTHING; |
367 | 1479 | } | 1478 | } |
368 | @@ -1484,8 +1483,8 @@ | |||
369 | 1484 | guint blur_items = 0; | 1483 | guint blur_items = 0; |
370 | 1485 | guint items = 0; | 1484 | guint items = 0; |
371 | 1486 | 1485 | ||
374 | 1487 | for (GSList const *i = objects; i != NULL; i = i->next) { | 1486 | for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
375 | 1488 | SPObject *obj = reinterpret_cast<SPObject *>(i->data); | 1487 | SPObject *obj = *i; |
376 | 1489 | if (!obj) { | 1488 | if (!obj) { |
377 | 1490 | continue; | 1489 | continue; |
378 | 1491 | } | 1490 | } |
379 | @@ -1553,7 +1552,7 @@ | |||
380 | 1553 | * the result to style, return appropriate flag. | 1552 | * the result to style, return appropriate flag. |
381 | 1554 | */ | 1553 | */ |
382 | 1555 | int | 1554 | int |
384 | 1556 | sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property) | 1555 | sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *style, int property) |
385 | 1557 | { | 1556 | { |
386 | 1558 | if (property == QUERY_STYLE_PROPERTY_FILL) { | 1557 | if (property == QUERY_STYLE_PROPERTY_FILL) { |
387 | 1559 | return objects_query_fillstroke (list, style, true); | 1558 | return objects_query_fillstroke (list, style, true); |
388 | @@ -1606,7 +1605,7 @@ | |||
389 | 1606 | 1605 | ||
390 | 1607 | // otherwise, do querying and averaging over selection | 1606 | // otherwise, do querying and averaging over selection |
391 | 1608 | if (desktop->selection != NULL) { | 1607 | if (desktop->selection != NULL) { |
393 | 1609 | return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property); | 1608 | return sp_desktop_query_style_from_list (desktop->selection->itemList(), style, property); |
394 | 1610 | } | 1609 | } |
395 | 1611 | 1610 | ||
396 | 1612 | return QUERY_STYLE_NOTHING; | 1611 | return QUERY_STYLE_NOTHING; |
397 | 1613 | 1612 | ||
398 | === modified file 'src/desktop-style.h' | |||
399 | --- src/desktop-style.h 2014-10-08 02:22:03 +0000 | |||
400 | +++ src/desktop-style.h 2015-04-29 21:03:59 +0000 | |||
401 | @@ -17,6 +17,7 @@ | |||
402 | 17 | class SPCSSAttr; | 17 | class SPCSSAttr; |
403 | 18 | class SPDesktop; | 18 | class SPDesktop; |
404 | 19 | class SPObject; | 19 | class SPObject; |
405 | 20 | class SPItem; | ||
406 | 20 | class SPStyle; | 21 | class SPStyle; |
407 | 21 | typedef struct _GSList GSList; | 22 | typedef struct _GSList GSList; |
408 | 22 | namespace Inkscape { | 23 | namespace Inkscape { |
409 | @@ -64,21 +65,21 @@ | |||
410 | 64 | double sp_desktop_get_font_size_tool (SPDesktop *desktop); | 65 | double sp_desktop_get_font_size_tool (SPDesktop *desktop); |
411 | 65 | void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool, bool with_text); | 66 | void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool, bool with_text); |
412 | 66 | 67 | ||
428 | 67 | gdouble stroke_average_width (GSList const *objects); | 68 | gdouble stroke_average_width (const std::vector<SPItem*> &objects); |
429 | 68 | 69 | ||
430 | 69 | int objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill); | 70 | int objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_res, bool const isfill); |
431 | 70 | int objects_query_fontnumbers (GSList *objects, SPStyle *style_res); | 71 | int objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_res); |
432 | 71 | int objects_query_fontstyle (GSList *objects, SPStyle *style_res); | 72 | int objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res); |
433 | 72 | int objects_query_fontfamily (GSList *objects, SPStyle *style_res); | 73 | int objects_query_fontfamily (const std::vector<SPItem*> &objects, SPStyle *style_res); |
434 | 73 | int objects_query_opacity (GSList *objects, SPStyle *style_res); | 74 | int objects_query_opacity (const std::vector<SPItem*> &objects, SPStyle *style_res); |
435 | 74 | int objects_query_strokewidth (GSList *objects, SPStyle *style_res); | 75 | int objects_query_strokewidth (const std::vector<SPItem*> &objects, SPStyle *style_res); |
436 | 75 | int objects_query_miterlimit (GSList *objects, SPStyle *style_res); | 76 | int objects_query_miterlimit (const std::vector<SPItem*> &objects, SPStyle *style_res); |
437 | 76 | int objects_query_strokecap (GSList *objects, SPStyle *style_res); | 77 | int objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res); |
438 | 77 | int objects_query_strokejoin (GSList *objects, SPStyle *style_res); | 78 | int objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_res); |
439 | 78 | 79 | ||
440 | 79 | int objects_query_blur (GSList *objects, SPStyle *style_res); | 80 | int objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res); |
441 | 80 | 81 | ||
442 | 81 | int sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property); | 82 | int sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *style, int property); |
443 | 82 | int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property); | 83 | int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property); |
444 | 83 | bool sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query); | 84 | bool sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query); |
445 | 84 | 85 | ||
446 | 85 | 86 | ||
447 | === modified file 'src/desktop.cpp' | |||
448 | --- src/desktop.cpp 2015-02-25 01:04:28 +0000 | |||
449 | +++ src/desktop.cpp 2015-04-29 21:03:59 +0000 | |||
450 | @@ -716,7 +716,7 @@ | |||
451 | 716 | /** | 716 | /** |
452 | 717 | * \see SPDocument::getItemFromListAtPointBottom() | 717 | * \see SPDocument::getItemFromListAtPointBottom() |
453 | 718 | */ | 718 | */ |
455 | 719 | SPItem *SPDesktop::getItemFromListAtPointBottom(const GSList *list, Geom::Point const &p) const | 719 | SPItem *SPDesktop::getItemFromListAtPointBottom(const std::vector<SPItem*> &list, Geom::Point const &p) const |
456 | 720 | { | 720 | { |
457 | 721 | g_return_val_if_fail (doc() != NULL, NULL); | 721 | g_return_val_if_fail (doc() != NULL, NULL); |
458 | 722 | return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p); | 722 | return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p); |
459 | 723 | 723 | ||
460 | === modified file 'src/desktop.h' | |||
461 | --- src/desktop.h 2014-12-21 21:58:32 +0000 | |||
462 | +++ src/desktop.h 2015-04-29 21:03:59 +0000 | |||
463 | @@ -319,7 +319,7 @@ | |||
464 | 319 | //void push_event_context (GType type, const gchar *config, unsigned int key); | 319 | //void push_event_context (GType type, const gchar *config, unsigned int key); |
465 | 320 | 320 | ||
466 | 321 | void set_coordinate_status (Geom::Point p); | 321 | void set_coordinate_status (Geom::Point p); |
468 | 322 | SPItem *getItemFromListAtPointBottom(const GSList *list, Geom::Point const &p) const; | 322 | SPItem *getItemFromListAtPointBottom(const std::vector<SPItem*> &list, Geom::Point const &p) const; |
469 | 323 | SPItem *getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; | 323 | SPItem *getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; |
470 | 324 | SPItem *getGroupAtPoint(Geom::Point const &p) const; | 324 | SPItem *getGroupAtPoint(Geom::Point const &p) const; |
471 | 325 | Geom::Point point() const; | 325 | Geom::Point point() const; |
472 | 326 | 326 | ||
473 | === modified file 'src/document.cpp' | |||
474 | --- src/document.cpp 2015-03-21 11:41:01 +0000 | |||
475 | +++ src/document.cpp 2015-04-29 21:03:59 +0000 | |||
476 | @@ -1266,7 +1266,7 @@ | |||
477 | 1266 | return area.intersects(box); | 1266 | return area.intersects(box); |
478 | 1267 | } | 1267 | } |
479 | 1268 | 1268 | ||
481 | 1269 | static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, Geom::Rect const &area, | 1269 | static std::vector<SPItem*> &find_items_in_area(std::vector<SPItem*> &s, SPGroup *group, unsigned int dkey, Geom::Rect const &area, |
482 | 1270 | bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false) | 1270 | bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false) |
483 | 1271 | { | 1271 | { |
484 | 1272 | g_return_val_if_fail(SP_IS_GROUP(group), s); | 1272 | g_return_val_if_fail(SP_IS_GROUP(group), s); |
485 | @@ -1279,7 +1279,7 @@ | |||
486 | 1279 | SPItem *child = SP_ITEM(o); | 1279 | SPItem *child = SP_ITEM(o); |
487 | 1280 | Geom::OptRect box = child->desktopVisualBounds(); | 1280 | Geom::OptRect box = child->desktopVisualBounds(); |
488 | 1281 | if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { | 1281 | if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { |
490 | 1282 | s = g_slist_append(s, child); | 1282 | s.push_back(child); |
491 | 1283 | } | 1283 | } |
492 | 1284 | } | 1284 | } |
493 | 1285 | } | 1285 | } |
494 | @@ -1306,7 +1306,7 @@ | |||
495 | 1306 | return inGroup; | 1306 | return inGroup; |
496 | 1307 | } | 1307 | } |
497 | 1308 | 1308 | ||
499 | 1309 | SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const &p, bool take_insensitive) | 1309 | SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, std::vector<SPItem*> const &list,Geom::Point const &p, bool take_insensitive) |
500 | 1310 | { | 1310 | { |
501 | 1311 | g_return_val_if_fail(group, NULL); | 1311 | g_return_val_if_fail(group, NULL); |
502 | 1312 | SPItem *bottomMost = 0; | 1312 | SPItem *bottomMost = 0; |
503 | @@ -1320,7 +1320,7 @@ | |||
504 | 1320 | Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey); | 1320 | Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey); |
505 | 1321 | if (arenaitem && arenaitem->pick(p, delta, 1) != NULL | 1321 | if (arenaitem && arenaitem->pick(p, delta, 1) != NULL |
506 | 1322 | && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { | 1322 | && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { |
508 | 1323 | if (g_slist_find((GSList *) list, item) != NULL) { | 1323 | if (find(list.begin(),list.end(),item)!=list.end() ) { |
509 | 1324 | bottomMost = item; | 1324 | bottomMost = item; |
510 | 1325 | } | 1325 | } |
511 | 1326 | } | 1326 | } |
512 | @@ -1422,11 +1422,11 @@ | |||
513 | 1422 | * Assumes box is normalized (and g_asserts it!) | 1422 | * Assumes box is normalized (and g_asserts it!) |
514 | 1423 | * | 1423 | * |
515 | 1424 | */ | 1424 | */ |
517 | 1425 | GSList *SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const | 1425 | std::vector<SPItem*> SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const |
518 | 1426 | { | 1426 | { |
522 | 1427 | g_return_val_if_fail(this->priv != NULL, NULL); | 1427 | std::vector<SPItem*> x; |
523 | 1428 | 1428 | g_return_val_if_fail(this->priv != NULL, x); | |
524 | 1429 | return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, is_within); | 1429 | return find_items_in_area(x, SP_GROUP(this->root), dkey, box, is_within); |
525 | 1430 | } | 1430 | } |
526 | 1431 | 1431 | ||
527 | 1432 | /* | 1432 | /* |
528 | @@ -1436,16 +1436,16 @@ | |||
529 | 1436 | * | 1436 | * |
530 | 1437 | */ | 1437 | */ |
531 | 1438 | 1438 | ||
533 | 1439 | GSList *SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const | 1439 | std::vector<SPItem*> SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const |
534 | 1440 | { | 1440 | { |
538 | 1441 | g_return_val_if_fail(this->priv != NULL, NULL); | 1441 | std::vector<SPItem*> x; |
539 | 1442 | 1442 | g_return_val_if_fail(this->priv != NULL, x); | |
540 | 1443 | return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, overlaps); | 1443 | return find_items_in_area(x, SP_GROUP(this->root), dkey, box, overlaps); |
541 | 1444 | } | 1444 | } |
542 | 1445 | 1445 | ||
544 | 1446 | GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const | 1446 | std::vector<SPItem*> SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const |
545 | 1447 | { | 1447 | { |
547 | 1448 | GSList *items = NULL; | 1448 | std::vector<SPItem*> items; |
548 | 1449 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 1449 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
549 | 1450 | 1450 | ||
550 | 1451 | // When picking along the path, we don't want small objects close together | 1451 | // When picking along the path, we don't want small objects close together |
551 | @@ -1454,11 +1454,11 @@ | |||
552 | 1454 | gdouble saved_delta = prefs->getDouble("/options/cursortolerance/value", 1.0); | 1454 | gdouble saved_delta = prefs->getDouble("/options/cursortolerance/value", 1.0); |
553 | 1455 | prefs->setDouble("/options/cursortolerance/value", 0.25); | 1455 | prefs->setDouble("/options/cursortolerance/value", 0.25); |
554 | 1456 | 1456 | ||
556 | 1457 | for(unsigned int i = 0; i < points.size(); i++) { | 1457 | for(int i = points.size()-1;i>=0; i--) { |
557 | 1458 | SPItem *item = getItemAtPoint(key, points[i], | 1458 | SPItem *item = getItemAtPoint(key, points[i], |
558 | 1459 | false, NULL); | 1459 | false, NULL); |
561 | 1460 | if (item && !g_slist_find(items, item)) | 1460 | if (item && items.end()==find(items.begin(),items.end(), item)) |
562 | 1461 | items = g_slist_prepend (items, item); | 1461 | items.push_back(item); |
563 | 1462 | } | 1462 | } |
564 | 1463 | 1463 | ||
565 | 1464 | // and now we restore it back | 1464 | // and now we restore it back |
566 | 1465 | 1465 | ||
567 | === modified file 'src/document.h' | |||
568 | --- src/document.h 2015-03-21 11:41:01 +0000 | |||
569 | +++ src/document.h 2015-04-29 21:03:59 +0000 | |||
570 | @@ -232,7 +232,7 @@ | |||
571 | 232 | /** | 232 | /** |
572 | 233 | * Returns the bottommost item from the list which is at the point, or NULL if none. | 233 | * Returns the bottommost item from the list which is at the point, or NULL if none. |
573 | 234 | */ | 234 | */ |
575 | 235 | static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const &p, bool take_insensitive = false); | 235 | static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const std::vector<SPItem*> &list, Geom::Point const &p, bool take_insensitive = false); |
576 | 236 | 236 | ||
577 | 237 | static SPDocument *createDoc(Inkscape::XML::Document *rdoc, char const *uri, | 237 | static SPDocument *createDoc(Inkscape::XML::Document *rdoc, char const *uri, |
578 | 238 | char const *base, char const *name, unsigned int keepalive, | 238 | char const *base, char const *name, unsigned int keepalive, |
579 | @@ -259,10 +259,10 @@ | |||
580 | 259 | bool addResource(char const *key, SPObject *object); | 259 | bool addResource(char const *key, SPObject *object); |
581 | 260 | bool removeResource(char const *key, SPObject *object); | 260 | bool removeResource(char const *key, SPObject *object); |
582 | 261 | const GSList *getResourceList(char const *key) const; | 261 | const GSList *getResourceList(char const *key) const; |
585 | 262 | GSList *getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; | 262 | std::vector<SPItem*> getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; |
586 | 263 | GSList *getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; | 263 | std::vector<SPItem*> getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; |
587 | 264 | SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; | 264 | SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; |
589 | 265 | GSList *getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const; | 265 | std::vector<SPItem*> getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const; |
590 | 266 | SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const; | 266 | SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const; |
591 | 267 | 267 | ||
592 | 268 | void changeUriAndHrefs(char const *uri); | 268 | void changeUriAndHrefs(char const *uri); |
593 | 269 | 269 | ||
594 | === modified file 'src/extension/execution-env.cpp' | |||
595 | --- src/extension/execution-env.cpp 2015-04-27 23:38:31 +0000 | |||
596 | +++ src/extension/execution-env.cpp 2015-04-29 21:03:59 +0000 | |||
597 | @@ -60,14 +60,12 @@ | |||
598 | 60 | sp_namedview_document_from_window(desktop); | 60 | sp_namedview_document_from_window(desktop); |
599 | 61 | 61 | ||
600 | 62 | if (desktop != NULL) { | 62 | if (desktop != NULL) { |
604 | 63 | Inkscape::Util::GSListConstIterator<SPItem *> selected = | 63 | std::vector<SPItem*> selected = desktop->getSelection()->itemList(); |
605 | 64 | desktop->getSelection()->itemList(); | 64 | for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); x++){ |
603 | 65 | while ( selected != NULL ) { | ||
606 | 66 | Glib::ustring selected_id; | 65 | Glib::ustring selected_id; |
608 | 67 | selected_id = (*selected)->getId(); | 66 | selected_id = (*x)->getId(); |
609 | 68 | _selected.insert(_selected.end(), selected_id); | 67 | _selected.insert(_selected.end(), selected_id); |
610 | 69 | //std::cout << "Selected: " << selected_id << std::endl; | 68 | //std::cout << "Selected: " << selected_id << std::endl; |
611 | 70 | ++selected; | ||
612 | 71 | } | 69 | } |
613 | 72 | } | 70 | } |
614 | 73 | 71 | ||
615 | 74 | 72 | ||
616 | === modified file 'src/extension/implementation/implementation.cpp' | |||
617 | --- src/extension/implementation/implementation.cpp 2014-12-21 21:58:32 +0000 | |||
618 | +++ src/extension/implementation/implementation.cpp 2015-04-29 21:03:59 +0000 | |||
619 | @@ -47,12 +47,10 @@ | |||
620 | 47 | 47 | ||
621 | 48 | SPDocument * current_document = view->doc(); | 48 | SPDocument * current_document = view->doc(); |
622 | 49 | 49 | ||
626 | 50 | using Inkscape::Util::GSListConstIterator; | 50 | std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); |
624 | 51 | // FIXME very unsafe cast | ||
625 | 52 | GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList(); | ||
627 | 53 | Inkscape::XML::Node const* first_select = NULL; | 51 | Inkscape::XML::Node const* first_select = NULL; |
630 | 54 | if (selected != NULL) { | 52 | if (!selected.empty()) { |
631 | 55 | const SPItem * item = *selected; | 53 | const SPItem * item = selected[0]; |
632 | 56 | first_select = item->getRepr(); | 54 | first_select = item->getRepr(); |
633 | 57 | } | 55 | } |
634 | 58 | 56 | ||
635 | 59 | 57 | ||
636 | === modified file 'src/extension/implementation/script.cpp' | |||
637 | --- src/extension/implementation/script.cpp 2015-04-27 16:01:19 +0000 | |||
638 | +++ src/extension/implementation/script.cpp 2015-04-29 21:03:59 +0000 | |||
639 | @@ -689,14 +689,13 @@ | |||
640 | 689 | return; | 689 | return; |
641 | 690 | } | 690 | } |
642 | 691 | 691 | ||
644 | 692 | Inkscape::Util::GSListConstIterator<SPItem *> selected = | 692 | std::vector<SPItem*> selected = |
645 | 693 | desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer | 693 | desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer |
647 | 694 | while ( selected != NULL ) { | 694 | for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); x++){ |
648 | 695 | Glib::ustring selected_id; | 695 | Glib::ustring selected_id; |
649 | 696 | selected_id += "--id="; | 696 | selected_id += "--id="; |
651 | 697 | selected_id += (*selected)->getId(); | 697 | selected_id += (*x)->getId(); |
652 | 698 | params.insert(params.begin(), selected_id); | 698 | params.insert(params.begin(), selected_id); |
653 | 699 | ++selected; | ||
654 | 700 | } | 699 | } |
655 | 701 | 700 | ||
656 | 702 | file_listener fileout; | 701 | file_listener fileout; |
657 | 703 | 702 | ||
658 | === modified file 'src/extension/internal/bitmap/imagemagick.cpp' | |||
659 | --- src/extension/internal/bitmap/imagemagick.cpp 2015-04-27 23:38:31 +0000 | |||
660 | +++ src/extension/internal/bitmap/imagemagick.cpp 2015-04-29 21:03:59 +0000 | |||
661 | @@ -66,8 +66,8 @@ | |||
662 | 66 | _imageItems(NULL) | 66 | _imageItems(NULL) |
663 | 67 | { | 67 | { |
664 | 68 | SPDesktop *desktop = (SPDesktop*)view; | 68 | SPDesktop *desktop = (SPDesktop*)view; |
667 | 69 | const GSList *selectedItemList = desktop->selection->itemList(); | 69 | const std::vector<SPItem*> selectedItemList = desktop->selection->itemList(); |
668 | 70 | int selectCount = g_slist_length((GSList *)selectedItemList); | 70 | int selectCount = selectedItemList.size(); |
669 | 71 | 71 | ||
670 | 72 | // Init the data-holders | 72 | // Init the data-holders |
671 | 73 | _nodes = new Inkscape::XML::Node*[selectCount]; | 73 | _nodes = new Inkscape::XML::Node*[selectCount]; |
672 | @@ -79,9 +79,8 @@ | |||
673 | 79 | _imageItems = new SPItem*[selectCount]; | 79 | _imageItems = new SPItem*[selectCount]; |
674 | 80 | 80 | ||
675 | 81 | // Loop through selected items | 81 | // Loop through selected items |
679 | 82 | for (; selectedItemList != NULL; selectedItemList = g_slist_next(selectedItemList)) | 82 | for (std::vector<SPItem*>::const_iterator i = selectedItemList.begin(); i != selectedItemList.end(); i++) { |
680 | 83 | { | 83 | SPItem *item = *i; |
678 | 84 | SPItem *item = SP_ITEM(selectedItemList->data); | ||
681 | 85 | Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(item->getRepr()); | 84 | Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(item->getRepr()); |
682 | 86 | if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) | 85 | if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) |
683 | 87 | { | 86 | { |
684 | @@ -237,13 +236,10 @@ | |||
685 | 237 | { | 236 | { |
686 | 238 | SPDocument * current_document = view->doc(); | 237 | SPDocument * current_document = view->doc(); |
687 | 239 | 238 | ||
692 | 240 | using Inkscape::Util::GSListConstIterator; | 239 | std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); |
689 | 241 | |||
690 | 242 | // FIXME very unsafe cast | ||
691 | 243 | GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList(); | ||
693 | 244 | Inkscape::XML::Node * first_select = NULL; | 240 | Inkscape::XML::Node * first_select = NULL; |
696 | 245 | if (selected != NULL) { | 241 | if (!selected.empty()) { |
697 | 246 | first_select = (*selected)->getRepr(); | 242 | first_select = (selected.front())->getRepr(); |
698 | 247 | } | 243 | } |
699 | 248 | 244 | ||
700 | 249 | return module->autogui(current_document, first_select, changeSignal); | 245 | return module->autogui(current_document, first_select, changeSignal); |
701 | 250 | 246 | ||
702 | === modified file 'src/extension/internal/bluredge.cpp' | |||
703 | --- src/extension/internal/bluredge.cpp 2014-03-27 01:33:44 +0000 | |||
704 | +++ src/extension/internal/bluredge.cpp 2015-04-29 21:03:59 +0000 | |||
705 | @@ -63,13 +63,11 @@ | |||
706 | 63 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 63 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
707 | 64 | double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); | 64 | double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); |
708 | 65 | 65 | ||
709 | 66 | using Inkscape::Util::GSListConstIterator; | ||
710 | 67 | // TODO need to properly refcount the items, at least | 66 | // TODO need to properly refcount the items, at least |
713 | 68 | std::list<SPItem *> items; | 67 | std::vector<SPItem*> items(selection->itemList()); |
712 | 69 | items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL); | ||
714 | 70 | selection->clear(); | 68 | selection->clear(); |
715 | 71 | 69 | ||
717 | 72 | for(std::list<SPItem *>::iterator item = items.begin(); | 70 | for(std::vector<SPItem*>::iterator item = items.begin(); |
718 | 73 | item != items.end(); ++item) { | 71 | item != items.end(); ++item) { |
719 | 74 | SPItem * spitem = *item; | 72 | SPItem * spitem = *item; |
720 | 75 | 73 | ||
721 | 76 | 74 | ||
722 | === modified file 'src/extension/internal/cairo-renderer.cpp' | |||
723 | --- src/extension/internal/cairo-renderer.cpp 2015-03-17 17:09:10 +0000 | |||
724 | +++ src/extension/internal/cairo-renderer.cpp 2015-04-29 21:03:59 +0000 | |||
725 | @@ -294,14 +294,12 @@ | |||
726 | 294 | CairoRenderer *renderer = ctx->getRenderer(); | 294 | CairoRenderer *renderer = ctx->getRenderer(); |
727 | 295 | TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(item->style->opacity.value))); | 295 | TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(item->style->opacity.value))); |
728 | 296 | 296 | ||
733 | 297 | GSList *l = g_slist_reverse(group->childList(false)); | 297 | std::vector<SPObject*> l(group->childList(false)); |
734 | 298 | while (l) { | 298 | for(std::vector<SPObject*>::const_iterator x = l.begin(); x!= l.end(); x++){ |
735 | 299 | SPObject *o = reinterpret_cast<SPObject *>(l->data); | 299 | SPItem *item = static_cast<SPItem*>(*x); |
732 | 300 | SPItem *item = dynamic_cast<SPItem *>(o); | ||
736 | 301 | if (item) { | 300 | if (item) { |
737 | 302 | renderer->renderItem(ctx, item); | 301 | renderer->renderItem(ctx, item); |
738 | 303 | } | 302 | } |
739 | 304 | l = g_slist_remove (l, o); | ||
740 | 305 | } | 303 | } |
741 | 306 | } | 304 | } |
742 | 307 | 305 | ||
743 | 308 | 306 | ||
744 | === modified file 'src/extension/internal/filter/filter.cpp' | |||
745 | --- src/extension/internal/filter/filter.cpp 2014-03-27 01:33:44 +0000 | |||
746 | +++ src/extension/internal/filter/filter.cpp 2015-04-29 21:03:59 +0000 | |||
747 | @@ -125,15 +125,13 @@ | |||
748 | 125 | //printf("Calling filter effect\n"); | 125 | //printf("Calling filter effect\n"); |
749 | 126 | Inkscape::Selection * selection = ((SPDesktop *)document)->selection; | 126 | Inkscape::Selection * selection = ((SPDesktop *)document)->selection; |
750 | 127 | 127 | ||
751 | 128 | using Inkscape::Util::GSListConstIterator; | ||
752 | 129 | // TODO need to properly refcount the items, at least | 128 | // TODO need to properly refcount the items, at least |
755 | 130 | std::list<SPItem *> items; | 129 | std::vector<SPItem*> items(selection->itemList()); |
754 | 131 | items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL); | ||
756 | 132 | 130 | ||
757 | 133 | Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); | 131 | Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); |
758 | 134 | Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); | 132 | Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); |
759 | 135 | 133 | ||
761 | 136 | for(std::list<SPItem *>::iterator item = items.begin(); | 134 | for(std::vector<SPItem*>::iterator item = items.begin(); |
762 | 137 | item != items.end(); ++item) { | 135 | item != items.end(); ++item) { |
763 | 138 | SPItem * spitem = *item; | 136 | SPItem * spitem = *item; |
764 | 139 | Inkscape::XML::Node * node = spitem->getRepr(); | 137 | Inkscape::XML::Node * node = spitem->getRepr(); |
765 | 140 | 138 | ||
766 | === modified file 'src/extension/internal/grid.cpp' | |||
767 | --- src/extension/internal/grid.cpp 2015-04-27 23:38:31 +0000 | |||
768 | +++ src/extension/internal/grid.cpp 2015-04-29 21:03:59 +0000 | |||
769 | @@ -186,13 +186,10 @@ | |||
770 | 186 | { | 186 | { |
771 | 187 | SPDocument * current_document = view->doc(); | 187 | SPDocument * current_document = view->doc(); |
772 | 188 | 188 | ||
777 | 189 | using Inkscape::Util::GSListConstIterator; | 189 | std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); |
774 | 190 | |||
775 | 191 | // FIXME very unsafe cast | ||
776 | 192 | GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList(); | ||
778 | 193 | Inkscape::XML::Node * first_select = NULL; | 190 | Inkscape::XML::Node * first_select = NULL; |
781 | 194 | if (selected != NULL) { | 191 | if (!selected.empty()) { |
782 | 195 | first_select = (*selected)->getRepr(); | 192 | first_select = selected[0]->getRepr(); |
783 | 196 | } | 193 | } |
784 | 197 | 194 | ||
785 | 198 | return module->autogui(current_document, first_select, changeSignal); | 195 | return module->autogui(current_document, first_select, changeSignal); |
786 | 199 | 196 | ||
787 | === modified file 'src/extension/internal/latex-text-renderer.cpp' | |||
788 | --- src/extension/internal/latex-text-renderer.cpp 2014-11-10 17:39:33 +0000 | |||
789 | +++ src/extension/internal/latex-text-renderer.cpp 2015-04-29 21:03:59 +0000 | |||
790 | @@ -228,14 +228,12 @@ | |||
791 | 228 | 228 | ||
792 | 229 | void LaTeXTextRenderer::sp_group_render(SPGroup *group) | 229 | void LaTeXTextRenderer::sp_group_render(SPGroup *group) |
793 | 230 | { | 230 | { |
798 | 231 | GSList *l = g_slist_reverse(group->childList(false)); | 231 | std::vector<SPObject*> l = (group->childList(false)); |
799 | 232 | while (l) { | 232 | for(std::vector<SPObject*>::const_iterator x = l.begin(); x != l.end(); x++){ |
800 | 233 | SPObject *o = reinterpret_cast<SPObject *>(l->data); | 233 | SPItem *item = static_cast<SPItem*>(*x); |
797 | 234 | SPItem *item = dynamic_cast<SPItem *>(o); | ||
801 | 235 | if (item) { | 234 | if (item) { |
802 | 236 | renderItem(item); | 235 | renderItem(item); |
803 | 237 | } | 236 | } |
804 | 238 | l = g_slist_remove (l, o); | ||
805 | 239 | } | 237 | } |
806 | 240 | } | 238 | } |
807 | 241 | 239 | ||
808 | 242 | 240 | ||
809 | === modified file 'src/file.cpp' | |||
810 | --- src/file.cpp 2015-02-23 16:48:29 +0000 | |||
811 | +++ src/file.cpp 2015-04-29 21:03:59 +0000 | |||
812 | @@ -1069,7 +1069,7 @@ | |||
813 | 1069 | desktop->doc()->importDefs(clipdoc); | 1069 | desktop->doc()->importDefs(clipdoc); |
814 | 1070 | 1070 | ||
815 | 1071 | // copy objects | 1071 | // copy objects |
817 | 1072 | GSList *pasted_objects = NULL; | 1072 | std::vector<Inkscape::XML::Node*> pasted_objects; |
818 | 1073 | for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) { | 1073 | for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) { |
819 | 1074 | // Don't copy metadata, defs, named views and internal clipboard contents to the document | 1074 | // Don't copy metadata, defs, named views and internal clipboard contents to the document |
820 | 1075 | if (!strcmp(obj->name(), "svg:defs")) { | 1075 | if (!strcmp(obj->name(), "svg:defs")) { |
821 | @@ -1088,9 +1088,8 @@ | |||
822 | 1088 | target_parent->appendChild(obj_copy); | 1088 | target_parent->appendChild(obj_copy); |
823 | 1089 | Inkscape::GC::release(obj_copy); | 1089 | Inkscape::GC::release(obj_copy); |
824 | 1090 | 1090 | ||
826 | 1091 | pasted_objects = g_slist_prepend(pasted_objects, (gpointer) obj_copy); | 1091 | pasted_objects.push_back(obj_copy); |
827 | 1092 | } | 1092 | } |
828 | 1093 | |||
829 | 1094 | // Change the selection to the freshly pasted objects | 1093 | // Change the selection to the freshly pasted objects |
830 | 1095 | Inkscape::Selection *selection = desktop->getSelection(); | 1094 | Inkscape::Selection *selection = desktop->getSelection(); |
831 | 1096 | selection->setReprList(pasted_objects); | 1095 | selection->setReprList(pasted_objects); |
832 | @@ -1129,8 +1128,6 @@ | |||
833 | 1129 | 1128 | ||
834 | 1130 | sp_selection_move_relative(selection, offset); | 1129 | sp_selection_move_relative(selection, offset); |
835 | 1131 | } | 1130 | } |
836 | 1132 | |||
837 | 1133 | g_slist_free(pasted_objects); | ||
838 | 1134 | } | 1131 | } |
839 | 1135 | 1132 | ||
840 | 1136 | 1133 | ||
841 | 1137 | 1134 | ||
842 | === modified file 'src/gradient-chemistry.cpp' | |||
843 | --- src/gradient-chemistry.cpp 2015-03-01 08:57:53 +0000 | |||
844 | +++ src/gradient-chemistry.cpp 2015-04-29 21:03:59 +0000 | |||
845 | @@ -1570,8 +1570,9 @@ | |||
846 | 1570 | { | 1570 | { |
847 | 1571 | Inkscape::Selection *selection = desktop->getSelection(); | 1571 | Inkscape::Selection *selection = desktop->getSelection(); |
848 | 1572 | 1572 | ||
851 | 1573 | for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { | 1573 | const std::vector<SPItem*> list=selection->itemList(); |
852 | 1574 | sp_item_gradient_invert_vector_color(SP_ITEM(i->data), fill_or_stroke); | 1574 | for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { |
853 | 1575 | sp_item_gradient_invert_vector_color(*i, fill_or_stroke); | ||
854 | 1575 | } | 1576 | } |
855 | 1576 | 1577 | ||
856 | 1577 | // we did an undoable action | 1578 | // we did an undoable action |
857 | @@ -1594,9 +1595,10 @@ | |||
858 | 1594 | if (drag && drag->selected) { | 1595 | if (drag && drag->selected) { |
859 | 1595 | drag->selected_reverse_vector(); | 1596 | drag->selected_reverse_vector(); |
860 | 1596 | } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) | 1597 | } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) |
864 | 1597 | for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { | 1598 | const std::vector<SPItem*> list=selection->itemList(); |
865 | 1598 | sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL); | 1599 | for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { |
866 | 1599 | sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE); | 1600 | sp_item_gradient_reverse_vector(*i, Inkscape::FOR_FILL); |
867 | 1601 | sp_item_gradient_reverse_vector(*i, Inkscape::FOR_STROKE); | ||
868 | 1600 | } | 1602 | } |
869 | 1601 | } | 1603 | } |
870 | 1602 | 1604 | ||
871 | 1603 | 1605 | ||
872 | === modified file 'src/gradient-drag.cpp' | |||
873 | --- src/gradient-drag.cpp 2015-03-01 08:57:53 +0000 | |||
874 | +++ src/gradient-drag.cpp 2015-04-29 21:03:59 +0000 | |||
875 | @@ -2082,9 +2082,9 @@ | |||
876 | 2082 | this->draggers = NULL; | 2082 | this->draggers = NULL; |
877 | 2083 | 2083 | ||
878 | 2084 | g_return_if_fail(this->selection != NULL); | 2084 | g_return_if_fail(this->selection != NULL); |
882 | 2085 | 2085 | std::vector<SPItem*> list = this->selection->itemList(); | |
883 | 2086 | for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { | 2086 | for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { |
884 | 2087 | SPItem *item = SP_ITEM(i->data); | 2087 | SPItem *item = *i; |
885 | 2088 | SPStyle *style = item->style; | 2088 | SPStyle *style = item->style; |
886 | 2089 | 2089 | ||
887 | 2090 | if (style && (style->fill.isPaintserver())) { | 2090 | if (style && (style->fill.isPaintserver())) { |
888 | @@ -2151,9 +2151,9 @@ | |||
889 | 2151 | 2151 | ||
890 | 2152 | g_return_if_fail(this->selection != NULL); | 2152 | g_return_if_fail(this->selection != NULL); |
891 | 2153 | 2153 | ||
895 | 2154 | for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { | 2154 | std::vector<SPItem*> list = this->selection->itemList(); |
896 | 2155 | 2155 | for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { | |
897 | 2156 | SPItem *item = SP_ITEM(i->data); | 2156 | SPItem *item = *i; |
898 | 2157 | 2157 | ||
899 | 2158 | SPStyle *style = item->style; | 2158 | SPStyle *style = item->style; |
900 | 2159 | 2159 | ||
901 | @@ -2295,8 +2295,9 @@ | |||
902 | 2295 | 2295 | ||
903 | 2296 | g_return_if_fail (this->selection != NULL); | 2296 | g_return_if_fail (this->selection != NULL); |
904 | 2297 | 2297 | ||
907 | 2298 | for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { | 2298 | std::vector<SPItem*> list = this->selection->itemList(); |
908 | 2299 | SPItem *item = SP_ITEM(i->data); | 2299 | for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { |
909 | 2300 | SPItem *item = *i; | ||
910 | 2300 | Geom::OptRect rect = item->desktopVisualBounds(); | 2301 | Geom::OptRect rect = item->desktopVisualBounds(); |
911 | 2301 | if (rect) { | 2302 | if (rect) { |
912 | 2302 | // Remember the edges of the bbox and the center axis | 2303 | // Remember the edges of the bbox and the center axis |
913 | 2303 | 2304 | ||
914 | === modified file 'src/graphlayout.cpp' | |||
915 | --- src/graphlayout.cpp 2014-11-26 01:35:57 +0000 | |||
916 | +++ src/graphlayout.cpp 2015-04-29 21:03:59 +0000 | |||
917 | @@ -88,9 +88,9 @@ | |||
918 | 88 | * Scans the items list and places those items that are | 88 | * Scans the items list and places those items that are |
919 | 89 | * not connectors in filtered | 89 | * not connectors in filtered |
920 | 90 | */ | 90 | */ |
924 | 91 | void filterConnectors(GSList const *const items, list<SPItem *> &filtered) { | 91 | void filterConnectors(std::vector<SPItem*> const &items, list<SPItem *> &filtered) { |
925 | 92 | for(GSList *i=(GSList *)items; i!=NULL; i=i->next) { | 92 | for(std::vector<SPItem*>::const_iterator i = items.begin();i !=items.end(); i++){ |
926 | 93 | SPItem *item=SP_ITEM(i->data); | 93 | SPItem *item = *i; |
927 | 94 | if(!isConnector(item)) { | 94 | if(!isConnector(item)) { |
928 | 95 | filtered.push_back(item); | 95 | filtered.push_back(item); |
929 | 96 | } | 96 | } |
930 | @@ -101,8 +101,8 @@ | |||
931 | 101 | * connectors between them, and uses graph layout techniques to find | 101 | * connectors between them, and uses graph layout techniques to find |
932 | 102 | * a nice layout | 102 | * a nice layout |
933 | 103 | */ | 103 | */ |
936 | 104 | void graphlayout(GSList const *const items) { | 104 | void graphlayout(std::vector<SPItem*> const &items) { |
937 | 105 | if(!items) { | 105 | if(items.empty()) { |
938 | 106 | return; | 106 | return; |
939 | 107 | } | 107 | } |
940 | 108 | 108 | ||
941 | 109 | 109 | ||
942 | === modified file 'src/graphlayout.h' | |||
943 | --- src/graphlayout.h 2014-10-08 02:22:03 +0000 | |||
944 | +++ src/graphlayout.h 2015-04-29 21:03:59 +0000 | |||
945 | @@ -19,10 +19,10 @@ | |||
946 | 19 | typedef struct _GSList GSList; | 19 | typedef struct _GSList GSList; |
947 | 20 | class SPItem; | 20 | class SPItem; |
948 | 21 | 21 | ||
950 | 22 | void graphlayout(GSList const *const items); | 22 | void graphlayout(std::vector<SPItem*> const &items); |
951 | 23 | 23 | ||
952 | 24 | bool isConnector(SPItem const *const item); | 24 | bool isConnector(SPItem const *const item); |
953 | 25 | 25 | ||
955 | 26 | void filterConnectors(GSList const *const items, std::list<SPItem *> &filtered); | 26 | void filterConnectors(std::vector<SPItem*> const &items, std::list<SPItem *> &filtered); |
956 | 27 | 27 | ||
957 | 28 | #endif // SEEN_GRAPHLAYOUT_H | 28 | #endif // SEEN_GRAPHLAYOUT_H |
958 | 29 | 29 | ||
959 | === modified file 'src/helper/png-write.cpp' | |||
960 | --- src/helper/png-write.cpp 2014-10-05 16:38:15 +0000 | |||
961 | +++ src/helper/png-write.cpp 2015-04-29 21:03:59 +0000 | |||
962 | @@ -361,19 +361,19 @@ | |||
963 | 361 | /** | 361 | /** |
964 | 362 | * Hide all items that are not listed in list, recursively, skipping groups and defs. | 362 | * Hide all items that are not listed in list, recursively, skipping groups and defs. |
965 | 363 | */ | 363 | */ |
967 | 364 | static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) | 364 | static void hide_other_items_recursively(SPObject *o, const std::vector<SPItem*> &list, unsigned dkey) |
968 | 365 | { | 365 | { |
969 | 366 | if ( SP_IS_ITEM(o) | 366 | if ( SP_IS_ITEM(o) |
970 | 367 | && !SP_IS_DEFS(o) | 367 | && !SP_IS_DEFS(o) |
971 | 368 | && !SP_IS_ROOT(o) | 368 | && !SP_IS_ROOT(o) |
972 | 369 | && !SP_IS_GROUP(o) | 369 | && !SP_IS_GROUP(o) |
974 | 370 | && !g_slist_find(list, o) ) | 370 | && list.end()==find(list.begin(),list.end(),o)) |
975 | 371 | { | 371 | { |
976 | 372 | SP_ITEM(o)->invoke_hide(dkey); | 372 | SP_ITEM(o)->invoke_hide(dkey); |
977 | 373 | } | 373 | } |
978 | 374 | 374 | ||
979 | 375 | // recurse | 375 | // recurse |
981 | 376 | if (!g_slist_find(list, o)) { | 376 | if (list.end()==find(list.begin(),list.end(),o)) { |
982 | 377 | for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) { | 377 | for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) { |
983 | 378 | hide_other_items_recursively(child, list, dkey); | 378 | hide_other_items_recursively(child, list, dkey); |
984 | 379 | } | 379 | } |
985 | @@ -387,7 +387,7 @@ | |||
986 | 387 | unsigned long bgcolor, | 387 | unsigned long bgcolor, |
987 | 388 | unsigned int (*status) (float, void *), | 388 | unsigned int (*status) (float, void *), |
988 | 389 | void *data, bool force_overwrite, | 389 | void *data, bool force_overwrite, |
990 | 390 | GSList *items_only) | 390 | const std::vector<SPItem*> &items_only) |
991 | 391 | { | 391 | { |
992 | 392 | return sp_export_png_file(doc, filename, Geom::Rect(Geom::Point(x0,y0),Geom::Point(x1,y1)), | 392 | return sp_export_png_file(doc, filename, Geom::Rect(Geom::Point(x0,y0),Geom::Point(x1,y1)), |
993 | 393 | width, height, xdpi, ydpi, bgcolor, status, data, force_overwrite, items_only); | 393 | width, height, xdpi, ydpi, bgcolor, status, data, force_overwrite, items_only); |
994 | @@ -399,7 +399,7 @@ | |||
995 | 399 | unsigned long bgcolor, | 399 | unsigned long bgcolor, |
996 | 400 | unsigned (*status)(float, void *), | 400 | unsigned (*status)(float, void *), |
997 | 401 | void *data, bool force_overwrite, | 401 | void *data, bool force_overwrite, |
999 | 402 | GSList *items_only) | 402 | const std::vector<SPItem*> &items_only) |
1000 | 403 | { | 403 | { |
1001 | 404 | g_return_val_if_fail(doc != NULL, EXPORT_ERROR); | 404 | g_return_val_if_fail(doc != NULL, EXPORT_ERROR); |
1002 | 405 | g_return_val_if_fail(filename != NULL, EXPORT_ERROR); | 405 | g_return_val_if_fail(filename != NULL, EXPORT_ERROR); |
1003 | @@ -457,7 +457,7 @@ | |||
1004 | 457 | 457 | ||
1005 | 458 | // We show all and then hide all items we don't want, instead of showing only requested items, | 458 | // We show all and then hide all items we don't want, instead of showing only requested items, |
1006 | 459 | // because that would not work if the shown item references something in defs | 459 | // because that would not work if the shown item references something in defs |
1008 | 460 | if (items_only) { | 460 | if (!items_only.empty()) { |
1009 | 461 | hide_other_items_recursively(doc->getRoot(), items_only, dkey); | 461 | hide_other_items_recursively(doc->getRoot(), items_only, dkey); |
1010 | 462 | } | 462 | } |
1011 | 463 | 463 | ||
1012 | 464 | 464 | ||
1013 | === modified file 'src/helper/png-write.h' | |||
1014 | --- src/helper/png-write.h 2014-03-27 01:33:44 +0000 | |||
1015 | +++ src/helper/png-write.h 2015-04-29 21:03:59 +0000 | |||
1016 | @@ -14,8 +14,9 @@ | |||
1017 | 14 | * Released under GNU GPL, read the file 'COPYING' for more information | 14 | * Released under GNU GPL, read the file 'COPYING' for more information |
1018 | 15 | */ | 15 | */ |
1019 | 16 | 16 | ||
1020 | 17 | #include <glib.h> | ||
1021 | 18 | #include <2geom/forward.h> | 17 | #include <2geom/forward.h> |
1022 | 18 | |||
1023 | 19 | |||
1024 | 19 | class SPDocument; | 20 | class SPDocument; |
1025 | 20 | 21 | ||
1026 | 21 | enum ExportResult { | 22 | enum ExportResult { |
1027 | @@ -33,12 +34,12 @@ | |||
1028 | 33 | double x0, double y0, double x1, double y1, | 34 | double x0, double y0, double x1, double y1, |
1029 | 34 | unsigned long int width, unsigned long int height, double xdpi, double ydpi, | 35 | unsigned long int width, unsigned long int height, double xdpi, double ydpi, |
1030 | 35 | unsigned long bgcolor, | 36 | unsigned long bgcolor, |
1032 | 36 | unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, GSList *items_only = NULL); | 37 | unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>()); |
1033 | 37 | 38 | ||
1034 | 38 | ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, | 39 | ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, |
1035 | 39 | Geom::Rect const &area, | 40 | Geom::Rect const &area, |
1036 | 40 | unsigned long int width, unsigned long int height, double xdpi, double ydpi, | 41 | unsigned long int width, unsigned long int height, double xdpi, double ydpi, |
1037 | 41 | unsigned long bgcolor, | 42 | unsigned long bgcolor, |
1039 | 42 | unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, GSList *items_only = NULL); | 43 | unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>()); |
1040 | 43 | 44 | ||
1041 | 44 | #endif // SEEN_SP_PNG_WRITE_H | 45 | #endif // SEEN_SP_PNG_WRITE_H |
1042 | 45 | 46 | ||
1043 | === modified file 'src/live_effects/lpe-knot.cpp' | |||
1044 | --- src/live_effects/lpe-knot.cpp 2015-03-08 16:10:20 +0000 | |||
1045 | +++ src/live_effects/lpe-knot.cpp 2015-04-29 21:03:59 +0000 | |||
1046 | @@ -505,9 +505,9 @@ | |||
1047 | 505 | static void | 505 | static void |
1048 | 506 | collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &paths, std::vector<double> &stroke_widths){ | 506 | collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &paths, std::vector<double> &stroke_widths){ |
1049 | 507 | if (SP_IS_GROUP(lpeitem)) { | 507 | if (SP_IS_GROUP(lpeitem)) { |
1053 | 508 | GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); | 508 | std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); |
1054 | 509 | for ( GSList const *iter = item_list; iter; iter = iter->next ) { | 509 | for ( std::vector<SPItem*>::const_iterator iter = item_list.begin(); iter != item_list.end(); iter++) { |
1055 | 510 | SPObject *subitem = static_cast<SPObject *>(iter->data); | 510 | SPObject *subitem = *iter; |
1056 | 511 | if (SP_IS_LPE_ITEM(subitem)) { | 511 | if (SP_IS_LPE_ITEM(subitem)) { |
1057 | 512 | collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths); | 512 | collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths); |
1058 | 513 | } | 513 | } |
1059 | 514 | 514 | ||
1060 | === modified file 'src/main.cpp' | |||
1061 | --- src/main.cpp 2015-02-26 02:49:35 +0000 | |||
1062 | +++ src/main.cpp 2015-04-29 21:03:59 +0000 | |||
1063 | @@ -1156,7 +1156,7 @@ | |||
1064 | 1156 | } | 1156 | } |
1065 | 1157 | if (sp_export_svg) { | 1157 | if (sp_export_svg) { |
1066 | 1158 | if (sp_export_text_to_path) { | 1158 | if (sp_export_text_to_path) { |
1068 | 1159 | GSList *items = NULL; | 1159 | std::vector<SPItem*> items; |
1069 | 1160 | SPRoot *root = doc->getRoot(); | 1160 | SPRoot *root = doc->getRoot(); |
1070 | 1161 | doc->ensureUpToDate(); | 1161 | doc->ensureUpToDate(); |
1071 | 1162 | for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) { | 1162 | for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) { |
1072 | @@ -1166,17 +1166,14 @@ | |||
1073 | 1166 | } | 1166 | } |
1074 | 1167 | 1167 | ||
1075 | 1168 | te_update_layout_now_recursive(item); | 1168 | te_update_layout_now_recursive(item); |
1077 | 1169 | items = g_slist_append(items, item); | 1169 | items.push_back(item); |
1078 | 1170 | } | 1170 | } |
1079 | 1171 | 1171 | ||
1088 | 1172 | GSList *selected = NULL; | 1172 | std::vector<SPItem*> selected; |
1089 | 1173 | GSList *to_select = NULL; | 1173 | std::vector<Inkscape::XML::Node*> to_select; |
1090 | 1174 | 1174 | ||
1091 | 1175 | sp_item_list_to_curves(items, &selected, &to_select); | 1175 | sp_item_list_to_curves(items, selected, to_select); |
1092 | 1176 | 1176 | ||
1085 | 1177 | g_slist_free (items); | ||
1086 | 1178 | g_slist_free (selected); | ||
1087 | 1179 | g_slist_free (to_select); | ||
1093 | 1180 | } | 1177 | } |
1094 | 1181 | if(sp_export_id) { | 1178 | if(sp_export_id) { |
1095 | 1182 | doc->ensureUpToDate(); | 1179 | doc->ensureUpToDate(); |
1096 | @@ -1435,7 +1432,7 @@ | |||
1097 | 1435 | g_warning ("--export-use-hints can only be used with --export-id or --export-area-drawing; ignored."); | 1432 | g_warning ("--export-use-hints can only be used with --export-id or --export-area-drawing; ignored."); |
1098 | 1436 | } | 1433 | } |
1099 | 1437 | 1434 | ||
1101 | 1438 | GSList *items = NULL; | 1435 | std::vector<SPItem*> items; |
1102 | 1439 | 1436 | ||
1103 | 1440 | Geom::Rect area; | 1437 | Geom::Rect area; |
1104 | 1441 | if (sp_export_id || sp_export_area_drawing) { | 1438 | if (sp_export_id || sp_export_area_drawing) { |
1105 | @@ -1459,7 +1456,7 @@ | |||
1106 | 1459 | return 1; | 1456 | return 1; |
1107 | 1460 | } | 1457 | } |
1108 | 1461 | 1458 | ||
1110 | 1462 | items = g_slist_prepend (items, SP_ITEM(o)); | 1459 | items.push_back(SP_ITEM(o)); |
1111 | 1463 | 1460 | ||
1112 | 1464 | if (sp_export_id_only) { | 1461 | if (sp_export_id_only) { |
1113 | 1465 | g_print("Exporting only object with id=\"%s\"; all other objects hidden\n", sp_export_id); | 1462 | g_print("Exporting only object with id=\"%s\"; all other objects hidden\n", sp_export_id); |
1114 | @@ -1644,10 +1641,12 @@ | |||
1115 | 1644 | g_print("Background RRGGBBAA: %08x\n", bgcolor); | 1641 | g_print("Background RRGGBBAA: %08x\n", bgcolor); |
1116 | 1645 | 1642 | ||
1117 | 1646 | 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); | 1643 | 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); |
1119 | 1647 | 1644 | ||
1120 | 1645 | reverse(items.begin(),items.end()); | ||
1121 | 1646 | |||
1122 | 1648 | if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { | 1647 | if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { |
1123 | 1649 | if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi, | 1648 | if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi, |
1125 | 1650 | dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL) == 1 ) { | 1649 | dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : std::vector<SPItem*>()) == 1 ) { |
1126 | 1651 | g_print("Bitmap saved as: %s\n", filename.c_str()); | 1650 | g_print("Bitmap saved as: %s\n", filename.c_str()); |
1127 | 1652 | } else { | 1651 | } else { |
1128 | 1653 | g_warning("Bitmap failed to save to: %s", filename.c_str()); | 1652 | g_warning("Bitmap failed to save to: %s", filename.c_str()); |
1129 | @@ -1657,7 +1656,6 @@ | |||
1130 | 1657 | } | 1656 | } |
1131 | 1658 | } | 1657 | } |
1132 | 1659 | 1658 | ||
1133 | 1660 | g_slist_free (items); | ||
1134 | 1661 | return retcode; | 1659 | return retcode; |
1135 | 1662 | } | 1660 | } |
1136 | 1663 | 1661 | ||
1137 | 1664 | 1662 | ||
1138 | === modified file 'src/object-snapper.cpp' | |||
1139 | --- src/object-snapper.cpp 2014-11-10 17:39:33 +0000 | |||
1140 | +++ src/object-snapper.cpp 2015-04-29 21:03:59 +0000 | |||
1141 | @@ -237,8 +237,9 @@ | |||
1142 | 237 | // current selection (see the comment in SelTrans::centerRequest()) | 237 | // current selection (see the comment in SelTrans::centerRequest()) |
1143 | 238 | bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER); | 238 | bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER); |
1144 | 239 | if (old_pref2) { | 239 | if (old_pref2) { |
1147 | 240 | for ( GSList const *itemlist = _snapmanager->getRotationCenterSource(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) { | 240 | std::vector<SPItem*> rotationSource=_snapmanager->getRotationCenterSource(); |
1148 | 241 | if ((*i).item == reinterpret_cast<SPItem*>(itemlist->data)) { | 241 | for ( std::vector<SPItem*>::const_iterator itemlist = rotationSource.begin(); itemlist != rotationSource.end(); itemlist++) { |
1149 | 242 | if ((*i).item == *itemlist) { | ||
1150 | 242 | // don't snap to this item's rotation center | 243 | // don't snap to this item's rotation center |
1151 | 243 | _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false); | 244 | _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false); |
1152 | 244 | break; | 245 | break; |
1153 | 245 | 246 | ||
1154 | === modified file 'src/object-test.h' | |||
1155 | --- src/object-test.h 2015-02-21 16:23:30 +0000 | |||
1156 | +++ src/object-test.h 2015-04-29 21:03:59 +0000 | |||
1157 | @@ -204,7 +204,8 @@ | |||
1158 | 204 | assert(n_group != NULL); | 204 | assert(n_group != NULL); |
1159 | 205 | 205 | ||
1160 | 206 | begin = clock(); | 206 | begin = clock(); |
1162 | 207 | sp_item_group_ungroup(n_group, NULL, false); | 207 | std::vector<SPItem*> ch; |
1163 | 208 | sp_item_group_ungroup(n_group, ch, false); | ||
1164 | 208 | end = clock(); | 209 | end = clock(); |
1165 | 209 | 210 | ||
1166 | 210 | std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to ungroup a <g> with " << num_elements << " elements\n"; | 211 | std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to ungroup a <g> with " << num_elements << " elements\n"; |
1167 | 211 | 212 | ||
1168 | === modified file 'src/path-chemistry.cpp' | |||
1169 | --- src/path-chemistry.cpp 2015-04-28 14:26:17 +0000 | |||
1170 | +++ src/path-chemistry.cpp 2015-04-29 21:03:59 +0000 | |||
1171 | @@ -44,13 +44,22 @@ | |||
1172 | 44 | 44 | ||
1173 | 45 | using Inkscape::DocumentUndo; | 45 | using Inkscape::DocumentUndo; |
1174 | 46 | 46 | ||
1175 | 47 | |||
1176 | 48 | inline bool less_than_items(SPItem const *first, SPItem const *second) | ||
1177 | 49 | { | ||
1178 | 50 | return sp_repr_compare_position(first->getRepr(), | ||
1179 | 51 | second->getRepr())<0; | ||
1180 | 52 | } | ||
1181 | 53 | |||
1182 | 47 | void | 54 | void |
1183 | 48 | sp_selected_path_combine(SPDesktop *desktop) | 55 | sp_selected_path_combine(SPDesktop *desktop) |
1184 | 49 | { | 56 | { |
1185 | 50 | Inkscape::Selection *selection = desktop->getSelection(); | 57 | Inkscape::Selection *selection = desktop->getSelection(); |
1186 | 51 | SPDocument *doc = desktop->getDocument(); | 58 | SPDocument *doc = desktop->getDocument(); |
1187 | 59 | |||
1188 | 60 | std::vector<SPItem*> items(selection->itemList()); | ||
1189 | 52 | 61 | ||
1191 | 53 | if (g_slist_length((GSList *) selection->itemList()) < 1) { | 62 | if (items.size() < 1) { |
1192 | 54 | desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine.")); | 63 | desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine.")); |
1193 | 55 | return; | 64 | return; |
1194 | 56 | } | 65 | } |
1195 | @@ -59,28 +68,23 @@ | |||
1196 | 59 | // set "busy" cursor | 68 | // set "busy" cursor |
1197 | 60 | desktop->setWaitingCursor(); | 69 | desktop->setWaitingCursor(); |
1198 | 61 | 70 | ||
1199 | 62 | GSList *items = g_slist_copy((GSList *) selection->itemList()); | ||
1200 | 63 | |||
1201 | 64 | items = sp_degroup_list (items); // descend into any groups in selection | 71 | items = sp_degroup_list (items); // descend into any groups in selection |
1202 | 65 | 72 | ||
1208 | 66 | GSList *to_paths = NULL; | 73 | std::vector<SPItem*> to_paths; |
1209 | 67 | for (GSList *i = items; i != NULL; i = i->next) { | 74 | for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++) { |
1210 | 68 | SPItem *item = (SPItem *) i->data; | 75 | if (!dynamic_cast<SPPath *>(*i) && !dynamic_cast<SPGroup *>(*i)) { |
1211 | 69 | if (!dynamic_cast<SPPath *>(item) && !dynamic_cast<SPGroup *>(item)) { | 76 | to_paths.push_back(*i); |
1207 | 70 | to_paths = g_slist_prepend(to_paths, item); | ||
1212 | 71 | } | 77 | } |
1213 | 72 | } | 78 | } |
1219 | 73 | GSList *converted = NULL; | 79 | std::vector<Inkscape::XML::Node*> converted; |
1220 | 74 | bool did = sp_item_list_to_curves(to_paths, &items, &converted); | 80 | bool did = sp_item_list_to_curves(to_paths, items, converted); |
1221 | 75 | g_slist_free(to_paths); | 81 | for (std::vector<Inkscape::XML::Node*>::const_iterator i = converted.begin(); i != converted.end(); i++) |
1222 | 76 | for (GSList *i = converted; i != NULL; i = i->next) | 82 | items.push_back((SPItem*)doc->getObjectByRepr(*i)); |
1218 | 77 | items = g_slist_prepend(items, doc->getObjectByRepr((Inkscape::XML::Node*)(i->data))); | ||
1223 | 78 | 83 | ||
1224 | 79 | items = sp_degroup_list (items); // converting to path may have added more groups, descend again | 84 | items = sp_degroup_list (items); // converting to path may have added more groups, descend again |
1225 | 80 | 85 | ||
1229 | 81 | items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position); | 86 | sort(items.begin(),items.end(),less_than_items); |
1230 | 82 | items = g_slist_reverse(items); | 87 | assert(!items.empty()); // cannot be NULL because of list length check at top of function |
1228 | 83 | assert(items); // cannot be NULL because of list length check at top of function | ||
1231 | 84 | 88 | ||
1232 | 85 | // remember the position, id, transform and style of the topmost path, they will be assigned to the combined one | 89 | // remember the position, id, transform and style of the topmost path, they will be assigned to the combined one |
1233 | 86 | gint position = 0; | 90 | gint position = 0; |
1234 | @@ -97,9 +101,9 @@ | |||
1235 | 97 | selection->clear(); | 101 | selection->clear(); |
1236 | 98 | } | 102 | } |
1237 | 99 | 103 | ||
1239 | 100 | for (GSList *i = items; i != NULL; i = i->next) { // going from top to bottom | 104 | for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++){ |
1240 | 101 | 105 | ||
1242 | 102 | SPItem *item = (SPItem *) i->data; | 106 | SPItem *item = *i; |
1243 | 103 | SPPath *path = dynamic_cast<SPPath *>(item); | 107 | SPPath *path = dynamic_cast<SPPath *>(item); |
1244 | 104 | if (!path) { | 108 | if (!path) { |
1245 | 105 | continue; | 109 | continue; |
1246 | @@ -136,7 +140,6 @@ | |||
1247 | 136 | } | 140 | } |
1248 | 137 | } | 141 | } |
1249 | 138 | 142 | ||
1250 | 139 | g_slist_free(items); | ||
1251 | 140 | 143 | ||
1252 | 141 | if (did) { | 144 | if (did) { |
1253 | 142 | first->deleteObject(false); | 145 | first->deleteObject(false); |
1254 | @@ -200,11 +203,10 @@ | |||
1255 | 200 | 203 | ||
1256 | 201 | bool did = false; | 204 | bool did = false; |
1257 | 202 | 205 | ||
1261 | 203 | for (GSList *items = g_slist_copy((GSList *) selection->itemList()); | 206 | std::vector<SPItem*> itemlist(selection->itemList()); |
1262 | 204 | items != NULL; | 207 | for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); i++){ |
1260 | 205 | items = items->next) { | ||
1263 | 206 | 208 | ||
1265 | 207 | SPItem *item = (SPItem *) items->data; | 209 | SPItem *item = *i; |
1266 | 208 | 210 | ||
1267 | 209 | SPPath *path = dynamic_cast<SPPath *>(item); | 211 | SPPath *path = dynamic_cast<SPPath *>(item); |
1268 | 210 | if (!path) { | 212 | if (!path) { |
1269 | @@ -241,7 +243,7 @@ | |||
1270 | 241 | 243 | ||
1271 | 242 | curve->unref(); | 244 | curve->unref(); |
1272 | 243 | 245 | ||
1274 | 244 | GSList *reprs = NULL; | 246 | std::vector<Inkscape::XML::Node*> reprs; |
1275 | 245 | for (GSList *l = list; l != NULL; l = l->next) { | 247 | for (GSList *l = list; l != NULL; l = l->next) { |
1276 | 246 | curve = (SPCurve *) l->data; | 248 | curve = (SPCurve *) l->data; |
1277 | 247 | 249 | ||
1278 | @@ -267,14 +269,12 @@ | |||
1279 | 267 | if (l == list) | 269 | if (l == list) |
1280 | 268 | repr->setAttribute("id", id); | 270 | repr->setAttribute("id", id); |
1281 | 269 | 271 | ||
1283 | 270 | reprs = g_slist_prepend (reprs, repr); | 272 | reprs.push_back(repr); |
1284 | 271 | 273 | ||
1285 | 272 | Inkscape::GC::release(repr); | 274 | Inkscape::GC::release(repr); |
1286 | 273 | } | 275 | } |
1287 | 274 | |||
1288 | 275 | selection->setReprList(reprs); | 276 | selection->setReprList(reprs); |
1289 | 276 | 277 | ||
1290 | 277 | g_slist_free(reprs); | ||
1291 | 278 | g_slist_free(list); | 278 | g_slist_free(list); |
1292 | 279 | g_free(style); | 279 | g_free(style); |
1293 | 280 | g_free(path_effect); | 280 | g_free(path_effect); |
1294 | @@ -307,18 +307,15 @@ | |||
1295 | 307 | desktop->setWaitingCursor(); | 307 | desktop->setWaitingCursor(); |
1296 | 308 | } | 308 | } |
1297 | 309 | 309 | ||
1300 | 310 | GSList *selected = g_slist_copy((GSList *) selection->itemList()); | 310 | std::vector<SPItem*> selected(selection->itemList()); |
1301 | 311 | GSList *to_select = NULL; | 311 | std::vector<Inkscape::XML::Node*> to_select; |
1302 | 312 | selection->clear(); | 312 | selection->clear(); |
1308 | 313 | GSList *items = g_slist_copy(selected); | 313 | std::vector<SPItem*> items(selected); |
1309 | 314 | 314 | ||
1310 | 315 | did = sp_item_list_to_curves(items, &selected, &to_select); | 315 | did = sp_item_list_to_curves(items, selected, to_select); |
1311 | 316 | 316 | ||
1307 | 317 | g_slist_free (items); | ||
1312 | 318 | selection->setReprList(to_select); | 317 | selection->setReprList(to_select); |
1313 | 319 | selection->addList(selected); | 318 | selection->addList(selected); |
1314 | 320 | g_slist_free (to_select); | ||
1315 | 321 | g_slist_free (selected); | ||
1316 | 322 | 319 | ||
1317 | 323 | if (interactive && desktop) { | 320 | if (interactive && desktop) { |
1318 | 324 | desktop->clearWaitingCursor(); | 321 | desktop->clearWaitingCursor(); |
1319 | @@ -341,33 +338,24 @@ | |||
1320 | 341 | return; | 338 | return; |
1321 | 342 | } | 339 | } |
1322 | 343 | 340 | ||
1325 | 344 | GSList *selected = g_slist_copy((GSList *) selection->itemList()); | 341 | std::vector<SPItem*> selected(selection->itemList()); |
1326 | 345 | GSList *to_select = NULL; | 342 | std::vector<Inkscape::XML::Node*> to_select; |
1327 | 346 | selection->clear(); | 343 | selection->clear(); |
1334 | 347 | GSList *items = g_slist_copy(selected); | 344 | std::vector<SPItem*> items(selected); |
1335 | 348 | 345 | ||
1336 | 349 | sp_item_list_to_curves(items, &selected, &to_select, true); | 346 | |
1337 | 350 | 347 | sp_item_list_to_curves(items, selected, to_select, true); | |
1338 | 351 | g_slist_free(items); | 348 | |
1333 | 352 | items = 0; | ||
1339 | 353 | selection->setReprList(to_select); | 349 | selection->setReprList(to_select); |
1340 | 354 | selection->addList(selected); | 350 | selection->addList(selected); |
1341 | 355 | g_slist_free(to_select); | ||
1342 | 356 | to_select = 0; | ||
1343 | 357 | g_slist_free(selected); | ||
1344 | 358 | selected = 0; | ||
1345 | 359 | } | 351 | } |
1346 | 360 | 352 | ||
1347 | 361 | bool | 353 | bool |
1349 | 362 | sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems) | 354 | sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*>& selected, std::vector<Inkscape::XML::Node*> &to_select, bool skip_all_lpeitems) |
1350 | 363 | { | 355 | { |
1351 | 364 | bool did = false; | 356 | bool did = false; |
1358 | 365 | 357 | for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++){ | |
1359 | 366 | for (; | 358 | SPItem *item = *i; |
1354 | 367 | items != NULL; | ||
1355 | 368 | items = items->next) { | ||
1356 | 369 | |||
1357 | 370 | SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data)); | ||
1360 | 371 | g_assert(item != NULL); | 359 | g_assert(item != NULL); |
1361 | 372 | SPDocument *document = item->document; | 360 | SPDocument *document = item->document; |
1362 | 373 | 361 | ||
1363 | @@ -398,9 +386,9 @@ | |||
1364 | 398 | Inkscape::XML::Node *repr = box3d_convert_to_group(box)->getRepr(); | 386 | Inkscape::XML::Node *repr = box3d_convert_to_group(box)->getRepr(); |
1365 | 399 | 387 | ||
1366 | 400 | if (repr) { | 388 | if (repr) { |
1368 | 401 | *to_select = g_slist_prepend (*to_select, repr); | 389 | to_select.insert(to_select.begin(),repr); |
1369 | 402 | did = true; | 390 | did = true; |
1371 | 403 | *selected = g_slist_remove (*selected, item); | 391 | selected.erase(find(selected.begin(),selected.end(),item)); |
1372 | 404 | } | 392 | } |
1373 | 405 | 393 | ||
1374 | 406 | continue; | 394 | continue; |
1375 | @@ -408,17 +396,14 @@ | |||
1376 | 408 | 396 | ||
1377 | 409 | if (group) { | 397 | if (group) { |
1378 | 410 | group->removeAllPathEffects(true); | 398 | group->removeAllPathEffects(true); |
1385 | 411 | GSList *item_list = sp_item_group_item_list(group); | 399 | std::vector<SPItem*> item_list = sp_item_group_item_list(group); |
1386 | 412 | 400 | ||
1387 | 413 | GSList *item_to_select = NULL; | 401 | std::vector<Inkscape::XML::Node*> item_to_select; |
1388 | 414 | GSList *item_selected = NULL; | 402 | std::vector<SPItem*> item_selected; |
1389 | 415 | 403 | ||
1390 | 416 | if (sp_item_list_to_curves(item_list, &item_selected, &item_to_select)) | 404 | if (sp_item_list_to_curves(item_list, item_selected, item_to_select)) |
1391 | 417 | did = true; | 405 | did = true; |
1392 | 418 | 406 | ||
1393 | 419 | g_slist_free(item_list); | ||
1394 | 420 | g_slist_free(item_to_select); | ||
1395 | 421 | g_slist_free(item_selected); | ||
1396 | 422 | 407 | ||
1397 | 423 | continue; | 408 | continue; |
1398 | 424 | } | 409 | } |
1399 | @@ -428,7 +413,7 @@ | |||
1400 | 428 | continue; | 413 | continue; |
1401 | 429 | 414 | ||
1402 | 430 | did = true; | 415 | did = true; |
1404 | 431 | *selected = g_slist_remove (*selected, item); | 416 | selected.erase(find(selected.begin(),selected.end(),item)); |
1405 | 432 | 417 | ||
1406 | 433 | // remember the position of the item | 418 | // remember the position of the item |
1407 | 434 | gint pos = item->getRepr()->position(); | 419 | gint pos = item->getRepr()->position(); |
1408 | @@ -470,7 +455,7 @@ | |||
1409 | 470 | 455 | ||
1410 | 471 | /* Buglet: We don't re-add the (new version of the) object to the selection of any other | 456 | /* Buglet: We don't re-add the (new version of the) object to the selection of any other |
1411 | 472 | * desktops where it was previously selected. */ | 457 | * desktops where it was previously selected. */ |
1413 | 473 | *to_select = g_slist_prepend (*to_select, repr); | 458 | to_select.insert(to_select.begin(),repr); |
1414 | 474 | Inkscape::GC::release(repr); | 459 | Inkscape::GC::release(repr); |
1415 | 475 | } | 460 | } |
1416 | 476 | 461 | ||
1417 | @@ -622,9 +607,9 @@ | |||
1418 | 622 | sp_selected_path_reverse(SPDesktop *desktop) | 607 | sp_selected_path_reverse(SPDesktop *desktop) |
1419 | 623 | { | 608 | { |
1420 | 624 | Inkscape::Selection *selection = desktop->getSelection(); | 609 | Inkscape::Selection *selection = desktop->getSelection(); |
1422 | 625 | GSList *items = (GSList *) selection->itemList(); | 610 | std::vector<SPItem*> items = selection->itemList(); |
1423 | 626 | 611 | ||
1425 | 627 | if (!items) { | 612 | if (items.empty()) { |
1426 | 628 | desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse.")); | 613 | desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse.")); |
1427 | 629 | return; | 614 | return; |
1428 | 630 | } | 615 | } |
1429 | @@ -636,9 +621,9 @@ | |||
1430 | 636 | bool did = false; | 621 | bool did = false; |
1431 | 637 | desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); | 622 | desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); |
1432 | 638 | 623 | ||
1434 | 639 | for (GSList *i = items; i != NULL; i = i->next) { | 624 | for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++){ |
1435 | 640 | 625 | ||
1437 | 641 | SPPath *path = dynamic_cast<SPPath *>(static_cast<SPObject *>(i->data)); | 626 | SPPath *path = dynamic_cast<SPPath *>(*i); |
1438 | 642 | if (!path) { | 627 | if (!path) { |
1439 | 643 | continue; | 628 | continue; |
1440 | 644 | } | 629 | } |
1441 | 645 | 630 | ||
1442 | === modified file 'src/path-chemistry.h' | |||
1443 | --- src/path-chemistry.h 2014-10-08 02:22:03 +0000 | |||
1444 | +++ src/path-chemistry.h 2015-04-29 21:03:59 +0000 | |||
1445 | @@ -33,7 +33,7 @@ | |||
1446 | 33 | void sp_selected_to_lpeitems(SPDesktop *desktop); | 33 | void sp_selected_to_lpeitems(SPDesktop *desktop); |
1447 | 34 | Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy); | 34 | Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy); |
1448 | 35 | void sp_selected_path_reverse (SPDesktop *desktop); | 35 | void sp_selected_path_reverse (SPDesktop *desktop); |
1450 | 36 | bool sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems = false); | 36 | bool sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*> &selected, std::vector<Inkscape::XML::Node*> &to_select, bool skip_all_lpeitems = false); |
1451 | 37 | 37 | ||
1452 | 38 | #endif // SEEN_PATH_CHEMISTRY_H | 38 | #endif // SEEN_PATH_CHEMISTRY_H |
1453 | 39 | 39 | ||
1454 | 40 | 40 | ||
1455 | === modified file 'src/removeoverlap.cpp' | |||
1456 | --- src/removeoverlap.cpp 2014-03-27 01:33:44 +0000 | |||
1457 | +++ src/removeoverlap.cpp 2015-04-29 21:03:59 +0000 | |||
1458 | @@ -38,20 +38,19 @@ | |||
1459 | 38 | * such that rectangular bounding boxes are separated by at least xGap | 38 | * such that rectangular bounding boxes are separated by at least xGap |
1460 | 39 | * horizontally and yGap vertically | 39 | * horizontally and yGap vertically |
1461 | 40 | */ | 40 | */ |
1466 | 41 | void removeoverlap(GSList const *const items, double const xGap, double const yGap) { | 41 | void removeoverlap(std::vector<SPItem*> const &items, double const xGap, double const yGap) { |
1467 | 42 | using Inkscape::Util::GSListConstIterator; | 42 | std::vector<SPItem*> selected(items); |
1464 | 43 | std::list<SPItem *> selected; | ||
1465 | 44 | selected.insert<GSListConstIterator<SPItem *> >(selected.end(), items, NULL); | ||
1468 | 45 | std::vector<Record> records; | 43 | std::vector<Record> records; |
1469 | 46 | std::vector<Rectangle *> rs; | 44 | std::vector<Rectangle *> rs; |
1470 | 47 | 45 | ||
1471 | 48 | Geom::Point const gap(xGap, yGap); | 46 | Geom::Point const gap(xGap, yGap); |
1473 | 49 | for (std::list<SPItem *>::iterator it(selected.begin()); | 47 | for (std::vector<SPItem*>::iterator it(selected.begin()); |
1474 | 50 | it != selected.end(); | 48 | it != selected.end(); |
1475 | 51 | ++it) | 49 | ++it) |
1476 | 52 | { | 50 | { |
1477 | 51 | SPItem* item = *it; | ||
1478 | 53 | using Geom::X; using Geom::Y; | 52 | using Geom::X; using Geom::Y; |
1480 | 54 | Geom::OptRect item_box((*it)->desktopVisualBounds()); | 53 | Geom::OptRect item_box((item)->desktopVisualBounds()); |
1481 | 55 | if (item_box) { | 54 | if (item_box) { |
1482 | 56 | Geom::Point min(item_box->min() - .5*gap); | 55 | Geom::Point min(item_box->min() - .5*gap); |
1483 | 57 | Geom::Point max(item_box->max() + .5*gap); | 56 | Geom::Point max(item_box->max() + .5*gap); |
1484 | @@ -67,7 +66,7 @@ | |||
1485 | 67 | min[Y] = max[Y] = (min[Y] + max[Y])/2; | 66 | min[Y] = max[Y] = (min[Y] + max[Y])/2; |
1486 | 68 | } | 67 | } |
1487 | 69 | Rectangle *vspc_rect = new Rectangle(min[X], max[X], min[Y], max[Y]); | 68 | Rectangle *vspc_rect = new Rectangle(min[X], max[X], min[Y], max[Y]); |
1489 | 70 | records.push_back(Record(*it, item_box->midpoint(), vspc_rect)); | 69 | records.push_back(Record(item, item_box->midpoint(), vspc_rect)); |
1490 | 71 | rs.push_back(vspc_rect); | 70 | rs.push_back(vspc_rect); |
1491 | 72 | } | 71 | } |
1492 | 73 | } | 72 | } |
1493 | 74 | 73 | ||
1494 | === modified file 'src/removeoverlap.h' | |||
1495 | --- src/removeoverlap.h 2014-10-08 02:22:03 +0000 | |||
1496 | +++ src/removeoverlap.h 2015-04-29 21:03:59 +0000 | |||
1497 | @@ -15,6 +15,6 @@ | |||
1498 | 15 | 15 | ||
1499 | 16 | typedef struct _GSList GSList; | 16 | typedef struct _GSList GSList; |
1500 | 17 | 17 | ||
1502 | 18 | void removeoverlap(GSList const *items, double xGap, double yGap); | 18 | void removeoverlap(std::vector<SPItem*> const &items, double xGap, double yGap); |
1503 | 19 | 19 | ||
1504 | 20 | #endif // SEEN_REMOVEOVERLAP_H | 20 | #endif // SEEN_REMOVEOVERLAP_H |
1505 | 21 | 21 | ||
1506 | === modified file 'src/selcue.cpp' | |||
1507 | --- src/selcue.cpp 2014-12-21 21:58:32 +0000 | |||
1508 | +++ src/selcue.cpp 2015-04-29 21:03:59 +0000 | |||
1509 | @@ -96,15 +96,16 @@ | |||
1510 | 96 | 96 | ||
1511 | 97 | void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) | 97 | void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) |
1512 | 98 | { | 98 | { |
1515 | 99 | GSList const *items = _selection->itemList(); | 99 | const std::vector<SPItem*> items = _selection->itemList(); |
1516 | 100 | if (_item_bboxes.size() != g_slist_length((GSList *) items)) { | 100 | if (_item_bboxes.size() != items.size()) { |
1517 | 101 | _newItemBboxes(); | 101 | _newItemBboxes(); |
1518 | 102 | return; | 102 | return; |
1519 | 103 | } | 103 | } |
1520 | 104 | 104 | ||
1521 | 105 | int bcount = 0; | 105 | int bcount = 0; |
1524 | 106 | for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { | 106 | std::vector<SPItem*> ll=_selection->itemList(); |
1525 | 107 | SPItem *item = static_cast<SPItem *>(l->data); | 107 | for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); l++) { |
1526 | 108 | SPItem *item = *l; | ||
1527 | 108 | SPCanvasItem* box = _item_bboxes[bcount ++]; | 109 | SPCanvasItem* box = _item_bboxes[bcount ++]; |
1528 | 109 | 110 | ||
1529 | 110 | if (box) { | 111 | if (box) { |
1530 | @@ -145,8 +146,9 @@ | |||
1531 | 145 | 146 | ||
1532 | 146 | int prefs_bbox = prefs->getBool("/tools/bounding_box"); | 147 | int prefs_bbox = prefs->getBool("/tools/bounding_box"); |
1533 | 147 | 148 | ||
1536 | 148 | for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { | 149 | std::vector<SPItem*> ll=_selection->itemList(); |
1537 | 149 | SPItem *item = static_cast<SPItem *>(l->data); | 150 | for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); l++) { |
1538 | 151 | SPItem *item = *l; | ||
1539 | 150 | 152 | ||
1540 | 151 | Geom::OptRect const b = (prefs_bbox == 0) ? | 153 | Geom::OptRect const b = (prefs_bbox == 0) ? |
1541 | 152 | item->desktopVisualBounds() : item->desktopGeometricBounds(); | 154 | item->desktopVisualBounds() : item->desktopGeometricBounds(); |
1542 | @@ -199,8 +201,9 @@ | |||
1543 | 199 | } | 201 | } |
1544 | 200 | _text_baselines.clear(); | 202 | _text_baselines.clear(); |
1545 | 201 | 203 | ||
1548 | 202 | for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { | 204 | std::vector<SPItem*> ll = _selection->itemList(); |
1549 | 203 | SPItem *item = static_cast<SPItem *>(l->data); | 205 | for (std::vector<SPItem*>::const_iterator l=ll.begin();l!=ll.end();l++) { |
1550 | 206 | SPItem *item = *l; | ||
1551 | 204 | 207 | ||
1552 | 205 | SPCanvasItem* baseline_point = NULL; | 208 | SPCanvasItem* baseline_point = NULL; |
1553 | 206 | if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { // visualize baseline | 209 | if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { // visualize baseline |
1554 | 207 | 210 | ||
1555 | === modified file 'src/selection-chemistry.cpp' | |||
1556 | --- src/selection-chemistry.cpp 2015-02-21 16:23:30 +0000 | |||
1557 | +++ src/selection-chemistry.cpp 2015-04-29 21:03:59 +0000 | |||
1558 | @@ -279,25 +279,21 @@ | |||
1559 | 279 | 279 | ||
1560 | 280 | Inkscape::Selection *selection = dt->getSelection(); | 280 | Inkscape::Selection *selection = dt->getSelection(); |
1561 | 281 | 281 | ||
1568 | 282 | GSList *items = NULL; | 282 | std::vector<SPItem*> items ; |
1569 | 283 | 283 | ||
1570 | 284 | GSList const *selList = selection->itemList(); | 284 | std::vector<SPItem*> const selList = selection->itemList(); |
1571 | 285 | 285 | ||
1572 | 286 | for( GSList const *i = selList; i; i = i->next ) { | 286 | for( std::vector<SPItem*>::const_reverse_iterator i = selList.rbegin(); i != selList.rend(); i++ ) { |
1573 | 287 | SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data)); | 287 | SPItem *item = *i; |
1574 | 288 | if( item && | 288 | if( item && |
1575 | 289 | !dt->isLayer(item) && | 289 | !dt->isLayer(item) && |
1576 | 290 | (!item->isLocked())) | 290 | (!item->isLocked())) |
1577 | 291 | { | 291 | { |
1579 | 292 | items = g_slist_prepend(items, item); | 292 | items.push_back(item); |
1580 | 293 | } | 293 | } |
1581 | 294 | } | 294 | } |
1582 | 295 | 295 | ||
1583 | 296 | selection->setList(items); | 296 | selection->setList(items); |
1584 | 297 | |||
1585 | 298 | if(items) { | ||
1586 | 299 | g_slist_free(items); | ||
1587 | 300 | } | ||
1588 | 301 | } | 297 | } |
1589 | 302 | 298 | ||
1590 | 303 | } // namespace Inkscape | 299 | } // namespace Inkscape |
1591 | @@ -307,7 +303,7 @@ | |||
1592 | 307 | * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t', | 303 | * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t', |
1593 | 308 | * then prepends the copy to 'clip'. | 304 | * then prepends the copy to 'clip'. |
1594 | 309 | */ | 305 | */ |
1596 | 310 | static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, GSList **clip, Inkscape::XML::Document* xml_doc) | 306 | 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) |
1597 | 311 | { | 307 | { |
1598 | 312 | Inkscape::XML::Node *copy = repr->duplicate(xml_doc); | 308 | Inkscape::XML::Node *copy = repr->duplicate(xml_doc); |
1599 | 313 | 309 | ||
1600 | @@ -323,41 +319,39 @@ | |||
1601 | 323 | copy->setAttribute("transform", affinestr); | 319 | copy->setAttribute("transform", affinestr); |
1602 | 324 | g_free(affinestr); | 320 | g_free(affinestr); |
1603 | 325 | 321 | ||
1605 | 326 | *clip = g_slist_prepend(*clip, copy); | 322 | clip.insert(clip.begin(),copy); |
1606 | 327 | } | 323 | } |
1607 | 328 | 324 | ||
1609 | 329 | static void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::Document* xml_doc) | 325 | static void sp_selection_copy_impl(std::vector<SPItem*> const &items, std::vector<Inkscape::XML::Node*> &clip, Inkscape::XML::Document* xml_doc) |
1610 | 330 | { | 326 | { |
1611 | 331 | // Sort items: | 327 | // Sort items: |
1614 | 332 | GSList *sorted_items = g_slist_copy(const_cast<GSList *>(items)); | 328 | std::vector<SPItem*> sorted_items(items); |
1615 | 333 | sorted_items = g_slist_sort(static_cast<GSList *>(sorted_items), (GCompareFunc) sp_object_compare_position); | 329 | sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position); |
1616 | 334 | 330 | ||
1617 | 335 | // Copy item reprs: | 331 | // Copy item reprs: |
1620 | 336 | for (GSList *i = sorted_items; i != NULL; i = i->next) { | 332 | for (std::vector<SPItem*>::const_iterator i = sorted_items.begin(); i != sorted_items.end(); i++) { |
1621 | 337 | SPItem *item = dynamic_cast<SPItem *>(SP_OBJECT(i->data)); | 333 | SPItem *item = *i; |
1622 | 338 | if (item) { | 334 | if (item) { |
1623 | 339 | sp_selection_copy_one(item->getRepr(), item->i2doc_affine(), clip, xml_doc); | 335 | sp_selection_copy_one(item->getRepr(), item->i2doc_affine(), clip, xml_doc); |
1624 | 340 | } else { | 336 | } else { |
1625 | 341 | g_assert_not_reached(); | 337 | g_assert_not_reached(); |
1626 | 342 | } | 338 | } |
1627 | 343 | } | 339 | } |
1631 | 344 | 340 | reverse(clip.begin(),clip.end()); | |
1629 | 345 | *clip = g_slist_reverse(*clip); | ||
1630 | 346 | g_slist_free(static_cast<GSList *>(sorted_items)); | ||
1632 | 347 | } | 341 | } |
1633 | 348 | 342 | ||
1634 | 349 | // TODO check if parent parameter should be changed to SPItem, of if the code should handle non-items. | 343 | // TODO check if parent parameter should be changed to SPItem, of if the code should handle non-items. |
1636 | 350 | static GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip) | 344 | static std::vector<Inkscape::XML::Node*> sp_selection_paste_impl(SPDocument *doc, SPObject *parent, std::vector<Inkscape::XML::Node*> &clip) |
1637 | 351 | { | 345 | { |
1638 | 352 | Inkscape::XML::Document *xml_doc = doc->getReprDoc(); | 346 | Inkscape::XML::Document *xml_doc = doc->getReprDoc(); |
1639 | 353 | 347 | ||
1640 | 354 | SPItem *parentItem = dynamic_cast<SPItem *>(parent); | 348 | SPItem *parentItem = dynamic_cast<SPItem *>(parent); |
1641 | 355 | g_assert(parentItem != NULL); | 349 | g_assert(parentItem != NULL); |
1642 | 356 | 350 | ||
1644 | 357 | GSList *copied = NULL; | 351 | std::vector<Inkscape::XML::Node*> copied; |
1645 | 358 | // add objects to document | 352 | // add objects to document |
1648 | 359 | for (GSList *l = *clip; l != NULL; l = l->next) { | 353 | for (std::vector<Inkscape::XML::Node*>::const_iterator l = clip.begin(); l != clip.end(); l++) { |
1649 | 360 | Inkscape::XML::Node *repr = static_cast<Inkscape::XML::Node *>(l->data); | 354 | Inkscape::XML::Node *repr = *l; |
1650 | 361 | Inkscape::XML::Node *copy = repr->duplicate(xml_doc); | 355 | Inkscape::XML::Node *copy = repr->duplicate(xml_doc); |
1651 | 362 | 356 | ||
1652 | 363 | // premultiply the item transform by the accumulated parent transform in the paste layer | 357 | // premultiply the item transform by the accumulated parent transform in the paste layer |
1653 | @@ -375,19 +369,19 @@ | |||
1654 | 375 | } | 369 | } |
1655 | 376 | 370 | ||
1656 | 377 | parent->appendChildRepr(copy); | 371 | parent->appendChildRepr(copy); |
1658 | 378 | copied = g_slist_prepend(copied, copy); | 372 | copied.push_back(copy); |
1659 | 379 | Inkscape::GC::release(copy); | 373 | Inkscape::GC::release(copy); |
1660 | 380 | } | 374 | } |
1661 | 381 | return copied; | 375 | return copied; |
1662 | 382 | } | 376 | } |
1663 | 383 | 377 | ||
1665 | 384 | static void sp_selection_delete_impl(GSList const *items, bool propagate = true, bool propagate_descendants = true) | 378 | static void sp_selection_delete_impl(std::vector<SPItem*> const &items, bool propagate = true, bool propagate_descendants = true) |
1666 | 385 | { | 379 | { |
1669 | 386 | for (GSList const *i = items ; i ; i = i->next ) { | 380 | for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) { |
1670 | 387 | sp_object_ref(static_cast<SPItem *>(i->data), NULL); | 381 | sp_object_ref(*i, NULL); |
1671 | 388 | } | 382 | } |
1674 | 389 | for (GSList const *i = items; i != NULL; i = i->next) { | 383 | for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) { |
1675 | 390 | SPItem *item = static_cast<SPItem *>(i->data); | 384 | SPItem *item = *i; |
1676 | 391 | item->deleteObject(propagate, propagate_descendants); | 385 | item->deleteObject(propagate, propagate_descendants); |
1677 | 392 | sp_object_unref(item, NULL); | 386 | sp_object_unref(item, NULL); |
1678 | 393 | } | 387 | } |
1679 | @@ -414,11 +408,9 @@ | |||
1680 | 414 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Nothing</b> was deleted.")); | 408 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Nothing</b> was deleted.")); |
1681 | 415 | return; | 409 | return; |
1682 | 416 | } | 410 | } |
1685 | 417 | 411 | std::vector<SPItem*> selected(selection->itemList()); | |
1684 | 418 | GSList *selected = g_slist_copy(const_cast<GSList *>(selection->itemList())); | ||
1686 | 419 | selection->clear(); | 412 | selection->clear(); |
1687 | 420 | sp_selection_delete_impl(selected); | 413 | sp_selection_delete_impl(selected); |
1688 | 421 | g_slist_free(selected); | ||
1689 | 422 | desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); | 414 | desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); |
1690 | 423 | 415 | ||
1691 | 424 | /* a tool may have set up private information in it's selection context | 416 | /* a tool may have set up private information in it's selection context |
1692 | @@ -461,16 +453,15 @@ | |||
1693 | 461 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to duplicate.")); | 453 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to duplicate.")); |
1694 | 462 | return; | 454 | return; |
1695 | 463 | } | 455 | } |
1698 | 464 | 456 | std::vector<Inkscape::XML::Node*> reprs(selection->reprList()); | |
1697 | 465 | GSList *reprs = g_slist_copy(const_cast<GSList *>(selection->reprList())); | ||
1699 | 466 | 457 | ||
1700 | 467 | selection->clear(); | 458 | selection->clear(); |
1701 | 468 | 459 | ||
1702 | 469 | // sorting items from different parents sorts each parent's subset without possibly mixing | 460 | // sorting items from different parents sorts each parent's subset without possibly mixing |
1703 | 470 | // them, just what we need | 461 | // them, just what we need |
1705 | 471 | reprs = g_slist_sort(reprs, (GCompareFunc) sp_repr_compare_position); | 462 | sort(reprs.begin(),reprs.end(),sp_repr_compare_position); |
1706 | 472 | 463 | ||
1708 | 473 | GSList *newsel = NULL; | 464 | std::vector<Inkscape::XML::Node*> newsel; |
1709 | 474 | 465 | ||
1710 | 475 | std::vector<const gchar *> old_ids; | 466 | std::vector<const gchar *> old_ids; |
1711 | 476 | std::vector<const gchar *> new_ids; | 467 | std::vector<const gchar *> new_ids; |
1712 | @@ -478,8 +469,8 @@ | |||
1713 | 478 | bool relink_clones = prefs->getBool("/options/relinkclonesonduplicate/value"); | 469 | bool relink_clones = prefs->getBool("/options/relinkclonesonduplicate/value"); |
1714 | 479 | const bool fork_livepatheffects = prefs->getBool("/options/forklpeonduplicate/value", true); | 470 | const bool fork_livepatheffects = prefs->getBool("/options/forklpeonduplicate/value", true); |
1715 | 480 | 471 | ||
1718 | 481 | while (reprs) { | 472 | for(std::vector<Inkscape::XML::Node*>::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){ |
1719 | 482 | Inkscape::XML::Node *old_repr = static_cast<Inkscape::XML::Node *>(reprs->data); | 473 | Inkscape::XML::Node *old_repr = *i; |
1720 | 483 | Inkscape::XML::Node *parent = old_repr->parent(); | 474 | Inkscape::XML::Node *parent = old_repr->parent(); |
1721 | 484 | Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); | 475 | Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); |
1722 | 485 | 476 | ||
1723 | @@ -500,8 +491,7 @@ | |||
1724 | 500 | } | 491 | } |
1725 | 501 | } | 492 | } |
1726 | 502 | 493 | ||
1729 | 503 | newsel = g_slist_prepend(newsel, copy); | 494 | newsel.push_back(copy); |
1728 | 504 | reprs = g_slist_remove(reprs, reprs->data); | ||
1730 | 505 | Inkscape::GC::release(copy); | 495 | Inkscape::GC::release(copy); |
1731 | 506 | } | 496 | } |
1732 | 507 | 497 | ||
1733 | @@ -547,8 +537,6 @@ | |||
1734 | 547 | } | 537 | } |
1735 | 548 | 538 | ||
1736 | 549 | selection->setReprList(newsel); | 539 | selection->setReprList(newsel); |
1737 | 550 | |||
1738 | 551 | g_slist_free(newsel); | ||
1739 | 552 | } | 540 | } |
1740 | 553 | 541 | ||
1741 | 554 | void sp_edit_clear_all(Inkscape::Selection *selection) | 542 | void sp_edit_clear_all(Inkscape::Selection *selection) |
1742 | @@ -561,11 +549,10 @@ | |||
1743 | 561 | 549 | ||
1744 | 562 | SPGroup *group = dynamic_cast<SPGroup *>(selection->layers()->currentLayer()); | 550 | SPGroup *group = dynamic_cast<SPGroup *>(selection->layers()->currentLayer()); |
1745 | 563 | g_return_if_fail(group != NULL); | 551 | g_return_if_fail(group != NULL); |
1747 | 564 | GSList *items = sp_item_group_item_list(group); | 552 | std::vector<SPItem*> items = sp_item_group_item_list(group); |
1748 | 565 | 553 | ||
1752 | 566 | while (items) { | 554 | for(unsigned int i = 0; i < items.size(); i++){ |
1753 | 567 | reinterpret_cast<SPObject*>(items->data)->deleteObject(); | 555 | items[i]->deleteObject(); |
1751 | 568 | items = g_slist_remove(items, items->data); | ||
1754 | 569 | } | 556 | } |
1755 | 570 | 557 | ||
1756 | 571 | DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, | 558 | DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, |
1757 | @@ -582,7 +569,7 @@ | |||
1758 | 582 | * onlysensitive - TRUE includes only non-locked items | 569 | * onlysensitive - TRUE includes only non-locked items |
1759 | 583 | * ingroups - TRUE to recursively get grouped items children | 570 | * ingroups - TRUE to recursively get grouped items children |
1760 | 584 | */ | 571 | */ |
1762 | 585 | GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude) | 572 | std::vector<SPItem*> &get_all_items(std::vector<SPItem*> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector<SPItem*> const &exclude) |
1763 | 586 | { | 573 | { |
1764 | 587 | for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) { | 574 | for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) { |
1765 | 588 | SPItem *item = dynamic_cast<SPItem *>(child); | 575 | SPItem *item = dynamic_cast<SPItem *>(child); |
1766 | @@ -590,10 +577,10 @@ | |||
1767 | 590 | !desktop->isLayer(item) && | 577 | !desktop->isLayer(item) && |
1768 | 591 | (!onlysensitive || !item->isLocked()) && | 578 | (!onlysensitive || !item->isLocked()) && |
1769 | 592 | (!onlyvisible || !desktop->itemIsHidden(item)) && | 579 | (!onlyvisible || !desktop->itemIsHidden(item)) && |
1771 | 593 | (!exclude || !g_slist_find(const_cast<GSList *>(exclude), child)) | 580 | (exclude.empty() || exclude.end() == std::find(exclude.begin(),exclude.end(),child)) |
1772 | 594 | ) | 581 | ) |
1773 | 595 | { | 582 | { |
1775 | 596 | list = g_slist_prepend(list, item); | 583 | list.insert(list.begin(),item); |
1776 | 597 | } | 584 | } |
1777 | 598 | 585 | ||
1778 | 599 | if (ingroups || (item && desktop->isLayer(item))) { | 586 | if (ingroups || (item && desktop->isLayer(item))) { |
1779 | @@ -618,9 +605,9 @@ | |||
1780 | 618 | bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); | 605 | bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); |
1781 | 619 | bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); | 606 | bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); |
1782 | 620 | 607 | ||
1784 | 621 | GSList *items = NULL; | 608 | std::vector<SPItem*> items ; |
1785 | 622 | 609 | ||
1787 | 623 | GSList const *exclude = NULL; | 610 | std::vector<SPItem*> exclude; |
1788 | 624 | if (invert) { | 611 | if (invert) { |
1789 | 625 | exclude = selection->itemList(); | 612 | exclude = selection->itemList(); |
1790 | 626 | } | 613 | } |
1791 | @@ -634,40 +621,38 @@ | |||
1792 | 634 | (onlyvisible && dt->itemIsHidden(dynamic_cast<SPItem *>(dt->currentLayer()))) ) | 621 | (onlyvisible && dt->itemIsHidden(dynamic_cast<SPItem *>(dt->currentLayer()))) ) |
1793 | 635 | return; | 622 | return; |
1794 | 636 | 623 | ||
1796 | 637 | GSList *all_items = sp_item_group_item_list(dynamic_cast<SPGroup *>(dt->currentLayer())); | 624 | std::vector<SPItem*> all_items = sp_item_group_item_list(dynamic_cast<SPGroup *>(dt->currentLayer())); |
1797 | 638 | 625 | ||
1800 | 639 | for (GSList *i = all_items; i; i = i->next) { | 626 | for (std::vector<SPItem*>::const_reverse_iterator i=all_items.rbegin();i!=all_items.rend();i++) { |
1801 | 640 | SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data)); | 627 | SPItem *item = *i; |
1802 | 641 | 628 | ||
1803 | 642 | if (item && (!onlysensitive || !item->isLocked())) { | 629 | if (item && (!onlysensitive || !item->isLocked())) { |
1804 | 643 | if (!onlyvisible || !dt->itemIsHidden(item)) { | 630 | if (!onlyvisible || !dt->itemIsHidden(item)) { |
1805 | 644 | if (!dt->isLayer(item)) { | 631 | if (!dt->isLayer(item)) { |
1808 | 645 | if (!invert || !g_slist_find(const_cast<GSList *>(exclude), item)) { | 632 | if (!invert || exclude.end() == std::find(exclude.begin(),exclude.end(),item)) { |
1809 | 646 | items = g_slist_prepend(items, item); // leave it in the list | 633 | items.push_back(item); // leave it in the list |
1810 | 647 | } | 634 | } |
1811 | 648 | } | 635 | } |
1812 | 649 | } | 636 | } |
1813 | 650 | } | 637 | } |
1814 | 651 | } | 638 | } |
1815 | 652 | 639 | ||
1816 | 653 | g_slist_free(all_items); | ||
1817 | 654 | break; | 640 | break; |
1818 | 655 | } | 641 | } |
1819 | 656 | case PREFS_SELECTION_LAYER_RECURSIVE: { | 642 | case PREFS_SELECTION_LAYER_RECURSIVE: { |
1821 | 657 | items = get_all_items(NULL, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude); | 643 | std::vector<SPItem*> x; |
1822 | 644 | items = get_all_items(x, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude); | ||
1823 | 658 | break; | 645 | break; |
1824 | 659 | } | 646 | } |
1825 | 660 | default: { | 647 | default: { |
1827 | 661 | items = get_all_items(NULL, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); | 648 | std::vector<SPItem*> x; |
1828 | 649 | items = get_all_items(x, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); | ||
1829 | 662 | break; | 650 | break; |
1830 | 663 | } | 651 | } |
1831 | 664 | } | 652 | } |
1832 | 665 | 653 | ||
1833 | 666 | selection->setList(items); | 654 | selection->setList(items); |
1834 | 667 | 655 | ||
1835 | 668 | if (items) { | ||
1836 | 669 | g_slist_free(items); | ||
1837 | 670 | } | ||
1838 | 671 | } | 656 | } |
1839 | 672 | 657 | ||
1840 | 673 | void sp_edit_select_all(SPDesktop *desktop) | 658 | void sp_edit_select_all(SPDesktop *desktop) |
1841 | @@ -690,16 +675,16 @@ | |||
1842 | 690 | sp_edit_select_all_full(desktop, true, true); | 675 | sp_edit_select_all_full(desktop, true, true); |
1843 | 691 | } | 676 | } |
1844 | 692 | 677 | ||
1846 | 693 | static void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { | 678 | static void sp_selection_group_impl(std::vector<Inkscape::XML::Node*> p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { |
1847 | 694 | 679 | ||
1849 | 695 | p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position); | 680 | sort(p.begin(),p.end(),sp_repr_compare_position); |
1850 | 696 | 681 | ||
1851 | 697 | // Remember the position and parent of the topmost object. | 682 | // Remember the position and parent of the topmost object. |
1854 | 698 | gint topmost = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->position(); | 683 | gint topmost = p.back()->position(); |
1855 | 699 | Inkscape::XML::Node *topmost_parent = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->parent(); | 684 | Inkscape::XML::Node *topmost_parent = p.back()->parent(); |
1856 | 700 | 685 | ||
1859 | 701 | while (p) { | 686 | for(std::vector<Inkscape::XML::Node*>::const_iterator i = p.begin(); i != p.end(); i++){ |
1860 | 702 | Inkscape::XML::Node *current = static_cast<Inkscape::XML::Node *>(p->data); | 687 | Inkscape::XML::Node *current = *i; |
1861 | 703 | 688 | ||
1862 | 704 | if (current->parent() == topmost_parent) { | 689 | if (current->parent() == topmost_parent) { |
1863 | 705 | Inkscape::XML::Node *spnew = current->duplicate(xml_doc); | 690 | Inkscape::XML::Node *spnew = current->duplicate(xml_doc); |
1864 | @@ -708,7 +693,7 @@ | |||
1865 | 708 | Inkscape::GC::release(spnew); | 693 | Inkscape::GC::release(spnew); |
1866 | 709 | topmost --; // only reduce count for those items deleted from topmost_parent | 694 | topmost --; // only reduce count for those items deleted from topmost_parent |
1867 | 710 | } else { // move it to topmost_parent first | 695 | } else { // move it to topmost_parent first |
1869 | 711 | GSList *temp_clip = NULL; | 696 | std::vector<Inkscape::XML::Node*> temp_clip; |
1870 | 712 | 697 | ||
1871 | 713 | // At this point, current may already have no item, due to its being a clone whose original is already moved away | 698 | // At this point, current may already have no item, due to its being a clone whose original is already moved away |
1872 | 714 | // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform | 699 | // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform |
1873 | @@ -724,15 +709,15 @@ | |||
1874 | 724 | // then, if this is clone, looking up its original in that array and pre-multiplying | 709 | // then, if this is clone, looking up its original in that array and pre-multiplying |
1875 | 725 | // it by the inverse of that original's transform diff. | 710 | // it by the inverse of that original's transform diff. |
1876 | 726 | 711 | ||
1878 | 727 | sp_selection_copy_one(current, item_t, &temp_clip, xml_doc); | 712 | sp_selection_copy_one(current, item_t, temp_clip, xml_doc); |
1879 | 728 | sp_repr_unparent(current); | 713 | sp_repr_unparent(current); |
1880 | 729 | 714 | ||
1881 | 730 | // paste into topmost_parent (temporarily) | 715 | // paste into topmost_parent (temporarily) |
1885 | 731 | GSList *copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), &temp_clip); | 716 | std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); |
1886 | 732 | if (temp_clip) g_slist_free(temp_clip); | 717 | if (!temp_clip.empty())temp_clip.clear() ; |
1887 | 733 | if (copied) { // if success, | 718 | if (!copied.empty()) { // if success, |
1888 | 734 | // take pasted object (now in topmost_parent) | 719 | // take pasted object (now in topmost_parent) |
1890 | 735 | Inkscape::XML::Node *in_topmost = static_cast<Inkscape::XML::Node *>(copied->data); | 720 | Inkscape::XML::Node *in_topmost = copied.back(); |
1891 | 736 | // make a copy | 721 | // make a copy |
1892 | 737 | Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); | 722 | Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); |
1893 | 738 | // remove pasted | 723 | // remove pasted |
1894 | @@ -740,10 +725,9 @@ | |||
1895 | 740 | // put its copy into group | 725 | // put its copy into group |
1896 | 741 | group->appendChild(spnew); | 726 | group->appendChild(spnew); |
1897 | 742 | Inkscape::GC::release(spnew); | 727 | Inkscape::GC::release(spnew); |
1899 | 743 | g_slist_free(copied); | 728 | copied.clear(); |
1900 | 744 | } | 729 | } |
1901 | 745 | } | 730 | } |
1902 | 746 | p = g_slist_remove(p, current); | ||
1903 | 747 | } | 731 | } |
1904 | 748 | 732 | ||
1905 | 749 | // Add the new group to the topmost members' parent | 733 | // Add the new group to the topmost members' parent |
1906 | @@ -764,9 +748,7 @@ | |||
1907 | 764 | return; | 748 | return; |
1908 | 765 | } | 749 | } |
1909 | 766 | 750 | ||
1913 | 767 | GSList const *l = const_cast<GSList *>(selection->reprList()); | 751 | std::vector<Inkscape::XML::Node*> p (selection->reprList()); |
1911 | 768 | |||
1912 | 769 | GSList *p = g_slist_copy(const_cast<GSList *>(l)); | ||
1914 | 770 | 752 | ||
1915 | 771 | selection->clear(); | 753 | selection->clear(); |
1916 | 772 | 754 | ||
1917 | @@ -802,11 +784,11 @@ | |||
1918 | 802 | } | 784 | } |
1919 | 803 | 785 | ||
1920 | 804 | // first check whether there is anything to ungroup | 786 | // first check whether there is anything to ungroup |
1923 | 805 | GSList *old_select = const_cast<GSList *>(selection->itemList()); | 787 | std::vector<SPItem*> old_select = selection->itemList(); |
1924 | 806 | GSList *new_select = NULL; | 788 | std::vector<SPItem*> new_select; |
1925 | 807 | GSList *groups = NULL; | 789 | GSList *groups = NULL; |
1928 | 808 | for (GSList *item = old_select; item; item = item->next) { | 790 | for (std::vector<SPItem*>::const_iterator item = old_select.begin(); item!=old_select.end(); item++) { |
1929 | 809 | SPItem *obj = static_cast<SPItem*>(item->data); | 791 | SPItem *obj = *item; |
1930 | 810 | if (dynamic_cast<SPGroup *>(obj)) { | 792 | if (dynamic_cast<SPGroup *>(obj)) { |
1931 | 811 | groups = g_slist_prepend(groups, obj); | 793 | groups = g_slist_prepend(groups, obj); |
1932 | 812 | } | 794 | } |
1933 | @@ -818,14 +800,14 @@ | |||
1934 | 818 | return; | 800 | return; |
1935 | 819 | } | 801 | } |
1936 | 820 | 802 | ||
1938 | 821 | GSList *items = g_slist_copy(old_select); | 803 | std::vector<SPItem*> items(old_select); |
1939 | 822 | selection->clear(); | 804 | selection->clear(); |
1940 | 823 | 805 | ||
1941 | 824 | // If any of the clones refer to the groups, unlink them and replace them with successors | 806 | // If any of the clones refer to the groups, unlink them and replace them with successors |
1942 | 825 | // in the items list. | 807 | // in the items list. |
1943 | 826 | GSList *clones_to_unlink = NULL; | 808 | GSList *clones_to_unlink = NULL; |
1946 | 827 | for (GSList *item = items; item; item = item->next) { | 809 | for (std::vector<SPItem*>::const_iterator item = items.begin(); item != items.end(); item++) { |
1947 | 828 | SPUse *use = dynamic_cast<SPUse *>(static_cast<SPItem *>(item->data)); | 810 | SPUse *use = dynamic_cast<SPUse *>(*item); |
1948 | 829 | 811 | ||
1949 | 830 | SPItem *original = use; | 812 | SPItem *original = use; |
1950 | 831 | while (dynamic_cast<SPUse *>(original)) { | 813 | while (dynamic_cast<SPUse *>(original)) { |
1951 | @@ -833,7 +815,7 @@ | |||
1952 | 833 | } | 815 | } |
1953 | 834 | 816 | ||
1954 | 835 | if (g_slist_find(groups, original) != NULL) { | 817 | if (g_slist_find(groups, original) != NULL) { |
1956 | 836 | clones_to_unlink = g_slist_prepend(clones_to_unlink, item->data); | 818 | clones_to_unlink = g_slist_prepend(clones_to_unlink, *item); |
1957 | 837 | } | 819 | } |
1958 | 838 | } | 820 | } |
1959 | 839 | 821 | ||
1960 | @@ -844,57 +826,53 @@ | |||
1961 | 844 | 826 | ||
1962 | 845 | for (GSList *item = clones_to_unlink; item; item = item->next) { | 827 | for (GSList *item = clones_to_unlink; item; item = item->next) { |
1963 | 846 | SPUse *use = static_cast<SPUse *>(item->data); | 828 | SPUse *use = static_cast<SPUse *>(item->data); |
1966 | 847 | GSList *items_node = g_slist_find(items, item->data); | 829 | std::vector<SPItem*>::iterator items_node = std::find(items.begin(),items.end(), item->data); |
1967 | 848 | items_node->data = use->unlink(); | 830 | *items_node = use->unlink(); |
1968 | 849 | } | 831 | } |
1969 | 850 | g_slist_free(clones_to_unlink); | 832 | g_slist_free(clones_to_unlink); |
1970 | 851 | 833 | ||
1971 | 852 | // do the actual work | 834 | // do the actual work |
1974 | 853 | for (GSList *item = items; item; item = item->next) { | 835 | for (std::vector<SPItem*>::iterator item = items.begin(); item != items.end(); item++) { |
1975 | 854 | SPItem *obj = static_cast<SPItem *>(item->data); | 836 | SPItem *obj = *item; |
1976 | 855 | 837 | ||
1977 | 856 | // ungroup only the groups marked earlier | 838 | // ungroup only the groups marked earlier |
1981 | 857 | if (g_slist_find(groups, item->data) != NULL) { | 839 | if (g_slist_find(groups, *item) != NULL) { |
1982 | 858 | GSList *children = NULL; | 840 | std::vector<SPItem*> children; |
1983 | 859 | sp_item_group_ungroup(dynamic_cast<SPGroup *>(obj), &children, false); | 841 | sp_item_group_ungroup(dynamic_cast<SPGroup *>(obj), children, false); |
1984 | 860 | // add the items resulting from ungrouping to the selection | 842 | // add the items resulting from ungrouping to the selection |
1987 | 861 | new_select = g_slist_concat(new_select, children); | 843 | new_select.insert(new_select.end(),children.begin(),children.end()); |
1988 | 862 | item->data = NULL; // zero out the original pointer, which is no longer valid | 844 | *item = NULL; // zero out the original pointer, which is no longer valid |
1989 | 863 | } else { | 845 | } else { |
1990 | 864 | // if not a group, keep in the selection | 846 | // if not a group, keep in the selection |
1992 | 865 | new_select = g_slist_append(new_select, item->data); | 847 | new_select.push_back(*item); |
1993 | 866 | } | 848 | } |
1994 | 867 | } | 849 | } |
1995 | 868 | 850 | ||
1996 | 869 | selection->addList(new_select); | 851 | selection->addList(new_select); |
1997 | 870 | g_slist_free(new_select); | ||
1998 | 871 | g_slist_free(items); | ||
1999 | 872 | 852 | ||
2000 | 873 | DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP, | 853 | DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP, |
2001 | 874 | _("Ungroup")); | 854 | _("Ungroup")); |
2002 | 875 | } | 855 | } |
2003 | 876 | 856 | ||
2004 | 877 | /** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */ | 857 | /** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */ |
2007 | 878 | GSList * | 858 | std::vector<SPItem*> |
2008 | 879 | sp_degroup_list(GSList *items) | 859 | sp_degroup_list(std::vector<SPItem*> &items) |
2009 | 880 | { | 860 | { |
2011 | 881 | GSList *out = NULL; | 861 | std::vector<SPItem*> out; |
2012 | 882 | bool has_groups = false; | 862 | bool has_groups = false; |
2015 | 883 | for (GSList *item = items; item; item = item->next) { | 863 | for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();item++) { |
2016 | 884 | SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(item->data)); | 864 | SPGroup *group = dynamic_cast<SPGroup *>(*item); |
2017 | 885 | if (!group) { | 865 | if (!group) { |
2019 | 886 | out = g_slist_prepend(out, item->data); | 866 | out.push_back(*item); |
2020 | 887 | } else { | 867 | } else { |
2021 | 888 | has_groups = true; | 868 | has_groups = true; |
2025 | 889 | GSList *members = sp_item_group_item_list(group); | 869 | std::vector<SPItem*> members = sp_item_group_item_list(group); |
2026 | 890 | for (GSList *member = members; member; member = member->next) { | 870 | for (std::vector<SPItem*>::const_iterator member=members.begin();member!=members.end();member++) { |
2027 | 891 | out = g_slist_prepend(out, member->data); | 871 | out.push_back(*member); |
2028 | 892 | } | 872 | } |
2030 | 893 | g_slist_free(members); | 873 | members.clear(); |
2031 | 894 | } | 874 | } |
2032 | 895 | } | 875 | } |
2033 | 896 | out = g_slist_reverse(out); | ||
2034 | 897 | g_slist_free(items); | ||
2035 | 898 | 876 | ||
2036 | 899 | if (has_groups) { // recurse if we unwrapped a group - it may have contained others | 877 | if (has_groups) { // recurse if we unwrapped a group - it may have contained others |
2037 | 900 | out = sp_degroup_list(out); | 878 | out = sp_degroup_list(out); |
2038 | @@ -906,18 +884,19 @@ | |||
2039 | 906 | 884 | ||
2040 | 907 | /** If items in the list have a common parent, return it, otherwise return NULL */ | 885 | /** If items in the list have a common parent, return it, otherwise return NULL */ |
2041 | 908 | static SPGroup * | 886 | static SPGroup * |
2043 | 909 | sp_item_list_common_parent_group(GSList const *items) | 887 | sp_item_list_common_parent_group(std::vector<SPItem*> const items) |
2044 | 910 | { | 888 | { |
2046 | 911 | if (!items) { | 889 | if (items.empty()) { |
2047 | 912 | return NULL; | 890 | return NULL; |
2048 | 913 | } | 891 | } |
2050 | 914 | SPObject *parent = SP_OBJECT(items->data)->parent; | 892 | SPObject *parent = items[0]->parent; |
2051 | 915 | // Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor | 893 | // Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor |
2052 | 916 | if (!dynamic_cast<SPGroup *>(parent)) { | 894 | if (!dynamic_cast<SPGroup *>(parent)) { |
2053 | 917 | return NULL; | 895 | return NULL; |
2054 | 918 | } | 896 | } |
2057 | 919 | for (items = items->next; items; items = items->next) { | 897 | for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();item++) { |
2058 | 920 | if (SP_OBJECT(items->data)->parent != parent) { | 898 | if((*item)==items[0])continue; |
2059 | 899 | if ((*item)->parent != parent) { | ||
2060 | 921 | return NULL; | 900 | return NULL; |
2061 | 922 | } | 901 | } |
2062 | 923 | } | 902 | } |
2063 | @@ -927,13 +906,13 @@ | |||
2064 | 927 | 906 | ||
2065 | 928 | /** Finds out the minimum common bbox of the selected items. */ | 907 | /** Finds out the minimum common bbox of the selected items. */ |
2066 | 929 | static Geom::OptRect | 908 | static Geom::OptRect |
2068 | 930 | enclose_items(GSList const *items) | 909 | enclose_items(std::vector<SPItem*> const &items) |
2069 | 931 | { | 910 | { |
2071 | 932 | g_assert(items != NULL); | 911 | g_assert(!items.empty()); |
2072 | 933 | 912 | ||
2073 | 934 | Geom::OptRect r; | 913 | Geom::OptRect r; |
2076 | 935 | for (GSList const *i = items; i; i = i->next) { | 914 | for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) { |
2077 | 936 | r.unionWith(static_cast<SPItem *>(i->data)->desktopVisualBounds()); | 915 | r.unionWith((*i)->desktopVisualBounds()); |
2078 | 937 | } | 916 | } |
2079 | 938 | return r; | 917 | return r; |
2080 | 939 | } | 918 | } |
2081 | @@ -948,11 +927,17 @@ | |||
2082 | 948 | return prev; | 927 | return prev; |
2083 | 949 | } | 928 | } |
2084 | 950 | 929 | ||
2085 | 930 | int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) | ||
2086 | 931 | { | ||
2087 | 932 | return sp_repr_compare_position(((SPItem*)first)->getRepr(), | ||
2088 | 933 | ((SPItem*)second)->getRepr())<0; | ||
2089 | 934 | } | ||
2090 | 935 | |||
2091 | 951 | void | 936 | void |
2092 | 952 | sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) | 937 | sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) |
2093 | 953 | { | 938 | { |
2096 | 954 | GSList const *items = const_cast<GSList *>(selection->itemList()); | 939 | std::vector<SPItem*> items= selection->itemList(); |
2097 | 955 | if (!items) { | 940 | if (items.empty()) { |
2098 | 956 | selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise.")); | 941 | selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise.")); |
2099 | 957 | return; | 942 | return; |
2100 | 958 | } | 943 | } |
2101 | @@ -966,16 +951,16 @@ | |||
2102 | 966 | Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr()); | 951 | Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr()); |
2103 | 967 | 952 | ||
2104 | 968 | /* Construct reverse-ordered list of selected children. */ | 953 | /* Construct reverse-ordered list of selected children. */ |
2107 | 969 | GSList *rev = g_slist_copy(const_cast<GSList *>(items)); | 954 | std::vector<SPItem*> rev(items); |
2108 | 970 | rev = g_slist_sort(rev, (GCompareFunc) sp_item_repr_compare_position); | 955 | sort(rev.begin(),rev.end(),sp_item_repr_compare_position); |
2109 | 971 | 956 | ||
2110 | 972 | // Determine the common bbox of the selected items. | 957 | // Determine the common bbox of the selected items. |
2111 | 973 | Geom::OptRect selected = enclose_items(items); | 958 | Geom::OptRect selected = enclose_items(items); |
2112 | 974 | 959 | ||
2113 | 975 | // Iterate over all objects in the selection (starting from top). | 960 | // Iterate over all objects in the selection (starting from top). |
2114 | 976 | if (selected) { | 961 | if (selected) { |
2117 | 977 | while (rev) { | 962 | for (std::vector<SPItem*>::const_iterator item=rev.begin();item!=rev.end();item++) { |
2118 | 978 | SPObject *child = reinterpret_cast<SPObject*>(rev->data); | 963 | SPObject *child = *item; |
2119 | 979 | // for each selected object, find the next sibling | 964 | // for each selected object, find the next sibling |
2120 | 980 | for (SPObject *newref = child->next; newref; newref = newref->next) { | 965 | for (SPObject *newref = child->next; newref; newref = newref->next) { |
2121 | 981 | // if the sibling is an item AND overlaps our selection, | 966 | // if the sibling is an item AND overlaps our selection, |
2122 | @@ -984,7 +969,7 @@ | |||
2123 | 984 | Geom::OptRect newref_bbox = newItem->desktopVisualBounds(); | 969 | Geom::OptRect newref_bbox = newItem->desktopVisualBounds(); |
2124 | 985 | if ( newref_bbox && selected->intersects(*newref_bbox) ) { | 970 | if ( newref_bbox && selected->intersects(*newref_bbox) ) { |
2125 | 986 | // AND if it's not one of our selected objects, | 971 | // AND if it's not one of our selected objects, |
2127 | 987 | if (!g_slist_find(const_cast<GSList *>(items), newref)) { | 972 | if ( std::find(items.begin(),items.end(),newref)==items.end()) { |
2128 | 988 | // move the selected object after that sibling | 973 | // move the selected object after that sibling |
2129 | 989 | grepr->changeOrder(child->getRepr(), newref->getRepr()); | 974 | grepr->changeOrder(child->getRepr(), newref->getRepr()); |
2130 | 990 | } | 975 | } |
2131 | @@ -992,12 +977,8 @@ | |||
2132 | 992 | } | 977 | } |
2133 | 993 | } | 978 | } |
2134 | 994 | } | 979 | } |
2135 | 995 | rev = g_slist_remove(rev, child); | ||
2136 | 996 | } | 980 | } |
2137 | 997 | } else { | ||
2138 | 998 | g_slist_free(rev); | ||
2139 | 999 | } | 981 | } |
2140 | 1000 | |||
2141 | 1001 | DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, | 982 | DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, |
2142 | 1002 | //TRANSLATORS: "Raise" means "to raise an object" in the undo history | 983 | //TRANSLATORS: "Raise" means "to raise an object" in the undo history |
2143 | 1003 | C_("Undo action", "Raise")); | 984 | C_("Undo action", "Raise")); |
2144 | @@ -1012,7 +993,7 @@ | |||
2145 | 1012 | return; | 993 | return; |
2146 | 1013 | } | 994 | } |
2147 | 1014 | 995 | ||
2149 | 1015 | GSList const *items = const_cast<GSList *>(selection->itemList()); | 996 | std::vector<SPItem*> items = selection->itemList(); |
2150 | 1016 | 997 | ||
2151 | 1017 | SPGroup const *group = sp_item_list_common_parent_group(items); | 998 | SPGroup const *group = sp_item_list_common_parent_group(items); |
2152 | 1018 | if (!group) { | 999 | if (!group) { |
2153 | @@ -1020,24 +1001,22 @@ | |||
2154 | 1020 | return; | 1001 | return; |
2155 | 1021 | } | 1002 | } |
2156 | 1022 | 1003 | ||
2159 | 1023 | GSList *rl = g_slist_copy(const_cast<GSList *>(selection->reprList())); | 1004 | std::vector<Inkscape::XML::Node*> rl(selection->reprList()); |
2160 | 1024 | rl = g_slist_sort(rl, (GCompareFunc) sp_repr_compare_position); | 1005 | sort(rl.begin(),rl.end(),sp_repr_compare_position); |
2161 | 1025 | 1006 | ||
2164 | 1026 | for (GSList *l = rl; l != NULL; l = l->next) { | 1007 | for (std::vector<Inkscape::XML::Node*>::const_iterator l=rl.begin(); l!=rl.end();l++) { |
2165 | 1027 | Inkscape::XML::Node *repr = static_cast<Inkscape::XML::Node *>(l->data); | 1008 | Inkscape::XML::Node *repr =(*l); |
2166 | 1028 | repr->setPosition(-1); | 1009 | repr->setPosition(-1); |
2167 | 1029 | } | 1010 | } |
2168 | 1030 | 1011 | ||
2169 | 1031 | g_slist_free(rl); | ||
2170 | 1032 | |||
2171 | 1033 | DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, | 1012 | DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, |
2172 | 1034 | _("Raise to top")); | 1013 | _("Raise to top")); |
2173 | 1035 | } | 1014 | } |
2174 | 1036 | 1015 | ||
2175 | 1037 | void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) | 1016 | void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) |
2176 | 1038 | { | 1017 | { |
2179 | 1039 | GSList const *items = const_cast<GSList *>(selection->itemList()); | 1018 | std::vector<SPItem*> items = selection->itemList(); |
2180 | 1040 | if (!items) { | 1019 | if (items.empty()) { |
2181 | 1041 | selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower.")); | 1020 | selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower.")); |
2182 | 1042 | return; | 1021 | return; |
2183 | 1043 | } | 1022 | } |
2184 | @@ -1054,14 +1033,13 @@ | |||
2185 | 1054 | Geom::OptRect selected = enclose_items(items); | 1033 | Geom::OptRect selected = enclose_items(items); |
2186 | 1055 | 1034 | ||
2187 | 1056 | /* Construct direct-ordered list of selected children. */ | 1035 | /* Construct direct-ordered list of selected children. */ |
2191 | 1057 | GSList *rev = g_slist_copy(const_cast<GSList *>(items)); | 1036 | std::vector<SPItem*> rev(items); |
2192 | 1058 | rev = g_slist_sort(rev, (GCompareFunc) sp_item_repr_compare_position); | 1037 | sort(rev.begin(),rev.end(),sp_item_repr_compare_position); |
2190 | 1059 | rev = g_slist_reverse(rev); | ||
2193 | 1060 | 1038 | ||
2194 | 1061 | // Iterate over all objects in the selection (starting from top). | 1039 | // Iterate over all objects in the selection (starting from top). |
2195 | 1062 | if (selected) { | 1040 | if (selected) { |
2198 | 1063 | while (rev) { | 1041 | for (std::vector<SPItem*>::const_reverse_iterator item=rev.rbegin();item!=rev.rend();item++) { |
2199 | 1064 | SPObject *child = reinterpret_cast<SPObject*>(rev->data); | 1042 | SPObject *child = *item; |
2200 | 1065 | // for each selected object, find the prev sibling | 1043 | // for each selected object, find the prev sibling |
2201 | 1066 | for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) { | 1044 | for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) { |
2202 | 1067 | // if the sibling is an item AND overlaps our selection, | 1045 | // if the sibling is an item AND overlaps our selection, |
2203 | @@ -1070,7 +1048,7 @@ | |||
2204 | 1070 | Geom::OptRect ref_bbox = newItem->desktopVisualBounds(); | 1048 | Geom::OptRect ref_bbox = newItem->desktopVisualBounds(); |
2205 | 1071 | if ( ref_bbox && selected->intersects(*ref_bbox) ) { | 1049 | if ( ref_bbox && selected->intersects(*ref_bbox) ) { |
2206 | 1072 | // AND if it's not one of our selected objects, | 1050 | // AND if it's not one of our selected objects, |
2208 | 1073 | if (!g_slist_find(const_cast<GSList *>(items), newref)) { | 1051 | if (items.end()==std::find(items.begin(),items.end(),newref)) { |
2209 | 1074 | // move the selected object before that sibling | 1052 | // move the selected object before that sibling |
2210 | 1075 | SPObject *put_after = prev_sibling(newref); | 1053 | SPObject *put_after = prev_sibling(newref); |
2211 | 1076 | if (put_after) | 1054 | if (put_after) |
2212 | @@ -1082,10 +1060,7 @@ | |||
2213 | 1082 | } | 1060 | } |
2214 | 1083 | } | 1061 | } |
2215 | 1084 | } | 1062 | } |
2216 | 1085 | rev = g_slist_remove(rev, child); | ||
2217 | 1086 | } | 1063 | } |
2218 | 1087 | } else { | ||
2219 | 1088 | g_slist_free(rev); | ||
2220 | 1089 | } | 1064 | } |
2221 | 1090 | 1065 | ||
2222 | 1091 | DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, | 1066 | DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, |
2223 | @@ -1102,7 +1077,7 @@ | |||
2224 | 1102 | return; | 1077 | return; |
2225 | 1103 | } | 1078 | } |
2226 | 1104 | 1079 | ||
2228 | 1105 | GSList const *items = const_cast<GSList *>(selection->itemList()); | 1080 | std::vector<SPItem*> items =selection->itemList(); |
2229 | 1106 | 1081 | ||
2230 | 1107 | SPGroup const *group = sp_item_list_common_parent_group(items); | 1082 | SPGroup const *group = sp_item_list_common_parent_group(items); |
2231 | 1108 | if (!group) { | 1083 | if (!group) { |
2232 | @@ -1110,15 +1085,13 @@ | |||
2233 | 1110 | return; | 1085 | return; |
2234 | 1111 | } | 1086 | } |
2235 | 1112 | 1087 | ||
2240 | 1113 | GSList *rl; | 1088 | std::vector<Inkscape::XML::Node*> rl(selection->reprList()); |
2241 | 1114 | rl = g_slist_copy(const_cast<GSList *>(selection->reprList())); | 1089 | sort(rl.begin(),rl.end(),sp_repr_compare_position); |
2238 | 1115 | rl = g_slist_sort(rl, (GCompareFunc) sp_repr_compare_position); | ||
2239 | 1116 | rl = g_slist_reverse(rl); | ||
2242 | 1117 | 1090 | ||
2244 | 1118 | for (GSList *l = rl; l != NULL; l = l->next) { | 1091 | for (std::vector<Inkscape::XML::Node*>::const_reverse_iterator l=rl.rbegin();l!=rl.rend();l++) { |
2245 | 1119 | gint minpos; | 1092 | gint minpos; |
2246 | 1120 | SPObject *pp, *pc; | 1093 | SPObject *pp, *pc; |
2248 | 1121 | Inkscape::XML::Node *repr = static_cast<Inkscape::XML::Node *>(l->data); | 1094 | Inkscape::XML::Node *repr = (*l); |
2249 | 1122 | pp = document->getObjectByRepr(repr->parent()); | 1095 | pp = document->getObjectByRepr(repr->parent()); |
2250 | 1123 | minpos = 0; | 1096 | minpos = 0; |
2251 | 1124 | g_assert(dynamic_cast<SPGroup *>(pp)); | 1097 | g_assert(dynamic_cast<SPGroup *>(pp)); |
2252 | @@ -1130,8 +1103,6 @@ | |||
2253 | 1130 | repr->setPosition(minpos); | 1103 | repr->setPosition(minpos); |
2254 | 1131 | } | 1104 | } |
2255 | 1132 | 1105 | ||
2256 | 1133 | g_slist_free(rl); | ||
2257 | 1134 | |||
2258 | 1135 | DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, | 1106 | DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, |
2259 | 1136 | _("Lower to bottom")); | 1107 | _("Lower to bottom")); |
2260 | 1137 | } | 1108 | } |
2261 | @@ -1269,9 +1240,9 @@ | |||
2262 | 1269 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from.")); | 1240 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from.")); |
2263 | 1270 | return; | 1241 | return; |
2264 | 1271 | } | 1242 | } |
2268 | 1272 | 1243 | std::vector<SPItem*> list=selection->itemList(); | |
2269 | 1273 | for ( GSList const *itemlist = selection->itemList(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) { | 1244 | for ( std::vector<SPItem*>::const_iterator itemlist=list.begin();itemlist!=list.end();itemlist++) { |
2270 | 1274 | SPItem *item = reinterpret_cast<SPItem*>(itemlist->data); | 1245 | SPItem *item = *itemlist; |
2271 | 1275 | 1246 | ||
2272 | 1276 | sp_selection_remove_livepatheffect_impl(item); | 1247 | sp_selection_remove_livepatheffect_impl(item); |
2273 | 1277 | 1248 | ||
2274 | @@ -1325,10 +1296,10 @@ | |||
2275 | 1325 | * Ensures that the clones of objects are not modified when moving objects between layers. | 1296 | * Ensures that the clones of objects are not modified when moving objects between layers. |
2276 | 1326 | * Calls the same function as ungroup | 1297 | * Calls the same function as ungroup |
2277 | 1327 | */ | 1298 | */ |
2279 | 1328 | void sp_selection_change_layer_maintain_clones(GSList const *items,SPObject *where) | 1299 | void sp_selection_change_layer_maintain_clones(std::vector<SPItem*> const &items,SPObject *where) |
2280 | 1329 | { | 1300 | { |
2283 | 1330 | for (const GSList *i = items; i != NULL; i = i->next) { | 1301 | for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) { |
2284 | 1331 | SPItem *item = dynamic_cast<SPItem *>(SP_OBJECT(i->data)); | 1302 | SPItem *item = *i; |
2285 | 1332 | if (item) { | 1303 | if (item) { |
2286 | 1333 | SPItem *oldparent = dynamic_cast<SPItem *>(item->parent); | 1304 | SPItem *oldparent = dynamic_cast<SPItem *>(item->parent); |
2287 | 1334 | SPItem *newparent = dynamic_cast<SPItem *>(where); | 1305 | SPItem *newparent = dynamic_cast<SPItem *>(where); |
2288 | @@ -1350,26 +1321,24 @@ | |||
2289 | 1350 | return; | 1321 | return; |
2290 | 1351 | } | 1322 | } |
2291 | 1352 | 1323 | ||
2293 | 1353 | GSList const *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); | 1324 | std::vector<SPItem*> items(selection->itemList()); |
2294 | 1354 | 1325 | ||
2295 | 1355 | bool no_more = false; // Set to true, if no more layers above | 1326 | bool no_more = false; // Set to true, if no more layers above |
2296 | 1356 | SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); | 1327 | SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); |
2297 | 1357 | if (next) { | 1328 | if (next) { |
2298 | 1358 | sp_selection_change_layer_maintain_clones(items,next); | 1329 | sp_selection_change_layer_maintain_clones(items,next); |
2301 | 1359 | GSList *temp_clip = NULL; | 1330 | std::vector<Inkscape::XML::Node*> temp_clip; |
2302 | 1360 | sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); | 1331 | sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); |
2303 | 1361 | sp_selection_delete_impl(items, false, false); | 1332 | sp_selection_delete_impl(items, false, false); |
2304 | 1362 | next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers | 1333 | next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers |
2306 | 1363 | GSList *copied; | 1334 | std::vector<Inkscape::XML::Node*> copied; |
2307 | 1364 | if (next) { | 1335 | if (next) { |
2309 | 1365 | copied = sp_selection_paste_impl(dt->getDocument(), next, &temp_clip); | 1336 | copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip); |
2310 | 1366 | } else { | 1337 | } else { |
2312 | 1367 | copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), &temp_clip); | 1338 | copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), temp_clip); |
2313 | 1368 | no_more = true; | 1339 | no_more = true; |
2314 | 1369 | } | 1340 | } |
2318 | 1370 | selection->setReprList((GSList const *) copied); | 1341 | selection->setReprList(copied); |
2316 | 1371 | g_slist_free(copied); | ||
2317 | 1372 | if (temp_clip) g_slist_free(temp_clip); | ||
2319 | 1373 | if (next) dt->setCurrentLayer(next); | 1342 | if (next) dt->setCurrentLayer(next); |
2320 | 1374 | if ( !suppressDone ) { | 1343 | if ( !suppressDone ) { |
2321 | 1375 | DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT, | 1344 | DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT, |
2322 | @@ -1383,7 +1352,6 @@ | |||
2323 | 1383 | dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers above.")); | 1352 | dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers above.")); |
2324 | 1384 | } | 1353 | } |
2325 | 1385 | 1354 | ||
2326 | 1386 | g_slist_free(const_cast<GSList *>(items)); | ||
2327 | 1387 | } | 1355 | } |
2328 | 1388 | 1356 | ||
2329 | 1389 | void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) | 1357 | void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) |
2330 | @@ -1396,26 +1364,24 @@ | |||
2331 | 1396 | return; | 1364 | return; |
2332 | 1397 | } | 1365 | } |
2333 | 1398 | 1366 | ||
2335 | 1399 | GSList const *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); | 1367 | const std::vector<SPItem*> items(selection->itemList()); |
2336 | 1400 | 1368 | ||
2337 | 1401 | bool no_more = false; // Set to true, if no more layers below | 1369 | bool no_more = false; // Set to true, if no more layers below |
2338 | 1402 | SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); | 1370 | SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); |
2339 | 1403 | if (next) { | 1371 | if (next) { |
2340 | 1404 | sp_selection_change_layer_maintain_clones(items,next); | 1372 | sp_selection_change_layer_maintain_clones(items,next); |
2343 | 1405 | GSList *temp_clip = NULL; | 1373 | std::vector<Inkscape::XML::Node*> temp_clip; |
2344 | 1406 | sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs | 1374 | sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs |
2345 | 1407 | sp_selection_delete_impl(items, false, false); | 1375 | sp_selection_delete_impl(items, false, false); |
2346 | 1408 | next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers | 1376 | next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers |
2348 | 1409 | GSList *copied; | 1377 | std::vector<Inkscape::XML::Node*> copied; |
2349 | 1410 | if (next) { | 1378 | if (next) { |
2351 | 1411 | copied = sp_selection_paste_impl(dt->getDocument(), next, &temp_clip); | 1379 | copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip); |
2352 | 1412 | } else { | 1380 | } else { |
2354 | 1413 | copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), &temp_clip); | 1381 | copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), temp_clip); |
2355 | 1414 | no_more = true; | 1382 | no_more = true; |
2356 | 1415 | } | 1383 | } |
2360 | 1416 | selection->setReprList((GSList const *) copied); | 1384 | selection->setReprList( copied); |
2358 | 1417 | g_slist_free(copied); | ||
2359 | 1418 | if (temp_clip) g_slist_free(temp_clip); | ||
2361 | 1419 | if (next) dt->setCurrentLayer(next); | 1385 | if (next) dt->setCurrentLayer(next); |
2362 | 1420 | if ( !suppressDone ) { | 1386 | if ( !suppressDone ) { |
2363 | 1421 | DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV, | 1387 | DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV, |
2364 | @@ -1428,8 +1394,6 @@ | |||
2365 | 1428 | if (no_more) { | 1394 | if (no_more) { |
2366 | 1429 | dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers below.")); | 1395 | dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers below.")); |
2367 | 1430 | } | 1396 | } |
2368 | 1431 | |||
2369 | 1432 | g_slist_free(const_cast<GSList *>(items)); | ||
2370 | 1433 | } | 1397 | } |
2371 | 1434 | 1398 | ||
2372 | 1435 | void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) | 1399 | void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) |
2373 | @@ -1442,25 +1406,22 @@ | |||
2374 | 1442 | return; | 1406 | return; |
2375 | 1443 | } | 1407 | } |
2376 | 1444 | 1408 | ||
2378 | 1445 | GSList const *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); | 1409 | std::vector<SPItem*> items(selection->itemList()); |
2379 | 1446 | 1410 | ||
2380 | 1447 | if (moveto) { | 1411 | if (moveto) { |
2381 | 1448 | sp_selection_change_layer_maintain_clones(items,moveto); | 1412 | sp_selection_change_layer_maintain_clones(items,moveto); |
2384 | 1449 | GSList *temp_clip = NULL; | 1413 | std::vector<Inkscape::XML::Node*> temp_clip; |
2385 | 1450 | sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs | 1414 | sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs |
2386 | 1451 | sp_selection_delete_impl(items, false, false); | 1415 | sp_selection_delete_impl(items, false, false); |
2391 | 1452 | GSList *copied = sp_selection_paste_impl(dt->getDocument(), moveto, &temp_clip); | 1416 | std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip); |
2392 | 1453 | selection->setReprList((GSList const *) copied); | 1417 | selection->setReprList(copied); |
2393 | 1454 | g_slist_free(copied); | 1418 | if (!temp_clip.empty()) temp_clip.clear(); |
2390 | 1455 | if (temp_clip) g_slist_free(temp_clip); | ||
2394 | 1456 | if (moveto) dt->setCurrentLayer(moveto); | 1419 | if (moveto) dt->setCurrentLayer(moveto); |
2395 | 1457 | if ( !suppressDone ) { | 1420 | if ( !suppressDone ) { |
2396 | 1458 | DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO, | 1421 | DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO, |
2397 | 1459 | _("Move selection to layer")); | 1422 | _("Move selection to layer")); |
2398 | 1460 | } | 1423 | } |
2399 | 1461 | } | 1424 | } |
2400 | 1462 | |||
2401 | 1463 | g_slist_free(const_cast<GSList *>(items)); | ||
2402 | 1464 | } | 1425 | } |
2403 | 1465 | 1426 | ||
2404 | 1466 | static bool | 1427 | static bool |
2405 | @@ -1495,8 +1456,9 @@ | |||
2406 | 1495 | selection_contains_both_clone_and_original(Inkscape::Selection *selection) | 1456 | selection_contains_both_clone_and_original(Inkscape::Selection *selection) |
2407 | 1496 | { | 1457 | { |
2408 | 1497 | bool clone_with_original = false; | 1458 | bool clone_with_original = false; |
2411 | 1498 | for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { | 1459 | std::vector<SPItem*> items = selection->itemList(); |
2412 | 1499 | SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data)); | 1460 | for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) { |
2413 | 1461 | SPItem *item = *l; | ||
2414 | 1500 | if (item) { | 1462 | if (item) { |
2415 | 1501 | clone_with_original |= selection_contains_original(item, selection); | 1463 | clone_with_original |= selection_contains_original(item, selection); |
2416 | 1502 | if (clone_with_original) | 1464 | if (clone_with_original) |
2417 | @@ -1539,9 +1501,9 @@ | |||
2418 | 1539 | 1501 | ||
2419 | 1540 | persp3d_apply_affine_transformation(transf_persp, affine); | 1502 | persp3d_apply_affine_transformation(transf_persp, affine); |
2420 | 1541 | } | 1503 | } |
2424 | 1542 | 1504 | std::vector<SPItem*> items = selection->itemList(); | |
2425 | 1543 | for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { | 1505 | for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) { |
2426 | 1544 | SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data)); | 1506 | SPItem *item = *l; |
2427 | 1545 | 1507 | ||
2428 | 1546 | if( dynamic_cast<SPRoot *>(item) ) { | 1508 | if( dynamic_cast<SPRoot *>(item) ) { |
2429 | 1547 | // An SVG element cannot have a transform. We could change 'x' and 'y' in response | 1509 | // An SVG element cannot have a transform. We could change 'x' and 'y' in response |
2430 | @@ -1710,10 +1672,9 @@ | |||
2431 | 1710 | 1672 | ||
2432 | 1711 | Inkscape::Selection *selection = desktop->getSelection(); | 1673 | Inkscape::Selection *selection = desktop->getSelection(); |
2433 | 1712 | 1674 | ||
2438 | 1713 | GSList const *l = const_cast<GSList *>(selection->reprList()); | 1675 | std::vector<Inkscape::XML::Node*> items = selection->reprList(); |
2439 | 1714 | while (l != NULL) { | 1676 | for (std::vector<Inkscape::XML::Node*>::const_iterator l=items.begin();l!=items.end() ;l++) { |
2440 | 1715 | ((Inkscape::XML::Node*)l->data)->setAttribute("transform", NULL, false); | 1677 | (*l)->setAttribute("transform", NULL, false); |
2437 | 1716 | l = l->next; | ||
2441 | 1717 | } | 1678 | } |
2442 | 1718 | 1679 | ||
2443 | 1719 | DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_FLATTEN, | 1680 | DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_FLATTEN, |
2444 | @@ -1811,10 +1772,10 @@ | |||
2445 | 1811 | if (selection->isEmpty()) | 1772 | if (selection->isEmpty()) |
2446 | 1812 | return; | 1773 | return; |
2447 | 1813 | 1774 | ||
2449 | 1814 | GSList const *l = selection->itemList(); | 1775 | std::vector<SPItem*> items = selection->itemList(); |
2450 | 1815 | Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw | 1776 | Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw |
2453 | 1816 | for (GSList const *l2 = l ; l2 != NULL ; l2 = l2->next) { | 1777 | for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) { |
2454 | 1817 | SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l2->data)); | 1778 | SPItem *item = *l; |
2455 | 1818 | if (item) { | 1779 | if (item) { |
2456 | 1819 | sp_item_rotate_rel(item, rot_90); | 1780 | sp_item_rotate_rel(item, rot_90); |
2457 | 1820 | } else { | 1781 | } else { |
2458 | @@ -1870,15 +1831,15 @@ | |||
2459 | 1870 | bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); | 1831 | bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); |
2460 | 1871 | bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); | 1832 | bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); |
2461 | 1872 | bool ingroups = TRUE; | 1833 | bool ingroups = TRUE; |
2465 | 1873 | 1834 | std::vector<SPItem*> x,y; | |
2466 | 1874 | GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL); | 1835 | std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); |
2467 | 1875 | GSList *all_matches = NULL; | 1836 | std::vector<SPItem*> all_matches; |
2468 | 1876 | 1837 | ||
2469 | 1877 | Inkscape::Selection *selection = desktop->getSelection(); | 1838 | Inkscape::Selection *selection = desktop->getSelection(); |
2474 | 1878 | 1839 | std::vector<SPItem*> items = selection->itemList(); | |
2475 | 1879 | for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) { | 1840 | for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { |
2476 | 1880 | SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(sel_iter->data)); | 1841 | SPItem *sel = *sel_iter; |
2477 | 1881 | GSList *matches = all_list; | 1842 | std::vector<SPItem*> matches = all_list; |
2478 | 1882 | if (fill && stroke && style) { | 1843 | if (fill && stroke && style) { |
2479 | 1883 | matches = sp_get_same_style(sel, matches); | 1844 | matches = sp_get_same_style(sel, matches); |
2480 | 1884 | } | 1845 | } |
2481 | @@ -1891,19 +1852,12 @@ | |||
2482 | 1891 | else if (style) { | 1852 | else if (style) { |
2483 | 1892 | matches = sp_get_same_style(sel, matches,SP_STROKE_STYLE_ALL); | 1853 | matches = sp_get_same_style(sel, matches,SP_STROKE_STYLE_ALL); |
2484 | 1893 | } | 1854 | } |
2486 | 1894 | all_matches = g_slist_concat (all_matches, matches); | 1855 | all_matches.insert(all_matches.end(), matches.begin(),matches.end()); |
2487 | 1895 | } | 1856 | } |
2488 | 1896 | 1857 | ||
2489 | 1897 | selection->clear(); | 1858 | selection->clear(); |
2490 | 1898 | selection->setList(all_matches); | 1859 | selection->setList(all_matches); |
2491 | 1899 | 1860 | ||
2492 | 1900 | if (all_matches) { | ||
2493 | 1901 | g_slist_free(all_matches); | ||
2494 | 1902 | } | ||
2495 | 1903 | if (all_list) { | ||
2496 | 1904 | g_slist_free(all_list); | ||
2497 | 1905 | } | ||
2498 | 1906 | |||
2499 | 1907 | } | 1861 | } |
2500 | 1908 | 1862 | ||
2501 | 1909 | 1863 | ||
2502 | @@ -1924,14 +1878,15 @@ | |||
2503 | 1924 | bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); | 1878 | bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); |
2504 | 1925 | bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); | 1879 | bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); |
2505 | 1926 | bool ingroups = TRUE; | 1880 | bool ingroups = TRUE; |
2509 | 1927 | 1881 | std::vector<SPItem*> x,y; | |
2510 | 1928 | GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL); | 1882 | std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); |
2511 | 1929 | GSList *matches = all_list; | 1883 | std::vector<SPItem*> matches = all_list; |
2512 | 1930 | 1884 | ||
2513 | 1931 | Inkscape::Selection *selection = desktop->getSelection(); | 1885 | Inkscape::Selection *selection = desktop->getSelection(); |
2514 | 1932 | 1886 | ||
2517 | 1933 | for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) { | 1887 | std::vector<SPItem*> items=selection->itemList(); |
2518 | 1934 | SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(sel_iter->data)); | 1888 | for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { |
2519 | 1889 | SPItem *sel = *sel_iter; | ||
2520 | 1935 | if (sel) { | 1890 | if (sel) { |
2521 | 1936 | matches = sp_get_same_object_type(sel, matches); | 1891 | matches = sp_get_same_object_type(sel, matches); |
2522 | 1937 | } else { | 1892 | } else { |
2523 | @@ -1942,12 +1897,6 @@ | |||
2524 | 1942 | selection->clear(); | 1897 | selection->clear(); |
2525 | 1943 | selection->setList(matches); | 1898 | selection->setList(matches); |
2526 | 1944 | 1899 | ||
2527 | 1945 | if (matches) { | ||
2528 | 1946 | g_slist_free(matches); | ||
2529 | 1947 | } | ||
2530 | 1948 | if (all_list) { | ||
2531 | 1949 | g_slist_free(all_list); | ||
2532 | 1950 | } | ||
2533 | 1951 | } | 1900 | } |
2534 | 1952 | 1901 | ||
2535 | 1953 | 1902 | ||
2536 | @@ -1956,15 +1905,15 @@ | |||
2537 | 1956 | * Find all items in src list that have the same fill or stroke style as sel | 1905 | * Find all items in src list that have the same fill or stroke style as sel |
2538 | 1957 | * Return the list of matching items | 1906 | * Return the list of matching items |
2539 | 1958 | */ | 1907 | */ |
2541 | 1959 | GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrokeStyleType type) | 1908 | std::vector<SPItem*> sp_get_same_fill_or_stroke_color(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type) |
2542 | 1960 | { | 1909 | { |
2544 | 1961 | GSList *matches = NULL; | 1910 | std::vector<SPItem*> matches ; |
2545 | 1962 | gboolean match = false; | 1911 | gboolean match = false; |
2546 | 1963 | 1912 | ||
2547 | 1964 | SPIPaint *sel_paint = (type == SP_FILL_COLOR) ? &(sel->style->fill) : &(sel->style->stroke); | 1913 | SPIPaint *sel_paint = (type == SP_FILL_COLOR) ? &(sel->style->fill) : &(sel->style->stroke); |
2548 | 1965 | 1914 | ||
2551 | 1966 | for (GSList *i = src; i != NULL; i = i->next) { | 1915 | for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { |
2552 | 1967 | SPItem *iter = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data)); | 1916 | SPItem *iter = *i; |
2553 | 1968 | if (iter) { | 1917 | if (iter) { |
2554 | 1969 | SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke); | 1918 | SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke); |
2555 | 1970 | match = false; | 1919 | match = false; |
2556 | @@ -2003,7 +1952,7 @@ | |||
2557 | 2003 | } | 1952 | } |
2558 | 2004 | 1953 | ||
2559 | 2005 | if (match) { | 1954 | if (match) { |
2561 | 2006 | matches = g_slist_prepend(matches, iter); | 1955 | matches.push_back(iter); |
2562 | 2007 | } | 1956 | } |
2563 | 2008 | } else { | 1957 | } else { |
2564 | 2009 | g_assert_not_reached(); | 1958 | g_assert_not_reached(); |
2565 | @@ -2054,17 +2003,16 @@ | |||
2566 | 2054 | * Find all items in src list that have the same object type as sel by type | 2003 | * Find all items in src list that have the same object type as sel by type |
2567 | 2055 | * Return the list of matching items | 2004 | * Return the list of matching items |
2568 | 2056 | */ | 2005 | */ |
2570 | 2057 | GSList *sp_get_same_object_type(SPItem *sel, GSList *src) | 2006 | std::vector<SPItem*> sp_get_same_object_type(SPItem *sel, std::vector<SPItem*> &src) |
2571 | 2058 | { | 2007 | { |
2573 | 2059 | GSList *matches = NULL; | 2008 | std::vector<SPItem*> matches; |
2574 | 2060 | 2009 | ||
2577 | 2061 | for (GSList *i = src; i != NULL; i = i->next) { | 2010 | for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { |
2578 | 2062 | SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data)); | 2011 | SPItem *item = *i; |
2579 | 2063 | if (item && item_type_match(sel, item) && !item->cloned) { | 2012 | if (item && item_type_match(sel, item) && !item->cloned) { |
2581 | 2064 | matches = g_slist_prepend (matches, item); | 2013 | matches.push_back(item); |
2582 | 2065 | } | 2014 | } |
2583 | 2066 | } | 2015 | } |
2584 | 2067 | |||
2585 | 2068 | return matches; | 2016 | return matches; |
2586 | 2069 | } | 2017 | } |
2587 | 2070 | 2018 | ||
2588 | @@ -2074,9 +2022,9 @@ | |||
2589 | 2074 | * Find all items in src list that have the same stroke style as sel by type | 2022 | * Find all items in src list that have the same stroke style as sel by type |
2590 | 2075 | * Return the list of matching items | 2023 | * Return the list of matching items |
2591 | 2076 | */ | 2024 | */ |
2593 | 2077 | GSList *sp_get_same_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type) | 2025 | std::vector<SPItem*> sp_get_same_style(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type) |
2594 | 2078 | { | 2026 | { |
2596 | 2079 | GSList *matches = NULL; | 2027 | std::vector<SPItem*> matches; |
2597 | 2080 | bool match = false; | 2028 | bool match = false; |
2598 | 2081 | 2029 | ||
2599 | 2082 | SPStyle *sel_style = sel->style; | 2030 | SPStyle *sel_style = sel->style; |
2600 | @@ -2092,16 +2040,16 @@ | |||
2601 | 2092 | * Stroke width needs to handle transformations, so call this function | 2040 | * Stroke width needs to handle transformations, so call this function |
2602 | 2093 | * to get the transformed stroke width | 2041 | * to get the transformed stroke width |
2603 | 2094 | */ | 2042 | */ |
2605 | 2095 | GSList *objects = NULL; | 2043 | std::vector<SPItem*> objects; |
2606 | 2096 | SPStyle *sel_style_for_width = NULL; | 2044 | SPStyle *sel_style_for_width = NULL; |
2607 | 2097 | if (type == SP_STROKE_STYLE_WIDTH || type == SP_STROKE_STYLE_ALL || type==SP_STYLE_ALL ) { | 2045 | if (type == SP_STROKE_STYLE_WIDTH || type == SP_STROKE_STYLE_ALL || type==SP_STYLE_ALL ) { |
2609 | 2098 | objects = g_slist_prepend(objects, sel); | 2046 | objects.push_back(sel); |
2610 | 2099 | sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT); | 2047 | sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT); |
2611 | 2100 | objects_query_strokewidth (objects, sel_style_for_width); | 2048 | objects_query_strokewidth (objects, sel_style_for_width); |
2612 | 2101 | } | 2049 | } |
2613 | 2102 | bool match_g; | 2050 | bool match_g; |
2616 | 2103 | for (GSList *i = src; i != NULL; i = i->next) { | 2051 | for (std::vector<SPItem*>::const_iterator i=src.begin();i!=src.end();i++) { |
2617 | 2104 | SPItem *iter = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data)); | 2052 | SPItem *iter = *i; |
2618 | 2105 | if (iter) { | 2053 | if (iter) { |
2619 | 2106 | match_g=true; | 2054 | match_g=true; |
2620 | 2107 | SPStyle *iter_style = iter->style; | 2055 | SPStyle *iter_style = iter->style; |
2621 | @@ -2110,15 +2058,14 @@ | |||
2622 | 2110 | if (type == SP_STROKE_STYLE_WIDTH|| type == SP_STROKE_STYLE_ALL|| type==SP_STYLE_ALL) { | 2058 | if (type == SP_STROKE_STYLE_WIDTH|| type == SP_STROKE_STYLE_ALL|| type==SP_STYLE_ALL) { |
2623 | 2111 | match = (sel_style->stroke_width.set == iter_style->stroke_width.set); | 2059 | match = (sel_style->stroke_width.set == iter_style->stroke_width.set); |
2624 | 2112 | if (sel_style->stroke_width.set && iter_style->stroke_width.set) { | 2060 | if (sel_style->stroke_width.set && iter_style->stroke_width.set) { |
2627 | 2113 | GSList *objects = NULL; | 2061 | std::vector<SPItem*> objects; |
2628 | 2114 | objects = g_slist_prepend(objects, iter); | 2062 | objects.insert(objects.begin(),iter); |
2629 | 2115 | SPStyle tmp_style(SP_ACTIVE_DOCUMENT); | 2063 | SPStyle tmp_style(SP_ACTIVE_DOCUMENT); |
2630 | 2116 | objects_query_strokewidth (objects, &tmp_style); | 2064 | objects_query_strokewidth (objects, &tmp_style); |
2631 | 2117 | 2065 | ||
2632 | 2118 | if (sel_style_for_width) { | 2066 | if (sel_style_for_width) { |
2633 | 2119 | match = (sel_style_for_width->stroke_width.computed == tmp_style.stroke_width.computed); | 2067 | match = (sel_style_for_width->stroke_width.computed == tmp_style.stroke_width.computed); |
2634 | 2120 | } | 2068 | } |
2635 | 2121 | g_slist_free(objects); | ||
2636 | 2122 | } | 2069 | } |
2637 | 2123 | } | 2070 | } |
2638 | 2124 | match_g = match_g && match; | 2071 | match_g = match_g && match; |
2639 | @@ -2141,10 +2088,10 @@ | |||
2640 | 2141 | } | 2088 | } |
2641 | 2142 | } | 2089 | } |
2642 | 2143 | } | 2090 | } |
2644 | 2144 | match_g = match_g && match; | 2091 | match_g = match_g && match; |
2645 | 2145 | if (match_g) { | 2092 | if (match_g) { |
2646 | 2146 | while (iter->cloned) iter=dynamic_cast<SPItem *>(iter->parent); | 2093 | while (iter->cloned) iter=dynamic_cast<SPItem *>(iter->parent); |
2648 | 2147 | matches = g_slist_prepend(matches, iter); | 2094 | matches.insert(matches.begin(),iter); |
2649 | 2148 | } | 2095 | } |
2650 | 2149 | } else { | 2096 | } else { |
2651 | 2150 | g_assert_not_reached(); | 2097 | g_assert_not_reached(); |
2652 | @@ -2152,8 +2099,6 @@ | |||
2653 | 2152 | } | 2099 | } |
2654 | 2153 | 2100 | ||
2655 | 2154 | if( sel_style_for_width != NULL ) delete sel_style_for_width; | 2101 | if( sel_style_for_width != NULL ) delete sel_style_for_width; |
2656 | 2155 | g_slist_free(objects); | ||
2657 | 2156 | |||
2658 | 2157 | return matches; | 2102 | return matches; |
2659 | 2158 | } | 2103 | } |
2660 | 2159 | 2104 | ||
2661 | @@ -2307,17 +2252,9 @@ | |||
2662 | 2307 | } | 2252 | } |
2663 | 2308 | } | 2253 | } |
2664 | 2309 | 2254 | ||
2676 | 2310 | namespace { | 2255 | |
2677 | 2311 | 2256 | ||
2678 | 2312 | template <typename D> | 2257 | typedef struct Forward { |
2668 | 2313 | SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, | ||
2669 | 2314 | bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive); | ||
2670 | 2315 | |||
2671 | 2316 | template <typename D> | ||
2672 | 2317 | SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items, SPObject *root, | ||
2673 | 2318 | bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive); | ||
2674 | 2319 | |||
2675 | 2320 | struct Forward { | ||
2679 | 2321 | typedef SPObject *Iterator; | 2258 | typedef SPObject *Iterator; |
2680 | 2322 | 2259 | ||
2681 | 2323 | static Iterator children(SPObject *o) { return o->firstChild(); } | 2260 | static Iterator children(SPObject *o) { return o->firstChild(); } |
2682 | @@ -2326,9 +2263,9 @@ | |||
2683 | 2326 | 2263 | ||
2684 | 2327 | static SPObject *object(Iterator i) { return i; } | 2264 | static SPObject *object(Iterator i) { return i; } |
2685 | 2328 | static Iterator next(Iterator i) { return i->getNext(); } | 2265 | static Iterator next(Iterator i) { return i->getNext(); } |
2687 | 2329 | }; | 2266 | } Forward; |
2688 | 2330 | 2267 | ||
2690 | 2331 | struct ListReverse { | 2268 | typedef struct ListReverse { |
2691 | 2332 | typedef GSList *Iterator; | 2269 | typedef GSList *Iterator; |
2692 | 2333 | 2270 | ||
2693 | 2334 | static Iterator children(SPObject *o) { | 2271 | static Iterator children(SPObject *o) { |
2694 | @@ -2359,8 +2296,87 @@ | |||
2695 | 2359 | } | 2296 | } |
2696 | 2360 | return list; | 2297 | return list; |
2697 | 2361 | } | 2298 | } |
2700 | 2362 | }; | 2299 | } ListReverse; |
2701 | 2363 | 2300 | ||
2702 | 2301 | |||
2703 | 2302 | |||
2704 | 2303 | template <typename D> | ||
2705 | 2304 | SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, | ||
2706 | 2305 | bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) | ||
2707 | 2306 | { | ||
2708 | 2307 | typename D::Iterator children; | ||
2709 | 2308 | typename D::Iterator iter; | ||
2710 | 2309 | |||
2711 | 2310 | SPItem *found=NULL; | ||
2712 | 2311 | |||
2713 | 2312 | if (path) { | ||
2714 | 2313 | SPObject *object=reinterpret_cast<SPObject *>(path->data); | ||
2715 | 2314 | g_assert(object->parent == root); | ||
2716 | 2315 | if (desktop->isLayer(object)) { | ||
2717 | 2316 | found = next_item<D>(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); | ||
2718 | 2317 | } | ||
2719 | 2318 | iter = children = D::siblings_after(object); | ||
2720 | 2319 | } else { | ||
2721 | 2320 | iter = children = D::children(root); | ||
2722 | 2321 | } | ||
2723 | 2322 | |||
2724 | 2323 | while ( iter && !found ) { | ||
2725 | 2324 | SPObject *object=D::object(iter); | ||
2726 | 2325 | if (desktop->isLayer(object)) { | ||
2727 | 2326 | if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers | ||
2728 | 2327 | found = next_item<D>(desktop, NULL, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); | ||
2729 | 2328 | } | ||
2730 | 2329 | } else { | ||
2731 | 2330 | SPItem *item = dynamic_cast<SPItem *>(object); | ||
2732 | 2331 | if ( item && | ||
2733 | 2332 | ( !only_in_viewport || desktop->isWithinViewport(item) ) && | ||
2734 | 2333 | ( !onlyvisible || !desktop->itemIsHidden(item)) && | ||
2735 | 2334 | ( !onlysensitive || !item->isLocked()) && | ||
2736 | 2335 | !desktop->isLayer(item) ) | ||
2737 | 2336 | { | ||
2738 | 2337 | found = item; | ||
2739 | 2338 | } | ||
2740 | 2339 | } | ||
2741 | 2340 | iter = D::next(iter); | ||
2742 | 2341 | } | ||
2743 | 2342 | |||
2744 | 2343 | D::dispose(children); | ||
2745 | 2344 | |||
2746 | 2345 | return found; | ||
2747 | 2346 | } | ||
2748 | 2347 | |||
2749 | 2348 | |||
2750 | 2349 | template <typename D> | ||
2751 | 2350 | SPItem *next_item_from_list(SPDesktop *desktop, std::vector<SPItem*> const items, | ||
2752 | 2351 | SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) | ||
2753 | 2352 | { | ||
2754 | 2353 | SPObject *current=root; | ||
2755 | 2354 | for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) { | ||
2756 | 2355 | SPItem *item = *i; | ||
2757 | 2356 | if ( root->isAncestorOf(item) && | ||
2758 | 2357 | ( !only_in_viewport || desktop->isWithinViewport(item) ) ) | ||
2759 | 2358 | { | ||
2760 | 2359 | current = item; | ||
2761 | 2360 | break; | ||
2762 | 2361 | } | ||
2763 | 2362 | } | ||
2764 | 2363 | |||
2765 | 2364 | GSList *path=NULL; | ||
2766 | 2365 | while ( current != root ) { | ||
2767 | 2366 | path = g_slist_prepend(path, current); | ||
2768 | 2367 | current = current->parent; | ||
2769 | 2368 | } | ||
2770 | 2369 | |||
2771 | 2370 | SPItem *next; | ||
2772 | 2371 | // first, try from the current object | ||
2773 | 2372 | next = next_item<D>(desktop, path, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); | ||
2774 | 2373 | g_slist_free(path); | ||
2775 | 2374 | |||
2776 | 2375 | if (!next) { // if we ran out of objects, start over at the root | ||
2777 | 2376 | next = next_item<D>(desktop, NULL, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); | ||
2778 | 2377 | } | ||
2779 | 2378 | |||
2780 | 2379 | return next; | ||
2781 | 2364 | } | 2380 | } |
2782 | 2365 | 2381 | ||
2783 | 2366 | void | 2382 | void |
2784 | @@ -2487,88 +2503,8 @@ | |||
2785 | 2487 | } | 2503 | } |
2786 | 2488 | 2504 | ||
2787 | 2489 | 2505 | ||
2870 | 2490 | namespace { | 2506 | |
2871 | 2491 | 2507 | ||
2790 | 2492 | template <typename D> | ||
2791 | 2493 | SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items, | ||
2792 | 2494 | SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) | ||
2793 | 2495 | { | ||
2794 | 2496 | SPObject *current=root; | ||
2795 | 2497 | while (items) { | ||
2796 | 2498 | SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data)); | ||
2797 | 2499 | if ( root->isAncestorOf(item) && | ||
2798 | 2500 | ( !only_in_viewport || desktop->isWithinViewport(item) ) ) | ||
2799 | 2501 | { | ||
2800 | 2502 | current = item; | ||
2801 | 2503 | break; | ||
2802 | 2504 | } | ||
2803 | 2505 | items = items->next; | ||
2804 | 2506 | } | ||
2805 | 2507 | |||
2806 | 2508 | GSList *path=NULL; | ||
2807 | 2509 | while ( current != root ) { | ||
2808 | 2510 | path = g_slist_prepend(path, current); | ||
2809 | 2511 | current = current->parent; | ||
2810 | 2512 | } | ||
2811 | 2513 | |||
2812 | 2514 | SPItem *next; | ||
2813 | 2515 | // first, try from the current object | ||
2814 | 2516 | next = next_item<D>(desktop, path, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); | ||
2815 | 2517 | g_slist_free(path); | ||
2816 | 2518 | |||
2817 | 2519 | if (!next) { // if we ran out of objects, start over at the root | ||
2818 | 2520 | next = next_item<D>(desktop, NULL, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); | ||
2819 | 2521 | } | ||
2820 | 2522 | |||
2821 | 2523 | return next; | ||
2822 | 2524 | } | ||
2823 | 2525 | |||
2824 | 2526 | template <typename D> | ||
2825 | 2527 | SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, | ||
2826 | 2528 | bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) | ||
2827 | 2529 | { | ||
2828 | 2530 | typename D::Iterator children; | ||
2829 | 2531 | typename D::Iterator iter; | ||
2830 | 2532 | |||
2831 | 2533 | SPItem *found=NULL; | ||
2832 | 2534 | |||
2833 | 2535 | if (path) { | ||
2834 | 2536 | SPObject *object=reinterpret_cast<SPObject *>(path->data); | ||
2835 | 2537 | g_assert(object->parent == root); | ||
2836 | 2538 | if (desktop->isLayer(object)) { | ||
2837 | 2539 | found = next_item<D>(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); | ||
2838 | 2540 | } | ||
2839 | 2541 | iter = children = D::siblings_after(object); | ||
2840 | 2542 | } else { | ||
2841 | 2543 | iter = children = D::children(root); | ||
2842 | 2544 | } | ||
2843 | 2545 | |||
2844 | 2546 | while ( iter && !found ) { | ||
2845 | 2547 | SPObject *object=D::object(iter); | ||
2846 | 2548 | if (desktop->isLayer(object)) { | ||
2847 | 2549 | if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers | ||
2848 | 2550 | found = next_item<D>(desktop, NULL, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); | ||
2849 | 2551 | } | ||
2850 | 2552 | } else { | ||
2851 | 2553 | SPItem *item = dynamic_cast<SPItem *>(object); | ||
2852 | 2554 | if ( item && | ||
2853 | 2555 | ( !only_in_viewport || desktop->isWithinViewport(item) ) && | ||
2854 | 2556 | ( !onlyvisible || !desktop->itemIsHidden(item)) && | ||
2855 | 2557 | ( !onlysensitive || !item->isLocked()) && | ||
2856 | 2558 | !desktop->isLayer(item) ) | ||
2857 | 2559 | { | ||
2858 | 2560 | found = item; | ||
2859 | 2561 | } | ||
2860 | 2562 | } | ||
2861 | 2563 | iter = D::next(iter); | ||
2862 | 2564 | } | ||
2863 | 2565 | |||
2864 | 2566 | D::dispose(children); | ||
2865 | 2567 | |||
2866 | 2568 | return found; | ||
2867 | 2569 | } | ||
2868 | 2570 | |||
2869 | 2571 | } | ||
2872 | 2572 | 2508 | ||
2873 | 2573 | /** | 2509 | /** |
2874 | 2574 | * If \a item is not entirely visible then adjust visible area to centre on the centre on of | 2510 | * If \a item is not entirely visible then adjust visible area to centre on the centre on of |
2875 | @@ -2608,17 +2544,17 @@ | |||
2876 | 2608 | return; | 2544 | return; |
2877 | 2609 | } | 2545 | } |
2878 | 2610 | 2546 | ||
2880 | 2611 | GSList *reprs = g_slist_copy(const_cast<GSList *>(selection->reprList())); | 2547 | std::vector<Inkscape::XML::Node*> reprs (selection->reprList()); |
2881 | 2612 | 2548 | ||
2882 | 2613 | selection->clear(); | 2549 | selection->clear(); |
2883 | 2614 | 2550 | ||
2884 | 2615 | // sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need | 2551 | // sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need |
2891 | 2616 | reprs = g_slist_sort(reprs, (GCompareFunc) sp_repr_compare_position); | 2552 | sort(reprs.begin(),reprs.end(),sp_repr_compare_position); |
2892 | 2617 | 2553 | ||
2893 | 2618 | GSList *newsel = NULL; | 2554 | std::vector<Inkscape::XML::Node*> newsel; |
2894 | 2619 | 2555 | ||
2895 | 2620 | while (reprs) { | 2556 | for(std::vector<Inkscape::XML::Node*>::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){ |
2896 | 2621 | Inkscape::XML::Node *sel_repr = static_cast<Inkscape::XML::Node *>(reprs->data); | 2557 | Inkscape::XML::Node *sel_repr = *i; |
2897 | 2622 | Inkscape::XML::Node *parent = sel_repr->parent(); | 2558 | Inkscape::XML::Node *parent = sel_repr->parent(); |
2898 | 2623 | 2559 | ||
2899 | 2624 | Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); | 2560 | Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); |
2900 | @@ -2634,8 +2570,7 @@ | |||
2901 | 2634 | // add the new clone to the top of the original's parent | 2570 | // add the new clone to the top of the original's parent |
2902 | 2635 | parent->appendChild(clone); | 2571 | parent->appendChild(clone); |
2903 | 2636 | 2572 | ||
2906 | 2637 | newsel = g_slist_prepend(newsel, clone); | 2573 | newsel.push_back(clone); |
2905 | 2638 | reprs = g_slist_remove(reprs, sel_repr); | ||
2907 | 2639 | Inkscape::GC::release(clone); | 2574 | Inkscape::GC::release(clone); |
2908 | 2640 | } | 2575 | } |
2909 | 2641 | 2576 | ||
2910 | @@ -2643,8 +2578,6 @@ | |||
2911 | 2643 | C_("Action", "Clone")); | 2578 | C_("Action", "Clone")); |
2912 | 2644 | 2579 | ||
2913 | 2645 | selection->setReprList(newsel); | 2580 | selection->setReprList(newsel); |
2914 | 2646 | |||
2915 | 2647 | g_slist_free(newsel); | ||
2916 | 2648 | } | 2581 | } |
2917 | 2649 | 2582 | ||
2918 | 2650 | void | 2583 | void |
2919 | @@ -2670,11 +2603,9 @@ | |||
2920 | 2670 | 2603 | ||
2921 | 2671 | // Get a copy of current selection. | 2604 | // Get a copy of current selection. |
2922 | 2672 | bool relinked = false; | 2605 | bool relinked = false; |
2928 | 2673 | for (GSList *items = const_cast<GSList *>(selection->itemList()); | 2606 | std::vector<SPItem*> items=selection->itemList(); |
2929 | 2674 | items != NULL; | 2607 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
2930 | 2675 | items = items->next) | 2608 | SPItem *item = *i; |
2926 | 2676 | { | ||
2927 | 2677 | SPItem *item = static_cast<SPItem *>(items->data); | ||
2931 | 2678 | 2609 | ||
2932 | 2679 | if (dynamic_cast<SPUse *>(item)) { | 2610 | if (dynamic_cast<SPUse *>(item)) { |
2933 | 2680 | item->getRepr()->setAttribute("xlink:href", newref); | 2611 | item->getRepr()->setAttribute("xlink:href", newref); |
2934 | @@ -2708,13 +2639,11 @@ | |||
2935 | 2708 | } | 2639 | } |
2936 | 2709 | 2640 | ||
2937 | 2710 | // Get a copy of current selection. | 2641 | // Get a copy of current selection. |
2939 | 2711 | GSList *new_select = NULL; | 2642 | std::vector<SPItem*> new_select; |
2940 | 2712 | bool unlinked = false; | 2643 | bool unlinked = false; |
2946 | 2713 | for (GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); | 2644 | std::vector<SPItem*> items=selection->itemList(); |
2947 | 2714 | items != NULL; | 2645 | for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ |
2948 | 2715 | items = items->next) | 2646 | SPItem *item = *i; |
2944 | 2716 | { | ||
2945 | 2717 | SPItem *item = static_cast<SPItem *>(items->data); | ||
2949 | 2718 | 2647 | ||
2950 | 2719 | if (dynamic_cast<SPText *>(item)) { | 2648 | if (dynamic_cast<SPText *>(item)) { |
2951 | 2720 | SPObject *tspan = sp_tref_convert_to_tspan(item); | 2649 | SPObject *tspan = sp_tref_convert_to_tspan(item); |
2952 | @@ -2730,7 +2659,7 @@ | |||
2953 | 2730 | 2659 | ||
2954 | 2731 | if (!(dynamic_cast<SPUse *>(item) || dynamic_cast<SPTRef *>(item))) { | 2660 | if (!(dynamic_cast<SPUse *>(item) || dynamic_cast<SPTRef *>(item))) { |
2955 | 2732 | // keep the non-use item in the new selection | 2661 | // keep the non-use item in the new selection |
2957 | 2733 | new_select = g_slist_prepend(new_select, item); | 2662 | new_select.push_back(item); |
2958 | 2734 | continue; | 2663 | continue; |
2959 | 2735 | } | 2664 | } |
2960 | 2736 | 2665 | ||
2961 | @@ -2740,7 +2669,7 @@ | |||
2962 | 2740 | unlink = use->unlink(); | 2669 | unlink = use->unlink(); |
2963 | 2741 | // Unable to unlink use (external or invalid href?) | 2670 | // Unable to unlink use (external or invalid href?) |
2964 | 2742 | if (!unlink) { | 2671 | if (!unlink) { |
2966 | 2743 | new_select = g_slist_prepend(new_select, item); | 2672 | new_select.push_back(item); |
2967 | 2744 | continue; | 2673 | continue; |
2968 | 2745 | } | 2674 | } |
2969 | 2746 | } else /*if (SP_IS_TREF(use))*/ { | 2675 | } else /*if (SP_IS_TREF(use))*/ { |
2970 | @@ -2750,13 +2679,12 @@ | |||
2971 | 2750 | 2679 | ||
2972 | 2751 | unlinked = true; | 2680 | unlinked = true; |
2973 | 2752 | // Add ungrouped items to the new selection. | 2681 | // Add ungrouped items to the new selection. |
2975 | 2753 | new_select = g_slist_prepend(new_select, unlink); | 2682 | new_select.push_back(unlink); |
2976 | 2754 | } | 2683 | } |
2977 | 2755 | 2684 | ||
2979 | 2756 | if (new_select) { // set new selection | 2685 | if (!new_select.empty()) { // set new selection |
2980 | 2757 | selection->clear(); | 2686 | selection->clear(); |
2981 | 2758 | selection->setList(new_select); | 2687 | selection->setList(new_select); |
2982 | 2759 | g_slist_free(new_select); | ||
2983 | 2760 | } | 2688 | } |
2984 | 2761 | if (!unlinked) { | 2689 | if (!unlinked) { |
2985 | 2762 | desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection.")); | 2690 | desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection.")); |
2986 | @@ -2779,7 +2707,9 @@ | |||
2987 | 2779 | gchar const *error = _("Select a <b>clone</b> to go to its original. Select a <b>linked offset</b> to go to its source. Select a <b>text on path</b> to go to the path. Select a <b>flowed text</b> to go to its frame."); | 2707 | gchar const *error = _("Select a <b>clone</b> to go to its original. Select a <b>linked offset</b> to go to its source. Select a <b>text on path</b> to go to the path. Select a <b>flowed text</b> to go to its frame."); |
2988 | 2780 | 2708 | ||
2989 | 2781 | // Check if other than two objects are selected | 2709 | // Check if other than two objects are selected |
2991 | 2782 | if (g_slist_length(const_cast<GSList *>(selection->itemList())) != 1 || !item) { | 2710 | |
2992 | 2711 | std::vector<SPItem*> items=selection->itemList(); | ||
2993 | 2712 | if (items.size() != 1 || !item) { | ||
2994 | 2783 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error); | 2713 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error); |
2995 | 2784 | return; | 2714 | return; |
2996 | 2785 | } | 2715 | } |
2997 | @@ -2876,14 +2806,15 @@ | |||
2998 | 2876 | 2806 | ||
2999 | 2877 | Inkscape::SVGOStringStream os; | 2807 | Inkscape::SVGOStringStream os; |
3000 | 2878 | SPObject * firstItem = NULL; | 2808 | SPObject * firstItem = NULL; |
3003 | 2879 | for (const GSList * item = selection->itemList(); item != NULL; item = item->next) { | 2809 | std::vector<SPItem*> items=selection->itemList(); |
3004 | 2880 | if (SP_IS_SHAPE(item->data) || SP_IS_TEXT(item->data)) { | 2810 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3005 | 2811 | if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) { | ||
3006 | 2881 | if (firstItem) { | 2812 | if (firstItem) { |
3007 | 2882 | os << "|"; | 2813 | os << "|"; |
3008 | 2883 | } else { | 2814 | } else { |
3010 | 2884 | firstItem = SP_ITEM(item->data); | 2815 | firstItem = SP_ITEM(*i); |
3011 | 2885 | } | 2816 | } |
3013 | 2886 | os << '#' << SP_ITEM(item->data)->getId() << ",0"; | 2817 | os << '#' << SP_ITEM(*i)->getId() << ",0"; |
3014 | 2887 | } | 2818 | } |
3015 | 2888 | } | 2819 | } |
3016 | 2889 | if (firstItem) { | 2820 | if (firstItem) { |
3017 | @@ -2960,12 +2891,12 @@ | |||
3018 | 2960 | Geom::Point center( *c - corner ); // As defined by rotation center | 2891 | Geom::Point center( *c - corner ); // As defined by rotation center |
3019 | 2961 | center[Geom::Y] = -center[Geom::Y]; | 2892 | center[Geom::Y] = -center[Geom::Y]; |
3020 | 2962 | 2893 | ||
3022 | 2963 | GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); | 2894 | std::vector<SPItem*> items(selection->itemList()); |
3023 | 2964 | 2895 | ||
3024 | 2965 | //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? | 2896 | //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? |
3025 | 2966 | 2897 | ||
3026 | 2967 | // bottommost object, after sorting | 2898 | // bottommost object, after sorting |
3028 | 2968 | SPObject *parent = SP_OBJECT(items->data)->parent; | 2899 | SPObject *parent = items[0]->parent; |
3029 | 2969 | 2900 | ||
3030 | 2970 | Geom::Affine parent_transform; | 2901 | Geom::Affine parent_transform; |
3031 | 2971 | { | 2902 | { |
3032 | @@ -2978,10 +2909,10 @@ | |||
3033 | 2978 | } | 2909 | } |
3034 | 2979 | 2910 | ||
3035 | 2980 | // Create a list of duplicates, to be pasted inside marker element. | 2911 | // Create a list of duplicates, to be pasted inside marker element. |
3040 | 2981 | GSList *repr_copies = NULL; | 2912 | std::vector<Inkscape::XML::Node*> repr_copies; |
3041 | 2982 | for (GSList *i = items; i != NULL; i = i->next) { | 2913 | for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ |
3042 | 2983 | Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); | 2914 | Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc); |
3043 | 2984 | repr_copies = g_slist_prepend(repr_copies, dup); | 2915 | repr_copies.push_back(dup); |
3044 | 2985 | } | 2916 | } |
3045 | 2986 | 2917 | ||
3046 | 2987 | Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); | 2918 | Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); |
3047 | @@ -2989,8 +2920,8 @@ | |||
3048 | 2989 | if (apply) { | 2920 | if (apply) { |
3049 | 2990 | // Delete objects so that their clones don't get alerted; | 2921 | // Delete objects so that their clones don't get alerted; |
3050 | 2991 | // the objects will be restored inside the marker element. | 2922 | // the objects will be restored inside the marker element. |
3053 | 2992 | for (GSList *i = items; i != NULL; i = i->next) { | 2923 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3054 | 2993 | SPObject *item = reinterpret_cast<SPObject*>(i->data); | 2924 | SPObject *item = *i; |
3055 | 2994 | item->deleteObject(false); | 2925 | item->deleteObject(false); |
3056 | 2995 | } | 2926 | } |
3057 | 2996 | } | 2927 | } |
3058 | @@ -3009,7 +2940,6 @@ | |||
3059 | 3009 | prefs->setInt("/options/clonecompensation/value", saved_compensation); | 2940 | prefs->setInt("/options/clonecompensation/value", saved_compensation); |
3060 | 3010 | 2941 | ||
3061 | 3011 | 2942 | ||
3062 | 3012 | g_slist_free(items); | ||
3063 | 3013 | 2943 | ||
3064 | 3014 | DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER, | 2944 | DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER, |
3065 | 3015 | _("Objects to marker")); | 2945 | _("Objects to marker")); |
3066 | @@ -3018,8 +2948,9 @@ | |||
3067 | 3018 | static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) { | 2948 | static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) { |
3068 | 3019 | SPGroup *group = dynamic_cast<SPGroup *>(item); | 2949 | SPGroup *group = dynamic_cast<SPGroup *>(item); |
3069 | 3020 | if (group && !dynamic_cast<SPBox3D *>(item) && !wholegroups) { | 2950 | if (group && !dynamic_cast<SPBox3D *>(item) && !wholegroups) { |
3072 | 3021 | for (GSList *i = sp_item_group_item_list(group); i != NULL; i = i->next) { | 2951 | std::vector<SPItem*> items=sp_item_group_item_list(group); |
3073 | 3022 | sp_selection_to_guides_recursive(static_cast<SPItem*>(i->data), wholegroups); | 2952 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3074 | 2953 | sp_selection_to_guides_recursive(*i, wholegroups); | ||
3075 | 3023 | } | 2954 | } |
3076 | 3024 | } else { | 2955 | } else { |
3077 | 3025 | item->convert_to_guides(); | 2956 | item->convert_to_guides(); |
3078 | @@ -3034,9 +2965,9 @@ | |||
3079 | 3034 | SPDocument *doc = desktop->getDocument(); | 2965 | SPDocument *doc = desktop->getDocument(); |
3080 | 3035 | Inkscape::Selection *selection = desktop->getSelection(); | 2966 | Inkscape::Selection *selection = desktop->getSelection(); |
3081 | 3036 | // we need to copy the list because it gets reset when objects are deleted | 2967 | // we need to copy the list because it gets reset when objects are deleted |
3083 | 3037 | GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); | 2968 | std::vector<SPItem*> items(selection->itemList()); |
3084 | 3038 | 2969 | ||
3086 | 3039 | if (!items) { | 2970 | if (items.empty()) { |
3087 | 3040 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides.")); | 2971 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides.")); |
3088 | 3041 | return; | 2972 | return; |
3089 | 3042 | } | 2973 | } |
3090 | @@ -3049,8 +2980,8 @@ | |||
3091 | 3049 | // and its entry in the selection list is invalid (crash). | 2980 | // and its entry in the selection list is invalid (crash). |
3092 | 3050 | // Therefore: first convert all, then delete all. | 2981 | // Therefore: first convert all, then delete all. |
3093 | 3051 | 2982 | ||
3096 | 3052 | for (GSList const *i = items; i != NULL; i = i->next) { | 2983 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3097 | 3053 | sp_selection_to_guides_recursive(static_cast<SPItem*>(i->data), wholegroups); | 2984 | sp_selection_to_guides_recursive(*i, wholegroups); |
3098 | 3054 | } | 2985 | } |
3099 | 3055 | 2986 | ||
3100 | 3056 | if (deleteitems) { | 2987 | if (deleteitems) { |
3101 | @@ -3058,8 +2989,6 @@ | |||
3102 | 3058 | sp_selection_delete_impl(items); | 2989 | sp_selection_delete_impl(items); |
3103 | 3059 | } | 2990 | } |
3104 | 3060 | 2991 | ||
3105 | 3061 | g_slist_free(items); | ||
3106 | 3062 | |||
3107 | 3063 | DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides")); | 2992 | DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides")); |
3108 | 3064 | } | 2993 | } |
3109 | 3065 | 2994 | ||
3110 | @@ -3102,18 +3031,18 @@ | |||
3111 | 3102 | 3031 | ||
3112 | 3103 | doc->ensureUpToDate(); | 3032 | doc->ensureUpToDate(); |
3113 | 3104 | 3033 | ||
3115 | 3105 | GSList *items = g_slist_copy(const_cast<GSList *>(selection->list())); | 3034 | std::vector<SPObject*> items(selection->list()); |
3116 | 3106 | 3035 | ||
3117 | 3107 | // Keep track of parent, this is where <use> will be inserted. | 3036 | // Keep track of parent, this is where <use> will be inserted. |
3119 | 3108 | Inkscape::XML::Node *the_first_repr = reinterpret_cast<SPObject *>( items->data )->getRepr(); | 3037 | Inkscape::XML::Node *the_first_repr = items[0]->getRepr(); |
3120 | 3109 | Inkscape::XML::Node *the_parent_repr = the_first_repr->parent(); | 3038 | Inkscape::XML::Node *the_parent_repr = the_first_repr->parent(); |
3121 | 3110 | 3039 | ||
3122 | 3111 | // Find out if we have a single group | 3040 | // Find out if we have a single group |
3123 | 3112 | bool single_group = false; | 3041 | bool single_group = false; |
3124 | 3113 | SPGroup *the_group = NULL; | 3042 | SPGroup *the_group = NULL; |
3125 | 3114 | Geom::Affine transform; | 3043 | Geom::Affine transform; |
3128 | 3115 | if( g_slist_length( items ) == 1 ) { | 3044 | if( items.size() == 1 ) { |
3129 | 3116 | SPObject *object = reinterpret_cast<SPObject *>( items->data ); | 3045 | SPObject *object = items[0]; |
3130 | 3117 | the_group = dynamic_cast<SPGroup *>(object); | 3046 | the_group = dynamic_cast<SPGroup *>(object); |
3131 | 3118 | if ( the_group ) { | 3047 | if ( the_group ) { |
3132 | 3119 | single_group = true; | 3048 | single_group = true; |
3133 | @@ -3124,7 +3053,6 @@ | |||
3134 | 3124 | if( transform.isTranslation() ) { | 3053 | if( transform.isTranslation() ) { |
3135 | 3125 | 3054 | ||
3136 | 3126 | // Create new list from group children. | 3055 | // Create new list from group children. |
3137 | 3127 | g_slist_free(items); | ||
3138 | 3128 | items = object->childList(false); | 3056 | items = object->childList(false); |
3139 | 3129 | 3057 | ||
3140 | 3130 | // Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals | 3058 | // Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals |
3141 | @@ -3170,8 +3098,8 @@ | |||
3142 | 3170 | } | 3098 | } |
3143 | 3171 | 3099 | ||
3144 | 3172 | // Move selected items to new <symbol> | 3100 | // Move selected items to new <symbol> |
3147 | 3173 | for (GSList *i = items; i != NULL; i = i->next) { | 3101 | for (std::vector<SPObject*>::const_iterator i=items.begin();i!=items.end();i++){ |
3148 | 3174 | Inkscape::XML::Node *repr = SP_OBJECT(i->data)->getRepr(); | 3102 | Inkscape::XML::Node *repr = (*i)->getRepr(); |
3149 | 3175 | repr->parent()->removeChild(repr); | 3103 | repr->parent()->removeChild(repr); |
3150 | 3176 | symbol_repr->addChild(repr,NULL); | 3104 | symbol_repr->addChild(repr,NULL); |
3151 | 3177 | } | 3105 | } |
3152 | @@ -3197,7 +3125,6 @@ | |||
3153 | 3197 | 3125 | ||
3154 | 3198 | // Clean up | 3126 | // Clean up |
3155 | 3199 | Inkscape::GC::release(symbol_repr); | 3127 | Inkscape::GC::release(symbol_repr); |
3156 | 3200 | g_slist_free(items); | ||
3157 | 3201 | 3128 | ||
3158 | 3202 | DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol")); | 3129 | DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol")); |
3159 | 3203 | } | 3130 | } |
3160 | @@ -3238,26 +3165,25 @@ | |||
3161 | 3238 | desktop->currentLayer()->getRepr()->appendChild(group); | 3165 | desktop->currentLayer()->getRepr()->appendChild(group); |
3162 | 3239 | 3166 | ||
3163 | 3240 | // Move all children of symbol to group | 3167 | // Move all children of symbol to group |
3165 | 3241 | GSList* children = symbol->childList(false); | 3168 | std::vector<SPObject*> children = symbol->childList(false); |
3166 | 3242 | 3169 | ||
3167 | 3243 | // Converting a group to a symbol inserts a group for non-translational transform. | 3170 | // Converting a group to a symbol inserts a group for non-translational transform. |
3168 | 3244 | // In converting a symbol back to a group we strip out the inserted group (or any other | 3171 | // In converting a symbol back to a group we strip out the inserted group (or any other |
3169 | 3245 | // group that only adds a transform to the symbol content). | 3172 | // group that only adds a transform to the symbol content). |
3172 | 3246 | if( g_slist_length( children ) == 1 ) { | 3173 | if( children.size() == 1 ) { |
3173 | 3247 | SPObject *object = reinterpret_cast<SPObject *>( children->data ); | 3174 | SPObject *object = children[0]; |
3174 | 3248 | if ( dynamic_cast<SPGroup *>( object ) ) { | 3175 | if ( dynamic_cast<SPGroup *>( object ) ) { |
3175 | 3249 | if( object->getAttribute("style") == NULL || | 3176 | if( object->getAttribute("style") == NULL || |
3176 | 3250 | object->getAttribute("class") == NULL ) { | 3177 | object->getAttribute("class") == NULL ) { |
3177 | 3251 | 3178 | ||
3178 | 3252 | group->setAttribute("transform", object->getAttribute("transform")); | 3179 | group->setAttribute("transform", object->getAttribute("transform")); |
3179 | 3253 | g_slist_free(children); | ||
3180 | 3254 | children = object->childList(false); | 3180 | children = object->childList(false); |
3181 | 3255 | } | 3181 | } |
3182 | 3256 | } | 3182 | } |
3183 | 3257 | } | 3183 | } |
3184 | 3258 | 3184 | ||
3187 | 3259 | for (GSList* i = children; i != NULL; i = i->next ) { | 3185 | for (std::vector<SPObject*>::const_reverse_iterator i=children.rbegin();i!=children.rend();i++){ |
3188 | 3260 | Inkscape::XML::Node *repr = SP_OBJECT(i->data)->getRepr(); | 3186 | Inkscape::XML::Node *repr = (*i)->getRepr(); |
3189 | 3261 | repr->parent()->removeChild(repr); | 3187 | repr->parent()->removeChild(repr); |
3190 | 3262 | group->addChild(repr,NULL); | 3188 | group->addChild(repr,NULL); |
3191 | 3263 | } | 3189 | } |
3192 | @@ -3283,7 +3209,6 @@ | |||
3193 | 3283 | 3209 | ||
3194 | 3284 | // Clean up | 3210 | // Clean up |
3195 | 3285 | Inkscape::GC::release(group); | 3211 | Inkscape::GC::release(group); |
3196 | 3286 | g_slist_free(children); | ||
3197 | 3287 | 3212 | ||
3198 | 3288 | DocumentUndo::done(doc, SP_VERB_EDIT_UNSYMBOL, _("Group from symbol")); | 3213 | DocumentUndo::done(doc, SP_VERB_EDIT_UNSYMBOL, _("Group from symbol")); |
3199 | 3289 | } | 3214 | } |
3200 | @@ -3318,12 +3243,12 @@ | |||
3201 | 3318 | move_p[Geom::Y] = -move_p[Geom::Y]; | 3243 | move_p[Geom::Y] = -move_p[Geom::Y]; |
3202 | 3319 | Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); | 3244 | Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); |
3203 | 3320 | 3245 | ||
3205 | 3321 | GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); | 3246 | std::vector<SPItem*> items (selection->itemList()); |
3206 | 3322 | 3247 | ||
3208 | 3323 | items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); | 3248 | sort(items.begin(),items.end(),sp_object_compare_position); |
3209 | 3324 | 3249 | ||
3210 | 3325 | // bottommost object, after sorting | 3250 | // bottommost object, after sorting |
3212 | 3326 | SPObject *parent = SP_OBJECT(items->data)->parent; | 3251 | SPObject *parent = items[0]->parent; |
3213 | 3327 | 3252 | ||
3214 | 3328 | 3253 | ||
3215 | 3329 | Geom::Affine parent_transform; | 3254 | Geom::Affine parent_transform; |
3216 | @@ -3337,23 +3262,21 @@ | |||
3217 | 3337 | } | 3262 | } |
3218 | 3338 | 3263 | ||
3219 | 3339 | // remember the position of the first item | 3264 | // remember the position of the first item |
3221 | 3340 | gint pos = SP_OBJECT(items->data)->getRepr()->position(); | 3265 | gint pos = items[0]->getRepr()->position(); |
3222 | 3341 | 3266 | ||
3223 | 3342 | // create a list of duplicates | 3267 | // create a list of duplicates |
3228 | 3343 | GSList *repr_copies = NULL; | 3268 | std::vector<Inkscape::XML::Node*> repr_copies; |
3229 | 3344 | for (GSList *i = items; i != NULL; i = i->next) { | 3269 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3230 | 3345 | Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); | 3270 | Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc); |
3231 | 3346 | repr_copies = g_slist_prepend(repr_copies, dup); | 3271 | repr_copies.push_back(dup); |
3232 | 3347 | } | 3272 | } |
3233 | 3348 | // restore the z-order after prepends | ||
3234 | 3349 | repr_copies = g_slist_reverse(repr_copies); | ||
3235 | 3350 | 3273 | ||
3236 | 3351 | Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); | 3274 | Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); |
3237 | 3352 | 3275 | ||
3238 | 3353 | if (apply) { | 3276 | if (apply) { |
3239 | 3354 | // delete objects so that their clones don't get alerted; this object will be restored shortly | 3277 | // delete objects so that their clones don't get alerted; this object will be restored shortly |
3242 | 3355 | for (GSList *i = items; i != NULL; i = i->next) { | 3278 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3243 | 3356 | SPObject *item = reinterpret_cast<SPObject*>(i->data); | 3279 | SPObject *item = *i; |
3244 | 3357 | item->deleteObject(false); | 3280 | item->deleteObject(false); |
3245 | 3358 | } | 3281 | } |
3246 | 3359 | } | 3282 | } |
3247 | @@ -3399,7 +3322,6 @@ | |||
3248 | 3399 | selection->set(rectangle); | 3322 | selection->set(rectangle); |
3249 | 3400 | } | 3323 | } |
3250 | 3401 | 3324 | ||
3251 | 3402 | g_slist_free(items); | ||
3252 | 3403 | 3325 | ||
3253 | 3404 | DocumentUndo::done(doc, SP_VERB_EDIT_TILE, | 3326 | DocumentUndo::done(doc, SP_VERB_EDIT_TILE, |
3254 | 3405 | _("Objects to pattern")); | 3327 | _("Objects to pattern")); |
3255 | @@ -3422,15 +3344,13 @@ | |||
3256 | 3422 | return; | 3344 | return; |
3257 | 3423 | } | 3345 | } |
3258 | 3424 | 3346 | ||
3260 | 3425 | GSList *new_select = NULL; | 3347 | std::vector<SPItem*> new_select; |
3261 | 3426 | 3348 | ||
3262 | 3427 | bool did = false; | 3349 | bool did = false; |
3263 | 3428 | 3350 | ||
3269 | 3429 | for (GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); | 3351 | std::vector<SPItem*> items(selection->itemList()); |
3270 | 3430 | items != NULL; | 3352 | for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ |
3271 | 3431 | items = items->next) { | 3353 | SPItem *item = *i; |
3267 | 3432 | |||
3268 | 3433 | SPItem *item = static_cast<SPItem *>(items->data); | ||
3272 | 3434 | 3354 | ||
3273 | 3435 | SPStyle *style = item->style; | 3355 | SPStyle *style = item->style; |
3274 | 3436 | 3356 | ||
3275 | @@ -3466,7 +3386,7 @@ | |||
3276 | 3466 | Geom::Affine transform( i->transform * pat_transform ); | 3386 | Geom::Affine transform( i->transform * pat_transform ); |
3277 | 3467 | i->doWriteTransform(i->getRepr(), transform); | 3387 | i->doWriteTransform(i->getRepr(), transform); |
3278 | 3468 | 3388 | ||
3280 | 3469 | new_select = g_slist_prepend(new_select, i); | 3389 | new_select.push_back(i); |
3281 | 3470 | } else { | 3390 | } else { |
3282 | 3471 | g_assert_not_reached(); | 3391 | g_assert_not_reached(); |
3283 | 3472 | } | 3392 | } |
3284 | @@ -3493,18 +3413,14 @@ | |||
3285 | 3493 | return; | 3413 | return; |
3286 | 3494 | } | 3414 | } |
3287 | 3495 | 3415 | ||
3289 | 3496 | GSList const *reprlst = selection->reprList(); | 3416 | std::vector<Inkscape::XML::Node*> const reprlst = selection->reprList(); |
3290 | 3497 | bool filename_search = TRUE; | 3417 | bool filename_search = TRUE; |
3291 | 3498 | bool xdpi_search = TRUE; | 3418 | bool xdpi_search = TRUE; |
3292 | 3499 | bool ydpi_search = TRUE; | 3419 | bool ydpi_search = TRUE; |
3293 | 3500 | 3420 | ||
3299 | 3501 | for (; reprlst != NULL && | 3421 | for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();i++){ |
3295 | 3502 | filename_search && | ||
3296 | 3503 | xdpi_search && | ||
3297 | 3504 | ydpi_search; | ||
3298 | 3505 | reprlst = reprlst->next) { | ||
3300 | 3506 | gchar const *dpi_string; | 3422 | gchar const *dpi_string; |
3302 | 3507 | Inkscape::XML::Node * repr = static_cast<Inkscape::XML::Node *>(reprlst->data); | 3423 | Inkscape::XML::Node *repr = *i; |
3303 | 3508 | 3424 | ||
3304 | 3509 | if (filename_search) { | 3425 | if (filename_search) { |
3305 | 3510 | const gchar* tmp = repr->attribute("inkscape:export-filename"); | 3426 | const gchar* tmp = repr->attribute("inkscape:export-filename"); |
3306 | @@ -3590,10 +3506,10 @@ | |||
3307 | 3590 | } | 3506 | } |
3308 | 3591 | 3507 | ||
3309 | 3592 | // List of the items to show; all others will be hidden | 3508 | // List of the items to show; all others will be hidden |
3311 | 3593 | GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); | 3509 | std::vector<SPItem*> items(selection->itemList()); |
3312 | 3594 | 3510 | ||
3313 | 3595 | // Sort items so that the topmost comes last | 3511 | // Sort items so that the topmost comes last |
3315 | 3596 | items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position); | 3512 | sort(items.begin(),items.end(),sp_item_repr_compare_position); |
3316 | 3597 | 3513 | ||
3317 | 3598 | // Generate a random value from the current time (you may create bitmap from the same object(s) | 3514 | // Generate a random value from the current time (you may create bitmap from the same object(s) |
3318 | 3599 | // multiple times, and this is done so that they don't clash) | 3515 | // multiple times, and this is done so that they don't clash) |
3319 | @@ -3604,7 +3520,7 @@ | |||
3320 | 3604 | // Create the filename. | 3520 | // Create the filename. |
3321 | 3605 | gchar *const basename = g_strdup_printf("%s-%s-%u.png", | 3521 | gchar *const basename = g_strdup_printf("%s-%s-%u.png", |
3322 | 3606 | document->getName(), | 3522 | document->getName(), |
3324 | 3607 | SP_OBJECT(items->data)->getRepr()->attribute("id"), | 3523 | items[0]->getRepr()->attribute("id"), |
3325 | 3608 | current); | 3524 | current); |
3326 | 3609 | // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters, | 3525 | // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters, |
3327 | 3610 | // digits, and a few other chars, with "_" | 3526 | // digits, and a few other chars, with "_" |
3328 | @@ -3624,8 +3540,8 @@ | |||
3329 | 3624 | //g_print("%s\n", filepath); | 3540 | //g_print("%s\n", filepath); |
3330 | 3625 | 3541 | ||
3331 | 3626 | // Remember parent and z-order of the topmost one | 3542 | // Remember parent and z-order of the topmost one |
3334 | 3627 | gint pos = SP_OBJECT(g_slist_last(items)->data)->getRepr()->position(); | 3543 | gint pos = items.back()->getRepr()->position(); |
3335 | 3628 | SPObject *parent_object = SP_OBJECT(g_slist_last(items)->data)->parent; | 3544 | SPObject *parent_object = items.back()->parent; |
3336 | 3629 | Inkscape::XML::Node *parent = parent_object->getRepr(); | 3545 | Inkscape::XML::Node *parent = parent_object->getRepr(); |
3337 | 3630 | 3546 | ||
3338 | 3631 | // Calculate resolution | 3547 | // Calculate resolution |
3339 | @@ -3717,8 +3633,6 @@ | |||
3340 | 3717 | true, /*bool force_overwrite,*/ | 3633 | true, /*bool force_overwrite,*/ |
3341 | 3718 | items); | 3634 | items); |
3342 | 3719 | 3635 | ||
3343 | 3720 | g_slist_free(items); | ||
3344 | 3721 | |||
3345 | 3722 | // Run filter, if any | 3636 | // Run filter, if any |
3346 | 3723 | if (run) { | 3637 | if (run) { |
3347 | 3724 | g_print("Running external filter: %s\n", run); | 3638 | g_print("Running external filter: %s\n", run); |
3348 | @@ -3793,22 +3707,20 @@ | |||
3349 | 3793 | return; | 3707 | return; |
3350 | 3794 | } | 3708 | } |
3351 | 3795 | 3709 | ||
3355 | 3796 | GSList const *l = const_cast<GSList *>(selection->reprList()); | 3710 | std::vector<Inkscape::XML::Node*> p(selection->reprList()); |
3353 | 3797 | |||
3354 | 3798 | GSList *p = g_slist_copy(const_cast<GSList *>(l)); | ||
3356 | 3799 | 3711 | ||
3358 | 3800 | p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position); | 3712 | sort(p.begin(),p.end(),sp_repr_compare_position); |
3359 | 3801 | 3713 | ||
3360 | 3802 | selection->clear(); | 3714 | selection->clear(); |
3361 | 3803 | 3715 | ||
3364 | 3804 | gint topmost = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->position(); | 3716 | int topmost = (p.back())->position(); |
3365 | 3805 | Inkscape::XML::Node *topmost_parent = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->parent(); | 3717 | Inkscape::XML::Node *topmost_parent = (p.back())->parent(); |
3366 | 3806 | 3718 | ||
3367 | 3807 | Inkscape::XML::Node *inner = xml_doc->createElement("svg:g"); | 3719 | Inkscape::XML::Node *inner = xml_doc->createElement("svg:g"); |
3368 | 3808 | inner->setAttribute("inkscape:label", "Clip"); | 3720 | inner->setAttribute("inkscape:label", "Clip"); |
3369 | 3809 | 3721 | ||
3372 | 3810 | while (p) { | 3722 | for(std::vector<Inkscape::XML::Node*>::const_iterator i=p.begin();i!=p.end();i++){ |
3373 | 3811 | Inkscape::XML::Node *current = static_cast<Inkscape::XML::Node *>(p->data); | 3723 | Inkscape::XML::Node *current = *i; |
3374 | 3812 | 3724 | ||
3375 | 3813 | if (current->parent() == topmost_parent) { | 3725 | if (current->parent() == topmost_parent) { |
3376 | 3814 | Inkscape::XML::Node *spnew = current->duplicate(xml_doc); | 3726 | Inkscape::XML::Node *spnew = current->duplicate(xml_doc); |
3377 | @@ -3817,7 +3729,7 @@ | |||
3378 | 3817 | Inkscape::GC::release(spnew); | 3729 | Inkscape::GC::release(spnew); |
3379 | 3818 | topmost --; // only reduce count for those items deleted from topmost_parent | 3730 | topmost --; // only reduce count for those items deleted from topmost_parent |
3380 | 3819 | } else { // move it to topmost_parent first | 3731 | } else { // move it to topmost_parent first |
3382 | 3820 | GSList *temp_clip = NULL; | 3732 | std::vector<Inkscape::XML::Node*> temp_clip; |
3383 | 3821 | 3733 | ||
3384 | 3822 | // At this point, current may already have no item, due to its being a clone whose original is already moved away | 3734 | // At this point, current may already have no item, due to its being a clone whose original is already moved away |
3385 | 3823 | // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform | 3735 | // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform |
3386 | @@ -3833,15 +3745,14 @@ | |||
3387 | 3833 | // then, if this is clone, looking up its original in that array and pre-multiplying | 3745 | // then, if this is clone, looking up its original in that array and pre-multiplying |
3388 | 3834 | // it by the inverse of that original's transform diff. | 3746 | // it by the inverse of that original's transform diff. |
3389 | 3835 | 3747 | ||
3391 | 3836 | sp_selection_copy_one(current, item_t, &temp_clip, xml_doc); | 3748 | sp_selection_copy_one(current, item_t, temp_clip, xml_doc); |
3392 | 3837 | sp_repr_unparent(current); | 3749 | sp_repr_unparent(current); |
3393 | 3838 | 3750 | ||
3394 | 3839 | // paste into topmost_parent (temporarily) | 3751 | // paste into topmost_parent (temporarily) |
3398 | 3840 | GSList *copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), &temp_clip); | 3752 | std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); |
3399 | 3841 | if (temp_clip) g_slist_free(temp_clip); | 3753 | if (!copied.empty()) { // if success, |
3397 | 3842 | if (copied) { // if success, | ||
3400 | 3843 | // take pasted object (now in topmost_parent) | 3754 | // take pasted object (now in topmost_parent) |
3402 | 3844 | Inkscape::XML::Node *in_topmost = static_cast<Inkscape::XML::Node *>(copied->data); | 3755 | Inkscape::XML::Node *in_topmost = copied.back(); |
3403 | 3845 | // make a copy | 3756 | // make a copy |
3404 | 3846 | Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); | 3757 | Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); |
3405 | 3847 | // remove pasted | 3758 | // remove pasted |
3406 | @@ -3849,10 +3760,8 @@ | |||
3407 | 3849 | // put its copy into group | 3760 | // put its copy into group |
3408 | 3850 | inner->appendChild(spnew); | 3761 | inner->appendChild(spnew); |
3409 | 3851 | Inkscape::GC::release(spnew); | 3762 | Inkscape::GC::release(spnew); |
3410 | 3852 | g_slist_free(copied); | ||
3411 | 3853 | } | 3763 | } |
3412 | 3854 | } | 3764 | } |
3413 | 3855 | p = g_slist_remove(p, current); | ||
3414 | 3856 | } | 3765 | } |
3415 | 3857 | 3766 | ||
3416 | 3858 | Inkscape::XML::Node *outer = xml_doc->createElement("svg:g"); | 3767 | Inkscape::XML::Node *outer = xml_doc->createElement("svg:g"); |
3417 | @@ -3910,7 +3819,7 @@ | |||
3418 | 3910 | if ( apply_to_layer && is_empty) { | 3819 | if ( apply_to_layer && is_empty) { |
3419 | 3911 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from.")); | 3820 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from.")); |
3420 | 3912 | return; | 3821 | return; |
3422 | 3913 | } else if (!apply_to_layer && ( is_empty || NULL == selection->itemList()->next )) { | 3822 | } else if (!apply_to_layer && ( is_empty || selection->itemList().size()==1 )) { |
3423 | 3914 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and <b>object(s)</b> to apply clippath or mask to.")); | 3823 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and <b>object(s)</b> to apply clippath or mask to.")); |
3424 | 3915 | return; | 3824 | return; |
3425 | 3916 | } | 3825 | } |
3426 | @@ -3925,9 +3834,9 @@ | |||
3427 | 3925 | 3834 | ||
3428 | 3926 | doc->ensureUpToDate(); | 3835 | doc->ensureUpToDate(); |
3429 | 3927 | 3836 | ||
3431 | 3928 | GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); | 3837 | std::vector<SPItem*> items(selection->itemList()); |
3432 | 3929 | 3838 | ||
3434 | 3930 | items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); | 3839 | sort(items.begin(),items.end(),sp_object_compare_position); |
3435 | 3931 | 3840 | ||
3436 | 3932 | // See lp bug #542004 | 3841 | // See lp bug #542004 |
3437 | 3933 | selection->clear(); | 3842 | selection->clear(); |
3438 | @@ -3936,7 +3845,7 @@ | |||
3439 | 3936 | GSList *mask_items = NULL; | 3845 | GSList *mask_items = NULL; |
3440 | 3937 | GSList *apply_to_items = NULL; | 3846 | GSList *apply_to_items = NULL; |
3441 | 3938 | GSList *items_to_delete = NULL; | 3847 | GSList *items_to_delete = NULL; |
3443 | 3939 | GSList *items_to_select = NULL; | 3848 | std::vector<SPItem*> items_to_select; |
3444 | 3940 | 3849 | ||
3445 | 3941 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 3850 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
3446 | 3942 | bool topmost = prefs->getBool("/options/maskobject/topmost", true); | 3851 | bool topmost = prefs->getBool("/options/maskobject/topmost", true); |
3447 | @@ -3947,38 +3856,38 @@ | |||
3448 | 3947 | // all selected items are used for mask, which is applied to a layer | 3856 | // all selected items are used for mask, which is applied to a layer |
3449 | 3948 | apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer()); | 3857 | apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer()); |
3450 | 3949 | 3858 | ||
3453 | 3950 | for (GSList *i = items; i != NULL; i = i->next) { | 3859 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { |
3454 | 3951 | Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); | 3860 | Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc); |
3455 | 3952 | mask_items = g_slist_prepend(mask_items, dup); | 3861 | mask_items = g_slist_prepend(mask_items, dup); |
3456 | 3953 | 3862 | ||
3458 | 3954 | SPObject *item = reinterpret_cast<SPObject*>(i->data); | 3863 | SPObject *item = *i; |
3459 | 3955 | if (remove_original) { | 3864 | if (remove_original) { |
3460 | 3956 | items_to_delete = g_slist_prepend(items_to_delete, item); | 3865 | items_to_delete = g_slist_prepend(items_to_delete, item); |
3461 | 3957 | } | 3866 | } |
3462 | 3958 | else { | 3867 | else { |
3464 | 3959 | items_to_select = g_slist_prepend(items_to_select, item); | 3868 | items_to_select.push_back((SPItem*)item); |
3465 | 3960 | } | 3869 | } |
3466 | 3961 | } | 3870 | } |
3467 | 3962 | } else if (!topmost) { | 3871 | } else if (!topmost) { |
3468 | 3963 | // topmost item is used as a mask, which is applied to other items in a selection | 3872 | // topmost item is used as a mask, which is applied to other items in a selection |
3471 | 3964 | GSList *i = items; | 3873 | Inkscape::XML::Node *dup = items[0]->getRepr()->duplicate(xml_doc); |
3470 | 3965 | Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); | ||
3472 | 3966 | mask_items = g_slist_prepend(mask_items, dup); | 3874 | mask_items = g_slist_prepend(mask_items, dup); |
3473 | 3967 | 3875 | ||
3474 | 3968 | if (remove_original) { | 3876 | if (remove_original) { |
3476 | 3969 | SPObject *item = reinterpret_cast<SPObject*>(i->data); | 3877 | SPObject *item = items.front(); |
3477 | 3970 | items_to_delete = g_slist_prepend(items_to_delete, item); | 3878 | items_to_delete = g_slist_prepend(items_to_delete, item); |
3478 | 3971 | } | 3879 | } |
3479 | 3972 | 3880 | ||
3483 | 3973 | for (i = i->next; i != NULL; i = i->next) { | 3881 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { |
3484 | 3974 | apply_to_items = g_slist_prepend(apply_to_items, i->data); | 3882 | if(i==items.begin())continue; |
3485 | 3975 | items_to_select = g_slist_prepend(items_to_select, i->data); | 3883 | apply_to_items = g_slist_prepend(apply_to_items, *i); |
3486 | 3884 | items_to_select.push_back(*i); | ||
3487 | 3976 | } | 3885 | } |
3488 | 3977 | } else { | 3886 | } else { |
3489 | 3978 | GSList *i = NULL; | 3887 | GSList *i = NULL; |
3493 | 3979 | for (i = items; NULL != i->next; i = i->next) { | 3888 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { |
3494 | 3980 | apply_to_items = g_slist_prepend(apply_to_items, i->data); | 3889 | apply_to_items = g_slist_prepend(apply_to_items, *i); |
3495 | 3981 | items_to_select = g_slist_prepend(items_to_select, i->data); | 3890 | items_to_select.push_back(*i); |
3496 | 3982 | } | 3891 | } |
3497 | 3983 | 3892 | ||
3498 | 3984 | Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); | 3893 | Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); |
3499 | @@ -3989,9 +3898,7 @@ | |||
3500 | 3989 | items_to_delete = g_slist_prepend(items_to_delete, item); | 3898 | items_to_delete = g_slist_prepend(items_to_delete, item); |
3501 | 3990 | } | 3899 | } |
3502 | 3991 | } | 3900 | } |
3506 | 3992 | 3901 | items.clear(); | |
3504 | 3993 | g_slist_free(items); | ||
3505 | 3994 | items = NULL; | ||
3507 | 3995 | 3902 | ||
3508 | 3996 | if (apply_to_items && grouping == PREFS_MASKOBJECT_GROUPING_ALL) { | 3903 | if (apply_to_items && grouping == PREFS_MASKOBJECT_GROUPING_ALL) { |
3509 | 3997 | // group all those objects into one group | 3904 | // group all those objects into one group |
3510 | @@ -4001,24 +3908,21 @@ | |||
3511 | 4001 | // make a note we should ungroup this when unsetting mask | 3908 | // make a note we should ungroup this when unsetting mask |
3512 | 4002 | group->setAttribute("inkscape:groupmode", "maskhelper"); | 3909 | group->setAttribute("inkscape:groupmode", "maskhelper"); |
3513 | 4003 | 3910 | ||
3515 | 4004 | GSList *reprs_to_group = NULL; | 3911 | std::vector<Inkscape::XML::Node*> reprs_to_group; |
3516 | 4005 | 3912 | ||
3517 | 4006 | for (GSList *i = apply_to_items ; NULL != i ; i = i->next) { | 3913 | for (GSList *i = apply_to_items ; NULL != i ; i = i->next) { |
3520 | 4007 | reprs_to_group = g_slist_prepend(reprs_to_group, SP_OBJECT(i->data)->getRepr()); | 3914 | reprs_to_group.push_back(static_cast<SPObject*>(i->data)->getRepr()); |
3521 | 4008 | items_to_select = g_slist_remove(items_to_select, i->data); | 3915 | items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),static_cast<SPObject*>(i->data))); |
3522 | 4009 | } | 3916 | } |
3523 | 4010 | reprs_to_group = g_slist_reverse(reprs_to_group); | ||
3524 | 4011 | 3917 | ||
3525 | 4012 | sp_selection_group_impl(reprs_to_group, group, xml_doc, doc); | 3918 | sp_selection_group_impl(reprs_to_group, group, xml_doc, doc); |
3526 | 4013 | 3919 | ||
3527 | 4014 | reprs_to_group = NULL; | ||
3528 | 4015 | |||
3529 | 4016 | // apply clip/mask only to newly created group | 3920 | // apply clip/mask only to newly created group |
3530 | 4017 | g_slist_free(apply_to_items); | 3921 | g_slist_free(apply_to_items); |
3531 | 4018 | apply_to_items = NULL; | 3922 | apply_to_items = NULL; |
3532 | 4019 | apply_to_items = g_slist_prepend(apply_to_items, doc->getObjectByRepr(group)); | 3923 | apply_to_items = g_slist_prepend(apply_to_items, doc->getObjectByRepr(group)); |
3533 | 4020 | 3924 | ||
3535 | 4021 | items_to_select = g_slist_prepend(items_to_select, doc->getObjectByRepr(group)); | 3925 | items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group))); |
3536 | 4022 | 3926 | ||
3537 | 4023 | Inkscape::GC::release(group); | 3927 | Inkscape::GC::release(group); |
3538 | 4024 | } | 3928 | } |
3539 | @@ -4058,7 +3962,7 @@ | |||
3540 | 4058 | 3962 | ||
3541 | 4059 | Inkscape::XML::Node *spnew = current->duplicate(xml_doc); | 3963 | Inkscape::XML::Node *spnew = current->duplicate(xml_doc); |
3542 | 4060 | gint position = current->position(); | 3964 | gint position = current->position(); |
3544 | 4061 | items_to_select = g_slist_remove(items_to_select, item); | 3965 | items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item)); |
3545 | 4062 | current->parent()->appendChild(group); | 3966 | current->parent()->appendChild(group); |
3546 | 4063 | sp_repr_unparent(current); | 3967 | sp_repr_unparent(current); |
3547 | 4064 | group->appendChild(spnew); | 3968 | group->appendChild(spnew); |
3548 | @@ -4067,7 +3971,7 @@ | |||
3549 | 4067 | // Apply clip/mask to group instead | 3971 | // Apply clip/mask to group instead |
3550 | 4068 | apply_mask_to = group; | 3972 | apply_mask_to = group; |
3551 | 4069 | 3973 | ||
3553 | 4070 | items_to_select = g_slist_prepend(items_to_select, doc->getObjectByRepr(group)); | 3974 | items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group))); |
3554 | 4071 | Inkscape::GC::release(spnew); | 3975 | Inkscape::GC::release(spnew); |
3555 | 4072 | Inkscape::GC::release(group); | 3976 | Inkscape::GC::release(group); |
3556 | 4073 | } | 3977 | } |
3557 | @@ -4082,14 +3986,11 @@ | |||
3558 | 4082 | for (GSList *i = items_to_delete; NULL != i; i = i->next) { | 3986 | for (GSList *i = items_to_delete; NULL != i; i = i->next) { |
3559 | 4083 | SPObject *item = reinterpret_cast<SPObject*>(i->data); | 3987 | SPObject *item = reinterpret_cast<SPObject*>(i->data); |
3560 | 4084 | item->deleteObject(false); | 3988 | item->deleteObject(false); |
3562 | 4085 | items_to_select = g_slist_remove(items_to_select, item); | 3989 | items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item)); |
3563 | 4086 | } | 3990 | } |
3564 | 4087 | g_slist_free(items_to_delete); | 3991 | g_slist_free(items_to_delete); |
3565 | 4088 | 3992 | ||
3566 | 4089 | items_to_select = g_slist_reverse(items_to_select); | ||
3567 | 4090 | |||
3568 | 4091 | selection->addList(items_to_select); | 3993 | selection->addList(items_to_select); |
3569 | 4092 | g_slist_free(items_to_select); | ||
3570 | 4093 | 3994 | ||
3571 | 4094 | if (apply_clip_path) { | 3995 | if (apply_clip_path) { |
3572 | 4095 | DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); | 3996 | DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); |
3573 | @@ -4121,20 +4022,19 @@ | |||
3574 | 4121 | gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; | 4022 | gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; |
3575 | 4122 | std::map<SPObject*,SPItem*> referenced_objects; | 4023 | std::map<SPObject*,SPItem*> referenced_objects; |
3576 | 4123 | 4024 | ||
3578 | 4124 | GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); | 4025 | std::vector<SPItem*> items(selection->itemList()); |
3579 | 4125 | selection->clear(); | 4026 | selection->clear(); |
3580 | 4126 | 4027 | ||
3581 | 4127 | GSList *items_to_ungroup = NULL; | 4028 | GSList *items_to_ungroup = NULL; |
3584 | 4128 | GSList *items_to_select = g_slist_copy(items); | 4029 | std::vector<SPItem*> items_to_select(items); |
3583 | 4129 | items_to_select = g_slist_reverse(items_to_select); | ||
3585 | 4130 | 4030 | ||
3586 | 4131 | 4031 | ||
3587 | 4132 | // SPObject* refers to a group containing the clipped path or mask itself, | 4032 | // SPObject* refers to a group containing the clipped path or mask itself, |
3588 | 4133 | // whereas SPItem* refers to the item being clipped or masked | 4033 | // whereas SPItem* refers to the item being clipped or masked |
3590 | 4134 | for (GSList const *i = items; NULL != i; i = i->next) { | 4034 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3591 | 4135 | if (remove_original) { | 4035 | if (remove_original) { |
3592 | 4136 | // remember referenced mask/clippath, so orphaned masks can be moved back to document | 4036 | // remember referenced mask/clippath, so orphaned masks can be moved back to document |
3594 | 4137 | SPItem *item = reinterpret_cast<SPItem *>(i->data); | 4037 | SPItem *item = *i; |
3595 | 4138 | Inkscape::URIReference *uri_ref = NULL; | 4038 | Inkscape::URIReference *uri_ref = NULL; |
3596 | 4139 | 4039 | ||
3597 | 4140 | if (apply_clip_path) { | 4040 | if (apply_clip_path) { |
3598 | @@ -4149,9 +4049,9 @@ | |||
3599 | 4149 | } | 4049 | } |
3600 | 4150 | } | 4050 | } |
3601 | 4151 | 4051 | ||
3603 | 4152 | SP_OBJECT(i->data)->getRepr()->setAttribute(attributeName, "none"); | 4052 | (*i)->getRepr()->setAttribute(attributeName, "none"); |
3604 | 4153 | 4053 | ||
3606 | 4154 | SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(i->data)); | 4054 | SPGroup *group = dynamic_cast<SPGroup *>(*i); |
3607 | 4155 | if (ungroup_masked && group) { | 4055 | if (ungroup_masked && group) { |
3608 | 4156 | // if we had previously enclosed masked object in group, | 4056 | // if we had previously enclosed masked object in group, |
3609 | 4157 | // add it to list so we can ungroup it later | 4057 | // add it to list so we can ungroup it later |
3610 | @@ -4163,7 +4063,6 @@ | |||
3611 | 4163 | 4063 | ||
3612 | 4164 | } | 4064 | } |
3613 | 4165 | } | 4065 | } |
3614 | 4166 | g_slist_free(items); | ||
3615 | 4167 | 4066 | ||
3616 | 4168 | // restore mask objects into a document | 4067 | // restore mask objects into a document |
3617 | 4169 | for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { | 4068 | for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { |
3618 | @@ -4171,7 +4070,7 @@ | |||
3619 | 4171 | GSList *items_to_move = NULL; | 4070 | GSList *items_to_move = NULL; |
3620 | 4172 | for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { | 4071 | for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { |
3621 | 4173 | // Collect all clipped paths and masks within a single group | 4072 | // Collect all clipped paths and masks within a single group |
3623 | 4174 | Inkscape::XML::Node *copy = SP_OBJECT(child)->getRepr()->duplicate(xml_doc); | 4073 | Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc); |
3624 | 4175 | if(copy->attribute("inkscape:original-d") && copy->attribute("inkscape:path-effect")) | 4074 | if(copy->attribute("inkscape:original-d") && copy->attribute("inkscape:path-effect")) |
3625 | 4176 | { | 4075 | { |
3626 | 4177 | copy->setAttribute("d", copy->attribute("inkscape:original-d")); | 4076 | copy->setAttribute("d", copy->attribute("inkscape:original-d")); |
3627 | @@ -4197,7 +4096,7 @@ | |||
3628 | 4197 | repr->setPosition((pos + 1) > 0 ? (pos + 1) : 0); | 4096 | repr->setPosition((pos + 1) > 0 ? (pos + 1) : 0); |
3629 | 4198 | 4097 | ||
3630 | 4199 | SPItem *mask_item = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(repr)); | 4098 | SPItem *mask_item = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(repr)); |
3632 | 4200 | items_to_select = g_slist_prepend(items_to_select, mask_item); | 4099 | items_to_select.push_back(mask_item); |
3633 | 4201 | 4100 | ||
3634 | 4202 | // transform mask, so it is moved the same spot where mask was applied | 4101 | // transform mask, so it is moved the same spot where mask was applied |
3635 | 4203 | Geom::Affine transform(mask_item->transform); | 4102 | Geom::Affine transform(mask_item->transform); |
3636 | @@ -4212,10 +4111,10 @@ | |||
3637 | 4212 | for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) { | 4111 | for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) { |
3638 | 4213 | SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(i->data)); | 4112 | SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(i->data)); |
3639 | 4214 | if (group) { | 4113 | if (group) { |
3644 | 4215 | items_to_select = g_slist_remove(items_to_select, group); | 4114 | items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),group)); |
3645 | 4216 | GSList *children = NULL; | 4115 | std::vector<SPItem*> children; |
3646 | 4217 | sp_item_group_ungroup(group, &children, false); | 4116 | sp_item_group_ungroup(group, children, false); |
3647 | 4218 | items_to_select = g_slist_concat(children, items_to_select); | 4117 | items_to_select.insert(items_to_select.end(),children.rbegin(),children.rend()); |
3648 | 4219 | } else { | 4118 | } else { |
3649 | 4220 | g_assert_not_reached(); | 4119 | g_assert_not_reached(); |
3650 | 4221 | } | 4120 | } |
3651 | @@ -4224,9 +4123,7 @@ | |||
3652 | 4224 | g_slist_free(items_to_ungroup); | 4123 | g_slist_free(items_to_ungroup); |
3653 | 4225 | 4124 | ||
3654 | 4226 | // rebuild selection | 4125 | // rebuild selection |
3655 | 4227 | items_to_select = g_slist_reverse(items_to_select); | ||
3656 | 4228 | selection->addList(items_to_select); | 4126 | selection->addList(items_to_select); |
3657 | 4229 | g_slist_free(items_to_select); | ||
3658 | 4230 | 4127 | ||
3659 | 4231 | if (apply_clip_path) { | 4128 | if (apply_clip_path) { |
3660 | 4232 | DocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path")); | 4129 | DocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path")); |
3661 | 4233 | 4130 | ||
3662 | === modified file 'src/selection-chemistry.h' | |||
3663 | --- src/selection-chemistry.h 2015-02-20 15:50:51 +0000 | |||
3664 | +++ src/selection-chemistry.h 2015-04-29 21:03:59 +0000 | |||
3665 | @@ -143,8 +143,9 @@ | |||
3666 | 143 | 143 | ||
3667 | 144 | void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolean strok, gboolean style); | 144 | void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolean strok, gboolean style); |
3668 | 145 | void sp_select_same_object_type(SPDesktop *desktop); | 145 | void sp_select_same_object_type(SPDesktop *desktop); |
3671 | 146 | GSList *sp_get_same_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type=SP_STYLE_ALL); | 146 | |
3672 | 147 | GSList *sp_get_same_object_type(SPItem *sel, GSList *src); | 147 | std::vector<SPItem*> sp_get_same_style(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type=SP_STYLE_ALL); |
3673 | 148 | std::vector<SPItem*> sp_get_same_object_type(SPItem *sel, std::vector<SPItem*> &src); | ||
3674 | 148 | 149 | ||
3675 | 149 | void scroll_to_show_item(SPDesktop *desktop, SPItem *item); | 150 | void scroll_to_show_item(SPDesktop *desktop, SPItem *item); |
3676 | 150 | 151 | ||
3677 | @@ -171,9 +172,9 @@ | |||
3678 | 171 | void unhide_all(SPDesktop *dt); | 172 | void unhide_all(SPDesktop *dt); |
3679 | 172 | void unhide_all_in_all_layers(SPDesktop *dt); | 173 | void unhide_all_in_all_layers(SPDesktop *dt); |
3680 | 173 | 174 | ||
3682 | 174 | GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude); | 175 | std::vector<SPItem*> &get_all_items(std::vector<SPItem*> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector<SPItem*> const &exclude); |
3683 | 175 | 176 | ||
3685 | 176 | GSList *sp_degroup_list (GSList *items); | 177 | std::vector<SPItem*> sp_degroup_list (std::vector<SPItem*> &items); |
3686 | 177 | 178 | ||
3687 | 178 | /* selection cycling */ | 179 | /* selection cycling */ |
3688 | 179 | typedef enum | 180 | typedef enum |
3689 | 180 | 181 | ||
3690 | === modified file 'src/selection-describer.cpp' | |||
3691 | --- src/selection-describer.cpp 2015-03-06 08:51:53 +0000 | |||
3692 | +++ src/selection-describer.cpp 2015-04-29 21:03:59 +0000 | |||
3693 | @@ -40,14 +40,14 @@ | |||
3694 | 40 | #include "sp-spiral.h" | 40 | #include "sp-spiral.h" |
3695 | 41 | 41 | ||
3696 | 42 | // Returns a list of terms for the items to be used in the statusbar | 42 | // Returns a list of terms for the items to be used in the statusbar |
3698 | 43 | char* collect_terms (GSList *items) | 43 | char* collect_terms (const std::vector<SPItem*> &items) |
3699 | 44 | { | 44 | { |
3700 | 45 | GSList *check = NULL; | 45 | GSList *check = NULL; |
3701 | 46 | std::stringstream ss; | 46 | std::stringstream ss; |
3702 | 47 | bool first = true; | 47 | bool first = true; |
3703 | 48 | 48 | ||
3706 | 49 | for (GSList *i = (GSList *)items; i != NULL; i = i->next) { | 49 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
3707 | 50 | SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(i->data)); | 50 | SPItem *item = *iter; |
3708 | 51 | if (item) { | 51 | if (item) { |
3709 | 52 | const char *term = item->displayName(); | 52 | const char *term = item->displayName(); |
3710 | 53 | if (term != NULL && g_slist_find (check, term) == NULL) { | 53 | if (term != NULL && g_slist_find (check, term) == NULL) { |
3711 | @@ -61,12 +61,12 @@ | |||
3712 | 61 | } | 61 | } |
3713 | 62 | 62 | ||
3714 | 63 | // Returns the number of terms in the list | 63 | // Returns the number of terms in the list |
3716 | 64 | static int count_terms (GSList *items) | 64 | static int count_terms (const std::vector<SPItem*> &items) |
3717 | 65 | { | 65 | { |
3718 | 66 | GSList *check = NULL; | 66 | GSList *check = NULL; |
3719 | 67 | int count=0; | 67 | int count=0; |
3722 | 68 | for (GSList *i = (GSList *)items; i != NULL; i = i->next) { | 68 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
3723 | 69 | SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(i->data)); | 69 | SPItem *item = *iter; |
3724 | 70 | if (item) { | 70 | if (item) { |
3725 | 71 | const char *term = item->displayName(); | 71 | const char *term = item->displayName(); |
3726 | 72 | if (term != NULL && g_slist_find (check, term) == NULL) { | 72 | if (term != NULL && g_slist_find (check, term) == NULL) { |
3727 | @@ -79,11 +79,11 @@ | |||
3728 | 79 | } | 79 | } |
3729 | 80 | 80 | ||
3730 | 81 | // Returns the number of filtered items in the list | 81 | // Returns the number of filtered items in the list |
3732 | 82 | static int count_filtered (GSList *items) | 82 | static int count_filtered (const std::vector<SPItem*> &items) |
3733 | 83 | { | 83 | { |
3734 | 84 | int count=0; | 84 | int count=0; |
3737 | 85 | for (GSList *i = items; i != NULL; i = i->next) { | 85 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
3738 | 86 | SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>((i->data))); | 86 | SPItem *item = *iter; |
3739 | 87 | if (item) { | 87 | if (item) { |
3740 | 88 | count += item->isFiltered(); | 88 | count += item->isFiltered(); |
3741 | 89 | } | 89 | } |
3742 | @@ -122,12 +122,12 @@ | |||
3743 | 122 | } | 122 | } |
3744 | 123 | 123 | ||
3745 | 124 | void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { | 124 | void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { |
3747 | 125 | GSList const *items = selection->itemList(); | 125 | std::vector<SPItem*> const items = selection->itemList(); |
3748 | 126 | 126 | ||
3750 | 127 | if (!items) { // no items | 127 | if (items.empty()) { // no items |
3751 | 128 | _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); | 128 | _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); |
3752 | 129 | } else { | 129 | } else { |
3754 | 130 | SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(items->data)); | 130 | SPItem *item = items[0]; |
3755 | 131 | g_assert(item != NULL); | 131 | g_assert(item != NULL); |
3756 | 132 | SPObject *layer = selection->layers()->layerForObject(item); | 132 | SPObject *layer = selection->layers()->layerForObject(item); |
3757 | 133 | SPObject *root = selection->layers()->currentRoot(); | 133 | SPObject *root = selection->layers()->currentRoot(); |
3758 | @@ -188,7 +188,7 @@ | |||
3759 | 188 | g_free (layer_name); | 188 | g_free (layer_name); |
3760 | 189 | g_free (parent_name); | 189 | g_free (parent_name); |
3761 | 190 | 190 | ||
3763 | 191 | if (!items->next) { // one item | 191 | if (items.size()==1) { // one item |
3764 | 192 | char *item_desc = item->detailedDescription(); | 192 | char *item_desc = item->detailedDescription(); |
3765 | 193 | 193 | ||
3766 | 194 | bool isUse = dynamic_cast<SPUse *>(item) != NULL; | 194 | bool isUse = dynamic_cast<SPUse *>(item) != NULL; |
3767 | @@ -228,9 +228,9 @@ | |||
3768 | 228 | 228 | ||
3769 | 229 | g_free(item_desc); | 229 | g_free(item_desc); |
3770 | 230 | } else { // multiple items | 230 | } else { // multiple items |
3774 | 231 | int objcount = g_slist_length((GSList *)items); | 231 | int objcount = items.size(); |
3775 | 232 | char *terms = collect_terms ((GSList *)items); | 232 | char *terms = collect_terms (items); |
3776 | 233 | int n_terms = count_terms((GSList *)items); | 233 | int n_terms = count_terms(items); |
3777 | 234 | 234 | ||
3778 | 235 | gchar *objects_str = g_strdup_printf(ngettext( | 235 | gchar *objects_str = g_strdup_printf(ngettext( |
3779 | 236 | "<b>%1$i</b> objects selected of type %2$s", | 236 | "<b>%1$i</b> objects selected of type %2$s", |
3780 | @@ -241,7 +241,7 @@ | |||
3781 | 241 | 241 | ||
3782 | 242 | // indicate all, some, or none filtered | 242 | // indicate all, some, or none filtered |
3783 | 243 | gchar *filt_str = NULL; | 243 | gchar *filt_str = NULL; |
3785 | 244 | int n_filt = count_filtered((GSList *)items); //all filtered | 244 | int n_filt = count_filtered(items); //all filtered |
3786 | 245 | if (n_filt) { | 245 | if (n_filt) { |
3787 | 246 | filt_str = g_strdup_printf(ngettext("; <i>%d filtered object</i> ", | 246 | filt_str = g_strdup_printf(ngettext("; <i>%d filtered object</i> ", |
3788 | 247 | "; <i>%d filtered objects</i> ", n_filt), n_filt); | 247 | "; <i>%d filtered objects</i> ", n_filt), n_filt); |
3789 | 248 | 248 | ||
3790 | === modified file 'src/selection.cpp' | |||
3791 | --- src/selection.cpp 2014-06-27 19:23:06 +0000 | |||
3792 | +++ src/selection.cpp 2015-04-29 21:03:59 +0000 | |||
3793 | @@ -42,9 +42,11 @@ | |||
3794 | 42 | namespace Inkscape { | 42 | namespace Inkscape { |
3795 | 43 | 43 | ||
3796 | 44 | Selection::Selection(LayerModel *layers, SPDesktop *desktop) : | 44 | Selection::Selection(LayerModel *layers, SPDesktop *desktop) : |
3800 | 45 | _objs(NULL), | 45 | _objs(std::list<SPObject*>()), |
3801 | 46 | _reprs(NULL), | 46 | _objs_vector(std::vector<SPObject*>()), |
3802 | 47 | _items(NULL), | 47 | _objs_set(std::set<SPObject*>()), |
3803 | 48 | _reprs(std::vector<XML::Node*>()), | ||
3804 | 49 | _items(std::vector<SPItem*>()), | ||
3805 | 48 | _layers(layers), | 50 | _layers(layers), |
3806 | 49 | _desktop(desktop), | 51 | _desktop(desktop), |
3807 | 50 | _selection_context(NULL), | 52 | _selection_context(NULL), |
3808 | @@ -121,17 +123,14 @@ | |||
3809 | 121 | } | 123 | } |
3810 | 122 | 124 | ||
3811 | 123 | void Selection::_invalidateCachedLists() { | 125 | void Selection::_invalidateCachedLists() { |
3817 | 124 | g_slist_free(_items); | 126 | _items.clear(); |
3818 | 125 | _items = NULL; | 127 | _reprs.clear(); |
3814 | 126 | |||
3815 | 127 | g_slist_free(_reprs); | ||
3816 | 128 | _reprs = NULL; | ||
3819 | 129 | } | 128 | } |
3820 | 130 | 129 | ||
3821 | 131 | void Selection::_clear() { | 130 | void Selection::_clear() { |
3822 | 132 | _invalidateCachedLists(); | 131 | _invalidateCachedLists(); |
3825 | 133 | while (_objs) { | 132 | while (!_objs.empty()) { |
3826 | 134 | SPObject *obj=reinterpret_cast<SPObject *>(_objs->data); | 133 | SPObject *obj=_objs.front(); |
3827 | 135 | _remove(obj); | 134 | _remove(obj); |
3828 | 136 | } | 135 | } |
3829 | 137 | } | 136 | } |
3830 | @@ -148,7 +147,7 @@ | |||
3831 | 148 | 147 | ||
3832 | 149 | g_return_val_if_fail(SP_IS_OBJECT(obj), FALSE); | 148 | g_return_val_if_fail(SP_IS_OBJECT(obj), FALSE); |
3833 | 150 | 149 | ||
3835 | 151 | return ( g_slist_find(_objs, obj) != NULL ); | 150 | return ( _objs_set.find(obj)!=_objs_set.end() ); |
3836 | 152 | } | 151 | } |
3837 | 153 | 152 | ||
3838 | 154 | void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) { | 153 | void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) { |
3839 | @@ -180,7 +179,8 @@ | |||
3840 | 180 | _removeObjectDescendants(obj); | 179 | _removeObjectDescendants(obj); |
3841 | 181 | _removeObjectAncestors(obj); | 180 | _removeObjectAncestors(obj); |
3842 | 182 | 181 | ||
3844 | 183 | _objs = g_slist_prepend(_objs, obj); | 182 | _objs.push_front(obj); |
3845 | 183 | _objs_set.insert(obj); | ||
3846 | 184 | 184 | ||
3847 | 185 | add_3D_boxes_recursively(obj); | 185 | add_3D_boxes_recursively(obj); |
3848 | 186 | 186 | ||
3849 | @@ -234,26 +234,27 @@ | |||
3850 | 234 | 234 | ||
3851 | 235 | remove_3D_boxes_recursively(obj); | 235 | remove_3D_boxes_recursively(obj); |
3852 | 236 | 236 | ||
3854 | 237 | _objs = g_slist_remove(_objs, obj); | 237 | _objs.remove(obj); |
3855 | 238 | _objs_set.erase(obj); | ||
3856 | 238 | } | 239 | } |
3857 | 239 | 240 | ||
3859 | 240 | void Selection::setList(GSList const *list) { | 241 | void Selection::setList(std::vector<SPItem*> const &list) { |
3860 | 241 | // Clear and add, or just clear with emit. | 242 | // Clear and add, or just clear with emit. |
3862 | 242 | if (list != NULL) { | 243 | if (!list.empty()) { |
3863 | 243 | _clear(); | 244 | _clear(); |
3864 | 244 | addList(list); | 245 | addList(list); |
3865 | 245 | } else clear(); | 246 | } else clear(); |
3866 | 246 | } | 247 | } |
3867 | 247 | 248 | ||
3869 | 248 | void Selection::addList(GSList const *list) { | 249 | void Selection::addList(std::vector<SPItem*> const &list) { |
3870 | 249 | 250 | ||
3872 | 250 | if (list == NULL) | 251 | if (list.empty()) |
3873 | 251 | return; | 252 | return; |
3874 | 252 | 253 | ||
3875 | 253 | _invalidateCachedLists(); | 254 | _invalidateCachedLists(); |
3876 | 254 | 255 | ||
3879 | 255 | for ( GSList const *iter = list ; iter != NULL ; iter = iter->next ) { | 256 | for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end();iter++ ) { |
3880 | 256 | SPObject *obj = reinterpret_cast<SPObject *>(iter->data); | 257 | SPObject *obj = *iter; |
3881 | 257 | if (includes(obj)) continue; | 258 | if (includes(obj)) continue; |
3882 | 258 | _add (obj); | 259 | _add (obj); |
3883 | 259 | } | 260 | } |
3884 | @@ -261,11 +262,11 @@ | |||
3885 | 261 | _emitChanged(); | 262 | _emitChanged(); |
3886 | 262 | } | 263 | } |
3887 | 263 | 264 | ||
3889 | 264 | void Selection::setReprList(GSList const *list) { | 265 | void Selection::setReprList(std::vector<XML::Node*> const &list) { |
3890 | 265 | _clear(); | 266 | _clear(); |
3891 | 266 | 267 | ||
3894 | 267 | for ( GSList const *iter = list ; iter != NULL ; iter = iter->next ) { | 268 | for ( std::vector<XML::Node*>::const_reverse_iterator iter=list.rbegin();iter!=list.rend();iter++ ) { |
3895 | 268 | SPObject *obj=_objectForXMLNode(reinterpret_cast<Inkscape::XML::Node *>(iter->data)); | 269 | SPObject *obj=_objectForXMLNode(*iter); |
3896 | 269 | if (obj) { | 270 | if (obj) { |
3897 | 270 | _add(obj); | 271 | _add(obj); |
3898 | 271 | } | 272 | } |
3899 | @@ -279,35 +280,38 @@ | |||
3900 | 279 | _emitChanged(); | 280 | _emitChanged(); |
3901 | 280 | } | 281 | } |
3902 | 281 | 282 | ||
3905 | 282 | GSList const *Selection::list() { | 283 | std::vector<SPObject*> const &Selection::list() { |
3906 | 283 | return _objs; | 284 | if(!_objs_vector.empty()) |
3907 | 285 | return _objs_vector; | ||
3908 | 286 | |||
3909 | 287 | for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { | ||
3910 | 288 | _objs_vector.push_back(*iter); | ||
3911 | 289 | } | ||
3912 | 290 | return _objs_vector; | ||
3913 | 291 | |||
3914 | 284 | } | 292 | } |
3915 | 285 | 293 | ||
3918 | 286 | GSList const *Selection::itemList() { | 294 | std::vector<SPItem*> const &Selection::itemList() { |
3919 | 287 | if (_items) { | 295 | if (!_items.empty()) { |
3920 | 288 | return _items; | 296 | return _items; |
3921 | 289 | } | 297 | } |
3922 | 290 | 298 | ||
3925 | 291 | for ( GSList const *iter=_objs ; iter != NULL ; iter = iter->next ) { | 299 | for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { |
3926 | 292 | SPObject *obj=reinterpret_cast<SPObject *>(iter->data); | 300 | SPObject *obj=*iter; |
3927 | 293 | if (SP_IS_ITEM(obj)) { | 301 | if (SP_IS_ITEM(obj)) { |
3929 | 294 | _items = g_slist_prepend(_items, SP_ITEM(obj)); | 302 | _items.push_back(SP_ITEM(obj)); |
3930 | 295 | } | 303 | } |
3931 | 296 | } | 304 | } |
3932 | 297 | _items = g_slist_reverse(_items); | ||
3933 | 298 | |||
3934 | 299 | return _items; | 305 | return _items; |
3935 | 300 | } | 306 | } |
3936 | 301 | 307 | ||
3943 | 302 | GSList const *Selection::reprList() { | 308 | std::vector<XML::Node*> const &Selection::reprList() { |
3944 | 303 | if (_reprs) { return _reprs; } | 309 | if (!_reprs.empty()) { return _reprs; } |
3945 | 304 | 310 | std::vector<SPItem*> list = itemList(); | |
3946 | 305 | for ( GSList const *iter=itemList() ; iter != NULL ; iter = iter->next ) { | 311 | for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end();iter++ ) { |
3947 | 306 | SPObject *obj=reinterpret_cast<SPObject *>(iter->data); | 312 | SPObject *obj = *iter; |
3948 | 307 | _reprs = g_slist_prepend(_reprs, obj->getRepr()); | 313 | _reprs.push_back(obj->getRepr()); |
3949 | 308 | } | 314 | } |
3950 | 309 | _reprs = g_slist_reverse(_reprs); | ||
3951 | 310 | |||
3952 | 311 | return _reprs; | 315 | return _reprs; |
3953 | 312 | } | 316 | } |
3954 | 313 | 317 | ||
3955 | @@ -337,17 +341,17 @@ | |||
3956 | 337 | } | 341 | } |
3957 | 338 | 342 | ||
3958 | 339 | SPObject *Selection::single() { | 343 | SPObject *Selection::single() { |
3961 | 340 | if ( _objs != NULL && _objs->next == NULL ) { | 344 | if ( _objs.size() == 1 ) { |
3962 | 341 | return reinterpret_cast<SPObject *>(_objs->data); | 345 | return _objs.front(); |
3963 | 342 | } else { | 346 | } else { |
3964 | 343 | return NULL; | 347 | return NULL; |
3965 | 344 | } | 348 | } |
3966 | 345 | } | 349 | } |
3967 | 346 | 350 | ||
3968 | 347 | SPItem *Selection::singleItem() { | 351 | SPItem *Selection::singleItem() { |
3972 | 348 | GSList const *items=itemList(); | 352 | std::vector<SPItem*> const items=itemList(); |
3973 | 349 | if ( items != NULL && items->next == NULL ) { | 353 | if ( items.size()==1) { |
3974 | 350 | return reinterpret_cast<SPItem *>(items->data); | 354 | return items[0]; |
3975 | 351 | } else { | 355 | } else { |
3976 | 352 | return NULL; | 356 | return NULL; |
3977 | 353 | } | 357 | } |
3978 | @@ -362,12 +366,12 @@ | |||
3979 | 362 | } | 366 | } |
3980 | 363 | 367 | ||
3981 | 364 | SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { | 368 | SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { |
3983 | 365 | GSList const *items = const_cast<Selection *>(this)->itemList(); | 369 | std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
3984 | 366 | gdouble max = sml ? 1e18 : 0; | 370 | gdouble max = sml ? 1e18 : 0; |
3985 | 367 | SPItem *ist = NULL; | 371 | SPItem *ist = NULL; |
3986 | 368 | 372 | ||
3989 | 369 | for ( GSList const *i = items; i != NULL ; i = i->next ) { | 373 | for ( std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++ ) { |
3990 | 370 | Geom::OptRect obox = SP_ITEM(i->data)->desktopPreferredBounds(); | 374 | Geom::OptRect obox = SP_ITEM(*i)->desktopPreferredBounds(); |
3991 | 371 | if (!obox || obox.isEmpty()) continue; | 375 | if (!obox || obox.isEmpty()) continue; |
3992 | 372 | Geom::Rect bbox = *obox; | 376 | Geom::Rect bbox = *obox; |
3993 | 373 | 377 | ||
3994 | @@ -376,7 +380,7 @@ | |||
3995 | 376 | size = sml ? size : size * -1; | 380 | size = sml ? size : size * -1; |
3996 | 377 | if (size < max) { | 381 | if (size < max) { |
3997 | 378 | max = size; | 382 | max = size; |
3999 | 379 | ist = SP_ITEM(i->data); | 383 | ist = SP_ITEM(*i); |
4000 | 380 | } | 384 | } |
4001 | 381 | } | 385 | } |
4002 | 382 | return ist; | 386 | return ist; |
4003 | @@ -395,22 +399,22 @@ | |||
4004 | 395 | 399 | ||
4005 | 396 | Geom::OptRect Selection::geometricBounds() const | 400 | Geom::OptRect Selection::geometricBounds() const |
4006 | 397 | { | 401 | { |
4008 | 398 | GSList const *items = const_cast<Selection *>(this)->itemList(); | 402 | std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4009 | 399 | 403 | ||
4010 | 400 | Geom::OptRect bbox; | 404 | Geom::OptRect bbox; |
4013 | 401 | for ( GSList const *i = items ; i != NULL ; i = i->next ) { | 405 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4014 | 402 | bbox.unionWith(SP_ITEM(i->data)->desktopGeometricBounds()); | 406 | bbox.unionWith(SP_ITEM(*iter)->desktopGeometricBounds()); |
4015 | 403 | } | 407 | } |
4016 | 404 | return bbox; | 408 | return bbox; |
4017 | 405 | } | 409 | } |
4018 | 406 | 410 | ||
4019 | 407 | Geom::OptRect Selection::visualBounds() const | 411 | Geom::OptRect Selection::visualBounds() const |
4020 | 408 | { | 412 | { |
4022 | 409 | GSList const *items = const_cast<Selection *>(this)->itemList(); | 413 | std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4023 | 410 | 414 | ||
4024 | 411 | Geom::OptRect bbox; | 415 | Geom::OptRect bbox; |
4027 | 412 | for ( GSList const *i = items ; i != NULL ; i = i->next ) { | 416 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4028 | 413 | bbox.unionWith(SP_ITEM(i->data)->desktopVisualBounds()); | 417 | bbox.unionWith(SP_ITEM(*iter)->desktopVisualBounds()); |
4029 | 414 | } | 418 | } |
4030 | 415 | return bbox; | 419 | return bbox; |
4031 | 416 | } | 420 | } |
4032 | @@ -427,11 +431,11 @@ | |||
4033 | 427 | Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const | 431 | Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const |
4034 | 428 | { | 432 | { |
4035 | 429 | Geom::OptRect bbox; | 433 | Geom::OptRect bbox; |
4038 | 430 | GSList const *items = const_cast<Selection *>(this)->itemList(); | 434 | std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4039 | 431 | if (!items) return bbox; | 435 | if (items.empty()) return bbox; |
4040 | 432 | 436 | ||
4043 | 433 | for ( GSList const *iter=items ; iter != NULL ; iter = iter->next ) { | 437 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4044 | 434 | SPItem *item = SP_ITEM(iter->data); | 438 | SPItem *item = SP_ITEM(*iter); |
4045 | 435 | bbox |= item->documentBounds(type); | 439 | bbox |= item->documentBounds(type); |
4046 | 436 | } | 440 | } |
4047 | 437 | 441 | ||
4048 | @@ -441,9 +445,9 @@ | |||
4049 | 441 | // If we have a selection of multiple items, then the center of the first item | 445 | // If we have a selection of multiple items, then the center of the first item |
4050 | 442 | // will be returned; this is also the case in SelTrans::centerRequest() | 446 | // will be returned; this is also the case in SelTrans::centerRequest() |
4051 | 443 | boost::optional<Geom::Point> Selection::center() const { | 447 | boost::optional<Geom::Point> Selection::center() const { |
4055 | 444 | GSList *items = (GSList *) const_cast<Selection *>(this)->itemList(); | 448 | std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4056 | 445 | if (items) { | 449 | if (!items.empty()) { |
4057 | 446 | SPItem *first = reinterpret_cast<SPItem*>(g_slist_last(items)->data); // from the first item in selection | 450 | SPItem *first = items.back(); // from the first item in selection |
4058 | 447 | if (first->isCenterSet()) { // only if set explicitly | 451 | if (first->isCenterSet()) { // only if set explicitly |
4059 | 448 | return first->getCenter(); | 452 | return first->getCenter(); |
4060 | 449 | } | 453 | } |
4061 | @@ -457,13 +461,13 @@ | |||
4062 | 457 | } | 461 | } |
4063 | 458 | 462 | ||
4064 | 459 | std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferences const *snapprefs) const { | 463 | std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferences const *snapprefs) const { |
4066 | 460 | GSList const *items = const_cast<Selection *>(this)->itemList(); | 464 | std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4067 | 461 | 465 | ||
4068 | 462 | SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs | 466 | SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs |
4069 | 463 | snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center | 467 | snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center |
4070 | 464 | std::vector<Inkscape::SnapCandidatePoint> p; | 468 | std::vector<Inkscape::SnapCandidatePoint> p; |
4073 | 465 | for (GSList const *iter = items; iter != NULL; iter = iter->next) { | 469 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4074 | 466 | SPItem *this_item = SP_ITEM(iter->data); | 470 | SPItem *this_item = *iter; |
4075 | 467 | this_item->getSnappoints(p, &snapprefs_dummy); | 471 | this_item->getSnappoints(p, &snapprefs_dummy); |
4076 | 468 | 472 | ||
4077 | 469 | //Include the transformation origin for snapping | 473 | //Include the transformation origin for snapping |
4078 | @@ -477,10 +481,8 @@ | |||
4079 | 477 | } | 481 | } |
4080 | 478 | 482 | ||
4081 | 479 | void Selection::_removeObjectDescendants(SPObject *obj) { | 483 | void Selection::_removeObjectDescendants(SPObject *obj) { |
4086 | 480 | GSList *iter, *next; | 484 | for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { |
4087 | 481 | for ( iter = _objs ; iter ; iter = next ) { | 485 | SPObject *sel_obj= *iter; |
4084 | 482 | next = iter->next; | ||
4085 | 483 | SPObject *sel_obj=reinterpret_cast<SPObject *>(iter->data); | ||
4088 | 484 | SPObject *parent = sel_obj->parent; | 486 | SPObject *parent = sel_obj->parent; |
4089 | 485 | while (parent) { | 487 | while (parent) { |
4090 | 486 | if ( parent == obj ) { | 488 | if ( parent == obj ) { |
4091 | @@ -511,32 +513,24 @@ | |||
4092 | 511 | return object; | 513 | return object; |
4093 | 512 | } | 514 | } |
4094 | 513 | 515 | ||
4103 | 514 | guint Selection::numberOfLayers() { | 516 | uint Selection::numberOfLayers() { |
4104 | 515 | GSList const *items = const_cast<Selection *>(this)->itemList(); | 517 | std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4105 | 516 | GSList *layers = NULL; | 518 | std::set<SPObject*> layers; |
4106 | 517 | for (GSList const *iter = items; iter != NULL; iter = iter->next) { | 519 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4107 | 518 | SPObject *layer = _layers->layerForObject(SP_OBJECT(iter->data)); | 520 | SPObject *layer = _layers->layerForObject(*iter); |
4108 | 519 | if (g_slist_find (layers, layer) == NULL) { | 521 | layers.insert(layer); |
4101 | 520 | layers = g_slist_prepend (layers, layer); | ||
4102 | 521 | } | ||
4109 | 522 | } | 522 | } |
4113 | 523 | guint ret = g_slist_length (layers); | 523 | return layers.size(); |
4111 | 524 | g_slist_free (layers); | ||
4112 | 525 | return ret; | ||
4114 | 526 | } | 524 | } |
4115 | 527 | 525 | ||
4116 | 528 | guint Selection::numberOfParents() { | 526 | guint Selection::numberOfParents() { |
4124 | 529 | GSList const *items = const_cast<Selection *>(this)->itemList(); | 527 | std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4125 | 530 | GSList *parents = NULL; | 528 | std::set<SPObject*> parents; |
4126 | 531 | for (GSList const *iter = items; iter != NULL; iter = iter->next) { | 529 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4127 | 532 | SPObject *parent = SP_OBJECT(iter->data)->parent; | 530 | SPObject *parent = (*iter)->parent; |
4128 | 533 | if (g_slist_find (parents, parent) == NULL) { | 531 | parents.insert(parent); |
4122 | 534 | parents = g_slist_prepend (parents, parent); | ||
4123 | 535 | } | ||
4129 | 536 | } | 532 | } |
4133 | 537 | guint ret = g_slist_length (parents); | 533 | return parents.size(); |
4131 | 538 | g_slist_free (parents); | ||
4132 | 539 | return ret; | ||
4134 | 540 | } | 534 | } |
4135 | 541 | 535 | ||
4136 | 542 | } | 536 | } |
4137 | 543 | 537 | ||
4138 | === modified file 'src/selection.h' | |||
4139 | --- src/selection.h 2015-02-26 02:49:35 +0000 | |||
4140 | +++ src/selection.h 2015-04-29 21:03:59 +0000 | |||
4141 | @@ -16,6 +16,7 @@ | |||
4142 | 16 | #include <vector> | 16 | #include <vector> |
4143 | 17 | #include <map> | 17 | #include <map> |
4144 | 18 | #include <list> | 18 | #include <list> |
4145 | 19 | #include <set> | ||
4146 | 19 | #include <stddef.h> | 20 | #include <stddef.h> |
4147 | 20 | #include <sigc++/sigc++.h> | 21 | #include <sigc++/sigc++.h> |
4148 | 21 | 22 | ||
4149 | @@ -26,11 +27,11 @@ | |||
4150 | 26 | #include "sp-item.h" | 27 | #include "sp-item.h" |
4151 | 27 | 28 | ||
4152 | 28 | 29 | ||
4153 | 30 | |||
4154 | 29 | class SPDesktop; | 31 | class SPDesktop; |
4155 | 30 | class SPItem; | 32 | class SPItem; |
4156 | 31 | class SPBox3D; | 33 | class SPBox3D; |
4157 | 32 | class Persp3D; | 34 | class Persp3D; |
4158 | 33 | typedef struct _GSList GSList; | ||
4159 | 34 | 35 | ||
4160 | 35 | namespace Inkscape { | 36 | namespace Inkscape { |
4161 | 36 | class LayerModel; | 37 | class LayerModel; |
4162 | @@ -39,6 +40,7 @@ | |||
4163 | 39 | } | 40 | } |
4164 | 40 | } | 41 | } |
4165 | 41 | 42 | ||
4166 | 43 | |||
4167 | 42 | namespace Inkscape { | 44 | namespace Inkscape { |
4168 | 43 | 45 | ||
4169 | 44 | /** | 46 | /** |
4170 | @@ -154,21 +156,21 @@ | |||
4171 | 154 | * | 156 | * |
4172 | 155 | * @param objs the objects to select | 157 | * @param objs the objects to select |
4173 | 156 | */ | 158 | */ |
4175 | 157 | void setList(GSList const *objs); | 159 | void setList(std::vector<SPItem*> const &objs); |
4176 | 158 | 160 | ||
4177 | 159 | /** | 161 | /** |
4178 | 160 | * Adds the specified objects to selection, without deselecting first. | 162 | * Adds the specified objects to selection, without deselecting first. |
4179 | 161 | * | 163 | * |
4180 | 162 | * @param objs the objects to select | 164 | * @param objs the objects to select |
4181 | 163 | */ | 165 | */ |
4183 | 164 | void addList(GSList const *objs); | 166 | void addList(std::vector<SPItem*> const &objs); |
4184 | 165 | 167 | ||
4185 | 166 | /** | 168 | /** |
4186 | 167 | * Clears the selection and selects the specified objects. | 169 | * Clears the selection and selects the specified objects. |
4187 | 168 | * | 170 | * |
4188 | 169 | * @param repr a list of xml nodes for the items to select | 171 | * @param repr a list of xml nodes for the items to select |
4189 | 170 | */ | 172 | */ |
4191 | 171 | void setReprList(GSList const *reprs); | 173 | void setReprList(std::vector<XML::Node*> const &reprs); |
4192 | 172 | 174 | ||
4193 | 173 | /** Add items from an STL iterator range to the selection. | 175 | /** Add items from an STL iterator range to the selection. |
4194 | 174 | * \param from the begin iterator | 176 | * \param from the begin iterator |
4195 | @@ -192,7 +194,7 @@ | |||
4196 | 192 | /** | 194 | /** |
4197 | 193 | * Returns true if no items are selected. | 195 | * Returns true if no items are selected. |
4198 | 194 | */ | 196 | */ |
4200 | 195 | bool isEmpty() const { return _objs == NULL; } | 197 | bool isEmpty() const { return _objs.empty(); } |
4201 | 196 | 198 | ||
4202 | 197 | /** | 199 | /** |
4203 | 198 | * Returns true if the given object is selected. | 200 | * Returns true if the given object is selected. |
4204 | @@ -238,13 +240,13 @@ | |||
4205 | 238 | XML::Node *singleRepr(); | 240 | XML::Node *singleRepr(); |
4206 | 239 | 241 | ||
4207 | 240 | /** Returns the list of selected objects. */ | 242 | /** Returns the list of selected objects. */ |
4209 | 241 | GSList const *list(); | 243 | std::vector<SPObject*> const &list(); |
4210 | 242 | /** Returns the list of selected SPItems. */ | 244 | /** Returns the list of selected SPItems. */ |
4212 | 243 | GSList const *itemList(); | 245 | std::vector<SPItem*> const &itemList(); |
4213 | 244 | /** Returns a list of the xml nodes of all selected objects. */ | 246 | /** Returns a list of the xml nodes of all selected objects. */ |
4214 | 245 | /// \todo only returns reprs of SPItems currently; need a separate | 247 | /// \todo only returns reprs of SPItems currently; need a separate |
4215 | 246 | /// method for that | 248 | /// method for that |
4217 | 247 | GSList const *reprList(); | 249 | std::vector<XML::Node*> const &reprList(); |
4218 | 248 | 250 | ||
4219 | 249 | /** Returns a list of all perspectives which have a 3D box in the current selection. | 251 | /** Returns a list of all perspectives which have a 3D box in the current selection. |
4220 | 250 | (these may also be nested in groups) */ | 252 | (these may also be nested in groups) */ |
4221 | @@ -360,9 +362,11 @@ | |||
4222 | 360 | /** Releases an active layer object that is being removed. */ | 362 | /** Releases an active layer object that is being removed. */ |
4223 | 361 | void _releaseContext(SPObject *obj); | 363 | void _releaseContext(SPObject *obj); |
4224 | 362 | 364 | ||
4228 | 363 | mutable GSList *_objs; | 365 | mutable std::list<SPObject*> _objs; //to more efficiently remove arbitrary elements |
4229 | 364 | mutable GSList *_reprs; | 366 | mutable std::vector<SPObject*> _objs_vector; // to be returned by list(); |
4230 | 365 | mutable GSList *_items; | 367 | mutable std::set<SPObject*> _objs_set; //to efficiently test if object is selected |
4231 | 368 | mutable std::vector<XML::Node*> _reprs; | ||
4232 | 369 | mutable std::vector<SPItem*> _items; | ||
4233 | 366 | 370 | ||
4234 | 367 | void add_box_perspective(SPBox3D *box); | 371 | void add_box_perspective(SPBox3D *box); |
4235 | 368 | void add_3D_boxes_recursively(SPObject *obj); | 372 | void add_3D_boxes_recursively(SPObject *obj); |
4236 | 369 | 373 | ||
4237 | === modified file 'src/seltrans.cpp' | |||
4238 | --- src/seltrans.cpp 2014-12-21 21:58:32 +0000 | |||
4239 | +++ src/seltrans.cpp 2015-04-29 21:03:59 +0000 | |||
4240 | @@ -112,7 +112,7 @@ | |||
4241 | 112 | _opposite_for_bboxpoints(Geom::Point(0,0)), | 112 | _opposite_for_bboxpoints(Geom::Point(0,0)), |
4242 | 113 | _origin_for_specpoints(Geom::Point(0,0)), | 113 | _origin_for_specpoints(Geom::Point(0,0)), |
4243 | 114 | _origin_for_bboxpoints(Geom::Point(0,0)), | 114 | _origin_for_bboxpoints(Geom::Point(0,0)), |
4245 | 115 | _stamp_cache(NULL), | 115 | _stamp_cache(std::vector<SPItem*>()), |
4246 | 116 | _message_context(desktop->messageStack()), | 116 | _message_context(desktop->messageStack()), |
4247 | 117 | _bounding_box_prefs_observer(*this) | 117 | _bounding_box_prefs_observer(*this) |
4248 | 118 | { | 118 | { |
4249 | @@ -239,8 +239,9 @@ | |||
4250 | 239 | _center_is_set = true; | 239 | _center_is_set = true; |
4251 | 240 | 240 | ||
4252 | 241 | // Write the new center position into all selected items | 241 | // Write the new center position into all selected items |
4255 | 242 | for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { | 242 | std::vector<SPItem*> items=_desktop->selection->itemList(); |
4256 | 243 | SPItem *it = SP_ITEM(l->data); | 243 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4257 | 244 | SPItem *it = SP_ITEM(*iter); | ||
4258 | 244 | it->setCenter(p); | 245 | it->setCenter(p); |
4259 | 245 | // only set the value; updating repr and document_done will be done once, on ungrab | 246 | // only set the value; updating repr and document_done will be done once, on ungrab |
4260 | 246 | } | 247 | } |
4261 | @@ -268,8 +269,9 @@ | |||
4262 | 268 | return; | 269 | return; |
4263 | 269 | } | 270 | } |
4264 | 270 | 271 | ||
4267 | 271 | for (GSList const *l = selection->itemList(); l; l = l->next) { | 272 | std::vector<SPItem*> items=_desktop->selection->itemList(); |
4268 | 272 | SPItem *it = reinterpret_cast<SPItem*>(sp_object_ref(SP_ITEM(l->data), NULL)); | 273 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4269 | 274 | SPItem *it = static_cast<SPItem*>(sp_object_ref(*iter, NULL)); | ||
4270 | 273 | _items.push_back(it); | 275 | _items.push_back(it); |
4271 | 274 | _items_const.push_back(it); | 276 | _items_const.push_back(it); |
4272 | 275 | _items_affines.push_back(it->i2dt_affine()); | 277 | _items_affines.push_back(it->i2dt_affine()); |
4273 | @@ -370,7 +372,7 @@ | |||
4274 | 370 | } | 372 | } |
4275 | 371 | 373 | ||
4276 | 372 | _updateHandles(); | 374 | _updateHandles(); |
4278 | 373 | g_return_if_fail(_stamp_cache == NULL); | 375 | g_return_if_fail(_stamp_cache.empty()); |
4279 | 374 | } | 376 | } |
4280 | 375 | 377 | ||
4281 | 376 | void Inkscape::SelTrans::transform(Geom::Affine const &rel_affine, Geom::Point const &norm) | 378 | void Inkscape::SelTrans::transform(Geom::Affine const &rel_affine, Geom::Point const &norm) |
4282 | @@ -432,10 +434,8 @@ | |||
4283 | 432 | for (int i = 0; i < 4; i++) | 434 | for (int i = 0; i < 4; i++) |
4284 | 433 | sp_canvas_item_hide(_l[i]); | 435 | sp_canvas_item_hide(_l[i]); |
4285 | 434 | } | 436 | } |
4290 | 435 | 437 | if(!_stamp_cache.empty()){ | |
4291 | 436 | if (_stamp_cache) { | 438 | _stamp_cache.clear(); |
4288 | 437 | g_slist_free(_stamp_cache); | ||
4289 | 438 | _stamp_cache = NULL; | ||
4292 | 439 | } | 439 | } |
4293 | 440 | 440 | ||
4294 | 441 | _message_context.clear(); | 441 | _message_context.clear(); |
4295 | @@ -491,8 +491,9 @@ | |||
4296 | 491 | 491 | ||
4297 | 492 | if (_center_is_set) { | 492 | if (_center_is_set) { |
4298 | 493 | // we were dragging center; update reprs and commit undoable action | 493 | // we were dragging center; update reprs and commit undoable action |
4301 | 494 | for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { | 494 | std::vector<SPItem*> items=_desktop->selection->itemList(); |
4302 | 495 | SPItem *it = SP_ITEM(l->data); | 495 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4303 | 496 | SPItem *it = *iter; | ||
4304 | 496 | it->updateRepr(); | 497 | it->updateRepr(); |
4305 | 497 | } | 498 | } |
4306 | 498 | DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, | 499 | DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, |
4307 | @@ -515,26 +516,25 @@ | |||
4308 | 515 | Inkscape::Selection *selection = _desktop->getSelection(); | 516 | Inkscape::Selection *selection = _desktop->getSelection(); |
4309 | 516 | 517 | ||
4310 | 517 | bool fixup = !_grabbed; | 518 | bool fixup = !_grabbed; |
4312 | 518 | if ( fixup && _stamp_cache ) { | 519 | if ( fixup && !_stamp_cache.empty() ) { |
4313 | 519 | // TODO - give a proper fix. Simple temporary work-around for the grab() issue | 520 | // TODO - give a proper fix. Simple temporary work-around for the grab() issue |
4316 | 520 | g_slist_free(_stamp_cache); | 521 | _stamp_cache.clear(); |
4315 | 521 | _stamp_cache = NULL; | ||
4317 | 522 | } | 522 | } |
4318 | 523 | 523 | ||
4319 | 524 | /* stamping mode */ | 524 | /* stamping mode */ |
4320 | 525 | if (!_empty) { | 525 | if (!_empty) { |
4323 | 526 | GSList *l; | 526 | std::vector<SPItem*> l; |
4324 | 527 | if (_stamp_cache) { | 527 | if (!_stamp_cache.empty()) { |
4325 | 528 | l = _stamp_cache; | 528 | l = _stamp_cache; |
4326 | 529 | } else { | 529 | } else { |
4327 | 530 | /* Build cache */ | 530 | /* Build cache */ |
4330 | 531 | l = g_slist_copy((GSList *) selection->itemList()); | 531 | l = selection->itemList(); |
4331 | 532 | l = g_slist_sort(l, (GCompareFunc) sp_object_compare_position); | 532 | sort(l.begin(),l.end(),sp_object_compare_position); |
4332 | 533 | _stamp_cache = l; | 533 | _stamp_cache = l; |
4333 | 534 | } | 534 | } |
4334 | 535 | 535 | ||
4337 | 536 | while (l) { | 536 | for(std::vector<SPItem*>::const_iterator x=l.begin();x!=l.end();x++) { |
4338 | 537 | SPItem *original_item = SP_ITEM(l->data); | 537 | SPItem *original_item = *x; |
4339 | 538 | Inkscape::XML::Node *original_repr = original_item->getRepr(); | 538 | Inkscape::XML::Node *original_repr = original_item->getRepr(); |
4340 | 539 | 539 | ||
4341 | 540 | // remember the position of the item | 540 | // remember the position of the item |
4342 | @@ -568,16 +568,14 @@ | |||
4343 | 568 | } | 568 | } |
4344 | 569 | 569 | ||
4345 | 570 | Inkscape::GC::release(copy_repr); | 570 | Inkscape::GC::release(copy_repr); |
4346 | 571 | l = l->next; | ||
4347 | 572 | } | 571 | } |
4348 | 573 | DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, | 572 | DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, |
4349 | 574 | _("Stamp")); | 573 | _("Stamp")); |
4350 | 575 | } | 574 | } |
4351 | 576 | 575 | ||
4353 | 577 | if ( fixup && _stamp_cache ) { | 576 | if ( fixup && !_stamp_cache.empty() ) { |
4354 | 578 | // TODO - give a proper fix. Simple temporary work-around for the grab() issue | 577 | // TODO - give a proper fix. Simple temporary work-around for the grab() issue |
4357 | 579 | g_slist_free(_stamp_cache); | 578 | _stamp_cache.clear(); |
4356 | 580 | _stamp_cache = NULL; | ||
4358 | 581 | } | 579 | } |
4359 | 582 | } | 580 | } |
4360 | 583 | 581 | ||
4361 | @@ -712,8 +710,9 @@ | |||
4362 | 712 | case HANDLE_CENTER: | 710 | case HANDLE_CENTER: |
4363 | 713 | if (state & GDK_SHIFT_MASK) { | 711 | if (state & GDK_SHIFT_MASK) { |
4364 | 714 | // Unset the center position for all selected items | 712 | // Unset the center position for all selected items |
4367 | 715 | for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { | 713 | std::vector<SPItem*> items=_desktop->selection->itemList(); |
4368 | 716 | SPItem *it = SP_ITEM(l->data); | 714 | for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4369 | 715 | SPItem *it = *iter; | ||
4370 | 717 | it->unsetCenter(); | 716 | it->unsetCenter(); |
4371 | 718 | it->updateRepr(); | 717 | it->updateRepr(); |
4372 | 719 | _center_is_set = false; // center has changed | 718 | _center_is_set = false; // center has changed |
4373 | @@ -1283,7 +1282,7 @@ | |||
4374 | 1283 | // items will share a single center. While dragging that single center, it should never snap to the | 1282 | // items will share a single center. While dragging that single center, it should never snap to the |
4375 | 1284 | // centers of any of the selected objects. Therefore we will have to pass the list of selected items | 1283 | // centers of any of the selected objects. Therefore we will have to pass the list of selected items |
4376 | 1285 | // to the snapper, to avoid self-snapping of the rotation center | 1284 | // to the snapper, to avoid self-snapping of the rotation center |
4378 | 1286 | GSList *items = (GSList *) const_cast<Selection *>(_selection)->itemList(); | 1285 | std::vector<SPItem*> items = const_cast<Selection *>(_selection)->itemList(); |
4379 | 1287 | SnapManager &m = _desktop->namedview->snap_manager; | 1286 | SnapManager &m = _desktop->namedview->snap_manager; |
4380 | 1288 | m.setup(_desktop); | 1287 | m.setup(_desktop); |
4381 | 1289 | m.setRotationCenterSource(items); | 1288 | m.setRotationCenterSource(items); |
4382 | 1290 | 1289 | ||
4383 | === modified file 'src/seltrans.h' | |||
4384 | --- src/seltrans.h 2014-10-08 02:22:03 +0000 | |||
4385 | +++ src/seltrans.h 2015-04-29 21:03:59 +0000 | |||
4386 | @@ -187,7 +187,7 @@ | |||
4387 | 187 | SPCtrlLine *_l[4]; | 187 | SPCtrlLine *_l[4]; |
4388 | 188 | unsigned int _sel_changed_id; | 188 | unsigned int _sel_changed_id; |
4389 | 189 | unsigned int _sel_modified_id; | 189 | unsigned int _sel_modified_id; |
4391 | 190 | GSList *_stamp_cache; | 190 | std::vector<SPItem*> _stamp_cache; |
4392 | 191 | 191 | ||
4393 | 192 | Geom::Point _origin; ///< position of origin for transforms | 192 | Geom::Point _origin; ///< position of origin for transforms |
4394 | 193 | Geom::Point _point; ///< original position of the knot being used for the current transform | 193 | Geom::Point _point; ///< original position of the knot being used for the current transform |
4395 | 194 | 194 | ||
4396 | === modified file 'src/snap.cpp' | |||
4397 | --- src/snap.cpp 2015-02-25 23:08:51 +0000 | |||
4398 | +++ src/snap.cpp 2015-04-29 21:03:59 +0000 | |||
4399 | @@ -43,7 +43,7 @@ | |||
4400 | 43 | object(this, 0), | 43 | object(this, 0), |
4401 | 44 | snapprefs(), | 44 | snapprefs(), |
4402 | 45 | _named_view(v), | 45 | _named_view(v), |
4404 | 46 | _rotation_center_source_items(NULL), | 46 | _rotation_center_source_items(std::vector<SPItem*>()), |
4405 | 47 | _guide_to_ignore(NULL), | 47 | _guide_to_ignore(NULL), |
4406 | 48 | _desktop(NULL), | 48 | _desktop(NULL), |
4407 | 49 | _snapindicator(true), | 49 | _snapindicator(true), |
4408 | @@ -1013,7 +1013,7 @@ | |||
4409 | 1013 | _snapindicator = snapindicator; | 1013 | _snapindicator = snapindicator; |
4410 | 1014 | _unselected_nodes = unselected_nodes; | 1014 | _unselected_nodes = unselected_nodes; |
4411 | 1015 | _guide_to_ignore = guide_to_ignore; | 1015 | _guide_to_ignore = guide_to_ignore; |
4413 | 1016 | _rotation_center_source_items = NULL; | 1016 | _rotation_center_source_items.clear(); |
4414 | 1017 | } | 1017 | } |
4415 | 1018 | 1018 | ||
4416 | 1019 | void SnapManager::setup(SPDesktop const *desktop, | 1019 | void SnapManager::setup(SPDesktop const *desktop, |
4417 | @@ -1031,7 +1031,7 @@ | |||
4418 | 1031 | _snapindicator = snapindicator; | 1031 | _snapindicator = snapindicator; |
4419 | 1032 | _unselected_nodes = unselected_nodes; | 1032 | _unselected_nodes = unselected_nodes; |
4420 | 1033 | _guide_to_ignore = guide_to_ignore; | 1033 | _guide_to_ignore = guide_to_ignore; |
4422 | 1034 | _rotation_center_source_items = NULL; | 1034 | _rotation_center_source_items.clear(); |
4423 | 1035 | } | 1035 | } |
4424 | 1036 | 1036 | ||
4425 | 1037 | /// Setup, taking the list of items to ignore from the desktop's selection. | 1037 | /// Setup, taking the list of items to ignore from the desktop's selection. |
4426 | @@ -1049,13 +1049,13 @@ | |||
4427 | 1049 | _snapindicator = snapindicator; | 1049 | _snapindicator = snapindicator; |
4428 | 1050 | _unselected_nodes = unselected_nodes; | 1050 | _unselected_nodes = unselected_nodes; |
4429 | 1051 | _guide_to_ignore = guide_to_ignore; | 1051 | _guide_to_ignore = guide_to_ignore; |
4431 | 1052 | _rotation_center_source_items = NULL; | 1052 | _rotation_center_source_items.clear(); |
4432 | 1053 | _items_to_ignore.clear(); | 1053 | _items_to_ignore.clear(); |
4433 | 1054 | 1054 | ||
4434 | 1055 | Inkscape::Selection *sel = _desktop->selection; | 1055 | Inkscape::Selection *sel = _desktop->selection; |
4438 | 1056 | GSList const *items = sel->itemList(); | 1056 | std::vector<SPItem*> const items = sel->itemList(); |
4439 | 1057 | for (GSList *i = const_cast<GSList*>(items); i; i = i->next) { | 1057 | for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { |
4440 | 1058 | _items_to_ignore.push_back(static_cast<SPItem const *>(i->data)); | 1058 | _items_to_ignore.push_back(*i); |
4441 | 1059 | } | 1059 | } |
4442 | 1060 | } | 1060 | } |
4443 | 1061 | 1061 | ||
4444 | 1062 | 1062 | ||
4445 | === modified file 'src/snap.h' | |||
4446 | --- src/snap.h 2014-10-08 02:22:03 +0000 | |||
4447 | +++ src/snap.h 2015-04-29 21:03:59 +0000 | |||
4448 | @@ -136,7 +136,7 @@ | |||
4449 | 136 | std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes = NULL, | 136 | std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes = NULL, |
4450 | 137 | SPGuide *guide_to_ignore = NULL); | 137 | SPGuide *guide_to_ignore = NULL); |
4451 | 138 | 138 | ||
4453 | 139 | void unSetup() {_rotation_center_source_items = NULL; | 139 | void unSetup() {_rotation_center_source_items.clear(); |
4454 | 140 | _guide_to_ignore = NULL; | 140 | _guide_to_ignore = NULL; |
4455 | 141 | _desktop = NULL; | 141 | _desktop = NULL; |
4456 | 142 | _unselected_nodes = NULL;} | 142 | _unselected_nodes = NULL;} |
4457 | @@ -145,8 +145,8 @@ | |||
4458 | 145 | // of this rotation center; this reference is used to make sure that we do not snap a rotation | 145 | // of this rotation center; this reference is used to make sure that we do not snap a rotation |
4459 | 146 | // center to itself | 146 | // center to itself |
4460 | 147 | // NOTE: Must be called after calling setup(), not before! | 147 | // NOTE: Must be called after calling setup(), not before! |
4463 | 148 | void setRotationCenterSource(GSList *items) {_rotation_center_source_items = items;} | 148 | void setRotationCenterSource(const std::vector<SPItem*> &items) {_rotation_center_source_items = items;} |
4464 | 149 | GSList const *getRotationCenterSource() {return _rotation_center_source_items;} | 149 | const std::vector<SPItem*> &getRotationCenterSource() {return _rotation_center_source_items;} |
4465 | 150 | 150 | ||
4466 | 151 | // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a | 151 | // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a |
4467 | 152 | // point if snapping has occurred (by overwriting p); otherwise p is untouched | 152 | // point if snapping has occurred (by overwriting p); otherwise p is untouched |
4468 | @@ -490,7 +490,7 @@ | |||
4469 | 490 | 490 | ||
4470 | 491 | private: | 491 | private: |
4471 | 492 | std::vector<SPItem const *> _items_to_ignore; ///< Items that should not be snapped to, for example the items that are currently being dragged. Set using the setup() method | 492 | std::vector<SPItem const *> _items_to_ignore; ///< Items that should not be snapped to, for example the items that are currently being dragged. Set using the setup() method |
4473 | 493 | GSList *_rotation_center_source_items; // to avoid snapping a rotation center to itself | 493 | std::vector<SPItem*> _rotation_center_source_items; // to avoid snapping a rotation center to itself |
4474 | 494 | SPGuide *_guide_to_ignore; ///< A guide that should not be snapped to, e.g. the guide that is currently being dragged | 494 | SPGuide *_guide_to_ignore; ///< A guide that should not be snapped to, e.g. the guide that is currently being dragged |
4475 | 495 | SPDesktop const *_desktop; | 495 | SPDesktop const *_desktop; |
4476 | 496 | bool _snapindicator; ///< When true, an indicator will be drawn at the position that was being snapped to | 496 | bool _snapindicator; ///< When true, an indicator will be drawn at the position that was being snapped to |
4477 | 497 | 497 | ||
4478 | === modified file 'src/sp-conn-end.cpp' | |||
4479 | --- src/sp-conn-end.cpp 2014-03-30 22:01:25 +0000 | |||
4480 | +++ src/sp-conn-end.cpp 2015-04-29 21:03:59 +0000 | |||
4481 | @@ -50,8 +50,9 @@ | |||
4482 | 50 | 50 | ||
4483 | 51 | // consider all first-order children | 51 | // consider all first-order children |
4484 | 52 | double child_pos = 0.0; | 52 | double child_pos = 0.0; |
4487 | 53 | for (GSList const* i = sp_item_group_item_list(group); i != NULL; i = i->next) { | 53 | std::vector<SPItem*> g = sp_item_group_item_list(group); |
4488 | 54 | SPItem* child_item = SP_ITEM(i->data); | 54 | for (std::vector<SPItem*>::const_iterator i = g.begin();i!=g.end();i++) { |
4489 | 55 | SPItem* child_item = *i; | ||
4490 | 55 | try_get_intersect_point_with_item_recursive(conn_pv, child_item, | 56 | try_get_intersect_point_with_item_recursive(conn_pv, child_item, |
4491 | 56 | item_transform * child_item->transform, child_pos); | 57 | item_transform * child_item->transform, child_pos); |
4492 | 57 | if (intersect_pos < child_pos) | 58 | if (intersect_pos < child_pos) |
4493 | 58 | 59 | ||
4494 | === modified file 'src/sp-defs.cpp' | |||
4495 | --- src/sp-defs.cpp 2015-02-25 00:22:08 +0000 | |||
4496 | +++ src/sp-defs.cpp 2015-04-29 21:03:59 +0000 | |||
4497 | @@ -36,11 +36,9 @@ | |||
4498 | 36 | } | 36 | } |
4499 | 37 | 37 | ||
4500 | 38 | flags &= SP_OBJECT_MODIFIED_CASCADE; | 38 | flags &= SP_OBJECT_MODIFIED_CASCADE; |
4506 | 39 | 39 | std::vector<SPObject*> l(this->childList(true)); | |
4507 | 40 | GSList *l = g_slist_reverse(this->childList(true)); | 40 | for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ |
4508 | 41 | while (l) { | 41 | SPObject *child = *i; |
4504 | 42 | SPObject *child = SP_OBJECT(l->data); | ||
4505 | 43 | l = g_slist_remove(l, child); | ||
4509 | 44 | if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { | 42 | if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
4510 | 45 | child->updateDisplay(ctx, flags); | 43 | child->updateDisplay(ctx, flags); |
4511 | 46 | } | 44 | } |
4512 | 47 | 45 | ||
4513 | === modified file 'src/sp-filter.cpp' | |||
4514 | --- src/sp-filter.cpp 2015-02-25 00:22:08 +0000 | |||
4515 | +++ src/sp-filter.cpp 2015-04-29 21:03:59 +0000 | |||
4516 | @@ -235,11 +235,9 @@ | |||
4517 | 235 | childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; | 235 | childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; |
4518 | 236 | } | 236 | } |
4519 | 237 | childflags &= SP_OBJECT_MODIFIED_CASCADE; | 237 | childflags &= SP_OBJECT_MODIFIED_CASCADE; |
4525 | 238 | 238 | std::vector<SPObject*> l(this->childList(true, SPObject::ActionUpdate)); | |
4526 | 239 | GSList *l = g_slist_reverse(this->childList(true, SPObject::ActionUpdate)); | 239 | for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ |
4527 | 240 | while (l) { | 240 | SPObject *child = *i; |
4523 | 241 | SPObject *child = SP_OBJECT (l->data); | ||
4524 | 242 | l = g_slist_remove (l, child); | ||
4528 | 243 | if( SP_IS_FILTER_PRIMITIVE( child ) ) { | 241 | if( SP_IS_FILTER_PRIMITIVE( child ) ) { |
4529 | 244 | child->updateDisplay(ctx, childflags); | 242 | child->updateDisplay(ctx, childflags); |
4530 | 245 | } | 243 | } |
4531 | 246 | 244 | ||
4532 | === modified file 'src/sp-item-group.cpp' | |||
4533 | --- src/sp-item-group.cpp 2015-03-12 08:19:08 +0000 | |||
4534 | +++ src/sp-item-group.cpp 2015-04-29 21:03:59 +0000 | |||
4535 | @@ -161,11 +161,9 @@ | |||
4536 | 161 | childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; | 161 | childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; |
4537 | 162 | } | 162 | } |
4538 | 163 | childflags &= SP_OBJECT_MODIFIED_CASCADE; | 163 | childflags &= SP_OBJECT_MODIFIED_CASCADE; |
4544 | 164 | 164 | std::vector<SPObject*> l=this->childList(true, SPObject::ActionUpdate); | |
4545 | 165 | GSList *l = g_slist_reverse(this->childList(true, SPObject::ActionUpdate)); | 165 | for(std::vector<SPObject*> ::const_iterator i=l.begin();i!=l.end();i++){ |
4546 | 166 | while (l) { | 166 | SPObject *child = *i; |
4542 | 167 | SPObject *child = SP_OBJECT (l->data); | ||
4543 | 168 | l = g_slist_remove (l, child); | ||
4547 | 169 | 167 | ||
4548 | 170 | if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { | 168 | if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
4549 | 171 | SPItem *item = dynamic_cast<SPItem *>(child); | 169 | SPItem *item = dynamic_cast<SPItem *>(child); |
4550 | @@ -201,20 +199,15 @@ | |||
4551 | 201 | void SPGroup::modified(guint flags) { | 199 | void SPGroup::modified(guint flags) { |
4552 | 202 | // std::cout << "SPGroup::modified(): " << (getId()?getId():"null") << std::endl; | 200 | // std::cout << "SPGroup::modified(): " << (getId()?getId():"null") << std::endl; |
4553 | 203 | SPLPEItem::modified(flags); | 201 | SPLPEItem::modified(flags); |
4554 | 204 | |||
4555 | 205 | SPObject *child; | ||
4556 | 206 | |||
4557 | 207 | if (flags & SP_OBJECT_MODIFIED_FLAG) { | 202 | if (flags & SP_OBJECT_MODIFIED_FLAG) { |
4558 | 208 | flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; | 203 | flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; |
4559 | 209 | } | 204 | } |
4560 | 210 | 205 | ||
4561 | 211 | flags &= SP_OBJECT_MODIFIED_CASCADE; | 206 | flags &= SP_OBJECT_MODIFIED_CASCADE; |
4562 | 212 | 207 | ||
4568 | 213 | GSList *l = g_slist_reverse(this->childList(true)); | 208 | std::vector<SPObject*> l=this->childList(true); |
4569 | 214 | 209 | for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ | |
4570 | 215 | while (l) { | 210 | SPObject *child = *i; |
4566 | 216 | child = SP_OBJECT (l->data); | ||
4567 | 217 | l = g_slist_remove (l, child); | ||
4571 | 218 | 211 | ||
4572 | 219 | if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { | 212 | if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
4573 | 220 | child->emitModified(flags); | 213 | child->emitModified(flags); |
4574 | @@ -286,35 +279,27 @@ | |||
4575 | 286 | Geom::OptRect bbox; | 279 | Geom::OptRect bbox; |
4576 | 287 | 280 | ||
4577 | 288 | // TODO CPPIFY: replace this const_cast later | 281 | // TODO CPPIFY: replace this const_cast later |
4583 | 289 | GSList *l = const_cast<SPGroup*>(this)->childList(false, SPObject::ActionBBox); | 282 | std::vector<SPObject*> l = const_cast<SPGroup*>(this)->childList(false, SPObject::ActionBBox); |
4584 | 290 | 283 | for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ | |
4585 | 291 | while (l) { | 284 | SPObject *o = *i; |
4581 | 292 | SPObject *o = SP_OBJECT (l->data); | ||
4582 | 293 | |||
4586 | 294 | SPItem *item = dynamic_cast<SPItem *>(o); | 285 | SPItem *item = dynamic_cast<SPItem *>(o); |
4587 | 295 | if (item && !item->isHidden()) { | 286 | if (item && !item->isHidden()) { |
4588 | 296 | Geom::Affine const ct(item->transform * transform); | 287 | Geom::Affine const ct(item->transform * transform); |
4589 | 297 | bbox |= item->bounds(bboxtype, ct); | 288 | bbox |= item->bounds(bboxtype, ct); |
4590 | 298 | } | 289 | } |
4591 | 299 | |||
4592 | 300 | l = g_slist_remove (l, o); | ||
4593 | 301 | } | 290 | } |
4594 | 302 | 291 | ||
4595 | 303 | return bbox; | 292 | return bbox; |
4596 | 304 | } | 293 | } |
4597 | 305 | 294 | ||
4598 | 306 | void SPGroup::print(SPPrintContext *ctx) { | 295 | void SPGroup::print(SPPrintContext *ctx) { |
4604 | 307 | GSList *l = g_slist_reverse(this->childList(false)); | 296 | std::vector<SPObject*> l=this->childList(false); |
4605 | 308 | 297 | for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ | |
4606 | 309 | while (l) { | 298 | SPObject *o = *i; |
4602 | 310 | SPObject *o = SP_OBJECT (l->data); | ||
4603 | 311 | |||
4607 | 312 | SPItem *item = dynamic_cast<SPItem *>(o); | 299 | SPItem *item = dynamic_cast<SPItem *>(o); |
4608 | 313 | if (item) { | 300 | if (item) { |
4609 | 314 | item->invoke_print(ctx); | 301 | item->invoke_print(ctx); |
4610 | 315 | } | 302 | } |
4611 | 316 | |||
4612 | 317 | l = g_slist_remove (l, o); | ||
4613 | 318 | } | 303 | } |
4614 | 319 | } | 304 | } |
4615 | 320 | 305 | ||
4616 | @@ -362,17 +347,14 @@ | |||
4617 | 362 | } | 347 | } |
4618 | 363 | 348 | ||
4619 | 364 | void SPGroup::hide (unsigned int key) { | 349 | void SPGroup::hide (unsigned int key) { |
4624 | 365 | GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow)); | 350 | std::vector<SPObject*> l=this->childList(false, SPObject::ActionShow); |
4625 | 366 | 351 | for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ | |
4626 | 367 | while (l) { | 352 | SPObject *o = *i; |
4623 | 368 | SPObject *o = SP_OBJECT (l->data); | ||
4627 | 369 | 353 | ||
4628 | 370 | SPItem *item = dynamic_cast<SPItem *>(o); | 354 | SPItem *item = dynamic_cast<SPItem *>(o); |
4629 | 371 | if (item) { | 355 | if (item) { |
4630 | 372 | item->invoke_hide(key); | 356 | item->invoke_hide(key); |
4631 | 373 | } | 357 | } |
4632 | 374 | |||
4633 | 375 | l = g_slist_remove (l, o); | ||
4634 | 376 | } | 358 | } |
4635 | 377 | 359 | ||
4636 | 378 | // SPLPEItem::onHide(key); | 360 | // SPLPEItem::onHide(key); |
4637 | @@ -407,7 +389,7 @@ | |||
4638 | 407 | } | 389 | } |
4639 | 408 | 390 | ||
4640 | 409 | void | 391 | void |
4642 | 410 | sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) | 392 | sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_done) |
4643 | 411 | { | 393 | { |
4644 | 412 | g_return_if_fail (group != NULL); | 394 | g_return_if_fail (group != NULL); |
4645 | 413 | 395 | ||
4646 | @@ -564,8 +546,8 @@ | |||
4647 | 564 | } | 546 | } |
4648 | 565 | 547 | ||
4649 | 566 | Inkscape::GC::release(repr); | 548 | Inkscape::GC::release(repr); |
4652 | 567 | if (children && item) { | 549 | if (!children.empty() && item) { |
4653 | 568 | *children = g_slist_prepend(*children, item); | 550 | children.insert(children.begin(),item); |
4654 | 569 | } | 551 | } |
4655 | 570 | 552 | ||
4656 | 571 | items = g_slist_remove (items, items->data); | 553 | items = g_slist_remove (items, items->data); |
4657 | @@ -580,19 +562,17 @@ | |||
4658 | 580 | * some API for list aspect of SPGroup | 562 | * some API for list aspect of SPGroup |
4659 | 581 | */ | 563 | */ |
4660 | 582 | 564 | ||
4662 | 583 | GSList *sp_item_group_item_list(SPGroup * group) | 565 | std::vector<SPItem*> sp_item_group_item_list(SPGroup * group) |
4663 | 584 | { | 566 | { |
4667 | 585 | g_return_val_if_fail(group != NULL, NULL); | 567 | std::vector<SPItem*> s; |
4668 | 586 | 568 | g_return_val_if_fail(group != NULL, s); | |
4666 | 587 | GSList *s = NULL; | ||
4669 | 588 | 569 | ||
4670 | 589 | for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { | 570 | for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { |
4671 | 590 | if ( dynamic_cast<SPItem *>(o) ) { | 571 | if ( dynamic_cast<SPItem *>(o) ) { |
4673 | 591 | s = g_slist_prepend(s, o); | 572 | s.push_back((SPItem*)o); |
4674 | 592 | } | 573 | } |
4675 | 593 | } | 574 | } |
4678 | 594 | 575 | return s; | |
4677 | 595 | return g_slist_reverse (s); | ||
4679 | 596 | } | 576 | } |
4680 | 597 | 577 | ||
4681 | 598 | SPObject *sp_item_group_get_child_by_name(SPGroup *group, SPObject *ref, const gchar *name) | 578 | SPObject *sp_item_group_get_child_by_name(SPGroup *group, SPObject *ref, const gchar *name) |
4682 | @@ -807,9 +787,9 @@ | |||
4683 | 807 | 787 | ||
4684 | 808 | void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { | 788 | void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { |
4685 | 809 | Inkscape::DrawingItem *ac = NULL; | 789 | Inkscape::DrawingItem *ac = NULL; |
4689 | 810 | GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow)); | 790 | std::vector<SPObject*> l=this->childList(false, SPObject::ActionShow); |
4690 | 811 | while (l) { | 791 | for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ |
4691 | 812 | SPObject *o = SP_OBJECT (l->data); | 792 | SPObject *o = *i; |
4692 | 813 | SPItem * child = dynamic_cast<SPItem *>(o); | 793 | SPItem * child = dynamic_cast<SPItem *>(o); |
4693 | 814 | if (child) { | 794 | if (child) { |
4694 | 815 | ac = child->invoke_show (drawing, key, flags); | 795 | ac = child->invoke_show (drawing, key, flags); |
4695 | @@ -817,7 +797,6 @@ | |||
4696 | 817 | ai->appendChild(ac); | 797 | ai->appendChild(ac); |
4697 | 818 | } | 798 | } |
4698 | 819 | } | 799 | } |
4699 | 820 | l = g_slist_remove (l, o); | ||
4700 | 821 | } | 800 | } |
4701 | 822 | } | 801 | } |
4702 | 823 | 802 | ||
4703 | @@ -826,10 +805,10 @@ | |||
4704 | 826 | g_message("sp_group_update_patheffect: %p\n", lpeitem); | 805 | g_message("sp_group_update_patheffect: %p\n", lpeitem); |
4705 | 827 | #endif | 806 | #endif |
4706 | 828 | 807 | ||
4708 | 829 | GSList const *item_list = sp_item_group_item_list(this); | 808 | std::vector<SPItem*> const item_list = sp_item_group_item_list(this); |
4709 | 830 | 809 | ||
4712 | 831 | for ( GSList const *iter = item_list; iter; iter = iter->next ) { | 810 | for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4713 | 832 | SPObject *subitem = static_cast<SPObject *>(iter->data); | 811 | SPObject *subitem = *iter; |
4714 | 833 | 812 | ||
4715 | 834 | SPLPEItem *lpeItem = dynamic_cast<SPLPEItem *>(subitem); | 813 | SPLPEItem *lpeItem = dynamic_cast<SPLPEItem *>(subitem); |
4716 | 835 | if (lpeItem) { | 814 | if (lpeItem) { |
4717 | @@ -854,10 +833,10 @@ | |||
4718 | 854 | static void | 833 | static void |
4719 | 855 | sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) | 834 | sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) |
4720 | 856 | { | 835 | { |
4722 | 857 | GSList const *item_list = sp_item_group_item_list(group); | 836 | std::vector<SPItem*> const item_list = sp_item_group_item_list(group); |
4723 | 858 | 837 | ||
4726 | 859 | for ( GSList const *iter = item_list; iter; iter = iter->next ) { | 838 | for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4727 | 860 | SPObject *subitem = static_cast<SPObject *>(iter->data); | 839 | SPObject *subitem = *iter; |
4728 | 861 | 840 | ||
4729 | 862 | SPGroup *subGroup = dynamic_cast<SPGroup *>(subitem); | 841 | SPGroup *subGroup = dynamic_cast<SPGroup *>(subitem); |
4730 | 863 | if (subGroup) { | 842 | if (subGroup) { |
4731 | 864 | 843 | ||
4732 | === modified file 'src/sp-item-group.h' | |||
4733 | --- src/sp-item-group.h 2015-02-21 16:23:30 +0000 | |||
4734 | +++ src/sp-item-group.h 2015-04-29 21:03:59 +0000 | |||
4735 | @@ -95,6 +95,7 @@ | |||
4736 | 95 | virtual void update_patheffect(bool write); | 95 | virtual void update_patheffect(bool write); |
4737 | 96 | }; | 96 | }; |
4738 | 97 | 97 | ||
4739 | 98 | |||
4740 | 98 | /** | 99 | /** |
4741 | 99 | * finds clones of a child of the group going out of the group; and inverse the group transform on its clones | 100 | * finds clones of a child of the group going out of the group; and inverse the group transform on its clones |
4742 | 100 | * Also called when moving objects between different layers | 101 | * Also called when moving objects between different layers |
4743 | @@ -104,10 +105,11 @@ | |||
4744 | 104 | */ | 105 | */ |
4745 | 105 | void sp_item_group_ungroup_handle_clones(SPItem *parent, Geom::Affine const g); | 106 | void sp_item_group_ungroup_handle_clones(SPItem *parent, Geom::Affine const g); |
4746 | 106 | 107 | ||
4751 | 107 | void sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done = true); | 108 | void sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_done = true); |
4752 | 108 | 109 | ||
4753 | 109 | 110 | ||
4754 | 110 | GSList *sp_item_group_item_list (SPGroup *group); | 111 | std::vector<SPItem*> sp_item_group_item_list (SPGroup *group); |
4755 | 112 | |||
4756 | 111 | SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const char *name); | 113 | SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const char *name); |
4757 | 112 | 114 | ||
4758 | 113 | #endif | 115 | #endif |
4759 | 114 | 116 | ||
4760 | === modified file 'src/sp-lpe-item.cpp' | |||
4761 | --- src/sp-lpe-item.cpp 2015-03-12 08:19:08 +0000 | |||
4762 | +++ src/sp-lpe-item.cpp 2015-04-29 21:03:59 +0000 | |||
4763 | @@ -353,9 +353,9 @@ | |||
4764 | 353 | sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); | 353 | sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); |
4765 | 354 | } | 354 | } |
4766 | 355 | if (SP_IS_GROUP(lpeitem)) { | 355 | if (SP_IS_GROUP(lpeitem)) { |
4770 | 356 | GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); | 356 | std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); |
4771 | 357 | for ( GSList const *iter = item_list; iter; iter = iter->next ) { | 357 | for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4772 | 358 | SPObject *subitem = static_cast<SPObject *>(iter->data); | 358 | SPObject *subitem = *iter; |
4773 | 359 | if (SP_IS_LPE_ITEM(subitem)) { | 359 | if (SP_IS_LPE_ITEM(subitem)) { |
4774 | 360 | sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(subitem)); | 360 | sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(subitem)); |
4775 | 361 | } | 361 | } |
4776 | @@ -387,9 +387,9 @@ | |||
4777 | 387 | sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); | 387 | sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); |
4778 | 388 | } | 388 | } |
4779 | 389 | } | 389 | } |
4783 | 390 | GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); | 390 | std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); |
4784 | 391 | for ( GSList const *iter = item_list; iter; iter = iter->next ) { | 391 | for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4785 | 392 | SPObject *subitem = static_cast<SPObject *>(iter->data); | 392 | SPObject *subitem = *iter; |
4786 | 393 | if (SP_IS_LPE_ITEM(subitem)) { | 393 | if (SP_IS_LPE_ITEM(subitem)) { |
4787 | 394 | sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem)); | 394 | sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem)); |
4788 | 395 | } | 395 | } |
4789 | @@ -680,9 +680,9 @@ | |||
4790 | 680 | } | 680 | } |
4791 | 681 | } | 681 | } |
4792 | 682 | if(SP_IS_GROUP(item)){ | 682 | if(SP_IS_GROUP(item)){ |
4796 | 683 | GSList const *item_list = sp_item_group_item_list(SP_GROUP(item)); | 683 | std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); |
4797 | 684 | for ( GSList const *iter = item_list; iter; iter = iter->next ) { | 684 | for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4798 | 685 | SPObject *subitem = static_cast<SPObject *>(iter->data); | 685 | SPObject *subitem = *iter; |
4799 | 686 | apply_to_clippath(SP_ITEM(subitem)); | 686 | apply_to_clippath(SP_ITEM(subitem)); |
4800 | 687 | } | 687 | } |
4801 | 688 | } | 688 | } |
4802 | @@ -732,9 +732,9 @@ | |||
4803 | 732 | } | 732 | } |
4804 | 733 | } | 733 | } |
4805 | 734 | if(SP_IS_GROUP(item)){ | 734 | if(SP_IS_GROUP(item)){ |
4809 | 735 | GSList const *item_list = sp_item_group_item_list(SP_GROUP(item)); | 735 | std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); |
4810 | 736 | for ( GSList const *iter = item_list; iter; iter = iter->next ) { | 736 | for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4811 | 737 | SPObject *subitem = static_cast<SPObject *>(iter->data); | 737 | SPObject *subitem = *iter; |
4812 | 738 | apply_to_mask(SP_ITEM(subitem)); | 738 | apply_to_mask(SP_ITEM(subitem)); |
4813 | 739 | } | 739 | } |
4814 | 740 | } | 740 | } |
4815 | @@ -746,9 +746,9 @@ | |||
4816 | 746 | if (!SP_IS_GROUP(group)) { | 746 | if (!SP_IS_GROUP(group)) { |
4817 | 747 | return; | 747 | return; |
4818 | 748 | } | 748 | } |
4822 | 749 | GSList *item_list = sp_item_group_item_list(SP_GROUP(group)); | 749 | std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(group)); |
4823 | 750 | for ( GSList *iter = item_list; iter; iter = iter->next ) { | 750 | for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4824 | 751 | SPObject *subitem = static_cast<SPObject *>(iter->data); | 751 | SPObject *subitem = *iter; |
4825 | 752 | if (SP_IS_GROUP(subitem)) { | 752 | if (SP_IS_GROUP(subitem)) { |
4826 | 753 | apply_to_clip_or_mask_group(SP_ITEM(subitem), item); | 753 | apply_to_clip_or_mask_group(SP_ITEM(subitem), item); |
4827 | 754 | } else if (SP_IS_SHAPE(subitem)) { | 754 | } else if (SP_IS_SHAPE(subitem)) { |
4828 | 755 | 755 | ||
4829 | === modified file 'src/sp-marker.cpp' | |||
4830 | --- src/sp-marker.cpp 2015-02-25 00:22:08 +0000 | |||
4831 | +++ src/sp-marker.cpp 2015-04-29 21:03:59 +0000 | |||
4832 | @@ -419,7 +419,7 @@ | |||
4833 | 419 | } | 419 | } |
4834 | 420 | 420 | ||
4835 | 421 | 421 | ||
4837 | 422 | const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) | 422 | const gchar *generate_marker(std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) |
4838 | 423 | { | 423 | { |
4839 | 424 | Inkscape::XML::Document *xml_doc = document->getReprDoc(); | 424 | Inkscape::XML::Document *xml_doc = document->getReprDoc(); |
4840 | 425 | Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); | 425 | Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); |
4841 | @@ -442,8 +442,8 @@ | |||
4842 | 442 | const gchar *mark_id = repr->attribute("id"); | 442 | const gchar *mark_id = repr->attribute("id"); |
4843 | 443 | SPObject *mark_object = document->getObjectById(mark_id); | 443 | SPObject *mark_object = document->getObjectById(mark_id); |
4844 | 444 | 444 | ||
4847 | 445 | for (GSList *i = reprs; i != NULL; i = i->next) { | 445 | for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ |
4848 | 446 | Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); | 446 | Inkscape::XML::Node *node = *i; |
4849 | 447 | SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node)); | 447 | SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node)); |
4850 | 448 | 448 | ||
4851 | 449 | Geom::Affine dup_transform; | 449 | Geom::Affine dup_transform; |
4852 | 450 | 450 | ||
4853 | === modified file 'src/sp-marker.h' | |||
4854 | --- src/sp-marker.h 2014-12-21 14:29:02 +0000 | |||
4855 | +++ src/sp-marker.h 2015-04-29 21:03:59 +0000 | |||
4856 | @@ -101,7 +101,7 @@ | |||
4857 | 101 | unsigned int key, unsigned int pos, | 101 | unsigned int key, unsigned int pos, |
4858 | 102 | Geom::Affine const &base, float linewidth); | 102 | Geom::Affine const &base, float linewidth); |
4859 | 103 | void sp_marker_hide (SPMarker *marker, unsigned int key); | 103 | void sp_marker_hide (SPMarker *marker, unsigned int key); |
4861 | 104 | const char *generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); | 104 | const char *generate_marker (std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); |
4862 | 105 | SPObject *sp_marker_fork_if_necessary(SPObject *marker); | 105 | SPObject *sp_marker_fork_if_necessary(SPObject *marker); |
4863 | 106 | 106 | ||
4864 | 107 | #endif | 107 | #endif |
4865 | 108 | 108 | ||
4866 | === modified file 'src/sp-object.cpp' | |||
4867 | --- src/sp-object.cpp 2015-02-25 00:22:08 +0000 | |||
4868 | +++ src/sp-object.cpp 2015-04-29 21:03:59 +0000 | |||
4869 | @@ -380,14 +380,14 @@ | |||
4870 | 380 | sp_repr_css_change(this->getRepr(), css, attr); | 380 | sp_repr_css_change(this->getRepr(), css, attr); |
4871 | 381 | } | 381 | } |
4872 | 382 | 382 | ||
4875 | 383 | GSList *SPObject::childList(bool add_ref, Action) { | 383 | std::vector<SPObject*> SPObject::childList(bool add_ref, Action) { |
4876 | 384 | GSList *l = NULL; | 384 | std::vector<SPObject*> l; |
4877 | 385 | for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { | 385 | for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { |
4878 | 386 | if (add_ref) { | 386 | if (add_ref) { |
4879 | 387 | sp_object_ref (child); | 387 | sp_object_ref (child); |
4880 | 388 | } | 388 | } |
4881 | 389 | 389 | ||
4883 | 390 | l = g_slist_prepend (l, child); | 390 | l.push_back(child); |
4884 | 391 | } | 391 | } |
4885 | 392 | return l; | 392 | return l; |
4886 | 393 | 393 | ||
4887 | 394 | 394 | ||
4888 | === modified file 'src/sp-object.h' | |||
4889 | --- src/sp-object.h 2015-02-21 16:23:30 +0000 | |||
4890 | +++ src/sp-object.h 2015-04-29 21:03:59 +0000 | |||
4891 | @@ -52,6 +52,7 @@ | |||
4892 | 52 | #include <sigc++/connection.h> | 52 | #include <sigc++/connection.h> |
4893 | 53 | #include <sigc++/functors/slot.h> | 53 | #include <sigc++/functors/slot.h> |
4894 | 54 | #include <sigc++/signal.h> | 54 | #include <sigc++/signal.h> |
4895 | 55 | #include <vector> | ||
4896 | 55 | 56 | ||
4897 | 56 | #include "version.h" | 57 | #include "version.h" |
4898 | 57 | #include "util/forward-pointer-iterator.h" | 58 | #include "util/forward-pointer-iterator.h" |
4899 | @@ -328,10 +329,10 @@ | |||
4900 | 328 | enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow }; | 329 | enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow }; |
4901 | 329 | 330 | ||
4902 | 330 | /** | 331 | /** |
4904 | 331 | * Retrieves the children as a GSList object, optionally ref'ing the children | 332 | * Retrieves the children as a std vector object, optionally ref'ing the children |
4905 | 332 | * in the process, if add_ref is specified. | 333 | * in the process, if add_ref is specified. |
4906 | 333 | */ | 334 | */ |
4908 | 334 | GSList *childList(bool add_ref, Action action = ActionGeneral); | 335 | std::vector<SPObject*> childList(bool add_ref, Action action = ActionGeneral); |
4909 | 335 | 336 | ||
4910 | 336 | /** | 337 | /** |
4911 | 337 | * Append repr as child of this object. | 338 | * Append repr as child of this object. |
4912 | 338 | 339 | ||
4913 | === modified file 'src/sp-pattern.cpp' | |||
4914 | --- src/sp-pattern.cpp 2015-02-25 00:22:08 +0000 | |||
4915 | +++ src/sp-pattern.cpp 2015-04-29 21:03:59 +0000 | |||
4916 | @@ -398,7 +398,7 @@ | |||
4917 | 398 | g_free(c); | 398 | g_free(c); |
4918 | 399 | } | 399 | } |
4919 | 400 | 400 | ||
4921 | 401 | const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) | 401 | const gchar *pattern_tile(const std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) |
4922 | 402 | { | 402 | { |
4923 | 403 | Inkscape::XML::Document *xml_doc = document->getReprDoc(); | 403 | Inkscape::XML::Document *xml_doc = document->getReprDoc(); |
4924 | 404 | Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); | 404 | Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); |
4925 | @@ -416,8 +416,8 @@ | |||
4926 | 416 | const gchar *pat_id = repr->attribute("id"); | 416 | const gchar *pat_id = repr->attribute("id"); |
4927 | 417 | SPObject *pat_object = document->getObjectById(pat_id); | 417 | SPObject *pat_object = document->getObjectById(pat_id); |
4928 | 418 | 418 | ||
4931 | 419 | for (GSList *i = reprs; i != NULL; i = i->next) { | 419 | for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ |
4932 | 420 | Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); | 420 | Inkscape::XML::Node *node = *i; |
4933 | 421 | SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); | 421 | SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); |
4934 | 422 | 422 | ||
4935 | 423 | Geom::Affine dup_transform; | 423 | Geom::Affine dup_transform; |
4936 | 424 | 424 | ||
4937 | === modified file 'src/sp-pattern.h' | |||
4938 | --- src/sp-pattern.h 2014-10-08 02:22:03 +0000 | |||
4939 | +++ src/sp-pattern.h 2015-04-29 21:03:59 +0000 | |||
4940 | @@ -89,7 +89,7 @@ | |||
4941 | 89 | SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const char *property); | 89 | SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const char *property); |
4942 | 90 | void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set); | 90 | void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set); |
4943 | 91 | 91 | ||
4945 | 92 | const char *pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); | 92 | const char *pattern_tile (const std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); |
4946 | 93 | 93 | ||
4947 | 94 | SPPattern *pattern_getroot (SPPattern *pat); | 94 | SPPattern *pattern_getroot (SPPattern *pat); |
4948 | 95 | 95 | ||
4949 | 96 | 96 | ||
4950 | === modified file 'src/sp-switch.cpp' | |||
4951 | --- src/sp-switch.cpp 2015-02-25 00:22:08 +0000 | |||
4952 | +++ src/sp-switch.cpp 2015-04-29 21:03:59 +0000 | |||
4953 | @@ -41,21 +41,22 @@ | |||
4954 | 41 | return first; | 41 | return first; |
4955 | 42 | } | 42 | } |
4956 | 43 | 43 | ||
4958 | 44 | GSList *SPSwitch::_childList(bool add_ref, SPObject::Action action) { | 44 | std::vector<SPObject*> SPSwitch::_childList(bool add_ref, SPObject::Action action) { |
4959 | 45 | if ( action != SPObject::ActionGeneral ) { | 45 | if ( action != SPObject::ActionGeneral ) { |
4960 | 46 | return this->childList(add_ref, action); | 46 | return this->childList(add_ref, action); |
4961 | 47 | } | 47 | } |
4962 | 48 | 48 | ||
4963 | 49 | SPObject *child = _evaluateFirst(); | 49 | SPObject *child = _evaluateFirst(); |
4964 | 50 | std::vector<SPObject*> x; | ||
4965 | 50 | if (NULL == child) | 51 | if (NULL == child) |
4967 | 51 | return NULL; | 52 | return x; |
4968 | 52 | 53 | ||
4969 | 53 | if (add_ref) { | 54 | if (add_ref) { |
4970 | 54 | //g_object_ref (G_OBJECT (child)); | 55 | //g_object_ref (G_OBJECT (child)); |
4971 | 55 | sp_object_ref(child); | 56 | sp_object_ref(child); |
4972 | 56 | } | 57 | } |
4975 | 57 | 58 | x.push_back(child); | |
4976 | 58 | return g_slist_prepend (NULL, child); | 59 | return x; |
4977 | 59 | } | 60 | } |
4978 | 60 | 61 | ||
4979 | 61 | const char *SPSwitch::displayName() const { | 62 | const char *SPSwitch::displayName() const { |
4980 | @@ -95,10 +96,9 @@ | |||
4981 | 95 | 96 | ||
4982 | 96 | _releaseLastItem(_cached_item); | 97 | _releaseLastItem(_cached_item); |
4983 | 97 | 98 | ||
4988 | 98 | for ( GSList *l = _childList(false, SPObject::ActionShow); | 99 | std::vector<SPObject*> item_list = _childList(false, SPObject::ActionShow); |
4989 | 99 | NULL != l ; l = g_slist_remove (l, l->data)) | 100 | for ( std::vector<SPObject*>::const_reverse_iterator iter=item_list.rbegin();iter!=item_list.rend();iter++) { |
4990 | 100 | { | 101 | SPObject *o = *iter; |
4987 | 101 | SPObject *o = SP_OBJECT (l->data); | ||
4991 | 102 | if ( !SP_IS_ITEM (o) ) { | 102 | if ( !SP_IS_ITEM (o) ) { |
4992 | 103 | continue; | 103 | continue; |
4993 | 104 | } | 104 | } |
4994 | @@ -130,10 +130,10 @@ | |||
4995 | 130 | void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { | 130 | void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { |
4996 | 131 | SPObject *evaluated_child = this->_evaluateFirst(); | 131 | SPObject *evaluated_child = this->_evaluateFirst(); |
4997 | 132 | 132 | ||
4999 | 133 | GSList *l = this->_childList(false, SPObject::ActionShow); | 133 | std::vector<SPObject*> l = this->_childList(false, SPObject::ActionShow); |
5000 | 134 | 134 |
I added some fancy new diff comments that should help show where things need fixing.