diff options
author | Eike Rathke <erack@redhat.com> | 2013-01-09 16:48:52 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-01-09 16:59:47 +0100 |
commit | 241ccc2568dd685d224f8a2b051c3e3a018d9400 (patch) | |
tree | da12883cfc55e669e9fff14452b74c1825f4eff3 /linguistic/source/misc.cxx | |
parent | a0bf71323741c5c58b77651fe656c73419dbf09f (diff) |
resolved fdo#58503 restore awkward handling of empty locale for legacy
Partly reverts d7a5ec62e91ce3dc5b784815254218f16181f676
An empty locale was treated as LANGUAGE_NONE, effectively being
interpreted as absence or undetermined or multiple or all depending on
context. Restore this behavior as it was an undocumented feature of the
API.
Change-Id: If4b1641e776d10dea0d3037f7a62725c2b8d612c
Diffstat (limited to 'linguistic/source/misc.cxx')
-rw-r--r-- | linguistic/source/misc.cxx | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx index adef81e3c7bd..cf590d5119f7 100644 --- a/linguistic/source/misc.cxx +++ b/linguistic/source/misc.cxx @@ -85,6 +85,36 @@ LocaleDataWrapper & GetLocaleDataWrapper( sal_Int16 nLang ) return aLclDtaWrp; } + +LanguageType LinguLocaleToLanguage( const ::com::sun::star::lang::Locale& rLocale ) +{ + if ( rLocale.Language.isEmpty() ) + return LANGUAGE_NONE; + return LanguageTag( rLocale ).getLanguageType(); +} + + +::com::sun::star::lang::Locale LinguLanguageToLocale( LanguageType nLanguage ) +{ + if (nLanguage == LANGUAGE_NONE) + return ::com::sun::star::lang::Locale(); + return LanguageTag( nLanguage).getLocale(); +} + + +bool LinguIsUnspecified( LanguageType nLanguage ) +{ + switch (nLanguage) + { + case LANGUAGE_NONE: + case LANGUAGE_UNDETERMINED: + case LANGUAGE_MULTIPLE: + 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; @@ -266,10 +296,10 @@ uno::Reference< XDictionaryEntry > SearchDicList( uno::Reference< XDictionary > axDic( pDic[i], UNO_QUERY ); DictionaryType eType = axDic->getDictionaryType(); - sal_Int16 nLang = LanguageTag( axDic->getLocale() ).getLanguageType(); + sal_Int16 nLang = LinguLocaleToLanguage( axDic->getLocale() ); if ( axDic.is() && axDic->isActive() - && (nLang == nLanguage || nLang == LANGUAGE_NONE) ) + && (nLang == nLanguage || LinguIsUnspecified( nLang)) ) { DBG_ASSERT( eType != DictionaryType_MIXED, "lng : unexpected dictionary type" ); @@ -373,7 +403,7 @@ uno::Sequence< sal_Int16 > sal_Int16 *pLang = aLangs.getArray(); for (sal_Int32 i = 0; i < nCount; ++i) { - pLang[i] = LanguageTag( pLocale[i] ).getLanguageType(); + pLang[i] = LinguLocaleToLanguage( pLocale[i] ); } return aLangs; @@ -554,7 +584,7 @@ uno::Reference< XHyphenatedWord > RebuildHyphensAndControlChars( } else { - sal_Int16 nLang = LanguageTag( rxHyphWord->getLocale() ).getLanguageType(); + sal_Int16 nLang = LinguLocaleToLanguage( rxHyphWord->getLocale() ); xRes = new HyphenatedWord( rOrigWord, nLang, nOrigHyphenationPos, aOrigHyphenatedWord, nOrigHyphenPos ); |