Index: gc_lang/fr/oxt/DictOptions/DictOptions.py ================================================================== --- gc_lang/fr/oxt/DictOptions/DictOptions.py +++ gc_lang/fr/oxt/DictOptions/DictOptions.py @@ -2,10 +2,11 @@ # by Olivier R. # License: MPL 2 import unohelper import uno +import re import traceback import helpers import do_strings @@ -49,11 +50,17 @@ def run (self, sLang): self.dUI = do_strings.getUI(sLang) self.xDesktop = self.xSvMgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx) self.xDocument = self.xDesktop.getCurrentComponent() - self.xOptionNode = helpers.getConfigSetting("/org.openoffice.Lightproof_grammalecte/Other/", True) + self.xGLOptionNode = helpers.getConfigSetting("/org.openoffice.Lightproof_grammalecte/Other/", True) + + # what is the current Hunspell dictionary + self.xHunspellNode = helpers.getConfigSetting("/org.openoffice.Office.Linguistic/ServiceManager/Dictionaries/HunSpellDic_fr", True) + xLocations = self.xHunspellNode.getByName("Locations") + m = re.search(r"fr-(\w*)\.(?:dic|aff)", xLocations[0]) + self.sHunspellCurrentDic = m.group(1) if m else "" # dialog self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx) self.xDialog.Width = 200 self.xDialog.Height = 285 @@ -128,23 +135,39 @@ # XActionListener def actionPerformed (self, xActionEvent): try: if xActionEvent.ActionCommand == 'Apply': - xChild = self.xOptionNode.getByName("o_fr") + # Grammalecte options + xChild = self.xGLOptionNode.getByName("o_fr") #xChild.setPropertyValue("use_community_dic", self.xCommunityDic.State) xChild.setPropertyValue("use_personal_dic", self.xPersonalDic.State) xChild.setPropertyValue("use_graphspell_sugg", self.xGraphspellSugg.State) - sMainDicName = "classic" if self.xSelClassic.State: - sMainDicName = "classic" + sMainDic = "classic" + sHunspellDic = "classique" elif self.xSelReform.State: - sMainDicName = "reform" + sMainDic = "reform" + sHunspellDic = "reforme1990" elif self.xSelAllvars.State: - sMainDicName = "allvars" - xChild.setPropertyValue("main_dic_name", sMainDicName) - self.xOptionNode.commitChanges() + sMainDic = "allvars" + sHunspellDic = "toutesvariantes" + else: + sMainDic = "classic" + sHunspellDic = "classique" + xChild.setPropertyValue("main_dic_name", sMainDic) + self.xGLOptionNode.commitChanges() + + # Hunspell options + xLocations = self.xHunspellNode.getByName("Locations") + v1 = xLocations[0].replace(self.sHunspellCurrentDic, sHunspellDic) + v2 = xLocations[1].replace(self.sHunspellCurrentDic, sHunspellDic) + #self.xHunspellNode.replaceByName("Locations", xLocations) # doesn't work, see line below + uno.invoke(self.xHunspellNode, "replaceByName", ("Locations", uno.Any("[]string", (v1, v2)))) + self.xHunspellNode.commitChanges() + + # Close window self.xContainer.endExecute() elif xActionEvent.ActionCommand == 'InfoDic': MessageBox(self.xDocument, self.dUI.get('spelling_descr', "#err"), "Orthographe du français", nBoxType=INFOBOX, nBoxButtons=BUTTONS_OK) else: self.xContainer.endExecute() @@ -159,11 +182,11 @@ except: traceback.print_exc() def _loadOptions (self): try: - xChild = self.xOptionNode.getByName("o_fr") + xChild = self.xGLOptionNode.getByName("o_fr") #self.xGraphspell.State = xChild.getPropertyValue("use_graphspell") self.xGraphspellSugg.State = xChild.getPropertyValue("use_graphspell_sugg") #self.xCommunityDic.State = xChild.getPropertyValue("use_community_dic") self.xPersonalDic.State = xChild.getPropertyValue("use_personal_dic") sMainDicName = xChild.getPropertyValue("main_dic_name") Index: gc_lang/fr/oxt/Dictionnaires/dictionaries.xcu ================================================================== --- gc_lang/fr/oxt/Dictionnaires/dictionaries.xcu +++ gc_lang/fr/oxt/Dictionnaires/dictionaries.xcu @@ -8,11 +8,11 @@ DICT_SPELL - fr-MC + fr-MC @@ -37,7 +37,7 @@ fr-FR fr-BE fr-CA fr-CH fr-LU fr-MC fr-BF fr-BJ fr-CD fr-CI fr-CM fr-MA fr-ML fr-MU fr-NE fr-RE fr-SN fr-TG - +