pt_BR/Lightproof.py                          |   17 +++++++++--------
 pt_BR/pythonpath/lightproof_handler_pt_BR.py |    2 +-
 pt_BR/pythonpath/lightproof_impl_pt_BR.py    |    1 +
 3 files changed, 11 insertions(+), 9 deletions(-)

New commits:
commit 3b6db3f228458fa2b2f9911716b95ed0d632c9ce
Author: Tor Lillqvist <t...@collabora.com>
Date:   Wed Jun 20 20:11:55 2018 +0300

    tdf#104332 (and others): Speed up Lightproof initialisation
    
    Delay import of the the heavy lightproof_impl_pt_BR to when actually
    needed. Shaves several hundred milliseconds (on my machine, about 300
    ms) from the time needed to just get a list of what grammars checkers
    are available. It's silly to load the heavy pt-BR impl module even if
    no Brazilian Portuguese proof reading is being performed.
    
    Sure, the same change could be done to the other Lightproof
    dictionaries, too, but they are much smaller, so importing them
    unconditionally always does not hurt so much.
    
    Change-Id: I3c3f64e80bd9519f188905abda7c25337c81462d
    Reviewed-on: https://gerrit.libreoffice.org/56176
    Reviewed-by: László Németh <nem...@numbertext.org>
    Tested-by: Tor Lillqvist <t...@collabora.com>
    (cherry picked from commit 2d8dd0af877de8494ca9c2c027eba4a42bbc09eb)
    (cherry picked from commit 846e5da4b28bb40158cfb992f3a371614e25a349)
    Reviewed-on: https://gerrit.libreoffice.org/56249
    Reviewed-by: Tor Lillqvist <t...@collabora.com>

diff --git a/pt_BR/Lightproof.py b/pt_BR/Lightproof.py
index 8064fee..0868693 100644
--- a/pt_BR/Lightproof.py
+++ b/pt_BR/Lightproof.py
@@ -3,9 +3,8 @@
 # 2009-2012 (c) Laszlo Nemeth (nemeth at numbertext org), license: MPL 1.1 / 
GPLv3+ / LGPLv3+
 
 import uno, unohelper, os, sys, traceback
-from lightproof_impl_pt_BR import locales
-from lightproof_impl_pt_BR import pkg
-import lightproof_impl_pt_BR
+locales = {'pt-BR': ['pt', 'BR', '']}
+pkg = "pt_BR"
 import lightproof_handler_pt_BR
 
 from com.sun.star.linguistic2 import XProofreader, XSupportedLocales
@@ -30,11 +29,6 @@ class Lightproof( unohelper.Base, XProofreader, 
XServiceInfo, XServiceName, XSer
             l = locales[i]
             self.locales += [Locale(l[0], l[1], l[2])]
         self.locales = tuple(self.locales)
-        currentContext = uno.getComponentContext()
-        lightproof_impl_pt_BR.SMGR = currentContext.ServiceManager
-        lightproof_impl_pt_BR.spellchecker = \
-            
lightproof_impl_pt_BR.SMGR.createInstanceWithContext("com.sun.star.linguistic2.SpellChecker",
 currentContext)
-        lightproof_handler_pt_BR.load(currentContext)
 
     # XServiceName method implementations
     def getServiceName(self):
@@ -68,6 +62,13 @@ class Lightproof( unohelper.Base, XProofreader, 
XServiceInfo, XServiceName, XSer
 
     def doProofreading(self, nDocId, rText, rLocale, nStartOfSentencePos, \
         nSuggestedSentenceEndPos, rProperties):
+        import lightproof_impl_pt_BR
+        currentContext = uno.getComponentContext()
+        if lightproof_impl_pt_BR.SMGR == None:
+            lightproof_impl_pt_BR.SMGR = currentContext.ServiceManager
+            lightproof_impl_pt_BR.spellchecker = \
+                
lightproof_impl_pt_BR.SMGR.createInstanceWithContext("com.sun.star.linguistic2.SpellChecker",
 currentContext)
+        lightproof_handler_pt_BR.load(currentContext)
         aRes = uno.createUnoStruct( 
"com.sun.star.linguistic2.ProofreadingResult" )
         aRes.aDocumentIdentifier = nDocId
         aRes.aText = rText
diff --git a/pt_BR/pythonpath/lightproof_handler_pt_BR.py 
b/pt_BR/pythonpath/lightproof_handler_pt_BR.py
index 406971a..e80e320 100644
--- a/pt_BR/pythonpath/lightproof_handler_pt_BR.py
+++ b/pt_BR/pythonpath/lightproof_handler_pt_BR.py
@@ -1,7 +1,7 @@
 import uno
 import unohelper
 import lightproof_opts_pt_BR
-from lightproof_impl_pt_BR import pkg
+pkg = "pt_BR"
 
 from com.sun.star.lang import XServiceInfo
 from com.sun.star.awt import XContainerWindowEventHandler
diff --git a/pt_BR/pythonpath/lightproof_impl_pt_BR.py 
b/pt_BR/pythonpath/lightproof_impl_pt_BR.py
index 8611ee5..d3a72a1 100644
--- a/pt_BR/pythonpath/lightproof_impl_pt_BR.py
+++ b/pt_BR/pythonpath/lightproof_impl_pt_BR.py
@@ -29,6 +29,7 @@ suggestions = {}
 # assign Calc functions
 calcfunc = None
 
+SMGR = None
 
 # check settings
 def option(lang, opt):
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to