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 | |
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')
-rw-r--r-- | linguistic/source/convdic.cxx | 2 | ||||
-rw-r--r-- | linguistic/source/convdiclist.cxx | 2 | ||||
-rw-r--r-- | linguistic/source/dicimp.cxx | 7 | ||||
-rw-r--r-- | linguistic/source/dlistimp.cxx | 6 | ||||
-rw-r--r-- | linguistic/source/gciterator.cxx | 6 | ||||
-rw-r--r-- | linguistic/source/hyphdsp.cxx | 18 | ||||
-rw-r--r-- | linguistic/source/lngsvcmgr.cxx | 10 | ||||
-rw-r--r-- | linguistic/source/misc.cxx | 38 | ||||
-rw-r--r-- | linguistic/source/spelldsp.cxx | 14 | ||||
-rw-r--r-- | linguistic/source/spelldta.cxx | 4 | ||||
-rw-r--r-- | linguistic/source/thesdsp.cxx | 10 |
11 files changed, 75 insertions, 42 deletions
diff --git a/linguistic/source/convdic.cxx b/linguistic/source/convdic.cxx index c497c8697b6a..37310db0bdb3 100644 --- a/linguistic/source/convdic.cxx +++ b/linguistic/source/convdic.cxx @@ -152,7 +152,7 @@ sal_Bool IsConvDic( const String &rFileURL, sal_Int16 &nLang, sal_Int16 &nConvTy uno::Reference< XInterface > xRef( (document::XFilter *) pImport, UNO_QUERY ); ReadThroughDic( rFileURL, *pImport ); // will implicitly add the entries - bRes = pImport->GetLanguage() != LANGUAGE_NONE && + bRes = !LinguIsUnspecified( pImport->GetLanguage()) && pImport->GetConversionType() != -1; DBG_ASSERT( bRes, "conversion dictionary corrupted?" ); diff --git a/linguistic/source/convdiclist.cxx b/linguistic/source/convdiclist.cxx index 52ea6211f1e0..9fa05f418482 100644 --- a/linguistic/source/convdiclist.cxx +++ b/linguistic/source/convdiclist.cxx @@ -483,7 +483,7 @@ uno::Reference< XConversionDictionary > SAL_CALL ConvDicList::addNewDictionary( { MutexGuard aGuard( GetLinguMutex() ); - sal_Int16 nLang = LanguageTag( rLocale ).getLanguageType(); + sal_Int16 nLang = LinguLocaleToLanguage( rLocale ); if (GetNameContainer().hasByName( rName )) throw ElementExistException(); diff --git a/linguistic/source/dicimp.cxx b/linguistic/source/dicimp.cxx index dafa95d7b6fa..231779b8e7dd 100644 --- a/linguistic/source/dicimp.cxx +++ b/linguistic/source/dicimp.cxx @@ -419,7 +419,10 @@ sal_uLong DictionaryNeo::saveEntries(const OUString &rURL) pStream->WriteLine(rtl::OString(pVerOOo7)); if (0 != (nErr = pStream->GetError())) return nErr; - if (nLanguage == LANGUAGE_NONE) + /* XXX: the <none> case could be differentiated, is it absence or + * undetermined or multiple? Earlier versions did not know about 'und' and + * 'mul' and 'zxx' codes. Sync with ReadDicVersion() */ + if (LinguIsUnspecified(nLanguage)) pStream->WriteLine(rtl::OString(RTL_CONSTASCII_STRINGPARAM("lang: <none>"))); else { @@ -773,7 +776,7 @@ void SAL_CALL DictionaryNeo::setLocale( const Locale& aLocale ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - sal_Int16 nLanguageP = LanguageTag( aLocale ).getLanguageType(); + sal_Int16 nLanguageP = LinguLocaleToLanguage( aLocale ); if (!bIsReadonly && nLanguage != nLanguageP) { nLanguage = nLanguageP; diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx index 2c83a2421ef3..5e1b1ffe35b0 100644 --- a/linguistic/source/dlistimp.cxx +++ b/linguistic/source/dlistimp.cxx @@ -566,7 +566,7 @@ uno::Reference< XDictionary > SAL_CALL { osl::MutexGuard aGuard( GetLinguMutex() ); - sal_Int16 nLanguage = LanguageTag( rLocale ).getLanguageType(); + sal_Int16 nLanguage = LinguLocaleToLanguage( rLocale ); bool bIsWriteablePath = rURL.match( GetDictionaryWriteablePath(), 0 ); return new DictionaryNeo( rName, nLanguage, eDicType, rURL, bIsWriteablePath ); } @@ -578,7 +578,7 @@ uno::Reference< XDictionaryEntry > SAL_CALL throw(RuntimeException) { osl::MutexGuard aGuard( GetLinguMutex() ); - return SearchDicList( this, rWord, LanguageTag( rLocale ).getLanguageType(), + return SearchDicList( this, rWord, LinguLocaleToLanguage( rLocale ), bSearchPosDics, bSearchSpellEntry ); } @@ -669,7 +669,7 @@ void DicList::_CreateDicList() // and add it to list rtl::OUString aDicName( A2OU( "IgnoreAllList" ) ); uno::Reference< XDictionary > xIgnAll( - createDictionary( aDicName, LanguageTag( LANGUAGE_NONE ).getLocale(), + createDictionary( aDicName, LinguLanguageToLocale( LANGUAGE_NONE ), DictionaryType_POSITIVE, rtl::OUString() ) ); if (xIgnAll.is()) { diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index c9bafd409374..792d406a3e84 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -1072,12 +1072,12 @@ void GrammarCheckingIterator::SetServiceList( { ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() ); - LanguageType nLanguage = LanguageTag( rLocale ).getLanguageType(); + LanguageType nLanguage = LinguLocaleToLanguage( rLocale ); OUString aImplName; if (rSvcImplNames.getLength() > 0) aImplName = rSvcImplNames[0]; // there is only one grammar checker per language - if (nLanguage != LANGUAGE_NONE && nLanguage != LANGUAGE_DONTKNOW) + if (!LinguIsUnspecified(nLanguage) && nLanguage != LANGUAGE_DONTKNOW) { if (!aImplName.isEmpty()) m_aGCImplNamesByLang[ nLanguage ] = aImplName; @@ -1095,7 +1095,7 @@ uno::Sequence< OUString > GrammarCheckingIterator::GetServiceList( uno::Sequence< OUString > aRes(1); OUString aImplName; // there is only one grammar checker per language - LanguageType nLang = LanguageTag( rLocale ).getLanguageType(); + LanguageType nLang = LinguLocaleToLanguage( rLocale ); GCImplNames_t::const_iterator aIt( m_aGCImplNamesByLang.find( nLang ) ); if (aIt != m_aGCImplNamesByLang.end()) aImplName = aIt->second; diff --git a/linguistic/source/hyphdsp.cxx b/linguistic/source/hyphdsp.cxx index ac08631f9862..757e836fc126 100644 --- a/linguistic/source/hyphdsp.cxx +++ b/linguistic/source/hyphdsp.cxx @@ -236,7 +236,7 @@ sal_Bool SAL_CALL HyphenatorDispatcher::hasLocale(const Locale& rLocale) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - HyphSvcByLangMap_t::const_iterator aIt( aSvcMap.find( LanguageTag( rLocale ).getLanguageType() ) ); + HyphSvcByLangMap_t::const_iterator aIt( aSvcMap.find( LinguLocaleToLanguage( rLocale ) ) ); return aIt != aSvcMap.end(); } @@ -252,8 +252,8 @@ Reference< XHyphenatedWord > SAL_CALL Reference< XHyphenatedWord > xRes; sal_Int32 nWordLen = rWord.getLength(); - sal_Int16 nLanguage = LanguageTag( rLocale ).getLanguageType(); - if (nLanguage == LANGUAGE_NONE || !nWordLen || + sal_Int16 nLanguage = LinguLocaleToLanguage( rLocale ); + if (LinguIsUnspecified(nLanguage) || !nWordLen || nMaxLeading == 0 || nMaxLeading == nWordLen) return xRes; @@ -390,8 +390,8 @@ Reference< XHyphenatedWord > SAL_CALL Reference< XHyphenatedWord > xRes; sal_Int32 nWordLen = rWord.getLength(); - sal_Int16 nLanguage = LanguageTag( rLocale ).getLanguageType(); - if (nLanguage == LANGUAGE_NONE || !nWordLen) + sal_Int16 nLanguage = LinguLocaleToLanguage( rLocale ); + if (LinguIsUnspecified(nLanguage) || !nWordLen) return xRes; // search for entry with that language @@ -521,8 +521,8 @@ Reference< XPossibleHyphens > SAL_CALL Reference< XPossibleHyphens > xRes; - sal_Int16 nLanguage = LanguageTag( rLocale ).getLanguageType(); - if (nLanguage == LANGUAGE_NONE || rWord.isEmpty()) + sal_Int16 nLanguage = LinguLocaleToLanguage( rLocale ); + if (LinguIsUnspecified(nLanguage) || rWord.isEmpty()) return xRes; // search for entry with that language @@ -638,7 +638,7 @@ void HyphenatorDispatcher::SetServiceList( const Locale &rLocale, { MutexGuard aGuard( GetLinguMutex() ); - sal_Int16 nLanguage = LanguageTag( rLocale ).getLanguageType(); + sal_Int16 nLanguage = LinguLocaleToLanguage( rLocale ); sal_Int32 nLen = rSvcImplNames.getLength(); if (0 == nLen) @@ -673,7 +673,7 @@ Sequence< OUString > Sequence< OUString > aRes; // search for entry with that language and use data from that - sal_Int16 nLanguage = LanguageTag( rLocale ).getLanguageType(); + sal_Int16 nLanguage = LinguLocaleToLanguage( rLocale ); HyphenatorDispatcher *pThis = (HyphenatorDispatcher *) this; const HyphSvcByLangMap_t::iterator aIt( pThis->aSvcMap.find( nLanguage ) ); const LangSvcEntries_Hyph *pEntry = aIt != aSvcMap.end() ? aIt->second.get() : NULL; diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx index a8e976351edb..fefef1cdc009 100644 --- a/linguistic/source/lngsvcmgr.cxx +++ b/linguistic/source/lngsvcmgr.cxx @@ -115,7 +115,7 @@ static uno::Sequence< lang::Locale > GetAvailLocales( for (sal_Int32 k = 0; k < nLoc; ++k) { const lang::Locale *pLoc = aLoc.getConstArray(); - LanguageType nLang = LanguageTag( pLoc[k] ).getLanguageType(); + LanguageType nLang = LinguLocaleToLanguage( pLoc[k] ); // language not already added? if (aLanguages.find( nLang ) == aLanguages.end()) @@ -1602,11 +1602,11 @@ uno::Sequence< OUString > SAL_CALL OUString *pImplName = aRes.getArray(); sal_uInt16 nCnt = 0; - LanguageType nLanguage = LanguageTag( rLocale ).getLanguageType(); + LanguageType nLanguage = LinguLocaleToLanguage( rLocale ); for (size_t i = 0; i < nMaxCnt; ++i) { const SvcInfo &rInfo = (*pInfoArray)[i]; - if (LANGUAGE_NONE == nLanguage + if (LinguIsUnspecified( nLanguage ) || rInfo.HasLanguage( nLanguage )) { pImplName[ nCnt++ ] = rInfo.aSvcImplName; @@ -1689,8 +1689,8 @@ void SAL_CALL #if OSL_DEBUG_LEVEL > 1 #endif - LanguageType nLanguage = LanguageTag( rLocale ).getLanguageType(); - if (LANGUAGE_NONE != nLanguage) + LanguageType nLanguage = LinguLocaleToLanguage( rLocale ); + if (!LinguIsUnspecified( nLanguage)) { if (0 == rServiceName.compareToAscii( SN_SPELLCHECKER )) { 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 ); diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx index 6472626aa760..5b6727f2e9c2 100644 --- a/linguistic/source/spelldsp.cxx +++ b/linguistic/source/spelldsp.cxx @@ -220,7 +220,7 @@ sal_Bool SAL_CALL SpellCheckerDispatcher::hasLocale( const Locale& rLocale ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - SpellSvcByLangMap_t::const_iterator aIt( aSvcMap.find( LanguageTag( rLocale ).getLanguageType() ) ); + SpellSvcByLangMap_t::const_iterator aIt( aSvcMap.find( LinguLocaleToLanguage( rLocale ) ) ); return aIt != aSvcMap.end(); } @@ -231,7 +231,7 @@ sal_Bool SAL_CALL throw(IllegalArgumentException, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - return isValid_Impl( rWord, LanguageTag( rLocale ).getLanguageType(), rProperties, sal_True ); + return isValid_Impl( rWord, LinguLocaleToLanguage( rLocale ), rProperties, sal_True ); } @@ -241,7 +241,7 @@ Reference< XSpellAlternatives > SAL_CALL throw(IllegalArgumentException, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - return spell_Impl( rWord, LanguageTag( rLocale ).getLanguageType(), rProperties, sal_True ); + return spell_Impl( rWord, LinguLocaleToLanguage( rLocale ), rProperties, sal_True ); } @@ -290,7 +290,7 @@ sal_Bool SpellCheckerDispatcher::isValid_Impl( sal_Bool bRes = sal_True; - if (nLanguage == LANGUAGE_NONE || rWord.isEmpty()) + if (LinguIsUnspecified( nLanguage) || rWord.isEmpty()) return bRes; // search for entry with that language @@ -460,7 +460,7 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl( Reference< XSpellAlternatives > xRes; - if (nLanguage == LANGUAGE_NONE || rWord.isEmpty()) + if (LinguIsUnspecified( nLanguage) || rWord.isEmpty()) return xRes; // search for entry with that language @@ -767,7 +767,7 @@ void SpellCheckerDispatcher::SetServiceList( const Locale &rLocale, if (pCache) pCache->Flush(); // new services may spell differently... - sal_Int16 nLanguage = LanguageTag( rLocale ).getLanguageType(); + sal_Int16 nLanguage = LinguLocaleToLanguage( rLocale ); sal_Int32 nLen = rSvcImplNames.getLength(); if (0 == nLen) @@ -801,7 +801,7 @@ Sequence< OUString > Sequence< OUString > aRes; // search for entry with that language and use data from that - sal_Int16 nLanguage = LanguageTag( rLocale ).getLanguageType(); + sal_Int16 nLanguage = LinguLocaleToLanguage( rLocale ); SpellCheckerDispatcher *pThis = (SpellCheckerDispatcher *) this; const SpellSvcByLangMap_t::iterator aIt( pThis->aSvcMap.find( nLanguage ) ); const LangSvcEntries_Spell *pEntry = aIt != aSvcMap.end() ? aIt->second.get() : NULL; diff --git a/linguistic/source/spelldta.cxx b/linguistic/source/spelldta.cxx index f135003e6fba..886af7072522 100644 --- a/linguistic/source/spelldta.cxx +++ b/linguistic/source/spelldta.cxx @@ -78,10 +78,10 @@ void SearchSimilarText( const OUString &rText, sal_Int16 nLanguage, { Reference< XDictionary > xDic( pDic[i], UNO_QUERY ); - sal_Int16 nLang = LanguageTag( xDic->getLocale() ).getLanguageType(); + sal_Int16 nLang = LinguLocaleToLanguage( xDic->getLocale() ); if ( xDic.is() && xDic->isActive() - && (nLang == nLanguage || nLang == LANGUAGE_NONE) ) + && (nLang == nLanguage || LinguIsUnspecified( nLang)) ) { #if OSL_DEBUG_LEVEL > 1 DictionaryType eType = xDic->getDictionaryType(); diff --git a/linguistic/source/thesdsp.cxx b/linguistic/source/thesdsp.cxx index e8656af3e914..dfd106f0eac7 100644 --- a/linguistic/source/thesdsp.cxx +++ b/linguistic/source/thesdsp.cxx @@ -101,7 +101,7 @@ sal_Bool SAL_CALL throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - ThesSvcByLangMap_t::const_iterator aIt( aSvcMap.find( LanguageTag( rLocale ).getLanguageType() ) ); + ThesSvcByLangMap_t::const_iterator aIt( aSvcMap.find( LinguLocaleToLanguage( rLocale ) ) ); return aIt != aSvcMap.end(); } @@ -116,8 +116,8 @@ Sequence< Reference< XMeaning > > SAL_CALL Sequence< Reference< XMeaning > > aMeanings; - sal_Int16 nLanguage = LanguageTag( rLocale ).getLanguageType(); - if (nLanguage == LANGUAGE_NONE || rTerm.isEmpty()) + sal_Int16 nLanguage = LinguLocaleToLanguage( rLocale ); + if (LinguIsUnspecified( nLanguage) || rTerm.isEmpty()) return aMeanings; // search for entry with that language @@ -210,7 +210,7 @@ void ThesaurusDispatcher::SetServiceList( const Locale &rLocale, { MutexGuard aGuard( GetLinguMutex() ); - sal_Int16 nLanguage = LanguageTag( rLocale ).getLanguageType(); + sal_Int16 nLanguage = LinguLocaleToLanguage( rLocale ); sal_Int32 nLen = rSvcImplNames.getLength(); if (0 == nLen) @@ -244,7 +244,7 @@ Sequence< OUString > Sequence< OUString > aRes; // search for entry with that language and use data from that - sal_Int16 nLanguage = LanguageTag( rLocale ).getLanguageType(); + sal_Int16 nLanguage = LinguLocaleToLanguage( rLocale ); ThesaurusDispatcher *pThis = (ThesaurusDispatcher *) this; const ThesSvcByLangMap_t::iterator aIt( pThis->aSvcMap.find( nLanguage ) ); const LangSvcEntries_Thes *pEntry = aIt != aSvcMap.end() ? aIt->second.get() : NULL; |