Compare commits
14 Commits
Author | SHA1 | Date |
---|---|---|
Mauricio Baeza | dfddead15b | |
Mauricio Baeza | d7ef6f91c1 | |
Mauricio Baeza | 31c8142397 | |
Mauricio Baeza | c72d5e58f4 | |
Mauricio Baeza | a797314ff3 | |
Mauricio Baeza | 4f2a99e8f1 | |
Mauricio Baeza | 9195b30d6f | |
Mauricio Baeza | 4c1183102b | |
Mauricio Baeza | a7501bad5f | |
Mauricio Baeza | 30a755a748 | |
Mauricio Baeza | dc61cfb45c | |
Mauricio Baeza | 801b4e7626 | |
Mauricio Baeza | 76e327e521 | |
Mauricio Baeza | 8c659c8af9 |
|
@ -1,4 +1,6 @@
|
||||||
# ---> Python
|
# ---> Python
|
||||||
|
*.po~
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|
|
@ -20,7 +20,7 @@ Requirements:
|
||||||
#### but, don't make the mistake of many of *thinking only in gratis software* that so much damage has done to **Free Software**.
|
#### but, don't make the mistake of many of *thinking only in gratis software* that so much damage has done to **Free Software**.
|
||||||
|
|
||||||
|
|
||||||
This extension have a cost of maintenance of 5 euros every year.
|
This extension have a cost of maintenance of 1 euro every year.
|
||||||
|
|
||||||
BCH: `qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d`
|
BCH: `qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d`
|
||||||
|
|
||||||
|
|
8
conf.py
8
conf.py
|
@ -26,7 +26,7 @@ import logging
|
||||||
TYPE_EXTENSION = 1
|
TYPE_EXTENSION = 1
|
||||||
|
|
||||||
# ~ https://semver.org/
|
# ~ https://semver.org/
|
||||||
VERSION = '0.1.0'
|
VERSION = '0.2.0'
|
||||||
|
|
||||||
# ~ Your great extension name, not used spaces or "-_"
|
# ~ Your great extension name, not used spaces or "-_"
|
||||||
NAME = 'ZAZLaTex2SVG'
|
NAME = 'ZAZLaTex2SVG'
|
||||||
|
@ -111,7 +111,7 @@ MENU_MAIN = {
|
||||||
MENUS = (
|
MENUS = (
|
||||||
{
|
{
|
||||||
'title': {'en': 'From selection', 'es': 'Desde selección'},
|
'title': {'en': 'From selection', 'es': 'Desde selección'},
|
||||||
'argument': 'selection',
|
'argument': 'from_selection',
|
||||||
'context': 'calc,writer,draw,impress',
|
'context': 'calc,writer,draw,impress',
|
||||||
'icon': 'icon1',
|
'icon': 'icon1',
|
||||||
'toolbar': False,
|
'toolbar': False,
|
||||||
|
@ -119,7 +119,7 @@ MENUS = (
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'title': {'en': 'Insert...', 'es': 'Insertar...'},
|
'title': {'en': 'Insert...', 'es': 'Insertar...'},
|
||||||
'argument': 'dlg',
|
'argument': 'from_dialog',
|
||||||
'context': 'calc,writer,draw,impress',
|
'context': 'calc,writer,draw,impress',
|
||||||
'icon': 'icon1',
|
'icon': 'icon1',
|
||||||
'toolbar': False,
|
'toolbar': False,
|
||||||
|
@ -127,7 +127,7 @@ MENUS = (
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'title': {'en': 'Validate applications', 'es': 'Validar aplicaciones'},
|
'title': {'en': 'Validate applications', 'es': 'Validar aplicaciones'},
|
||||||
'argument': 'app',
|
'argument': 'validate_app',
|
||||||
'context': 'calc,writer,draw,impress',
|
'context': 'calc,writer,draw,impress',
|
||||||
'icon': 'icon2',
|
'icon': 'icon2',
|
||||||
'toolbar': False,
|
'toolbar': False,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1 +0,0 @@
|
||||||
/home/mau/Projects/libre_office/zaz/source/easymacro2.py
|
|
Binary file not shown.
Binary file not shown.
|
@ -20,7 +20,7 @@
|
||||||
<value>com.sun.star.sheet.SpreadsheetDocument,com.sun.star.text.TextDocument,com.sun.star.drawing.DrawingDocument,com.sun.star.presentation.PresentationDocument</value>
|
<value>com.sun.star.sheet.SpreadsheetDocument,com.sun.star.text.TextDocument,com.sun.star.drawing.DrawingDocument,com.sun.star.presentation.PresentationDocument</value>
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="URL" oor:type="xs:string">
|
<prop oor:name="URL" oor:type="xs:string">
|
||||||
<value>service:net.elmau.zaz.latex2svg?selection</value>
|
<value>service:net.elmau.zaz.latex2svg?from_selection</value>
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="Target" oor:type="xs:string">
|
<prop oor:name="Target" oor:type="xs:string">
|
||||||
<value>_self</value>
|
<value>_self</value>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
<value>com.sun.star.sheet.SpreadsheetDocument,com.sun.star.text.TextDocument,com.sun.star.drawing.DrawingDocument,com.sun.star.presentation.PresentationDocument</value>
|
<value>com.sun.star.sheet.SpreadsheetDocument,com.sun.star.text.TextDocument,com.sun.star.drawing.DrawingDocument,com.sun.star.presentation.PresentationDocument</value>
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="URL" oor:type="xs:string">
|
<prop oor:name="URL" oor:type="xs:string">
|
||||||
<value>service:net.elmau.zaz.latex2svg?dlg</value>
|
<value>service:net.elmau.zaz.latex2svg?from_dialog</value>
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="Target" oor:type="xs:string">
|
<prop oor:name="Target" oor:type="xs:string">
|
||||||
<value>_self</value>
|
<value>_self</value>
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
<value>com.sun.star.sheet.SpreadsheetDocument,com.sun.star.text.TextDocument,com.sun.star.drawing.DrawingDocument,com.sun.star.presentation.PresentationDocument</value>
|
<value>com.sun.star.sheet.SpreadsheetDocument,com.sun.star.text.TextDocument,com.sun.star.drawing.DrawingDocument,com.sun.star.presentation.PresentationDocument</value>
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="URL" oor:type="xs:string">
|
<prop oor:name="URL" oor:type="xs:string">
|
||||||
<value>service:net.elmau.zaz.latex2svg?app</value>
|
<value>service:net.elmau.zaz.latex2svg?validate_app</value>
|
||||||
</prop>
|
</prop>
|
||||||
<prop oor:name="Target" oor:type="xs:string">
|
<prop oor:name="Target" oor:type="xs:string">
|
||||||
<value>_self</value>
|
<value>_self</value>
|
||||||
|
|
|
@ -1,265 +1,23 @@
|
||||||
import uno
|
import uno
|
||||||
import unohelper
|
import unohelper
|
||||||
from com.sun.star.task import XJobExecutor
|
from com.sun.star.task import XJobExecutor
|
||||||
import easymacro2 as app
|
import main
|
||||||
|
|
||||||
|
|
||||||
ID_EXTENSION = 'net.elmau.zaz.latex2svg'
|
ID_EXTENSION = 'net.elmau.zaz.latex2svg'
|
||||||
SERVICE = ('com.sun.star.task.Job',)
|
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}}
|
|
||||||
"""
|
|
||||||
# ~ TEMPLATE = """\documentclass{{standalone}}
|
|
||||||
# ~ \\usepackage[a5paper, landscape]{{geometry}}
|
|
||||||
# ~ \\usepackage{{xcolor}}
|
|
||||||
# ~ \\usepackage{{amssymb}}
|
|
||||||
# ~ \\usepackage{{amsmath}}
|
|
||||||
# ~ \\usepackage{{tikz}}
|
|
||||||
# ~ \pagestyle{{empty}}
|
|
||||||
# ~ \\begin{{document}}
|
|
||||||
# ~ \\begin{{tikzpicture}}
|
|
||||||
|
|
||||||
# ~ \\node at (0, 0) {{
|
|
||||||
# ~ \\begin{{equation*}}
|
|
||||||
|
|
||||||
# ~ \[ {} \]
|
|
||||||
|
|
||||||
# ~ \end{{equation*}}
|
|
||||||
# ~ }};
|
|
||||||
|
|
||||||
# ~ \end{{tikzpicture}}
|
|
||||||
# ~ \end{{document}}
|
|
||||||
# ~ """
|
|
||||||
|
|
||||||
|
|
||||||
class Controllers(object):
|
|
||||||
|
|
||||||
def __init__(self, dlg):
|
|
||||||
self.d = dlg
|
|
||||||
self._path = ''
|
|
||||||
|
|
||||||
def cmd_close_action(self, event):
|
|
||||||
self.d.close()
|
|
||||||
return
|
|
||||||
|
|
||||||
def cmd_preview_action(self, event):
|
|
||||||
code = self.d.text.value
|
|
||||||
if not code:
|
|
||||||
msg = _('Write some code')
|
|
||||||
app.errorbox(msg)
|
|
||||||
return
|
|
||||||
|
|
||||||
self._path = _latex_to_svg(code)
|
|
||||||
self.d.image.url = self._path
|
|
||||||
return
|
|
||||||
|
|
||||||
def cmd_insert_action(self, event):
|
|
||||||
if not self._path:
|
|
||||||
msg = _('First, generate preview')
|
|
||||||
app.errorbox(msg)
|
|
||||||
return
|
|
||||||
|
|
||||||
attr = {}
|
|
||||||
sel = app.selection
|
|
||||||
if hasattr(sel, 'anchor'):
|
|
||||||
attr = sel.size
|
|
||||||
anchor = sel.anchor
|
|
||||||
anchor.dp.remove(sel)
|
|
||||||
sel = anchor
|
|
||||||
|
|
||||||
image = sel.insert_image(self._path, attr)
|
|
||||||
image.description = self.d.text.value
|
|
||||||
self.d.close()
|
|
||||||
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):
|
class ZAZLaTex2SVG(unohelper.Base, XJobExecutor):
|
||||||
NAME = 'temp'
|
|
||||||
_msg1 = _('Not found')
|
|
||||||
_msg2 = _('Found')
|
|
||||||
|
|
||||||
def __init__(self, ctx):
|
def __init__(self, ctx):
|
||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
|
|
||||||
def trigger(self, args=''):
|
def trigger(self, args=''):
|
||||||
if args == 'app':
|
main.ID_EXTENSION = ID_EXTENSION
|
||||||
self._app()
|
main.run(args, __file__)
|
||||||
return
|
return
|
||||||
|
|
||||||
if args == 'dlg':
|
|
||||||
self._dlg()
|
|
||||||
return
|
|
||||||
|
|
||||||
self._from_selection()
|
|
||||||
return
|
|
||||||
|
|
||||||
def _app(self):
|
|
||||||
result = self._msg1
|
|
||||||
if app.paths.exists_app('pdflatex'):
|
|
||||||
result = self._msg2
|
|
||||||
msg = f'pdflatex = {result}\n'
|
|
||||||
|
|
||||||
result = self._msg1
|
|
||||||
if app.paths.exists_app('pdfcrop'):
|
|
||||||
result = self._msg2
|
|
||||||
msg += f'pdfcrop = {result}\n'
|
|
||||||
|
|
||||||
result = self._msg1
|
|
||||||
if app.paths.exists_app('pdf2svg'):
|
|
||||||
result = self._msg2
|
|
||||||
msg += f'pdf2svg = {result}\n\n'
|
|
||||||
|
|
||||||
msg += _('Not used, if not found some application.')
|
|
||||||
|
|
||||||
app.msgbox(msg)
|
|
||||||
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
|
|
||||||
if hasattr(sel, 'description'):
|
|
||||||
dlg.text.value = sel.description
|
|
||||||
dlg.open()
|
|
||||||
return
|
|
||||||
|
|
||||||
def _create_dialog(self):
|
|
||||||
args = {
|
|
||||||
'Name': 'dialog',
|
|
||||||
'Title': TITLE,
|
|
||||||
'Width': 270,
|
|
||||||
'Height': 250,
|
|
||||||
}
|
|
||||||
dlg = app.create_dialog(args)
|
|
||||||
dlg.id = ID_EXTENSION
|
|
||||||
dlg.events = Controllers
|
|
||||||
|
|
||||||
args = {
|
|
||||||
'Type': 'Label',
|
|
||||||
'Name': 'lbl_code',
|
|
||||||
'Label': _('Latex code'),
|
|
||||||
'Width': 70,
|
|
||||||
'Height': 10,
|
|
||||||
'X': 10,
|
|
||||||
'Y': 5,
|
|
||||||
'VerticalAlign': 1,
|
|
||||||
}
|
|
||||||
dlg.add_control(args)
|
|
||||||
|
|
||||||
args = {
|
|
||||||
'Type': 'Text',
|
|
||||||
'Name': 'text',
|
|
||||||
'Width': 250,
|
|
||||||
'Height': 75,
|
|
||||||
'MultiLine': True,
|
|
||||||
'VScroll': True,
|
|
||||||
}
|
|
||||||
dlg.add_control(args)
|
|
||||||
|
|
||||||
args = {
|
|
||||||
'Type': 'Button',
|
|
||||||
'Name': 'cmd_preview',
|
|
||||||
'Label': _('Preview'),
|
|
||||||
'Width': 70,
|
|
||||||
'Height': 15,
|
|
||||||
'ImageURL': 'view.png',
|
|
||||||
'ImagePosition': 1,
|
|
||||||
}
|
|
||||||
dlg.add_control(args)
|
|
||||||
|
|
||||||
args = {
|
|
||||||
'Type': 'Image',
|
|
||||||
'Name': 'image',
|
|
||||||
'Width': 250,
|
|
||||||
'Height': 100,
|
|
||||||
}
|
|
||||||
dlg.add_control(args)
|
|
||||||
|
|
||||||
args = {
|
|
||||||
'Type': 'Button',
|
|
||||||
'Name': 'cmd_insert',
|
|
||||||
'Label': _('Insert'),
|
|
||||||
'Width': 70,
|
|
||||||
'Height': 15,
|
|
||||||
'ImageURL': 'insert.png',
|
|
||||||
'ImagePosition': 1,
|
|
||||||
}
|
|
||||||
dlg.add_control(args)
|
|
||||||
args = {
|
|
||||||
'Type': 'Button',
|
|
||||||
'Name': 'cmd_close',
|
|
||||||
'Label': _('Close'),
|
|
||||||
'Width': 70,
|
|
||||||
'Height': 15,
|
|
||||||
'ImageURL': 'close.png',
|
|
||||||
'ImagePosition': 1,
|
|
||||||
}
|
|
||||||
dlg.add_control(args)
|
|
||||||
|
|
||||||
dlg.text.move(dlg.lbl_code)
|
|
||||||
dlg.cmd_preview.move(dlg.text, center=True)
|
|
||||||
dlg.image.move(dlg.cmd_preview, center=True)
|
|
||||||
dlg.cmd_insert.move(dlg.image)
|
|
||||||
dlg.cmd_close.move(dlg.image)
|
|
||||||
controls = (dlg.cmd_insert, dlg.cmd_close)
|
|
||||||
dlg.center(controls)
|
|
||||||
|
|
||||||
return dlg
|
|
||||||
|
|
||||||
|
|
||||||
g_ImplementationHelper = unohelper.ImplementationHelper()
|
g_ImplementationHelper = unohelper.ImplementationHelper()
|
||||||
g_ImplementationHelper.addImplementation(ZAZLaTex2SVG, ID_EXTENSION, SERVICE)
|
g_ImplementationHelper.addImplementation(ZAZLaTex2SVG, ID_EXTENSION, SERVICE)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<description xmlns="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:d="http://openoffice.org/extensions/description/2006">
|
<description xmlns="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:d="http://openoffice.org/extensions/description/2006">
|
||||||
<identifier value="net.elmau.zaz.latex2svg"/>
|
<identifier value="net.elmau.zaz.latex2svg"/>
|
||||||
<version value="0.1.0"/>
|
<version value="0.2.0"/>
|
||||||
<display-name>
|
<display-name>
|
||||||
<name lang="en">ZAZLaTex2SVG</name>
|
<name lang="en">ZAZLaTex2SVG</name>
|
||||||
<name lang="es">ZAZLaTex2SVG</name>
|
<name lang="es">ZAZLaTex2SVG</name>
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 32 32"
|
||||||
|
version="1.1"
|
||||||
|
x="0px"
|
||||||
|
y="0px"
|
||||||
|
id="svg18"
|
||||||
|
width="32"
|
||||||
|
height="32">
|
||||||
|
<metadata
|
||||||
|
id="metadata24">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title>9.4</dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs22" />
|
||||||
|
<title
|
||||||
|
id="title2">9.4</title>
|
||||||
|
<desc
|
||||||
|
id="desc4">Created with Sketch.</desc>
|
||||||
|
<g
|
||||||
|
stroke="none"
|
||||||
|
stroke-width="1"
|
||||||
|
fill="none"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
id="g12"
|
||||||
|
transform="scale(0.66666667)">
|
||||||
|
<g
|
||||||
|
fill-rule="nonzero"
|
||||||
|
fill="#000000"
|
||||||
|
id="g10">
|
||||||
|
<g
|
||||||
|
id="g8">
|
||||||
|
<path
|
||||||
|
d="m 26.828427,24 6.366079,6.366079 c 0.779879,0.779879 0.784376,2.039815 -0.0021,2.826309 -0.781048,0.781049 -2.047059,0.781368 -2.826309,0.0021 L 24,26.828427 17.633921,33.194506 c -0.779879,0.779879 -2.039815,0.784376 -2.826309,-0.0021 -0.781049,-0.781048 -0.781368,-2.047059 -0.0021,-2.826309 L 21.171573,24 14.805494,17.633921 c -0.779879,-0.779879 -0.784376,-2.039815 0.0021,-2.826309 0.781048,-0.781049 2.047059,-0.781368 2.826309,-0.0021 L 24,21.171573 30.366079,14.805494 c 0.779879,-0.779879 2.039815,-0.784376 2.826309,0.0021 0.781049,0.781048 0.781368,2.047059 0.0021,2.826309 z M 24,48 C 10.745166,48 0,37.254834 0,24 0,10.745166 10.745166,0 24,0 37.254834,0 48,10.745166 48,24 48,37.254834 37.254834,48 24,48 Z m 0,-4 C 35.045695,44 44,35.045695 44,24 44,12.954305 35.045695,4 24,4 12.954305,4 4,12.954305 4,24 4,35.045695 12.954305,44 24,44 Z"
|
||||||
|
id="path6" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.9 KiB |
|
@ -0,0 +1,87 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
version="1.1"
|
||||||
|
id="Capa_1"
|
||||||
|
x="0px"
|
||||||
|
y="0px"
|
||||||
|
width="25.061001"
|
||||||
|
height="31.99976"
|
||||||
|
viewBox="0 0 25.061001 31.99976"
|
||||||
|
xml:space="preserve"><metadata
|
||||||
|
id="metadata41"><rdf:RDF><cc:Work
|
||||||
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||||
|
id="defs39" />
|
||||||
|
<g
|
||||||
|
id="g4"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
<path
|
||||||
|
d="m 13.874,25.477 0.646,1.27 H 3.22 V 0 H 25.574 V 20.073 L 24.218,19.415 V 1.269 H 4.578 V 25.477 Z M 7.528,8.308 C 7.415,8.414 7.281,8.502 7.128,8.57 6.973,8.639 6.81,8.688 6.639,8.722 L 6.848,9.69 7.945,9.453 8.528,12.151 9.927,11.848 8.915,7.165 7.813,7.405 C 7.845,7.599 7.834,7.772 7.779,7.924 7.724,8.076 7.641,8.201 7.528,8.308 Z m 6.859,0.26 -1.184,0.255 -0.256,-1.184 -1.03,0.222 0.257,1.186 -1.184,0.254 0.222,1.03 1.184,-0.256 0.256,1.184 1.029,-0.222 -0.255,-1.186 1.184,-0.256 z m 1.671,-2.105 c -0.113,0.105 -0.246,0.193 -0.4,0.262 -0.153,0.068 -0.317,0.119 -0.488,0.152 l 0.209,0.968 1.096,-0.237 0.584,2.698 1.398,-0.303 L 17.442,5.32 16.34,5.557 c 0.032,0.196 0.021,0.369 -0.033,0.52 -0.051,0.151 -0.135,0.279 -0.249,0.386 z M 23.315,8.558 23.09,7.529 19.694,8.265 19.918,9.294 Z M 19.344,6.642 19.568,7.671 22.965,6.936 22.741,5.907 Z m 1.666,12.6 v -6.818 h -3.238 v 6.818 1.458 1.435 l -1.09,-2.234 -3.055,-0.008 1.255,2.573 H 14.87 l 0.809,1.632 0.104,0.215 h 0.002 l 1.988,4.022 v 10e-4 h 1.34 v 1.359 h 6.023 v -1.359 h 1.34 v -6.222 z"
|
||||||
|
id="path2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g6"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g8"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g10"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g12"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g14"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g16"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g18"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g20"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g22"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g24"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g26"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g28"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g30"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g32"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g34"
|
||||||
|
transform="matrix(1.0776144,0,0,1.0776144,-3.4699184,0)">
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.0 KiB |
|
@ -0,0 +1,113 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
version="1.1"
|
||||||
|
id="Layer_1"
|
||||||
|
x="0px"
|
||||||
|
y="0px"
|
||||||
|
viewBox="0 0 31.999998 32.000061"
|
||||||
|
xml:space="preserve"
|
||||||
|
sodipodi:docname="preview.svg"
|
||||||
|
width="31.999998"
|
||||||
|
height="32.000061"
|
||||||
|
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"><sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="2560"
|
||||||
|
inkscape:window-height="1006"
|
||||||
|
id="namedview23"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="1.6074219"
|
||||||
|
inkscape:cx="16.0005"
|
||||||
|
inkscape:cy="16.00003"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="37"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="Layer_1" /><metadata
|
||||||
|
id="metadata43"><rdf:RDF><cc:Work
|
||||||
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
|
||||||
|
id="defs41" />
|
||||||
|
<g
|
||||||
|
id="g6"
|
||||||
|
transform="scale(0.06250012)">
|
||||||
|
<g
|
||||||
|
id="g4">
|
||||||
|
<path
|
||||||
|
d="M 509.107,130.133 364.04,2.133 c -1.741,-1.536 -3.968,-2.236 -6.101,-2.116 L 8.533,0 C 6.263,0 4.096,0.896 2.5,2.5 0.905,4.105 0,6.263 0,8.533 v 358.4 c 0,4.719 3.814,8.533 8.533,8.533 h 179.2 c 0.205,0 0.384,-0.102 0.58,-0.119 18.765,20.966 45.935,34.253 76.22,34.253 13.909,0 27.179,-2.816 39.279,-7.859 l 90.735,107.238 c 1.63,1.911 4.011,3.021 6.519,3.021 27.844,0 42.667,-19.823 42.667,-34.133 0,-2.014 -0.717,-3.977 -2.014,-5.513 l -81.988,-96.888 h 143.735 c 4.719,0 8.533,-3.814 8.533,-8.533 v -230.4 c 10e-4,-2.449 -1.049,-4.778 -2.892,-6.4 z M 366.933,27.443 480.896,128 H 366.933 Z m -102.4,365.09 c -47.053,0 -85.333,-38.281 -85.333,-85.333 0,-47.052 38.281,-85.333 85.333,-85.333 47.052,0 85.333,38.281 85.333,85.333 0,47.052 -38.28,85.333 -85.333,85.333 z m 161.647,87.894 c -1.638,5.009 -7.697,13.047 -21.308,14.336 L 319.274,393.592 c 7.228,-4.599 13.824,-10.061 19.678,-16.265 z M 494.933,358.4 h -141.85 c 8.755,-15.078 13.85,-32.538 13.85,-51.2 0,-56.465 -45.935,-102.4 -102.4,-102.4 -56.465,0 -102.4,45.935 -102.4,102.4 0,18.662 5.094,36.122 13.85,51.2 H 17.067 V 17.067 l 332.8,0.017 v 119.45 c 0,4.719 3.814,8.533 8.533,8.533 h 136.533 z"
|
||||||
|
id="path2" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g8"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g10"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g12"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g14"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g16"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g18"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g20"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g22"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g24"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g26"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g28"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g30"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g32"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g34"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g36"
|
||||||
|
transform="translate(-239.9995,-239.99997)">
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.6 KiB |
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,227 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import easymacro as app
|
||||||
|
|
||||||
|
|
||||||
|
ID_EXTENSION = ''
|
||||||
|
TITLE = 'ZAZ Latex2SVG'
|
||||||
|
_ = None
|
||||||
|
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):
|
||||||
|
|
||||||
|
def __init__(self, dlg):
|
||||||
|
self.d = dlg
|
||||||
|
self._path = ''
|
||||||
|
|
||||||
|
def cmd_close_action(self, event):
|
||||||
|
self.d.close()
|
||||||
|
return
|
||||||
|
|
||||||
|
def cmd_preview_action(self, event):
|
||||||
|
code = self.d.text.value
|
||||||
|
if not code:
|
||||||
|
msg = _('Write some code')
|
||||||
|
app.errorbox(msg)
|
||||||
|
return
|
||||||
|
|
||||||
|
self._path = _latex_to_svg(code)
|
||||||
|
self.d.image.url = self._path
|
||||||
|
return
|
||||||
|
|
||||||
|
def cmd_insert_action(self, event):
|
||||||
|
if not self._path:
|
||||||
|
msg = _('First, generate preview')
|
||||||
|
app.errorbox(msg)
|
||||||
|
return
|
||||||
|
|
||||||
|
attr = {}
|
||||||
|
sel = app.selection
|
||||||
|
if hasattr(sel, 'anchor'):
|
||||||
|
attr = sel.size
|
||||||
|
anchor = sel.anchor
|
||||||
|
anchor.dp.remove(sel)
|
||||||
|
sel = anchor
|
||||||
|
|
||||||
|
image = sel.insert_image(self._path, attr)
|
||||||
|
image.description = self.d.text.value
|
||||||
|
self.d.close()
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def validate_app():
|
||||||
|
msg1 = _('Not found')
|
||||||
|
msg2 = _('Found')
|
||||||
|
|
||||||
|
result = msg1
|
||||||
|
if app.paths.exists_app('pdflatex'):
|
||||||
|
result = msg2
|
||||||
|
msg = f'pdflatex = {result}\n'
|
||||||
|
|
||||||
|
result = msg1
|
||||||
|
if app.paths.exists_app('pdfcrop'):
|
||||||
|
result = msg2
|
||||||
|
msg += f'pdfcrop = {result}\n'
|
||||||
|
|
||||||
|
result = msg1
|
||||||
|
if app.paths.exists_app('pdf2svg'):
|
||||||
|
result = msg2
|
||||||
|
msg += f'pdf2svg = {result}\n\n'
|
||||||
|
|
||||||
|
msg += _('Not used, if not found some application.')
|
||||||
|
|
||||||
|
app.msgbox(msg)
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
def from_selection():
|
||||||
|
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 _create_dialog():
|
||||||
|
args = {
|
||||||
|
'Name': 'dialog',
|
||||||
|
'Title': TITLE,
|
||||||
|
'Width': 270,
|
||||||
|
'Height': 260,
|
||||||
|
}
|
||||||
|
dlg = app.create_dialog(args)
|
||||||
|
dlg.id = ID_EXTENSION
|
||||||
|
dlg.events = Controllers
|
||||||
|
|
||||||
|
args = {
|
||||||
|
'Type': 'Label',
|
||||||
|
'Name': 'lbl_code',
|
||||||
|
'Label': _('Latex code'),
|
||||||
|
'Width': 70,
|
||||||
|
'Height': 10,
|
||||||
|
'X': 10,
|
||||||
|
'Y': 5,
|
||||||
|
'VerticalAlign': 1,
|
||||||
|
}
|
||||||
|
dlg.add_control(args)
|
||||||
|
|
||||||
|
args = {
|
||||||
|
'Type': 'Text',
|
||||||
|
'Name': 'text',
|
||||||
|
'Width': 250,
|
||||||
|
'Height': 75,
|
||||||
|
'MultiLine': True,
|
||||||
|
'VScroll': True,
|
||||||
|
}
|
||||||
|
dlg.add_control(args)
|
||||||
|
|
||||||
|
args = {
|
||||||
|
'Type': 'Button',
|
||||||
|
'Name': 'cmd_preview',
|
||||||
|
'Label': _('Preview'),
|
||||||
|
'Width': 70,
|
||||||
|
'Height': 20,
|
||||||
|
'ImageURL': 'preview.svg',
|
||||||
|
'ImagePosition': 1,
|
||||||
|
}
|
||||||
|
dlg.add_control(args)
|
||||||
|
|
||||||
|
args = {
|
||||||
|
'Type': 'Image',
|
||||||
|
'Name': 'image',
|
||||||
|
'Width': 250,
|
||||||
|
'Height': 100,
|
||||||
|
}
|
||||||
|
dlg.add_control(args)
|
||||||
|
|
||||||
|
args = {
|
||||||
|
'Type': 'Button',
|
||||||
|
'Name': 'cmd_insert',
|
||||||
|
'Label': _('Insert'),
|
||||||
|
'Width': 70,
|
||||||
|
'Height': 20,
|
||||||
|
'ImageURL': 'insert.svg',
|
||||||
|
'ImagePosition': 1,
|
||||||
|
}
|
||||||
|
dlg.add_control(args)
|
||||||
|
args = {
|
||||||
|
'Type': 'Button',
|
||||||
|
'Name': 'cmd_close',
|
||||||
|
'Label': _('Close'),
|
||||||
|
'Width': 70,
|
||||||
|
'Height': 20,
|
||||||
|
'ImageURL': 'close.svg',
|
||||||
|
'ImagePosition': 1,
|
||||||
|
}
|
||||||
|
dlg.add_control(args)
|
||||||
|
|
||||||
|
dlg.text.move(dlg.lbl_code)
|
||||||
|
dlg.cmd_preview.move(dlg.text, center=True)
|
||||||
|
dlg.image.move(dlg.cmd_preview, center=True)
|
||||||
|
dlg.cmd_insert.move(dlg.image)
|
||||||
|
dlg.cmd_close.move(dlg.image)
|
||||||
|
controls = (dlg.cmd_insert, dlg.cmd_close)
|
||||||
|
dlg.center(controls)
|
||||||
|
|
||||||
|
return dlg
|
||||||
|
|
||||||
|
|
||||||
|
def from_dialog():
|
||||||
|
dlg = _create_dialog()
|
||||||
|
sel = app.selection
|
||||||
|
if hasattr(sel, 'description'):
|
||||||
|
dlg.text.value = sel.description
|
||||||
|
dlg.open()
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def run(args, path_locales):
|
||||||
|
global _
|
||||||
|
_ = app.install_locales(path_locales)
|
||||||
|
globals()[args]()
|
||||||
|
return
|
56
zaz.py
56
zaz.py
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
# ~ This file is part of ZAZ.
|
# ~ This file is part of ZAZ.
|
||||||
|
|
||||||
|
# ~ https://git.elmau.net/elmau/zaz
|
||||||
|
|
||||||
# ~ ZAZ is free software: you can redistribute it and/or modify
|
# ~ ZAZ is free software: you can redistribute it and/or modify
|
||||||
# ~ it under the terms of the GNU General Public License as published by
|
# ~ it under the terms of the GNU General Public License as published by
|
||||||
# ~ the Free Software Foundation, either version 3 of the License, or
|
# ~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
@ -44,6 +46,10 @@ from conf import (
|
||||||
log)
|
log)
|
||||||
|
|
||||||
|
|
||||||
|
EASYMACRO_TMP = 'easymacro2.py'
|
||||||
|
EASYMACRO = 'easymacro.py'
|
||||||
|
|
||||||
|
|
||||||
class LiboXML(object):
|
class LiboXML(object):
|
||||||
CONTEXT = {
|
CONTEXT = {
|
||||||
'calc': 'com.sun.star.sheet.SpreadsheetDocument',
|
'calc': 'com.sun.star.sheet.SpreadsheetDocument',
|
||||||
|
@ -549,7 +555,7 @@ def _update_files():
|
||||||
copyfile(source, target)
|
copyfile(source, target)
|
||||||
|
|
||||||
if FILES['easymacro']:
|
if FILES['easymacro']:
|
||||||
source = 'easymacro2.py'
|
source = EASYMACRO
|
||||||
target = _join(path_source, 'pythonpath', source)
|
target = _join(path_source, 'pythonpath', source)
|
||||||
copyfile(source, target)
|
copyfile(source, target)
|
||||||
|
|
||||||
|
@ -595,7 +601,7 @@ def _update_files():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def _new():
|
def _create():
|
||||||
if not _validate_new():
|
if not _validate_new():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -617,7 +623,6 @@ def _get_info_path(path):
|
||||||
|
|
||||||
def _zip_embed(source, files):
|
def _zip_embed(source, files):
|
||||||
PATH = 'Scripts/python/'
|
PATH = 'Scripts/python/'
|
||||||
EASYMACRO = 'easymacro2.py'
|
|
||||||
FILE_PYC = 'easymacro.pyc'
|
FILE_PYC = 'easymacro.pyc'
|
||||||
|
|
||||||
p, f, name, e = _get_info_path(source)
|
p, f, name, e = _get_info_path(source)
|
||||||
|
@ -693,8 +698,6 @@ def _embed(args):
|
||||||
|
|
||||||
|
|
||||||
def _locales(args):
|
def _locales(args):
|
||||||
EASYMACRO = 'easymacro2.py'
|
|
||||||
|
|
||||||
if args.files:
|
if args.files:
|
||||||
files = args.files.split(',')
|
files = args.files.split(',')
|
||||||
else:
|
else:
|
||||||
|
@ -726,8 +729,39 @@ def _update():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def _new(args):
|
||||||
|
if not args.target:
|
||||||
|
msg = 'Add argument target: -t PATH_TARGET'
|
||||||
|
log.error(msg)
|
||||||
|
return
|
||||||
|
|
||||||
|
if not args.name:
|
||||||
|
msg = 'Add argument name: -n name-new-extension'
|
||||||
|
log.error(msg)
|
||||||
|
return
|
||||||
|
|
||||||
|
path = _join(args.target, args.name)
|
||||||
|
_mkdir(path)
|
||||||
|
_mkdir(_join(path, 'files'))
|
||||||
|
_mkdir(_join(path, 'images'))
|
||||||
|
path_logo = 'images/pymacros.png'
|
||||||
|
copyfile(path_logo, _join(path, 'images/logo.png'))
|
||||||
|
copyfile('zaz.py', _join(path, 'zaz.py'))
|
||||||
|
copyfile(EASYMACRO_TMP, _join(path, 'easymacro.py'))
|
||||||
|
copyfile('conf.py.example', _join(path, 'conf.py'))
|
||||||
|
|
||||||
|
msg = 'Folders and files copy successfully for new extension.'
|
||||||
|
log.info(msg)
|
||||||
|
msg = f'Change to folder: {path}'
|
||||||
|
log.info(msg)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
|
if args.new:
|
||||||
|
_new(args)
|
||||||
|
return
|
||||||
|
|
||||||
if args.update:
|
if args.update:
|
||||||
_update()
|
_update()
|
||||||
return
|
return
|
||||||
|
@ -740,8 +774,8 @@ def main(args):
|
||||||
_embed(args)
|
_embed(args)
|
||||||
return
|
return
|
||||||
|
|
||||||
if args.new:
|
if args.create:
|
||||||
_new()
|
_create()
|
||||||
return
|
return
|
||||||
|
|
||||||
if not _validate_update():
|
if not _validate_update():
|
||||||
|
@ -762,9 +796,13 @@ def main(args):
|
||||||
def _process_command_line_arguments():
|
def _process_command_line_arguments():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Make LibreOffice extensions')
|
description='Make LibreOffice extensions')
|
||||||
parser.add_argument('-i', '--install', dest='install', action='store_true',
|
parser.add_argument('-new', '--new', dest='new', action='store_true',
|
||||||
default=False, required=False)
|
default=False, required=False)
|
||||||
parser.add_argument('-n', '--new', dest='new', action='store_true',
|
parser.add_argument('-t', '--target', dest='target', default='')
|
||||||
|
parser.add_argument('-n', '--name', dest='name', default='', required=False)
|
||||||
|
parser.add_argument('-c', '--create', dest='create', action='store_true',
|
||||||
|
default=False, required=False)
|
||||||
|
parser.add_argument('-i', '--install', dest='install', action='store_true',
|
||||||
default=False, required=False)
|
default=False, required=False)
|
||||||
parser.add_argument('-e', '--embed', dest='embed', action='store_true',
|
parser.add_argument('-e', '--embed', dest='embed', action='store_true',
|
||||||
default=False, required=False)
|
default=False, required=False)
|
||||||
|
|
Loading…
Reference in New Issue