Grammalecte  Check-in [efad935afc]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[lo] graphic options for Writer: underling style and colors
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256:efad935afcbfcef56e5b5222f94e65970816cf7300433001920ccfbfee0fe9cf
User & Date: olr 2019-06-10 17:22:34
Context
2019-06-10
18:00
[lo] graphic option: update labels -> for LO 6.3+ check-in: 1934da7c59 user: olr tags: lo, trunk
17:22
[lo] graphic options for Writer: underling style and colors check-in: efad935afc user: olr tags: lo, trunk
07:14
[core] change the paragraph slicer check-in: 01d15e4e8d user: olr tags: core, trunk
Changes

Changes to gc_core/py/lang_core/gc_engine.py.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
..
49
50
51
52
53
54
55



56
57
58
59
60
61
62
...
187
188
189
190
191
192
193



















194
195
196
197
198
199
200
...
659
660
661
662
663
664
665
666
667


668
669
670
671
672
673
674
675
676
except ImportError:
    _bWriterError = False


__all__ = [ "lang", "locales", "pkg", "name", "version", "author", \
            "load", "parse", "getSpellChecker", \
            "setOption", "setOptions", "getOptions", "getDefaultOptions", "getOptionsLabels", "resetOptions", "displayOptions", \
            "ignoreRule", "resetIgnoreRules", "reactivateRule", "listRules", "displayRules" ]

__version__ = "${version}"


lang = "${lang}"
locales = ${loc}
pkg = "${implname}"
................................................................................
_sAppContext = ""                           # what software is running
_dOptions = None
_dOptionsColors = None
_oSpellChecker = None
_oTokenizer = None
_aIgnoredRules = set()






#### Initialization

def load (sContext="Python", sColorType="aRGB"):
    "initialization of the grammar checker"
    global _oSpellChecker
................................................................................


def resetOptions ():
    "set options to default values"
    global _dOptions
    _dOptions = getDefaultOptions()





















#### Parsing

def parse (sText, sCountry="${country_default}", bDebug=False, dOptions=None, bContext=False, bFullInfo=False):
    "init point to analyse <sText> and returns an iterable of errors or (with option <bFullInfo>) paragraphs errors and sentences with tokens and errors"
    oText = TextParser(sText)
    return oText.parse(sCountry, bDebug, dOptions, bContext, bFullInfo)
................................................................................
        xErr.nErrorLength = nLen
        xErr.nErrorType = PROOFREADING
        xErr.aRuleIdentifier = sRuleId
        xErr.aShortComment = sMessage   # sMessage.split("|")[0]     # in context menu
        xErr.aFullComment = sMessage    # sMessage.split("|")[-1]    # in dialog
        xErr.aSuggestions = tuple(lSugg)
        # Properties
        lProperties = [
            PropertyValue(Name="LineType", Value=18), # WAVE: 10, DASH: 5, BOLD: 12, BOLDWAVE: 18 https://api.libreoffice.org/docs/idl/ref/FontUnderline_8idl.html


            PropertyValue(Name="LineColor", Value=_dOptionsColors.get(sOption, 33023))
        ]
        if sURL:
            lProperties.append(PropertyValue(Name="FullCommentURL", Value=sURL))
        xErr.aProperties = lProperties
        return xErr

    def _createErrorAsDict (self, nStart, nEnd, sLineId, sRuleId, sOption, sMessage, lSugg, sURL, bContext):
        dErr = {







|







 







>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
|
>
>
|
<







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
..
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
...
681
682
683
684
685
686
687
688
689
690
691
692

693
694
695
696
697
698
699
except ImportError:
    _bWriterError = False


__all__ = [ "lang", "locales", "pkg", "name", "version", "author", \
            "load", "parse", "getSpellChecker", \
            "setOption", "setOptions", "getOptions", "getDefaultOptions", "getOptionsLabels", "resetOptions", "displayOptions", \
            "ignoreRule", "resetIgnoreRules", "reactivateRule", "listRules", "displayRules", "setWriterUnderliningStyle" ]

__version__ = "${version}"


lang = "${lang}"
locales = ${loc}
pkg = "${implname}"
................................................................................
_sAppContext = ""                           # what software is running
_dOptions = None
_dOptionsColors = None
_oSpellChecker = None
_oTokenizer = None
_aIgnoredRules = set()

# Writer underlining style
_bMulticolor = True
_nUnderliningStyle = 0


#### Initialization

def load (sContext="Python", sColorType="aRGB"):
    "initialization of the grammar checker"
    global _oSpellChecker
................................................................................


def resetOptions ():
    "set options to default values"
    global _dOptions
    _dOptions = getDefaultOptions()


def setWriterUnderliningStyle (sStyle="BOLDWAVE", bMulticolor=True):
    "set underlining style for Writer (WAVE, BOLDWAVE, BOLD)"
    global _nUnderliningStyle
    global _bMulticolor
    # https://api.libreoffice.org/docs/idl/ref/FontUnderline_8idl.html
    # WAVE: 10, BOLD: 12, BOLDWAVE: 18 DASH: 5
    if sStyle == "WAVE":
        _nUnderliningStyle = 0  # 0 for default Writer setting
    elif sStyle == "BOLDWAVE":
        _nUnderliningStyle = 18
    elif sStyle == "BOLD":
        _nUnderliningStyle = 12
    elif sStyle == "DASH":
        _nUnderliningStyle = 5
    else:
        _nUnderliningStyle = 0
    _bMulticolor = bMulticolor


#### Parsing

def parse (sText, sCountry="${country_default}", bDebug=False, dOptions=None, bContext=False, bFullInfo=False):
    "init point to analyse <sText> and returns an iterable of errors or (with option <bFullInfo>) paragraphs errors and sentences with tokens and errors"
    oText = TextParser(sText)
    return oText.parse(sCountry, bDebug, dOptions, bContext, bFullInfo)
................................................................................
        xErr.nErrorLength = nLen
        xErr.nErrorType = PROOFREADING
        xErr.aRuleIdentifier = sRuleId
        xErr.aShortComment = sMessage   # sMessage.split("|")[0]     # in context menu
        xErr.aFullComment = sMessage    # sMessage.split("|")[-1]    # in dialog
        xErr.aSuggestions = tuple(lSugg)
        # Properties
        lProperties = []
        if _nUnderliningStyle:
            lProperties.append(PropertyValue(Name="LineType", Value=_nUnderliningStyle))
        if _bMulticolor:
            lProperties.append(PropertyValue(Name="LineColor", Value=_dOptionsColors.get(sOption, 33023)))

        if sURL:
            lProperties.append(PropertyValue(Name="FullCommentURL", Value=sURL))
        xErr.aProperties = lProperties
        return xErr

    def _createErrorAsDict (self, nStart, nEnd, sLineId, sRuleId, sOption, sMessage, lSugg, sURL, bContext):
        dErr = {

Changes to gc_core/py/oxt/Grammalecte.py.

37
38
39
40
41
42
43


44
45
46
47
48
49
50
...
146
147
148
149
150
151
152










153
154
155
156
157
158
159
        gce.load("Writer", "nInt")
        # GC options
        # opt_handler.load(xCurCtx)
        dOpt = Options.load(xCurCtx)
        gce.setOptions(dOpt)
        # dictionaries options
        self.loadUserDictionaries()


        # store for results of big paragraphs
        self.dResult = {}
        self.nMaxRes = 1500
        self.lLastRes = deque(maxlen=self.nMaxRes)
        self.nRes = 0


................................................................................
            if xChild.getPropertyValue("use_personal_dic"):
                sJSON = xChild.getPropertyValue("personal_dic")
                if sJSON:
                    oSpellChecker = gce.getSpellChecker();
                    oSpellChecker.setPersonalDictionary(json.loads(sJSON))
        except:
            traceback.print_exc()












g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(Grammalecte, "org.openoffice.comp.pyuno.Lightproof."+gce.pkg, ("com.sun.star.linguistic2.Proofreader",),)

# g_ImplementationHelper.addImplementation( opt_handler.LightproofOptionsEventHandler, \
#     "org.openoffice.comp.pyuno.LightproofOptionsEventHandler." + gce.pkg, ("com.sun.star.awt.XContainerWindowEventHandler",),)







>
>







 







>
>
>
>
>
>
>
>
>
>







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
        gce.load("Writer", "nInt")
        # GC options
        # opt_handler.load(xCurCtx)
        dOpt = Options.load(xCurCtx)
        gce.setOptions(dOpt)
        # dictionaries options
        self.loadUserDictionaries()
        # underlining options
        self.setWriterUnderliningStyle()
        # store for results of big paragraphs
        self.dResult = {}
        self.nMaxRes = 1500
        self.lLastRes = deque(maxlen=self.nMaxRes)
        self.nRes = 0


................................................................................
            if xChild.getPropertyValue("use_personal_dic"):
                sJSON = xChild.getPropertyValue("personal_dic")
                if sJSON:
                    oSpellChecker = gce.getSpellChecker();
                    oSpellChecker.setPersonalDictionary(json.loads(sJSON))
        except:
            traceback.print_exc()

    def setWriterUnderliningStyle (self):
        try:
            xSettingNode = helpers.getConfigSetting("/org.openoffice.Lightproof_grammalecte/Other/", False)
            xChild = xSettingNode.getByName("o_${lang}")
            sLineType = xChild.getPropertyValue("line_type")
            bMulticolor = bool(xChild.getPropertyValue("line_multicolor"))
            gce.setWriterUnderliningStyle(sLineType, bMulticolor)
        except:
            traceback.print_exc()


g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(Grammalecte, "org.openoffice.comp.pyuno.Lightproof."+gce.pkg, ("com.sun.star.linguistic2.Proofreader",),)

# g_ImplementationHelper.addImplementation( opt_handler.LightproofOptionsEventHandler, \
#     "org.openoffice.comp.pyuno.LightproofOptionsEventHandler." + gce.pkg, ("com.sun.star.awt.XContainerWindowEventHandler",),)

Changes to gc_core/py/oxt/OptionsDialog.xcs.

17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32



33
34
35
36
37
38
39
            ${xcs_options}
        </group>

        <group oor:name="o_${lang}">
            <info>
                <desc>The data for one leaf.</desc>
            </info>

            <prop oor:name="use_graphspell" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="use_graphspell_sugg" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="use_extended_dic" oor:type="xs:int"><value>0</value></prop>
            <prop oor:name="use_community_dic" oor:type="xs:int"><value>0</value></prop>
            <prop oor:name="use_personal_dic" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="main_dic_name" oor:type="xs:string"><value>classic</value></prop>
            <prop oor:name="extended_dic" oor:type="xs:string"><value></value></prop>
            <prop oor:name="community_dic" oor:type="xs:string"><value></value></prop>
            <prop oor:name="personal_dic" oor:type="xs:string"><value></value></prop>



        </group>
    </templates>

    <component>
        <group oor:name="Leaves">
            <node-ref oor:name="${lang}" oor:node-type="${lang}" />
        </group>







>


<



<


>
>
>







17
18
19
20
21
22
23
24
25
26

27
28
29

30
31
32
33
34
35
36
37
38
39
40
41
            ${xcs_options}
        </group>

        <group oor:name="o_${lang}">
            <info>
                <desc>The data for one leaf.</desc>
            </info>
            <!-- spelling options -->
            <prop oor:name="use_graphspell" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="use_graphspell_sugg" oor:type="xs:int"><value>1</value></prop>

            <prop oor:name="use_community_dic" oor:type="xs:int"><value>0</value></prop>
            <prop oor:name="use_personal_dic" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="main_dic_name" oor:type="xs:string"><value>classic</value></prop>

            <prop oor:name="community_dic" oor:type="xs:string"><value></value></prop>
            <prop oor:name="personal_dic" oor:type="xs:string"><value></value></prop>
            <!-- graphic options -->
            <prop oor:name="line_multicolor" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="line_type" oor:type="xs:string"><value>BOLDWAVE</value></prop>
        </group>
    </templates>

    <component>
        <group oor:name="Leaves">
            <node-ref oor:name="${lang}" oor:node-type="${lang}" />
        </group>

Changes to gc_lang/fr/config.ini.

102
103
104
105
106
107
108



109
110
111
112
113
114
115
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
oxt/DictOptions/SearchWords.py = pythonpath/SearchWords.py
oxt/DictOptions/sw_strings.py = pythonpath/sw_strings.py
oxt/DictOptions/TagsInfo.py = pythonpath/TagsInfo.py
oxt/DictOptions/ti_strings.py = pythonpath/ti_strings.py



# ContextMenu
oxt/ContextMenu/ContextMenu.py = ContextMenu.py
oxt/ContextMenu/jobs.xcu = config/jobs.xcu
# TextFormatter
oxt/TextFormatter/TextFormatter.py = pythonpath/TextFormatter.py
oxt/TextFormatter/tf_strings.py = pythonpath/tf_strings.py
oxt/TextFormatter/tf_options.py = pythonpath/tf_options.py







>
>
>







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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
oxt/DictOptions/SearchWords.py = pythonpath/SearchWords.py
oxt/DictOptions/sw_strings.py = pythonpath/sw_strings.py
oxt/DictOptions/TagsInfo.py = pythonpath/TagsInfo.py
oxt/DictOptions/ti_strings.py = pythonpath/ti_strings.py
# Graphic options
oxt/GraphicOptions/GraphicOptions.py = pythonpath/GraphicOptions.py
oxt/GraphicOptions/go_strings.py = pythonpath/go_strings.py
# ContextMenu
oxt/ContextMenu/ContextMenu.py = ContextMenu.py
oxt/ContextMenu/jobs.xcu = config/jobs.xcu
# TextFormatter
oxt/TextFormatter/TextFormatter.py = pythonpath/TextFormatter.py
oxt/TextFormatter/tf_strings.py = pythonpath/tf_strings.py
oxt/TextFormatter/tf_options.py = pythonpath/tf_options.py

Changes to gc_lang/fr/oxt/AppLauncher.py.

62
63
64
65
66
67
68




69
70
71
72
73
74
75
                import Options
                xDialog = Options.GC_Options(self.ctx)
                xDialog.run(self.sLang)
            elif sCmd == "EN":
                import Enumerator
                xDialog = Enumerator.Enumerator(self.ctx)
                xDialog.run(self.sLang)




            elif sCmd.startswith("FA/"):
                findAll(sCmd[6:], (sCmd[3:4] == "y"), (sCmd[4:5] == "y"))
            # elif sCmd.startswith("URL/"):
            #     # Call from context menu to launch URL?
            #     # http://opengrok.libreoffice.org/xref/core/sw/source/ui/lingu/olmenu.cxx#785
            #     xSystemShellExecute = self.ctx.getServiceManager().createInstanceWithContext('com.sun.star.system.SystemShellExecute', self.ctx)
            #     xSystemShellExecute.execute(url, "", uno.getConstantByName("com.sun.star.system.SystemShellExecuteFlags.URIS_ONLY"))







>
>
>
>







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
                import Options
                xDialog = Options.GC_Options(self.ctx)
                xDialog.run(self.sLang)
            elif sCmd == "EN":
                import Enumerator
                xDialog = Enumerator.Enumerator(self.ctx)
                xDialog.run(self.sLang)
            elif sCmd == "GO":
                import GraphicOptions
                xDialog = GraphicOptions.GraphicOptions(self.ctx)
                xDialog.run(self.sLang)
            elif sCmd.startswith("FA/"):
                findAll(sCmd[6:], (sCmd[3:4] == "y"), (sCmd[4:5] == "y"))
            # elif sCmd.startswith("URL/"):
            #     # Call from context menu to launch URL?
            #     # http://opengrok.libreoffice.org/xref/core/sw/source/ui/lingu/olmenu.cxx#785
            #     xSystemShellExecute = self.ctx.getServiceManager().createInstanceWithContext('com.sun.star.system.SystemShellExecute', self.ctx)
            #     xSystemShellExecute.execute(url, "", uno.getConstantByName("com.sun.star.system.SystemShellExecuteFlags.URIS_ONLY"))

Added gc_lang/fr/oxt/GraphicOptions/GraphicOptions.py.































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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
# Graphic Options
# by Olivier R.
# License: MPL 2

import unohelper
import uno
import re
import traceback

import helpers
import go_strings

from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener
from com.sun.star.beans import PropertyValue


class GraphicOptions (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):
        self.dUI = go_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)

        # dialog
        self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx)
        self.xDialog.Width = 200
        self.xDialog.Height = 220
        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 = 10
        xFDSubTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
        xFDSubTitle.Name = "Verdana"

        # widget
        nX = 10
        nY1 = 10
        nY2 = nY1 + 45
        nY3 = nY2 + 55
        nY4 = nY3 + 65

        nWidth = self.xDialog.Width - 20
        nHeight = 10

        # Info
        self._addWidget("graphic_info", 'FixedText', nX, nY1, nWidth, nHeight*2, Label = self.dUI.get("graphic_info", "#err"), MultiLine = True, FontDescriptor = xFDSubTitle)
        self._addWidget("spell_info", 'FixedText', nX, nY1+20, nWidth, nHeight*2, Label = self.dUI.get("spell_info", "#err"), MultiLine = True)

        # Line type
        self._addWidget('linetype_section', 'FixedLine', nX, nY2, nWidth, nHeight, Label = self.dUI.get('linetype_section', "#err"), FontDescriptor = xFDTitle)
        self.xWaveLine = self._addWidget('wave_line', 'RadioButton', nX, nY2+15, nWidth, nHeight, Label = self.dUI.get('wave_line', "#err"))
        self.xBoldWaveLine = self._addWidget('boldwave_line', 'RadioButton', nX, nY2+25, nWidth, nHeight, Label = self.dUI.get('boldwave_line', "#err"))
        self.xBoldLine = self._addWidget('bold_line', 'RadioButton', nX, nY2+35, nWidth, nHeight, Label = self.dUI.get('bold_line', "#err"))

        # Color
        self._addWidget("color_section", 'FixedLine', nX, nY3, nWidth, nHeight, Label = self.dUI.get("color_section", "#err"), FontDescriptor = xFDTitle)
        self.xMulticolor = self._addWidget('multicolor_line', 'CheckBox', nX, nY3+15, nWidth, nHeight, Label = self.dUI.get('multicolor_line', "#err"))
        self._addWidget('multicolor_descr', 'FixedText', nX, nY3+25, nWidth, nHeight*4, Label = self.dUI.get('multicolor_descr', "#err"), MultiLine = True)

        # Restart message
        self._addWidget('restart', 'FixedText', nX, nY4, nWidth, nHeight*2, Label = self.dUI.get('restart', "#err"), FontDescriptor = xFDTitle, MultiLine = True, TextColor = 0x880000)

        # Button
        self._addWidget('apply_button', 'Button', self.xDialog.Width-115, self.xDialog.Height-20, 50, 14, Label = self.dUI.get('apply_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x005500)
        self._addWidget('cancel_button', 'Button', self.xDialog.Width-60, self.xDialog.Height-20, 50, 14, Label = self.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('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):
        if xActionEvent.ActionCommand == 'Apply':
            try:
                # Grammalecte options
                xChild = self.xGLOptionNode.getByName("o_fr")
                xChild.setPropertyValue("line_multicolor", self.xMulticolor.State)
                if self.xWaveLine.State:
                    sLineType = "WAVE"
                elif self.xBoldWaveLine.State:
                    sLineType = "BOLDWAVE"
                elif self.xBoldLine.State:
                    sLineType = "BOLD"
                else:
                    sLineType = "BOLDWAVE"
                xChild.setPropertyValue("line_type", sLineType)
                self.xGLOptionNode.commitChanges()
            except:
                traceback.print_exc()
        # Close window
        self.xContainer.endExecute()

    # XJobExecutor
    def trigger (self, args):
        try:
            dialog = GraphicOptions(self.ctx)
            dialog.run()
        except:
            traceback.print_exc()

    def _loadOptions (self):
        try:
            xChild = self.xGLOptionNode.getByName("o_fr")
            self.xMulticolor.State = xChild.getPropertyValue("line_multicolor")
            sLineType = xChild.getPropertyValue("line_type")
            if sLineType == "WAVE":
                self.xWaveLine.State = 1
            elif sLineType == "BOLDWAVE":
                self.xBoldWaveLine.State = 1
            elif sLineType == "BOLD":
                self.xBoldLine.State = 1
            else:
                print("Error. Unknown line type: " + sLineType)
        except:
            traceback.print_exc()


#g_ImplementationHelper = unohelper.ImplementationHelper()
#g_ImplementationHelper.addImplementation(GraphicOptions, 'net.grammalecte.GraphicOptions', ('com.sun.star.task.Job',))

Added gc_lang/fr/oxt/GraphicOptions/go_strings.py.



































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def getUI (sLang):
    if sLang in dStrings:
        return dStrings[sLang]
    return dStrings["fr"]

dStrings = {
    "fr": {
        "title": "Grammalecte · Options graphiques",

        "graphic_info": "Apparence du soulignement des erreurs grammaticales et typographiques",

        "linetype_section": "Type de ligne",
        "wave_line": "Vaguelette fine (réglage par défaut de Writer)",
        "boldwave_line": "Vaguelette épaisse (réglage par défaut de Grammalecte)",
        "bold_line": "Trait droit et épais",

        "color_section": "Couleurs",
        "multicolor_line": "Utiliser plusieurs couleurs",
        "multicolor_descr": "Par défaut, Writer signale les erreurs grammaticales et typographiques avec une vaguelette de couleur bleue. Si cette option est cochée, Grammalecte attribuera des couleurs différentes aux erreurs selon leur type.",

        "spell_info": "L’apparence du soulignement des erreurs orthographiques (vaguelette rouge) n’est pas modifiable",

        "restart": "Le changement ne prendra effet qu’après le redémarrage du logiciel.",

        "apply_button": "Appliquer",
        "cancel_button": "Annuler",
    },
    "en": {
        "title": "Grammalecte · Graphic options",

        "graphic_info": "Appearance of uderlines for grammar and typographical mistakes",

        "linetype_section": "Line types",
        "wave_line": "Thin wave (default setting of Writer)",
        "boldwave_line": "Thick wave (default setting of Grammalecte)",
        "bold_line": "Thick and straight line",

        "color_section": "Colors",
        "multicolor_line": "Use several colors",
        "multicolor_descr": "By default, Writer underlines grammar and typographical mistakes with a blue wave. If this option is activated, Grammalecte uses different colors for mistakes according to the type they belong to.",

        "spell_info": "Appearance of underlines for spelling mistakes (red and thin wave) can’t be modified",

        "restart": "The modification will be effective only after restarting the software.",

        "apply_button": "Apply",
        "cancel_button": "Cancel",
    },
}

Changes to gc_lang/fr/oxt/addons.xcu.

132
133
134
135
136
137
138






















139
140
141
142
143
144
145
                        <value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument</value>
                    </prop>
                    <prop oor:name="ImageIdentifier" oor:type="xs:string">
                        <value>org.dicollecte.images:Grammalecte</value>
                    </prop>
                </node>
                <node oor:name="m7" oor:op="replace">






















                    <prop oor:name="URL" oor:type="xs:string">
                        <value>service:net.grammalecte.AppLauncher?DI</value>
                    </prop>
                    <prop oor:name="Title" oor:type="xs:string">
                        <value/>
                        <value xml:lang="fr">Options des ~dictionnaires…</value>
                        <value xml:lang="en-US">~Dictionaries options…</value>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
                        <value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument</value>
                    </prop>
                    <prop oor:name="ImageIdentifier" oor:type="xs:string">
                        <value>org.dicollecte.images:Grammalecte</value>
                    </prop>
                </node>
                <node oor:name="m7" oor:op="replace">
                    <prop oor:name="URL" oor:type="xs:string">
                        <value>service:net.grammalecte.AppLauncher?GO</value>
                    </prop>
                    <!--<prop oor:name="URL" oor:type="xs:string">
                        <value>.uno:OptionsTreeDialog?OptionsPageURL:string=%origin%/dialog/fr.xdl</value>
                    </prop>-->
                    <prop oor:name="Title" oor:type="xs:string">
                        <value/>
                        <value xml:lang="fr">Options grap~hiques…</value>
                        <value xml:lang="en-US">Grap~hic options…</value>
                    </prop>
                    <prop oor:name="Target" oor:type="xs:string">
                        <value>_self</value>
                    </prop>
                    <prop oor:name="Context" oor:type="xs:string">
                        <value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument</value>
                    </prop>
                    <prop oor:name="ImageIdentifier" oor:type="xs:string">
                        <value>org.dicollecte.images:Grammalecte</value>
                    </prop>
                </node>
                <node oor:name="m8" oor:op="replace">
                    <prop oor:name="URL" oor:type="xs:string">
                        <value>service:net.grammalecte.AppLauncher?DI</value>
                    </prop>
                    <prop oor:name="Title" oor:type="xs:string">
                        <value/>
                        <value xml:lang="fr">Options des ~dictionnaires…</value>
                        <value xml:lang="en-US">~Dictionaries options…</value>