summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2017-09-13 16:16:11 +0100
committerMichael Meeks <michael.meeks@collabora.com>2017-09-14 12:59:46 +0200
commit91cf85936aff8bcc3b837584a834a0f2d9f3ed3a (patch)
tree4f7055a7043d1adc5f4ce510cc624dfc0ee0428e /desktop
parentb0de7bc428aaf914a836da3c33b123e4195e603e (diff)
Pre-load dictionaries for online.
Change-Id: Ied81f20900060ff6a78704fa9195320b8fb86e45 Reviewed-on: https://gerrit.libreoffice.org/42269 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6e8136d740a0..f9a825564c88 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -54,6 +54,9 @@
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/document/XRedlinesSupplier.hpp>
+#include <com/sun/star/linguistic2/LinguServiceManager.hpp>
+#include <com/sun/star/linguistic2/XSpellChecker.hpp>
+
#include <editeng/fontitem.hxx>
#include <editeng/flstitem.hxx>
#include <sfx2/objsh.hxx>
@@ -3150,6 +3153,25 @@ static void lo_status_indicator_callback(void *data, comphelper::LibreOfficeKit:
}
}
+static void preloadData()
+{
+ // First: sit down and read all dictionaries: yum.
+ css::uno::Reference<css::linguistic2::XLinguServiceManager> xLngSvcMgr =
+ css::linguistic2::LinguServiceManager::create(comphelper::getProcessComponentContext());
+ css::uno::Reference<linguistic2::XSpellChecker> xSpellChecker(xLngSvcMgr->getSpellChecker());
+
+ css::uno::Reference<linguistic2::XSupportedLocales> xLocales(xSpellChecker, css::uno::UNO_QUERY_THROW);
+ uno::Sequence< css::lang::Locale > aLocales = xLocales->getLocales();
+ SAL_INFO("lok", "Preloading #" << aLocales.getLength() << " dictionaries");
+ for (auto &it : aLocales)
+ {
+ SAL_INFO("lok", " load " << it.Language << "_" << it.Country);
+ css::beans::PropertyValues aNone;
+ xSpellChecker->isValid("forcefed", it, aNone);
+ }
+ SAL_INFO("lok", "Preloading done");
+}
+
static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char* pUserProfileUrl)
{
enum {
@@ -3261,6 +3283,8 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
// 3) InitVCL()
aService->initialize({css::uno::makeAny<OUString>("preload")});
+ preloadData();
+
// Release Solar Mutex, lo_startmain thread should acquire it.
Application::ReleaseSolarMutex();
}