From b796a2030b9814978c904979dc609422d08eb538 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Thu, 24 Oct 2013 12:26:02 +0200 Subject: [PATCH] added isNonLatinWestern() Change-Id: Ie2aadab8302f365379a569989bd9640db55b9716 --- i18nlangtag/source/isolang/mslangid.cxx | 42 +++++++++++++++++++++++++ include/i18nlangtag/mslangid.hxx | 3 ++ 2 files changed, 45 insertions(+) diff --git a/i18nlangtag/source/isolang/mslangid.cxx b/i18nlangtag/source/isolang/mslangid.cxx index 72d5051ee32e..a48693ba4a14 100644 --- a/i18nlangtag/source/isolang/mslangid.cxx +++ b/i18nlangtag/source/isolang/mslangid.cxx @@ -24,6 +24,10 @@ #include "i18nlangtag/mslangid.hxx" +// Only very limited few functions that are guaranteed to not be called from +// LanguageTag may use LanguageTag ... +#include "i18nlangtag/languagetag.hxx" + LanguageType MsLangId::nConfiguredSystemLanguage = LANGUAGE_SYSTEM; LanguageType MsLangId::nConfiguredSystemUILanguage = LANGUAGE_SYSTEM; @@ -404,6 +408,44 @@ sal_Int16 MsLangId::getScriptType( LanguageType nLang ) } +// static +bool MsLangId::isNonLatinWestern( LanguageType nLang ) +{ + switch (nLang) + { + case LANGUAGE_AZERI_CYRILLIC: + case LANGUAGE_AZERI_CYRILLIC_LSO: + case LANGUAGE_BELARUSIAN: + case LANGUAGE_BOSNIAN_CYRILLIC_BOSNIA_HERZEGOVINA: + case LANGUAGE_BOSNIAN_CYRILLIC_LSO: + case LANGUAGE_BULGARIAN: + case LANGUAGE_GREEK: + case LANGUAGE_MONGOLIAN_CYRILLIC_LSO: + case LANGUAGE_MONGOLIAN_CYRILLIC_MONGOLIA: + case LANGUAGE_RUSSIAN: + case LANGUAGE_RUSSIAN_MOLDOVA: + case LANGUAGE_SERBIAN_CYRILLIC_BOSNIA_HERZEGOVINA: + case LANGUAGE_SERBIAN_CYRILLIC_LSO: + case LANGUAGE_SERBIAN_CYRILLIC_MONTENEGRO: + case LANGUAGE_SERBIAN_CYRILLIC_SAM: + case LANGUAGE_SERBIAN_CYRILLIC_SERBIA: + case LANGUAGE_UKRAINIAN: + case LANGUAGE_UZBEK_CYRILLIC: + case LANGUAGE_UZBEK_CYRILLIC_LSO: + return true; + default: + { + if (getScriptType( nLang) != com::sun::star::i18n::ScriptType::LATIN) + return false; + LanguageTag aLanguageTag( nLang); + if (aLanguageTag.hasScript()) + return aLanguageTag.getScript() != "Latn"; + } + } + return false; +} + + // static LanguageType MsLangId::getReplacementForObsoleteLanguage( LanguageType nLang, bool /*bUserInterfaceSelection*/ ) { diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx index e0582d858ed2..c35996ce83dc 100644 --- a/include/i18nlangtag/mslangid.hxx +++ b/include/i18nlangtag/mslangid.hxx @@ -148,6 +148,9 @@ public: /** Get ::com::sun::star::i18n::ScriptType of locale. */ static sal_Int16 getScriptType( LanguageType nLang ); + /** Whether locale is "Western" but not Latin script, e.g. Cyrillic or Greek. */ + static bool isNonLatinWestern( LanguageType nLang ); + /** Map an obsolete user defined LANGID (see lang.h LANGUAGE_OBSOLETE_USER_...) to the new value defined by MS in the