From 6b35e804198ac45386805e80a3d413ed3405c3b4 Mon Sep 17 00:00:00 2001 From: Martin Hosken Date: Wed, 16 Nov 2016 00:53:59 +0000 Subject: Fix tdf#103855 add language codes and names to language lists from extensions Rationale for changes to languagetag.hxx can be found in the bug tdf#103855. Change-Id: I7fa7c8a3f7b219ce08df69a3965f544ae156beab Reviewed-on: https://gerrit.libreoffice.org/30882 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- svtools/source/misc/langtab.cxx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'svtools') diff --git a/svtools/source/misc/langtab.cxx b/svtools/source/misc/langtab.cxx index 3540c316e472..272f8edf3fc6 100644 --- a/svtools/source/misc/langtab.cxx +++ b/svtools/source/misc/langtab.cxx @@ -17,7 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include #include +#include +#include #include #include @@ -28,6 +31,7 @@ #include #include #include +#include using namespace ::com::sun::star; @@ -129,6 +133,28 @@ const OUString ApplyLreOrRleEmbedding( const OUString &rText ) SvtLanguageTableImpl::SvtLanguageTableImpl() : ResStringArray( SvtResId( STR_ARR_SVT_LANGUAGE_TABLE ) ) { + auto xNA = officecfg::VCL::ExtraLanguages::get(); + uno::Sequence rElementNames = xNA->getElementNames(); + sal_Int32 nLen = rElementNames.getLength(); + for (sal_Int32 i = 0; i < nLen; ++i) + { + OUString aName; + sal_Int32 nType = 0; + uno::Reference xNB; + xNA->getByName(rElementNames[i]) >>= xNB; + bool bSuccess = (xNB->getByName("Name") >>= aName) && + (xNB->getByName("ScriptType") >>= nType); + if (bSuccess) + { + LanguageTag aLang(rElementNames[i]); + LanguageType nLangType = aLang.getLanguageType(); + if (nType <= LanguageTag::ScriptType::RTL && nType > LanguageTag::ScriptType::UNKNOWN) + aLang.setScriptType(LanguageTag::ScriptType(nType)); + sal_uInt32 nPos = FindIndex(nLangType); + if (nPos == RESARRAY_INDEX_NOTFOUND) + AddItem((aName.isEmpty() ? rElementNames[i] : aName), nLangType); + } + } } SvtLanguageTableImpl::~SvtLanguageTableImpl() -- cgit v1.2.3