Diable search
This commit is contained in:
parent
46b4855f60
commit
d502f36313
137
easymacro.py
137
easymacro.py
|
@ -4,7 +4,7 @@
|
|||
|
||||
# ~ This file is part of ZAZ.
|
||||
|
||||
# ~ https://git.elmau.net/elmau/zaz
|
||||
# ~ https://git.cuates.net/elmau/zaz
|
||||
|
||||
# ~ ZAZ is free software: you can redistribute it and/or modify
|
||||
# ~ it under the terms of the GNU General Public License as published by
|
||||
|
@ -290,7 +290,7 @@ def create_instance(name: str, with_context: bool=False, args: Any=None) -> Any:
|
|||
return instance
|
||||
|
||||
|
||||
def get_app_config(node_name, key=''):
|
||||
def get_app_config(node_name: str, key: str=''):
|
||||
name = 'com.sun.star.configuration.ConfigurationProvider'
|
||||
service = 'com.sun.star.configuration.ConfigurationAccess'
|
||||
cp = create_instance(name, True)
|
||||
|
@ -337,7 +337,7 @@ def info(*args):
|
|||
return
|
||||
|
||||
|
||||
def save_log(path, data):
|
||||
def save_log(path: str, data):
|
||||
with open(path, 'a') as f:
|
||||
f.write(f'{str(now())[:19]} -{LOG_NAME}- ')
|
||||
pprint(data, stream=f)
|
||||
|
@ -365,7 +365,7 @@ def inspect(obj: Any) -> None:
|
|||
return
|
||||
|
||||
|
||||
def mri(obj):
|
||||
def mri(obj: Any) -> None:
|
||||
m = create_instance('mytools.Mri')
|
||||
if m is None:
|
||||
msg = 'Extension MRI not found'
|
||||
|
@ -384,7 +384,7 @@ def run_in_thread(fn):
|
|||
return run
|
||||
|
||||
|
||||
def now(only_time=False):
|
||||
def now(only_time: bool=False):
|
||||
now = datetime.datetime.now()
|
||||
if only_time:
|
||||
now = now.time()
|
||||
|
@ -538,7 +538,7 @@ def _struct_to_date(value):
|
|||
return d
|
||||
|
||||
|
||||
def _get_url_script(args):
|
||||
def _get_url_script(args: dict):
|
||||
library = args['library']
|
||||
module = '.'
|
||||
name = args['name']
|
||||
|
@ -557,7 +557,7 @@ def _get_url_script(args):
|
|||
return url
|
||||
|
||||
|
||||
def _call_macro(args):
|
||||
def _call_macro(args: dict):
|
||||
#~ https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification
|
||||
|
||||
url = _get_url_script(args)
|
||||
|
@ -641,7 +641,7 @@ def stop_timer(name):
|
|||
return
|
||||
|
||||
|
||||
def install_locales(path, domain='base', dir_locales=DIR['locales']):
|
||||
def install_locales(path: str, domain: str='base', dir_locales=DIR['locales']):
|
||||
path_locales = _P.join(_P(path).path, dir_locales)
|
||||
try:
|
||||
lang = gettext.translation(domain, path_locales, languages=[LANG])
|
||||
|
@ -702,7 +702,7 @@ def start():
|
|||
return
|
||||
|
||||
|
||||
def end(get_seconds=False):
|
||||
def end(get_seconds: bool=False):
|
||||
global _start
|
||||
e = now()
|
||||
td = e - _start
|
||||
|
@ -2775,7 +2775,7 @@ class LOWriterTextRange(object):
|
|||
@property
|
||||
def string(self):
|
||||
s = ''
|
||||
if self._is_paragraph:
|
||||
if not self._is_table:
|
||||
s = self.obj.String
|
||||
return s
|
||||
@string.setter
|
||||
|
@ -4676,12 +4676,11 @@ class UnoGrid(UnoBaseObject):
|
|||
def __init__(self, obj):
|
||||
super().__init__(obj)
|
||||
self._gdm = self.model.GridDataModel
|
||||
self._columns = []
|
||||
self._data = []
|
||||
# ~ self._format_columns = ()
|
||||
self._formats = ()
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name in ('_gdm', '_columns', '_data'):
|
||||
if name in ('_gdm', '_data', '_formats'):
|
||||
self.__dict__[name] = value
|
||||
else:
|
||||
super().__setattr__(name, value)
|
||||
|
@ -4700,10 +4699,10 @@ class UnoGrid(UnoBaseObject):
|
|||
|
||||
@property
|
||||
def columns(self):
|
||||
return self._columns
|
||||
return {}
|
||||
@columns.setter
|
||||
def columns(self, values):
|
||||
self._columns = values
|
||||
# ~ self._columns = values
|
||||
#~ https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1awt_1_1grid_1_1XGridColumn.html
|
||||
model = create_instance('com.sun.star.awt.grid.DefaultGridColumnModel', True)
|
||||
for properties in values:
|
||||
|
@ -4742,35 +4741,46 @@ class UnoGrid(UnoBaseObject):
|
|||
def row(self):
|
||||
return self.obj.CurrentRow
|
||||
|
||||
@property
|
||||
def row_count(self):
|
||||
return self._gdm.RowCount
|
||||
|
||||
@property
|
||||
def column(self):
|
||||
return self.obj.CurrentColumn
|
||||
|
||||
@property
|
||||
def column(self):
|
||||
return self.obj.CurrentColumn
|
||||
|
||||
@property
|
||||
def is_valid(self):
|
||||
return not (self.row == -1 or self.column == -1)
|
||||
|
||||
@property
|
||||
def formats(self):
|
||||
return self._formats
|
||||
@formats.setter
|
||||
def formats(self, values):
|
||||
self._formats = values
|
||||
|
||||
def clear(self):
|
||||
self._gdm.removeAllRows()
|
||||
return
|
||||
|
||||
# UP
|
||||
def _format_cols(self):
|
||||
rows = tuple(tuple(
|
||||
self._format_columns[i].format(r) for i, r in enumerate(row)) for row in self._data
|
||||
)
|
||||
return rows
|
||||
def _format_columns(self, data):
|
||||
row = data
|
||||
if self.formats:
|
||||
for i, f in enumerate(formats):
|
||||
if f:
|
||||
row[i] = f.format(data[i])
|
||||
return row
|
||||
|
||||
# ~ @property
|
||||
# ~ def format_columns(self):
|
||||
# ~ return self._format_columns
|
||||
# ~ @format_columns.setter
|
||||
# ~ def format_columns(self, value):
|
||||
# ~ self._format_columns = value
|
||||
|
||||
# ~ @property
|
||||
# ~ def rows(self):
|
||||
# ~ return self._gdm.RowCount
|
||||
|
||||
# ~ @property
|
||||
# ~ def columns(self):
|
||||
# ~ return self._gdm.ColumnCount
|
||||
def add_row(self, data):
|
||||
self._data.append(data)
|
||||
row = self._format_columns(data)
|
||||
self._gdm.addRow(self.row_count + 1, row)
|
||||
return
|
||||
|
||||
def set_cell_tooltip(self, col, row, value):
|
||||
self._gdm.updateCellToolTip(col, row, value)
|
||||
|
@ -4780,45 +4790,20 @@ class UnoGrid(UnoBaseObject):
|
|||
value = self._gdm.getCellToolTip(col, row)
|
||||
return value
|
||||
|
||||
def _validate_column(self, data):
|
||||
row = []
|
||||
for i, d in enumerate(data):
|
||||
if i in self._columns:
|
||||
if 'image' in self._columns[i]:
|
||||
row.append(self._columns[i]['image'])
|
||||
else:
|
||||
row.append(d)
|
||||
return tuple(row)
|
||||
|
||||
def add_row(self, data):
|
||||
# ~ self._data.append(data)
|
||||
data = self._validate_column(data)
|
||||
self._gdm.addRow(self.rows + 1, data)
|
||||
return
|
||||
|
||||
def remove_row(self, row):
|
||||
self._gdm.removeRow(row)
|
||||
# ~ del self._data[row]
|
||||
self.update_row_heading()
|
||||
return
|
||||
|
||||
def update_row_heading(self):
|
||||
for i in range(self.rows):
|
||||
self._gdm.updateRowHeading(i, i + 1)
|
||||
return
|
||||
|
||||
def sort(self, column, asc=True):
|
||||
self._gdm.sortByColumn(column, asc)
|
||||
self.update_row_heading()
|
||||
return
|
||||
|
||||
def set_column_image(self, column, path):
|
||||
gp = create_instance('com.sun.star.graphic.GraphicProvider')
|
||||
data = dict_to_property({'URL': _path_url(path)})
|
||||
image = gp.queryGraphic(data)
|
||||
if not column in self._columns:
|
||||
self._columns[column] = {}
|
||||
self._columns[column]['image'] = image
|
||||
def update_row_heading(self):
|
||||
for i in range(self.row_count):
|
||||
self._gdm.updateRowHeading(i, i + 1)
|
||||
return
|
||||
|
||||
def remove_row(self, row):
|
||||
self._gdm.removeRow(row)
|
||||
del self._data[row]
|
||||
self.update_row_heading()
|
||||
return
|
||||
|
||||
|
||||
|
@ -5422,9 +5407,9 @@ class LOMenu(object):
|
|||
if MENUS[index.lower()] == cmd:
|
||||
self._menu = menu
|
||||
break
|
||||
line = self._menu.get('CommandURL', '')
|
||||
line += self._get_submenus(self._menu['ItemDescriptorContainer'])
|
||||
return line
|
||||
# ~ line = self._menu.get('CommandURL', '')
|
||||
# ~ line += self._get_submenus(self._menu['ItemDescriptorContainer'])
|
||||
return self._menu
|
||||
|
||||
def _get_menus(self):
|
||||
instance = 'com.sun.star.ui.ModuleUIConfigurationManagerSupplier'
|
||||
|
@ -6212,6 +6197,14 @@ class Paths(object):
|
|||
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def image(cls, path):
|
||||
gp = create_instance('com.sun.star.graphic.GraphicProvider')
|
||||
image = gp.queryGraphic((
|
||||
PropertyValue(Name='URL', Value=cls.to_url(path)),
|
||||
))
|
||||
return image
|
||||
|
||||
@classmethod
|
||||
def copy(cls, source, target='', name=''):
|
||||
p, f, n, e = _P(source).info
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -448,8 +448,6 @@ def _create_dialog():
|
|||
'Width': 12,
|
||||
'Height': 12,
|
||||
'Step': 1,
|
||||
# ~ 'ImageURL': 'close.svg',
|
||||
# ~ 'ImagePosition': 1,
|
||||
}
|
||||
dialog.add_control(args)
|
||||
|
||||
|
@ -471,7 +469,6 @@ def _create_dialog():
|
|||
'Step': 1,
|
||||
'ImageURL': 'close.svg',
|
||||
'ImagePosition': 1,
|
||||
# ~ 'PushButtonType': 2,
|
||||
}
|
||||
dialog.add_control(args)
|
||||
dialog.center(dialog.cmd_close, y=-5)
|
||||
|
@ -496,6 +493,7 @@ def _create_dialog():
|
|||
'Step': 1,
|
||||
'ImageURL': 'search.svg',
|
||||
'FocusOnClick': False,
|
||||
'Enabled': False,
|
||||
'Y': 2,
|
||||
}
|
||||
dialog.add_control(args)
|
||||
|
|
Loading…
Reference in New Issue