Index: gc_lang/fr/config.ini ================================================================== --- gc_lang/fr/config.ini +++ gc_lang/fr/config.ini @@ -82,10 +82,13 @@ # 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 # 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,14 @@ 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 == "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,134 @@ +# Dictionary Options +# by Olivier R. +# License: MPL 2 + +import unohelper +import uno +import traceback + +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) + + # what is the current dictionary + xSettings = helpers.getConfigSetting("/org.openoffice.Office.Linguistic/ServiceManager/Dictionaries/HunSpellDic_fr", False) + xLocations = xSettings.getByName("Locations") + + # dialog + self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx) + self.xDialog.Width = 200 + self.xDialog.Height = 290 + 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.xActivateMain = self._addWidget('activate_main', 'CheckBox', nX, nY1+15, nWidth, nHeight, Label = dUI.get('activate_main', "#err"), State = True) + 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.xActivateSugg = self._addWidget('activate_spell_sugg', 'CheckBox', nX, nY2+15, nWidth, nHeight, Label = dUI.get('activate_spell_sugg', "#err"), State = True) + 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.xActivatePersonnal = self._addWidget('activate_personal', 'CheckBox', nX, nY3+15, nWidth, nHeight, Label = dUI.get('activate_personal', "#err"), State = True) + 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, nHeight, Label = dUI.get('import_personal', "#err"), FontDescriptor = xFDSubTitle) + + 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"), TextColor = 0x00AA00) + self._addWidget('cancel_button', 'Button', self.xDialog.Width-10, self.xDialog.Height-25, 50, 14, Label = dUI.get('cancel_button', "#err"), TextColor = 0xAA0000) + + # 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('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: + if xActionEvent.ActionCommand == 'Apply': + if False: + # Modify the registry + xSettings = helpers.getConfigSetting("/org.openoffice.Office.Linguistic/ServiceManager/Dictionaries/HunSpellDic_fr", True) + xLocations = xSettings.getByName("Locations") + v1 = xLocations[0].replace(self.sCurrentDic, self.sSelectedDic) + v2 = xLocations[1].replace(self.sCurrentDic, self.sSelectedDic) + #xSettings.replaceByName("Locations", xLocations) # doesn't work, see line below + uno.invoke(xSettings, "replaceByName", ("Locations", uno.Any("[]string", (v1, v2)))) + xSettings.commitChanges() + self.xContainer.endExecute() + except: + traceback.print_exc() + + # XJobExecutor + def trigger (self, args): + try: + dialog = DictOptions(self.ctx) + dialog.run() + 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/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": "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": "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", + }, +} Index: gc_lang/fr/oxt/addons.xcu ================================================================== --- gc_lang/fr/oxt/addons.xcu +++ gc_lang/fr/oxt/addons.xcu @@ -118,10 +118,29 @@ 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?DS @@ -136,19 +155,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