From 91cf85936aff8bcc3b837584a834a0f2d9f3ed3a Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Wed, 13 Sep 2017 16:16:11 +0100 Subject: [PATCH] Pre-load dictionaries for online. Change-Id: Ied81f20900060ff6a78704fa9195320b8fb86e45 Reviewed-on: https://gerrit.libreoffice.org/42269 Tested-by: Jenkins Reviewed-by: Michael Meeks --- desktop/source/lib/init.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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 #include +#include +#include + #include #include #include @@ -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 xLngSvcMgr = + css::linguistic2::LinguServiceManager::create(comphelper::getProcessComponentContext()); + css::uno::Reference xSpellChecker(xLngSvcMgr->getSpellChecker()); + + css::uno::Reference 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("preload")}); + preloadData(); + // Release Solar Mutex, lo_startmain thread should acquire it. Application::ReleaseSolarMutex(); }