Test install numpy
This commit is contained in:
commit
ebd4f74e79
10
CHANGELOG
10
CHANGELOG
|
@ -1,3 +1,13 @@
|
||||||
|
v 0.3.0 [12-nov-2019]
|
||||||
|
- Update easymacro.py
|
||||||
|
- Test install numpy
|
||||||
|
|
||||||
|
|
||||||
|
v 0.2.0 [18-oct-2019]
|
||||||
|
---------------------
|
||||||
|
- Add spanish
|
||||||
|
|
||||||
|
|
||||||
v 0.1.0 [18-oct-2019]
|
v 0.1.0 [18-oct-2019]
|
||||||
---------------------
|
---------------------
|
||||||
- Initial version
|
- Initial version
|
||||||
|
|
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.2.0'
|
VERSION = '0.3.0'
|
||||||
|
|
||||||
# ~ Your great extension name, not used spaces
|
# ~ Your great extension name, not used spaces
|
||||||
NAME = 'ZAZPip'
|
NAME = 'ZAZPip'
|
||||||
|
|
109
easymacro.py
109
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
|
||||||
|
@ -41,13 +42,9 @@ import time
|
||||||
import traceback
|
import traceback
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
# ~ from collections import OrderedDict
|
|
||||||
# ~ from collections.abc import MutableMapping
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from operator import itemgetter
|
|
||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from enum import Enum, IntEnum
|
|
||||||
from urllib.request import Request, urlopen
|
from urllib.request import Request, urlopen
|
||||||
from urllib.error import URLError, HTTPError
|
from urllib.error import URLError, HTTPError
|
||||||
from string import Template
|
from string import Template
|
||||||
|
@ -96,15 +93,6 @@ from com.sun.star.awt.grid import XGridDataListener
|
||||||
from com.sun.star.awt.grid import XGridSelectionListener
|
from com.sun.star.awt.grid import XGridSelectionListener
|
||||||
|
|
||||||
|
|
||||||
class FontSlant(IntEnum):
|
|
||||||
NONE = 0
|
|
||||||
OBLIQUE = 1
|
|
||||||
ITALIC = 2
|
|
||||||
DONTKNOW = 3
|
|
||||||
REVERSE_OBLIQUE = 4
|
|
||||||
REVERSE_ITALIC = 5
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from fernet import Fernet, InvalidToken
|
from fernet import Fernet, InvalidToken
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -124,7 +112,6 @@ KEY = {
|
||||||
|
|
||||||
SEPARATION = 5
|
SEPARATION = 5
|
||||||
|
|
||||||
|
|
||||||
MSG_LANG = {
|
MSG_LANG = {
|
||||||
'es': {
|
'es': {
|
||||||
'OK': 'Aceptar',
|
'OK': 'Aceptar',
|
||||||
|
@ -135,35 +122,36 @@ MSG_LANG = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OS = platform.system()
|
OS = platform.system()
|
||||||
USER = getpass.getuser()
|
USER = getpass.getuser()
|
||||||
PC = platform.node()
|
PC = platform.node()
|
||||||
DESKTOP = os.environ.get('DESKTOP_SESSION', '')
|
DESKTOP = os.environ.get('DESKTOP_SESSION', '')
|
||||||
INFO_DEBUG = '{}\n\n{}\n\n{}'.format(sys.version, platform.platform(), '\n'.join(sys.path))
|
INFO_DEBUG = '{}\n\n{}\n\n{}'.format(sys.version, platform.platform(), '\n'.join(sys.path))
|
||||||
|
|
||||||
|
|
||||||
IS_WIN = OS == 'Windows'
|
IS_WIN = OS == 'Windows'
|
||||||
LOG_NAME = 'ZAZ'
|
LOG_NAME = 'ZAZ'
|
||||||
CLIPBOARD_FORMAT_TEXT = 'text/plain;charset=utf-16'
|
CLIPBOARD_FORMAT_TEXT = 'text/plain;charset=utf-16'
|
||||||
|
|
||||||
|
|
||||||
PYTHON = 'python'
|
PYTHON = 'python'
|
||||||
if IS_WIN:
|
if IS_WIN:
|
||||||
PYTHON = 'python.exe'
|
PYTHON = 'python.exe'
|
||||||
CALC = 'calc'
|
CALC = 'calc'
|
||||||
WRITER = 'writer'
|
WRITER = 'writer'
|
||||||
|
|
||||||
OBJ_CELL = 'ScCellObj'
|
OBJ_CELL = 'ScCellObj'
|
||||||
OBJ_RANGE = 'ScCellRangeObj'
|
OBJ_RANGE = 'ScCellRangeObj'
|
||||||
OBJ_RANGES = 'ScCellRangesObj'
|
OBJ_RANGES = 'ScCellRangesObj'
|
||||||
OBJ_TYPE_RANGES = (OBJ_CELL, OBJ_RANGE, OBJ_RANGES)
|
OBJ_TYPE_RANGES = (OBJ_CELL, OBJ_RANGE, OBJ_RANGES)
|
||||||
|
|
||||||
|
TEXT_RANGE = 'SwXTextRange'
|
||||||
|
TEXT_RANGES = 'SwXTextRanges'
|
||||||
|
TEXT_TYPE_RANGES = (TEXT_RANGE, TEXT_RANGES)
|
||||||
|
|
||||||
TYPE_DOC = {
|
TYPE_DOC = {
|
||||||
'calc': 'com.sun.star.sheet.SpreadsheetDocument',
|
'calc': 'com.sun.star.sheet.SpreadsheetDocument',
|
||||||
'writer': 'com.sun.star.text.TextDocument',
|
'writer': 'com.sun.star.text.TextDocument',
|
||||||
'impress': 'com.sun.star.presentation.PresentationDocument',
|
'impress': 'com.sun.star.presentation.PresentationDocument',
|
||||||
'draw': 'com.sun.star.drawing.DrawingDocument',
|
'draw': 'com.sun.star.drawing.DrawingDocument',
|
||||||
# ~ 'base': 'com.sun.star.sdb.OfficeDatabaseDocument',
|
|
||||||
'base': 'com.sun.star.sdb.DocumentDataSource',
|
'base': 'com.sun.star.sdb.DocumentDataSource',
|
||||||
'math': 'com.sun.star.formula.FormulaProperties',
|
'math': 'com.sun.star.formula.FormulaProperties',
|
||||||
'basic': 'com.sun.star.script.BasicIDE',
|
'basic': 'com.sun.star.script.BasicIDE',
|
||||||
|
@ -202,19 +190,16 @@ MENUS_WRITER = {
|
||||||
'windows': '.uno:WindowList',
|
'windows': '.uno:WindowList',
|
||||||
'help': '.uno:HelpMenu',
|
'help': '.uno:HelpMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
MENUS_APP = {
|
MENUS_APP = {
|
||||||
'main': MENUS_MAIN,
|
'main': MENUS_MAIN,
|
||||||
'calc': MENUS_CALC,
|
'calc': MENUS_CALC,
|
||||||
'writer': MENUS_WRITER,
|
'writer': MENUS_WRITER,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EXT = {
|
EXT = {
|
||||||
'pdf': 'pdf',
|
'pdf': 'pdf',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FILE_NAME_DEBUG = 'debug.odt'
|
FILE_NAME_DEBUG = 'debug.odt'
|
||||||
FILE_NAME_CONFIG = 'zaz-{}.json'
|
FILE_NAME_CONFIG = 'zaz-{}.json'
|
||||||
LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
|
LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
|
||||||
|
@ -284,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):
|
||||||
|
@ -1008,7 +999,9 @@ class LOCalc(LODocument):
|
||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
if isinstance(index, str):
|
if isinstance(index, str):
|
||||||
index = [s.Name for s in self._sheets if s.CodeName == index][0] or index
|
code_name = [s.Name for s in self._sheets if s.CodeName == index]
|
||||||
|
if code_name:
|
||||||
|
index = code_name[0]
|
||||||
return LOCalcSheet(self._sheets[index], self)
|
return LOCalcSheet(self._sheets[index], self)
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
|
@ -1376,7 +1369,11 @@ class LOWriter(LODocument):
|
||||||
@property
|
@property
|
||||||
def selection(self):
|
def selection(self):
|
||||||
sel = self.obj.getCurrentSelection()
|
sel = self.obj.getCurrentSelection()
|
||||||
return LOTextRange(sel[0])
|
if sel.ImplementationName == TEXT_RANGES:
|
||||||
|
return LOTextRange(sel[0])
|
||||||
|
elif sel.ImplementationName == TEXT_RANGE:
|
||||||
|
return LOTextRange(sel)
|
||||||
|
return sel
|
||||||
|
|
||||||
def write(self, data, cursor=None):
|
def write(self, data, cursor=None):
|
||||||
cursor = cursor or self.selection.cursor.getEnd()
|
cursor = cursor or self.selection.cursor.getEnd()
|
||||||
|
@ -1710,6 +1707,9 @@ class LOCellRange(object):
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
return LOCellRange(self.obj[index], self.doc)
|
return LOCellRange(self.obj[index], self.doc)
|
||||||
|
|
||||||
|
def __contains__(self, item):
|
||||||
|
return item.in_range(self)
|
||||||
|
|
||||||
def _init_values(self):
|
def _init_values(self):
|
||||||
self._type_obj = self.obj.ImplementationName
|
self._type_obj = self.obj.ImplementationName
|
||||||
self._type_content = EMPTY
|
self._type_content = EMPTY
|
||||||
|
@ -1759,7 +1759,7 @@ class LOCellRange(object):
|
||||||
self.obj.setFormula(data)
|
self.obj.setFormula(data)
|
||||||
else:
|
else:
|
||||||
self.obj.setString(data)
|
self.obj.setString(data)
|
||||||
elif isinstance(data, (int, float)):
|
elif isinstance(data, (int, float, bool)):
|
||||||
self.obj.setValue(data)
|
self.obj.setValue(data)
|
||||||
elif isinstance(data, datetime.datetime):
|
elif isinstance(data, datetime.datetime):
|
||||||
d = data.toordinal()
|
d = data.toordinal()
|
||||||
|
@ -1777,8 +1777,6 @@ class LOCellRange(object):
|
||||||
return self.obj.getDataArray()
|
return self.obj.getDataArray()
|
||||||
@data.setter
|
@data.setter
|
||||||
def data(self, values):
|
def data(self, values):
|
||||||
if isinstance(values, list):
|
|
||||||
values = tuple(values)
|
|
||||||
self.obj.setDataArray(values)
|
self.obj.setDataArray(values)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1786,8 +1784,6 @@ class LOCellRange(object):
|
||||||
return self.obj.getFormulaArray()
|
return self.obj.getFormulaArray()
|
||||||
@formula.setter
|
@formula.setter
|
||||||
def formula(self, values):
|
def formula(self, values):
|
||||||
if isinstance(values, list):
|
|
||||||
values = tuple(values)
|
|
||||||
self.obj.setFormulaArray(values)
|
self.obj.setFormulaArray(values)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1812,13 +1808,19 @@ class LOCellRange(object):
|
||||||
cursor.collapseToSize(cols, rows)
|
cursor.collapseToSize(cols, rows)
|
||||||
return LOCellRange(self.sheet[cursor.AbsoluteName].obj, self.doc)
|
return LOCellRange(self.sheet[cursor.AbsoluteName].obj, self.doc)
|
||||||
|
|
||||||
def copy_from(self, rango):
|
def copy_from(self, rango, formula=False):
|
||||||
data = rango
|
data = rango
|
||||||
if isinstance(rango, LOCellRange):
|
if isinstance(rango, LOCellRange):
|
||||||
data = rango.data
|
if formula:
|
||||||
|
data = rango.formula
|
||||||
|
else:
|
||||||
|
data = rango.data
|
||||||
rows = len(data)
|
rows = len(data)
|
||||||
cols = len(data[0])
|
cols = len(data[0])
|
||||||
self.to_size(rows, cols).data = data
|
if formula:
|
||||||
|
self.to_size(rows, cols).formula = data
|
||||||
|
else:
|
||||||
|
self.to_size(rows, cols).data = data
|
||||||
return
|
return
|
||||||
|
|
||||||
def copy_to(self, cell, formula=False):
|
def copy_to(self, cell, formula=False):
|
||||||
|
@ -2178,7 +2180,10 @@ class EventsItem(EventsListenerBase, XItemListener):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def itemStateChanged(self, event):
|
def itemStateChanged(self, event):
|
||||||
pass
|
event_name = '{}_item_changed'.format(self.name)
|
||||||
|
if hasattr(self._controller, event_name):
|
||||||
|
getattr(self._controller, event_name)(event)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class EventsItemRoadmap(EventsItem):
|
class EventsItemRoadmap(EventsItem):
|
||||||
|
@ -2447,23 +2452,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):
|
||||||
|
@ -2526,8 +2531,12 @@ class UnoBaseObject(object):
|
||||||
def move(self, origin, x=0, y=5):
|
def move(self, origin, x=0, y=5):
|
||||||
if x:
|
if x:
|
||||||
self.x = origin.x + origin.width + x
|
self.x = origin.x + origin.width + x
|
||||||
|
else:
|
||||||
|
self.x = origin.x
|
||||||
if y:
|
if y:
|
||||||
self.y = origin.y + origin.height + y
|
self.y = origin.y + origin.height + y
|
||||||
|
else:
|
||||||
|
self.y = origin.y
|
||||||
return
|
return
|
||||||
|
|
||||||
def possize(self, origin):
|
def possize(self, origin):
|
||||||
|
@ -2771,7 +2780,6 @@ class UnoGrid(UnoBaseObject):
|
||||||
|
|
||||||
def sort(self, column, asc=True):
|
def sort(self, column, asc=True):
|
||||||
self._gdm.sortByColumn(column, asc)
|
self._gdm.sortByColumn(column, asc)
|
||||||
# ~ self._data.sort(key=itemgetter(column), reverse=not asc)
|
|
||||||
self.update_row_heading()
|
self.update_row_heading()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -3022,7 +3030,6 @@ def get_control_model(control):
|
||||||
return services[control]
|
return services[control]
|
||||||
|
|
||||||
|
|
||||||
@catch_exception
|
|
||||||
def add_listeners(events, control, name=''):
|
def add_listeners(events, control, name=''):
|
||||||
listeners = {
|
listeners = {
|
||||||
'addActionListener': EventsButton,
|
'addActionListener': EventsButton,
|
||||||
|
@ -3446,6 +3453,7 @@ class LOChart(object):
|
||||||
chart_data.setData(data)
|
chart_data.setData(data)
|
||||||
chart_data.RowDescriptions = labels
|
chart_data.RowDescriptions = labels
|
||||||
|
|
||||||
|
# ~ Bug
|
||||||
if tipo == 'Pie':
|
if tipo == 'Pie':
|
||||||
chart.setDiagram(chart.createInstance(self.BASE.format('Bar')))
|
chart.setDiagram(chart.createInstance(self.BASE.format('Bar')))
|
||||||
chart.setDiagram(chart.createInstance(self.BASE.format('Pie')))
|
chart.setDiagram(chart.createInstance(self.BASE.format('Pie')))
|
||||||
|
@ -3890,7 +3898,6 @@ class LOWindow(object):
|
||||||
|
|
||||||
return properties
|
return properties
|
||||||
|
|
||||||
@catch_exception
|
|
||||||
def add_control(self, properties):
|
def add_control(self, properties):
|
||||||
tipo = properties.pop('Type').lower()
|
tipo = properties.pop('Type').lower()
|
||||||
root = properties.pop('Root', '')
|
root = properties.pop('Root', '')
|
||||||
|
@ -4404,23 +4411,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):
|
||||||
|
@ -5397,8 +5410,6 @@ class LIBOServer(object):
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ~ controls = {
|
# ~ controls = {
|
||||||
# ~ 'CheckBox': 'com.sun.star.awt.UnoControlCheckBoxModel',
|
# ~ 'CheckBox': 'com.sun.star.awt.UnoControlCheckBoxModel',
|
||||||
# ~ 'ComboBox': 'com.sun.star.awt.UnoControlComboBoxModel',
|
# ~ 'ComboBox': 'com.sun.star.awt.UnoControlComboBoxModel',
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -16,6 +16,7 @@ PIP = 'pip'
|
||||||
PACKAGES = {
|
PACKAGES = {
|
||||||
'psycopg2-binary': 'ok.png',
|
'psycopg2-binary': 'ok.png',
|
||||||
'peewee': 'ok.png',
|
'peewee': 'ok.png',
|
||||||
|
'numpy': 'ok.png',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,10 +63,10 @@ class Controllers(object):
|
||||||
path_pip = f.name
|
path_pip = f.name
|
||||||
|
|
||||||
self.d.lst_log.insert('Download PIP...')
|
self.d.lst_log.insert('Download PIP...')
|
||||||
data = app.url_open(URL_PIP)
|
data, err = app.url_open(URL_PIP, verify=False)
|
||||||
if not data:
|
if err:
|
||||||
msg = _('Do you have internet connection?')
|
msg = _('Do you have internet connection?')
|
||||||
app.errorbox(msg)
|
app.errorbox('{}\n\n{}'.format(msg, err))
|
||||||
return
|
return
|
||||||
|
|
||||||
app.save_file(path_pip, 'wb', data)
|
app.save_file(path_pip, 'wb', data)
|
||||||
|
@ -486,13 +487,13 @@ class ZAZPip(unohelper.Base, XJobExecutor):
|
||||||
|
|
||||||
controls = (dialog.cmd_home, dialog.cmd_search,
|
controls = (dialog.cmd_home, dialog.cmd_search,
|
||||||
dialog.cmd_uninstall, dialog.cmd_shell)
|
dialog.cmd_uninstall, dialog.cmd_shell)
|
||||||
dialog.center(controls)
|
dialog.lbl_package.move(dialog.cmd_home)
|
||||||
|
dialog.txt_search.move(dialog.lbl_package)
|
||||||
|
dialog.lst_package.move(dialog.txt_search)
|
||||||
dialog.lbl_package.center()
|
dialog.lbl_package.center()
|
||||||
dialog.lst_package.center()
|
dialog.lst_package.center()
|
||||||
dialog.txt_search.center()
|
dialog.txt_search.center()
|
||||||
dialog.lbl_package.move(dialog.cmd_search)
|
dialog.center(controls)
|
||||||
dialog.txt_search.move(dialog.lbl_package)
|
|
||||||
dialog.lst_package.move(dialog.txt_search)
|
|
||||||
|
|
||||||
dialog.step = 10
|
dialog.step = 10
|
||||||
|
|
||||||
|
|
|
@ -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.pip" />
|
<identifier value="net.elmau.zaz.pip" />
|
||||||
<version value="0.2.0" />
|
<version value="0.3.0" />
|
||||||
<display-name>
|
<display-name>
|
||||||
<name lang="en">ZAZ Pip</name>
|
<name lang="en">ZAZ Pip</name>
|
||||||
<name lang="es">ZAZ Pip</name>
|
<name lang="es">ZAZ Pip</name>
|
||||||
|
|
|
@ -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
|
||||||
|
@ -41,13 +42,9 @@ import time
|
||||||
import traceback
|
import traceback
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
# ~ from collections import OrderedDict
|
|
||||||
# ~ from collections.abc import MutableMapping
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from operator import itemgetter
|
|
||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from enum import IntEnum
|
|
||||||
from urllib.request import Request, urlopen
|
from urllib.request import Request, urlopen
|
||||||
from urllib.error import URLError, HTTPError
|
from urllib.error import URLError, HTTPError
|
||||||
from string import Template
|
from string import Template
|
||||||
|
@ -92,14 +89,9 @@ from com.sun.star.awt import XKeyListener
|
||||||
from com.sun.star.awt import XItemListener
|
from com.sun.star.awt import XItemListener
|
||||||
from com.sun.star.awt import XFocusListener
|
from com.sun.star.awt import XFocusListener
|
||||||
from com.sun.star.awt import XTabListener
|
from com.sun.star.awt import XTabListener
|
||||||
|
from com.sun.star.awt.grid import XGridDataListener
|
||||||
|
from com.sun.star.awt.grid import XGridSelectionListener
|
||||||
|
|
||||||
class FontSlant(IntEnum):
|
|
||||||
NONE = 0
|
|
||||||
OBLIQUE = 1
|
|
||||||
ITALIC = 2
|
|
||||||
DONTKNOW = 3
|
|
||||||
REVERSE_OBLIQUE = 4
|
|
||||||
REVERSE_ITALIC = 5
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from fernet import Fernet, InvalidToken
|
from fernet import Fernet, InvalidToken
|
||||||
|
@ -120,7 +112,6 @@ KEY = {
|
||||||
|
|
||||||
SEPARATION = 5
|
SEPARATION = 5
|
||||||
|
|
||||||
|
|
||||||
MSG_LANG = {
|
MSG_LANG = {
|
||||||
'es': {
|
'es': {
|
||||||
'OK': 'Aceptar',
|
'OK': 'Aceptar',
|
||||||
|
@ -131,35 +122,36 @@ MSG_LANG = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OS = platform.system()
|
OS = platform.system()
|
||||||
USER = getpass.getuser()
|
USER = getpass.getuser()
|
||||||
PC = platform.node()
|
PC = platform.node()
|
||||||
DESKTOP = os.environ.get('DESKTOP_SESSION', '')
|
DESKTOP = os.environ.get('DESKTOP_SESSION', '')
|
||||||
INFO_DEBUG = '{}\n\n{}\n\n{}'.format(sys.version, platform.platform(), '\n'.join(sys.path))
|
INFO_DEBUG = '{}\n\n{}\n\n{}'.format(sys.version, platform.platform(), '\n'.join(sys.path))
|
||||||
|
|
||||||
|
|
||||||
IS_WIN = OS == 'Windows'
|
IS_WIN = OS == 'Windows'
|
||||||
LOG_NAME = 'ZAZ'
|
LOG_NAME = 'ZAZ'
|
||||||
CLIPBOARD_FORMAT_TEXT = 'text/plain;charset=utf-16'
|
CLIPBOARD_FORMAT_TEXT = 'text/plain;charset=utf-16'
|
||||||
|
|
||||||
|
|
||||||
PYTHON = 'python'
|
PYTHON = 'python'
|
||||||
if IS_WIN:
|
if IS_WIN:
|
||||||
PYTHON = 'python.exe'
|
PYTHON = 'python.exe'
|
||||||
CALC = 'calc'
|
CALC = 'calc'
|
||||||
WRITER = 'writer'
|
WRITER = 'writer'
|
||||||
|
|
||||||
OBJ_CELL = 'ScCellObj'
|
OBJ_CELL = 'ScCellObj'
|
||||||
OBJ_RANGE = 'ScCellRangeObj'
|
OBJ_RANGE = 'ScCellRangeObj'
|
||||||
OBJ_RANGES = 'ScCellRangesObj'
|
OBJ_RANGES = 'ScCellRangesObj'
|
||||||
OBJ_TYPE_RANGES = (OBJ_CELL, OBJ_RANGE, OBJ_RANGES)
|
OBJ_TYPE_RANGES = (OBJ_CELL, OBJ_RANGE, OBJ_RANGES)
|
||||||
|
|
||||||
|
TEXT_RANGE = 'SwXTextRange'
|
||||||
|
TEXT_RANGES = 'SwXTextRanges'
|
||||||
|
TEXT_TYPE_RANGES = (TEXT_RANGE, TEXT_RANGES)
|
||||||
|
|
||||||
TYPE_DOC = {
|
TYPE_DOC = {
|
||||||
'calc': 'com.sun.star.sheet.SpreadsheetDocument',
|
'calc': 'com.sun.star.sheet.SpreadsheetDocument',
|
||||||
'writer': 'com.sun.star.text.TextDocument',
|
'writer': 'com.sun.star.text.TextDocument',
|
||||||
'impress': 'com.sun.star.presentation.PresentationDocument',
|
'impress': 'com.sun.star.presentation.PresentationDocument',
|
||||||
'draw': 'com.sun.star.drawing.DrawingDocument',
|
'draw': 'com.sun.star.drawing.DrawingDocument',
|
||||||
# ~ 'base': 'com.sun.star.sdb.OfficeDatabaseDocument',
|
|
||||||
'base': 'com.sun.star.sdb.DocumentDataSource',
|
'base': 'com.sun.star.sdb.DocumentDataSource',
|
||||||
'math': 'com.sun.star.formula.FormulaProperties',
|
'math': 'com.sun.star.formula.FormulaProperties',
|
||||||
'basic': 'com.sun.star.script.BasicIDE',
|
'basic': 'com.sun.star.script.BasicIDE',
|
||||||
|
@ -198,19 +190,16 @@ MENUS_WRITER = {
|
||||||
'windows': '.uno:WindowList',
|
'windows': '.uno:WindowList',
|
||||||
'help': '.uno:HelpMenu',
|
'help': '.uno:HelpMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
MENUS_APP = {
|
MENUS_APP = {
|
||||||
'main': MENUS_MAIN,
|
'main': MENUS_MAIN,
|
||||||
'calc': MENUS_CALC,
|
'calc': MENUS_CALC,
|
||||||
'writer': MENUS_WRITER,
|
'writer': MENUS_WRITER,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EXT = {
|
EXT = {
|
||||||
'pdf': 'pdf',
|
'pdf': 'pdf',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FILE_NAME_DEBUG = 'debug.odt'
|
FILE_NAME_DEBUG = 'debug.odt'
|
||||||
FILE_NAME_CONFIG = 'zaz-{}.json'
|
FILE_NAME_CONFIG = 'zaz-{}.json'
|
||||||
LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
|
LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
|
||||||
|
@ -280,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):
|
||||||
|
@ -1004,7 +999,9 @@ class LOCalc(LODocument):
|
||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
if isinstance(index, str):
|
if isinstance(index, str):
|
||||||
index = [s.Name for s in self._sheets if s.CodeName == index][0] or index
|
code_name = [s.Name for s in self._sheets if s.CodeName == index]
|
||||||
|
if code_name:
|
||||||
|
index = code_name[0]
|
||||||
return LOCalcSheet(self._sheets[index], self)
|
return LOCalcSheet(self._sheets[index], self)
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
|
@ -1372,7 +1369,11 @@ class LOWriter(LODocument):
|
||||||
@property
|
@property
|
||||||
def selection(self):
|
def selection(self):
|
||||||
sel = self.obj.getCurrentSelection()
|
sel = self.obj.getCurrentSelection()
|
||||||
return LOTextRange(sel[0])
|
if sel.ImplementationName == TEXT_RANGES:
|
||||||
|
return LOTextRange(sel[0])
|
||||||
|
elif sel.ImplementationName == TEXT_RANGE:
|
||||||
|
return LOTextRange(sel)
|
||||||
|
return sel
|
||||||
|
|
||||||
def write(self, data, cursor=None):
|
def write(self, data, cursor=None):
|
||||||
cursor = cursor or self.selection.cursor.getEnd()
|
cursor = cursor or self.selection.cursor.getEnd()
|
||||||
|
@ -1706,6 +1707,9 @@ class LOCellRange(object):
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
return LOCellRange(self.obj[index], self.doc)
|
return LOCellRange(self.obj[index], self.doc)
|
||||||
|
|
||||||
|
def __contains__(self, item):
|
||||||
|
return item.in_range(self)
|
||||||
|
|
||||||
def _init_values(self):
|
def _init_values(self):
|
||||||
self._type_obj = self.obj.ImplementationName
|
self._type_obj = self.obj.ImplementationName
|
||||||
self._type_content = EMPTY
|
self._type_content = EMPTY
|
||||||
|
@ -1755,7 +1759,7 @@ class LOCellRange(object):
|
||||||
self.obj.setFormula(data)
|
self.obj.setFormula(data)
|
||||||
else:
|
else:
|
||||||
self.obj.setString(data)
|
self.obj.setString(data)
|
||||||
elif isinstance(data, (int, float)):
|
elif isinstance(data, (int, float, bool)):
|
||||||
self.obj.setValue(data)
|
self.obj.setValue(data)
|
||||||
elif isinstance(data, datetime.datetime):
|
elif isinstance(data, datetime.datetime):
|
||||||
d = data.toordinal()
|
d = data.toordinal()
|
||||||
|
@ -1773,8 +1777,6 @@ class LOCellRange(object):
|
||||||
return self.obj.getDataArray()
|
return self.obj.getDataArray()
|
||||||
@data.setter
|
@data.setter
|
||||||
def data(self, values):
|
def data(self, values):
|
||||||
if isinstance(values, list):
|
|
||||||
values = tuple(values)
|
|
||||||
self.obj.setDataArray(values)
|
self.obj.setDataArray(values)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1782,8 +1784,6 @@ class LOCellRange(object):
|
||||||
return self.obj.getFormulaArray()
|
return self.obj.getFormulaArray()
|
||||||
@formula.setter
|
@formula.setter
|
||||||
def formula(self, values):
|
def formula(self, values):
|
||||||
if isinstance(values, list):
|
|
||||||
values = tuple(values)
|
|
||||||
self.obj.setFormulaArray(values)
|
self.obj.setFormulaArray(values)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1808,13 +1808,19 @@ class LOCellRange(object):
|
||||||
cursor.collapseToSize(cols, rows)
|
cursor.collapseToSize(cols, rows)
|
||||||
return LOCellRange(self.sheet[cursor.AbsoluteName].obj, self.doc)
|
return LOCellRange(self.sheet[cursor.AbsoluteName].obj, self.doc)
|
||||||
|
|
||||||
def copy_from(self, rango):
|
def copy_from(self, rango, formula=False):
|
||||||
data = rango
|
data = rango
|
||||||
if isinstance(rango, LOCellRange):
|
if isinstance(rango, LOCellRange):
|
||||||
data = rango.data
|
if formula:
|
||||||
|
data = rango.formula
|
||||||
|
else:
|
||||||
|
data = rango.data
|
||||||
rows = len(data)
|
rows = len(data)
|
||||||
cols = len(data[0])
|
cols = len(data[0])
|
||||||
self.to_size(rows, cols).data = data
|
if formula:
|
||||||
|
self.to_size(rows, cols).formula = data
|
||||||
|
else:
|
||||||
|
self.to_size(rows, cols).data = data
|
||||||
return
|
return
|
||||||
|
|
||||||
def copy_to(self, cell, formula=False):
|
def copy_to(self, cell, formula=False):
|
||||||
|
@ -2060,6 +2066,10 @@ class EventsListenerBase(unohelper.Base, XEventListener):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._window = window
|
self._window = window
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
def disposing(self, event):
|
def disposing(self, event):
|
||||||
self._controller = None
|
self._controller = None
|
||||||
if not self._window is None:
|
if not self._window is None:
|
||||||
|
@ -2170,7 +2180,10 @@ class EventsItem(EventsListenerBase, XItemListener):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def itemStateChanged(self, event):
|
def itemStateChanged(self, event):
|
||||||
pass
|
event_name = '{}_item_changed'.format(self.name)
|
||||||
|
if hasattr(self._controller, event_name):
|
||||||
|
getattr(self._controller, event_name)(event)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class EventsItemRoadmap(EventsItem):
|
class EventsItemRoadmap(EventsItem):
|
||||||
|
@ -2231,6 +2244,33 @@ class EventsTab(EventsListenerBase, XTabListener):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class EventsGrid(EventsListenerBase, XGridDataListener, XGridSelectionListener):
|
||||||
|
|
||||||
|
def __init__(self, controller, name):
|
||||||
|
super().__init__(controller, name)
|
||||||
|
|
||||||
|
def dataChanged(self, event):
|
||||||
|
event_name = '{}_data_changed'.format(self.name)
|
||||||
|
if hasattr(self._controller, event_name):
|
||||||
|
getattr(self._controller, event_name)(event)
|
||||||
|
return
|
||||||
|
|
||||||
|
def rowHeadingChanged(self, event):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def rowsInserted(self, event):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def rowsRemoved(self, evemt):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def selectionChanged(self, event):
|
||||||
|
event_name = '{}_selection_changed'.format(self.name)
|
||||||
|
if hasattr(self._controller, event_name):
|
||||||
|
getattr(self._controller, event_name)(event)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class EventsKeyWindow(EventsListenerBase, XKeyListener):
|
class EventsKeyWindow(EventsListenerBase, XKeyListener):
|
||||||
"""
|
"""
|
||||||
event.KeyChar
|
event.KeyChar
|
||||||
|
@ -2307,8 +2347,8 @@ class EventsWindow(EventsListenerBase, XTopWindowListener, XWindowListener):
|
||||||
|
|
||||||
# ~ XWindowListener
|
# ~ XWindowListener
|
||||||
def windowResized(self, event):
|
def windowResized(self, event):
|
||||||
# ~ sb = self._container.getControl('subcontainer')
|
sb = self._cls._subcont
|
||||||
# ~ sb.setPosSize(0, 0, event.Width, event.Height, SIZE)
|
sb.setPosSize(0, 0, event.Width, event.Height, SIZE)
|
||||||
event_name = '{}_resized'.format(self._name)
|
event_name = '{}_resized'.format(self._name)
|
||||||
if hasattr(self._controller, event_name):
|
if hasattr(self._controller, event_name):
|
||||||
getattr(self._controller, event_name)(event)
|
getattr(self._controller, event_name)(event)
|
||||||
|
@ -2370,6 +2410,7 @@ class UnoBaseObject(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def parent(self):
|
def parent(self):
|
||||||
|
ps = self.obj.getContext().PosSize
|
||||||
return self.obj.getContext()
|
return self.obj.getContext()
|
||||||
|
|
||||||
def _get_possize(self, name):
|
def _get_possize(self, name):
|
||||||
|
@ -2411,17 +2452,23 @@ class UnoBaseObject(object):
|
||||||
return self._model.Width
|
return self._model.Width
|
||||||
@width.setter
|
@width.setter
|
||||||
def width(self, value):
|
def width(self, value):
|
||||||
self._model.Width = value
|
if hasattr(self.model, 'Width'):
|
||||||
|
self.model.Width = value
|
||||||
|
elif hasattr(self.obj, 'PosSize'):
|
||||||
|
self._set_possize('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):
|
||||||
self._model.Height = value
|
if hasattr(self.model, 'Height'):
|
||||||
|
self.model.Height = value
|
||||||
|
elif hasattr(self.obj, 'PosSize'):
|
||||||
|
self._set_possize('Height', value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tag(self):
|
def tag(self):
|
||||||
|
@ -2484,8 +2531,12 @@ class UnoBaseObject(object):
|
||||||
def move(self, origin, x=0, y=5):
|
def move(self, origin, x=0, y=5):
|
||||||
if x:
|
if x:
|
||||||
self.x = origin.x + origin.width + x
|
self.x = origin.x + origin.width + x
|
||||||
|
else:
|
||||||
|
self.x = origin.x
|
||||||
if y:
|
if y:
|
||||||
self.y = origin.y + origin.height + y
|
self.y = origin.y + origin.height + y
|
||||||
|
else:
|
||||||
|
self.y = origin.y
|
||||||
return
|
return
|
||||||
|
|
||||||
def possize(self, origin):
|
def possize(self, origin):
|
||||||
|
@ -2654,16 +2705,19 @@ class UnoGrid(UnoBaseObject):
|
||||||
# ~ def format_columns(self, value):
|
# ~ def format_columns(self, value):
|
||||||
# ~ self._format_columns = value
|
# ~ self._format_columns = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self):
|
||||||
|
return self[self.column, self.row]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
return self._data
|
return self._data
|
||||||
@data.setter
|
@data.setter
|
||||||
def data(self, values):
|
def data(self, values):
|
||||||
# ~ self._data = values
|
# ~ self._data = values
|
||||||
self._gdm.removeAllRows()
|
self.clear()
|
||||||
headings = tuple(range(1, len(values) + 1))
|
headings = tuple(range(1, len(values) + 1))
|
||||||
self._gdm.addRows(headings, values)
|
self._gdm.addRows(headings, values)
|
||||||
|
|
||||||
# ~ rows = range(grid_dm.RowCount)
|
# ~ rows = range(grid_dm.RowCount)
|
||||||
# ~ colors = [COLORS['GRAY'] if r % 2 else COLORS['WHITE'] for r in rows]
|
# ~ colors = [COLORS['GRAY'] if r % 2 else COLORS['WHITE'] for r in rows]
|
||||||
# ~ grid.Model.RowBackgroundColors = tuple(colors)
|
# ~ grid.Model.RowBackgroundColors = tuple(colors)
|
||||||
|
@ -2703,6 +2757,10 @@ class UnoGrid(UnoBaseObject):
|
||||||
row.append(d)
|
row.append(d)
|
||||||
return tuple(row)
|
return tuple(row)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._gdm.removeAllRows()
|
||||||
|
return
|
||||||
|
|
||||||
def add_row(self, data):
|
def add_row(self, data):
|
||||||
# ~ self._data.append(data)
|
# ~ self._data.append(data)
|
||||||
data = self._validate_column(data)
|
data = self._validate_column(data)
|
||||||
|
@ -2712,18 +2770,17 @@ class UnoGrid(UnoBaseObject):
|
||||||
def remove_row(self, row):
|
def remove_row(self, row):
|
||||||
self._gdm.removeRow(row)
|
self._gdm.removeRow(row)
|
||||||
# ~ del self._data[row]
|
# ~ del self._data[row]
|
||||||
self._update_row_heading()
|
self.update_row_heading()
|
||||||
return
|
return
|
||||||
|
|
||||||
def _update_row_heading(self):
|
def update_row_heading(self):
|
||||||
for i in range(self.rows):
|
for i in range(self.rows):
|
||||||
self._gdm.updateRowHeading(i, i + 1)
|
self._gdm.updateRowHeading(i, i + 1)
|
||||||
return
|
return
|
||||||
|
|
||||||
def sort(self, column, asc=True):
|
def sort(self, column, asc=True):
|
||||||
self._gdm.sortByColumn(column, asc)
|
self._gdm.sortByColumn(column, asc)
|
||||||
# ~ self._data.sort(key=itemgetter(column), reverse=not asc)
|
self.update_row_heading()
|
||||||
self._update_row_heading()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def set_column_image(self, column, path):
|
def set_column_image(self, column, path):
|
||||||
|
@ -2823,7 +2880,7 @@ class UnoTree(UnoBaseObject):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class UnoPages(UnoBaseObject):
|
class UnoTab(UnoBaseObject):
|
||||||
|
|
||||||
def __init__(self, obj):
|
def __init__(self, obj):
|
||||||
super().__init__(obj)
|
super().__init__(obj)
|
||||||
|
@ -2835,6 +2892,9 @@ class UnoPages(UnoBaseObject):
|
||||||
@property
|
@property
|
||||||
def current(self):
|
def current(self):
|
||||||
return self.obj.getActiveTabID()
|
return self.obj.getActiveTabID()
|
||||||
|
@property
|
||||||
|
def active(self):
|
||||||
|
return self.current
|
||||||
|
|
||||||
def get_sheet(self, id):
|
def get_sheet(self, id):
|
||||||
if isinstance(id, int):
|
if isinstance(id, int):
|
||||||
|
@ -2887,7 +2947,11 @@ class UnoPages(UnoBaseObject):
|
||||||
def _special_properties(self, tipo, properties):
|
def _special_properties(self, tipo, properties):
|
||||||
columns = properties.pop('Columns', ())
|
columns = properties.pop('Columns', ())
|
||||||
if tipo == 'grid':
|
if tipo == 'grid':
|
||||||
properties['ColumnModel'] = self._set_column_model(columns)
|
properties['ColumnModel'] = _set_column_model(columns)
|
||||||
|
if not 'Width' in properties:
|
||||||
|
properties['Width'] = self.width
|
||||||
|
if not 'Height' in properties:
|
||||||
|
properties['Height'] = self.height
|
||||||
elif tipo == 'button' and 'ImageURL' in properties:
|
elif tipo == 'button' and 'ImageURL' in properties:
|
||||||
properties['ImageURL'] = self._set_image_url(properties['ImageURL'])
|
properties['ImageURL'] = self._set_image_url(properties['ImageURL'])
|
||||||
elif tipo == 'roadmap':
|
elif tipo == 'roadmap':
|
||||||
|
@ -2939,7 +3003,7 @@ def get_custom_class(tipo, obj):
|
||||||
'link': UnoLabelLink,
|
'link': UnoLabelLink,
|
||||||
'roadmap': UnoRoadmap,
|
'roadmap': UnoRoadmap,
|
||||||
'tree': UnoTree,
|
'tree': UnoTree,
|
||||||
'pages': UnoPages,
|
'tab': UnoTab,
|
||||||
# ~ 'image': UnoImage,
|
# ~ 'image': UnoImage,
|
||||||
# ~ 'radio': UnoRadio,
|
# ~ 'radio': UnoRadio,
|
||||||
# ~ 'groupbox': UnoGroupBox,
|
# ~ 'groupbox': UnoGroupBox,
|
||||||
|
@ -2961,7 +3025,7 @@ def get_control_model(control):
|
||||||
'groupbox': 'com.sun.star.awt.UnoControlGroupBoxModel',
|
'groupbox': 'com.sun.star.awt.UnoControlGroupBoxModel',
|
||||||
'image': 'com.sun.star.awt.UnoControlImageControlModel',
|
'image': 'com.sun.star.awt.UnoControlImageControlModel',
|
||||||
'radio': 'com.sun.star.awt.UnoControlRadioButtonModel',
|
'radio': 'com.sun.star.awt.UnoControlRadioButtonModel',
|
||||||
'pages': 'com.sun.star.awt.UnoMultiPageModel',
|
'tab': 'com.sun.star.awt.UnoMultiPageModel',
|
||||||
}
|
}
|
||||||
return services[control]
|
return services[control]
|
||||||
|
|
||||||
|
@ -2995,6 +3059,11 @@ def add_listeners(events, control, name=''):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
getattr(control, key)(listeners[key](events, name))
|
getattr(control, key)(listeners[key](events, name))
|
||||||
|
|
||||||
|
if is_grid:
|
||||||
|
controllers = EventsGrid(events, name)
|
||||||
|
control.addSelectionListener(controllers)
|
||||||
|
control.Model.GridDataModel.addGridDataListener(controllers)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -3384,6 +3453,7 @@ class LOChart(object):
|
||||||
chart_data.setData(data)
|
chart_data.setData(data)
|
||||||
chart_data.RowDescriptions = labels
|
chart_data.RowDescriptions = labels
|
||||||
|
|
||||||
|
# ~ Bug
|
||||||
if tipo == 'Pie':
|
if tipo == 'Pie':
|
||||||
chart.setDiagram(chart.createInstance(self.BASE.format('Bar')))
|
chart.setDiagram(chart.createInstance(self.BASE.format('Bar')))
|
||||||
chart.setDiagram(chart.createInstance(self.BASE.format('Pie')))
|
chart.setDiagram(chart.createInstance(self.BASE.format('Pie')))
|
||||||
|
@ -3435,6 +3505,29 @@ class LOChart(object):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
def _set_column_model(columns):
|
||||||
|
#~ https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1awt_1_1grid_1_1XGridColumn.html
|
||||||
|
column_model = create_instance('com.sun.star.awt.grid.DefaultGridColumnModel', True)
|
||||||
|
for column in columns:
|
||||||
|
grid_column = create_instance('com.sun.star.awt.grid.GridColumn', True)
|
||||||
|
for k, v in column.items():
|
||||||
|
setattr(grid_column, k, v)
|
||||||
|
column_model.addColumn(grid_column)
|
||||||
|
return column_model
|
||||||
|
|
||||||
|
|
||||||
|
def _set_image_url(image, id_extension=''):
|
||||||
|
if exists_path(image):
|
||||||
|
return _path_url(image)
|
||||||
|
|
||||||
|
if not id_extension:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
path = get_path_extension(id_extension)
|
||||||
|
path = join(path, DIR['images'], image)
|
||||||
|
return _path_url(path)
|
||||||
|
|
||||||
|
|
||||||
class LODialog(object):
|
class LODialog(object):
|
||||||
|
|
||||||
def __init__(self, **properties):
|
def __init__(self, **properties):
|
||||||
|
@ -3622,7 +3715,7 @@ class LODialog(object):
|
||||||
properties['Height'] = self.height
|
properties['Height'] = self.height
|
||||||
if 'Title' in properties:
|
if 'Title' in properties:
|
||||||
properties['Text'] = properties.pop('Title')
|
properties['Text'] = properties.pop('Title')
|
||||||
elif tipo == 'pages':
|
elif tipo == 'tab':
|
||||||
if not 'Width' in properties:
|
if not 'Width' in properties:
|
||||||
properties['Width'] = self.width
|
properties['Width'] = self.width
|
||||||
if not 'Height' in properties:
|
if not 'Height' in properties:
|
||||||
|
@ -3681,13 +3774,26 @@ class LODialog(object):
|
||||||
|
|
||||||
|
|
||||||
class LOWindow(object):
|
class LOWindow(object):
|
||||||
|
EMPTY = b"""<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
|
||||||
|
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="empty" dlg:left="0" dlg:top="0" dlg:width="0" dlg:height="0" dlg:closeable="true" dlg:moveable="true" dlg:withtitlebar="false"/>"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self._events = None
|
self._events = None
|
||||||
self._menu = None
|
self._menu = None
|
||||||
self._container = None
|
self._container = None
|
||||||
|
self._id_extension = ''
|
||||||
self._obj = self._create(kwargs)
|
self._obj = self._create(kwargs)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id_extension(self):
|
||||||
|
return self._id_extension
|
||||||
|
@id_extension.setter
|
||||||
|
def id_extension(self, value):
|
||||||
|
global ID_EXTENSION
|
||||||
|
ID_EXTENSION = value
|
||||||
|
self._id_extension = value
|
||||||
|
|
||||||
def _create(self, properties):
|
def _create(self, properties):
|
||||||
ps = (
|
ps = (
|
||||||
properties.get('X', 0),
|
properties.get('X', 0),
|
||||||
|
@ -3698,6 +3804,7 @@ class LOWindow(object):
|
||||||
self._title = properties.get('Title', TITLE)
|
self._title = properties.get('Title', TITLE)
|
||||||
self._create_frame(ps)
|
self._create_frame(ps)
|
||||||
self._create_container(ps)
|
self._create_container(ps)
|
||||||
|
self._create_subcontainer(ps)
|
||||||
# ~ self._create_splitter(ps)
|
# ~ self._create_splitter(ps)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -3729,6 +3836,31 @@ class LOWindow(object):
|
||||||
self._frame.setComponent(self._container, None)
|
self._frame.setComponent(self._container, None)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _create_subcontainer(self, ps):
|
||||||
|
service = 'com.sun.star.awt.ContainerWindowProvider'
|
||||||
|
cwp = create_instance(service, True)
|
||||||
|
with get_temp_file() as f:
|
||||||
|
f.write(self.EMPTY)
|
||||||
|
f.flush()
|
||||||
|
subcont = cwp.createContainerWindow(
|
||||||
|
_path_url(f.name), '', self._container.getPeer(), None)
|
||||||
|
|
||||||
|
# ~ service = 'com.sun.star.awt.UnoControlDialog'
|
||||||
|
# ~ subcont2 = create_instance(service, True)
|
||||||
|
# ~ service = 'com.sun.star.awt.UnoControlDialogModel'
|
||||||
|
# ~ model = create_instance(service, True)
|
||||||
|
# ~ service = 'com.sun.star.awt.UnoControlContainer'
|
||||||
|
# ~ context = create_instance(service, True)
|
||||||
|
# ~ subcont2.setModel(model)
|
||||||
|
# ~ subcont2.setContext(context)
|
||||||
|
# ~ subcont2.createPeer(self._toolkit, self._container.getPeer())
|
||||||
|
|
||||||
|
subcont.setPosSize(0, 0, 500, 500, POSSIZE)
|
||||||
|
subcont.setVisible(True)
|
||||||
|
self._container.addControl('subcont', subcont)
|
||||||
|
self._subcont = subcont
|
||||||
|
return
|
||||||
|
|
||||||
def _get_base_control(self, tipo):
|
def _get_base_control(self, tipo):
|
||||||
services = {
|
services = {
|
||||||
'label': 'com.sun.star.awt.UnoControlFixedText',
|
'label': 'com.sun.star.awt.UnoControlFixedText',
|
||||||
|
@ -3742,25 +3874,50 @@ class LOWindow(object):
|
||||||
'radio': 'com.sun.star.awt.UnoControlRadioButton',
|
'radio': 'com.sun.star.awt.UnoControlRadioButton',
|
||||||
'tree': 'com.sun.star.awt.tree.TreeControl',
|
'tree': 'com.sun.star.awt.tree.TreeControl',
|
||||||
'grid': 'com.sun.star.awt.grid.UnoControlGrid',
|
'grid': 'com.sun.star.awt.grid.UnoControlGrid',
|
||||||
|
'tab': 'com.sun.star.awt.tab.UnoControlTabPage',
|
||||||
}
|
}
|
||||||
return services[tipo]
|
return services[tipo]
|
||||||
|
|
||||||
|
def _special_properties(self, tipo, properties):
|
||||||
|
columns = properties.pop('Columns', ())
|
||||||
|
if tipo == 'grid':
|
||||||
|
properties['ColumnModel'] = self._set_column_model(columns)
|
||||||
|
elif tipo == 'button' and 'ImageURL' in properties:
|
||||||
|
properties['ImageURL'] = _set_image_url(
|
||||||
|
properties['ImageURL'], self.id_extension)
|
||||||
|
elif tipo == 'roadmap':
|
||||||
|
if not 'Height' in properties:
|
||||||
|
properties['Height'] = self.height
|
||||||
|
if 'Title' in properties:
|
||||||
|
properties['Text'] = properties.pop('Title')
|
||||||
|
elif tipo == 'tab':
|
||||||
|
if not 'Width' in properties:
|
||||||
|
properties['Width'] = self.width - 20
|
||||||
|
if not 'Height' in properties:
|
||||||
|
properties['Height'] = self.height - 20
|
||||||
|
|
||||||
|
return properties
|
||||||
|
|
||||||
def add_control(self, properties):
|
def add_control(self, properties):
|
||||||
tipo = properties.pop('Type').lower()
|
tipo = properties.pop('Type').lower()
|
||||||
base = self._get_base_control(tipo)
|
root = properties.pop('Root', '')
|
||||||
obj = create_instance(base, True)
|
sheets = properties.pop('Sheets', ())
|
||||||
model = create_instance('{}Model'.format(base), True)
|
|
||||||
|
properties = self._special_properties(tipo, properties)
|
||||||
|
model = self._subcont.Model.createInstance(get_control_model(tipo))
|
||||||
set_properties(model, properties)
|
set_properties(model, properties)
|
||||||
obj.setModel(model)
|
|
||||||
x = properties.get('X', 5)
|
|
||||||
y = properties.get('Y', 5)
|
|
||||||
w = properties.get('Width', 200)
|
|
||||||
h = properties.get('Height', 25)
|
|
||||||
obj.setPosSize(x, y, w, h, POSSIZE)
|
|
||||||
name = properties['Name']
|
name = properties['Name']
|
||||||
self._container.addControl(name, obj)
|
self._subcont.Model.insertByName(name, model)
|
||||||
add_listeners(self.events, obj, name)
|
control = self._subcont.getControl(name)
|
||||||
control = get_custom_class(tipo, obj)
|
add_listeners(self.events, control, name)
|
||||||
|
control = get_custom_class(tipo, control)
|
||||||
|
|
||||||
|
if tipo == 'tree' and root:
|
||||||
|
control.root = root
|
||||||
|
elif tipo == 'tab' and sheets:
|
||||||
|
control.sheets = sheets
|
||||||
|
control.events = self.events
|
||||||
|
|
||||||
setattr(self, name, control)
|
setattr(self, name, control)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -4201,7 +4358,7 @@ def open_file(path):
|
||||||
if IS_WIN:
|
if IS_WIN:
|
||||||
os.startfile(path)
|
os.startfile(path)
|
||||||
else:
|
else:
|
||||||
subprocess.Popen(['xdg-open', path])
|
pid = subprocess.Popen(['xdg-open', path]).pid
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -4254,23 +4411,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):
|
||||||
|
@ -5247,8 +5410,6 @@ class LIBOServer(object):
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ~ controls = {
|
# ~ controls = {
|
||||||
# ~ 'CheckBox': 'com.sun.star.awt.UnoControlCheckBoxModel',
|
# ~ 'CheckBox': 'com.sun.star.awt.UnoControlCheckBoxModel',
|
||||||
# ~ 'ComboBox': 'com.sun.star.awt.UnoControlComboBoxModel',
|
# ~ 'ComboBox': 'com.sun.star.awt.UnoControlComboBoxModel',
|
||||||
|
|
Loading…
Reference in New Issue