summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d144437)
raw | patch | inline | side by side (parent: d144437)
author | Johan Engelen <goejendaagh@zonnet.nl> | |
Sun, 14 Mar 2010 17:59:51 +0000 (18:59 +0100) | ||
committer | Johan Engelen <goejendaagh@zonnet.nl> | |
Sun, 14 Mar 2010 17:59:51 +0000 (18:59 +0100) |
src/path-chemistry.cpp | patch | blob | history | |
src/path-chemistry.h | patch | blob | history | |
src/ui/clipboard.cpp | patch | blob | history |
diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index 50d26ba645969035c47cd295c3ce4b8c76259250..c44ab5bc616e3c64e26e2558f27a467b59478bfd 100644 (file)
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
}
}
+/** Converts the selected items to LPEItems if they are not already so; e.g. SPRects) */
+void sp_selected_to_lpeitems(SPDesktop *desktop)
+{
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
+
+ if (selection->isEmpty()) {
+ return;
+ }
+
+ bool did = false;
+
+ GSList *selected = g_slist_copy((GSList *) selection->itemList());
+ GSList *to_select = NULL;
+ selection->clear();
+ GSList *items = g_slist_copy(selected);
+
+ did = sp_item_list_to_curves(items, &selected, &to_select, true);
+
+ g_slist_free (items);
+ selection->setReprList(to_select);
+ selection->addList(selected);
+ g_slist_free (to_select);
+ g_slist_free (selected);
+}
+
bool
-sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select)
+sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems)
{
bool did = false;
@@ -335,6 +360,13 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec
SPItem *item = SP_ITEM(items->data);
SPDocument *document = item->document;
+ if ( skip_all_lpeitems &&
+ SP_IS_LPE_ITEM(item) &&
+ !SP_IS_GROUP(item) ) // also convert objects in an SPGroup when skip_all_lpeitems is set.
+ {
+ continue;
+ }
+
if (SP_IS_PATH(item) && !SP_PATH(item)->original_curve) {
continue; // already a path, and no path effect
}
diff --git a/src/path-chemistry.h b/src/path-chemistry.h
index 14b2b6ffbd9cec0034157b88bc80b3ff5b7e3bd1..64d7f63af9f3399174f2b89212607fb9dfd8f571 100644 (file)
--- a/src/path-chemistry.h
+++ b/src/path-chemistry.h
void sp_selected_path_combine (SPDesktop *desktop);
void sp_selected_path_break_apart (SPDesktop *desktop);
void sp_selected_path_to_curves (SPDesktop *desktop, bool interactive = true);
+void sp_selected_to_lpeitems(SPDesktop *desktop);
Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy);
void sp_selected_path_reverse (SPDesktop *desktop);
-bool sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select);
+bool sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems = false);
#endif
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 99d83573097e294f88b68c4f1a227297b04c93f0..db509da2e2cc9efc85c9bae7c2393f8c97c2ff7a 100644 (file)
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
Inkscape::XML::Node *root = sp_document_repr_root(tempdoc);
Inkscape::XML::Node *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1);
if ( clipnode ) {
- gchar const *effect = clipnode->attribute("inkscape:path-effect");
- if ( effect ) {
+ gchar const *effectstack = clipnode->attribute("inkscape:path-effect");
+ if ( effectstack ) {
_pasteDefs(tempdoc);
// make sure all selected items are converted to paths first (i.e. rectangles)
- sp_selected_path_to_curves(desktop, false);
- for (GSList *item = const_cast<GSList *>(selection->itemList()) ; item ; item = item->next) {
- _applyPathEffect(reinterpret_cast<SPItem*>(item->data), effect);
+ sp_selected_to_lpeitems(desktop);
+ for (GSList *itemptr = const_cast<GSList *>(selection->itemList()) ; itemptr ; itemptr = itemptr->next) {
+ SPItem *item = reinterpret_cast<SPItem*>(itemptr->data);
+ _applyPathEffect(item, effectstack);
}
return true;
/**
* @brief Applies a pasted path effect to a given item
*/
-void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effect)
+void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectstack)
{
if ( item == NULL ) return;
if ( SP_IS_RECT(item) ) return;
@@ -984,11 +985,17 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effect)
if (SP_IS_LPE_ITEM(item))
{
SPLPEItem *lpeitem = SP_LPE_ITEM(item);
- SPObject *obj = sp_uri_reference_resolve(_clipboardSPDoc, effect);
- if (!obj) return;
- // if the effect is not used by anyone, we might as well take it
- LivePathEffectObject *lpeobj = LIVEPATHEFFECT(obj)->fork_private_if_necessary(1);
- sp_lpe_item_add_path_effect(lpeitem, lpeobj);
+ // for each effect in the stack, check if we need to fork it before adding it to the item
+ std::istringstream iss(effectstack);
+ std::string href;
+ while (std::getline(iss, href, ';'))
+ {
+ SPObject *obj = sp_uri_reference_resolve(_clipboardSPDoc, href.c_str());
+ if (!obj) return;
+ // if the effectstack is not used by anyone, we might as well take it
+ LivePathEffectObject *lpeobj = LIVEPATHEFFECT(obj)->fork_private_if_necessary(1);
+ sp_lpe_item_add_path_effect(lpeitem, lpeobj);
+ }
}
}