commit
58a51117d5
|
@ -6,6 +6,7 @@ conf.py
|
||||||
files/
|
files/
|
||||||
|
|
||||||
docs/
|
docs/
|
||||||
|
source/source/
|
||||||
|
|
||||||
# Virtualenv
|
# Virtualenv
|
||||||
.env/
|
.env/
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
v 0.5.0 [15-sep-2019]
|
||||||
|
---------------------
|
||||||
|
- Add support for shortcuts
|
||||||
|
|
||||||
v 0.4.0 [14-sep-2019]
|
v 0.4.0 [14-sep-2019]
|
||||||
---------------------
|
---------------------
|
||||||
- Add support for locales
|
- Add support for locales
|
||||||
|
|
|
@ -36,13 +36,20 @@ ID = 'org.myextension.test'
|
||||||
|
|
||||||
# ~ If you extension will be multilanguage set: True
|
# ~ If you extension will be multilanguage set: True
|
||||||
# ~ This feature used gettext, set pythonpath and easymacro in True
|
# ~ This feature used gettext, set pythonpath and easymacro in True
|
||||||
|
# ~ Yu can used PoEdit for edit PO files and generate MO files.
|
||||||
|
# ~ https://poedit.net/
|
||||||
USE_LOCALES = True
|
USE_LOCALES = True
|
||||||
DOMAIN = 'base'
|
DOMAIN = 'base'
|
||||||
PATH_LOCALES = 'locales'
|
PATH_LOCALES = 'locales'
|
||||||
|
# ~ locate pygettext.py
|
||||||
|
PATH_PYGETTEXT = '/usr/lib/python3.7/Tools/i18n/pygettext.py'
|
||||||
|
PATH_MSGMERGE = 'msgmerge'
|
||||||
|
|
||||||
|
|
||||||
|
# ~ Show in extension manager
|
||||||
PUBLISHER = {
|
PUBLISHER = {
|
||||||
'en': {'text': 'El Mau', 'link': 'https://elmau.net'},
|
'en': {'text': 'El Mau', 'link': 'https://gitlab.com/mauriciobaeza'},
|
||||||
'es': {'text': 'El Mau', 'link': 'https://elmau.net'},
|
'es': {'text': 'El Mau', 'link': 'https://gitlab.com/mauriciobaeza'},
|
||||||
}
|
}
|
||||||
|
|
||||||
# ~ Name in this folder for copy
|
# ~ Name in this folder for copy
|
||||||
|
@ -102,6 +109,12 @@ CONTEXT = {
|
||||||
# ~ For icons con name: NAME_16.bmp, used only NAME
|
# ~ For icons con name: NAME_16.bmp, used only NAME
|
||||||
# ~ PARENT = ''
|
# ~ PARENT = ''
|
||||||
# ~ MENU_MAIN = {}
|
# ~ MENU_MAIN = {}
|
||||||
|
# ~ Shortcut: Key + "Modifier Keys"
|
||||||
|
# ~ Important: Not used any shortcuts used for LibreOffice
|
||||||
|
# ~ SHIFT is mapped to Shift on all platforms.
|
||||||
|
# ~ MOD1 is mapped to Ctrl on Windows/Linux, while it is mapped to Cmd on Mac.
|
||||||
|
# ~ MOD2 is mapped to Alt on all platforms.
|
||||||
|
# ~ For example: Shift+Ctrl+Alt+T -> T_SHIFT_MOD1_MOD2
|
||||||
PARENT = 'OfficeMenuBar'
|
PARENT = 'OfficeMenuBar'
|
||||||
MENU_MAIN = {
|
MENU_MAIN = {
|
||||||
'en': 'My Extension',
|
'en': 'My Extension',
|
||||||
|
@ -114,9 +127,11 @@ MENUS = (
|
||||||
'context': 'calc,writer',
|
'context': 'calc,writer',
|
||||||
'icon': 'icon',
|
'icon': 'icon',
|
||||||
'toolbar': True,
|
'toolbar': True,
|
||||||
|
'shortcut': 'T_SHIFT_MOD1_MOD2',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# ~ Functions, only for TYPE_EXTENSION = 3
|
# ~ Functions, only for TYPE_EXTENSION = 3
|
||||||
FUNCTIONS = {
|
FUNCTIONS = {
|
||||||
'test': {
|
'test': {
|
||||||
|
@ -150,8 +165,9 @@ DIRS = {
|
||||||
'images': 'images',
|
'images': 'images',
|
||||||
'registration': 'registration',
|
'registration': 'registration',
|
||||||
'files': 'files',
|
'files': 'files',
|
||||||
'pythonpath': True,
|
'office': 'Office',
|
||||||
'locales': PATH_LOCALES,
|
'locales': PATH_LOCALES,
|
||||||
|
'pythonpath': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,6 +183,7 @@ FILES = {
|
||||||
'rdb': f'X{NAME}.rdb',
|
'rdb': f'X{NAME}.rdb',
|
||||||
'update': f'{NAME.lower()}.update.xml',
|
'update': f'{NAME.lower()}.update.xml',
|
||||||
'addin': 'CalcAddIn.xcu',
|
'addin': 'CalcAddIn.xcu',
|
||||||
|
'shortcut': 'Accelerators.xcu',
|
||||||
'easymacro': True,
|
'easymacro': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +435,8 @@ if TYPE_EXTENSION == 3:
|
||||||
|
|
||||||
FILE_MANIFEST = f"""<?xml version="1.0" encoding="UTF-8"?>
|
FILE_MANIFEST = f"""<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<manifest:manifest>
|
<manifest:manifest>
|
||||||
<manifest:file-entry manifest:full-path="{FILES['py']}" manifest:media-type="application/vnd.sun.star.uno-component;type=Python"/>{NODE_ADDONS}
|
<manifest:file-entry manifest:full-path="{FILES['py']}" manifest:media-type="application/vnd.sun.star.uno-component;type=Python"/>
|
||||||
|
<manifest:file-entry manifest:full-path="Office/{FILES['shortcut']}" manifest:media-type="application/vnd.sun.star.configuration-data"/>{NODE_ADDONS}
|
||||||
</manifest:manifest>
|
</manifest:manifest>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -559,6 +577,55 @@ FILE_ADDIN = f"""<?xml version="1.0" encoding="UTF-8"?>
|
||||||
</oor:component-data>"""
|
</oor:component-data>"""
|
||||||
|
|
||||||
|
|
||||||
|
NODE_SHORTCUT = """ {0}<node oor:name="{1}" oor:op="fuse">
|
||||||
|
{0}<prop oor:name="Command">
|
||||||
|
{0}<value xml:lang="en-US">service:{2}?{3}</value>
|
||||||
|
{0}</prop>
|
||||||
|
{0}</node>
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
NODE_SHORTCUTS = ''
|
||||||
|
if TYPE_EXTENSION == 1:
|
||||||
|
node_global = []
|
||||||
|
node_module = {}
|
||||||
|
for m in MENUS:
|
||||||
|
if not m.get('shortcut', ''):
|
||||||
|
continue
|
||||||
|
if m['context']:
|
||||||
|
for c in m['context'].split(','):
|
||||||
|
if not c in node_module:
|
||||||
|
node_module[c] = []
|
||||||
|
node = NODE_SHORTCUT.format(' ', m['shortcut'], ID, m['argument'])
|
||||||
|
node_module[c].append(node)
|
||||||
|
continue
|
||||||
|
node = NODE_SHORTCUT.format('', m['shortcut'], ID, m['argument'])
|
||||||
|
node_global.append(node)
|
||||||
|
if node_global:
|
||||||
|
NODE_SHORTCUTS = ' <node oor:name="Global">\n'
|
||||||
|
NODE_SHORTCUTS += '\n'.join(node_global)
|
||||||
|
NODE_SHORTCUTS += ' </node>'
|
||||||
|
if node_module:
|
||||||
|
NODE_SHORTCUTS += ' <node oor:name="Modules">\n'
|
||||||
|
for c, n in node_module.items():
|
||||||
|
NODE_SHORTCUTS += ' <node oor:name="{}">\n'.format(CONTEXT[c])
|
||||||
|
NODE_SHORTCUTS += '\n'.join(n)
|
||||||
|
NODE_SHORTCUTS += ' </node>\n'
|
||||||
|
NODE_SHORTCUTS += ' </node>'
|
||||||
|
|
||||||
|
FILE_SHORTCUTS = f"""<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<oor:component-data
|
||||||
|
xmlns:oor="http://openoffice.org/2001/registry"
|
||||||
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
|
oor:name="Accelerators"
|
||||||
|
oor:package="org.openoffice.Office">
|
||||||
|
<node oor:name="PrimaryKeys">
|
||||||
|
{NODE_SHORTCUTS}
|
||||||
|
</node>
|
||||||
|
</oor:component-data>
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
DATA = {
|
DATA = {
|
||||||
'py': FILE_PY,
|
'py': FILE_PY,
|
||||||
'manifest': FILE_MANIFEST,
|
'manifest': FILE_MANIFEST,
|
||||||
|
@ -567,6 +634,7 @@ DATA = {
|
||||||
'update': FILE_UPDATE,
|
'update': FILE_UPDATE,
|
||||||
'idl': FILE_IDL,
|
'idl': FILE_IDL,
|
||||||
'addin': FILE_ADDIN,
|
'addin': FILE_ADDIN,
|
||||||
|
'shortcut': FILE_SHORTCUTS,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,12 +68,9 @@ MSG_LANG = {
|
||||||
FILE_NAME_DEBUG = 'zaz-debug.log'
|
FILE_NAME_DEBUG = 'zaz-debug.log'
|
||||||
LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
|
LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
|
||||||
LOG_DATE = '%d/%m/%Y %H:%M:%S'
|
LOG_DATE = '%d/%m/%Y %H:%M:%S'
|
||||||
LEVEL_ERROR = logging.getLevelName(logging.ERROR)
|
logging.addLevelName(logging.ERROR, '\033[1;41mERROR\033[1;0m')
|
||||||
LEVEL_DEBUG = logging.getLevelName(logging.DEBUG)
|
logging.addLevelName(logging.DEBUG, '\x1b[33mDEBUG\033[1;0m')
|
||||||
LEVEL_INFO = logging.getLevelName(logging.INFO)
|
logging.addLevelName(logging.INFO, '\x1b[32mINFO\033[1;0m')
|
||||||
logging.addLevelName(logging.ERROR, f'\033[1;41m{LEVEL_ERROR}\033[1;0m')
|
|
||||||
logging.addLevelName(logging.DEBUG, f'\x1b[33m{LEVEL_DEBUG}\033[1;0m')
|
|
||||||
logging.addLevelName(logging.INFO, f'\x1b[32m{LEVEL_INFO}\033[1;0m')
|
|
||||||
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT, datefmt=LOG_DATE)
|
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT, datefmt=LOG_DATE)
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -176,10 +173,12 @@ def debug(info):
|
||||||
# ~ doc = app.newDoc(WRITER)
|
# ~ doc = app.newDoc(WRITER)
|
||||||
# ~ out = OutputDoc(doc)
|
# ~ out = OutputDoc(doc)
|
||||||
# ~ sys.stdout = out
|
# ~ sys.stdout = out
|
||||||
pprint(info)
|
# ~ pprint(info)
|
||||||
|
doc = LogWin(new_doc('writer').obj)
|
||||||
|
doc.write(info)
|
||||||
return
|
return
|
||||||
|
|
||||||
log.debug(info)
|
log.debug(str(info))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,6 +202,11 @@ def run_in_thread(fn):
|
||||||
return run
|
return run
|
||||||
|
|
||||||
|
|
||||||
|
def sleep(sec):
|
||||||
|
time.sleep(sec)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def _(msg):
|
def _(msg):
|
||||||
L = LANGUAGE.split('-')[0]
|
L = LANGUAGE.split('-')[0]
|
||||||
if L == 'en':
|
if L == 'en':
|
||||||
|
@ -247,7 +251,10 @@ def get_dispatch():
|
||||||
|
|
||||||
|
|
||||||
def get_temp_file():
|
def get_temp_file():
|
||||||
return tempfile.NamedTemporaryFile()
|
delete = True
|
||||||
|
if IS_WIN:
|
||||||
|
delete = False
|
||||||
|
return tempfile.NamedTemporaryFile(delete=delete)
|
||||||
|
|
||||||
|
|
||||||
def _path_url(path):
|
def _path_url(path):
|
||||||
|
|
|
@ -46,7 +46,7 @@ def _join(*paths):
|
||||||
|
|
||||||
|
|
||||||
def _mkdir(path):
|
def _mkdir(path):
|
||||||
return os.mkdir(path)
|
return Path(path).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
def _save(path, data):
|
def _save(path, data):
|
||||||
|
@ -114,6 +114,8 @@ def _create_new_directories():
|
||||||
_mkdir(path)
|
_mkdir(path)
|
||||||
path = _join(path_source, DIRS['registration'])
|
path = _join(path_source, DIRS['registration'])
|
||||||
_mkdir(path)
|
_mkdir(path)
|
||||||
|
path = _join(path_source, DIRS['office'])
|
||||||
|
_mkdir(path)
|
||||||
|
|
||||||
if FILES['easymacro'] or DIRS['pythonpath']:
|
if FILES['easymacro'] or DIRS['pythonpath']:
|
||||||
path = _join(path_source, 'pythonpath')
|
path = _join(path_source, 'pythonpath')
|
||||||
|
@ -223,6 +225,11 @@ def _update_files():
|
||||||
path = _join(path_source, DIRS['meta'], FILES['manifest'])
|
path = _join(path_source, DIRS['meta'], FILES['manifest'])
|
||||||
_save(path, DATA['manifest'])
|
_save(path, DATA['manifest'])
|
||||||
|
|
||||||
|
path = _join(path_source, DIRS['office'])
|
||||||
|
_mkdir(path)
|
||||||
|
path = _join(path_source, DIRS['office'], FILES['shortcut'])
|
||||||
|
_save(path, DATA['shortcut'])
|
||||||
|
|
||||||
path = _join(path_source, FILES['addons'])
|
path = _join(path_source, FILES['addons'])
|
||||||
_save(path, DATA['addons'])
|
_save(path, DATA['addons'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue