summaryrefslogtreecommitdiffstats
path: root/src/ui/clipboard.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2010-03-14 17:59:51 +0000
committerJohan Engelen <goejendaagh@zonnet.nl>2010-03-14 17:59:51 +0000
commitb11b62ddd952a15b0e3f1192c38f3ca15d1197f8 (patch)
tree81780525416b938689fa0e85aaa9256d459f601f /src/ui/clipboard.cpp
parentImplement keyboard shortcuts for single handle adjustments. (diff)
downloadinkscape-b11b62ddd952a15b0e3f1192c38f3ca15d1197f8.tar.gz
inkscape-b11b62ddd952a15b0e3f1192c38f3ca15d1197f8.zip
fix pasting of LPE stacks
Fixed bugs: - https://launchpad.net/bugs/290834 (bzr r9191)
Diffstat (limited to 'src/ui/clipboard.cpp')
-rw-r--r--src/ui/clipboard.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 99d835730..db509da2e 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -489,13 +489,14 @@ bool ClipboardManagerImpl::pastePathEffect()
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;
@@ -976,7 +977,7 @@ SPCSSAttr *ClipboardManagerImpl::_parseColor(const Glib::ustring &text)
/**
* @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);
+ }
}
}