From 5ab08d9f7d378f9dee682173fe4e4e3154608b9d Mon Sep 17 00:00:00 2001 From: buliabyak Date: Sat, 24 Feb 2007 19:21:04 +0000 Subject: [PATCH] some more refactoring --- src/selection-chemistry.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index cf16aba60..86e6bdc90 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -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; } -- 2.30.2