Merge lp:~mc.../inkscape/mc-selection-transform into lp:~inkscape.dev/inkscape/trunk

Proposed by Mc
Status: Needs review
Proposed branch: lp:~mc.../inkscape/mc-selection-transform
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 3772 lines (+882/-872)
3 files modified
src/selection-chemistry.cpp (+865/-872)
src/selection.cpp (+7/-0)
src/selection.h (+10/-0)
To merge this branch: bzr merge lp:~mc.../inkscape/mc-selection-transform
Reviewer Review Type Date Requested Status
Jabiertxof code Approve
Review via email: mp+269893@code.launchpad.net

Description of the change

Refactoring of sp_selection_apply_affine, taking care of the case when we select an original and a clone which is present in a selected group (and not directly selected)

To post a comment you must log in.
Revision history for this message
Mc (mc...) wrote :

NB: The diff is huge because i made a clang-format to have all the presentation right, the only non-whitespace parts are lines 1297-1651 and 3728+

Revision history for this message
Jabiertxof (jabiertxof) wrote :

I put three minor things about coding style previouly someone review me. AlsoNathan ping me about dont "clangformat" merges, till become accepted. Anyway I read your comment and help me a lot in the review. I do not a usage review, ping me if you want me to compile to give a second try.

review: Approve (code)

Unmerged revisions

14347. By Mc

more clang-format because i can never get the spacing right

14346. By Mc

final comments and refactor

14345. By Mc

refactor + fixed linked offsets

14344. By Mc

I was not /that/ far yesterday at 4am. Ready to be tested !

14343. By Mc

works better than previously, but there is still some strange behavior

14342. By Mc

Wait a minute, is that really working ? Have those several hours with paper and pen, filling pages with matrix multiplications, not been in vain ?

Just kidding, still WIP. make a clone of clone, move the original and first clone, the second moves unexpectedly.

But still, the fact that the first clone behaves right is already pretty cool !

14341. By Mc

I'm so confused right now.

14340. By Mc

does not break anything yet. I still have to fix the case where i resize a (original+(clone in a group)) selection

14339. By Mc

clang-format src/selection-chemistry.cpp

14338. By Mc

add includes_deeply helper function to test if an object is selected, even indirectly

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/selection-chemistry.cpp'
2--- src/selection-chemistry.cpp 2015-05-26 20:27:00 +0000
3+++ src/selection-chemistry.cpp 2015-09-02 11:21:15 +0000
4@@ -12,15 +12,16 @@
5 * Abhishek Sharma
6 * Kris De Gussem <Kris.DeGussem@gmail.com>
7 * Tavmjong Bah <tavmjong@free.fr> (Symbol additions)
8+ * Marc Jeanmougin <marc@jeanmougin.fr>
9 *
10- * Copyright (C) 1999-2010,2012 authors
11+ * Copyright (C) 1999-2010,2012,2015 authors
12 * Copyright (C) 2001-2002 Ximian, Inc.
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
16
17 #ifdef HAVE_CONFIG_H
18-# include "config.h"
19+#include "config.h"
20 #endif
21
22 #include <gtkmm/clipboard.h>
23@@ -131,14 +132,12 @@
24
25 // helper for printing error messages, regardless of whether we have a GUI or not
26 // If desktop == NULL, errors will be shown on stderr
27-static void
28-selection_display_message(SPDesktop *desktop, Inkscape::MessageType msgType, Glib::ustring const &msg)
29+static void selection_display_message(SPDesktop *desktop, Inkscape::MessageType msgType, Glib::ustring const &msg)
30 {
31 if (desktop) {
32 desktop->messageStack()->flash(msgType, msg);
33 } else {
34- if (msgType == Inkscape::IMMEDIATE_MESSAGE ||
35- msgType == Inkscape::WARNING_MESSAGE ||
36+ if (msgType == Inkscape::IMMEDIATE_MESSAGE || msgType == Inkscape::WARNING_MESSAGE ||
37 msgType == Inkscape::ERROR_MESSAGE) {
38 g_printerr("%s\n", msg.c_str());
39 }
40@@ -150,7 +149,7 @@
41 void SelectionHelper::selectAll(SPDesktop *dt)
42 {
43 if (tools_isactive(dt, TOOLS_NODES)) {
44- NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
45+ NodeTool *nt = static_cast<NodeTool *>(dt->event_context);
46 if (!nt->_multipath->empty()) {
47 nt->_multipath->selectSubpaths();
48 return;
49@@ -162,7 +161,7 @@
50 void SelectionHelper::selectAllInAll(SPDesktop *dt)
51 {
52 if (tools_isactive(dt, TOOLS_NODES)) {
53- NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
54+ NodeTool *nt = static_cast<NodeTool *>(dt->event_context);
55 nt->_selected_nodes->selectAll();
56 } else {
57 sp_edit_select_all_in_all_layers(dt);
58@@ -173,7 +172,7 @@
59 {
60 NodeTool *nt = NULL;
61 if (tools_isactive(dt, TOOLS_NODES)) {
62- nt = static_cast<NodeTool*>(dt->event_context);
63+ nt = static_cast<NodeTool *>(dt->event_context);
64 }
65
66 if (nt && !nt->_selected_nodes->empty()) {
67@@ -186,35 +185,20 @@
68 }
69 }
70
71-void SelectionHelper::selectSameFillStroke(SPDesktop *dt)
72-{
73- sp_select_same_fill_stroke_style(dt, true, true, true);
74-}
75-
76-void SelectionHelper::selectSameFillColor(SPDesktop *dt)
77-{
78- sp_select_same_fill_stroke_style(dt, true, false, false);
79-}
80-
81-void SelectionHelper::selectSameStrokeColor(SPDesktop *dt)
82-{
83- sp_select_same_fill_stroke_style(dt, false, true, false);
84-}
85-
86-void SelectionHelper::selectSameStrokeStyle(SPDesktop *dt)
87-{
88- sp_select_same_fill_stroke_style(dt, false, false, true);
89-}
90-
91-void SelectionHelper::selectSameObjectType(SPDesktop *dt)
92-{
93- sp_select_same_object_type(dt);
94-}
95+void SelectionHelper::selectSameFillStroke(SPDesktop *dt) { sp_select_same_fill_stroke_style(dt, true, true, true); }
96+
97+void SelectionHelper::selectSameFillColor(SPDesktop *dt) { sp_select_same_fill_stroke_style(dt, true, false, false); }
98+
99+void SelectionHelper::selectSameStrokeColor(SPDesktop *dt) { sp_select_same_fill_stroke_style(dt, false, true, false); }
100+
101+void SelectionHelper::selectSameStrokeStyle(SPDesktop *dt) { sp_select_same_fill_stroke_style(dt, false, false, true); }
102+
103+void SelectionHelper::selectSameObjectType(SPDesktop *dt) { sp_select_same_object_type(dt); }
104
105 void SelectionHelper::invert(SPDesktop *dt)
106 {
107 if (tools_isactive(dt, TOOLS_NODES)) {
108- NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
109+ NodeTool *nt = static_cast<NodeTool *>(dt->event_context);
110 nt->_multipath->invertSelectionInSubpaths();
111 } else {
112 sp_edit_invert(dt);
113@@ -224,7 +208,7 @@
114 void SelectionHelper::invertAllInAll(SPDesktop *dt)
115 {
116 if (tools_isactive(dt, TOOLS_NODES)) {
117- NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
118+ NodeTool *nt = static_cast<NodeTool *>(dt->event_context);
119 nt->_selected_nodes->invertSelection();
120 } else {
121 sp_edit_invert_in_all_layers(dt);
122@@ -235,7 +219,7 @@
123 {
124 // TODO make this a virtual method of event context!
125 if (tools_isactive(dt, TOOLS_NODES)) {
126- NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
127+ NodeTool *nt = static_cast<NodeTool *>(dt->event_context);
128 nt->_multipath->reverseSubpaths();
129 } else {
130 sp_selected_path_reverse(dt);
131@@ -246,10 +230,9 @@
132 {
133 Inkscape::UI::Tools::ToolBase *ec = dt->event_context;
134 if (tools_isactive(dt, TOOLS_NODES)) {
135- NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
136+ NodeTool *nt = static_cast<NodeTool *>(dt->event_context);
137 nt->_multipath->shiftSelection(1);
138- } else if (tools_isactive(dt, TOOLS_GRADIENT)
139- && ec->_grdrag->isNonEmpty()) {
140+ } else if (tools_isactive(dt, TOOLS_GRADIENT) && ec->_grdrag->isNonEmpty()) {
141 Inkscape::UI::Tools::sp_gradient_context_select_next(ec);
142 } else {
143 sp_selection_item_next(dt);
144@@ -260,10 +243,9 @@
145 {
146 Inkscape::UI::Tools::ToolBase *ec = dt->event_context;
147 if (tools_isactive(dt, TOOLS_NODES)) {
148- NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
149+ NodeTool *nt = static_cast<NodeTool *>(dt->event_context);
150 nt->_multipath->shiftSelection(-1);
151- } else if (tools_isactive(dt, TOOLS_GRADIENT)
152- && ec->_grdrag->isNonEmpty()) {
153+ } else if (tools_isactive(dt, TOOLS_GRADIENT) && ec->_grdrag->isNonEmpty()) {
154 Inkscape::UI::Tools::sp_gradient_context_select_prev(ec);
155 } else {
156 sp_selection_item_prev(dt);
157@@ -273,23 +255,20 @@
158 /*
159 * Fixes the current selection, removing locked objects from it
160 */
161-void SelectionHelper::fixSelection(SPDesktop *dt)
162+void SelectionHelper::fixSelection(SPDesktop *dt)
163 {
164- if(!dt)
165+ if (!dt)
166 return;
167
168 Inkscape::Selection *selection = dt->getSelection();
169-
170- std::vector<SPItem*> items ;
171-
172- std::vector<SPItem*> const selList = selection->itemList();
173-
174- for( std::vector<SPItem*>::const_reverse_iterator i = selList.rbegin(); i != selList.rend(); i++ ) {
175+
176+ std::vector<SPItem *> items;
177+
178+ std::vector<SPItem *> const selList = selection->itemList();
179+
180+ for (std::vector<SPItem *>::const_reverse_iterator i = selList.rbegin(); i != selList.rend(); i++) {
181 SPItem *item = *i;
182- if( item &&
183- !dt->isLayer(item) &&
184- (!item->isLocked()))
185- {
186+ if (item && !dt->isLayer(item) && (!item->isLocked())) {
187 items.push_back(item);
188 }
189 }
190@@ -304,7 +283,8 @@
191 * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t',
192 * then prepends the copy to 'clip'.
193 */
194-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)
195+static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t,
196+ std::vector<Inkscape::XML::Node *> &clip, Inkscape::XML::Document *xml_doc)
197 {
198 Inkscape::XML::Node *copy = repr->duplicate(xml_doc);
199
200@@ -316,21 +296,22 @@
201 // write the complete accumulated transform passed to us
202 // (we're dealing with unattached repr, so we write to its attr
203 // instead of using sp_item_set_transform)
204- gchar *affinestr=sp_svg_transform_write(full_t);
205+ gchar *affinestr = sp_svg_transform_write(full_t);
206 copy->setAttribute("transform", affinestr);
207 g_free(affinestr);
208
209- clip.insert(clip.begin(),copy);
210+ clip.insert(clip.begin(), copy);
211 }
212
213-static void sp_selection_copy_impl(std::vector<SPItem*> const &items, std::vector<Inkscape::XML::Node*> &clip, Inkscape::XML::Document* xml_doc)
214+static void sp_selection_copy_impl(std::vector<SPItem *> const &items, std::vector<Inkscape::XML::Node *> &clip,
215+ Inkscape::XML::Document *xml_doc)
216 {
217 // Sort items:
218- std::vector<SPItem*> sorted_items(items);
219- sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position_bool);
220+ std::vector<SPItem *> sorted_items(items);
221+ sort(sorted_items.begin(), sorted_items.end(), sp_object_compare_position_bool);
222
223 // Copy item reprs:
224- for (std::vector<SPItem*>::const_iterator i = sorted_items.begin(); i != sorted_items.end(); i++) {
225+ for (std::vector<SPItem *>::const_iterator i = sorted_items.begin(); i != sorted_items.end(); i++) {
226 SPItem *item = *i;
227 if (item) {
228 sp_selection_copy_one(item->getRepr(), item->i2doc_affine(), clip, xml_doc);
229@@ -338,20 +319,21 @@
230 g_assert_not_reached();
231 }
232 }
233- reverse(clip.begin(),clip.end());
234+ reverse(clip.begin(), clip.end());
235 }
236
237 // TODO check if parent parameter should be changed to SPItem, of if the code should handle non-items.
238-static std::vector<Inkscape::XML::Node*> sp_selection_paste_impl(SPDocument *doc, SPObject *parent, std::vector<Inkscape::XML::Node*> &clip)
239+static std::vector<Inkscape::XML::Node *> sp_selection_paste_impl(SPDocument *doc, SPObject *parent,
240+ std::vector<Inkscape::XML::Node *> &clip)
241 {
242 Inkscape::XML::Document *xml_doc = doc->getReprDoc();
243
244 SPItem *parentItem = dynamic_cast<SPItem *>(parent);
245 g_assert(parentItem != NULL);
246
247- std::vector<Inkscape::XML::Node*> copied;
248+ std::vector<Inkscape::XML::Node *> copied;
249 // add objects to document
250- for (std::vector<Inkscape::XML::Node*>::const_iterator l = clip.begin(); l != clip.end(); l++) {
251+ for (std::vector<Inkscape::XML::Node *>::const_iterator l = clip.begin(); l != clip.end(); l++) {
252 Inkscape::XML::Node *repr = *l;
253 Inkscape::XML::Node *copy = repr->duplicate(xml_doc);
254
255@@ -364,7 +346,7 @@
256 sp_svg_transform_read(t_str, &item_t);
257 item_t *= local.inverse();
258 // (we're dealing with unattached repr, so we write to its attr instead of using sp_item_set_transform)
259- gchar *affinestr=sp_svg_transform_write(item_t);
260+ gchar *affinestr = sp_svg_transform_write(item_t);
261 copy->setAttribute("transform", affinestr);
262 g_free(affinestr);
263 }
264@@ -376,12 +358,13 @@
265 return copied;
266 }
267
268-static void sp_selection_delete_impl(std::vector<SPItem*> const &items, bool propagate = true, bool propagate_descendants = true)
269+static void sp_selection_delete_impl(std::vector<SPItem *> const &items, bool propagate = true,
270+ bool propagate_descendants = true)
271 {
272- for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
273+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
274 sp_object_ref(*i, NULL);
275 }
276- for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
277+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
278 SPItem *item = *i;
279 item->deleteObject(propagate, propagate_descendants);
280 sp_object_unref(item, NULL);
281@@ -397,8 +380,7 @@
282
283 if (tools_isactive(desktop, TOOLS_TEXT))
284 if (Inkscape::UI::Tools::sp_text_delete_selection(desktop->event_context)) {
285- DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
286- _("Delete text"));
287+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Delete text"));
288 return;
289 }
290
291@@ -409,7 +391,7 @@
292 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Nothing</b> was deleted."));
293 return;
294 }
295- std::vector<SPItem*> selected(selection->itemList());
296+ std::vector<SPItem *> selected(selection->itemList());
297 selection->clear();
298 sp_selection_delete_impl(selected);
299 desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
300@@ -420,10 +402,9 @@
301 * associated selection context. For example: deleting an object
302 * while moving it around the canvas.
303 */
304- tools_switch( desktop, tools_active( desktop ) );
305+ tools_switch(desktop, tools_active(desktop));
306
307- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_DELETE,
308- _("Delete"));
309+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_DELETE, _("Delete"));
310 }
311
312 static void add_ids_recursive(std::vector<const gchar *> &ids, SPObject *obj)
313@@ -432,7 +413,7 @@
314 ids.push_back(obj->getId());
315
316 if (dynamic_cast<SPGroup *>(obj)) {
317- for (SPObject *child = obj->firstChild() ; child; child = child->getNext() ) {
318+ for (SPObject *child = obj->firstChild(); child; child = child->getNext()) {
319 add_ids_recursive(ids, child);
320 }
321 }
322@@ -446,7 +427,7 @@
323 }
324
325 SPDocument *doc = desktop->doc();
326- Inkscape::XML::Document* xml_doc = doc->getReprDoc();
327+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
328 Inkscape::Selection *selection = desktop->getSelection();
329
330 // check if something is selected
331@@ -454,9 +435,9 @@
332 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to duplicate."));
333 return;
334 }
335- std::vector<Inkscape::XML::Node*> reprs(selection->reprList());
336+ std::vector<Inkscape::XML::Node *> reprs(selection->reprList());
337
338- if(duplicateLayer){
339+ if (duplicateLayer) {
340 reprs.clear();
341 reprs.push_back(desktop->currentLayer()->getRepr());
342 }
343@@ -465,9 +446,9 @@
344
345 // sorting items from different parents sorts each parent's subset without possibly mixing
346 // them, just what we need
347- sort(reprs.begin(),reprs.end(),sp_repr_compare_position_bool);
348+ sort(reprs.begin(), reprs.end(), sp_repr_compare_position_bool);
349
350- std::vector<Inkscape::XML::Node*> newsel;
351+ std::vector<Inkscape::XML::Node *> newsel;
352
353 std::vector<const gchar *> old_ids;
354 std::vector<const gchar *> new_ids;
355@@ -475,15 +456,15 @@
356 bool relink_clones = prefs->getBool("/options/relinkclonesonduplicate/value");
357 const bool fork_livepatheffects = prefs->getBool("/options/forklpeonduplicate/value", true);
358
359- for(std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){
360+ for (std::vector<Inkscape::XML::Node *>::const_iterator i = reprs.begin(); i != reprs.end(); i++) {
361 Inkscape::XML::Node *old_repr = *i;
362 Inkscape::XML::Node *parent = old_repr->parent();
363 Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
364
365- if(! duplicateLayer)
366+ if (!duplicateLayer)
367 parent->appendChild(copy);
368 else
369- parent->addChild(copy, old_repr);
370+ parent->addChild(copy, old_repr);
371
372 if (relink_clones) {
373 SPObject *old_obj = doc->getObjectByRepr(old_repr);
374@@ -519,7 +500,8 @@
375 for (unsigned int j = 0; j < old_ids.size(); j++) {
376 if (!strcmp(orig->getId(), old_ids[j])) {
377 // we have both orig and clone in selection, relink
378- // std::cout << id << " old, its ori: " << orig->getId() << "; will relink:" << new_ids[i] << " to " << new_ids[j] << "\n";
379+ // std::cout << id << " old, its ori: " << orig->getId() << "; will relink:" << new_ids[i] << "
380+ // to " << new_ids[j] << "\n";
381 SPObject *new_clone = doc->getObjectById(new_ids[i]);
382 new_clone->getRepr()->setAttribute("xlink:href", Glib::ustring("#") + new_ids[j]);
383 new_clone->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
384@@ -530,8 +512,9 @@
385 if (offset) {
386 for (guint j = 0; j < old_ids.size(); j++) {
387 gchar *source_href = offset->sourceHref;
388- if (source_href && source_href[0]=='#' && !strcmp(source_href+1, old_ids[j])) {
389- doc->getObjectById(new_ids[i])->getRepr()->setAttribute("xlink:href", Glib::ustring("#") + new_ids[j]);
390+ if (source_href && source_href[0] == '#' && !strcmp(source_href + 1, old_ids[j])) {
391+ doc->getObjectById(new_ids[i])->getRepr()->setAttribute("xlink:href",
392+ Glib::ustring("#") + new_ids[j]);
393 }
394 }
395 }
396@@ -540,16 +523,15 @@
397 }
398
399
400- if ( !suppressDone ) {
401- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_DUPLICATE,
402- _("Duplicate"));
403+ if (!suppressDone) {
404+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_DUPLICATE, _("Duplicate"));
405 }
406- if(!duplicateLayer)
407+ if (!duplicateLayer)
408 selection->setReprList(newsel);
409- else{
410- SPObject* new_layer = doc->getObjectByRepr(newsel[0]);
411- gchar* name = g_strdup_printf(_("%s copy"), new_layer->label());
412- desktop->layer_manager->renameLayer( new_layer, name, TRUE );
413+ else {
414+ SPObject *new_layer = doc->getObjectByRepr(newsel[0]);
415+ gchar *name = g_strdup_printf(_("%s copy"), new_layer->label());
416+ desktop->layer_manager->renameLayer(new_layer, name, TRUE);
417 g_free(name);
418 }
419 }
420@@ -564,14 +546,13 @@
421
422 SPGroup *group = dynamic_cast<SPGroup *>(selection->layers()->currentLayer());
423 g_return_if_fail(group != NULL);
424- std::vector<SPItem*> items = sp_item_group_item_list(group);
425+ std::vector<SPItem *> items = sp_item_group_item_list(group);
426
427- for(unsigned int i = 0; i < items.size(); i++){
428+ for (unsigned int i = 0; i < items.size(); i++) {
429 items[i]->deleteObject();
430 }
431
432- DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL,
433- _("Delete all"));
434+ DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, _("Delete all"));
435 }
436
437 /*
438@@ -584,18 +565,15 @@
439 * onlysensitive - TRUE includes only non-locked items
440 * ingroups - TRUE to recursively get grouped items children
441 */
442-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)
443+std::vector<SPItem *> &get_all_items(std::vector<SPItem *> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible,
444+ bool onlysensitive, bool ingroups, std::vector<SPItem *> const &exclude)
445 {
446- for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) {
447+ for (SPObject *child = from->firstChild(); child; child = child->getNext()) {
448 SPItem *item = dynamic_cast<SPItem *>(child);
449- if (item &&
450- !desktop->isLayer(item) &&
451- (!onlysensitive || !item->isLocked()) &&
452+ if (item && !desktop->isLayer(item) && (!onlysensitive || !item->isLocked()) &&
453 (!onlyvisible || !desktop->itemIsHidden(item)) &&
454- (exclude.empty() || exclude.end() == std::find(exclude.begin(),exclude.end(),child))
455- )
456- {
457- list.insert(list.begin(),item);
458+ (exclude.empty() || exclude.end() == std::find(exclude.begin(), exclude.end(), child))) {
459+ list.insert(list.begin(), item);
460 }
461
462 if (ingroups || (item && desktop->isLayer(item))) {
463@@ -616,13 +594,14 @@
464 g_return_if_fail(dynamic_cast<SPGroup *>(dt->currentLayer()));
465
466 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
467- PrefsSelectionContext inlayer = (PrefsSelectionContext) prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
468+ PrefsSelectionContext inlayer =
469+ (PrefsSelectionContext)prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
470 bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
471 bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
472
473- std::vector<SPItem*> items ;
474+ std::vector<SPItem *> items;
475
476- std::vector<SPItem*> exclude;
477+ std::vector<SPItem *> exclude;
478 if (invert) {
479 exclude = selection->itemList();
480 }
481@@ -632,73 +611,62 @@
482
483 switch (inlayer) {
484 case PREFS_SELECTION_LAYER: {
485- if ( (onlysensitive && dynamic_cast<SPItem *>(dt->currentLayer())->isLocked()) ||
486- (onlyvisible && dt->itemIsHidden(dynamic_cast<SPItem *>(dt->currentLayer()))) )
487- return;
488-
489- std::vector<SPItem*> all_items = sp_item_group_item_list(dynamic_cast<SPGroup *>(dt->currentLayer()));
490-
491- for (std::vector<SPItem*>::const_reverse_iterator i=all_items.rbegin();i!=all_items.rend();i++) {
492- SPItem *item = *i;
493-
494- if (item && (!onlysensitive || !item->isLocked())) {
495- if (!onlyvisible || !dt->itemIsHidden(item)) {
496- if (!dt->isLayer(item)) {
497- if (!invert || exclude.end() == std::find(exclude.begin(),exclude.end(),item)) {
498- items.push_back(item); // leave it in the list
499+ if ((onlysensitive && dynamic_cast<SPItem *>(dt->currentLayer())->isLocked()) ||
500+ (onlyvisible && dt->itemIsHidden(dynamic_cast<SPItem *>(dt->currentLayer()))))
501+ return;
502+
503+ std::vector<SPItem *> all_items = sp_item_group_item_list(dynamic_cast<SPGroup *>(dt->currentLayer()));
504+
505+ for (std::vector<SPItem *>::const_reverse_iterator i = all_items.rbegin(); i != all_items.rend(); i++) {
506+ SPItem *item = *i;
507+
508+ if (item && (!onlysensitive || !item->isLocked())) {
509+ if (!onlyvisible || !dt->itemIsHidden(item)) {
510+ if (!dt->isLayer(item)) {
511+ if (!invert || exclude.end() == std::find(exclude.begin(), exclude.end(), item)) {
512+ items.push_back(item); // leave it in the list
513+ }
514 }
515 }
516 }
517 }
518- }
519
520 break;
521 }
522 case PREFS_SELECTION_LAYER_RECURSIVE: {
523- std::vector<SPItem*> x;
524+ std::vector<SPItem *> x;
525 items = get_all_items(x, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude);
526 break;
527 }
528 default: {
529- std::vector<SPItem*> x;
530+ std::vector<SPItem *> x;
531 items = get_all_items(x, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude);
532 break;
533- }
534+ }
535 }
536
537 selection->setList(items);
538-
539-}
540-
541-void sp_edit_select_all(SPDesktop *desktop)
542-{
543- sp_edit_select_all_full(desktop, false, false);
544-}
545-
546-void sp_edit_select_all_in_all_layers(SPDesktop *desktop)
547-{
548- sp_edit_select_all_full(desktop, true, false);
549-}
550-
551-void sp_edit_invert(SPDesktop *desktop)
552-{
553- sp_edit_select_all_full(desktop, false, true);
554-}
555-
556-void sp_edit_invert_in_all_layers(SPDesktop *desktop)
557-{
558- sp_edit_select_all_full(desktop, true, true);
559-}
560-
561-static void sp_selection_group_impl(std::vector<Inkscape::XML::Node*> p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) {
562-
563- sort(p.begin(),p.end(),sp_repr_compare_position_bool);
564+}
565+
566+void sp_edit_select_all(SPDesktop *desktop) { sp_edit_select_all_full(desktop, false, false); }
567+
568+void sp_edit_select_all_in_all_layers(SPDesktop *desktop) { sp_edit_select_all_full(desktop, true, false); }
569+
570+void sp_edit_invert(SPDesktop *desktop) { sp_edit_select_all_full(desktop, false, true); }
571+
572+void sp_edit_invert_in_all_layers(SPDesktop *desktop) { sp_edit_select_all_full(desktop, true, true); }
573+
574+static void sp_selection_group_impl(std::vector<Inkscape::XML::Node *> p, Inkscape::XML::Node *group,
575+ Inkscape::XML::Document *xml_doc, SPDocument *doc)
576+{
577+
578+ sort(p.begin(), p.end(), sp_repr_compare_position_bool);
579
580 // Remember the position and parent of the topmost object.
581 gint topmost = p.back()->position();
582 Inkscape::XML::Node *topmost_parent = p.back()->parent();
583
584- for(std::vector<Inkscape::XML::Node*>::const_iterator i = p.begin(); i != p.end(); i++){
585+ for (std::vector<Inkscape::XML::Node *>::const_iterator i = p.begin(); i != p.end(); i++) {
586 Inkscape::XML::Node *current = *i;
587
588 if (current->parent() == topmost_parent) {
589@@ -706,12 +674,14 @@
590 sp_repr_unparent(current);
591 group->appendChild(spnew);
592 Inkscape::GC::release(spnew);
593- topmost --; // only reduce count for those items deleted from topmost_parent
594- } else { // move it to topmost_parent first
595- std::vector<Inkscape::XML::Node*> temp_clip;
596+ topmost--; // only reduce count for those items deleted from topmost_parent
597+ } else { // move it to topmost_parent first
598+ std::vector<Inkscape::XML::Node *> temp_clip;
599
600- // At this point, current may already have no item, due to its being a clone whose original is already moved away
601- // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform
602+ // At this point, current may already have no item, due to its being a clone whose original is already moved
603+ // away
604+ // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent
605+ // transform
606 gchar const *t_str = current->attribute("transform");
607 Geom::Affine item_t(Geom::identity());
608 if (t_str)
609@@ -728,8 +698,10 @@
610 sp_repr_unparent(current);
611
612 // paste into topmost_parent (temporarily)
613- std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip);
614- if (!temp_clip.empty())temp_clip.clear() ;
615+ std::vector<Inkscape::XML::Node *> copied =
616+ sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip);
617+ if (!temp_clip.empty())
618+ temp_clip.clear();
619 if (!copied.empty()) { // if success,
620 // take pasted object (now in topmost_parent)
621 Inkscape::XML::Node *in_topmost = copied.back();
622@@ -763,7 +735,7 @@
623 return;
624 }
625
626- std::vector<Inkscape::XML::Node*> p (selection->reprList());
627+ std::vector<Inkscape::XML::Node *> p(selection->reprList());
628
629 selection->clear();
630
631@@ -771,14 +743,14 @@
632
633 sp_selection_group_impl(p, group, xml_doc, doc);
634
635- DocumentUndo::done(doc, SP_VERB_SELECTION_GROUP,
636- C_("Verb", "Group"));
637+ DocumentUndo::done(doc, SP_VERB_SELECTION_GROUP, C_("Verb", "Group"));
638
639 selection->set(group);
640 Inkscape::GC::release(group);
641 }
642
643-static gint clone_depth_descending(gconstpointer a, gconstpointer b) {
644+static gint clone_depth_descending(gconstpointer a, gconstpointer b)
645+{
646 SPUse *use_a = static_cast<SPUse *>(const_cast<gpointer>(a));
647 SPUse *use_b = static_cast<SPUse *>(const_cast<gpointer>(b));
648 int depth_a = use_a->cloneDepth();
649@@ -799,10 +771,10 @@
650 }
651
652 // first check whether there is anything to ungroup
653- std::vector<SPItem*> old_select = selection->itemList();
654- std::vector<SPItem*> new_select;
655+ std::vector<SPItem *> old_select = selection->itemList();
656+ std::vector<SPItem *> new_select;
657 GSList *groups = NULL;
658- for (std::vector<SPItem*>::const_iterator item = old_select.begin(); item!=old_select.end(); item++) {
659+ for (std::vector<SPItem *>::const_iterator item = old_select.begin(); item != old_select.end(); item++) {
660 SPItem *obj = *item;
661 if (dynamic_cast<SPGroup *>(obj)) {
662 groups = g_slist_prepend(groups, obj);
663@@ -815,13 +787,13 @@
664 return;
665 }
666
667- std::vector<SPItem*> items(old_select);
668+ std::vector<SPItem *> items(old_select);
669 selection->clear();
670
671 // If any of the clones refer to the groups, unlink them and replace them with successors
672 // in the items list.
673 GSList *clones_to_unlink = NULL;
674- for (std::vector<SPItem*>::const_iterator item = items.begin(); item != items.end(); item++) {
675+ for (std::vector<SPItem *>::const_iterator item = items.begin(); item != items.end(); item++) {
676 SPUse *use = dynamic_cast<SPUse *>(*item);
677
678 SPItem *original = use;
679@@ -841,21 +813,21 @@
680
681 for (GSList *item = clones_to_unlink; item; item = item->next) {
682 SPUse *use = static_cast<SPUse *>(item->data);
683- std::vector<SPItem*>::iterator items_node = std::find(items.begin(),items.end(), item->data);
684+ std::vector<SPItem *>::iterator items_node = std::find(items.begin(), items.end(), item->data);
685 *items_node = use->unlink();
686 }
687 g_slist_free(clones_to_unlink);
688
689 // do the actual work
690- for (std::vector<SPItem*>::iterator item = items.begin(); item != items.end(); item++) {
691+ for (std::vector<SPItem *>::iterator item = items.begin(); item != items.end(); item++) {
692 SPItem *obj = *item;
693
694 // ungroup only the groups marked earlier
695 if (g_slist_find(groups, *item) != NULL) {
696- std::vector<SPItem*> children;
697+ std::vector<SPItem *> children;
698 sp_item_group_ungroup(dynamic_cast<SPGroup *>(obj), children, false);
699 // add the items resulting from ungrouping to the selection
700- new_select.insert(new_select.end(),children.begin(),children.end());
701+ new_select.insert(new_select.end(), children.begin(), children.end());
702 *item = NULL; // zero out the original pointer, which is no longer valid
703 } else {
704 // if not a group, keep in the selection
705@@ -865,24 +837,22 @@
706
707 selection->addList(new_select);
708
709- DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP,
710- _("Ungroup"));
711+ DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP, _("Ungroup"));
712 }
713
714 /** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */
715-std::vector<SPItem*>
716-sp_degroup_list(std::vector<SPItem*> &items)
717+std::vector<SPItem *> sp_degroup_list(std::vector<SPItem *> &items)
718 {
719- std::vector<SPItem*> out;
720+ std::vector<SPItem *> out;
721 bool has_groups = false;
722- for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();item++) {
723+ for (std::vector<SPItem *>::const_iterator item = items.begin(); item != items.end(); item++) {
724 SPGroup *group = dynamic_cast<SPGroup *>(*item);
725 if (!group) {
726 out.push_back(*item);
727 } else {
728 has_groups = true;
729- std::vector<SPItem*> members = sp_item_group_item_list(group);
730- for (std::vector<SPItem*>::const_iterator member=members.begin();member!=members.end();member++) {
731+ std::vector<SPItem *> members = sp_item_group_item_list(group);
732+ for (std::vector<SPItem *>::const_iterator member = members.begin(); member != members.end(); member++) {
733 out.push_back(*member);
734 }
735 members.clear();
736@@ -898,8 +868,7 @@
737
738
739 /** If items in the list have a common parent, return it, otherwise return NULL */
740-static SPGroup *
741-sp_item_list_common_parent_group(std::vector<SPItem*> const items)
742+static SPGroup *sp_item_list_common_parent_group(std::vector<SPItem *> const items)
743 {
744 if (items.empty()) {
745 return NULL;
746@@ -909,8 +878,9 @@
747 if (!dynamic_cast<SPGroup *>(parent)) {
748 return NULL;
749 }
750- for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();item++) {
751- if((*item)==items[0])continue;
752+ for (std::vector<SPItem *>::const_iterator item = items.begin(); item != items.end(); item++) {
753+ if ((*item) == items[0])
754+ continue;
755 if ((*item)->parent != parent) {
756 return NULL;
757 }
758@@ -920,13 +890,12 @@
759 }
760
761 /** Finds out the minimum common bbox of the selected items. */
762-static Geom::OptRect
763-enclose_items(std::vector<SPItem*> const &items)
764+static Geom::OptRect enclose_items(std::vector<SPItem *> const &items)
765 {
766 g_assert(!items.empty());
767
768 Geom::OptRect r;
769- for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) {
770+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
771 r.unionWith((*i)->desktopVisualBounds());
772 }
773 return r;
774@@ -936,7 +905,7 @@
775 static SPObject *prev_sibling(SPObject *child)
776 {
777 SPObject *prev = 0;
778- if ( child && dynamic_cast<SPGroup *>(child->parent) ) {
779+ if (child && dynamic_cast<SPGroup *>(child->parent)) {
780 prev = child->getPrev();
781 }
782 return prev;
783@@ -944,14 +913,12 @@
784
785 bool sp_item_repr_compare_position_bool(SPObject const *first, SPObject const *second)
786 {
787- return sp_repr_compare_position(((SPItem*)first)->getRepr(),
788- ((SPItem*)second)->getRepr())<0;
789+ return sp_repr_compare_position(((SPItem *)first)->getRepr(), ((SPItem *)second)->getRepr()) < 0;
790 }
791
792-void
793-sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop)
794+void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop)
795 {
796- std::vector<SPItem*> items= selection->itemList();
797+ std::vector<SPItem *> items = selection->itemList();
798 if (items.empty()) {
799 selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise."));
800 return;
801@@ -959,22 +926,23 @@
802
803 SPGroup const *group = sp_item_list_common_parent_group(items);
804 if (!group) {
805- selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
806+ selection_display_message(desktop, Inkscape::ERROR_MESSAGE,
807+ _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
808 return;
809 }
810
811 Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr());
812
813 /* Construct reverse-ordered list of selected children. */
814- std::vector<SPItem*> rev(items);
815- sort(rev.begin(),rev.end(),sp_item_repr_compare_position_bool);
816+ std::vector<SPItem *> rev(items);
817+ sort(rev.begin(), rev.end(), sp_item_repr_compare_position_bool);
818
819 // Determine the common bbox of the selected items.
820 Geom::OptRect selected = enclose_items(items);
821
822 // Iterate over all objects in the selection (starting from top).
823 if (selected) {
824- for (std::vector<SPItem*>::const_iterator item=rev.begin();item!=rev.end();item++) {
825+ for (std::vector<SPItem *>::const_iterator item = rev.begin(); item != rev.end(); item++) {
826 SPObject *child = *item;
827 // for each selected object, find the next sibling
828 for (SPObject *newref = child->next; newref; newref = newref->next) {
829@@ -982,9 +950,9 @@
830 SPItem *newItem = dynamic_cast<SPItem *>(newref);
831 if (newItem) {
832 Geom::OptRect newref_bbox = newItem->desktopVisualBounds();
833- if ( newref_bbox && selected->intersects(*newref_bbox) ) {
834+ if (newref_bbox && selected->intersects(*newref_bbox)) {
835 // AND if it's not one of our selected objects,
836- if ( std::find(items.begin(),items.end(),newref)==items.end()) {
837+ if (std::find(items.begin(), items.end(), newref) == items.end()) {
838 // move the selected object after that sibling
839 grepr->changeOrder(child->getRepr(), newref->getRepr());
840 }
841@@ -995,7 +963,7 @@
842 }
843 }
844 DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE,
845- //TRANSLATORS: "Raise" means "to raise an object" in the undo history
846+ // TRANSLATORS: "Raise" means "to raise an object" in the undo history
847 C_("Undo action", "Raise"));
848 }
849
850@@ -1008,29 +976,29 @@
851 return;
852 }
853
854- std::vector<SPItem*> items = selection->itemList();
855+ std::vector<SPItem *> items = selection->itemList();
856
857 SPGroup const *group = sp_item_list_common_parent_group(items);
858 if (!group) {
859- selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
860+ selection_display_message(desktop, Inkscape::ERROR_MESSAGE,
861+ _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
862 return;
863 }
864
865- std::vector<Inkscape::XML::Node*> rl(selection->reprList());
866- sort(rl.begin(),rl.end(),sp_repr_compare_position_bool);
867+ std::vector<Inkscape::XML::Node *> rl(selection->reprList());
868+ sort(rl.begin(), rl.end(), sp_repr_compare_position_bool);
869
870- for (std::vector<Inkscape::XML::Node*>::const_iterator l=rl.begin(); l!=rl.end();l++) {
871- Inkscape::XML::Node *repr =(*l);
872+ for (std::vector<Inkscape::XML::Node *>::const_iterator l = rl.begin(); l != rl.end(); l++) {
873+ Inkscape::XML::Node *repr = (*l);
874 repr->setPosition(-1);
875 }
876
877- DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT,
878- _("Raise to top"));
879+ DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, _("Raise to top"));
880 }
881
882 void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop)
883 {
884- std::vector<SPItem*> items = selection->itemList();
885+ std::vector<SPItem *> items = selection->itemList();
886 if (items.empty()) {
887 selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower."));
888 return;
889@@ -1038,7 +1006,8 @@
890
891 SPGroup const *group = sp_item_list_common_parent_group(items);
892 if (!group) {
893- selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
894+ selection_display_message(desktop, Inkscape::ERROR_MESSAGE,
895+ _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
896 return;
897 }
898
899@@ -1048,12 +1017,12 @@
900 Geom::OptRect selected = enclose_items(items);
901
902 /* Construct direct-ordered list of selected children. */
903- std::vector<SPItem*> rev(items);
904- sort(rev.begin(),rev.end(),sp_item_repr_compare_position_bool);
905+ std::vector<SPItem *> rev(items);
906+ sort(rev.begin(), rev.end(), sp_item_repr_compare_position_bool);
907
908 // Iterate over all objects in the selection (starting from top).
909 if (selected) {
910- for (std::vector<SPItem*>::const_reverse_iterator item=rev.rbegin();item!=rev.rend();item++) {
911+ for (std::vector<SPItem *>::const_reverse_iterator item = rev.rbegin(); item != rev.rend(); item++) {
912 SPObject *child = *item;
913 // for each selected object, find the prev sibling
914 for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) {
915@@ -1061,9 +1030,9 @@
916 SPItem *newItem = dynamic_cast<SPItem *>(newref);
917 if (newItem) {
918 Geom::OptRect ref_bbox = newItem->desktopVisualBounds();
919- if ( ref_bbox && selected->intersects(*ref_bbox) ) {
920+ if (ref_bbox && selected->intersects(*ref_bbox)) {
921 // AND if it's not one of our selected objects,
922- if (items.end()==std::find(items.begin(),items.end(),newref)) {
923+ if (items.end() == std::find(items.begin(), items.end(), newref)) {
924 // move the selected object before that sibling
925 SPObject *put_after = prev_sibling(newref);
926 if (put_after)
927@@ -1079,7 +1048,7 @@
928 }
929
930 DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER,
931- //TRANSLATORS: "Lower" means "to lower an object" in the undo history
932+ // TRANSLATORS: "Lower" means "to lower an object" in the undo history
933 C_("Undo action", "Lower"));
934 }
935
936@@ -1092,18 +1061,19 @@
937 return;
938 }
939
940- std::vector<SPItem*> items =selection->itemList();
941+ std::vector<SPItem *> items = selection->itemList();
942
943 SPGroup const *group = sp_item_list_common_parent_group(items);
944 if (!group) {
945- selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
946+ selection_display_message(desktop, Inkscape::ERROR_MESSAGE,
947+ _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
948 return;
949 }
950
951- std::vector<Inkscape::XML::Node*> rl(selection->reprList());
952- sort(rl.begin(),rl.end(),sp_repr_compare_position_bool);
953+ std::vector<Inkscape::XML::Node *> rl(selection->reprList());
954+ sort(rl.begin(), rl.end(), sp_repr_compare_position_bool);
955
956- for (std::vector<Inkscape::XML::Node*>::const_reverse_iterator l=rl.rbegin();l!=rl.rend();l++) {
957+ for (std::vector<Inkscape::XML::Node *>::const_reverse_iterator l = rl.rbegin(); l != rl.rend(); l++) {
958 gint minpos;
959 SPObject *pp, *pc;
960 Inkscape::XML::Node *repr = (*l);
961@@ -1118,26 +1088,25 @@
962 repr->setPosition(minpos);
963 }
964
965- DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK,
966- _("Lower to bottom"));
967+ DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, _("Lower to bottom"));
968 }
969
970-void
971-sp_undo(SPDesktop *desktop, SPDocument *)
972+void sp_undo(SPDesktop *desktop, SPDocument *)
973 {
974 // No re/undo while dragging, too dangerous.
975- if(desktop->getCanvas()->is_dragging) return;
976+ if (desktop->getCanvas()->is_dragging)
977+ return;
978
979 if (!DocumentUndo::undo(desktop->getDocument())) {
980 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to undo."));
981 }
982 }
983
984-void
985-sp_redo(SPDesktop *desktop, SPDocument *)
986+void sp_redo(SPDesktop *desktop, SPDocument *)
987 {
988 // No re/undo while dragging, too dangerous.
989- if(desktop->getCanvas()->is_dragging) return;
990+ if (desktop->getCanvas()->is_dragging)
991+ return;
992
993 if (!DocumentUndo::redo(desktop->getDocument())) {
994 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to redo."));
995@@ -1153,8 +1122,7 @@
996 /**
997 * \pre item != NULL
998 */
999-SPCSSAttr *
1000-take_style_from_item(SPObject *object)
1001+SPCSSAttr *take_style_from_item(SPObject *object)
1002 {
1003 // CPPIFY:
1004 // This function should only take SPItems, but currently SPString is not an Item.
1005@@ -1168,8 +1136,9 @@
1006 (dynamic_cast<SPText *>(object) && object->children && object->children->next == NULL)) {
1007 // if this is a text with exactly one tspan child, merge the style of that tspan as well
1008 // If this is a group, merge the style of its topmost (last) child with style
1009- for (SPObject *last_element = object->lastChild(); last_element != NULL; last_element = last_element->getPrev()) {
1010- if ( last_element->style ) {
1011+ for (SPObject *last_element = object->lastChild(); last_element != NULL;
1012+ last_element = last_element->getPrev()) {
1013+ if (last_element->style) {
1014 SPCSSAttr *temp = sp_css_attr_from_object(last_element, SP_STYLE_FLAG_IFSET);
1015 if (temp) {
1016 sp_repr_css_merge(css, temp);
1017@@ -1183,7 +1152,8 @@
1018 // Remove black-listed properties (those that should not be used in a default style)
1019 css = sp_css_attr_unset_blacklist(css);
1020
1021- if (!(dynamic_cast<SPText *>(object) || dynamic_cast<SPTSpan *>(object) || dynamic_cast<SPTRef *>(object) || dynamic_cast<SPString *>(object))) {
1022+ if (!(dynamic_cast<SPText *>(object) || dynamic_cast<SPTSpan *>(object) || dynamic_cast<SPTRef *>(object) ||
1023+ dynamic_cast<SPString *>(object))) {
1024 // do not copy text properties from non-text objects, it's confusing
1025 css = sp_css_attr_unset_text(css);
1026 }
1027@@ -1229,16 +1199,15 @@
1028 {
1029 Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
1030 if (cm->pastePathEffect(desktop)) {
1031- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_LIVEPATHEFFECT,
1032- _("Paste live path effect"));
1033+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_LIVEPATHEFFECT, _("Paste live path effect"));
1034 }
1035 }
1036
1037
1038 static void sp_selection_remove_livepatheffect_impl(SPItem *item)
1039 {
1040- if ( SPLPEItem *lpeitem = dynamic_cast<SPLPEItem*>(item) ) {
1041- if ( lpeitem->hasPathEffect() ) {
1042+ if (SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item)) {
1043+ if (lpeitem->hasPathEffect()) {
1044 lpeitem->removeAllPathEffects(false);
1045 }
1046 }
1047@@ -1246,30 +1215,31 @@
1048
1049 void sp_selection_remove_livepatheffect(SPDesktop *desktop)
1050 {
1051- if (desktop == NULL) return;
1052+ if (desktop == NULL)
1053+ return;
1054
1055 Inkscape::Selection *selection = desktop->getSelection();
1056
1057 // check if something is selected
1058 if (selection->isEmpty()) {
1059- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from."));
1060+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE,
1061+ _("Select <b>object(s)</b> to remove live path effects from."));
1062 return;
1063 }
1064- std::vector<SPItem*> list=selection->itemList();
1065- for ( std::vector<SPItem*>::const_iterator itemlist=list.begin();itemlist!=list.end();itemlist++) {
1066+ std::vector<SPItem *> list = selection->itemList();
1067+ for (std::vector<SPItem *>::const_iterator itemlist = list.begin(); itemlist != list.end(); itemlist++) {
1068 SPItem *item = *itemlist;
1069
1070 sp_selection_remove_livepatheffect_impl(item);
1071-
1072 }
1073
1074- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT,
1075- _("Remove live path effect"));
1076+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT, _("Remove live path effect"));
1077 }
1078
1079 void sp_selection_remove_filter(SPDesktop *desktop)
1080 {
1081- if (desktop == NULL) return;
1082+ if (desktop == NULL)
1083+ return;
1084
1085 Inkscape::Selection *selection = desktop->getSelection();
1086
1087@@ -1284,8 +1254,7 @@
1088 sp_desktop_set_style(desktop, css);
1089 sp_repr_css_attr_unref(css);
1090
1091- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_REMOVE_FILTER,
1092- _("Remove filter"));
1093+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_REMOVE_FILTER, _("Remove filter"));
1094 }
1095
1096
1097@@ -1293,8 +1262,7 @@
1098 {
1099 Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
1100 if (cm->pasteSize(desktop, false, apply_x, apply_y)) {
1101- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_SIZE,
1102- _("Paste size"));
1103+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_SIZE, _("Paste size"));
1104 }
1105 }
1106
1107@@ -1302,8 +1270,7 @@
1108 {
1109 Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
1110 if (cm->pasteSize(desktop, true, apply_x, apply_y)) {
1111- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY,
1112- _("Paste size separately"));
1113+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY, _("Paste size separately"));
1114 }
1115 }
1116
1117@@ -1311,16 +1278,15 @@
1118 * Ensures that the clones of objects are not modified when moving objects between layers.
1119 * Calls the same function as ungroup
1120 */
1121-void sp_selection_change_layer_maintain_clones(std::vector<SPItem*> const &items,SPObject *where)
1122+void sp_selection_change_layer_maintain_clones(std::vector<SPItem *> const &items, SPObject *where)
1123 {
1124- for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
1125+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
1126 SPItem *item = *i;
1127 if (item) {
1128 SPItem *oldparent = dynamic_cast<SPItem *>(item->parent);
1129 SPItem *newparent = dynamic_cast<SPItem *>(where);
1130 sp_item_group_ungroup_handle_clones(item,
1131- (oldparent->i2doc_affine())
1132- *((newparent->i2doc_affine()).inverse()));
1133+ (oldparent->i2doc_affine()) * ((newparent->i2doc_affine()).inverse()));
1134 }
1135 }
1136 }
1137@@ -1336,17 +1302,18 @@
1138 return;
1139 }
1140
1141- std::vector<SPItem*> items(selection->itemList());
1142+ std::vector<SPItem *> items(selection->itemList());
1143
1144 bool no_more = false; // Set to true, if no more layers above
1145- SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer());
1146+ SPObject *next = Inkscape::next_layer(dt->currentRoot(), dt->currentLayer());
1147 if (next) {
1148- sp_selection_change_layer_maintain_clones(items,next);
1149- std::vector<Inkscape::XML::Node*> temp_clip;
1150+ sp_selection_change_layer_maintain_clones(items, next);
1151+ std::vector<Inkscape::XML::Node *> temp_clip;
1152 sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc());
1153 sp_selection_delete_impl(items, false, false);
1154- next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
1155- std::vector<Inkscape::XML::Node*> copied;
1156+ next =
1157+ Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
1158+ std::vector<Inkscape::XML::Node *> copied;
1159 if (next) {
1160 copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip);
1161 } else {
1162@@ -1354,10 +1321,10 @@
1163 no_more = true;
1164 }
1165 selection->setReprList(copied);
1166- if (next) dt->setCurrentLayer(next);
1167- if ( !suppressDone ) {
1168- DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT,
1169- _("Raise to next layer"));
1170+ if (next)
1171+ dt->setCurrentLayer(next);
1172+ if (!suppressDone) {
1173+ DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT, _("Raise to next layer"));
1174 }
1175 } else {
1176 no_more = true;
1177@@ -1366,7 +1333,6 @@
1178 if (no_more) {
1179 dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers above."));
1180 }
1181-
1182 }
1183
1184 void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
1185@@ -1379,28 +1345,30 @@
1186 return;
1187 }
1188
1189- const std::vector<SPItem*> items(selection->itemList());
1190+ const std::vector<SPItem *> items(selection->itemList());
1191
1192 bool no_more = false; // Set to true, if no more layers below
1193- SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer());
1194+ SPObject *next = Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer());
1195 if (next) {
1196- sp_selection_change_layer_maintain_clones(items,next);
1197- std::vector<Inkscape::XML::Node*> temp_clip;
1198- sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
1199+ sp_selection_change_layer_maintain_clones(items, next);
1200+ std::vector<Inkscape::XML::Node *> temp_clip;
1201+ sp_selection_copy_impl(items, temp_clip,
1202+ dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
1203 sp_selection_delete_impl(items, false, false);
1204- next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
1205- std::vector<Inkscape::XML::Node*> copied;
1206+ next = Inkscape::previous_layer(dt->currentRoot(),
1207+ dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
1208+ std::vector<Inkscape::XML::Node *> copied;
1209 if (next) {
1210 copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip);
1211 } else {
1212 copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), temp_clip);
1213 no_more = true;
1214 }
1215- selection->setReprList( copied);
1216- if (next) dt->setCurrentLayer(next);
1217- if ( !suppressDone ) {
1218- DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV,
1219- _("Lower to previous layer"));
1220+ selection->setReprList(copied);
1221+ if (next)
1222+ dt->setCurrentLayer(next);
1223+ if (!suppressDone) {
1224+ DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV, _("Lower to previous layer"));
1225 }
1226 } else {
1227 no_more = true;
1228@@ -1421,34 +1389,34 @@
1229 return;
1230 }
1231
1232- std::vector<SPItem*> items(selection->itemList());
1233+ std::vector<SPItem *> items(selection->itemList());
1234
1235 if (moveto) {
1236- sp_selection_change_layer_maintain_clones(items,moveto);
1237- std::vector<Inkscape::XML::Node*> temp_clip;
1238- sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
1239+ sp_selection_change_layer_maintain_clones(items, moveto);
1240+ std::vector<Inkscape::XML::Node *> temp_clip;
1241+ sp_selection_copy_impl(items, temp_clip,
1242+ dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
1243 sp_selection_delete_impl(items, false, false);
1244- std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip);
1245+ std::vector<Inkscape::XML::Node *> copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip);
1246 selection->setReprList(copied);
1247- if (!temp_clip.empty()) temp_clip.clear();
1248- if (moveto) dt->setCurrentLayer(moveto);
1249- if ( !suppressDone ) {
1250- DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO,
1251- _("Move selection to layer"));
1252+ if (!temp_clip.empty())
1253+ temp_clip.clear();
1254+ if (moveto)
1255+ dt->setCurrentLayer(moveto);
1256+ if (!suppressDone) {
1257+ DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO, _("Move selection to layer"));
1258 }
1259 }
1260 }
1261
1262-static bool
1263-selection_contains_original(SPItem *item, Inkscape::Selection *selection)
1264+static bool selection_contains_original(SPItem *item, Inkscape::Selection *selection)
1265 {
1266 bool contains_original = false;
1267
1268 SPItem *item_use = item;
1269 SPItem *item_use_first = item;
1270 SPUse *use = dynamic_cast<SPUse *>(item_use);
1271- while (use && item_use && !contains_original)
1272- {
1273+ while (use && item_use && !contains_original) {
1274 item_use = use->get_original();
1275 use = dynamic_cast<SPUse *>(item_use);
1276 contains_original |= selection->includes(item_use);
1277@@ -1467,12 +1435,11 @@
1278 }
1279
1280
1281-static bool
1282-selection_contains_both_clone_and_original(Inkscape::Selection *selection)
1283+static bool selection_contains_both_clone_and_original(Inkscape::Selection *selection)
1284 {
1285 bool clone_with_original = false;
1286- std::vector<SPItem*> items = selection->itemList();
1287- for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) {
1288+ std::vector<SPItem *> items = selection->itemList();
1289+ for (std::vector<SPItem *>::const_iterator l = items.begin(); l != items.end(); l++) {
1290 SPItem *item = *l;
1291 if (item) {
1292 clone_with_original |= selection_contains_original(item, selection);
1293@@ -1483,13 +1450,149 @@
1294 return clone_with_original;
1295 }
1296
1297+/* This function is called by sp_selection_apply_affine.
1298+It takes all elements in selection, looks for all clones (or linked offsets) that are also in the
1299+selection (either directly selected or in a selected group)
1300+
1301+The matrix magic in it is designed so that any transformation (translation or other) is handled
1302+with any selections in a coherent way.
1303+
1304+Note that if affine is a translation, then SPUse::compensate is involved in a subtle way and we
1305+have to account for it.
1306+
1307+If you want to modify this function, please watch carefully for regressions, and take extra care
1308+to have the right advertised transforms so that clones of clones behave well.
1309+
1310+There are 10 cases to test.
1311+*/
1312+static void prevent_clone_double_transform(Inkscape::Selection *selection, SPItem *parent, Geom::Affine affine,
1313+ bool compensate)
1314+{
1315+ // "clones are unmoved when original is moved" preference
1316+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
1317+ int compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
1318+ bool prefs_unmoved = (compensation == SP_CLONE_COMPENSATION_UNMOVED);
1319+ bool prefs_parallel = (compensation == SP_CLONE_COMPENSATION_PARALLEL);
1320+
1321+ // calculate the matrix we need to apply to the clone to cancel its induced transform from its original
1322+ if (!dynamic_cast<SPItem *>(parent->parent))
1323+ return;
1324+ Geom::Affine parent2dt = dynamic_cast<SPItem *>(parent->parent)->i2dt_affine();
1325+ Geom::Affine t = parent2dt * affine * parent2dt.inverse();
1326+ Geom::Affine t_inv = t.inverse();
1327+
1328+ for (std::list<SPObject *>::const_iterator refd = parent->hrefList.begin(); refd != parent->hrefList.end();
1329+ refd++) {
1330+ SPItem *item = dynamic_cast<SPItem *>(*refd);
1331+ if (!item || item->cloned)
1332+ continue;
1333+ bool transform_offset_with_source = false;
1334+ bool transform_clone_with_original = false;
1335+ bool transform_deep_offset_with_source = false;
1336+ bool transform_deep_clone_with_original = false;
1337+
1338+ SPUse *useitem = dynamic_cast<SPUse *>(item);
1339+ SPOffset *off = dynamic_cast<SPOffset *>(item);
1340+ if (off && off->sourceHref && sp_offset_get_source(off) == parent) {
1341+ // We transform a linked offset and (directly) its original
1342+ transform_offset_with_source = selection->includes(off);
1343+ transform_deep_offset_with_source = selection->includes_deeply(off);
1344+ } else if (useitem && useitem->get_original() == parent) {
1345+ // We are transforming a clone along with its original.
1346+ transform_clone_with_original = selection->includes(useitem);
1347+ transform_deep_clone_with_original = selection->includes_deeply(useitem);
1348+ } else
1349+ continue;
1350+
1351+ // restore item->transform field from the repr, in case it was changed by seltrans
1352+ item->readAttr("transform");
1353+
1354+ if (transform_clone_with_original || transform_offset_with_source) {
1355+ // case 1: the clone and the original are directly selected.
1356+
1357+ Geom::Affine result = t_inv * item->transform * t;
1358+
1359+ if (transform_clone_with_original && (prefs_parallel || prefs_unmoved) && affine.isTranslation()) {
1360+ // 1.1: translation, clone
1361+ // find out the clone move, same as in SPUse::move_compensate
1362+ Geom::Affine parent = useitem->get_parent_transform();
1363+ Geom::Affine clone_move = parent.inverse() * t * parent;
1364+
1365+ if (prefs_parallel) {
1366+ Geom::Affine move = result * clone_move * t_inv;
1367+ item->doWriteTransform(item->getRepr(), move, &move, compensate);
1368+
1369+ } else if (prefs_unmoved) {
1370+ Geom::Affine move = result * clone_move;
1371+ item->doWriteTransform(item->getRepr(), move, &t, compensate);
1372+ }
1373+
1374+ } else if (transform_offset_with_source && (prefs_parallel || prefs_unmoved) && affine.isTranslation()) {
1375+ // 1.2: translation, offset
1376+ Geom::Affine parent = item->transform;
1377+ Geom::Affine offset_move = parent.inverse() * t * parent;
1378+
1379+ if (prefs_parallel) {
1380+ Geom::Affine move = result * offset_move * t_inv;
1381+ item->doWriteTransform(item->getRepr(), move, &move, compensate);
1382+
1383+ } else if (prefs_unmoved) {
1384+ Geom::Affine move = result * offset_move;
1385+ item->doWriteTransform(item->getRepr(), move, &t, compensate);
1386+ }
1387+ } else { // 1.3: affine is no translation, just apply the result
1388+ item->doWriteTransform(item->getRepr(), result, &t, compensate);
1389+ }
1390+ } else if (transform_deep_clone_with_original || transform_deep_offset_with_source) {
1391+ // case 2: The original is selected, and the clone is somewhere in a selected group.
1392+ if (transform_deep_clone_with_original && (prefs_parallel || prefs_unmoved) && affine.isTranslation()) {
1393+ // 2.1: translation, clone
1394+
1395+ Geom::Affine parent = useitem->get_parent_transform();
1396+ Geom::Affine clone_move = parent.inverse() * t * parent;
1397+
1398+ if (prefs_parallel) {
1399+ Geom::Affine move = t_inv * item->transform * t_inv * clone_move;
1400+ item->doWriteTransform(item->getRepr(), move, &move, compensate);
1401+
1402+ } else if (prefs_unmoved) {
1403+ Geom::Affine move = t_inv * item->transform * clone_move;
1404+ Geom::Affine move_a = Geom::Affine::identity();
1405+ item->doWriteTransform(item->getRepr(), move, &move_a, compensate);
1406+ }
1407+ } else if (transform_deep_offset_with_source && (prefs_parallel || prefs_unmoved) &&
1408+ affine.isTranslation()) {
1409+ // 2.2: translation, offset
1410+ Geom::Affine parent = item->transform;
1411+ Geom::Affine offset_move = parent.inverse() * t * parent;
1412+ Geom::Affine result = t_inv * item->transform * t_inv;
1413+
1414+ if (prefs_parallel) {
1415+ Geom::Affine move = result * offset_move;
1416+ item->doWriteTransform(item->getRepr(), move, &move, compensate);
1417+
1418+ } else if (prefs_unmoved) {
1419+ Geom::Affine move = result * t * offset_move;
1420+ Geom::Affine move_a = Geom::Affine::identity();
1421+ item->doWriteTransform(item->getRepr(), move, &move_a, compensate);
1422+ }
1423+ } else { // 2.3: affine is no translation
1424+ Geom::Affine move = parent2dt * affine.inverse() * parent2dt.inverse() * item->transform;
1425+ item->doWriteTransform(item->getRepr(), move, &move, compensate);
1426+ }
1427+ }
1428+ }
1429+}
1430+
1431+
1432 /** Apply matrix to the selection. \a set_i2d is normally true, which means objects are in the
1433 original transform, synced with their reprs, and need to jump to the new transform in one go. A
1434 value of set_i2d==false is only used by seltrans when it's dragging objects live (not outlines); in
1435 that case, items are already in the new position, but the repr is in the old, and this function
1436 then simply updates the repr from item->transform.
1437 */
1438-void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d, bool compensate, bool adjust_transf_center)
1439+void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d,
1440+ bool compensate, bool adjust_transf_center)
1441 {
1442 if (selection->isEmpty())
1443 return;
1444@@ -1500,13 +1603,13 @@
1445 Persp3D *transf_persp;
1446 std::list<Persp3D *> plist = selection->perspList();
1447 for (std::list<Persp3D *>::iterator i = plist.begin(); i != plist.end(); ++i) {
1448- persp = (Persp3D *) (*i);
1449+ persp = (Persp3D *)(*i);
1450
1451- if (!persp3d_has_all_boxes_in_selection (persp, selection)) {
1452+ if (!persp3d_has_all_boxes_in_selection(persp, selection)) {
1453 std::list<SPBox3D *> selboxes = selection->box3DList(persp);
1454
1455 // create a new perspective as a copy of the current one and link the selected boxes to it
1456- transf_persp = persp3d_create_xml_element (persp->document, persp->perspective_impl);
1457+ transf_persp = persp3d_create_xml_element(persp->document, persp->perspective_impl);
1458
1459 for (std::list<SPBox3D *>::iterator b = selboxes.begin(); b != selboxes.end(); ++b)
1460 box3d_switch_perspectives(*b, persp, transf_persp);
1461@@ -1516,38 +1619,49 @@
1462
1463 persp3d_apply_affine_transformation(transf_persp, affine);
1464 }
1465- std::vector<SPItem*> items = selection->itemList();
1466- for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) {
1467+ std::vector<SPItem *> items = selection->itemList();
1468+ for (std::vector<SPItem *>::const_iterator l = items.begin(); l != items.end(); l++) {
1469 SPItem *item = *l;
1470
1471- if( dynamic_cast<SPRoot *>(item) ) {
1472+ if (dynamic_cast<SPRoot *>(item)) {
1473 // An SVG element cannot have a transform. We could change 'x' and 'y' in response
1474 // to a translation... but leave that for another day.
1475- selection->desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot transform an embedded SVG."));
1476+ selection->desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE,
1477+ _("Cannot transform an embedded SVG."));
1478 break;
1479 }
1480
1481- Geom::Point old_center(0,0);
1482+ Geom::Point old_center(0, 0);
1483 if (set_i2d && item->isCenterSet())
1484 old_center = item->getCenter();
1485
1486-#if 0 /* Re-enable this once persistent guides have a graphical indication.
1487+#if 0 /* Re-enable this once persistent guides have a graphical indication. \
1488 At the time of writing, this is the only place to re-enable. */
1489 sp_item_update_cns(*item, selection->desktop());
1490 #endif
1491
1492- // we're moving both a clone and its original or any ancestor in clone chain?
1493- bool transform_clone_with_original = selection_contains_original(item, selection);
1494-
1495- // ...both a text-on-path and its path?
1496- bool transform_textpath_with_path = ((dynamic_cast<SPText *>(item) && item->firstChild() && dynamic_cast<SPTextPath *>(item->firstChild()))
1497- && selection->includes( sp_textpath_get_path_item(dynamic_cast<SPTextPath *>(item->firstChild())) ));
1498-
1499- // ...both a flowtext and its frame?
1500- bool transform_flowtext_with_frame = (dynamic_cast<SPFlowtext *>(item) && selection->includes( dynamic_cast<SPFlowtext *>(item)->get_frame(NULL))); // (only the first frame is checked so far)
1501-
1502- // ...both an offset and its source?
1503- bool transform_offset_with_source = (dynamic_cast<SPOffset *>(item) && dynamic_cast<SPOffset *>(item)->sourceHref) && selection->includes( sp_offset_get_source(dynamic_cast<SPOffset *>(item)) );
1504+ // everyting is taken care of in prevent_clone_double_transform for the two first cases,
1505+ // *after* the transformation is applied to the original.
1506+
1507+ // Tests if we're moving both a clone and its original...
1508+ if (selection_contains_original(item, selection))
1509+ continue;
1510+
1511+ // ...both an offset and its source...
1512+ if ((dynamic_cast<SPOffset *>(item) && dynamic_cast<SPOffset *>(item)->sourceHref) &&
1513+ selection->includes(sp_offset_get_source(dynamic_cast<SPOffset *>(item))))
1514+ continue;
1515+
1516+ // ...both a text-on-path and its path...
1517+ bool transform_textpath_with_path =
1518+ ((dynamic_cast<SPText *>(item) && item->firstChild() && dynamic_cast<SPTextPath *>(item->firstChild())) &&
1519+ selection->includes(sp_textpath_get_path_item(dynamic_cast<SPTextPath *>(item->firstChild()))));
1520+
1521+ // ...both a flowtext and its frame...
1522+ bool transform_flowtext_with_frame = (dynamic_cast<SPFlowtext *>(item) &&
1523+ selection->includes(dynamic_cast<SPFlowtext *>(item)->get_frame(
1524+ NULL))); // (only the first frame is checked so far)
1525+
1526
1527 // If we're moving a connector, we want to detach it
1528 // from shapes that aren't part of the selection, but
1529@@ -1555,7 +1669,7 @@
1530 if (Inkscape::UI::Tools::cc_item_is_connector(item)) {
1531 SPPath *path = dynamic_cast<SPPath *>(item);
1532 if (path) {
1533- SPItem *attItem[2] = {0, 0};
1534+ SPItem *attItem[2] = { 0, 0 };
1535 path->connEndPair.getAttachedItems(attItem);
1536 for (int n = 0; n < 2; ++n) {
1537 if (!selection->includes(attItem[n])) {
1538@@ -1567,12 +1681,6 @@
1539 }
1540 }
1541
1542- // "clones are unmoved when original is moved" preference
1543- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
1544- int compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
1545- bool prefs_unmoved = (compensation == SP_CLONE_COMPENSATION_UNMOVED);
1546- bool prefs_parallel = (compensation == SP_CLONE_COMPENSATION_PARALLEL);
1547-
1548 /* If this is a clone and it's selected along with its original, do not move it;
1549 * it will feel the transform of its original and respond to it itself.
1550 * Without this, a clone is doubly transformed, very unintuitive.
1551@@ -1582,86 +1690,20 @@
1552 * Same for linked offset if we are also moving its source: do not move it. */
1553 if (transform_textpath_with_path) {
1554 // Restore item->transform field from the repr, in case it was changed by seltrans.
1555- item->readAttr( "transform" );
1556+ item->readAttr("transform");
1557 } else if (transform_flowtext_with_frame) {
1558 // apply the inverse of the region's transform to the <use> so that the flow remains
1559 // the same (even though the output itself gets transformed)
1560- for ( SPObject *region = item->firstChild() ; region ; region = region->getNext() ) {
1561+ for (SPObject *region = item->firstChild(); region; region = region->getNext()) {
1562 if (dynamic_cast<SPFlowregion *>(region) || dynamic_cast<SPFlowregionExclude *>(region)) {
1563- for ( SPObject *item = region->firstChild() ; item ; item = item->getNext() ) {
1564+ for (SPObject *item = region->firstChild(); item; item = item->getNext()) {
1565 SPUse *use = dynamic_cast<SPUse *>(item);
1566- if ( use ) {
1567+ if (use) {
1568 use->doWriteTransform(use->getRepr(), use->transform.inverse(), NULL, compensate);
1569 }
1570 }
1571 }
1572 }
1573- } else if (transform_clone_with_original || transform_offset_with_source) {
1574- // We are transforming a clone along with its original. The below matrix juggling is
1575- // necessary to ensure that they transform as a whole, i.e. the clone's induced
1576- // transform and its move compensation are both cancelled out.
1577-
1578- // restore item->transform field from the repr, in case it was changed by seltrans
1579- item->readAttr( "transform" );
1580-
1581- // calculate the matrix we need to apply to the clone to cancel its induced transform from its original
1582- Geom::Affine parent2dt;
1583- {
1584- SPItem *parentItem = dynamic_cast<SPItem *>(item->parent);
1585- if (parentItem) {
1586- parent2dt = parentItem->i2dt_affine();
1587- } else {
1588- g_assert_not_reached();
1589- }
1590- }
1591- Geom::Affine t = parent2dt * affine * parent2dt.inverse();
1592- Geom::Affine t_inv = t.inverse();
1593- Geom::Affine result = t_inv * item->transform * t;
1594-
1595- if (transform_clone_with_original && (prefs_parallel || prefs_unmoved) && affine.isTranslation()) {
1596- // we need to cancel out the move compensation, too
1597-
1598- // find out the clone move, same as in sp_use_move_compensate
1599- Geom::Affine parent;
1600- {
1601- SPUse *use = dynamic_cast<SPUse *>(item);
1602- if (use) {
1603- parent = use->get_parent_transform();
1604- } else {
1605- g_assert_not_reached();
1606- }
1607- }
1608- Geom::Affine clone_move = parent.inverse() * t * parent;
1609-
1610- if (prefs_parallel) {
1611- Geom::Affine move = result * clone_move * t_inv;
1612- item->doWriteTransform(item->getRepr(), move, &move, compensate);
1613-
1614- } else if (prefs_unmoved) {
1615- //if (dynamic_cast<SPUse *>(sp_use_get_original(dynamic_cast<SPUse *>(item))))
1616- // clone_move = Geom::identity();
1617- Geom::Affine move = result * clone_move;
1618- item->doWriteTransform(item->getRepr(), move, &t, compensate);
1619- }
1620-
1621- } else if (transform_offset_with_source && (prefs_parallel || prefs_unmoved) && affine.isTranslation()){
1622- Geom::Affine parent = item->transform;
1623- Geom::Affine offset_move = parent.inverse() * t * parent;
1624-
1625- if (prefs_parallel) {
1626- Geom::Affine move = result * offset_move * t_inv;
1627- item->doWriteTransform(item->getRepr(), move, &move, compensate);
1628-
1629- } else if (prefs_unmoved) {
1630- Geom::Affine move = result * offset_move;
1631- item->doWriteTransform(item->getRepr(), move, &t, compensate);
1632- }
1633-
1634- } else {
1635- // just apply the result
1636- item->doWriteTransform(item->getRepr(), result, &t, compensate);
1637- }
1638-
1639 } else {
1640 if (set_i2d) {
1641 item->set_i2d_affine(item->i2dt_affine() * (Geom::Affine)affine);
1642@@ -1669,7 +1711,11 @@
1643 item->doWriteTransform(item->getRepr(), item->transform, NULL, compensate);
1644 }
1645
1646- if (adjust_transf_center) { // The transformation center should not be touched in case of pasting or importing, which is allowed by this if clause
1647+ // taking care of clones and linked offsets
1648+ prevent_clone_double_transform(selection, item, affine, compensate);
1649+
1650+ if (adjust_transf_center) { // The transformation center should not be touched in case of pasting or importing,
1651+ // which is allowed by this if clause
1652 // if we're moving the actual object, not just updating the repr, we can transform the
1653 // center by the same matrix (only necessary for non-translations)
1654 if (set_i2d && item->isCenterSet() && !(affine.isTranslation() || affine.isIdentity())) {
1655@@ -1687,35 +1733,31 @@
1656
1657 Inkscape::Selection *selection = desktop->getSelection();
1658
1659- std::vector<Inkscape::XML::Node*> items = selection->reprList();
1660- for (std::vector<Inkscape::XML::Node*>::const_iterator l=items.begin();l!=items.end() ;l++) {
1661+ std::vector<Inkscape::XML::Node *> items = selection->reprList();
1662+ for (std::vector<Inkscape::XML::Node *>::const_iterator l = items.begin(); l != items.end(); l++) {
1663 (*l)->setAttribute("transform", NULL, false);
1664 }
1665
1666- DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_FLATTEN,
1667- _("Remove transform"));
1668+ DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_FLATTEN, _("Remove transform"));
1669 }
1670
1671-void
1672-sp_selection_scale_absolute(Inkscape::Selection *selection,
1673- double const x0, double const x1,
1674- double const y0, double const y1)
1675+void sp_selection_scale_absolute(Inkscape::Selection *selection, double const x0, double const x1, double const y0,
1676+ double const y1)
1677 {
1678 if (selection->isEmpty())
1679 return;
1680
1681 Geom::OptRect bbox = selection->visualBounds();
1682- if ( !bbox ) {
1683+ if (!bbox) {
1684 return;
1685 }
1686
1687 Geom::Translate const p2o(-bbox->min());
1688
1689- Geom::Scale const newSize(x1 - x0,
1690- y1 - y0);
1691- Geom::Scale const scale( newSize * Geom::Scale(bbox->dimensions()).inverse() );
1692+ Geom::Scale const newSize(x1 - x0, y1 - y0);
1693+ Geom::Scale const scale(newSize * Geom::Scale(bbox->dimensions()).inverse());
1694 Geom::Translate const o2n(x0, y0);
1695- Geom::Affine const final( p2o * scale * o2n );
1696+ Geom::Affine const final(p2o * scale * o2n);
1697
1698 sp_selection_apply_affine(selection, final);
1699 }
1700@@ -1728,42 +1770,38 @@
1701
1702 Geom::OptRect bbox = selection->visualBounds();
1703
1704- if ( !bbox ) {
1705+ if (!bbox) {
1706 return;
1707 }
1708
1709- // FIXME: ARBITRARY LIMIT: don't try to scale above 1 Mpx, it won't display properly and will crash sooner or later anyway
1710- if ( bbox->dimensions()[Geom::X] * scale[Geom::X] > 1e6 ||
1711- bbox->dimensions()[Geom::Y] * scale[Geom::Y] > 1e6 )
1712- {
1713+ // FIXME: ARBITRARY LIMIT: don't try to scale above 1 Mpx, it won't display properly and will crash sooner or later
1714+ // anyway
1715+ if (bbox->dimensions()[Geom::X] * scale[Geom::X] > 1e6 || bbox->dimensions()[Geom::Y] * scale[Geom::Y] > 1e6) {
1716 return;
1717 }
1718
1719 Geom::Translate const n2d(-align);
1720 Geom::Translate const d2n(align);
1721- Geom::Affine const final( n2d * scale * d2n );
1722+ Geom::Affine const final(n2d * scale * d2n);
1723 sp_selection_apply_affine(selection, final);
1724 }
1725
1726-void
1727-sp_selection_rotate_relative(Inkscape::Selection *selection, Geom::Point const &center, gdouble const angle_degrees)
1728+void sp_selection_rotate_relative(Inkscape::Selection *selection, Geom::Point const &center,
1729+ gdouble const angle_degrees)
1730 {
1731 Geom::Translate const d2n(center);
1732 Geom::Translate const n2d(-center);
1733 Geom::Rotate const rotate(Geom::Rotate::from_degrees(angle_degrees));
1734- Geom::Affine const final( Geom::Affine(n2d) * rotate * d2n );
1735+ Geom::Affine const final(Geom::Affine(n2d) * rotate * d2n);
1736 sp_selection_apply_affine(selection, final);
1737 }
1738
1739-void
1740-sp_selection_skew_relative(Inkscape::Selection *selection, Geom::Point const &align, double dx, double dy)
1741+void sp_selection_skew_relative(Inkscape::Selection *selection, Geom::Point const &align, double dx, double dy)
1742 {
1743 Geom::Translate const d2n(align);
1744 Geom::Translate const n2d(-align);
1745- Geom::Affine const skew(1, dy,
1746- dx, 1,
1747- 0, 0);
1748- Geom::Affine const final( n2d * skew * d2n );
1749+ Geom::Affine const skew(1, dy, dx, 1, 0, 0);
1750+ Geom::Affine const final(n2d * skew * d2n);
1751 sp_selection_apply_affine(selection, final);
1752 }
1753
1754@@ -1787,9 +1825,9 @@
1755 if (selection->isEmpty())
1756 return;
1757
1758- std::vector<SPItem*> items = selection->itemList();
1759+ std::vector<SPItem *> items = selection->itemList();
1760 Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw
1761- for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) {
1762+ for (std::vector<SPItem *>::const_iterator l = items.begin(); l != items.end(); l++) {
1763 SPItem *item = *l;
1764 if (item) {
1765 sp_item_rotate_rel(item, rot_90);
1766@@ -1798,13 +1836,11 @@
1767 }
1768 }
1769
1770- DocumentUndo::done(desktop->getDocument(),
1771- ccw ? SP_VERB_OBJECT_ROTATE_90_CCW : SP_VERB_OBJECT_ROTATE_90_CW,
1772+ DocumentUndo::done(desktop->getDocument(), ccw ? SP_VERB_OBJECT_ROTATE_90_CCW : SP_VERB_OBJECT_ROTATE_90_CW,
1773 ccw ? _("Rotate 90\xc2\xb0 CCW") : _("Rotate 90\xc2\xb0 CW"));
1774 }
1775
1776-void
1777-sp_selection_rotate(Inkscape::Selection *selection, gdouble const angle_degrees)
1778+void sp_selection_rotate(Inkscape::Selection *selection, gdouble const angle_degrees)
1779 {
1780 if (selection->isEmpty())
1781 return;
1782@@ -1817,11 +1853,8 @@
1783 sp_selection_rotate_relative(selection, *center, angle_degrees);
1784
1785 DocumentUndo::maybeDone(selection->desktop()->getDocument(),
1786- ( ( angle_degrees > 0 )
1787- ? "selector:rotate:ccw"
1788- : "selector:rotate:cw" ),
1789- SP_VERB_CONTEXT_SELECT,
1790- _("Rotate"));
1791+ ((angle_degrees > 0) ? "selector:rotate:ccw" : "selector:rotate:cw"),
1792+ SP_VERB_CONTEXT_SELECT, _("Rotate"));
1793 }
1794
1795 /*
1796@@ -1846,42 +1879,39 @@
1797 bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
1798 bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
1799 bool ingroups = TRUE;
1800- std::vector<SPItem*> x,y;
1801- std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y);
1802- std::vector<SPItem*> all_matches;
1803+ std::vector<SPItem *> x, y;
1804+ std::vector<SPItem *> all_list =
1805+ get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y);
1806+ std::vector<SPItem *> all_matches;
1807
1808 Inkscape::Selection *selection = desktop->getSelection();
1809- std::vector<SPItem*> items = selection->itemList();
1810+ std::vector<SPItem *> items = selection->itemList();
1811
1812- std::vector<SPItem*> tmp;
1813- for (std::vector<SPItem*>::const_iterator iter=all_list.begin();iter!=all_list.end();iter++) {
1814- if(!SP_IS_GROUP(*iter)){
1815+ std::vector<SPItem *> tmp;
1816+ for (std::vector<SPItem *>::const_iterator iter = all_list.begin(); iter != all_list.end(); iter++) {
1817+ if (!SP_IS_GROUP(*iter)) {
1818 tmp.push_back(*iter);
1819 }
1820 }
1821- all_list=tmp;
1822+ all_list = tmp;
1823
1824- for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) {
1825+ for (std::vector<SPItem *>::const_iterator sel_iter = items.begin(); sel_iter != items.end(); sel_iter++) {
1826 SPItem *sel = *sel_iter;
1827- std::vector<SPItem*> matches = all_list;
1828+ std::vector<SPItem *> matches = all_list;
1829 if (fill && stroke && style) {
1830 matches = sp_get_same_style(sel, matches);
1831- }
1832- else if (fill) {
1833+ } else if (fill) {
1834 matches = sp_get_same_style(sel, matches, SP_FILL_COLOR);
1835- }
1836- else if (stroke) {
1837+ } else if (stroke) {
1838 matches = sp_get_same_style(sel, matches, SP_STROKE_COLOR);
1839- }
1840- else if (style) {
1841- matches = sp_get_same_style(sel, matches,SP_STROKE_STYLE_ALL);
1842- }
1843- all_matches.insert(all_matches.end(), matches.begin(),matches.end());
1844+ } else if (style) {
1845+ matches = sp_get_same_style(sel, matches, SP_STROKE_STYLE_ALL);
1846+ }
1847+ all_matches.insert(all_matches.end(), matches.begin(), matches.end());
1848 }
1849
1850 selection->clear();
1851 selection->setList(all_matches);
1852-
1853 }
1854
1855
1856@@ -1902,14 +1932,15 @@
1857 bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
1858 bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
1859 bool ingroups = TRUE;
1860- std::vector<SPItem*> x,y;
1861- std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y);
1862- std::vector<SPItem*> matches = all_list;
1863+ std::vector<SPItem *> x, y;
1864+ std::vector<SPItem *> all_list =
1865+ get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y);
1866+ std::vector<SPItem *> matches = all_list;
1867
1868 Inkscape::Selection *selection = desktop->getSelection();
1869
1870- std::vector<SPItem*> items=selection->itemList();
1871- for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) {
1872+ std::vector<SPItem *> items = selection->itemList();
1873+ for (std::vector<SPItem *>::const_iterator sel_iter = items.begin(); sel_iter != items.end(); sel_iter++) {
1874 SPItem *sel = *sel_iter;
1875 if (sel) {
1876 matches = sp_get_same_object_type(sel, matches);
1877@@ -1920,7 +1951,6 @@
1878
1879 selection->clear();
1880 selection->setList(matches);
1881-
1882 }
1883
1884
1885@@ -1929,14 +1959,15 @@
1886 * Find all items in src list that have the same fill or stroke style as sel
1887 * Return the list of matching items
1888 */
1889-std::vector<SPItem*> sp_get_same_fill_or_stroke_color(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type)
1890+std::vector<SPItem *> sp_get_same_fill_or_stroke_color(SPItem *sel, std::vector<SPItem *> &src,
1891+ SPSelectStrokeStyleType type)
1892 {
1893- std::vector<SPItem*> matches ;
1894+ std::vector<SPItem *> matches;
1895 gboolean match = false;
1896
1897 SPIPaint *sel_paint = (type == SP_FILL_COLOR) ? &(sel->style->fill) : &(sel->style->stroke);
1898
1899- for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) {
1900+ for (std::vector<SPItem *>::const_reverse_iterator i = src.rbegin(); i != src.rend(); i++) {
1901 SPItem *iter = *i;
1902 if (iter) {
1903 SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke);
1904@@ -1952,10 +1983,11 @@
1905 (type == SP_FILL_COLOR) ? iter->style->getFillPaintServer() : iter->style->getStrokePaintServer();
1906
1907 if ((dynamic_cast<SPLinearGradient *>(sel_server) || dynamic_cast<SPRadialGradient *>(sel_server) ||
1908- (dynamic_cast<SPGradient *>(sel_server) && dynamic_cast<SPGradient *>(sel_server)->getVector()->isSwatch()))
1909- &&
1910+ (dynamic_cast<SPGradient *>(sel_server) &&
1911+ dynamic_cast<SPGradient *>(sel_server)->getVector()->isSwatch())) &&
1912 (dynamic_cast<SPLinearGradient *>(iter_server) || dynamic_cast<SPRadialGradient *>(iter_server) ||
1913- (dynamic_cast<SPGradient *>(iter_server) && dynamic_cast<SPGradient *>(iter_server)->getVector()->isSwatch()))) {
1914+ (dynamic_cast<SPGradient *>(iter_server) &&
1915+ dynamic_cast<SPGradient *>(iter_server)->getVector()->isSwatch()))) {
1916 SPGradient *sel_vector = dynamic_cast<SPGradient *>(sel_server)->getVector();
1917 SPGradient *iter_vector = dynamic_cast<SPGradient *>(iter_server)->getVector();
1918 if (sel_vector == iter_vector) {
1919@@ -1986,16 +2018,16 @@
1920 return matches;
1921 }
1922
1923-static bool item_type_match (SPItem *i, SPItem *j)
1924+static bool item_type_match(SPItem *i, SPItem *j)
1925 {
1926- if ( dynamic_cast<SPRect *>(i)) {
1927- return ( dynamic_cast<SPRect *>(j) );
1928+ if (dynamic_cast<SPRect *>(i)) {
1929+ return (dynamic_cast<SPRect *>(j));
1930
1931 } else if (dynamic_cast<SPGenericEllipse *>(i)) {
1932 return (dynamic_cast<SPGenericEllipse *>(j));
1933
1934 } else if (dynamic_cast<SPStar *>(i) || dynamic_cast<SPPolygon *>(i)) {
1935- return (dynamic_cast<SPStar *>(j) || dynamic_cast<SPPolygon *>(j)) ;
1936+ return (dynamic_cast<SPStar *>(j) || dynamic_cast<SPPolygon *>(j));
1937
1938 } else if (dynamic_cast<SPSpiral *>(i)) {
1939 return (dynamic_cast<SPSpiral *>(j));
1940@@ -2003,21 +2035,22 @@
1941 } else if (dynamic_cast<SPPath *>(i) || dynamic_cast<SPLine *>(i) || dynamic_cast<SPPolyLine *>(i)) {
1942 return (dynamic_cast<SPPath *>(j) || dynamic_cast<SPLine *>(j) || dynamic_cast<SPPolyLine *>(j));
1943
1944- } else if (dynamic_cast<SPText *>(i) || dynamic_cast<SPFlowtext *>(i) || dynamic_cast<SPTSpan *>(i) || dynamic_cast<SPTRef *>(i) || dynamic_cast<SPString *>(i)) {
1945- return (dynamic_cast<SPText *>(j) || dynamic_cast<SPFlowtext *>(j) || dynamic_cast<SPTSpan *>(j) || dynamic_cast<SPTRef *>(j) || dynamic_cast<SPString *>(j));
1946+ } else if (dynamic_cast<SPText *>(i) || dynamic_cast<SPFlowtext *>(i) || dynamic_cast<SPTSpan *>(i) ||
1947+ dynamic_cast<SPTRef *>(i) || dynamic_cast<SPString *>(i)) {
1948+ return (dynamic_cast<SPText *>(j) || dynamic_cast<SPFlowtext *>(j) || dynamic_cast<SPTSpan *>(j) ||
1949+ dynamic_cast<SPTRef *>(j) || dynamic_cast<SPString *>(j));
1950
1951- } else if (dynamic_cast<SPUse *>(i)) {
1952- return (dynamic_cast<SPUse *>(j)) ;
1953+ } else if (dynamic_cast<SPUse *>(i)) {
1954+ return (dynamic_cast<SPUse *>(j));
1955
1956 } else if (dynamic_cast<SPImage *>(i)) {
1957 return (dynamic_cast<SPImage *>(j));
1958
1959- } else if (dynamic_cast<SPOffset *>(i) && dynamic_cast<SPOffset *>(i)->sourceHref) { // Linked offset
1960+ } else if (dynamic_cast<SPOffset *>(i) && dynamic_cast<SPOffset *>(i)->sourceHref) { // Linked offset
1961 return (dynamic_cast<SPOffset *>(j) && dynamic_cast<SPOffset *>(j)->sourceHref);
1962
1963- } else if (dynamic_cast<SPOffset *>(i) && !dynamic_cast<SPOffset *>(i)->sourceHref) { // Dynamic offset
1964+ } else if (dynamic_cast<SPOffset *>(i) && !dynamic_cast<SPOffset *>(i)->sourceHref) { // Dynamic offset
1965 return (dynamic_cast<SPOffset *>(j) && !dynamic_cast<SPOffset *>(j)->sourceHref);
1966-
1967 }
1968
1969 return false;
1970@@ -2027,11 +2060,11 @@
1971 * Find all items in src list that have the same object type as sel by type
1972 * Return the list of matching items
1973 */
1974-std::vector<SPItem*> sp_get_same_object_type(SPItem *sel, std::vector<SPItem*> &src)
1975+std::vector<SPItem *> sp_get_same_object_type(SPItem *sel, std::vector<SPItem *> &src)
1976 {
1977- std::vector<SPItem*> matches;
1978+ std::vector<SPItem *> matches;
1979
1980- for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) {
1981+ for (std::vector<SPItem *>::const_reverse_iterator i = src.rbegin(); i != src.rend(); i++) {
1982 SPItem *item = *i;
1983 if (item && item_type_match(sel, item) && !item->cloned) {
1984 matches.push_back(item);
1985@@ -2046,9 +2079,9 @@
1986 * Find all items in src list that have the same stroke style as sel by type
1987 * Return the list of matching items
1988 */
1989-std::vector<SPItem*> sp_get_same_style(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type)
1990+std::vector<SPItem *> sp_get_same_style(SPItem *sel, std::vector<SPItem *> &src, SPSelectStrokeStyleType type)
1991 {
1992- std::vector<SPItem*> matches;
1993+ std::vector<SPItem *> matches;
1994 bool match = false;
1995
1996 SPStyle *sel_style = sel->style;
1997@@ -2064,28 +2097,28 @@
1998 * Stroke width needs to handle transformations, so call this function
1999 * to get the transformed stroke width
2000 */
2001- std::vector<SPItem*> objects;
2002+ std::vector<SPItem *> objects;
2003 SPStyle *sel_style_for_width = NULL;
2004- if (type == SP_STROKE_STYLE_WIDTH || type == SP_STROKE_STYLE_ALL || type==SP_STYLE_ALL ) {
2005+ if (type == SP_STROKE_STYLE_WIDTH || type == SP_STROKE_STYLE_ALL || type == SP_STYLE_ALL) {
2006 objects.push_back(sel);
2007 sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT);
2008- objects_query_strokewidth (objects, sel_style_for_width);
2009+ objects_query_strokewidth(objects, sel_style_for_width);
2010 }
2011 bool match_g;
2012- for (std::vector<SPItem*>::const_iterator i=src.begin();i!=src.end();i++) {
2013+ for (std::vector<SPItem *>::const_iterator i = src.begin(); i != src.end(); i++) {
2014 SPItem *iter = *i;
2015 if (iter) {
2016- match_g=true;
2017+ match_g = true;
2018 SPStyle *iter_style = iter->style;
2019 match = true;
2020
2021- if (type == SP_STROKE_STYLE_WIDTH|| type == SP_STROKE_STYLE_ALL|| type==SP_STYLE_ALL) {
2022+ if (type == SP_STROKE_STYLE_WIDTH || type == SP_STROKE_STYLE_ALL || type == SP_STYLE_ALL) {
2023 match = (sel_style->stroke_width.set == iter_style->stroke_width.set);
2024 if (sel_style->stroke_width.set && iter_style->stroke_width.set) {
2025- std::vector<SPItem*> objects;
2026- objects.insert(objects.begin(),iter);
2027+ std::vector<SPItem *> objects;
2028+ objects.insert(objects.begin(), iter);
2029 SPStyle tmp_style(SP_ACTIVE_DOCUMENT);
2030- objects_query_strokewidth (objects, &tmp_style);
2031+ objects_query_strokewidth(objects, &tmp_style);
2032
2033 if (sel_style_for_width) {
2034 match = (sel_style_for_width->stroke_width.computed == tmp_style.stroke_width.computed);
2035@@ -2093,16 +2126,16 @@
2036 }
2037 }
2038 match_g = match_g && match;
2039- if (type == SP_STROKE_STYLE_DASHES|| type == SP_STROKE_STYLE_ALL || type==SP_STYLE_ALL) {
2040+ if (type == SP_STROKE_STYLE_DASHES || type == SP_STROKE_STYLE_ALL || type == SP_STYLE_ALL) {
2041 match = (sel_style->stroke_dasharray.set == iter_style->stroke_dasharray.set);
2042 if (sel_style->stroke_dasharray.set && iter_style->stroke_dasharray.set) {
2043 match = (sel_style->stroke_dasharray.values == iter_style->stroke_dasharray.values);
2044 }
2045 }
2046 match_g = match_g && match;
2047- if (type == SP_STROKE_STYLE_MARKERS|| type == SP_STROKE_STYLE_ALL|| type==SP_STYLE_ALL) {
2048+ if (type == SP_STROKE_STYLE_MARKERS || type == SP_STROKE_STYLE_ALL || type == SP_STYLE_ALL) {
2049 match = true;
2050- int len = sizeof(sel_style->marker)/sizeof(SPIString);
2051+ int len = sizeof(sel_style->marker) / sizeof(SPIString);
2052 for (int i = 0; i < len; i++) {
2053 match = (sel_style->marker_ptrs[i]->set == iter_style->marker_ptrs[i]->set);
2054 if (sel_style->marker_ptrs[i]->set && iter_style->marker_ptrs[i]->set &&
2055@@ -2112,24 +2145,25 @@
2056 }
2057 }
2058 }
2059- match_g = match_g && match;
2060+ match_g = match_g && match;
2061 if (match_g) {
2062- while (iter->cloned) iter=dynamic_cast<SPItem *>(iter->parent);
2063- matches.insert(matches.begin(),iter);
2064+ while (iter->cloned)
2065+ iter = dynamic_cast<SPItem *>(iter->parent);
2066+ matches.insert(matches.begin(), iter);
2067 }
2068 } else {
2069 g_assert_not_reached();
2070 }
2071 }
2072
2073- if( sel_style_for_width != NULL ) delete sel_style_for_width;
2074+ if (sel_style_for_width != NULL)
2075+ delete sel_style_for_width;
2076 return matches;
2077 }
2078
2079 // helper function:
2080-static
2081-Geom::Point
2082-cornerFarthestFrom(Geom::Rect const &r, Geom::Point const &p){
2083+static Geom::Point cornerFarthestFrom(Geom::Rect const &r, Geom::Point const &p)
2084+{
2085 Geom::Point m = r.midpoint();
2086 unsigned i = 0;
2087 if (p[X] < m[X]) {
2088@@ -2142,10 +2176,10 @@
2089 }
2090
2091 /**
2092-\param angle the angle in "angular pixels", i.e. how many visible pixels must move the outermost point of the rotated object
2093+\param angle the angle in "angular pixels", i.e. how many visible pixels must move the outermost point of the rotated
2094+object
2095 */
2096-void
2097-sp_selection_rotate_screen(Inkscape::Selection *selection, gdouble angle)
2098+void sp_selection_rotate_screen(Inkscape::Selection *selection, gdouble angle)
2099 {
2100 if (selection->isEmpty())
2101 return;
2102@@ -2153,7 +2187,7 @@
2103 Geom::OptRect bbox = selection->visualBounds();
2104 boost::optional<Geom::Point> center = selection->center();
2105
2106- if ( !bbox || !center ) {
2107+ if (!bbox || !center) {
2108 return;
2109 }
2110
2111@@ -2166,15 +2200,11 @@
2112 sp_selection_rotate_relative(selection, *center, zangle);
2113
2114 DocumentUndo::maybeDone(selection->desktop()->getDocument(),
2115- ( (angle > 0)
2116- ? "selector:rotate:ccw"
2117- : "selector:rotate:cw" ),
2118- SP_VERB_CONTEXT_SELECT,
2119+ ((angle > 0) ? "selector:rotate:ccw" : "selector:rotate:cw"), SP_VERB_CONTEXT_SELECT,
2120 _("Rotate by pixels"));
2121 }
2122
2123-void
2124-sp_selection_scale(Inkscape::Selection *selection, gdouble grow)
2125+void sp_selection_scale(Inkscape::Selection *selection, gdouble grow)
2126 {
2127 if (selection->isEmpty())
2128 return;
2129@@ -2188,7 +2218,7 @@
2130
2131 // you can't scale "do nizhe pola" (below zero)
2132 double const max_len = bbox->maxExtent();
2133- if ( max_len + grow <= 1e-3 ) {
2134+ if (max_len + grow <= 1e-3) {
2135 return;
2136 }
2137
2138@@ -2196,22 +2226,16 @@
2139 sp_selection_scale_relative(selection, center, Geom::Scale(times, times));
2140
2141 DocumentUndo::maybeDone(selection->desktop()->getDocument(),
2142- ( (grow > 0)
2143- ? "selector:scale:larger"
2144- : "selector:scale:smaller" ),
2145- SP_VERB_CONTEXT_SELECT,
2146+ ((grow > 0) ? "selector:scale:larger" : "selector:scale:smaller"), SP_VERB_CONTEXT_SELECT,
2147 _("Scale"));
2148 }
2149
2150-void
2151-sp_selection_scale_screen(Inkscape::Selection *selection, gdouble grow_pixels)
2152+void sp_selection_scale_screen(Inkscape::Selection *selection, gdouble grow_pixels)
2153 {
2154- sp_selection_scale(selection,
2155- grow_pixels / selection->desktop()->current_zoom());
2156+ sp_selection_scale(selection, grow_pixels / selection->desktop()->current_zoom());
2157 }
2158
2159-void
2160-sp_selection_scale_times(Inkscape::Selection *selection, gdouble times)
2161+void sp_selection_scale_times(Inkscape::Selection *selection, gdouble times)
2162 {
2163 if (selection->isEmpty())
2164 return;
2165@@ -2224,12 +2248,10 @@
2166
2167 Geom::Point const center(sel_bbox->midpoint());
2168 sp_selection_scale_relative(selection, center, Geom::Scale(times, times));
2169- DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_CONTEXT_SELECT,
2170- _("Scale by whole factor"));
2171+ DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_CONTEXT_SELECT, _("Scale by whole factor"));
2172 }
2173
2174-void
2175-sp_selection_move(Inkscape::Selection *selection, gdouble dx, gdouble dy)
2176+void sp_selection_move(Inkscape::Selection *selection, gdouble dx, gdouble dy)
2177 {
2178 if (selection->isEmpty()) {
2179 return;
2180@@ -2239,19 +2261,15 @@
2181
2182 SPDocument *doc = selection->layers()->getDocument();
2183 if (dx == 0) {
2184- DocumentUndo::maybeDone(doc, "selector:move:vertical", SP_VERB_CONTEXT_SELECT,
2185- _("Move vertically"));
2186+ DocumentUndo::maybeDone(doc, "selector:move:vertical", SP_VERB_CONTEXT_SELECT, _("Move vertically"));
2187 } else if (dy == 0) {
2188- DocumentUndo::maybeDone(doc, "selector:move:horizontal", SP_VERB_CONTEXT_SELECT,
2189- _("Move horizontally"));
2190+ DocumentUndo::maybeDone(doc, "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, _("Move horizontally"));
2191 } else {
2192- DocumentUndo::done(doc, SP_VERB_CONTEXT_SELECT,
2193- _("Move"));
2194+ DocumentUndo::done(doc, SP_VERB_CONTEXT_SELECT, _("Move"));
2195 }
2196 }
2197
2198-void
2199-sp_selection_move_screen(Inkscape::Selection *selection, gdouble dx, gdouble dy)
2200+void sp_selection_move_screen(Inkscape::Selection *selection, gdouble dx, gdouble dy)
2201 {
2202 if (selection->isEmpty() || !selection->desktop()) {
2203 return;
2204@@ -2265,14 +2283,12 @@
2205
2206 SPDocument *doc = selection->layers()->getDocument();
2207 if (dx == 0) {
2208- DocumentUndo::maybeDone(doc, "selector:move:vertical", SP_VERB_CONTEXT_SELECT,
2209- _("Move vertically by pixels"));
2210+ DocumentUndo::maybeDone(doc, "selector:move:vertical", SP_VERB_CONTEXT_SELECT, _("Move vertically by pixels"));
2211 } else if (dy == 0) {
2212 DocumentUndo::maybeDone(doc, "selector:move:horizontal", SP_VERB_CONTEXT_SELECT,
2213 _("Move horizontally by pixels"));
2214 } else {
2215- DocumentUndo::done(doc, SP_VERB_CONTEXT_SELECT,
2216- _("Move"));
2217+ DocumentUndo::done(doc, SP_VERB_CONTEXT_SELECT, _("Move"));
2218 }
2219 }
2220
2221@@ -2292,25 +2308,18 @@
2222 typedef struct ListReverse {
2223 typedef GSList *Iterator;
2224
2225- static Iterator children(SPObject *o) {
2226- return make_list(o->firstChild(), NULL);
2227- }
2228- static Iterator siblings_after(SPObject *o) {
2229- return make_list(o->parent->firstChild(), o);
2230- }
2231- static void dispose(Iterator i) {
2232- g_slist_free(i);
2233- }
2234+ static Iterator children(SPObject *o) { return make_list(o->firstChild(), NULL); }
2235+ static Iterator siblings_after(SPObject *o) { return make_list(o->parent->firstChild(), o); }
2236+ static void dispose(Iterator i) { g_slist_free(i); }
2237
2238- static SPObject *object(Iterator i) {
2239- return reinterpret_cast<SPObject *>(i->data);
2240- }
2241+ static SPObject *object(Iterator i) { return reinterpret_cast<SPObject *>(i->data); }
2242 static Iterator next(Iterator i) { return i->next; }
2243
2244-private:
2245- static GSList *make_list(SPObject *object, SPObject *limit) {
2246+ private:
2247+ static GSList *make_list(SPObject *object, SPObject *limit)
2248+ {
2249 GSList *list = NULL;
2250- while ( object != limit ) {
2251+ while (object != limit) {
2252 if (!object) { // TODO check if this happens in practice
2253 g_warning("Unexpected list overrun");
2254 break;
2255@@ -2325,16 +2334,16 @@
2256
2257
2258 template <typename D>
2259-SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root,
2260- bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
2261+SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, bool only_in_viewport,
2262+ PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
2263 {
2264 typename D::Iterator children;
2265 typename D::Iterator iter;
2266
2267- SPItem *found=NULL;
2268+ SPItem *found = NULL;
2269
2270 if (path) {
2271- SPObject *object=reinterpret_cast<SPObject *>(path->data);
2272+ SPObject *object = reinterpret_cast<SPObject *>(path->data);
2273 g_assert(object->parent == root);
2274 if (desktop->isLayer(object)) {
2275 found = next_item<D>(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive);
2276@@ -2344,20 +2353,17 @@
2277 iter = children = D::children(root);
2278 }
2279
2280- while ( iter && !found ) {
2281- SPObject *object=D::object(iter);
2282+ while (iter && !found) {
2283+ SPObject *object = D::object(iter);
2284 if (desktop->isLayer(object)) {
2285 if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers
2286 found = next_item<D>(desktop, NULL, object, only_in_viewport, inlayer, onlyvisible, onlysensitive);
2287 }
2288 } else {
2289 SPItem *item = dynamic_cast<SPItem *>(object);
2290- if ( item &&
2291- ( !only_in_viewport || desktop->isWithinViewport(item) ) &&
2292- ( !onlyvisible || !desktop->itemIsHidden(item)) &&
2293- ( !onlysensitive || !item->isLocked()) &&
2294- !desktop->isLayer(item) )
2295- {
2296+ if (item && (!only_in_viewport || desktop->isWithinViewport(item)) &&
2297+ (!onlyvisible || !desktop->itemIsHidden(item)) && (!onlysensitive || !item->isLocked()) &&
2298+ !desktop->isLayer(item)) {
2299 found = item;
2300 }
2301 }
2302@@ -2371,22 +2377,20 @@
2303
2304
2305 template <typename D>
2306-SPItem *next_item_from_list(SPDesktop *desktop, std::vector<SPItem*> const items,
2307- SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
2308+SPItem *next_item_from_list(SPDesktop *desktop, std::vector<SPItem *> const items, SPObject *root,
2309+ bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
2310 {
2311- SPObject *current=root;
2312- for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) {
2313+ SPObject *current = root;
2314+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
2315 SPItem *item = *i;
2316- if ( root->isAncestorOf(item) &&
2317- ( !only_in_viewport || desktop->isWithinViewport(item) ) )
2318- {
2319+ if (root->isAncestorOf(item) && (!only_in_viewport || desktop->isWithinViewport(item))) {
2320 current = item;
2321 break;
2322 }
2323 }
2324
2325- GSList *path=NULL;
2326- while ( current != root ) {
2327+ GSList *path = NULL;
2328+ while (current != root) {
2329 path = g_slist_prepend(path, current);
2330 current = current->parent;
2331 }
2332@@ -2403,14 +2407,14 @@
2333 return next;
2334 }
2335
2336-void
2337-sp_selection_item_next(SPDesktop *desktop)
2338+void sp_selection_item_next(SPDesktop *desktop)
2339 {
2340 g_return_if_fail(desktop != NULL);
2341 Inkscape::Selection *selection = desktop->getSelection();
2342
2343 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
2344- PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
2345+ PrefsSelectionContext inlayer =
2346+ (PrefsSelectionContext)prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
2347 bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
2348 bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
2349
2350@@ -2421,18 +2425,18 @@
2351 root = desktop->currentRoot();
2352 }
2353
2354- SPItem *item=next_item_from_list<Forward>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
2355+ SPItem *item = next_item_from_list<Forward>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE,
2356+ inlayer, onlyvisible, onlysensitive);
2357
2358 if (item) {
2359 selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer);
2360- if ( SP_CYCLING == SP_CYCLE_FOCUS ) {
2361+ if (SP_CYCLING == SP_CYCLE_FOCUS) {
2362 scroll_to_show_item(desktop, item);
2363 }
2364 }
2365 }
2366
2367-void
2368-sp_selection_item_prev(SPDesktop *desktop)
2369+void sp_selection_item_prev(SPDesktop *desktop)
2370 {
2371 SPDocument *document = desktop->getDocument();
2372 g_return_if_fail(document != NULL);
2373@@ -2440,7 +2444,8 @@
2374 Inkscape::Selection *selection = desktop->getSelection();
2375
2376 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
2377- PrefsSelectionContext inlayer = (PrefsSelectionContext) prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
2378+ PrefsSelectionContext inlayer =
2379+ (PrefsSelectionContext)prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
2380 bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
2381 bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
2382
2383@@ -2451,24 +2456,26 @@
2384 root = desktop->currentRoot();
2385 }
2386
2387- SPItem *item=next_item_from_list<ListReverse>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
2388+ SPItem *item = next_item_from_list<ListReverse>(
2389+ desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
2390
2391 if (item) {
2392 selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer);
2393- if ( SP_CYCLING == SP_CYCLE_FOCUS ) {
2394+ if (SP_CYCLING == SP_CYCLE_FOCUS) {
2395 scroll_to_show_item(desktop, item);
2396 }
2397 }
2398 }
2399
2400-void sp_selection_next_patheffect_param(SPDesktop * dt)
2401+void sp_selection_next_patheffect_param(SPDesktop *dt)
2402 {
2403- if (!dt) return;
2404+ if (!dt)
2405+ return;
2406
2407 Inkscape::Selection *selection = dt->getSelection();
2408- if ( selection && !selection->isEmpty() ) {
2409+ if (selection && !selection->isEmpty()) {
2410 SPItem *item = selection->singleItem();
2411- if ( SPLPEItem *lpeitem = dynamic_cast<SPLPEItem*>(item) ) {
2412+ if (SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item)) {
2413 if (lpeitem->hasPathEffect()) {
2414 lpeitem->editNextParamOncanvas(dt);
2415 } else {
2416@@ -2528,8 +2535,6 @@
2417
2418
2419
2420-
2421-
2422 /**
2423 * If \a item is not entirely visible then adjust visible area to centre on the centre on of
2424 * \a item.
2425@@ -2539,14 +2544,14 @@
2426 Geom::Rect dbox = desktop->get_display_area();
2427 Geom::OptRect sbox = item->desktopVisualBounds();
2428
2429- if ( sbox && dbox.contains(*sbox) == false ) {
2430+ if (sbox && dbox.contains(*sbox) == false) {
2431 Geom::Point const s_dt = sbox->midpoint();
2432 Geom::Point const s_w = desktop->d2w(s_dt);
2433 Geom::Point const d_dt = dbox.midpoint();
2434 Geom::Point const d_w = desktop->d2w(d_dt);
2435- Geom::Point const moved_w( d_w - s_w );
2436- gint const dx = (gint) moved_w[X];
2437- gint const dy = (gint) moved_w[Y];
2438+ Geom::Point const moved_w(d_w - s_w);
2439+ gint const dx = (gint)moved_w[X];
2440+ gint const dy = (gint)moved_w[Y];
2441 desktop->scroll_world(dx, dy);
2442 }
2443 }
2444@@ -2568,17 +2573,17 @@
2445 return;
2446 }
2447
2448- std::vector<Inkscape::XML::Node*> reprs (selection->reprList());
2449+ std::vector<Inkscape::XML::Node *> reprs(selection->reprList());
2450
2451 selection->clear();
2452
2453 // sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need
2454- sort(reprs.begin(),reprs.end(),sp_repr_compare_position_bool);
2455-
2456- std::vector<Inkscape::XML::Node*> newsel;
2457-
2458- for(std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){
2459- Inkscape::XML::Node *sel_repr = *i;
2460+ sort(reprs.begin(), reprs.end(), sp_repr_compare_position_bool);
2461+
2462+ std::vector<Inkscape::XML::Node *> newsel;
2463+
2464+ for (std::vector<Inkscape::XML::Node *>::const_iterator i = reprs.begin(); i != reprs.end(); i++) {
2465+ Inkscape::XML::Node *sel_repr = *i;
2466 Inkscape::XML::Node *parent = sel_repr->parent();
2467
2468 Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");
2469@@ -2598,14 +2603,12 @@
2470 Inkscape::GC::release(clone);
2471 }
2472
2473- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_CLONE,
2474- C_("Action", "Clone"));
2475+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_CLONE, C_("Action", "Clone"));
2476
2477 selection->setReprList(newsel);
2478 }
2479
2480-void
2481-sp_selection_relink(SPDesktop *desktop)
2482+void sp_selection_relink(SPDesktop *desktop)
2483 {
2484 if (!desktop)
2485 return;
2486@@ -2620,15 +2623,16 @@
2487 Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
2488 const gchar *newid = cm->getFirstObjectID();
2489 if (!newid) {
2490- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Copy an <b>object</b> to clipboard to relink clones to."));
2491+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE,
2492+ _("Copy an <b>object</b> to clipboard to relink clones to."));
2493 return;
2494 }
2495 gchar *newref = g_strdup_printf("#%s", newid);
2496
2497 // Get a copy of current selection.
2498 bool relinked = false;
2499- std::vector<SPItem*> items=selection->itemList();
2500- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
2501+ std::vector<SPItem *> items = selection->itemList();
2502+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
2503 SPItem *item = *i;
2504
2505 if (dynamic_cast<SPUse *>(item)) {
2506@@ -2643,14 +2647,12 @@
2507 if (!relinked) {
2508 desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to relink</b> in the selection."));
2509 } else {
2510- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNLINK_CLONE,
2511- _("Relink clone"));
2512+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNLINK_CLONE, _("Relink clone"));
2513 }
2514 }
2515
2516
2517-void
2518-sp_selection_unlink(SPDesktop *desktop)
2519+void sp_selection_unlink(SPDesktop *desktop)
2520 {
2521 if (!desktop)
2522 return;
2523@@ -2663,10 +2665,10 @@
2524 }
2525
2526 // Get a copy of current selection.
2527- std::vector<SPItem*> new_select;
2528+ std::vector<SPItem *> new_select;
2529 bool unlinked = false;
2530- std::vector<SPItem*> items=selection->itemList();
2531- for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){
2532+ std::vector<SPItem *> items = selection->itemList();
2533+ for (std::vector<SPItem *>::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++) {
2534 SPItem *item = *i;
2535
2536 if (dynamic_cast<SPText *>(item)) {
2537@@ -2714,12 +2716,10 @@
2538 desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection."));
2539 }
2540
2541- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNLINK_CLONE,
2542- _("Unlink clone"));
2543+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNLINK_CLONE, _("Unlink clone"));
2544 }
2545
2546-void
2547-sp_select_clone_original(SPDesktop *desktop)
2548+void sp_select_clone_original(SPDesktop *desktop)
2549 {
2550 if (desktop == NULL)
2551 return;
2552@@ -2728,11 +2728,13 @@
2553
2554 SPItem *item = selection->singleItem();
2555
2556- 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.");
2557+ gchar const *error =
2558+ _("Select a <b>clone</b> to go to its original. Select a <b>linked offset</b> to go to its source. Select a "
2559+ "<b>text on path</b> to go to the path. Select a <b>flowed text</b> to go to its frame.");
2560
2561 // Check if other than two objects are selected
2562
2563- std::vector<SPItem*> items=selection->itemList();
2564+ std::vector<SPItem *> items = selection->itemList();
2565 if (items.size() != 1 || !item) {
2566 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error);
2567 return;
2568@@ -2759,10 +2761,12 @@
2569 SPLPEItem *lpeItem = dynamic_cast<SPLPEItem *>(item);
2570 if (lpeItem) {
2571 // check if the applied LPE is Clone original, if so, go to the refered path
2572- Inkscape::LivePathEffect::Effect* lpe = lpeItem->getPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL);
2573+ Inkscape::LivePathEffect::Effect *lpe =
2574+ lpeItem->getPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL);
2575 if (lpe) {
2576 Inkscape::LivePathEffect::Parameter *lpeparam = lpe->getParameter("linkedpath");
2577- if (Inkscape::LivePathEffect::OriginalPathParam *pathparam = dynamic_cast<Inkscape::LivePathEffect::OriginalPathParam *>(lpeparam)) {
2578+ if (Inkscape::LivePathEffect::OriginalPathParam *pathparam =
2579+ dynamic_cast<Inkscape::LivePathEffect::OriginalPathParam *>(lpeparam)) {
2580 original = pathparam->getObject();
2581 }
2582 }
2583@@ -2778,13 +2782,17 @@
2584 }
2585
2586 if (!original) {
2587- desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>Cannot find</b> the object to select (orphaned clone, offset, textpath, flowed text?)"));
2588+ desktop->messageStack()->flash(
2589+ Inkscape::ERROR_MESSAGE,
2590+ _("<b>Cannot find</b> the object to select (orphaned clone, offset, textpath, flowed text?)"));
2591 return;
2592 }
2593
2594 for (SPObject *o = original; o && !dynamic_cast<SPRoot *>(o); o = o->parent) {
2595 if (dynamic_cast<SPDefs *>(o)) {
2596- desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The object you're trying to select is <b>not visible</b> (it is in &lt;defs&gt;)"));
2597+ desktop->messageStack()->flash(
2598+ Inkscape::ERROR_MESSAGE,
2599+ _("The object you're trying to select is <b>not visible</b> (it is in &lt;defs&gt;)"));
2600 return;
2601 }
2602 }
2603@@ -2795,14 +2803,15 @@
2604 if (highlight) {
2605 Geom::OptRect a = item->desktopVisualBounds();
2606 Geom::OptRect b = original->desktopVisualBounds();
2607- if ( a && b ) {
2608+ if (a && b) {
2609 // draw a flashing line between the objects
2610 SPCurve *curve = new SPCurve();
2611 curve->moveto(a->midpoint());
2612 curve->lineto(b->midpoint());
2613
2614- SPCanvasItem * canvasitem = sp_canvas_bpath_new(desktop->getTempGroup(), curve);
2615- sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvasitem), 0x0000ddff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT, 5, 3);
2616+ SPCanvasItem *canvasitem = sp_canvas_bpath_new(desktop->getTempGroup(), curve);
2617+ sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvasitem), 0x0000ddff, 1.0, SP_STROKE_LINEJOIN_MITER,
2618+ SP_STROKE_LINECAP_BUTT, 5, 3);
2619 sp_canvas_item_show(canvasitem);
2620 curve->unref();
2621 desktop->add_temporary_canvasitem(canvasitem, 1000);
2622@@ -2829,9 +2838,9 @@
2623 Inkscape::Selection *selection = desktop->getSelection();
2624
2625 Inkscape::SVGOStringStream os;
2626- SPObject * firstItem = NULL;
2627- std::vector<SPItem*> items=selection->itemList();
2628- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
2629+ SPObject *firstItem = NULL;
2630+ std::vector<SPItem *> items = selection->itemList();
2631+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
2632 if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) {
2633 if (firstItem) {
2634 os << "|";
2635@@ -2850,7 +2859,8 @@
2636 {
2637 lpe_repr->setAttribute("effect", "fill_between_many");
2638 lpe_repr->setAttribute("linkedpaths", os.str());
2639- desktop->doc()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to <defs> and assigns the 'id' attribute
2640+ desktop->doc()->getDefs()->getRepr()->addChild(lpe_repr,
2641+ NULL); // adds to <defs> and assigns the 'id' attribute
2642 }
2643 std::string lpe_id_href = std::string("#") + lpe_repr->attribute("id");
2644 Inkscape::GC::release(lpe_repr);
2645@@ -2899,25 +2909,25 @@
2646 doc->ensureUpToDate();
2647 Geom::OptRect r = selection->visualBounds();
2648 boost::optional<Geom::Point> c = selection->center();
2649- if ( !r || !c ) {
2650+ if (!r || !c) {
2651 return;
2652 }
2653
2654 // FIXME: Inverted Y coodinate
2655- Geom::Point doc_height( 0, doc->getHeight().value("px"));
2656+ Geom::Point doc_height(0, doc->getHeight().value("px"));
2657
2658 // calculate the transform to be applied to objects to move them to 0,0
2659- Geom::Point corner( r->min()[Geom::X], r->max()[Geom::Y] ); // FIXME: Inverted Y coodinate
2660+ Geom::Point corner(r->min()[Geom::X], r->max()[Geom::Y]); // FIXME: Inverted Y coodinate
2661 Geom::Point move_p = doc_height - corner;
2662 move_p[Geom::Y] = -move_p[Geom::Y];
2663 Geom::Affine move = Geom::Affine(Geom::Translate(move_p));
2664
2665- Geom::Point center( *c - corner ); // As defined by rotation center
2666+ Geom::Point center(*c - corner); // As defined by rotation center
2667 center[Geom::Y] = -center[Geom::Y];
2668
2669- std::vector<SPItem*> items(selection->itemList());
2670+ std::vector<SPItem *> items(selection->itemList());
2671
2672- //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed?
2673+ // items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed?
2674
2675 // bottommost object, after sorting
2676 SPObject *parent = items[0]->parent;
2677@@ -2933,8 +2943,8 @@
2678 }
2679
2680 // Create a list of duplicates, to be pasted inside marker element.
2681- std::vector<Inkscape::XML::Node*> repr_copies;
2682- for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){
2683+ std::vector<Inkscape::XML::Node *> repr_copies;
2684+ for (std::vector<SPItem *>::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++) {
2685 Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc);
2686 repr_copies.push_back(dup);
2687 }
2688@@ -2944,7 +2954,7 @@
2689 if (apply) {
2690 // Delete objects so that their clones don't get alerted;
2691 // the objects will be restored inside the marker element.
2692- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
2693+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
2694 SPObject *item = *i;
2695 item->deleteObject(false);
2696 }
2697@@ -2965,15 +2975,15 @@
2698
2699
2700
2701- DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER,
2702- _("Objects to marker"));
2703+ DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER, _("Objects to marker"));
2704 }
2705
2706-static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) {
2707+static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups)
2708+{
2709 SPGroup *group = dynamic_cast<SPGroup *>(item);
2710 if (group && !dynamic_cast<SPBox3D *>(item) && !wholegroups) {
2711- std::vector<SPItem*> items=sp_item_group_item_list(group);
2712- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
2713+ std::vector<SPItem *> items = sp_item_group_item_list(group);
2714+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
2715 sp_selection_to_guides_recursive(*i, wholegroups);
2716 }
2717 } else {
2718@@ -2989,7 +2999,7 @@
2719 SPDocument *doc = desktop->getDocument();
2720 Inkscape::Selection *selection = desktop->getSelection();
2721 // we need to copy the list because it gets reset when objects are deleted
2722- std::vector<SPItem*> items(selection->itemList());
2723+ std::vector<SPItem *> items(selection->itemList());
2724
2725 if (items.empty()) {
2726 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides."));
2727@@ -3004,7 +3014,7 @@
2728 // and its entry in the selection list is invalid (crash).
2729 // Therefore: first convert all, then delete all.
2730
2731- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
2732+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
2733 sp_selection_to_guides_recursive(*i, wholegroups);
2734 }
2735
2736@@ -3018,7 +3028,7 @@
2737
2738 /*
2739 * Convert objects to <symbol>. How that happens depends on what is selected:
2740- *
2741+ *
2742 * 1) A random selection of objects will be embedded into a single <symbol> element.
2743 *
2744 * 2) Except, a single <g> will have its content directly embedded into a <symbol>; the 'id' and
2745@@ -3036,7 +3046,7 @@
2746 * For SVG2, set 'refX' 'refY' to object center (with compensating shift in <use>
2747 * transformation).
2748 */
2749-void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
2750+void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/)
2751 {
2752 if (desktop == NULL) {
2753 return;
2754@@ -3049,13 +3059,13 @@
2755
2756 // Check if something is selected.
2757 if (selection->isEmpty()) {
2758- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>objects</b> to convert to symbol."));
2759- return;
2760+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>objects</b> to convert to symbol."));
2761+ return;
2762 }
2763
2764 doc->ensureUpToDate();
2765
2766- std::vector<SPObject*> items(selection->list());
2767+ std::vector<SPObject *> items(selection->list());
2768
2769 // Keep track of parent, this is where <use> will be inserted.
2770 Inkscape::XML::Node *the_first_repr = items[0]->getRepr();
2771@@ -3065,16 +3075,16 @@
2772 bool single_group = false;
2773 SPGroup *the_group = NULL;
2774 Geom::Affine transform;
2775- if( items.size() == 1 ) {
2776+ if (items.size() == 1) {
2777 SPObject *object = items[0];
2778 the_group = dynamic_cast<SPGroup *>(object);
2779- if ( the_group ) {
2780+ if (the_group) {
2781 single_group = true;
2782
2783- if( !sp_svg_transform_read( object->getAttribute("transform"), &transform ))
2784+ if (!sp_svg_transform_read(object->getAttribute("transform"), &transform))
2785 transform = Geom::identity();
2786
2787- if( transform.isTranslation() ) {
2788+ if (transform.isTranslation()) {
2789
2790 // Create new list from group children.
2791 items = object->childList(false);
2792@@ -3083,7 +3093,8 @@
2793 // without disturbing clones.
2794 // See ActorAlign::on_button_click() in src/ui/dialog/align-and-distribute.cpp
2795 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
2796- int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
2797+ int saved_compensation =
2798+ prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
2799 prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
2800
2801 // Remove transform on group, updating clones.
2802@@ -3101,11 +3112,11 @@
2803 defsrepr->appendChild(symbol_repr);
2804
2805 // For a single group, copy relevant attributes.
2806- if( single_group ) {
2807+ if (single_group) {
2808
2809- symbol_repr->setAttribute("style", the_group->getAttribute("style"));
2810- symbol_repr->setAttribute("class", the_group->getAttribute("class"));
2811- symbol_repr->setAttribute("id", the_group->getAttribute("id") );
2812+ symbol_repr->setAttribute("style", the_group->getAttribute("style"));
2813+ symbol_repr->setAttribute("class", the_group->getAttribute("class"));
2814+ symbol_repr->setAttribute("id", the_group->getAttribute("id"));
2815
2816 // This should eventually be replaced by 'refX' and 'refY' once SVG WG approves it.
2817 // It is done here for round-tripping
2818@@ -3118,30 +3129,29 @@
2819 Glib::ustring id = symbol_repr->attribute("id");
2820 id += "_transform";
2821 the_group->setAttribute("id", id);
2822-
2823 }
2824
2825 // Move selected items to new <symbol>
2826- for (std::vector<SPObject*>::const_iterator i=items.begin();i!=items.end();i++){
2827- Inkscape::XML::Node *repr = (*i)->getRepr();
2828- repr->parent()->removeChild(repr);
2829- symbol_repr->addChild(repr,NULL);
2830+ for (std::vector<SPObject *>::const_iterator i = items.begin(); i != items.end(); i++) {
2831+ Inkscape::XML::Node *repr = (*i)->getRepr();
2832+ repr->parent()->removeChild(repr);
2833+ symbol_repr->addChild(repr, NULL);
2834 }
2835
2836- if( single_group && transform.isTranslation() ) {
2837+ if (single_group && transform.isTranslation()) {
2838 the_group->deleteObject(true);
2839 }
2840
2841 // Create <use> pointing to new symbol (to replace the moved objects).
2842 Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");
2843
2844- clone->setAttribute("xlink:href", Glib::ustring("#")+symbol_repr->attribute("id"), false);
2845+ clone->setAttribute("xlink:href", Glib::ustring("#") + symbol_repr->attribute("id"), false);
2846
2847 the_parent_repr->appendChild(clone);
2848
2849- if( single_group && transform.isTranslation() ) {
2850- if( !transform.isIdentity() )
2851- clone->setAttribute("transform", sp_svg_transform_write( transform ));
2852+ if (single_group && transform.isTranslation()) {
2853+ if (!transform.isIdentity())
2854+ clone->setAttribute("transform", sp_svg_transform_write(transform));
2855 }
2856
2857 // Change selection to new <use> element.
2858@@ -3173,12 +3183,13 @@
2859 return;
2860 }
2861
2862- SPObject* symbol = selection->single();
2863-
2864+ SPObject *symbol = selection->single();
2865+
2866 // Make sure we have only one object in selection.
2867 // Require that we really have a <symbol>.
2868- if( symbol == NULL || !dynamic_cast<SPSymbol *>( symbol )) {
2869- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one <b>symbol</b> in Symbol dialog to convert to group."));
2870+ if (symbol == NULL || !dynamic_cast<SPSymbol *>(symbol)) {
2871+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE,
2872+ _("Select only one <b>symbol</b> in Symbol dialog to convert to group."));
2873 return;
2874 }
2875
2876@@ -3189,36 +3200,33 @@
2877 desktop->currentLayer()->getRepr()->appendChild(group);
2878
2879 // Move all children of symbol to group
2880- std::vector<SPObject*> children = symbol->childList(false);
2881+ std::vector<SPObject *> children = symbol->childList(false);
2882
2883 // Converting a group to a symbol inserts a group for non-translational transform.
2884 // In converting a symbol back to a group we strip out the inserted group (or any other
2885 // group that only adds a transform to the symbol content).
2886- if( children.size() == 1 ) {
2887+ if (children.size() == 1) {
2888 SPObject *object = children[0];
2889- if ( dynamic_cast<SPGroup *>( object ) ) {
2890- if( object->getAttribute("style") == NULL ||
2891- object->getAttribute("class") == NULL ) {
2892+ if (dynamic_cast<SPGroup *>(object)) {
2893+ if (object->getAttribute("style") == NULL || object->getAttribute("class") == NULL) {
2894
2895 group->setAttribute("transform", object->getAttribute("transform"));
2896 children = object->childList(false);
2897 }
2898 }
2899 }
2900-
2901- for (std::vector<SPObject*>::const_reverse_iterator i=children.rbegin();i!=children.rend();i++){
2902+
2903+ for (std::vector<SPObject *>::const_reverse_iterator i = children.rbegin(); i != children.rend(); i++) {
2904 Inkscape::XML::Node *repr = (*i)->getRepr();
2905 repr->parent()->removeChild(repr);
2906- group->addChild(repr,NULL);
2907+ group->addChild(repr, NULL);
2908 }
2909
2910 // Copy relevant attributes
2911 group->setAttribute("style", symbol->getAttribute("style"));
2912 group->setAttribute("class", symbol->getAttribute("class"));
2913- group->setAttribute("inkscape:transform-center-x",
2914- symbol->getAttribute("inkscape:transform-center-x"));
2915- group->setAttribute("inkscape:transform-center-y",
2916- symbol->getAttribute("inkscape:transform-center-y"));
2917+ group->setAttribute("inkscape:transform-center-x", symbol->getAttribute("inkscape:transform-center-x"));
2918+ group->setAttribute("inkscape:transform-center-y", symbol->getAttribute("inkscape:transform-center-y"));
2919
2920
2921 // Need to delete <symbol>; all <use> elements that referenced <symbol> should
2922@@ -3237,8 +3245,7 @@
2923 DocumentUndo::done(doc, SP_VERB_EDIT_UNSYMBOL, _("Group from symbol"));
2924 }
2925
2926-void
2927-sp_selection_tile(SPDesktop *desktop, bool apply)
2928+void sp_selection_tile(SPDesktop *desktop, bool apply)
2929 {
2930 // sp_selection_to_marker has similar code
2931 if (desktop == NULL) {
2932@@ -3258,22 +3265,23 @@
2933
2934 doc->ensureUpToDate();
2935 Geom::OptRect r = selection->visualBounds();
2936- if ( !r ) {
2937+ if (!r) {
2938 return;
2939 }
2940
2941 // calculate the transform to be applied to objects to move them to 0,0
2942- Geom::Point move_p = Geom::Point(0, doc->getHeight().value("px")) - (r->min() + Geom::Point(0, r->dimensions()[Geom::Y]));
2943+ Geom::Point move_p =
2944+ Geom::Point(0, doc->getHeight().value("px")) - (r->min() + Geom::Point(0, r->dimensions()[Geom::Y]));
2945 move_p[Geom::Y] = -move_p[Geom::Y];
2946 Geom::Affine move = Geom::Affine(Geom::Translate(move_p));
2947
2948- std::vector<SPItem*> items (selection->itemList());
2949+ std::vector<SPItem *> items(selection->itemList());
2950
2951- sort(items.begin(),items.end(),sp_object_compare_position_bool);
2952+ sort(items.begin(), items.end(), sp_object_compare_position_bool);
2953
2954 // bottommost object, after sorting
2955 SPObject *parent = items[0]->parent;
2956-
2957+
2958
2959 Geom::Affine parent_transform;
2960 {
2961@@ -3289,8 +3297,8 @@
2962 gint pos = items[0]->getRepr()->position();
2963
2964 // create a list of duplicates
2965- std::vector<Inkscape::XML::Node*> repr_copies;
2966- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
2967+ std::vector<Inkscape::XML::Node *> repr_copies;
2968+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
2969 Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc);
2970 repr_copies.push_back(dup);
2971 }
2972@@ -3299,7 +3307,7 @@
2973
2974 if (apply) {
2975 // delete objects so that their clones don't get alerted; this object will be restored shortly
2976- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
2977+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
2978 SPObject *item = *i;
2979 item->deleteObject(false);
2980 }
2981@@ -3312,11 +3320,11 @@
2982 int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
2983 prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
2984
2985- gchar const *pat_id = SPPattern::produce(repr_copies, bbox, doc,
2986- ( Geom::Affine(Geom::Translate(desktop->dt2doc(Geom::Point(r->min()[Geom::X],
2987- r->max()[Geom::Y]))))
2988- * parent_transform.inverse() ),
2989- parent_transform * move);
2990+ gchar const *pat_id = SPPattern::produce(
2991+ repr_copies, bbox, doc,
2992+ (Geom::Affine(Geom::Translate(desktop->dt2doc(Geom::Point(r->min()[Geom::X], r->max()[Geom::Y])))) *
2993+ parent_transform.inverse()),
2994+ parent_transform * move);
2995
2996 // restore compensation setting
2997 prefs->setInt("/options/clonecompensation/value", saved_compensation);
2998@@ -3347,8 +3355,7 @@
2999 }
3000
3001
3002- DocumentUndo::done(doc, SP_VERB_EDIT_TILE,
3003- _("Objects to pattern"));
3004+ DocumentUndo::done(doc, SP_VERB_EDIT_TILE, _("Objects to pattern"));
3005 }
3006
3007 void sp_selection_untile(SPDesktop *desktop)
3008@@ -3364,16 +3371,17 @@
3009
3010 // check if something is selected
3011 if (selection->isEmpty()) {
3012- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object with pattern fill</b> to extract objects from."));
3013+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE,
3014+ _("Select an <b>object with pattern fill</b> to extract objects from."));
3015 return;
3016 }
3017
3018- std::vector<SPItem*> new_select;
3019+ std::vector<SPItem *> new_select;
3020
3021 bool did = false;
3022
3023- std::vector<SPItem*> items(selection->itemList());
3024- for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){
3025+ std::vector<SPItem *> items(selection->itemList());
3026+ for (std::vector<SPItem *>::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++) {
3027 SPItem *item = *i;
3028
3029 SPStyle *style = item->style;
3030@@ -3395,19 +3403,19 @@
3031 Geom::Affine pat_transform = basePat->getTransform();
3032 pat_transform *= item->transform;
3033
3034- for (SPObject *child = pattern->firstChild() ; child != NULL; child = child->next ) {
3035+ for (SPObject *child = pattern->firstChild(); child != NULL; child = child->next) {
3036 if (dynamic_cast<SPItem *>(child)) {
3037 Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc);
3038 SPItem *i = dynamic_cast<SPItem *>(desktop->currentLayer()->appendChildRepr(copy));
3039
3040- // FIXME: relink clones to the new canvas objects
3041- // use SPObject::setid when mental finishes it to steal ids of
3042+ // FIXME: relink clones to the new canvas objects
3043+ // use SPObject::setid when mental finishes it to steal ids of
3044
3045 // this is needed to make sure the new item has curve (simply requestDisplayUpdate does not work)
3046 doc->ensureUpToDate();
3047
3048 if (i) {
3049- Geom::Affine transform( i->transform * pat_transform );
3050+ Geom::Affine transform(i->transform * pat_transform);
3051 i->doWriteTransform(i->getRepr(), transform);
3052
3053 new_select.push_back(i);
3054@@ -3425,8 +3433,7 @@
3055 if (!did) {
3056 desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No pattern fills</b> in the selection."));
3057 } else {
3058- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNTILE,
3059- _("Pattern to objects"));
3060+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNTILE, _("Pattern to objects"));
3061 selection->setList(new_select);
3062 }
3063 }
3064@@ -3437,22 +3444,22 @@
3065 return;
3066 }
3067
3068- std::vector<Inkscape::XML::Node*> const reprlst = selection->reprList();
3069+ std::vector<Inkscape::XML::Node *> const reprlst = selection->reprList();
3070 bool filename_search = TRUE;
3071 bool xdpi_search = TRUE;
3072 bool ydpi_search = TRUE;
3073
3074- for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();i++){
3075+ for (std::vector<Inkscape::XML::Node *>::const_iterator i = reprlst.begin();
3076+ filename_search && xdpi_search && ydpi_search && i != reprlst.end(); i++) {
3077 gchar const *dpi_string;
3078 Inkscape::XML::Node *repr = *i;
3079
3080 if (filename_search) {
3081- const gchar* tmp = repr->attribute("inkscape:export-filename");
3082- if (tmp){
3083+ const gchar *tmp = repr->attribute("inkscape:export-filename");
3084+ if (tmp) {
3085 filename = tmp;
3086 filename_search = FALSE;
3087- }
3088- else{
3089+ } else {
3090 filename.clear();
3091 }
3092 }
3093@@ -3477,15 +3484,12 @@
3094
3095 void sp_document_get_export_hints(SPDocument *doc, Glib::ustring &filename, float *xdpi, float *ydpi)
3096 {
3097- Inkscape::XML::Node * repr = doc->getReprRoot();
3098+ Inkscape::XML::Node *repr = doc->getReprRoot();
3099
3100- const gchar* tmp = repr->attribute("inkscape:export-filename");
3101- if(tmp)
3102- {
3103+ const gchar *tmp = repr->attribute("inkscape:export-filename");
3104+ if (tmp) {
3105 filename = tmp;
3106- }
3107- else
3108- {
3109+ } else {
3110 filename.clear();
3111 }
3112 gchar const *dpi_string = repr->attribute("inkscape:export-xdpi");
3113@@ -3530,30 +3534,28 @@
3114 }
3115
3116 // List of the items to show; all others will be hidden
3117- std::vector<SPItem*> items(selection->itemList());
3118+ std::vector<SPItem *> items(selection->itemList());
3119
3120 // Sort items so that the topmost comes last
3121- sort(items.begin(),items.end(),sp_item_repr_compare_position_bool);
3122+ sort(items.begin(), items.end(), sp_item_repr_compare_position_bool);
3123
3124 // Generate a random value from the current time (you may create bitmap from the same object(s)
3125 // multiple times, and this is done so that they don't clash)
3126 GTimeVal cu;
3127 g_get_current_time(&cu);
3128- guint current = (int) (cu.tv_sec * 1000000 + cu.tv_usec) % 1024;
3129+ guint current = (int)(cu.tv_sec * 1000000 + cu.tv_usec) % 1024;
3130
3131 // Create the filename.
3132- gchar *const basename = g_strdup_printf("%s-%s-%u.png",
3133- document->getName(),
3134- items[0]->getRepr()->attribute("id"),
3135- current);
3136+ gchar *const basename =
3137+ g_strdup_printf("%s-%s-%u.png", document->getName(), items[0]->getRepr()->attribute("id"), current);
3138 // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters,
3139 // digits, and a few other chars, with "_"
3140 g_strcanon(basename, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.=+~$#@^&!?", '_');
3141
3142 // Build the complete path by adding document base dir, if set, otherwise home dir
3143 gchar *directory = NULL;
3144- if ( document->getURI() ) {
3145- directory = g_path_get_dirname( document->getURI() );
3146+ if (document->getURI()) {
3147+ directory = g_path_get_dirname(document->getURI());
3148 }
3149 if (directory == NULL) {
3150 directory = INKSCAPE.homedir_path(NULL);
3151@@ -3561,7 +3563,7 @@
3152 gchar *filepath = g_build_filename(directory, basename, NULL);
3153 g_free(directory);
3154
3155- //g_print("%s\n", filepath);
3156+ // g_print("%s\n", filepath);
3157
3158 // Remember parent and z-order of the topmost one
3159 gint pos = items.back()->getRepr()->position();
3160@@ -3599,8 +3601,8 @@
3161 }
3162
3163 // The width and height of the bitmap in pixels
3164- unsigned width = (unsigned) floor(bbox->width() * Inkscape::Util::Quantity::convert(res, "px", "in"));
3165- unsigned height =(unsigned) floor(bbox->height() * Inkscape::Util::Quantity::convert(res, "px", "in"));
3166+ unsigned width = (unsigned)floor(bbox->width() * Inkscape::Util::Quantity::convert(res, "px", "in"));
3167+ unsigned height = (unsigned)floor(bbox->height() * Inkscape::Util::Quantity::convert(res, "px", "in"));
3168
3169 // Find out if we have to run an external filter
3170 gchar const *run = NULL;
3171@@ -3642,19 +3644,16 @@
3172 double shift_y = bbox->max()[Geom::Y];
3173 if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) { // for default 96 dpi, snap it to pixel grid
3174 shift_x = round(shift_x);
3175- shift_y = -round(-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone
3176+ shift_y = -round(-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations
3177+ // when the inversion is gone
3178 }
3179- t = Geom::Scale(1, -1) * Geom::Translate(shift_x, shift_y) * eek.inverse(); /// @fixme hardcoded doc2dt transform?
3180+ t = Geom::Scale(1, -1) * Geom::Translate(shift_x, shift_y) * eek.inverse(); /// @fixme hardcoded doc2dt transform?
3181
3182 // TODO: avoid roundtrip via file
3183 // Do the export
3184- sp_export_png_file(document, filepath,
3185- bbox->min()[Geom::X], bbox->min()[Geom::Y],
3186- bbox->max()[Geom::X], bbox->max()[Geom::Y],
3187- width, height, res, res,
3188- (guint32) 0xffffff00,
3189- NULL, NULL,
3190- true, /*bool force_overwrite,*/
3191+ sp_export_png_file(document, filepath, bbox->min()[Geom::X], bbox->min()[Geom::Y], bbox->max()[Geom::X],
3192+ bbox->max()[Geom::Y], width, height, res, res, (guint32)0xffffff00, NULL, NULL,
3193+ true, /*bool force_overwrite,*/
3194 items);
3195
3196 // Run filter, if any
3197@@ -3662,7 +3661,7 @@
3198 g_print("Running external filter: %s\n", run);
3199 int result = system(run);
3200
3201- if(result == -1)
3202+ if (result == -1)
3203 g_warning("Could not run external filter: %s\n", run);
3204 }
3205
3206@@ -3671,7 +3670,7 @@
3207 if (pb) {
3208 // Create the repr for the image
3209 // TODO: avoid unnecessary roundtrip between data URI and decoded pixbuf
3210- Inkscape::XML::Node * repr = xml_doc->createElement("svg:image");
3211+ Inkscape::XML::Node *repr = xml_doc->createElement("svg:image");
3212 sp_embed_image(repr, pb);
3213 if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) { // for default 96 dpi, snap it to pixel grid
3214 sp_repr_set_svg_double(repr, "width", width);
3215@@ -3682,7 +3681,7 @@
3216 }
3217
3218 // Write transform
3219- gchar *c=sp_svg_transform_write(t);
3220+ gchar *c = sp_svg_transform_write(t);
3221 repr->setAttribute("transform", c);
3222 g_free(c);
3223
3224@@ -3701,8 +3700,7 @@
3225 g_object_unref(pb);
3226
3227 // Complete undoable transaction
3228- DocumentUndo::done(document, SP_VERB_SELECTION_CREATE_BITMAP,
3229- _("Create bitmap"));
3230+ DocumentUndo::done(document, SP_VERB_SELECTION_CREATE_BITMAP, _("Create bitmap"));
3231 }
3232
3233 desktop->clearWaitingCursor();
3234@@ -3722,18 +3720,19 @@
3235 if (desktop == NULL) {
3236 return;
3237 }
3238- SPDocument* doc = desktop->getDocument();
3239+ SPDocument *doc = desktop->getDocument();
3240 Inkscape::XML::Document *xml_doc = doc->getReprDoc();
3241
3242 Inkscape::Selection *selection = desktop->getSelection();
3243 if (selection->isEmpty()) {
3244- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from."));
3245+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE,
3246+ _("Select <b>object(s)</b> to create clippath or mask from."));
3247 return;
3248 }
3249-
3250- std::vector<Inkscape::XML::Node*> p(selection->reprList());
3251-
3252- sort(p.begin(),p.end(),sp_repr_compare_position_bool);
3253+
3254+ std::vector<Inkscape::XML::Node *> p(selection->reprList());
3255+
3256+ sort(p.begin(), p.end(), sp_repr_compare_position_bool);
3257
3258 selection->clear();
3259
3260@@ -3742,21 +3741,23 @@
3261
3262 Inkscape::XML::Node *inner = xml_doc->createElement("svg:g");
3263 inner->setAttribute("inkscape:label", "Clip");
3264-
3265- for(std::vector<Inkscape::XML::Node*>::const_iterator i=p.begin();i!=p.end();i++){
3266- Inkscape::XML::Node *current = *i;
3267+
3268+ for (std::vector<Inkscape::XML::Node *>::const_iterator i = p.begin(); i != p.end(); i++) {
3269+ Inkscape::XML::Node *current = *i;
3270
3271 if (current->parent() == topmost_parent) {
3272 Inkscape::XML::Node *spnew = current->duplicate(xml_doc);
3273 sp_repr_unparent(current);
3274 inner->appendChild(spnew);
3275 Inkscape::GC::release(spnew);
3276- topmost --; // only reduce count for those items deleted from topmost_parent
3277- } else { // move it to topmost_parent first
3278- std::vector<Inkscape::XML::Node*> temp_clip;
3279+ topmost--; // only reduce count for those items deleted from topmost_parent
3280+ } else { // move it to topmost_parent first
3281+ std::vector<Inkscape::XML::Node *> temp_clip;
3282
3283- // At this point, current may already have no item, due to its being a clone whose original is already moved away
3284- // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform
3285+ // At this point, current may already have no item, due to its being a clone whose original is already moved
3286+ // away
3287+ // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent
3288+ // transform
3289 gchar const *t_str = current->attribute("transform");
3290 Geom::Affine item_t(Geom::identity());
3291 if (t_str)
3292@@ -3773,7 +3774,8 @@
3293 sp_repr_unparent(current);
3294
3295 // paste into topmost_parent (temporarily)
3296- std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip);
3297+ std::vector<Inkscape::XML::Node *> copied =
3298+ sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip);
3299 if (!copied.empty()) { // if success,
3300 // take pasted object (now in topmost_parent)
3301 Inkscape::XML::Node *in_topmost = copied.back();
3302@@ -3787,12 +3789,12 @@
3303 }
3304 }
3305 }
3306-
3307+
3308 Inkscape::XML::Node *outer = xml_doc->createElement("svg:g");
3309 outer->appendChild(inner);
3310 topmost_parent->appendChild(outer);
3311 outer->setPosition(topmost + 1);
3312-
3313+
3314 Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");
3315 clone->setAttribute("x", "0", false);
3316 clone->setAttribute("y", "0", false);
3317@@ -3802,16 +3804,16 @@
3318 clone->setAttribute("inkscape:transform-center-y", inner->attribute("inkscape:transform-center-y"), false);
3319
3320 const Geom::Affine maskTransform(Geom::Affine::identity());
3321- std::vector<Inkscape::XML::Node*> templist;
3322+ std::vector<Inkscape::XML::Node *> templist;
3323 templist.push_back(clone);
3324 // add the new clone to the top of the original's parent
3325 gchar const *mask_id = SPClipPath::create(templist, doc, &maskTransform);
3326-
3327-
3328+
3329+
3330 outer->setAttribute("clip-path", g_strdup_printf("url(#%s)", mask_id));
3331
3332 Inkscape::GC::release(clone);
3333-
3334+
3335 selection->set(outer);
3336 DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Create Clip Group"));
3337 }
3338@@ -3838,11 +3840,13 @@
3339
3340 // check if something is selected
3341 bool is_empty = selection->isEmpty();
3342- if ( apply_to_layer && is_empty) {
3343- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from."));
3344+ if (apply_to_layer && is_empty) {
3345+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE,
3346+ _("Select <b>object(s)</b> to create clippath or mask from."));
3347 return;
3348- } else if (!apply_to_layer && ( is_empty || selection->itemList().size()==1 )) {
3349- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and <b>object(s)</b> to apply clippath or mask to."));
3350+ } else if (!apply_to_layer && (is_empty || selection->itemList().size() == 1)) {
3351+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE,
3352+ _("Select mask object and <b>object(s)</b> to apply clippath or mask to."));
3353 return;
3354 }
3355
3356@@ -3856,18 +3860,18 @@
3357
3358 doc->ensureUpToDate();
3359
3360- std::vector<SPItem*> items(selection->itemList());
3361+ std::vector<SPItem *> items(selection->itemList());
3362
3363- sort(items.begin(),items.end(),sp_object_compare_position_bool);
3364+ sort(items.begin(), items.end(), sp_object_compare_position_bool);
3365
3366 // See lp bug #542004
3367 selection->clear();
3368
3369 // create a list of duplicates
3370- std::vector<Inkscape::XML::Node*> mask_items;
3371- std::vector<SPItem*> apply_to_items;
3372- std::vector<SPItem*> items_to_delete;
3373- std::vector<SPItem*> items_to_select;
3374+ std::vector<Inkscape::XML::Node *> mask_items;
3375+ std::vector<SPItem *> apply_to_items;
3376+ std::vector<SPItem *> items_to_delete;
3377+ std::vector<SPItem *> items_to_select;
3378
3379 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
3380 bool topmost = prefs->getBool("/options/maskobject/topmost", true);
3381@@ -3879,12 +3883,11 @@
3382 apply_to_items.push_back(SP_ITEM(desktop->currentLayer()));
3383 }
3384
3385- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) {
3386- if((!topmost && !apply_to_layer && *i == items.front())
3387- || (topmost && !apply_to_layer && *i == items.back())
3388- || apply_to_layer){
3389+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
3390+ if ((!topmost && !apply_to_layer && *i == items.front()) ||
3391+ (topmost && !apply_to_layer && *i == items.back()) || apply_to_layer) {
3392
3393- Geom::Affine oldtr=(*i)->transform;
3394+ Geom::Affine oldtr = (*i)->transform;
3395 (*i)->doWriteTransform((*i)->getRepr(), (*i)->i2doc_affine());
3396 Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc);
3397 (*i)->doWriteTransform((*i)->getRepr(), oldtr);
3398@@ -3892,12 +3895,11 @@
3399
3400 if (remove_original) {
3401 items_to_delete.push_back(*i);
3402- }
3403- else {
3404+ } else {
3405 items_to_select.push_back(*i);
3406 }
3407- continue;
3408- }else{
3409+ continue;
3410+ } else {
3411 apply_to_items.push_back(*i);
3412 items_to_select.push_back(*i);
3413 }
3414@@ -3913,9 +3915,9 @@
3415 // make a note we should ungroup this when unsetting mask
3416 group->setAttribute("inkscape:groupmode", "maskhelper");
3417
3418- std::vector<Inkscape::XML::Node*> reprs_to_group;
3419- for (std::vector<SPItem*>::const_iterator i = apply_to_items.begin(); i != apply_to_items.end(); i++) {
3420- reprs_to_group.push_back(static_cast<SPObject*>(*i)->getRepr());
3421+ std::vector<Inkscape::XML::Node *> reprs_to_group;
3422+ for (std::vector<SPItem *>::const_iterator i = apply_to_items.begin(); i != apply_to_items.end(); i++) {
3423+ reprs_to_group.push_back(static_cast<SPObject *>(*i)->getRepr());
3424 }
3425 items_to_select.clear();
3426
3427@@ -3923,9 +3925,9 @@
3428
3429 // apply clip/mask only to newly created group
3430 apply_to_items.clear();
3431- apply_to_items.push_back(dynamic_cast<SPItem*>(doc->getObjectByRepr(group)));
3432+ apply_to_items.push_back(dynamic_cast<SPItem *>(doc->getObjectByRepr(group)));
3433
3434- items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group)));
3435+ items_to_select.push_back((SPItem *)(doc->getObjectByRepr(group)));
3436
3437 Inkscape::GC::release(group);
3438 }
3439@@ -3935,13 +3937,13 @@
3440
3441
3442 gchar const *attributeName = apply_clip_path ? "clip-path" : "mask";
3443- for (std::vector<SPItem*>::const_reverse_iterator i = apply_to_items.rbegin(); i != apply_to_items.rend(); i++) {
3444+ for (std::vector<SPItem *>::const_reverse_iterator i = apply_to_items.rbegin(); i != apply_to_items.rend(); i++) {
3445 SPItem *item = reinterpret_cast<SPItem *>(*i);
3446 // inverted object transform should be applied to a mask object,
3447 // as mask is calculated in user space (after applying transform)
3448- std::vector<Inkscape::XML::Node*> mask_items_dup;
3449- for(std::vector<Inkscape::XML::Node*>::const_iterator it=mask_items.begin();it!=mask_items.end();it++)
3450- mask_items_dup.push_back((*it)->duplicate(xml_doc));
3451+ std::vector<Inkscape::XML::Node *> mask_items_dup;
3452+ for (std::vector<Inkscape::XML::Node *>::const_iterator it = mask_items.begin(); it != mask_items.end(); it++)
3453+ mask_items_dup.push_back((*it)->duplicate(xml_doc));
3454 Inkscape::XML::Node *current = SP_OBJECT(*i)->getRepr();
3455 // Node to apply mask to
3456 Inkscape::XML::Node *apply_mask_to = current;
3457@@ -3962,7 +3964,7 @@
3458 // Apply clip/mask to group instead
3459 apply_mask_to = group;
3460
3461- items_to_select.push_back(item = (SPItem*)(doc->getObjectByRepr(group)));
3462+ items_to_select.push_back(item = (SPItem *)(doc->getObjectByRepr(group)));
3463 Inkscape::GC::release(spnew);
3464 Inkscape::GC::release(group);
3465 }
3466@@ -3977,11 +3979,10 @@
3467 }
3468
3469 apply_mask_to->setAttribute(attributeName, Glib::ustring("url(#") + mask_id + ')');
3470-
3471 }
3472
3473- for (std::vector<SPItem*>::const_iterator i = items_to_delete.begin(); i != items_to_delete.end(); i++) {
3474- SPObject *item = reinterpret_cast<SPObject*>(*i);
3475+ for (std::vector<SPItem *>::const_iterator i = items_to_delete.begin(); i != items_to_delete.end(); i++) {
3476+ SPObject *item = reinterpret_cast<SPObject *>(*i);
3477 item->deleteObject(false);
3478 items_to_select.erase(remove(items_to_select.begin(), items_to_select.end(), item), items_to_select.end());
3479 }
3480@@ -3995,7 +3996,8 @@
3481 }
3482 }
3483
3484-void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
3485+void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path)
3486+{
3487 if (desktop == NULL) {
3488 return;
3489 }
3490@@ -4006,7 +4008,8 @@
3491
3492 // check if something is selected
3493 if (selection->isEmpty()) {
3494- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove clippath or mask from."));
3495+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE,
3496+ _("Select <b>object(s)</b> to remove clippath or mask from."));
3497 return;
3498 }
3499
3500@@ -4016,18 +4019,18 @@
3501 doc->ensureUpToDate();
3502
3503 gchar const *attributeName = apply_clip_path ? "clip-path" : "mask";
3504- std::map<SPObject*,SPItem*> referenced_objects;
3505+ std::map<SPObject *, SPItem *> referenced_objects;
3506
3507- std::vector<SPItem*> items(selection->itemList());
3508+ std::vector<SPItem *> items(selection->itemList());
3509 selection->clear();
3510
3511 GSList *items_to_ungroup = NULL;
3512- std::vector<SPItem*> items_to_select(items);
3513+ std::vector<SPItem *> items_to_select(items);
3514
3515
3516 // SPObject* refers to a group containing the clipped path or mask itself,
3517 // whereas SPItem* refers to the item being clipped or masked
3518- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
3519+ for (std::vector<SPItem *>::const_iterator i = items.begin(); i != items.end(); i++) {
3520 if (remove_original) {
3521 // remember referenced mask/clippath, so orphaned masks can be moved back to document
3522 SPItem *item = *i;
3523@@ -4049,26 +4052,25 @@
3524
3525 SPGroup *group = dynamic_cast<SPGroup *>(*i);
3526 if (ungroup_masked && group) {
3527- // if we had previously enclosed masked object in group,
3528- // add it to list so we can ungroup it later
3529-
3530- // ungroup only groups we created when setting clip/mask
3531- if (group->layerMode() == SPGroup::MASK_HELPER) {
3532- items_to_ungroup = g_slist_prepend(items_to_ungroup, group);
3533- }
3534-
3535+ // if we had previously enclosed masked object in group,
3536+ // add it to list so we can ungroup it later
3537+
3538+ // ungroup only groups we created when setting clip/mask
3539+ if (group->layerMode() == SPGroup::MASK_HELPER) {
3540+ items_to_ungroup = g_slist_prepend(items_to_ungroup, group);
3541+ }
3542 }
3543 }
3544
3545 // restore mask objects into a document
3546- for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) {
3547+ for (std::map<SPObject *, SPItem *>::iterator it = referenced_objects.begin(); it != referenced_objects.end();
3548+ ++it) {
3549 SPObject *obj = (*it).first; // Group containing the clipped paths or masks
3550 GSList *items_to_move = NULL;
3551- for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) {
3552+ for (SPObject *child = obj->firstChild(); child; child = child->getNext()) {
3553 // Collect all clipped paths and masks within a single group
3554 Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc);
3555- if(copy->attribute("inkscape:original-d") && copy->attribute("inkscape:path-effect"))
3556- {
3557+ if (copy->attribute("inkscape:original-d") && copy->attribute("inkscape:path-effect")) {
3558 copy->setAttribute("d", copy->attribute("inkscape:original-d"));
3559 }
3560 items_to_move = g_slist_prepend(items_to_move, copy);
3561@@ -4104,13 +4106,13 @@
3562 }
3563
3564 // ungroup marked groups added when setting mask
3565- for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) {
3566+ for (GSList *i = items_to_ungroup; NULL != i; i = i->next) {
3567 SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(i->data));
3568 if (group) {
3569 items_to_select.erase(remove(items_to_select.begin(), items_to_select.end(), group), items_to_select.end());
3570- std::vector<SPItem*> children;
3571+ std::vector<SPItem *> children;
3572 sp_item_group_ungroup(group, children, false);
3573- items_to_select.insert(items_to_select.end(),children.rbegin(),children.rend());
3574+ items_to_select.insert(items_to_select.end(), children.rbegin(), children.rend());
3575 } else {
3576 g_assert_not_reached();
3577 }
3578@@ -4133,8 +4135,7 @@
3579 * "fit-margin-..." attributes. See SPDocument::fitToRect.
3580 * \return true if an undoable change should be recorded.
3581 */
3582-bool
3583-fit_canvas_to_selection(SPDesktop *desktop, bool with_margins)
3584+bool fit_canvas_to_selection(SPDesktop *desktop, bool with_margins)
3585 {
3586 g_return_val_if_fail(desktop != NULL, false);
3587 SPDocument *doc = desktop->getDocument();
3588@@ -4158,12 +4159,10 @@
3589 /**
3590 * Fit canvas to the bounding box of the selection, as an undoable action.
3591 */
3592-void
3593-verb_fit_canvas_to_selection(SPDesktop *const desktop)
3594+void verb_fit_canvas_to_selection(SPDesktop *const desktop)
3595 {
3596 if (fit_canvas_to_selection(desktop)) {
3597- DocumentUndo::done(desktop->getDocument(), SP_VERB_FIT_CANVAS_TO_SELECTION,
3598- _("Fit Page to Selection"));
3599+ DocumentUndo::done(desktop->getDocument(), SP_VERB_FIT_CANVAS_TO_SELECTION, _("Fit Page to Selection"));
3600 }
3601 }
3602
3603@@ -4171,8 +4170,7 @@
3604 * \param with_margins margins defined in the xml under <sodipodi:namedview>
3605 * "fit-margin-..." attributes. See SPDocument::fitToRect.
3606 */
3607-bool
3608-fit_canvas_to_drawing(SPDocument *doc, bool with_margins)
3609+bool fit_canvas_to_drawing(SPDocument *doc, bool with_margins)
3610 {
3611 g_return_val_if_fail(doc != NULL, false);
3612
3613@@ -4187,12 +4185,10 @@
3614 }
3615 }
3616
3617-void
3618-verb_fit_canvas_to_drawing(SPDesktop *desktop)
3619+void verb_fit_canvas_to_drawing(SPDesktop *desktop)
3620 {
3621 if (fit_canvas_to_drawing(desktop->getDocument())) {
3622- DocumentUndo::done(desktop->getDocument(), SP_VERB_FIT_CANVAS_TO_DRAWING,
3623- _("Fit Page to Drawing"));
3624+ DocumentUndo::done(desktop->getDocument(), SP_VERB_FIT_CANVAS_TO_DRAWING, _("Fit Page to Drawing"));
3625 }
3626 }
3627
3628@@ -4201,23 +4197,24 @@
3629 * "fit-margin-..." attributes. See SPDocument::fitToRect and
3630 * ui/dialog/page-sizer.
3631 */
3632-void fit_canvas_to_selection_or_drawing(SPDesktop *desktop) {
3633+void fit_canvas_to_selection_or_drawing(SPDesktop *desktop)
3634+{
3635 g_return_if_fail(desktop != NULL);
3636 SPDocument *doc = desktop->getDocument();
3637
3638 g_return_if_fail(doc != NULL);
3639 g_return_if_fail(desktop->selection != NULL);
3640
3641- bool const changed = ( desktop->selection->isEmpty()
3642- ? fit_canvas_to_drawing(doc, true)
3643- : fit_canvas_to_selection(desktop, true) );
3644+ bool const changed =
3645+ (desktop->selection->isEmpty() ? fit_canvas_to_drawing(doc, true) : fit_canvas_to_selection(desktop, true));
3646 if (changed) {
3647 DocumentUndo::done(desktop->getDocument(), SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING,
3648 _("Fit Page to Selection or Drawing"));
3649 }
3650 };
3651
3652-static void itemtree_map(void (*f)(SPItem *, SPDesktop *), SPObject *root, SPDesktop *desktop) {
3653+static void itemtree_map(void (*f)(SPItem *, SPDesktop *), SPObject *root, SPDesktop *desktop)
3654+{
3655 // don't operate on layers
3656 {
3657 SPItem *item = dynamic_cast<SPItem *>(root);
3658@@ -4225,8 +4222,8 @@
3659 f(item, desktop);
3660 }
3661 }
3662- for ( SPObject::SiblingIterator iter = root->firstChild() ; iter ; ++iter ) {
3663- //don't recurse into locked layers
3664+ for (SPObject::SiblingIterator iter = root->firstChild(); iter; ++iter) {
3665+ // don't recurse into locked layers
3666 SPItem *item = dynamic_cast<SPItem *>(&*iter);
3667 if (!(item && desktop->isLayer(item) && item->isLocked())) {
3668 itemtree_map(f, iter, desktop);
3669@@ -4234,20 +4231,24 @@
3670 }
3671 }
3672
3673-static void unlock(SPItem *item, SPDesktop */*desktop*/) {
3674+static void unlock(SPItem *item, SPDesktop * /*desktop*/)
3675+{
3676 if (item->isLocked()) {
3677 item->setLocked(FALSE);
3678 }
3679 }
3680
3681-static void unhide(SPItem *item, SPDesktop *desktop) {
3682+static void unhide(SPItem *item, SPDesktop *desktop)
3683+{
3684 if (desktop->itemIsHidden(item)) {
3685 item->setExplicitlyHidden(FALSE);
3686 }
3687 }
3688
3689-static void process_all(void (*f)(SPItem *, SPDesktop *), SPDesktop *dt, bool layer_only) {
3690- if (!dt) return;
3691+static void process_all(void (*f)(SPItem *, SPDesktop *), SPDesktop *dt, bool layer_only)
3692+{
3693+ if (!dt)
3694+ return;
3695
3696 SPObject *root;
3697 if (layer_only) {
3698@@ -4259,21 +4260,13 @@
3699 itemtree_map(f, root, dt);
3700 }
3701
3702-void unlock_all(SPDesktop *dt) {
3703- process_all(&unlock, dt, true);
3704-}
3705-
3706-void unlock_all_in_all_layers(SPDesktop *dt) {
3707- process_all(&unlock, dt, false);
3708-}
3709-
3710-void unhide_all(SPDesktop *dt) {
3711- process_all(&unhide, dt, true);
3712-}
3713-
3714-void unhide_all_in_all_layers(SPDesktop *dt) {
3715- process_all(&unhide, dt, false);
3716-}
3717+void unlock_all(SPDesktop *dt) { process_all(&unlock, dt, true); }
3718+
3719+void unlock_all_in_all_layers(SPDesktop *dt) { process_all(&unlock, dt, false); }
3720+
3721+void unhide_all(SPDesktop *dt) { process_all(&unhide, dt, true); }
3722+
3723+void unhide_all_in_all_layers(SPDesktop *dt) { process_all(&unhide, dt, false); }
3724
3725
3726 /*
3727
3728=== modified file 'src/selection.cpp'
3729--- src/selection.cpp 2015-05-12 22:12:43 +0000
3730+++ src/selection.cpp 2015-09-02 11:21:15 +0000
3731@@ -30,6 +30,7 @@
3732
3733 #include "sp-shape.h"
3734 #include "sp-path.h"
3735+#include "sp-root.h"
3736 #include "sp-item-group.h"
3737 #include "box3d.h"
3738 #include "box3d.h"
3739@@ -151,6 +152,12 @@
3740 return ( _objs_set.find(obj)!=_objs_set.end() );
3741 }
3742
3743+bool Selection::includes_deeply(SPObject *obj) const{
3744+ if(!obj || dynamic_cast<SPRoot*>(obj)){return false;}
3745+ return (includes(obj) || includes_deeply(obj->parent));
3746+}
3747+
3748+
3749 void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) {
3750 g_return_if_fail(obj != NULL);
3751 g_return_if_fail(SP_IS_OBJECT(obj));
3752
3753=== modified file 'src/selection.h'
3754--- src/selection.h 2015-04-29 22:29:17 +0000
3755+++ src/selection.h 2015-09-02 11:21:15 +0000
3756@@ -209,6 +209,16 @@
3757 }
3758
3759 /**
3760+ * Returns true if the given item is descendant of a selected item.
3761+ */
3762+ bool includes_deeply(SPObject *obj) const;
3763+ bool includes_deeply(XML::Node *repr) const {
3764+ return includes_deeply(_objectForXMLNode(repr));
3765+ }
3766+
3767+
3768+
3769+ /**
3770 * Returns a single selected object.
3771 *
3772 * @return NULL unless exactly one object is selected