diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2017-09-13 16:16:11 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-09-14 12:06:34 +0200 |
commit | 4a9280e3fa2a86f00510361118d8b96359958a0e (patch) | |
tree | 8aae38d6f6c66edb12ded98b3ca9ad144349520a /desktop | |
parent | b04d175b03ec22c00e149fd3a42041225b156760 (diff) |
Pre-load dictionaries for online.
Change-Id: Ied81f20900060ff6a78704fa9195320b8fb86e45
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index b0499399b97b..5153ba980ca6 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> @@ -3199,6 +3202,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 { @@ -3310,6 +3332,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(); } |