Remove insert in draw and impress

This commit is contained in:
Mauricio Baeza 2020-12-23 22:35:47 -06:00
parent 490975b268
commit b3d8674a9e
1 changed files with 0 additions and 92 deletions

View File

@ -13,10 +13,6 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
def __init__(self, ctx):
self.ctx = ctx
# ~ self._data = ''
# ~ self._type = ''
# ~ self._ask = False
# ~ self._path = ''
def execute(self, args):
data = app.property_to_dict(args)
@ -42,94 +38,6 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
main.run(args, __file__)
return
def _create_code(self, path=''):
if not path:
path = app.get_temp_file(True)
if self._type == QR:
factory = svg.SvgImage
img = qrcode.make(self._data, border=2, image_factory=factory)
img.save(path)
else:
try:
path = generate(self._type, self._data, output=path)
except Exception as e:
app.error(e)
return str(e)
if app.is_created(path):
self._path = path
return ''
return _('Not generated')
def _get_values(self):
self._type = ''
dlg = self._create_dialog()
if dlg.open():
self._data = dlg.text.value.strip()
self._type = dlg.listbox.value
self._ask = True
return True
return False
def _insert_in_calc(self, doc):
cell = doc.get_cell()
if not self._data:
self._data = cell.value
if not self._data:
msg = _('Select data')
self._show_error(msg)
return
result = self._create_code()
if result:
self._show_error(result)
return
if not self._ask:
cell = cell.offset(0, 1)
cell.insert_image(self._path)
return
def _insert_in_writer(self, doc):
doc = app.get_document()
if not self._data:
sel = app.get_selection()
self._data = sel.string
if not self._data:
msg = _('Select data')
self._show_error(msg)
return
result = self._create_code()
if result:
self._show_error(result)
return
doc.insert_image(self._path)
return
def _insert_in_draw(self, doc):
result = self._create_code()
if result:
self._show_error(result)
return
doc.insert_image(self._path)
return
def _insert_in_impress(self, doc):
self._insert_in_draw(doc)
return
def _show_error(self, error):
msg = _('Error in: {}\n\n{}').format(self._type, error)
app.error(error)
app.errorbox(msg, TITLE)
return
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(ZAZBarCode, ID_EXTENSION, SERVICE)