zaz-barcode/source/ZAZBarCode.py

44 lines
1.0 KiB
Python

import gettext
import uno
import unohelper
from com.sun.star.task import XJobExecutor, XJob
import main
ID_EXTENSION = 'net.elmau.zaz.BarCode'
SERVICE = ('com.sun.star.task.Job',)
class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
def __init__(self, ctx):
self.ctx = ctx
def execute(self, args):
data = app.property_to_dict(args)
self._type = data['Type'].lower()
self._data = data['Data']
if 'Path' in data:
if not self._type == QR:
p, _, n, _ = app.get_info_path(data['Path'])
data['Path'] = app.join(p, n)
else:
data['Path'] = ''
result = self._create_code(data['Path'])
if result:
app.error(result)
self._path = ''
return self._path
def trigger(self, args):
main.ID_EXTENSION = ID_EXTENSION
main.run(args, __file__)
return
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(ZAZBarCode, ID_EXTENSION, SERVICE)