-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from wanglongqi/why_xpath_not_working
Clean up old codes. The functionality should be all right.
- Loading branch information
Showing
1 changed file
with
13 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
An Latex equation editor for Inkscape. | ||
:Author: WANG Longqi <[email protected]> | ||
:Date: 2017-08-12 | ||
:Version: v1.6.1 | ||
:Date: 2017-11-04 | ||
:Version: v1.6.2 | ||
This file is a part of WriteTeX extension for Inkscape. For more information, | ||
please refer to http://wanglongqi.github.io/WriteTeX. | ||
|
@@ -71,17 +71,6 @@ def __init__(self): | |
help="Write output directly to a new node in svg file") | ||
|
||
def effect(self): | ||
self.zoom = float(self.document.xpath( | ||
'//sodipodi:namedview/@inkscape:zoom', namespaces=inkex.NSS)[0]) | ||
self.width = 1/self.zoom * \ | ||
float(self.document.xpath( | ||
'//sodipodi:namedview/@inkscape:window-width', namespaces=inkex.NSS)[0]) | ||
self.height = 1/self.zoom * \ | ||
float(self.document.xpath( | ||
'//sodipodi:namedview/@inkscape:window-height', namespaces=inkex.NSS)[0]) | ||
self.width = self.unittouu(str(self.width)+'px') | ||
self.height = self.unittouu(str(self.height)+'px') | ||
|
||
self.options.scale = float(self.options.scale) | ||
action = self.options.action.strip("\"") | ||
if action == "viewold": | ||
|
@@ -93,8 +82,8 @@ def effect(self): | |
if self.options.tosvg == "true": | ||
doc = inkex.etree.fromstring( | ||
'<text x="%g" y="%g">%s</text>' % ( | ||
self.view_center[0]-self.width/6, | ||
self.view_center[1]-self.height/6, | ||
self.view_center[0], | ||
self.view_center[1], | ||
node.attrib.get( | ||
'{%s}text' % WriteTexNS, '').decode('string-escape'))) | ||
p = node.getparent() | ||
|
@@ -233,16 +222,16 @@ def svg_to_group(self, svgin): | |
if self.options.rescale == 'true': | ||
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % ( | ||
800*self.options.scale, 800*self.options.scale, | ||
self.view_center[0]-self.width/6, | ||
self.view_center[1]-self.height/6) | ||
self.view_center[0], | ||
self.view_center[1]) | ||
else: | ||
if 'transform' in node.attrib: | ||
newnode.attrib['transform'] = node.attrib['transform'] | ||
else: | ||
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % ( | ||
800*self.options.scale, 800*self.options.scale, | ||
self.view_center[0]-self.width/6, | ||
self.view_center[1]-self.height/6) | ||
self.view_center[0], | ||
self.view_center[1]) | ||
newnode.attrib['style'] = node.attrib['style'] | ||
except: | ||
pass | ||
|
@@ -252,8 +241,8 @@ def svg_to_group(self, svgin): | |
else: | ||
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % ( | ||
800*self.options.scale, 800*self.options.scale, | ||
self.view_center[0]-self.width/6, | ||
self.view_center[1]-self.height/6) | ||
self.view_center[0], | ||
self.view_center[1]) | ||
self.current_layer.append(newnode) | ||
|
||
def merge_pdf2svg_svg(self, svg_file): | ||
|
@@ -311,8 +300,8 @@ def svg_to_group(self, svgin): | |
if self.options.rescale == 'true': | ||
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % ( | ||
self.options.scale, self.options.scale, | ||
self.view_center[0]-self.width/6, | ||
self.view_center[1]-self.height/6) | ||
self.view_center[0], | ||
self.view_center[1]) | ||
else: | ||
if 'transform' in node.attrib: | ||
newnode.attrib['transform'] = node.attrib['transform'] | ||
|
@@ -355,4 +344,4 @@ def parse_transform(transf): | |
|
||
if __name__ == '__main__': | ||
e = WriteTex() | ||
e.affect() | ||
e.affect() |