Index: gc_lang/fr/oxt/AppLauncher.py ================================================================== --- gc_lang/fr/oxt/AppLauncher.py +++ gc_lang/fr/oxt/AppLauncher.py @@ -1,16 +1,19 @@ -# 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 - -import helpers - from com.sun.star.task import XJobExecutor + +import helpers xDesktop = None Index: gc_lang/fr/oxt/Graphspell.py ================================================================== --- gc_lang/fr/oxt/Graphspell.py +++ gc_lang/fr/oxt/Graphspell.py @@ -1,23 +1,25 @@ -# Graphspell -# -# Spellchecker based on a DAWG (Direct Acyclic Word Graph) +""" +Graphspell +Spellchecker based on a DAWG (Direct Acyclic Word Graph) +""" +# License: MPL 2 -import uno -import unohelper import traceback import re import json -import helpers -from grammalecte.graphspell import SpellChecker - +#import uno +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) @@ -43,10 +45,11 @@ 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" @@ -56,11 +59,11 @@ 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: @@ -93,11 +96,11 @@ # 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 @@ -125,17 +128,17 @@ 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 Index: gc_lang/fr/oxt/TextFormatter/TextFormatter.py ================================================================== --- gc_lang/fr/oxt/TextFormatter/TextFormatter.py +++ gc_lang/fr/oxt/TextFormatter/TextFormatter.py @@ -1,11 +1,11 @@ -# Text Formatter -# by Olivier R. -# License: MPL 2 +""" +Text Formatter +For LibreOffice +""" -import unohelper -import uno +# License: MPL 2 import traceback import time import json @@ -12,11 +12,12 @@ 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 Index: gc_lang/fr/oxt/TextFormatter/tf_strings.py ================================================================== --- gc_lang/fr/oxt/TextFormatter/tf_strings.py +++ gc_lang/fr/oxt/TextFormatter/tf_strings.py @@ -1,6 +1,5 @@ -# -*- encoding: UTF-8 -*- def getUI (sLang): if sLang in dStrings: return dStrings[sLang] return dStrings["fr"]