From: acspike Date: Mon, 8 Oct 2007 01:21:34 +0000 (+0000) Subject: fix hacked element cloning X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5b2208f64b606f78f10d1136d933135a9d70a11a;p=inkscape.git fix hacked element cloning cloning with fromstring(tostring()) striped xmlns now using copy.deepcopy() --- diff --git a/share/extensions/coloreffect.py b/share/extensions/coloreffect.py index 76887faf0..52eff5c0d 100644 --- a/share/extensions/coloreffect.py +++ b/share/extensions/coloreffect.py @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -import sys, copy, optparse, simplestyle, inkex +import sys, copy, optparse, simplestyle, inkex, copy import random @@ -81,7 +81,7 @@ class ColorEffect(inkex.Effect): #return #self.visited.append(this_id) #inkex.debug("visited: " + str(self.visited)) - newnode = inkex.etree.fromstring(inkex.etree.tostring(node)) + newnode = copy.deepcopy(node) newnode.set('id', newid) node.getparent().append(newnode) self.changeStyle(newnode) diff --git a/share/extensions/edge3d.py b/share/extensions/edge3d.py index 0192da022..318e97c72 100644 --- a/share/extensions/edge3d.py +++ b/share/extensions/edge3d.py @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -import inkex, simplepath, sys +import inkex, simplepath, sys, copy from math import degrees, atan2 class Edge3d(inkex.Effect): @@ -103,7 +103,7 @@ class Edge3d(inkex.Effect): if result: if not g: g = self.getGroup(node) - nn = inkex.etree.fromstring(inkex.etree.tostring(node)) + nn = copy.deepcopy(node) nn.set('d',simplepath.formatPath(result)) col = 255 - int(255. * level) @@ -118,7 +118,7 @@ class Edge3d(inkex.Effect): # make a clipped group, clip with clone of original, clipped group # include original and group of paths clip = inkex.etree.SubElement(defs,inkex.addNS('clipPath','svg')) - clip.append(inkex.etree.fromstring(inkex.etree.tostring(node))) + clip.append(copy.deepcopy(node)) clipId = self.uniqueId('clipPath') clip.set('id', clipId) clipG = inkex.etree.SubElement(node.getparent(),inkex.addNS('g','svg')) diff --git a/share/extensions/markers_strokepaint.py b/share/extensions/markers_strokepaint.py index cc186eaa2..04fd4c5c7 100644 --- a/share/extensions/markers_strokepaint.py +++ b/share/extensions/markers_strokepaint.py @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -import random, inkex, simplestyle +import random, inkex, simplestyle, copy class MyEffect(inkex.Effect): def __init__(self): @@ -47,7 +47,7 @@ class MyEffect(inkex.Effect): try: old_mnode = self.xpathSingle('/svg:svg//svg:marker[@id="%s"]' % marker_id) if not self.options.modify: - mnode = inkex.etree.fromstring(inkex.etree.tostring(old_mnode)) + mnode = copy.deepcopy(old_mnode) else: mnode = old_mnode except: diff --git a/share/extensions/pathmodifier.py b/share/extensions/pathmodifier.py index 245665588..baa31fca2 100644 --- a/share/extensions/pathmodifier.py +++ b/share/extensions/pathmodifier.py @@ -148,7 +148,7 @@ class PathModifier(inkex.Effect): def duplicateNodes(self, aList): clones={} for id,node in aList.iteritems(): - clone=inkex.etree.fromstring(inkex.etree.tostring(node)) + clone=copy.deepcopy(node) #!!!--> should it be given an id? #seems to work without this!?! myid = node.tag.split('}')[-1] @@ -187,7 +187,7 @@ class PathModifier(inkex.Effect): refid=node.get(inkex.addNS('href','xlink')) path = '//*[@id="%s"]' % refid[1:] refnode = self.document.getroot().xpath(path,inkex.NSS) - newnode=inkex.etree.fromstring(inkex.etree.tostring(refnode)) + newnode=copy.deepcopy(refnode) self.recursNewIds(newnode) s = node.get('style')