Grammalecte  Diff

Differences From Artifact [ddd3fdd4f4]:

To Artifact [427b5db60b]:


1
2
3
4
5
6

7
8
9
10
11
12
13
..
47
48
49
50
51
52
53
54






55
56
57
58
59
60
61
...
126
127
128
129
130
131
132

133
134
135
136
137
138
139

140
141

142
143




144
145










146
147
148
149
150
151
152
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# 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
................................................................................
        return xWidget

    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)







        # dialog
        self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx)
        self.xDialog.Width = 200
        self.xDialog.Height = 285
        self.xDialog.Title = self.dUI.get('title', "#title#")
        xWindowSize = helpers.getWindowSize()
................................................................................
        self.xContainer.createPeer(toolkit, None)
        self.xContainer.execute()

    # XActionListener
    def actionPerformed (self, xActionEvent):
        try:
            if xActionEvent.ActionCommand == 'Apply':

                xChild = self.xOptionNode.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"

                elif self.xSelReform.State:
                    sMainDicName = "reform"

                elif self.xSelAllvars.State:
                    sMainDicName = "allvars"




                xChild.setPropertyValue("main_dic_name", sMainDicName)
                self.xOptionNode.commitChanges()










                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()
        except:
            traceback.print_exc()
................................................................................
            dialog = DictOptions(self.ctx)
            dialog.run()
        except:
            traceback.print_exc()

    def _loadOptions (self):
        try:
            xChild = self.xOptionNode.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")
            if sMainDicName == "classic":
                self.xSelClassic.State = 1






>







 







|
>
>
>
>
>
>







 







>
|



<

|
>

|
>

|
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>







 







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
...
133
134
135
136
137
138
139
140
141
142
143
144

145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
...
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# Dictionary Options
# by Olivier R.
# License: MPL 2

import unohelper
import uno
import re
import traceback

import helpers
import do_strings

from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener
................................................................................
        return xWidget

    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.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
        self.xDialog.Title = self.dUI.get('title', "#title#")
        xWindowSize = helpers.getWindowSize()
................................................................................
        self.xContainer.createPeer(toolkit, None)
        self.xContainer.execute()

    # XActionListener
    def actionPerformed (self, xActionEvent):
        try:
            if xActionEvent.ActionCommand == 'Apply':
                # 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)

                if self.xSelClassic.State:
                    sMainDic = "classic"
                    sHunspellDic = "classique"
                elif self.xSelReform.State:
                    sMainDic = "reform"
                    sHunspellDic = "reforme1990"
                elif self.xSelAllvars.State:
                    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()
        except:
            traceback.print_exc()
................................................................................
            dialog = DictOptions(self.ctx)
            dialog.run()
        except:
            traceback.print_exc()

    def _loadOptions (self):
        try:
            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")
            if sMainDicName == "classic":
                self.xSelClassic.State = 1