Code

fix an old bug in the style splitting routine and add to the makefile
authoracspike <acspike@users.sourceforge.net>
Thu, 20 Jul 2006 04:23:59 +0000 (04:23 +0000)
committeracspike <acspike@users.sourceforge.net>
Thu, 20 Jul 2006 04:23:59 +0000 (04:23 +0000)
share/extensions/Makefile.am
share/extensions/markers_strokepaint.py
share/extensions/simplestyle.py

index 1195266b1d0aeff5278a358371fada4c0fa97602..fc4297abcd139a73f1dd9cd3e37a90220be160f4 100644 (file)
@@ -52,7 +52,8 @@ extensions = \
        flatten.py \
        measure.py \
        gimp_xcf.py \
-       eqtexsvg.py
+       eqtexsvg.py \
+       markers_strokepaint.py 
 
 otherstuff = \
     aisvg.xslt
@@ -103,7 +104,8 @@ modules = \
        gimp_xcf.inx \
         randompnt.inx \
         randompos.inx \
-       eqtexsvg.inx
+       eqtexsvg.inx \
+       markers_strokepaint.inx
 
 extension_SCRIPTS = \
        $(extensions)
index f49a37a773d5f19ba12118579ee5768e4dc7ff8d..163767f1aaa4f5d423c16055eba39c4e5fa5dfd2 100644 (file)
@@ -32,7 +32,7 @@ class MyEffect(inkex.Effect):
         self.ctx = inkex.xml.xpath.Context.Context(self.document,processorNss=inkex.NSS)\r
         defs = self.xpathSingle('/svg/defs')  \r
         for id, node in self.selected.iteritems():\r
-            mprops = ['marker-start','marker-mid','marker-end']\r
+            mprops = ['marker','marker-start','marker-mid','marker-end']\r
             style = simplestyle.parseStyle(node.attributes.getNamedItem('style').value)\r
             \r
             try:\r
@@ -43,15 +43,16 @@ class MyEffect(inkex.Effect):
             for mprop in mprops:\r
                 if style.has_key(mprop) and style[mprop] != 'none'and style[mprop][:5] == 'url(#':\r
                     marker_id = style[mprop][5:-1]\r
-                    old_mnode = self.xpathSingle('/svg/defs/marker[@id="%s"]' % marker_id)\r
+                    old_mnode = self.xpathSingle('/svg//marker[@id="%s"]' % marker_id)\r
                     mnode = old_mnode.cloneNode(True)\r
                     new_id = "%s%s" % (marker_id,2)\r
                     style[mprop] = "url(#%s)" % new_id\r
                     mnode.attributes.getNamedItem('id').value = new_id\r
                     defs.appendChild(mnode)\r
                     \r
-                    children = inkex.xml.xpath.Evaluate('/svg/defs/marker[@id="%s"]//*[@style]' % new_id,self.document,context=self.ctx)\r
+                    children = inkex.xml.xpath.Evaluate('/svg//marker[@id="%s"]//*[@style]' % new_id,self.document,context=self.ctx)\r
                     for child in children:\r
+                        inkex.debug(child.attributes.getNamedItem('style').value)\r
                         cstyle = simplestyle.parseStyle(child.attributes.getNamedItem('style').value)\r
                         if (cstyle.has_key('stroke') and cstyle['stroke'] != 'none') or not cstyle.has_key('stroke'):\r
                                 cstyle['stroke'] = stroke\r
index 22b4c3e8b21d1ecc0dff56488f361d14a83ca540..e11f91ae0a0495a5b48ce05f6733377e46a52e78 100755 (executable)
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 """
 def parseStyle(s):
     """Create a dictionary from the value of an inline style attribute"""
-    return dict([i.split(":") for i in s.split(";")])
+    return dict([i.split(":") for i in s.split(";") if len(i)])
 def formatStyle(a):
     """Format an inline style attribute from a dictionary"""
     return ";".join([":".join(i) for i in a.iteritems()])