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