Grammalecte  Check-in [3879004037]

Overview
Comment:[lo] use user dictionary
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | lo | multid
Files: files | file ages | folders
SHA3-256: 38790040371489087035cb19f87a01cb2495b625fd07b5b2ab6badc79fc8ebe3
User & Date: olr on 2018-02-28 18:43:11
Other Links: branch diff | manifest | tags
Context
2018-03-02
13:00
merge trunk check-in: c43c446a59 user: olr tags: multid
2018-02-28
18:43
[lo] use user dictionary check-in: 3879004037 user: olr tags: lo, multid
18:27
[graphspell][py] spellchecker: dictionary object can be used to initialize IBDAWG check-in: 0cd3bfee2d user: olr tags: graphspell, multid
Changes

Modified gc_core/py/oxt/Grammalecte.py from [1e4211990b] to [6b2cfc5228].

     1         -# -*- encoding: UTF-8 -*-
     2      1   # Grammalecte for Writer
     3      2   # License: MPL 2
     4      3   # A derivative work of Lightproof from László Németh (http://cgit.freedesktop.org/libreoffice/lightproof/)
     5      4   
     6      5   import uno
     7      6   import unohelper
            7  +import json
     8      8   import sys
     9      9   import traceback
    10     10   from collections import deque
    11     11   
    12     12   from com.sun.star.linguistic2 import XProofreader, XSupportedLocales
    13     13   from com.sun.star.linguistic2 import ProofreadingResult
    14     14   from com.sun.star.lang import XServiceInfo, XServiceName, XServiceDisplayName
    15     15   from com.sun.star.lang import Locale
    16     16   
           17  +import helpers
    17     18   import grammalecte.${lang} as gce
    18     19   #import lightproof_handler_${implname} as opt_handler
    19     20   import Options
    20     21   
    21     22   
    22     23   class Grammalecte (unohelper.Base, XProofreader, XServiceInfo, XServiceName, XServiceDisplayName, XSupportedLocales):
    23     24   
................................................................................
    34     35           xCurCtx = uno.getComponentContext()
    35     36           # init
    36     37           gce.load("Writer")
    37     38           # GC options
    38     39           # opt_handler.load(xCurCtx)
    39     40           dOpt = Options.load(xCurCtx)
    40     41           gce.setOptions(dOpt)
           42  +        # dictionaries options
           43  +        self.loadUserDictionaries()
    41     44           # store for results of big paragraphs
    42     45           self.dResult = {}
    43     46           self.nMaxRes = 1500
    44     47           self.lLastRes = deque(maxlen=self.nMaxRes)
    45     48           self.nRes = 0
    46         -        #oSpellChecker = gce.getSpellChecker();
    47         -        #oSpellChecker.setPersonalDictionary("fr.personal.json")
           49  +
    48     50   
    49     51       # XServiceName method implementations
    50     52       def getServiceName (self):
    51     53           return self.ImplementationName
    52     54   
    53     55       # XServiceInfo method implementations
    54     56       def getImplementationName (self):
................................................................................
   132    134       # XServiceDisplayName
   133    135       def getServiceDisplayName (self, aLocale):
   134    136           return gce.name
   135    137   
   136    138       # Grammalecte
   137    139       def getSpellChecker (self):
   138    140           return gce.getSpellChecker()
          141  +
          142  +    def loadUserDictionaries (self):
          143  +        try:
          144  +            xSettingNode = helpers.getConfigSetting("/org.openoffice.Lightproof_grammalecte/Other/", False)
          145  +            xChild = xSettingNode.getByName("o_${lang}")
          146  +            if xChild.getPropertyValue("use_personal_dic"):
          147  +                sJSON = xChild.getPropertyValue("personal_dic")
          148  +                if sJSON:
          149  +                    oSpellChecker = gce.getSpellChecker();
          150  +                    oSpellChecker.setPersonalDictionary(json.loads(sJSON))
          151  +        except:
          152  +            traceback.print_exc()
   139    153   
   140    154   
   141    155   g_ImplementationHelper = unohelper.ImplementationHelper()
   142    156   g_ImplementationHelper.addImplementation(Grammalecte, "org.openoffice.comp.pyuno.Lightproof."+gce.pkg, ("com.sun.star.linguistic2.Proofreader",),)
   143    157   
   144    158   # g_ImplementationHelper.addImplementation( opt_handler.LightproofOptionsEventHandler, \
   145    159   #     "org.openoffice.comp.pyuno.LightproofOptionsEventHandler." + gce.pkg, ("com.sun.star.awt.XContainerWindowEventHandler",),)