Grammalecte  Check-in [3eef67439f]

Overview
Comment:[lo] use Dialog for dictionaries to set Hunspell dictionary also
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256: 3eef67439f5b6df31e2c6a02f26cde7ae610c011b835aa2ba86f69d67fc01623
User & Date: olr on 2019-04-29 16:24:42
Other Links: manifest | tags
Context
2019-04-29
16:36
[lo] remove dictionary switcher (deprecated code) check-in: 1daf45b00e user: olr tags: trunk, lo
16:24
[lo] use Dialog for dictionaries to set Hunspell dictionary also check-in: 3eef67439f user: olr tags: trunk, lo
15:34
[lo] Dictionary switcher: code cleaning, doesn’t work anymore for an obscure reason (though it works in another dialog) check-in: e60cef893b user: olr tags: trunk, lo
Changes

Modified gc_lang/fr/oxt/DictOptions/DictOptions.py from [ddd3fdd4f4] to [427b5db60b].

1
2
3
4
5
6

7
8
9
10
11
12
13
# 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






>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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
47
48
49
50
51
52
53
54






55
56
57
58
59
60
61
        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()







|
>
>
>
>
>
>







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
        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()
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
        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()

    # XJobExecutor
    def trigger (self, args):
        try:
            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







>
|



<

|
>

|
>

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


















|







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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
        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()

    # XJobExecutor
    def trigger (self, args):
        try:
            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

Modified gc_lang/fr/oxt/Dictionnaires/dictionaries.xcu from [364c96ad52] to [4e98e6e385].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?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="Linguistic" oor:package="org.openoffice.Office">
 <node oor:name="ServiceManager">
    <node oor:name="Dictionaries">
        <node oor:name="HunSpellDic_fr" oor:op="fuse">
            <prop oor:name="Locations" oor:type="oor:string-list">
                <value>%origin%/dictionaries/fr-classique.aff %origin%/dictionaries/fr-classique.dic</value>
            </prop>
            <prop oor:name="Format" oor:type="xs:string">
                <value>DICT_SPELL</value>
            </prop>
            <prop oor:name="Locales" oor:type="oor:string-list">
                <value>fr-MC</value>
                <!-- <value>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</value> -->
                <!-- France, Belgique, Canada, Suisse, Luxembourg, Monaco -->
                <!-- Burkina Faso, Côte d’Ivoire, Sénégal, Mali, Niger, Togo, Benin -->
            </prop>
        </node>
        <node oor:name="HyphDic_fr" oor:op="fuse">
            <prop oor:name="Locations" oor:type="oor:string-list">












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?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="Linguistic" oor:package="org.openoffice.Office">
 <node oor:name="ServiceManager">
    <node oor:name="Dictionaries">
        <node oor:name="HunSpellDic_fr" oor:op="fuse">
            <prop oor:name="Locations" oor:type="oor:string-list">
                <value>%origin%/dictionaries/fr-classique.aff %origin%/dictionaries/fr-classique.dic</value>
            </prop>
            <prop oor:name="Format" oor:type="xs:string">
                <value>DICT_SPELL</value>
            </prop>
            <prop oor:name="Locales" oor:type="oor:string-list">
                <value>fr-MC</value> <!-- Monaco uniquement, pour avoir encore accès aux dictionnaires Hunspell si besoin -->
                <!-- <value>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</value> -->
                <!-- France, Belgique, Canada, Suisse, Luxembourg, Monaco -->
                <!-- Burkina Faso, Côte d’Ivoire, Sénégal, Mali, Niger, Togo, Benin -->
            </prop>
        </node>
        <node oor:name="HyphDic_fr" oor:op="fuse">
            <prop oor:name="Locations" oor:type="oor:string-list">
35
36
37
38
39
40
41
42
43
                <value>DICT_THES</value>
            </prop>
            <prop oor:name="Locales" oor:type="oor:string-list">
                <value>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</value>
            </prop>
        </node>
    </node>
 </node>  
</oor:component-data>







|

35
36
37
38
39
40
41
42
43
                <value>DICT_THES</value>
            </prop>
            <prop oor:name="Locales" oor:type="oor:string-list">
                <value>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</value>
            </prop>
        </node>
    </node>
 </node>
</oor:component-data>