Add support for writer
This commit is contained in:
parent
28e17d4b6c
commit
ced8ac7386
42
easymacro.py
42
easymacro.py
|
@ -114,9 +114,23 @@ MENUS_CALC = {
|
|||
'windows': '.uno:WindowList',
|
||||
'help': '.uno:HelpMenu',
|
||||
}
|
||||
MENUS_WRITER = {
|
||||
'file': '.uno:PickList',
|
||||
'edit': '.uno:EditMenu',
|
||||
'view': '.uno:ViewMenu',
|
||||
'insert': '.uno:InsertMenu',
|
||||
'format': '.uno:FormatMenu',
|
||||
'styles': '.uno:FormatStylesMenu',
|
||||
'sheet': '.uno:TableMenu',
|
||||
'data': '.uno:FormatFormMenu',
|
||||
'tools': '.uno:ToolsMenu',
|
||||
'windows': '.uno:WindowList',
|
||||
'help': '.uno:HelpMenu',
|
||||
}
|
||||
|
||||
MENUS_APP = {
|
||||
'calc': MENUS_CALC,
|
||||
'writer': MENUS_WRITER,
|
||||
}
|
||||
|
||||
|
||||
|
@ -1980,6 +1994,34 @@ def remove_menu(type_doc, name_menu, command):
|
|||
return True
|
||||
|
||||
|
||||
def _get_app_submenus(menus, count=0):
|
||||
for i, menu in enumerate(menus):
|
||||
data = property_to_dict(menu)
|
||||
cmd = data.get('CommandURL', '')
|
||||
msg = ' ' * count + '├─' + cmd
|
||||
debug(msg)
|
||||
submenu = data.get('ItemDescriptorContainer', None)
|
||||
if not submenu is None:
|
||||
_get_app_submenus(submenu, count + 1)
|
||||
return
|
||||
|
||||
|
||||
def get_app_menus(name_app, index=-1):
|
||||
instance = 'com.sun.star.ui.ModuleUIConfigurationManagerSupplier'
|
||||
service = TYPE_DOC[name_app]
|
||||
manager = create_instance(instance, True)
|
||||
ui = manager.getUIConfigurationManager(service)
|
||||
menus = ui.getSettings(NODE_MENUBAR, True)
|
||||
if index == -1:
|
||||
for menu in menus:
|
||||
data = property_to_dict(menu)
|
||||
debug(data.get('CommandURL', ''))
|
||||
else:
|
||||
menus = property_to_dict(menus[index])['ItemDescriptorContainer']
|
||||
_get_app_submenus(menus)
|
||||
return menus
|
||||
|
||||
|
||||
# ~ name = 'com.sun.star.configuration.ConfigurationProvider'
|
||||
# ~ cp = create_instance(name, True)
|
||||
# ~ node = PropertyValue(Name='nodepath', Value=NODE_SETTING)
|
||||
|
|
Binary file not shown.
|
@ -43,39 +43,44 @@ class Controllers(object):
|
|||
self.d.grid.sort(0)
|
||||
return
|
||||
|
||||
@app.catch_exception
|
||||
def button_save_action(self, event):
|
||||
msg = _('¿You want save your favorites?')
|
||||
if app.question(msg, self.TITLE):
|
||||
base = 'service:net.elmau.zaz.Favorites?{}'
|
||||
paths = []
|
||||
submenus = []
|
||||
for row in range(self.d.grid.rows):
|
||||
label = '{}. {}'.format(row + 1, self.d.grid[0, row])
|
||||
path = self.d.grid[2, row]
|
||||
paths.append(path)
|
||||
path = app._path_url(path)
|
||||
sm = {'Label': label, 'CommandURL': base.format(path)}
|
||||
submenus.append(sm)
|
||||
sm = {'Label': '-'}
|
||||
submenus.append(sm)
|
||||
sm = {'Label': _('Favorites...'), 'CommandURL': base.format('config')}
|
||||
submenus.append(sm)
|
||||
if not app.question(msg, self.TITLE):
|
||||
return
|
||||
|
||||
command = 'menu.zaz.favorites'
|
||||
data = {
|
||||
'Label': 'Favorites',
|
||||
'CommandURL': command,
|
||||
'After': '.uno:RecentFileList',
|
||||
'Submenu': submenus,
|
||||
}
|
||||
doc = app.get_document()
|
||||
app.remove_menu(doc.type, 'File', command)
|
||||
app.insert_menu(doc.type, 'File', **data)
|
||||
app.set_config('paths', paths)
|
||||
base = 'service:net.elmau.zaz.Favorites?{}'
|
||||
paths = []
|
||||
submenus = []
|
||||
for row in range(self.d.grid.rows):
|
||||
label = '{}. {}'.format(row + 1, self.d.grid[0, row])
|
||||
path = self.d.grid[2, row]
|
||||
paths.append(path)
|
||||
path = app._path_url(path)
|
||||
sm = {'Label': label, 'CommandURL': base.format(path)}
|
||||
submenus.append(sm)
|
||||
sm = {'Label': '-'}
|
||||
submenus.append(sm)
|
||||
sm = {'Label': _('Favorites...'), 'CommandURL': base.format('config')}
|
||||
submenus.append(sm)
|
||||
|
||||
self.d.close(1)
|
||||
msg = _('Favorites saved correctly')
|
||||
app.msgbox(msg, self.TITLE)
|
||||
command = 'menu.zaz.favorites'
|
||||
data = {
|
||||
'Label': 'Favorites',
|
||||
'CommandURL': command,
|
||||
'After': '.uno:RecentFileList',
|
||||
'Submenu': submenus,
|
||||
}
|
||||
doc = app.get_document()
|
||||
|
||||
for doc_type in ('calc', 'writer'):
|
||||
app.remove_menu(doc_type, 'File', command)
|
||||
app.insert_menu(doc_type, 'File', **data)
|
||||
app.set_config('paths', paths)
|
||||
|
||||
self.d.close(1)
|
||||
msg = _('Favorites saved correctly')
|
||||
app.msgbox(msg, self.TITLE)
|
||||
return
|
||||
|
||||
def grid_click(self, event):
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2019-09-19 21:06-0500\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: source/ZAZFavorites.py:35
|
||||
msgid "Path previously added"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:47
|
||||
msgid "¿You want save your favorites?"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:63
|
||||
msgid "Favorites..."
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:81
|
||||
msgid "Favorites saved correctly"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:91
|
||||
msgid "¿You want delete this file?"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:111
|
||||
msgid "ZAZ Favorites"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:144
|
||||
msgid "~Add"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:155
|
||||
msgid "File Name"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:179
|
||||
msgid "~Save"
|
||||
msgstr ""
|
||||
|
Binary file not shown.
|
@ -0,0 +1,54 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2019-09-19 21:06-0500\n"
|
||||
"PO-Revision-Date: 2019-09-19 21:07-0500\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
"X-Generator: Poedit 2.2.1\n"
|
||||
"Last-Translator: \n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: en\n"
|
||||
|
||||
#: source/ZAZFavorites.py:35
|
||||
msgid "Path previously added"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:47
|
||||
msgid "¿You want save your favorites?"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:63
|
||||
msgid "Favorites..."
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:81
|
||||
msgid "Favorites saved correctly"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:91
|
||||
msgid "¿You want delete this file?"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:111
|
||||
msgid "ZAZ Favorites"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:144
|
||||
msgid "~Add"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:155
|
||||
msgid "File Name"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZFavorites.py:179
|
||||
msgid "~Save"
|
||||
msgstr ""
|
|
@ -114,9 +114,23 @@ MENUS_CALC = {
|
|||
'windows': '.uno:WindowList',
|
||||
'help': '.uno:HelpMenu',
|
||||
}
|
||||
MENUS_WRITER = {
|
||||
'file': '.uno:PickList',
|
||||
'edit': '.uno:EditMenu',
|
||||
'view': '.uno:ViewMenu',
|
||||
'insert': '.uno:InsertMenu',
|
||||
'format': '.uno:FormatMenu',
|
||||
'styles': '.uno:FormatStylesMenu',
|
||||
'sheet': '.uno:TableMenu',
|
||||
'data': '.uno:FormatFormMenu',
|
||||
'tools': '.uno:ToolsMenu',
|
||||
'windows': '.uno:WindowList',
|
||||
'help': '.uno:HelpMenu',
|
||||
}
|
||||
|
||||
MENUS_APP = {
|
||||
'calc': MENUS_CALC,
|
||||
'writer': MENUS_WRITER,
|
||||
}
|
||||
|
||||
|
||||
|
@ -1980,6 +1994,34 @@ def remove_menu(type_doc, name_menu, command):
|
|||
return True
|
||||
|
||||
|
||||
def _get_app_submenus(menus, count=0):
|
||||
for i, menu in enumerate(menus):
|
||||
data = property_to_dict(menu)
|
||||
cmd = data.get('CommandURL', '')
|
||||
msg = ' ' * count + '├─' + cmd
|
||||
debug(msg)
|
||||
submenu = data.get('ItemDescriptorContainer', None)
|
||||
if not submenu is None:
|
||||
_get_app_submenus(submenu, count + 1)
|
||||
return
|
||||
|
||||
|
||||
def get_app_menus(name_app, index=-1):
|
||||
instance = 'com.sun.star.ui.ModuleUIConfigurationManagerSupplier'
|
||||
service = TYPE_DOC[name_app]
|
||||
manager = create_instance(instance, True)
|
||||
ui = manager.getUIConfigurationManager(service)
|
||||
menus = ui.getSettings(NODE_MENUBAR, True)
|
||||
if index == -1:
|
||||
for menu in menus:
|
||||
data = property_to_dict(menu)
|
||||
debug(data.get('CommandURL', ''))
|
||||
else:
|
||||
menus = property_to_dict(menus[index])['ItemDescriptorContainer']
|
||||
_get_app_submenus(menus)
|
||||
return menus
|
||||
|
||||
|
||||
# ~ name = 'com.sun.star.configuration.ConfigurationProvider'
|
||||
# ~ cp = create_instance(name, True)
|
||||
# ~ node = PropertyValue(Name='nodepath', Value=NODE_SETTING)
|
||||
|
|
Loading…
Reference in New Issue