Call by code
This commit is contained in:
parent
ed56332bdd
commit
db57e3f6cd
|
@ -1,3 +1,8 @@
|
||||||
|
v 0.6.0 [15-nov-2019]
|
||||||
|
---------------------
|
||||||
|
- Call by code
|
||||||
|
|
||||||
|
|
||||||
v 0.5.0 [10-nov-2019]
|
v 0.5.0 [10-nov-2019]
|
||||||
---------------------
|
---------------------
|
||||||
- Update library easymacro.py
|
- Update library easymacro.py
|
||||||
|
|
|
@ -22,6 +22,11 @@ Barcodes provided
|
||||||
* qrcode
|
* qrcode
|
||||||
|
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
|
||||||
|
LibreOffice 6.2+ with support for Python macros
|
||||||
|
|
||||||
|
|
||||||
Thanks!
|
Thanks!
|
||||||
|
|
||||||
https://gitlab.com/mauriciobaeza/zaz
|
https://gitlab.com/mauriciobaeza/zaz
|
||||||
|
@ -36,9 +41,9 @@ https://github.com/lincolnloop/python-qrcode
|
||||||
|
|
||||||
This extension have a cost of maintenance of 1 euro every year.
|
This extension have a cost of maintenance of 1 euro every year.
|
||||||
|
|
||||||
BCH: `1RPLWHJW34p7pMQV1ft4x7eWhAYw69Dsb`
|
BCH: `qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d`
|
||||||
|
|
||||||
BTC: `3Fe4JuADrAK8Qs7GDAxbSXR8E54avwZJLW`
|
BTC: `3FhiXcXmAesmQzrNEngjHFnvaJRhU1AGWV`
|
||||||
|
|
||||||
|
|
||||||
* [Look the wiki](https://gitlab.com/mauriciobaeza/zaz-barcode/wikis/home)
|
* [Look the wiki](https://gitlab.com/mauriciobaeza/zaz-barcode/wikis/home)
|
||||||
|
|
2
conf.py
2
conf.py
|
@ -26,7 +26,7 @@ import logging
|
||||||
TYPE_EXTENSION = 1
|
TYPE_EXTENSION = 1
|
||||||
|
|
||||||
# ~ https://semver.org/
|
# ~ https://semver.org/
|
||||||
VERSION = '0.5.0'
|
VERSION = '0.6.0'
|
||||||
|
|
||||||
# ~ Your great extension name, not used spaces
|
# ~ Your great extension name, not used spaces
|
||||||
NAME = 'ZAZBarCode'
|
NAME = 'ZAZBarCode'
|
||||||
|
|
53
easymacro.py
53
easymacro.py
|
@ -34,6 +34,7 @@ import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import ssl
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
import threading
|
||||||
|
@ -268,6 +269,12 @@ def mri(obj):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def inspect(obj):
|
||||||
|
zaz = create_instance('net.elmau.zaz.inspect')
|
||||||
|
zaz.inspect(obj)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def catch_exception(f):
|
def catch_exception(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def func(*args, **kwargs):
|
def func(*args, **kwargs):
|
||||||
|
@ -443,12 +450,14 @@ def call_dispatch(url, args=()):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def get_temp_file():
|
def get_temp_file(only_name=False):
|
||||||
delete = True
|
delete = True
|
||||||
if IS_WIN:
|
if IS_WIN:
|
||||||
delete = False
|
delete = False
|
||||||
return tempfile.NamedTemporaryFile(delete=delete)
|
tmp = tempfile.NamedTemporaryFile(delete=delete)
|
||||||
|
if only_name:
|
||||||
|
tmp = tmp.name
|
||||||
|
return tmp
|
||||||
|
|
||||||
def _path_url(path):
|
def _path_url(path):
|
||||||
if path.startswith('file://'):
|
if path.startswith('file://'):
|
||||||
|
@ -1643,7 +1652,7 @@ class LODrawImpress(LODocument):
|
||||||
|
|
||||||
def insert_image(self, path, **kwargs):
|
def insert_image(self, path, **kwargs):
|
||||||
w = kwargs.get('width', 3000)
|
w = kwargs.get('width', 3000)
|
||||||
h = kwargs.get('Height', 1000)
|
h = kwargs.get('Height', 3000)
|
||||||
x = kwargs.get('X', 1000)
|
x = kwargs.get('X', 1000)
|
||||||
y = kwargs.get('Y', 1000)
|
y = kwargs.get('Y', 1000)
|
||||||
|
|
||||||
|
@ -2445,23 +2454,23 @@ class UnoBaseObject(object):
|
||||||
return self._model.Width
|
return self._model.Width
|
||||||
@width.setter
|
@width.setter
|
||||||
def width(self, value):
|
def width(self, value):
|
||||||
if hasattr(self.obj, 'PosSize'):
|
if hasattr(self.model, 'Width'):
|
||||||
|
self.model.Width = value
|
||||||
|
elif hasattr(self.obj, 'PosSize'):
|
||||||
self._set_possize('Width', value)
|
self._set_possize('Width', value)
|
||||||
else:
|
|
||||||
self._model.Width = value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def height(self):
|
def height(self):
|
||||||
if hasattr(self._model, 'Height'):
|
if hasattr(self.model, 'Height'):
|
||||||
return self._model.Height
|
return self.model.Height
|
||||||
ps = self.obj.getPosSize()
|
ps = self.obj.getPosSize()
|
||||||
return ps.Height
|
return ps.Height
|
||||||
@height.setter
|
@height.setter
|
||||||
def height(self, value):
|
def height(self, value):
|
||||||
if hasattr(self.obj, 'PosSize'):
|
if hasattr(self.model, 'Height'):
|
||||||
|
self.model.Height = value
|
||||||
|
elif hasattr(self.obj, 'PosSize'):
|
||||||
self._set_possize('Height', value)
|
self._set_possize('Height', value)
|
||||||
else:
|
|
||||||
self._model.Height = value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tag(self):
|
def tag(self):
|
||||||
|
@ -4206,8 +4215,12 @@ def json_loads(data):
|
||||||
|
|
||||||
|
|
||||||
def get_path_extension(id):
|
def get_path_extension(id):
|
||||||
|
path = ''
|
||||||
pip = CTX.getValueByName('/singletons/com.sun.star.deployment.PackageInformationProvider')
|
pip = CTX.getValueByName('/singletons/com.sun.star.deployment.PackageInformationProvider')
|
||||||
path = _path_system(pip.getPackageLocation(id))
|
try:
|
||||||
|
path = _path_system(pip.getPackageLocation(id))
|
||||||
|
except Exception as e:
|
||||||
|
error(e)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
@ -4404,23 +4417,29 @@ def popen(command, stdin=None):
|
||||||
yield (e.errno, e.strerror)
|
yield (e.errno, e.strerror)
|
||||||
|
|
||||||
|
|
||||||
def url_open(url, options={}, json=False):
|
def url_open(url, options={}, verify=True, json=False):
|
||||||
data = ''
|
data = ''
|
||||||
|
err = ''
|
||||||
req = Request(url)
|
req = Request(url)
|
||||||
try:
|
try:
|
||||||
response = urlopen(req)
|
if verify:
|
||||||
# ~ response.info()
|
response = urlopen(req)
|
||||||
|
else:
|
||||||
|
context = ssl._create_unverified_context()
|
||||||
|
response = urlopen(req, context=context)
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
error(e)
|
error(e)
|
||||||
|
err = str(e)
|
||||||
except URLError as e:
|
except URLError as e:
|
||||||
error(e.reason)
|
error(e.reason)
|
||||||
|
err = str(e.reason)
|
||||||
else:
|
else:
|
||||||
if json:
|
if json:
|
||||||
data = json_loads(response.read())
|
data = json_loads(response.read())
|
||||||
else:
|
else:
|
||||||
data = response.read()
|
data = response.read()
|
||||||
|
|
||||||
return data
|
return data, err
|
||||||
|
|
||||||
|
|
||||||
def run(command, wait=False):
|
def run(command, wait=False):
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -5,10 +5,10 @@
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
|
||||||
<identifier value="net.elmau.zaz.BarCode" />
|
<identifier value="net.elmau.zaz.BarCode" />
|
||||||
<version value="0.5.0" />
|
<version value="0.6.0" />
|
||||||
|
|
||||||
<update-download>
|
<update-download>
|
||||||
<src xlink:href="https://gitlab.com/mauriciobaeza/zaz-barcode/raw/master/files/ZAZBarCode_v0.5.0.oxt"/>
|
<src xlink:href="https://gitlab.com/mauriciobaeza/zaz-barcode/raw/master/files/ZAZBarCode_v0.6.0.oxt"/>
|
||||||
</update-download>
|
</update-download>
|
||||||
<release-notes>
|
<release-notes>
|
||||||
</release-notes>
|
</release-notes>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest:manifest manifest:version="1.2" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
|
<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" manifest:version="1.2">
|
||||||
<manifest:file-entry manifest:full-path="ZAZBarCode.py" manifest:media-type="application/vnd.sun.star.uno-component;type=Python"/>
|
<manifest:file-entry manifest:full-path="ZAZBarCode.py" manifest:media-type="application/vnd.sun.star.uno-component;type=Python"/>
|
||||||
<manifest:file-entry manifest:full-path="Office/Accelerators.xcu" manifest:media-type="application/vnd.sun.star.configuration-data"/>
|
<manifest:file-entry manifest:full-path="Office/Accelerators.xcu" manifest:media-type="application/vnd.sun.star.configuration-data"/>
|
||||||
<manifest:file-entry manifest:full-path="Addons.xcu" manifest:media-type="application/vnd.sun.star.configuration-data"/>
|
<manifest:file-entry manifest:full-path="Addons.xcu" manifest:media-type="application/vnd.sun.star.configuration-data"/>
|
||||||
|
|
|
@ -44,29 +44,32 @@ class Controllers(object):
|
||||||
|
|
||||||
|
|
||||||
class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
||||||
IMAGES = 'images'
|
|
||||||
|
|
||||||
def __init__(self, ctx):
|
def __init__(self, ctx):
|
||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
self._data = ''
|
self._data = ''
|
||||||
self._type = ''
|
self._type = ''
|
||||||
self._ask = False
|
self._ask = False
|
||||||
self.path_ext = app.get_path_extension(ID_EXTENSION)
|
self._path = ''
|
||||||
self.IMAGES = app.join(self.path_ext, self.IMAGES)
|
|
||||||
|
|
||||||
def execute(self, args):
|
def execute(self, args):
|
||||||
data = app.property_to_dict(args)
|
data = app.property_to_dict(args)
|
||||||
|
self._type = data['Type'].lower()
|
||||||
|
self._data = data['Data']
|
||||||
|
|
||||||
if data['Type'] == QR:
|
if 'Path' in data:
|
||||||
factory = svg.SvgImage
|
if not self._type == QR:
|
||||||
img = qrcode.make(data['Data'], image_factory=factory)
|
p, _, n, _ = app.get_info_path(data['Path'])
|
||||||
img.save(data['Path'])
|
data['Path'] = app.join(p, n)
|
||||||
else:
|
else:
|
||||||
try:
|
data['Path'] = ''
|
||||||
generate(data['Type'].lower(), data['Data'], output=data['Path'])
|
|
||||||
except Exception as e:
|
result = self._create_code(data['Path'])
|
||||||
app.debug(str(e))
|
if result:
|
||||||
return
|
app.error(result)
|
||||||
|
self._path = ''
|
||||||
|
|
||||||
|
return self._path
|
||||||
|
|
||||||
def trigger(self, args):
|
def trigger(self, args):
|
||||||
self._type = args
|
self._type = args
|
||||||
|
@ -75,21 +78,25 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
||||||
|
|
||||||
doc = app.get_document()
|
doc = app.get_document()
|
||||||
getattr(self, '_insert_in_{}'.format(doc.type))(doc)
|
getattr(self, '_insert_in_{}'.format(doc.type))(doc)
|
||||||
|
app.kill(self._path)
|
||||||
return
|
return
|
||||||
|
|
||||||
def _create_code(self, tmp_file):
|
def _create_code(self, path=''):
|
||||||
|
if not path:
|
||||||
|
path = app.get_temp_file(True)
|
||||||
if self._type == QR:
|
if self._type == QR:
|
||||||
factory = svg.SvgImage
|
factory = svg.SvgImage
|
||||||
img = qrcode.make(self._data, image_factory=factory)
|
img = qrcode.make(self._data, border=2, image_factory=factory)
|
||||||
img.save(tmp_file.name)
|
img.save(path)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
generate(self._type, self._data, output=tmp_file)
|
path = generate(self._type, self._data, output=path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
app.error(e)
|
app.error(e)
|
||||||
return str(e)
|
return str(e)
|
||||||
|
|
||||||
if app.is_created(tmp_file.name):
|
if app.is_created(path):
|
||||||
|
self._path = path
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
return _('Not generated')
|
return _('Not generated')
|
||||||
|
@ -114,57 +121,42 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
||||||
self._show_error(msg)
|
self._show_error(msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
tf = app.get_temp_file()
|
result = self._create_code()
|
||||||
result = self._create_code(tf)
|
|
||||||
if result:
|
if result:
|
||||||
tf.close()
|
|
||||||
self._show_error(result)
|
self._show_error(result)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self._ask:
|
if not self._ask:
|
||||||
cell = cell.offset(0, 1)
|
cell = cell.offset(0, 1)
|
||||||
if app.IS_WIN:
|
|
||||||
tf.close()
|
|
||||||
|
|
||||||
cell.insert_image(tf.name)
|
cell.insert_image(self._path)
|
||||||
tf.close()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _insert_in_writer(self, doc):
|
def _insert_in_writer(self, doc):
|
||||||
doc = app.get_document()
|
doc = app.get_document()
|
||||||
sel = app.get_selection()
|
|
||||||
if not self._data:
|
if not self._data:
|
||||||
|
sel = app.get_selection()
|
||||||
self._data = sel.string
|
self._data = sel.string
|
||||||
if not self._data:
|
if not self._data:
|
||||||
msg = _('Select data')
|
msg = _('Select data')
|
||||||
self._show_error(msg)
|
self._show_error(msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
tf = app.get_temp_file()
|
result = self._create_code()
|
||||||
result = self._create_code(tf)
|
|
||||||
if result:
|
if result:
|
||||||
tf.close()
|
|
||||||
self._show_error(result)
|
self._show_error(result)
|
||||||
return
|
return
|
||||||
|
|
||||||
if app.IS_WIN:
|
doc.insert_image(self._path)
|
||||||
tf.close()
|
|
||||||
doc.insert_image(tf.name)
|
|
||||||
tf.close()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _insert_in_draw(self, doc):
|
def _insert_in_draw(self, doc):
|
||||||
tf = app.get_temp_file()
|
result = self._create_code()
|
||||||
result = self._create_code(tf)
|
|
||||||
if result:
|
if result:
|
||||||
tf.close()
|
|
||||||
self._show_error(result)
|
self._show_error(result)
|
||||||
return
|
return
|
||||||
|
|
||||||
if app.IS_WIN:
|
doc.insert_image(self._path)
|
||||||
tf.close()
|
|
||||||
doc.insert_image(tf.name)
|
|
||||||
tf.close()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _insert_in_impress(self, doc):
|
def _insert_in_impress(self, doc):
|
||||||
|
@ -186,6 +178,7 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
||||||
}
|
}
|
||||||
dlg = app.create_dialog(args)
|
dlg = app.create_dialog(args)
|
||||||
dlg.events = Controllers(dlg)
|
dlg.events = Controllers(dlg)
|
||||||
|
dlg.id_extension = ID_EXTENSION
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
'Type': 'Label',
|
'Type': 'Label',
|
||||||
|
@ -238,7 +231,7 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
||||||
'Label': _('~Insert Barcode'),
|
'Label': _('~Insert Barcode'),
|
||||||
'Width': 70,
|
'Width': 70,
|
||||||
'Height': 15,
|
'Height': 15,
|
||||||
'ImageURL': app.join(self.IMAGES, 'qr.png'),
|
'ImageURL': 'qr.png',
|
||||||
'ImagePosition': 1,
|
'ImagePosition': 1,
|
||||||
}
|
}
|
||||||
dlg.add_control(args)
|
dlg.add_control(args)
|
||||||
|
|
|
@ -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.BarCode" />
|
<identifier value="net.elmau.zaz.BarCode" />
|
||||||
<version value="0.5.0" />
|
<version value="0.6.0" />
|
||||||
<display-name>
|
<display-name>
|
||||||
<name lang="en">ZAZ Bar Code</name>
|
<name lang="en">ZAZ Bar Code</name>
|
||||||
<name lang="es">ZAZ Códigos de Barras</name>
|
<name lang="es">ZAZ Códigos de Barras</name>
|
||||||
|
|
Binary file not shown.
|
@ -6,7 +6,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"POT-Creation-Date: 2019-11-10 15:06-0600\n"
|
"POT-Creation-Date: 2019-11-10 15:06-0600\n"
|
||||||
"PO-Revision-Date: 2019-11-10 15:26-0600\n"
|
"PO-Revision-Date: 2019-11-12 13:30-0600\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: eo\n"
|
"Language: eo\n"
|
||||||
|
@ -27,7 +27,7 @@ msgstr "Datumkampo estas deviga"
|
||||||
|
|
||||||
#: source/ZAZBarCode.py:91
|
#: source/ZAZBarCode.py:91
|
||||||
msgid "Not generated"
|
msgid "Not generated"
|
||||||
msgstr "Ne generita"
|
msgstr "Ne eligata"
|
||||||
|
|
||||||
#: source/ZAZBarCode.py:109 source/ZAZBarCode.py:135
|
#: source/ZAZBarCode.py:109 source/ZAZBarCode.py:135
|
||||||
msgid "Select data"
|
msgid "Select data"
|
||||||
|
|
|
@ -19,11 +19,6 @@ from barcode.upc import UPCA
|
||||||
from barcode.itf import ITF
|
from barcode.itf import ITF
|
||||||
from barcode.version import version # noqa: F401
|
from barcode.version import version # noqa: F401
|
||||||
|
|
||||||
try:
|
|
||||||
_strbase = basestring # lint:ok
|
|
||||||
except NameError:
|
|
||||||
_strbase = str
|
|
||||||
|
|
||||||
|
|
||||||
__BARCODE_MAP = dict(
|
__BARCODE_MAP = dict(
|
||||||
ean8=EAN8,
|
ean8=EAN8,
|
||||||
|
@ -73,7 +68,7 @@ def generate(name, code, writer=None, output=None, writer_options=None,
|
||||||
barcode = get(name, code, writer, options)
|
barcode = get(name, code, writer, options)
|
||||||
if pil:
|
if pil:
|
||||||
return barcode.render(writer_options, text)
|
return barcode.render(writer_options, text)
|
||||||
if isinstance(output, _strbase):
|
if isinstance(output, str):
|
||||||
fullname = barcode.save(output, options, text)
|
fullname = barcode.save(output, options, text)
|
||||||
return fullname
|
return fullname
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -34,6 +34,7 @@ import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import ssl
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
import threading
|
||||||
|
@ -268,6 +269,12 @@ def mri(obj):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def inspect(obj):
|
||||||
|
zaz = create_instance('net.elmau.zaz.inspect')
|
||||||
|
zaz.inspect(obj)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def catch_exception(f):
|
def catch_exception(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def func(*args, **kwargs):
|
def func(*args, **kwargs):
|
||||||
|
@ -443,12 +450,14 @@ def call_dispatch(url, args=()):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def get_temp_file():
|
def get_temp_file(only_name=False):
|
||||||
delete = True
|
delete = True
|
||||||
if IS_WIN:
|
if IS_WIN:
|
||||||
delete = False
|
delete = False
|
||||||
return tempfile.NamedTemporaryFile(delete=delete)
|
tmp = tempfile.NamedTemporaryFile(delete=delete)
|
||||||
|
if only_name:
|
||||||
|
tmp = tmp.name
|
||||||
|
return tmp
|
||||||
|
|
||||||
def _path_url(path):
|
def _path_url(path):
|
||||||
if path.startswith('file://'):
|
if path.startswith('file://'):
|
||||||
|
@ -1643,7 +1652,7 @@ class LODrawImpress(LODocument):
|
||||||
|
|
||||||
def insert_image(self, path, **kwargs):
|
def insert_image(self, path, **kwargs):
|
||||||
w = kwargs.get('width', 3000)
|
w = kwargs.get('width', 3000)
|
||||||
h = kwargs.get('Height', 1000)
|
h = kwargs.get('Height', 3000)
|
||||||
x = kwargs.get('X', 1000)
|
x = kwargs.get('X', 1000)
|
||||||
y = kwargs.get('Y', 1000)
|
y = kwargs.get('Y', 1000)
|
||||||
|
|
||||||
|
@ -2445,23 +2454,23 @@ class UnoBaseObject(object):
|
||||||
return self._model.Width
|
return self._model.Width
|
||||||
@width.setter
|
@width.setter
|
||||||
def width(self, value):
|
def width(self, value):
|
||||||
if hasattr(self.obj, 'PosSize'):
|
if hasattr(self.model, 'Width'):
|
||||||
|
self.model.Width = value
|
||||||
|
elif hasattr(self.obj, 'PosSize'):
|
||||||
self._set_possize('Width', value)
|
self._set_possize('Width', value)
|
||||||
else:
|
|
||||||
self._model.Width = value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def height(self):
|
def height(self):
|
||||||
if hasattr(self._model, 'Height'):
|
if hasattr(self.model, 'Height'):
|
||||||
return self._model.Height
|
return self.model.Height
|
||||||
ps = self.obj.getPosSize()
|
ps = self.obj.getPosSize()
|
||||||
return ps.Height
|
return ps.Height
|
||||||
@height.setter
|
@height.setter
|
||||||
def height(self, value):
|
def height(self, value):
|
||||||
if hasattr(self.obj, 'PosSize'):
|
if hasattr(self.model, 'Height'):
|
||||||
|
self.model.Height = value
|
||||||
|
elif hasattr(self.obj, 'PosSize'):
|
||||||
self._set_possize('Height', value)
|
self._set_possize('Height', value)
|
||||||
else:
|
|
||||||
self._model.Height = value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tag(self):
|
def tag(self):
|
||||||
|
@ -4206,8 +4215,12 @@ def json_loads(data):
|
||||||
|
|
||||||
|
|
||||||
def get_path_extension(id):
|
def get_path_extension(id):
|
||||||
|
path = ''
|
||||||
pip = CTX.getValueByName('/singletons/com.sun.star.deployment.PackageInformationProvider')
|
pip = CTX.getValueByName('/singletons/com.sun.star.deployment.PackageInformationProvider')
|
||||||
path = _path_system(pip.getPackageLocation(id))
|
try:
|
||||||
|
path = _path_system(pip.getPackageLocation(id))
|
||||||
|
except Exception as e:
|
||||||
|
error(e)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
@ -4404,23 +4417,29 @@ def popen(command, stdin=None):
|
||||||
yield (e.errno, e.strerror)
|
yield (e.errno, e.strerror)
|
||||||
|
|
||||||
|
|
||||||
def url_open(url, options={}, json=False):
|
def url_open(url, options={}, verify=True, json=False):
|
||||||
data = ''
|
data = ''
|
||||||
|
err = ''
|
||||||
req = Request(url)
|
req = Request(url)
|
||||||
try:
|
try:
|
||||||
response = urlopen(req)
|
if verify:
|
||||||
# ~ response.info()
|
response = urlopen(req)
|
||||||
|
else:
|
||||||
|
context = ssl._create_unverified_context()
|
||||||
|
response = urlopen(req, context=context)
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
error(e)
|
error(e)
|
||||||
|
err = str(e)
|
||||||
except URLError as e:
|
except URLError as e:
|
||||||
error(e.reason)
|
error(e.reason)
|
||||||
|
err = str(e.reason)
|
||||||
else:
|
else:
|
||||||
if json:
|
if json:
|
||||||
data = json_loads(response.read())
|
data = json_loads(response.read())
|
||||||
else:
|
else:
|
||||||
data = response.read()
|
data = response.read()
|
||||||
|
|
||||||
return data
|
return data, err
|
||||||
|
|
||||||
|
|
||||||
def run(command, wait=False):
|
def run(command, wait=False):
|
||||||
|
|
Loading…
Reference in New Issue