From 4517038755f4211da3b5e9afb5567e9d608875da Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 2 Jan 2008 18:10:43 +0000 Subject: + Fix bug #179840, forking of LPEs + Groundwork for fixing transforming LPE bugs. TODO: implement the actual transformation of LPE parameters. (bzr r4367) --- src/selection-chemistry.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 040e5f839..56ef7b01f 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -76,6 +76,8 @@ #include "xml/simple-document.h" #include "sp-filter-reference.h" #include "gradient-drag.h" +#include "uri-references.h" +#include "live_effects/lpeobject.h" using NR::X; using NR::Y; @@ -1268,11 +1270,12 @@ void sp_selection_paste_livepatheffect() return; } - paste_defs (&defs_clipboard, sp_desktop_document(desktop)); + SPDocument *doc = sp_desktop_document(desktop); + paste_defs (&defs_clipboard, doc); Inkscape::XML::Node *repr = (Inkscape::XML::Node *) clipboard->data; - char const *effectstr = repr->attribute("inkscape:path-effect"); - if (!effectstr) { + char const *effecturi = repr->attribute("inkscape:path-effect"); + if (!effecturi) { SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Clipboard does not contain a live path effect.")); return; } @@ -1280,8 +1283,13 @@ void sp_selection_paste_livepatheffect() for ( GSList const *itemlist = selection->itemList(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) { SPItem *item = reinterpret_cast(itemlist->data); if ( item && SP_IS_SHAPE(item) ) { - Inkscape::XML::Node *selrepr = (Inkscape::XML::Node *) SP_OBJECT_REPR(item); - selrepr->setAttribute("inkscape:path-effect", effectstr); + SPShape * shape = SP_SHAPE(item); + + // create a private LPE object! + SPObject * obj = sp_uri_reference_resolve(doc, effecturi); + LivePathEffectObject * lpeobj = LIVEPATHEFFECT(obj)->fork_private_if_necessary(0); + + sp_shape_set_path_effect(shape, lpeobj); // set inkscape:original-d for paths. the other shapes don't need this. if ( SP_IS_PATH(item) ) { -- cgit v1.2.3