diff options
author | Eike Rathke <erack@redhat.com> | 2013-09-12 19:31:04 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-09-12 19:31:45 +0200 |
commit | b291852c2f907e5d181b1de43af216f7d03db96a (patch) | |
tree | 014dfe4334ecd0edc46f6570cceae1c9cf1e3166 | |
parent | 2f6551b0167c2651f900b9c727bd74240b493754 (diff) |
get rid of unnecessary conversion, use LinguIsUnspecified(OUString)
Change-Id: Ib1074e3025680306c0a8bf7dcff651cefdcb90ba
-rw-r--r-- | include/linguistic/misc.hxx | 4 | ||||
-rw-r--r-- | lingucomponent/source/lingutil/lingutil.cxx | 6 | ||||
-rw-r--r-- | linguistic/source/misc.cxx | 13 |
3 files changed, 18 insertions, 5 deletions
diff --git a/include/linguistic/misc.hxx b/include/linguistic/misc.hxx index 3d6321ef1e74..da5c4dccec2e 100644 --- a/include/linguistic/misc.hxx +++ b/include/linguistic/misc.hxx @@ -111,6 +111,10 @@ LNG_DLLPUBLIC ::com::sun::star::lang::Locale LinguLanguageToLocale( LanguageType */ LNG_DLLPUBLIC bool LinguIsUnspecified( LanguageType nLanguage ); +/** The same as LinguIsUnspecified(LanguageType) but taking a BCP 47 language + tag string instead. */ +LNG_DLLPUBLIC bool LinguIsUnspecified( const OUString & rBcp47 ); + ::com::sun::star::uno::Sequence< sal_Int16 > LocaleSeqToLangSeq( ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > &rLocaleSeq ); diff --git a/lingucomponent/source/lingutil/lingutil.cxx b/lingucomponent/source/lingutil/lingutil.cxx index 48fe7c582134..5543a66a9dc7 100644 --- a/lingucomponent/source/lingutil/lingutil.cxx +++ b/lingucomponent/source/lingutil/lingutil.cxx @@ -208,11 +208,7 @@ void MergeNewStyleDicsAndOldStyleDics( DBG_ASSERT( nOldStyleDics, "old style dictionary with more then one language found!"); if (nOldStyleDics > 0) { - /* TODO: this conversion exists only to check with - * LinguIsUnspecified(), add another check that takes the tag - * string instead. */ - LanguageType nLang = LanguageTag::convertToLanguageTypeWithFallback( aIt2->aLocaleNames[0] ); - if (nLang == LANGUAGE_DONTKNOW || linguistic::LinguIsUnspecified( nLang)) + if (linguistic::LinguIsUnspecified( aIt2->aLocaleNames[0])) { OSL_FAIL( "old style dictionary with invalid language found!" ); continue; diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx index 867dccfc4c38..fe24438a0b6c 100644 --- a/linguistic/source/misc.cxx +++ b/linguistic/source/misc.cxx @@ -106,6 +106,19 @@ bool LinguIsUnspecified( LanguageType nLanguage ) return false; } +// When adding anything keep both LinguIsUnspecified() methods in sync! +// For mappings between language code string and LanguageType see +// i18nlangtag/source/isolang/isolang.cxx + +bool LinguIsUnspecified( const OUString & rBcp47 ) +{ + if (rBcp47.getLength() != 3) + return false; + if (rBcp47 == "zxx" || rBcp47 == "und" || rBcp47 == "mul") + return true; + return false; +} + static inline sal_Int32 Minimum( sal_Int32 n1, sal_Int32 n2, sal_Int32 n3 ) { sal_Int32 nMin = n1 < n2 ? n1 : n2; |