Index: gc_core/py/oxt/OptionsDialog.xcs ================================================================== --- gc_core/py/oxt/OptionsDialog.xcs +++ gc_core/py/oxt/OptionsDialog.xcs @@ -14,14 +14,28 @@ The data for one leaf. ${xcs_options} + + + + The data for one leaf. + + 1 + 1 + 0 + 1 + + + + + ADDED gc_core/py/oxt/helpers.py Index: gc_core/py/oxt/helpers.py ================================================================== --- /dev/null +++ gc_core/py/oxt/helpers.py @@ -0,0 +1,74 @@ +# Helpers for LibreOffice extension + +import os +import traceback + +import uno + +from com.sun.star.beans import PropertyValue +from com.sun.star.uno import RuntimeException as _rtex + + +def xray (myObject): + "XRay - API explorer" + try: + sm = uno.getComponentContext().ServiceManager + mspf = sm.createInstanceWithContext("com.sun.star.script.provider.MasterScriptProviderFactory", uno.getComponentContext()) + scriptPro = mspf.createScriptProvider("") + xScript = scriptPro.getScript("vnd.sun.star.script:XrayTool._Main.Xray?language=Basic&location=application") + xScript.invoke((myObject,), (), ()) + return + except: + raise _rtex("\nBasic library Xray is not installed", uno.getComponentContext()) + + +def mri (ctx, xTarget): + "MRI - API Explorer" + try: + xMri = ctx.ServiceManager.createInstanceWithContext("mytools.Mri", ctx) + xMri.inspect(xTarget) + except: + raise _rtex("\nPython extension MRI is not installed", uno.getComponentContext()) + + +def getConfigSetting (sNodeConfig, bUpdate=False): + "get a configuration node" + # example: xNode = getConfigSetting("/org.openoffice.Office.Common/Path/Current", False) + xSvMgr = uno.getComponentContext().ServiceManager + xConfigProvider = xSvMgr.createInstanceWithContext("com.sun.star.configuration.ConfigurationProvider", uno.getComponentContext()) + xPropertyValue = uno.createUnoStruct("com.sun.star.beans.PropertyValue") + xPropertyValue.Name = "nodepath" + xPropertyValue.Value = sNodeConfig + if bUpdate: + sService = "com.sun.star.configuration.ConfigurationUpdateAccess" + else: + sService = "com.sun.star.configuration.ConfigurationAccess" + return xConfigProvider.createInstanceWithArguments(sService, (xPropertyValue,)) # return xNode + + +def printServices (o): + for s in o.getAvailableServiceNames(): + print(' > '+s) + + +def getWindowSize (): + "return main window size" + xCurCtx = uno.getComponentContext() + xDesktop = xCurCtx.getServiceManager().createInstanceWithContext('com.sun.star.frame.Desktop', xCurCtx) + xContainerWindow = xDesktop.getCurrentComponent().CurrentController.Frame.ContainerWindow + xWindowSize = xContainerWindow.convertSizeToLogic(xContainerWindow.Size, uno.getConstantByName("com.sun.star.util.MeasureUnit.POINT")) + #print(xContainerWindow.Size.Width, ">", xWindowSize.Width) + #print(xContainerWindow.Size.Height, ">", xWindowSize.Height) + xWindowSize.Width = xWindowSize.Width * 0.666 + xWindowSize.Height = xWindowSize.Height * 0.666 + return xWindowSize + + +def getAbsolutePathOf (sPath=""): + xDefaultContext = uno.getComponentContext().ServiceManager.DefaultContext + xPackageInfoProvider = xDefaultContext.getValueByName("/singletons/com.sun.star.deployment.PackageInformationProvider") + sFullPath = xPackageInfoProvider.getPackageLocation("French.linguistic.resources.from.Dicollecte.by.OlivierR") + if sPath and not sPath.startswith("/"): + sPath = "/" + sPath + sFullPath = sFullPath[8:] + sPath + return os.path.abspath(sFullPath) Index: gc_lang/fr/config.ini ================================================================== --- gc_lang/fr/config.ini +++ gc_lang/fr/config.ini @@ -73,19 +73,23 @@ oxt/_img/Algoo_logo.png = img/Algoo_logo.png oxt/_img/grammalecte_16.bmp = img/grammalecte_16.bmp oxt/_img/french_flag_16.bmp = img/french_flag_16.bmp # AppLauncher oxt/AppLauncher.py = AppLauncher.py -oxt/helpers.py = pythonpath/helpers.py # About oxt/About/About.py = pythonpath/About.py oxt/About/ab_strings.py = pythonpath/ab_strings.py # Dictionaries oxt/Dictionnaires/dictionaries = dictionaries oxt/Dictionnaires/dictionaries.xcu = dictionaries.xcu oxt/Dictionnaires/DictionarySwitcher.py = pythonpath/DictionarySwitcher.py oxt/Dictionnaires/ds_strings.py = pythonpath/ds_strings.py +# Dictionary Options +oxt/DictOptions/DictOptions.py = pythonpath/DictOptions.py +oxt/DictOptions/do_strings.py = pythonpath/do_strings.py +oxt/DictOptions/LexiconEditor.py = pythonpath/LexiconEditor.py +oxt/DictOptions/lxe_strings.py = pythonpath/lxe_strings.py # ContextMenu oxt/ContextMenu/ContextMenu.py = ContextMenu.py oxt/ContextMenu/jobs.xcu = config/jobs.xcu # TextFormatter oxt/TextFormatter/TextFormatter.py = pythonpath/TextFormatter.py Index: gc_lang/fr/oxt/AppLauncher.py ================================================================== --- gc_lang/fr/oxt/AppLauncher.py +++ gc_lang/fr/oxt/AppLauncher.py @@ -40,10 +40,18 @@ xDialog.run() elif sCmd == "TF": import TextFormatter xDialog = TextFormatter.TextFormatter(self.ctx) xDialog.run(self.sLang) + elif sCmd == "DI": + import DictOptions + xDialog = DictOptions.DictOptions(self.ctx) + xDialog.run(self.sLang) + elif sCmd == "LE": + import LexiconEditor + xDialog = LexiconEditor.LexiconEditor(self.ctx) + xDialog.run(self.sLang) elif sCmd == "DS": import DictionarySwitcher xDialog = DictionarySwitcher.FrenchDictionarySwitcher(self.ctx) xDialog.run(self.sLang) elif sCmd == "MA": ADDED gc_lang/fr/oxt/DictOptions/DictOptions.py Index: gc_lang/fr/oxt/DictOptions/DictOptions.py ================================================================== --- /dev/null +++ gc_lang/fr/oxt/DictOptions/DictOptions.py @@ -0,0 +1,157 @@ +# Dictionary Options +# by Olivier R. +# License: MPL 2 + +import unohelper +import uno +import traceback +import time + +import helpers +import do_strings + +from com.sun.star.task import XJobExecutor +from com.sun.star.awt import XActionListener +from com.sun.star.beans import PropertyValue + + +class DictOptions (unohelper.Base, XActionListener, XJobExecutor): + + def __init__ (self, ctx): + self.ctx = ctx + self.xSvMgr = self.ctx.ServiceManager + self.xContainer = None + self.xDialog = None + + def _addWidget (self, name, wtype, x, y, w, h, **kwargs): + xWidget = self.xDialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype) + xWidget.Name = name + xWidget.PositionX = x + xWidget.PositionY = y + xWidget.Width = w + xWidget.Height = h + for k, w in kwargs.items(): + setattr(xWidget, k, w) + self.xDialog.insertByName(name, xWidget) + return xWidget + + def run (self, sLang): + dUI = do_strings.getUI(sLang) + + self.xSettingNode = helpers.getConfigSetting("/org.openoffice.Lightproof_grammalecte/Other/", True) + + # dialog + self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx) + self.xDialog.Width = 200 + self.xDialog.Height = 255 + self.xDialog.Title = dUI.get('title', "#title#") + xWindowSize = helpers.getWindowSize() + self.xDialog.PositionX = int((xWindowSize.Width / 2) - (self.xDialog.Width / 2)) + self.xDialog.PositionY = int((xWindowSize.Height / 2) - (self.xDialog.Height / 2)) + + # fonts + xFDTitle = uno.createUnoStruct("com.sun.star.awt.FontDescriptor") + xFDTitle.Height = 9 + xFDTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD") + xFDTitle.Name = "Verdana" + + xFDSubTitle = uno.createUnoStruct("com.sun.star.awt.FontDescriptor") + xFDSubTitle.Height = 8 + xFDSubTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD") + xFDSubTitle.Name = "Verdana" + + # widget + nX = 10 + nY1 = 10 + nY2 = nY1 + 50 + nY3 = nY2 + 70 + + nWidth = self.xDialog.Width - 20 + nHeight = 10 + + # Spell checker section + self._addWidget("spelling_section", 'FixedLine', nX, nY1, nWidth, nHeight, Label = dUI.get("spelling_section", "#err"), FontDescriptor = xFDTitle) + self.xGraphspell = self._addWidget('activate_main', 'CheckBox', nX, nY1+15, nWidth, nHeight, Label = dUI.get('activate_main', "#err")) + self._addWidget('activate_main_descr', 'FixedText', nX, nY1+25, nWidth, nHeight*2, Label = dUI.get('activate_main_descr', "#err"), MultiLine = True) + + # Spell suggestion engine section + self._addWidget("suggestion_section", 'FixedLine', nX, nY2, nWidth, nHeight, Label = dUI.get("suggestion_section", "#err"), FontDescriptor = xFDTitle) + self.xGraphspellSugg = self._addWidget('activate_spell_sugg', 'CheckBox', nX, nY2+15, nWidth, nHeight, Label = dUI.get('activate_spell_sugg', "#err")) + self._addWidget('activate_spell_sugg_descr', 'FixedText', nX, nY2+25, nWidth, nHeight*4, Label = dUI.get('activate_spell_sugg_descr', "#err"), MultiLine = True) + + # Personal dictionary section + self._addWidget("personal_section", 'FixedLine', nX, nY3, nWidth, nHeight, Label = dUI.get("personal_section", "#err"), FontDescriptor = xFDTitle) + self.xPersonalDic = self._addWidget('activate_personal', 'CheckBox', nX, nY3+15, nWidth, nHeight, Label = dUI.get('activate_personal', "#err")) + self._addWidget('activate_personnal_descr', 'FixedText', nX, nY3+25, nWidth, nHeight*3, Label = dUI.get('activate_personal_descr', "#err"), MultiLine = True) + self._addWidget('import_personal', 'FixedText', nX, nY3+55, nWidth-60, nHeight, Label = dUI.get('import_personal', "#err"), FontDescriptor = xFDSubTitle) + self.xMsg = self._addWidget('msg', 'FixedText', nX, nY3+65, nWidth-50, nHeight, Label = "[néant]") + self._addWidget('import_button', 'Button', self.xDialog.Width-50, nY3+65, 40, 10, Label = dUI.get('import_button', "#err"), TextColor = 0x005500) + self._addWidget('create_dictionary', 'FixedText', nX, nY3+75, nWidth, nHeight*2, Label = dUI.get('create_dictionary', "#err"), MultiLine = True) + + # Button + self._addWidget('apply_button', 'Button', self.xDialog.Width-120, self.xDialog.Height-25, 50, 14, Label = dUI.get('apply_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x005500) + self._addWidget('cancel_button', 'Button', self.xDialog.Width-60, self.xDialog.Height-25, 50, 14, Label = dUI.get('cancel_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x550000) + + self._loadOptions() + + # container + self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx) + self.xContainer.setModel(self.xDialog) + self.xContainer.getControl('apply_button').addActionListener(self) + self.xContainer.getControl('apply_button').setActionCommand('Apply') + self.xContainer.getControl('import_button').addActionListener(self) + self.xContainer.getControl('import_button').setActionCommand('Import') + self.xContainer.getControl('cancel_button').addActionListener(self) + self.xContainer.getControl('cancel_button').setActionCommand('Cancel') + self.xContainer.setVisible(False) + toolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx) + self.xContainer.createPeer(toolkit, None) + self.xContainer.execute() + + # XActionListener + def actionPerformed (self, xActionEvent): + try: + xChild = self.xSettingNode.getByName("o_fr") + if xActionEvent.ActionCommand == 'Apply': + xChild.setPropertyValue("graphspell", self.xGraphspell.State) + xChild.setPropertyValue("graphspellsugg", self.xGraphspellSugg.State) + #xChild.setPropertyValue("extended_dic", self.xExtendedDic.State) + xChild.setPropertyValue("personal_dic", self.xPersonalDic.State) + self.xSettingNode.commitChanges() + elif xActionEvent.ActionCommand == "Import": + xFilePicker = self.xSvMgr.createInstanceWithContext('com.sun.star.ui.dialogs.SystemFilePicker', self.ctx) + xFilePicker.appendFilter("Supported files", "*.json; *.bdic") + #xFilePicker.setDisplayDirectory("") + #xFilePicker.setMultiSelectionMode(True) + nResult = xFilePicker.execute() + if nResult == 1: + pass + #lFile = xFilePicker.getSelectedFiles() + #lFile = xFilePicker.getFiles() + else: + pass + self.xContainer.endExecute() + except: + traceback.print_exc() + + # XJobExecutor + def trigger (self, args): + try: + dialog = DictOptions(self.ctx) + dialog.run() + except: + traceback.print_exc() + + def _loadOptions (self): + try: + xChild = self.xSettingNode.getByName("o_fr") + self.xGraphspell.State = xChild.getPropertyValue("graphspell") + self.xGraphspellSugg.State = xChild.getPropertyValue("graphspellsugg") + #self.xExtendedDic.State = xChild.getPropertyValue("extended_dic") + self.xPersonalDic.State = xChild.getPropertyValue("personal_dic") + except: + traceback.print_exc() + + +#g_ImplementationHelper = unohelper.ImplementationHelper() +#g_ImplementationHelper.addImplementation(DictOptions, 'net.grammalecte.graphspell.DictOptions', ('com.sun.star.task.Job',)) ADDED gc_lang/fr/oxt/DictOptions/LexiconEditor.py Index: gc_lang/fr/oxt/DictOptions/LexiconEditor.py ================================================================== --- /dev/null +++ gc_lang/fr/oxt/DictOptions/LexiconEditor.py @@ -0,0 +1,264 @@ +# Lexicon Editor +# by Olivier R. +# License: GPL 3 + +import unohelper +import uno +import traceback + +import helpers +import lxe_strings +import grammalecte.graphspell as sc + +from com.sun.star.task import XJobExecutor +from com.sun.star.awt import XActionListener + + +def _waitPointer (funcDecorated): + def wrapper (*args, **kwargs): + # self is the first parameter if the decorator is applied on a object + self = args[0] + # before + xPointer = self.xSvMgr.createInstanceWithContext("com.sun.star.awt.Pointer", self.ctx) + xPointer.setType(uno.getConstantByName("com.sun.star.awt.SystemPointer.WAIT")) + xWindowPeer = self.xContainer.getPeer() + xWindowPeer.setPointer(xPointer) + for x in xWindowPeer.Windows: + x.setPointer(xPointer) + # processing + result = funcDecorated(*args, **kwargs) + # after + xPointer.setType(uno.getConstantByName("com.sun.star.awt.SystemPointer.ARROW")) + xWindowPeer.setPointer(xPointer) + for x in xWindowPeer.Windows: + x.setPointer(xPointer) + self.xContainer.setVisible(True) # seems necessary to refresh the dialog box and text widgets (why?) + # return + return result + return wrapper + + +class LexiconEditor (unohelper.Base, XActionListener, XJobExecutor): + + def __init__ (self, ctx): + self.ctx = ctx + self.xSvMgr = self.ctx.ServiceManager + self.xDesktop = self.xSvMgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx) + self.xDocument = self.xDesktop.getCurrentComponent() + self.xContainer = None + self.xDialog = None + self.oSpellChecker = None + + def _addWidget (self, name, wtype, x, y, w, h, **kwargs): + xWidget = self.xDialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype) + xWidget.Name = name + xWidget.PositionX = x + xWidget.PositionY = y + xWidget.Width = w + xWidget.Height = h + for k, w in kwargs.items(): + setattr(xWidget, k, w) + self.xDialog.insertByName(name, xWidget) + return xWidget + + def _addGrid (self, name, x, y, w, h, columns, **kwargs): + xGridModel = self.xDialog.createInstance('com.sun.star.awt.grid.UnoControlGridModel') + xGridModel.Name = name + xGridModel.PositionX = x + xGridModel.PositionY = y + xGridModel.Width = w + xGridModel.Height = h + xColumnModel = xGridModel.ColumnModel + for e in columns: + xCol = xColumnModel.createColumn() + for k, w in e.items(): + setattr(xCol, k, w) + xColumnModel.addColumn(xCol) + for k, w in kwargs.items(): + setattr(xGridModel, k, w) + self.xDialog.insertByName(name, xGridModel) + return xGridModel + + def run (self, sLang): + self.dUI = lxe_strings.getUI(sLang) + + # dialog + self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx) + self.xDialog.Width = 620 + self.xDialog.Height = 300 + self.xDialog.Title = self.dUI.get('title', "#title#") + xWindowSize = helpers.getWindowSize() + self.xDialog.PositionX = int((xWindowSize.Width / 2) - (self.xDialog.Width / 2)) + self.xDialog.PositionY = int((xWindowSize.Height / 2) - (self.xDialog.Height / 2)) + + # fonts + xFDTitle = uno.createUnoStruct("com.sun.star.awt.FontDescriptor") + xFDTitle.Height = 9 + xFDTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD") + xFDTitle.Name = "Verdana" + + xFDSubTitle = uno.createUnoStruct("com.sun.star.awt.FontDescriptor") + xFDSubTitle.Height = 8 + xFDSubTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD") + xFDSubTitle.Name = "Verdana" + + # widget + nX1 = 10 + nX2 = 20 + + nY1 = 5 + nY2 = nY1 + 25 # nom commun + nY3 = nY2 + 95 # nom propre + nY4 = nY3 + 45 # verbe + nY5 = nY4 + 70 # adverbe + nY6 = nY5 + 15 # autre + + nXB = nX1 + 195 + nXC = nXB + 205 + + nHeight = 10 + + #### Add word + self._addWidget("add_section", 'FixedLine', nX1, nY1, 190, nHeight, Label = self.dUI.get("add_section", "#err"), FontDescriptor = xFDTitle) + #self._addWidget('main_lemma_label', 'FixedText', nX1, nY1+10, 30, nHeight, Label = self.dUI.get('lemma', "#err")) + self.xLemma = self._addWidget('main_lemma', 'Edit', nX1, nY1+10, 120, nHeight+2) + + # Radio buttons: main POS tag + # Note: the only way to group RadioButtons is to create them successively + self.xNA = self._addWidget('nom_adj', 'RadioButton', nX1, nY2+12, 60, nHeight, Label = self.dUI.get("nom_adj", "#err")) + self.xN = self._addWidget('nom', 'RadioButton', nX1, nY2+22, 60, nHeight, Label = self.dUI.get("nom", "#err")) + self.xA = self._addWidget('adj', 'RadioButton', nX1, nY2+32, 60, nHeight, Label = self.dUI.get("adj", "#err")) + self.xM1 = self._addWidget('M1', 'RadioButton', nX1, nY3+12, 60, nHeight, Label = self.dUI.get("M1", "#err")) + self.xM2 = self._addWidget('M2', 'RadioButton', nX1, nY3+22, 60, nHeight, Label = self.dUI.get("M2", "#err")) + self.xMP = self._addWidget('MP', 'RadioButton', nX1, nY3+32, 60, nHeight, Label = self.dUI.get("MP", "#err")) + self.xV = self._addWidget('verb', 'RadioButton', nX1, nY4+2, 10, nHeight) + self.xW = self._addWidget('adv', 'RadioButton', nX1, nY5+2, 10, nHeight) + self.xX = self._addWidget('other', 'RadioButton', nX1, nY6+2, 10, nHeight) + + # Nom, adjectif + self._addWidget("fl_nom_adj", 'FixedLine', nX1, nY2, 190, nHeight, Label = self.dUI.get("common_name", "#err"), FontDescriptor = xFDSubTitle) + self.xSepi = self._addWidget('Sepi', 'RadioButton', nX1+65, nY2+12, 50, nHeight, Label = self.dUI.get("epi", "#err")) + self.xSmas = self._addWidget('Smas', 'RadioButton', nX1+65, nY2+22, 50, nHeight, Label = self.dUI.get("mas", "#err")) + self.xSfem = self._addWidget('Sfem', 'RadioButton', nX1+65, nY2+32, 50, nHeight, Label = self.dUI.get("fem", "#err")) + self.xSs = self._addWidget('S-s', 'RadioButton', nX1+120, nY2+12, 50, nHeight, Label = self.dUI.get("-s", "#err")) + self.xSx = self._addWidget('S-x', 'RadioButton', nX1+120, nY2+22, 50, nHeight, Label = self.dUI.get("-x", "#err")) + self.xSinv = self._addWidget('Sinv', 'RadioButton', nX1+120, nY2+32, 50, nHeight, Label = self.dUI.get("inv", "#err")) + + self._addWidget("alt_lemma_label", 'FixedLine', nX1+10, nY2+42, 180, nHeight, Label = self.dUI.get("alt_lemma", "#err")) + self.xAltLemma = self._addWidget('alt_lemma', 'Edit', nX1+10, nY2+52, 120, nHeight) + self.xNA2 = self._addWidget('nom_adj2', 'RadioButton', nX1+10, nY2+65, 60, nHeight, Label = self.dUI.get("nom_adj", "#err")) + self.xN2 = self._addWidget('nom2', 'RadioButton', nX1+10, nY2+75, 60, nHeight, Label = self.dUI.get("nom", "#err")) + self.xA2 = self._addWidget('adj2', 'RadioButton', nX1+10, nY2+85, 60, nHeight, Label = self.dUI.get("adj", "#err")) + self.xSepi2 = self._addWidget('Sepi2', 'RadioButton', nX1+75, nY2+65, 50, nHeight, Label = self.dUI.get("epi", "#err")) + self.xSmas2 = self._addWidget('Smas2', 'RadioButton', nX1+75, nY2+75, 50, nHeight, Label = self.dUI.get("mas", "#err")) + self.xSfem2 = self._addWidget('Sfem2', 'RadioButton', nX1+75, nY2+85, 50, nHeight, Label = self.dUI.get("fem", "#err")) + self.xSs2 = self._addWidget('S-s2', 'RadioButton', nX1+130, nY2+65, 50, nHeight, Label = self.dUI.get("-s", "#err")) + self.xSx2 = self._addWidget('S-x2', 'RadioButton', nX1+130, nY2+75, 50, nHeight, Label = self.dUI.get("-x", "#err")) + self.xSinv2 = self._addWidget('Sinv2', 'RadioButton', nX1+130, nY2+85, 50, nHeight, Label = self.dUI.get("inv", "#err")) + + # Nom propre + self._addWidget("fl_M", 'FixedLine', nX1, nY3, 190, nHeight, Label = self.dUI.get("proper_name", "#err"), FontDescriptor = xFDSubTitle) + self.xMepi = self._addWidget('Mepi', 'RadioButton', nX1+65, nY3+12, 50, nHeight, Label = self.dUI.get("epi", "#err")) + self.xMmas = self._addWidget('Mmas', 'RadioButton', nX1+65, nY3+22, 50, nHeight, Label = self.dUI.get("mas", "#err")) + self.xMfem = self._addWidget('Mfem', 'RadioButton', nX1+65, nY3+32, 50, nHeight, Label = self.dUI.get("fem", "#err")) + + # Verbe + self._addWidget("fl_verb", 'FixedLine', nX2, nY4, 180, nHeight, Label = self.dUI.get("verb", "#err"), FontDescriptor = xFDSubTitle) + self.xV_i = self._addWidget('v_i', 'CheckBox', nX2, nY4+12, 60, nHeight, Label = self.dUI.get("v_i", "#err")) + self.xV_t = self._addWidget('v_t', 'CheckBox', nX2, nY4+20, 60, nHeight, Label = self.dUI.get("v_t", "#err")) + self.xV_n = self._addWidget('v_n', 'CheckBox', nX2, nY4+28, 60, nHeight, Label = self.dUI.get("v_n", "#err")) + self.xV_p = self._addWidget('v_p', 'CheckBox', nX2, nY4+36, 60, nHeight, Label = self.dUI.get("v_p", "#err")) + self.xV_m = self._addWidget('v_m', 'CheckBox', nX2, nY4+44, 60, nHeight, Label = self.dUI.get("v_m", "#err")) + + self._addWidget('aux', 'FixedText', nX2+75, nY4+10, 90, nHeight, Label = self.dUI.get("aux", "#err")) + self.xV_ae = self._addWidget('v_ae', 'CheckBox', nX2+75, nY4+20, 90, nHeight, Label = self.dUI.get("v_ae", "#err")) + self.xV_aa = self._addWidget('v_aa', 'CheckBox', nX2+75, nY4+28, 90, nHeight, Label = self.dUI.get("v_aa", "#err")) + + self.xV_pp = self._addWidget('v_pp', 'CheckBox', nX2+75, nY4+44, 90, nHeight, Label = self.dUI.get("v_pp", "#err")) + + self._addWidget('v_pattern_label', 'FixedText', nX2+10, nY4+56, 70, nHeight, Label = self.dUI.get('v_pattern', "#err"), Align = 2) + self.xVpattern = self._addWidget('v_pattern', 'Edit', nX2+85, nY4+56, 80, nHeight) + + # Adverbe + self._addWidget("fl_adv", 'FixedLine', nX2, nY5, 180, nHeight, Label = self.dUI.get("adverb", "#err"), FontDescriptor = xFDSubTitle) + + # Autre + self._addWidget("fl_other", 'FixedLine', nX2, nY6, 180, nHeight, Label = self.dUI.get("other", "#err"), FontDescriptor = xFDSubTitle) + self._addWidget('flexion_label', 'FixedText', nX2, nY6+10, 85, nHeight, Label = self.dUI.get('flexion', "#err")) + self.xFlexion = self._addWidget('flexion', 'Edit', nX2, nY6+20, 85, nHeight) + self._addWidget('tags_label', 'FixedText', nX2+90, nY6+10, 85, nHeight, Label = self.dUI.get('tags', "#err")) + self.xTags = self._addWidget('tags', 'Edit', nX2+90, nY6+20, 85, nHeight) + + #### Generated words + self._addWidget("gwords_section", 'FixedLine', nXB, nY1, 200, nHeight, Label = self.dUI.get("new_section", "#err"), FontDescriptor = xFDTitle) + self.xGridModelNew = self._addGrid("list_grid_gwords", nXB, nY1+10, 200, 200, [ + {"Title": self.dUI.get("lex_flex", "#err"), "ColumnWidth": 80}, + {"Title": self.dUI.get("lex_lemma", "#err"), "ColumnWidth": 50}, + {"Title": self.dUI.get("lex_tags", "#err"), "ColumnWidth": 50} + ]) + self._addWidget("dictionary_section", 'FixedLine', nXB, nY1+210, 200, nHeight, Label = self.dUI.get("dictionary_section", "#err"), FontDescriptor = xFDTitle) + + #### Lexicon section + self._addWidget("lexicon_section", 'FixedLine', nXC, nY1, 200, nHeight, Label = self.dUI.get("lexicon_section", "#err"), FontDescriptor = xFDTitle) + self.xGridModelLex = self._addGrid("list_grid_lexicon", nXC, nY1+10, 200, 255, [ + {"Title": self.dUI.get("lex_flex", "#err"), "ColumnWidth": 80}, + {"Title": self.dUI.get("lex_lemma", "#err"), "ColumnWidth": 50}, + {"Title": self.dUI.get("lex_tags", "#err"), "ColumnWidth": 50} + ]) + + # Close + self._addWidget('close_button', 'Button', self.xDialog.Width-60, self.xDialog.Height-20, 50, 14, Label = self.dUI.get('close_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x550000) + + # container + self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx) + self.xContainer.setModel(self.xDialog) + self.xGridControlNew = self.xContainer.getControl('list_grid_gwords') + self.xGridControlLex = self.xContainer.getControl('list_grid_lexicon') + #self.xContainer.getControl('add_button').addActionListener(self) + #self.xContainer.getControl('add_button').setActionCommand('Add') + #self.xContainer.getControl('delete_button').addActionListener(self) + #self.xContainer.getControl('delete_button').setActionCommand('Delete') + #self.xContainer.getControl('save_button').addActionListener(self) + #self.xContainer.getControl('save_button').setActionCommand('Save') + self.xContainer.getControl('close_button').addActionListener(self) + self.xContainer.getControl('close_button').setActionCommand('Close') + self.xContainer.setVisible(False) + xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx) + self.xContainer.createPeer(xToolkit, None) + self.xContainer.execute() + + # XActionListener + def actionPerformed (self, xActionEvent): + try: + if xActionEvent.ActionCommand == "Add": + pass + elif xActionEvent.ActionCommand == "Delete": + pass + elif xActionEvent.ActionCommand == "Save": + pass + elif xActionEvent.ActionCommand == "Close": + self.xContainer.endExecute() + except: + traceback.print_exc() + + # XJobExecutor + def trigger (self, args): + try: + xDialog = LexiconEditor(self.ctx) + xDialog.run() + except: + traceback.print_exc() + + # Code + @_waitPointer + def add (self): + pass + + @_waitPointer + def loadLexicon (self): + pass + + + +#g_ImplementationHelper = unohelper.ImplementationHelper() +#g_ImplementationHelper.addImplementation(LexiconEditor, 'net.grammalecte.LexiconEditor', ('com.sun.star.task.Job',)) ADDED gc_lang/fr/oxt/DictOptions/do_strings.py Index: gc_lang/fr/oxt/DictOptions/do_strings.py ================================================================== --- /dev/null +++ gc_lang/fr/oxt/DictOptions/do_strings.py @@ -0,0 +1,49 @@ +def getUI (sLang): + if sLang in dStrings: + return dStrings[sLang] + return dStrings["fr"] + +dStrings = { + "fr": { + "title": "Grammalecte · Options des dictionnaires", + + "spelling_section": "Correcteur orthographique", + "activate_main": "Activer le correcteur orthographique de Grammalecte", + "activate_main_descr": "Supplante le correcteur orthographique inclus dans LibreOffice (Hunspell).", + + "personal_section": "Dictionnaire personnel", + "activate_personal": "Utiliser", + "activate_personal_descr": "Le dictionnaire personnel est une commodité pour ajouter le vocabulaire qui vous est utile. Il ne supplante pas le dictionnaire commun ; il ne fait qu’ajouter de nouveaux mots.", + "import_personal": "Importer un dictionnaire personnel", + "import_button": "Importer", + "create_dictionary": "Vous pouvez créer un dictionnaire personnel avec l’extension Grammalecte pour Firefox ou Chrome.", + + "suggestion_section": "Moteur de suggestion orthographique", + "activate_spell_sugg": "Activer le moteur de suggestion de Grammalecte", + "activate_spell_sugg_descr": "Désactivée, cette option remplace la suggestion orthographique de Grammalecte par celle fournie par LibreOffice (Hunspell). Les mots inclus dans le dictionnaire personnalisé ne seront plus inclus aux suggestions.", + + "apply_button": "Appliquer", + "cancel_button": "Annuler", + }, + "en": { + "title": "Grammalecte · Options for dictionaries", + + "spelling_section": "Spell checker", + "activate_main": "Activate the spell checker from Grammalecte", + "activate_main_descr": "Overrides the spell checker included in LibreOffice (Hunspell)", + + "personal_section": "Personal dictionary", + "activate_personal": "Use", + "activate_personal_descr": "The personal dictionary is a commodity to add the vocabulary you want. It doesn’t override the common dictionary ; it only adds new words.", + "import_personal": "Import a personal dictionary", + "import_button": "Import", + "create_dictionary": "You can create a personal dictionary with the Grammalecte addon for Firefox or Chrome.", + + "suggestion_section": "Spell suggestion engine", + "activate_spell_sugg": "Activate the suggestion engine of Grammalecte", + "activate_spell_sugg_descr": "Disactivated, this option replace the spell suggestion engine of Grammalecte by the one of LibreOffice (Hunspell). Words included in the personal dictionary won’t be included among suggestions.", + + "apply_button": "Apply", + "cancel_button": "Cancel", + }, +} ADDED gc_lang/fr/oxt/DictOptions/lxe_strings.py Index: gc_lang/fr/oxt/DictOptions/lxe_strings.py ================================================================== --- /dev/null +++ gc_lang/fr/oxt/DictOptions/lxe_strings.py @@ -0,0 +1,78 @@ +def getUI (sLang): + if sLang in dStrings: + return dStrings[sLang] + return dStrings["fr"] + +dStrings = { + "fr": { + "title": "Grammalecte · Éditeur lexical", + + # Ajout + "add_section": "Nouveau mot (lemme)", + "lemma": "Lemme", + + # catégories + "common_name": "Nom commun", + "nom_adj": "Nom et adjectif", + "nom": "Nom", + "adj": "Adjectif", + "alt_lemma": "[optionnel] Autre forme (masculine, féminine, variante, etc.)", + + "proper_name": "Nom propre", + "M1": "Prénom", + "M2": "Patronyme", + "MP": "Autre", + + "gender": "Genre", + "epi": "épicène", + "mas": "masculin", + "fem": "féminin", + "plural": "Pluriel", + "-s": "pluriel en ·s", + "-x": "pluriel en ·x", + "inv": "invariable", + + "verb": "Verbe", + "v_i": "intransitif", + "v_t": "transitif", + "v_n": "transitif indirect", + "v_p": "pronominal", + "v_m": "impersonnel", + "aux": "Auxiliaire au passé composé", + "v_ae": "être", + "v_aa": "avoir", + "v_pp": "Participes passés variables", + "v_pattern": "Verbe modèle [optionnel]", + + "adverb": "Adverbe", + + "other": "Autre", + "flexion": "Flexion", + "tags": "Étiquettes", + + "add_button": "Ajouter", + + # Lexicon + "new_section": "Mots générés", + "lexicon_section": "Votre lexique", + "lex_#": "#", + "lex_flex": "Flexions", + "lex_lemma": "Lemmes", + "lex_tags": "Étiquettes", + "delete_button": "Supprimer", + + # Dictionnaire + "dictionary_section": "Dictionnaire enregistré", + "num_of_entries": "Nombre d’entrées", + "save_date": "Date d’enregistrement", + + # + "close_button": "Fermer", + }, + # Traduction délibérément limitée + "en": { + "title": "Grammalecte · Lexical editor", + + "close_button": "Close", + }, +} Index: gc_lang/fr/oxt/TextFormatter/TextFormatter.py ================================================================== --- gc_lang/fr/oxt/TextFormatter/TextFormatter.py +++ gc_lang/fr/oxt/TextFormatter/TextFormatter.py @@ -383,17 +383,12 @@ for key, lWidget in self.dCheckboxWidgets.items(): w = getattr(self, key) dOpt[w.Name] = w.State for w in lWidget: dOpt[w.Name] = w.State - # get extension path - xDefaultContext = self.ctx.ServiceManager.DefaultContext - xPackageInfoProvider = xDefaultContext.getValueByName("/singletons/com.sun.star.deployment.PackageInformationProvider") - sExtPath = xPackageInfoProvider.getPackageLocation("French.linguistic.resources.from.Dicollecte.by.OlivierR") - sExtPath = sExtPath[8:] + "/pythonpath/tf_options.py" # remove "file:///" - sExtPath = os.path.abspath(sExtPath) # write file + sExtPath = helpers.getAbsolutePathOf("/pythonpath/tf_options.py") if os.path.isfile(sExtPath): hOpt = open(sExtPath, "w") hOpt.write("dDefaultOpt = " + str(tf_options.dDefaultOpt) + "\n") hOpt.write("dOpt = " + str(dOpt)) hOpt.close() Index: gc_lang/fr/oxt/addons.xcu ================================================================== --- gc_lang/fr/oxt/addons.xcu +++ gc_lang/fr/oxt/addons.xcu @@ -75,11 +75,11 @@ service:net.grammalecte.AppLauncher?EN ~Recenseur de mots… - ~Enumerator of words… + Enumerato~r of words… _self @@ -134,10 +134,48 @@ org.dicollecte.images:Grammalecte + + service:net.grammalecte.AppLauncher?DI + + + + ~Options des dictionnaires… + Dictionaries ~options… + + + _self + + + com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument + + + org.dicollecte.images:Frenchflag + + + + + service:net.grammalecte.AppLauncher?LE + + + + Éditeur ~lexical… + ~Lexicon editor… + + + _self + + + com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument + + + org.dicollecte.images:Frenchflag + + + service:net.grammalecte.AppLauncher?DS @@ -152,19 +190,19 @@ org.dicollecte.images:Frenchflag - + private:separator com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument - + service:net.grammalecte.AppLauncher?About DELETED gc_lang/fr/oxt/helpers.py Index: gc_lang/fr/oxt/helpers.py ================================================================== --- gc_lang/fr/oxt/helpers.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf8 -*- - -import uno -import traceback - -from com.sun.star.beans import PropertyValue - - -# XRay - API explorer -from com.sun.star.uno import RuntimeException as _rtex -def xray (myObject): - try: - sm = uno.getComponentContext().ServiceManager - mspf = sm.createInstanceWithContext("com.sun.star.script.provider.MasterScriptProviderFactory", uno.getComponentContext()) - scriptPro = mspf.createScriptProvider("") - xScript = scriptPro.getScript("vnd.sun.star.script:XrayTool._Main.Xray?language=Basic&location=application") - xScript.invoke((myObject,), (), ()) - return - except: - raise _rtex("\nBasic library Xray is not installed", uno.getComponentContext()) - - -# MRI - API Explorer -def mri (ctx, xTarget): - try: - xMri = ctx.ServiceManager.createInstanceWithContext("mytools.Mri", ctx) - xMri.inspect(xTarget) - except: - raise _rtex("\Python extension MRI is not installed", uno.getComponentContext()) - - -def getConfigSetting (sNodeConfig, bUpdate): - "get a configuration node" - # example: xNode = getConfigSetting("/org.openoffice.Office.Common/Path/Current", False) - xSvMgr = uno.getComponentContext().ServiceManager - xConfigProvider = xSvMgr.createInstanceWithContext("com.sun.star.configuration.ConfigurationProvider", uno.getComponentContext()) - xPropertyValue = uno.createUnoStruct("com.sun.star.beans.PropertyValue") - xPropertyValue.Name = "nodepath" - xPropertyValue.Value = sNodeConfig - if bUpdate: - sService = "com.sun.star.configuration.ConfigurationUpdateAccess" - else: - sService = "com.sun.star.configuration.ConfigurationAccess" - return xConfigProvider.createInstanceWithArguments(sService, (xPropertyValue,)) # return xNode - - -def printServices (o): - for s in o.getAvailableServiceNames(): - print(' > '+s) - - -def getWindowSize (): - "return main window size" - xCurCtx = uno.getComponentContext() - xDesktop = xCurCtx.getServiceManager().createInstanceWithContext('com.sun.star.frame.Desktop', xCurCtx) - xContainerWindow = xDesktop.getCurrentComponent().CurrentController.Frame.ContainerWindow - xWindowSize = xContainerWindow.convertSizeToLogic(xContainerWindow.Size, uno.getConstantByName("com.sun.star.util.MeasureUnit.POINT")) - #print(xContainerWindow.Size.Width, ">", xWindowSize.Width) - #print(xContainerWindow.Size.Height, ">", xWindowSize.Height) - xWindowSize.Width = xWindowSize.Width * 0.666 - xWindowSize.Height = xWindowSize.Height * 0.666 - return xWindowSize Index: make.py ================================================================== --- make.py +++ make.py @@ -84,10 +84,11 @@ # Extension files hZip.writestr("META-INF/manifest.xml", helpers.fileFile("gc_core/py/oxt/manifest.xml", dVars)) hZip.writestr("description.xml", helpers.fileFile("gc_core/py/oxt/description.xml", dVars)) hZip.writestr("Linguistic.xcu", helpers.fileFile("gc_core/py/oxt/Linguistic.xcu", dVars)) hZip.writestr("Grammalecte.py", helpers.fileFile("gc_core/py/oxt/Grammalecte.py", dVars)) + hZip.writestr("pythonpath/helpers.py", helpers.fileFile("gc_core/py/oxt/helpers.py", dVars)) for sf in dVars["extras"].split(","): hZip.writestr(sf.strip(), helpers.fileFile(spLang + '/' + sf.strip(), dVars)) if "logo" in dVars.keys() and dVars["logo"].strip():