Skip to content

Commit a220fd2

Browse files
authored
Merge pull request #7 from wanglongqi/why_xpath_not_working
Clean up old codes. The functionality should be all right.
2 parents e3f62eb + 4e486e8 commit a220fd2

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

writetex.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
An Latex equation editor for Inkscape.
66
77
:Author: WANG Longqi <[email protected]>
8-
:Date: 2017-08-12
9-
:Version: v1.6.1
8+
:Date: 2017-11-04
9+
:Version: v1.6.2
1010
1111
This file is a part of WriteTeX extension for Inkscape. For more information,
1212
please refer to http://wanglongqi.github.io/WriteTeX.
@@ -71,17 +71,6 @@ def __init__(self):
7171
help="Write output directly to a new node in svg file")
7272

7373
def effect(self):
74-
self.zoom = float(self.document.xpath(
75-
'//sodipodi:namedview/@inkscape:zoom', namespaces=inkex.NSS)[0])
76-
self.width = 1/self.zoom * \
77-
float(self.document.xpath(
78-
'//sodipodi:namedview/@inkscape:window-width', namespaces=inkex.NSS)[0])
79-
self.height = 1/self.zoom * \
80-
float(self.document.xpath(
81-
'//sodipodi:namedview/@inkscape:window-height', namespaces=inkex.NSS)[0])
82-
self.width = self.unittouu(str(self.width)+'px')
83-
self.height = self.unittouu(str(self.height)+'px')
84-
8574
self.options.scale = float(self.options.scale)
8675
action = self.options.action.strip("\"")
8776
if action == "viewold":
@@ -93,8 +82,8 @@ def effect(self):
9382
if self.options.tosvg == "true":
9483
doc = inkex.etree.fromstring(
9584
'<text x="%g" y="%g">%s</text>' % (
96-
self.view_center[0]-self.width/6,
97-
self.view_center[1]-self.height/6,
85+
self.view_center[0],
86+
self.view_center[1],
9887
node.attrib.get(
9988
'{%s}text' % WriteTexNS, '').decode('string-escape')))
10089
p = node.getparent()
@@ -233,16 +222,16 @@ def svg_to_group(self, svgin):
233222
if self.options.rescale == 'true':
234223
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % (
235224
800*self.options.scale, 800*self.options.scale,
236-
self.view_center[0]-self.width/6,
237-
self.view_center[1]-self.height/6)
225+
self.view_center[0],
226+
self.view_center[1])
238227
else:
239228
if 'transform' in node.attrib:
240229
newnode.attrib['transform'] = node.attrib['transform']
241230
else:
242231
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % (
243232
800*self.options.scale, 800*self.options.scale,
244-
self.view_center[0]-self.width/6,
245-
self.view_center[1]-self.height/6)
233+
self.view_center[0],
234+
self.view_center[1])
246235
newnode.attrib['style'] = node.attrib['style']
247236
except:
248237
pass
@@ -252,8 +241,8 @@ def svg_to_group(self, svgin):
252241
else:
253242
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % (
254243
800*self.options.scale, 800*self.options.scale,
255-
self.view_center[0]-self.width/6,
256-
self.view_center[1]-self.height/6)
244+
self.view_center[0],
245+
self.view_center[1])
257246
self.current_layer.append(newnode)
258247

259248
def merge_pdf2svg_svg(self, svg_file):
@@ -311,8 +300,8 @@ def svg_to_group(self, svgin):
311300
if self.options.rescale == 'true':
312301
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % (
313302
self.options.scale, self.options.scale,
314-
self.view_center[0]-self.width/6,
315-
self.view_center[1]-self.height/6)
303+
self.view_center[0],
304+
self.view_center[1])
316305
else:
317306
if 'transform' in node.attrib:
318307
newnode.attrib['transform'] = node.attrib['transform']
@@ -355,4 +344,4 @@ def parse_transform(transf):
355344

356345
if __name__ == '__main__':
357346
e = WriteTex()
358-
e.affect()
347+
e.affect()

0 commit comments

Comments
 (0)