Code

some more refactoring
authorbuliabyak <buliabyak@users.sourceforge.net>
Sat, 24 Feb 2007 19:21:04 +0000 (19:21 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Sat, 24 Feb 2007 19:21:04 +0000 (19:21 +0000)
src/selection-chemistry.cpp

index cf16aba60a76d84a97e3ce27c648c5b57a8fe1ba..86e6bdc909d5fb0874248da7a84f922004524048 100644 (file)
@@ -1333,23 +1333,32 @@ void sp_selection_to_prev_layer ()
     g_slist_free ((GSList *) items);
 }
 
+bool
+selection_contains_original (SPItem *item, Inkscape::Selection *selection)
+{
+    bool contains_original = false;
+    bool is_use = SP_IS_USE(item);
+    SPItem *item_use = item;
+    SPItem *item_use_first = item;
+    while (is_use && item_use && !contains_original)
+    {
+        item_use = sp_use_get_original (SP_USE(item_use));
+        contains_original |= selection->includes(item_use);
+        if (item_use == item_use_first)
+            break;
+        is_use = SP_IS_USE(item_use);
+    }   
+    return contains_original;
+}
+
+
 bool
 selection_contains_both_clone_and_original (Inkscape::Selection *selection)
 {
     bool clone_with_original = false;
     for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {
         SPItem *item = SP_ITEM(l->data);
-        bool is_use = SP_IS_USE(item);
-        SPItem *item_use = item;
-        SPItem *item_use_first = item;
-        while (is_use && item_use && !clone_with_original)
-        {
-            item_use = sp_use_get_original (SP_USE(item_use));
-            clone_with_original |= selection->includes(item_use);
-            if (item_use == item_use_first)
-                break;
-            is_use = SP_IS_USE(item_use);
-        }   
+        clone_with_original |= selection_contains_original(item, selection);
         if (clone_with_original) 
             break;
     }