Clean
This commit is contained in:
parent
9195b30d6f
commit
4f2a99e8f1
|
@ -8,27 +8,6 @@ import easymacro as app
|
|||
|
||||
ID_EXTENSION = 'net.elmau.zaz.latex2svg'
|
||||
SERVICE = ('com.sun.star.task.Job',)
|
||||
TITLE = 'ZAZ Latex2SVG'
|
||||
|
||||
|
||||
_ = app.install_locales(__file__)
|
||||
|
||||
|
||||
TEMPLATE = """\documentclass{{article}}
|
||||
\\usepackage[a5paper, landscape]{{geometry}}
|
||||
\\usepackage{{xcolor}}
|
||||
\\usepackage{{amssymb}}
|
||||
\\usepackage{{amsmath}}
|
||||
\pagestyle{{empty}}
|
||||
\\begin{{document}}
|
||||
\\begingroup
|
||||
\Huge
|
||||
|
||||
\[ {} \]
|
||||
|
||||
\endgroup
|
||||
\end{{document}}
|
||||
"""
|
||||
|
||||
|
||||
class Controllers(object):
|
||||
|
@ -72,27 +51,6 @@ class Controllers(object):
|
|||
return
|
||||
|
||||
|
||||
def _latex_to_svg(code):
|
||||
NAME = 'temp'
|
||||
data = TEMPLATE.format(code)
|
||||
dt = app.paths.dir_tmp()
|
||||
path_tex = app._P.join(dt.name, f'{NAME}.tex')
|
||||
path_pdf = app._P.join(dt.name, f'{NAME}.pdf')
|
||||
path_svg = app._P.join(app._P.temp_dir, f'{NAME}.svg')
|
||||
|
||||
app.paths.save(path_tex, data)
|
||||
cmd = f'pdflatex --interaction=batchmode -output-directory="{dt.name}" "{path_tex}"'
|
||||
app.run(cmd)
|
||||
cmd = f'pdfcrop "{path_pdf}" "{path_pdf}"'
|
||||
app.run(cmd)
|
||||
cmd = f'pdf2svg "{path_pdf}" "{path_svg}"'
|
||||
app.run(cmd)
|
||||
|
||||
if not app.paths.exists(path_svg):
|
||||
path_svg = ''
|
||||
dt.cleanup()
|
||||
return path_svg
|
||||
|
||||
|
||||
class ZAZLaTex2SVG(unohelper.Base, XJobExecutor):
|
||||
NAME = 'temp'
|
||||
|
@ -105,21 +63,6 @@ class ZAZLaTex2SVG(unohelper.Base, XJobExecutor):
|
|||
main.run(args, __file__)
|
||||
return
|
||||
|
||||
def _from_selection(self):
|
||||
doc = app.active
|
||||
sel = doc.selection
|
||||
|
||||
data = sel.value
|
||||
path_svg = _latex_to_svg(data)
|
||||
|
||||
sel = sel.offset()
|
||||
args = {}
|
||||
if doc.type == 'writer':
|
||||
args = {'Width': 5000, 'Height': 2000}
|
||||
image = sel.insert_image(path_svg, args)
|
||||
image.description = data
|
||||
return
|
||||
|
||||
def _dlg(self):
|
||||
dlg = self._create_dialog()
|
||||
sel = app.selection
|
||||
|
|
|
@ -4,7 +4,7 @@ import easymacro as app
|
|||
|
||||
|
||||
ID_EXTENSION = ''
|
||||
|
||||
TITLE = 'ZAZ Latex2SVG'
|
||||
_ = None
|
||||
|
||||
TEMPLATE = """\documentclass{{article}}
|
||||
|
@ -92,9 +92,6 @@ def from_dialog():
|
|||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def run(args, path_locales):
|
||||
global _
|
||||
_ = app.install_locales(path_locales)
|
||||
|
|
Loading…
Reference in New Issue