Grammalecte  Check-in [b4038dd6fd]

Overview
Comment:[lo] small code cleaning
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256: b4038dd6fd2c780a9e126535ca616e386b5e0c0cdcbd4aea5c1b1e380028d6db
User & Date: olr on 2019-11-20 10:12:40
Other Links: manifest | tags
Context
2019-11-20
10:18
[core][lo][fr] formateur de texte: … check-in: 2785b3b65a user: olr tags: trunk, fr, core, lo
10:12
[lo] small code cleaning check-in: b4038dd6fd user: olr tags: trunk, lo
09:32
[fr] nr: étant donné que check-in: 63df9daceb user: olr tags: trunk, fr
Changes

Modified gc_lang/fr/oxt/AppLauncher.py from [df677fbd72] to [b4674c5ea1].


1
2




3


4
5
6
7

8
9
10
11
12
13
14
15
16
17
18
1


2
3
4
5
6
7
8
9
10
11

12
13
14


15
16
17
18
19
20
21
+
-
-
+
+
+
+

+
+



-
+


-
-







"""
# Grammalecte AppLauncher
# by Olivier R.
Grammalecte AppLauncher
Service to avoid creating a service for each feature (which would slows LO start-up)
"""

# License: MPL 2

import traceback

import unohelper
import uno
import traceback
from com.sun.star.task import XJobExecutor

import helpers

from com.sun.star.task import XJobExecutor


xDesktop = None


class AppLauncher (unohelper.Base, XJobExecutor):
    def __init__ (self, ctx):

Modified gc_lang/fr/oxt/Graphspell.py from [b9945ec9c3] to [810dc52bd8].


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
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
+
-
+
-
-
+
+

+

-
-




-
+
-
-
+




+
+
+







"""
# Graphspell
Graphspell
#
# Spellchecker based on a DAWG (Direct Acyclic Word Graph)
Spellchecker based on a DAWG (Direct Acyclic Word Graph)
"""

# License: MPL 2

import uno
import unohelper
import traceback
import re
import json

import helpers
#import uno
from grammalecte.graphspell import SpellChecker

import unohelper
from com.sun.star.linguistic2 import XSupportedLocales, XSpellChecker, XSpellAlternatives
from com.sun.star.lang import XServiceInfo, XServiceName, XServiceDisplayName
from com.sun.star.lang import Locale

import helpers
from grammalecte.graphspell import SpellChecker


lLocale = {
    # List of locales in LibreOffice
    # https://cgit.freedesktop.org/libreoffice/core/tree/i18nlangtag/source/isolang/isolang.cxx
    #('la', 'VA', ''),  # Latin (for testing purpose)
    ('fr', 'FR', ''),  # France
    ('fr', 'BE', ''),  # Belgique
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
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







+













-
+







    ('fr', 'TG', '')   # Togo
}

zElidedWords = re.compile("(?i)^(?:[ldnmtsjcçy]|qu|lorsqu|quoiqu|puisqu|jusqu)['’`‘]")


class Graphspell (unohelper.Base, XSpellChecker, XServiceInfo, XServiceName, XServiceDisplayName, XSupportedLocales):
    """Spellchecker class: will be loaded by LibreOffice"""

    def __init__ (self, ctx, *args):
        try:
            self.ctx = ctx
            self.sServiceName = "com.sun.star.linguistic2.SpellChecker"
            self.sImplementationName = "net.grammalecte.graphspell"
            self.tSupportedServiceNames = (self.sServiceName, )
            self.xSvMgr = ctx.ServiceManager
            self.locales = tuple([ Locale(t[0], t[1], t[2])  for t in lLocale ])
            self.xSettingNode = helpers.getConfigSetting("/org.openoffice.Lightproof_grammalecte/Other/", False)
            self.xOptionNode = self.xSettingNode.getByName("o_fr")
            sMainDicName = self.xOptionNode.getPropertyValue("main_dic_name")
            personal_dic = ""
            if (self.xOptionNode.getPropertyValue("use_personal_dic")):
            if self.xOptionNode.getPropertyValue("use_personal_dic"):
                sPersonalDicJSON = self.xOptionNode.getPropertyValue("personal_dic")
                if sPersonalDicJSON:
                    try:
                        personal_dic = json.loads(sPersonalDicJSON)
                    except:
                        print("Graphspell: wrong personal_dic")
                        traceback.print_exc()
91
92
93
94
95
96
97
98

99
100
101
102
103
104
105
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108







-
+







        return self.sImplementationName     #self.sServiceName

    # XServiceInfo
    def getImplementationName (self):
        return self.sImplementationName

    def supportsService (self, sServiceName):
        return (sServiceName in self.tSupportedServiceNames)
        return sServiceName in self.tSupportedServiceNames

    def getSupportedServiceNames (self):
        return self.tSupportedServiceNames

    # XSupportedLocales
    def hasLocale (self, aLocale):
        if aLocale in self.locales:
123
124
125
126
127
128
129

130
131
132
133
134
135
136


137
138
139
140
141
142
143
126
127
128
129
130
131
132
133
134
135
136
137



138
139
140
141
142
143
144
145
146







+




-
-
-
+
+







            traceback.print_exc()
        return False

    def spell (self, aWord, aLocale, aProperties):
        "returns an object SpellAlternatives"
        try:
            if not self.bHunspell:
                # Graphspell
                lSugg = []
                for l in self.oGraphspell.suggest(aWord):
                    lSugg.extend(l)
                return SpellAlternatives(aWord, tuple(lSugg))
            else:
                # fallback dictionary suggestions (Hunspell)
                return self.xHunspell.spell(aWord, self.xHunspellLocale, aProperties)
            # fallback dictionary suggestions (Hunspell)
            return self.xHunspell.spell(aWord, self.xHunspellLocale, aProperties)
        except:
            traceback.print_exc()
        return None

    # XServiceDisplayName
    def getServiceDisplayName(self, aLocale):
        return "Graphspell (fr)"

Modified gc_lang/fr/oxt/TextFormatter/TextFormatter.py from [3573b30804] to [9ccd38723a].


1
2




3
4
5
6
7
8
9
10
11
12
13
14
15
16
17


18
19
20
21
22
23
24
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
+
-
-
+
+
+
+

-
-
-










-
+
+







"""
# Text Formatter
# by Olivier R.
Text Formatter
For LibreOffice
"""

# License: MPL 2

import unohelper
import uno

import traceback
import time
import json

import tf_strings
import tf_options
import tf_tabrep
import helpers


import unohelper
import uno
from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener


from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK
# BUTTONS_OK, BUTTONS_OK_CANCEL, BUTTONS_YES_NO, BUTTONS_YES_NO_CANCEL, BUTTONS_RETRY_CANCEL, BUTTONS_ABORT_IGNORE_RETRY
# DEFAULT_BUTTON_OK, DEFAULT_BUTTON_CANCEL, DEFAULT_BUTTON_RETRY, DEFAULT_BUTTON_YES, DEFAULT_BUTTON_NO, DEFAULT_BUTTON_IGNORE

Modified gc_lang/fr/oxt/TextFormatter/tf_strings.py from [54ab7ccb3a] to [7368cd8ce9].

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
-







# -*- encoding: UTF-8 -*-

def getUI (sLang):
    if sLang in dStrings:
        return dStrings[sLang]
    return dStrings["fr"]

dStrings = {