From 7fbea38b7aa5335abef55b445df88ee571d18360 Mon Sep 17 00:00:00 2001 From: Mert Tumer Date: Tue, 10 May 2022 13:06:06 +0300 Subject: Load the locales from config file for languagetool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Locales needs to be read again in the Preferences/Writing Aids section and since this is a network operation it can cause a problem. Better to list all the supported locales in the xcu and load it right away. Signed-off-by: Mert Tumer Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135598 Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153959 Reviewed-by: Andras Timar Tested-by: Andras Timar (cherry picked from commit 84bdf9e81a63a8bd308709c86b51bf3900a23c50) Change-Id: Iad9201101aa167ad33f479c67f72649786e1f2cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158330 Reviewed-by: Caolán McNamara --- unotools/source/config/lingucfg.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'unotools') diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx index 571601e1663a..1a4172c7844a 100644 --- a/unotools/source/config/lingucfg.cxx +++ b/unotools/source/config/lingucfg.cxx @@ -941,6 +941,27 @@ bool SvtLinguConfig::GetSupportedDictionaryFormatsFor( return bSuccess; } +bool SvtLinguConfig::GetLocaleListFor( const OUString &rSetName, const OUString &rSetEntry, css::uno::Sequence< OUString > &rLocaleList ) const +{ + if (rSetName.isEmpty() || rSetEntry.isEmpty()) + return false; + bool bSuccess = false; + try + { + uno::Reference< container::XNameAccess > xNA( GetMainUpdateAccess(), uno::UNO_QUERY_THROW ); + xNA.set( xNA->getByName("ServiceManager"), uno::UNO_QUERY_THROW ); + xNA.set( xNA->getByName( rSetName ), uno::UNO_QUERY_THROW ); + xNA.set( xNA->getByName( rSetEntry ), uno::UNO_QUERY_THROW ); + if (xNA->getByName( "Locales" ) >>= rLocaleList) + bSuccess = true; + DBG_ASSERT( rLocaleList.hasElements(), "Locale list is empty" ); + } + catch (uno::Exception &) + { + } + return bSuccess; +} + static bool lcl_GetFileUrlFromOrigin( OUString /*out*/ &rFileUrl, const OUString &rOrigin ) -- cgit