summaryrefslogtreecommitdiff
path: root/cui/source/options
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2012-11-24 18:54:09 +0100
committerEike Rathke <erack@redhat.com>2012-11-24 18:56:43 +0100
commit41956321ceefb5836feb2c119b66de7bb557740f (patch)
treee756d740615881ceeea816e7ef15096f91d7cc1e /cui/source/options
parent6395c843710b59e391f10f3532442ae11fe64357 (diff)
get rid of Svx...Locale...() double conversion nonsense
Change-Id: I21d14ff6087d1adb0ce769f2e8f8060a005250cc
Diffstat (limited to 'cui/source/options')
-rw-r--r--cui/source/options/optasian.cxx15
-rw-r--r--cui/source/options/optdict.cxx18
-rw-r--r--cui/source/options/optgdlg.cxx17
-rw-r--r--cui/source/options/optlingu.cxx46
4 files changed, 39 insertions, 57 deletions
diff --git a/cui/source/options/optasian.cxx b/cui/source/options/optasian.cxx
index 9a0819d0893a..50bfe4da92a5 100644
--- a/cui/source/options/optasian.cxx
+++ b/cui/source/options/optasian.cxx
@@ -202,8 +202,7 @@ sal_Bool SvxAsianLayoutPage::FillItemSet( SfxItemSet& )
for( itElem = pImpl->aChangedLanguagesMap.begin();
itElem != pImpl->aChangedLanguagesMap.end(); ++itElem )
{
- Locale aLocale;
- SvxLanguageToLocale( aLocale, itElem->first );
+ Locale aLocale( LanguageTag( itElem->first ).getLocale());
if(itElem->second->bRemoved)
pImpl->xForbidden->removeForbiddenCharacters( aLocale );
else if(itElem->second->pCharacters)
@@ -289,8 +288,8 @@ void SvxAsianLayoutPage::Reset( const SfxItemSet& )
//preselect the system language in the box - if available
if(USHRT_MAX == eLastUsedLanguageTypeForForbiddenCharacters)
{
- eLastUsedLanguageTypeForForbiddenCharacters = SvxLocaleToLanguage(
- Application::GetSettings().GetLanguageTag().getLocale() );
+ eLastUsedLanguageTypeForForbiddenCharacters =
+ Application::GetSettings().GetLanguageTag().getLanguageType();
if (MsLangId::isSimplifiedChinese(eLastUsedLanguageTypeForForbiddenCharacters))
eLastUsedLanguageTypeForForbiddenCharacters = LANGUAGE_CHINESE_SIMPLIFIED;
else if (MsLangId::isTraditionalChinese(eLastUsedLanguageTypeForForbiddenCharacters))
@@ -303,10 +302,9 @@ void SvxAsianLayoutPage::Reset( const SfxItemSet& )
IMPL_LINK_NOARG(SvxAsianLayoutPage, LanguageHdl)
{
//set current value
- Locale aLocale;
LanguageType eSelectLanguage = aLanguageLB.GetSelectLanguage();
- SvxLanguageToLocale(aLocale, eSelectLanguage );
- LanguageTag aLanguageTag( aLocale);
+ LanguageTag aLanguageTag( eSelectLanguage);
+ Locale aLocale( aLanguageTag.getLocale());
OUString sStart, sEnd;
sal_Bool bAvail;
@@ -380,9 +378,8 @@ IMPL_LINK(SvxAsianLayoutPage, ChangeStandardHdl, CheckBox*, pBox)
IMPL_LINK(SvxAsianLayoutPage, ModifyHdl, Edit*, pEdit)
{
- Locale aLocale;
LanguageType eSelectLanguage = aLanguageLB.GetSelectLanguage();
- SvxLanguageToLocale(aLocale, eSelectLanguage );
+ Locale aLocale( LanguageTag( eSelectLanguage ).getLocale());
OUString sStart = aStartED.GetText();
OUString sEnd = aEndED.GetText();
sal_Bool bEnable = pEdit->IsEnabled();
diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx
index b18c8bbbe6ea..97c21fd733df 100644
--- a/cui/source/options/optdict.cxx
+++ b/cui/source/options/optdict.cxx
@@ -153,7 +153,7 @@ IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl)
DictionaryType_NEGATIVE : DictionaryType_POSITIVE;
if (xDicList.is())
{
- lang::Locale aLocale( SvxCreateLocale(nLang) );
+ lang::Locale aLocale( LanguageTag(nLang).getLocale() );
String aURL( linguistic::GetWritableDictionaryURL( sDict ) );
xNewDic = Reference< XDictionary > (
xDicList->createDictionary( sDict, aLocale, eType, aURL ) , UNO_QUERY );
@@ -279,8 +279,8 @@ SvxEditDictionaryDialog::SvxEditDictionaryDialog(
sal_Bool bNegative = xDic->getDictionaryType() == DictionaryType_NEGATIVE ?
sal_True : sal_False;
String aDicName( xDic->getName() );
- const String aTxt( ::GetDicInfoStr( aDicName, SvxLocaleToLanguage( xDic->getLocale() ),
- bNegative ) );
+ const String aTxt( ::GetDicInfoStr( aDicName,
+ LanguageTag( xDic->getLocale() ).getLanguageType(), bNegative ) );
aAllDictsLB.InsertEntry( aTxt );
if (rName == aDicName)
@@ -307,7 +307,7 @@ SvxEditDictionaryDialog::SvxEditDictionaryDialog(
if (nPos != LISTBOX_ENTRY_NOTFOUND)
xDic = Reference< XDictionary > ( aDics.getConstArray()[ nPos ], UNO_QUERY );
if (xDic.is())
- SetLanguage_Impl( SvxLocaleToLanguage( xDic->getLocale() ) );
+ SetLanguage_Impl( LanguageTag( xDic->getLocale() ).getLanguageType() );
// check if dictionary is read-only
SetDicReadonly_Impl(xDic);
@@ -426,7 +426,7 @@ IMPL_LINK_NOARG(SvxEditDictionaryDialog, SelectBookHdl_Impl)
// enable or disable new and delete button according to file attributes
Reference< XDictionary > xDic( aDics.getConstArray()[ nPos ], UNO_QUERY );
if (xDic.is())
- SetLanguage_Impl( SvxLocaleToLanguage( xDic->getLocale() ) );
+ SetLanguage_Impl( LanguageTag( xDic->getLocale() ).getLanguageType() );
SetDicReadonly_Impl(xDic);
sal_Bool bEnable = !IsDicReadonly_Impl();
@@ -443,7 +443,7 @@ IMPL_LINK_NOARG(SvxEditDictionaryDialog, SelectLangHdl_Impl)
sal_uInt16 nDicPos = aAllDictsLB.GetSelectEntryPos();
sal_uInt16 nLang = aLangLB.GetSelectLanguage();
Reference< XDictionary > xDic( aDics.getConstArray()[ nDicPos ], UNO_QUERY );
- sal_Int16 nOldLang = SvxLocaleToLanguage( xDic->getLocale() );
+ sal_Int16 nOldLang = LanguageTag( xDic->getLocale() ).getLanguageType();
if ( nLang != nOldLang )
{
@@ -454,12 +454,12 @@ IMPL_LINK_NOARG(SvxEditDictionaryDialog, SelectLangHdl_Impl)
if ( aBox.Execute() == RET_YES )
{
- xDic->setLocale( SvxCreateLocale( nLang ) );
+ xDic->setLocale( LanguageTag( nLang ).getLocale() );
sal_Bool bNegativ = xDic->getDictionaryType() == DictionaryType_NEGATIVE;
const String sName(
::GetDicInfoStr( xDic->getName(),
- SvxLocaleToLanguage( xDic->getLocale() ),
+ LanguageTag( xDic->getLocale() ).getLanguageType(),
bNegativ ) );
aAllDictsLB.RemoveEntry( nDicPos );
aAllDictsLB.InsertEntry( sName, nDicPos );
@@ -619,7 +619,7 @@ IMPL_LINK(SvxEditDictionaryDialog, NewDelHdl, PushButton*, pBtn)
Reference<XDictionary> aXDictionary(xDic, UNO_QUERY);
nAddRes = linguistic::AddEntryToDic( aXDictionary,
aNewWord, bIsNegEntry,
- aRplcText, SvxLocaleToLanguage( xDic->getLocale() ), sal_False );
+ aRplcText, LanguageTag( xDic->getLocale() ).getLanguageType(), sal_False );
}
}
if (DIC_ERR_NONE != nAddRes)
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index eeb29f1d8c70..1e1a48b556ce 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -1375,7 +1375,7 @@ static LanguageType lcl_LangStringToLangType(const OUString& rLang)
if (nSep < rLang.getLength())
aLocale.Country = rLang.copy(nSep+1, rLang.getLength() - (nSep+1));
}
- LanguageType eLangType = SvxLocaleToLanguage( aLocale );
+ LanguageType eLangType = LanguageTag( aLocale ).getLanguageType();
return eLangType;
}
@@ -1492,16 +1492,7 @@ sal_Bool OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet )
// an empty string denotes SYSTEM locale
OUString sNewLang;
if ( eNewLocale != LANGUAGE_SYSTEM )
- {
- Locale aLocale;
- SvxLanguageToLocale( aLocale, eNewLocale );
- sNewLang = aLocale.Language;
- if ( !aLocale.Country.isEmpty() )
- {
- sNewLang += "-";
- sNewLang += aLocale.Country;
- }
- }
+ sNewLang = LanguageTag( eNewLocale).getBcp47();
// locale nowadays get to AppSettings via notification
// this will happen after releasing the lock on the ConfigurationBroadcaster at
@@ -1891,9 +1882,7 @@ IMPL_LINK( OfaLanguagesTabPage, LocaleSettingHdl, SvxLanguageBox*, pBox )
aCurrencyLB.SelectEntryPos( nPos );
// obtain corresponding locale data
- Locale aTempLocale;
- SvxLanguageToLocale( aTempLocale, eLang );
- LanguageTag aLanguageTag( aTempLocale);
+ LanguageTag aLanguageTag( eLang);
LocaleDataWrapper aLocaleWrapper( aLanguageTag );
// update the decimal separator key of the related CheckBox
diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx
index 24a94433d05a..65af919beee8 100644
--- a/cui/source/options/optlingu.cxx
+++ b/cui/source/options/optlingu.cxx
@@ -100,7 +100,7 @@ static Sequence< sal_Int16 > lcl_LocaleSeqToLangSeq( const Sequence< Locale > &r
const Locale *pSeq = rSeq.getConstArray();
for (sal_Int32 i = 0; i < nLen; ++i)
{
- pRes[i] = SvxLocaleToLanguage( pSeq[i] );
+ pRes[i] = LanguageTag( pSeq[i] ).getLanguageType();
}
return aRes;
}
@@ -734,9 +734,7 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
xMSF = ::comphelper::getProcessServiceFactory();
xLinguSrvcMgr = LinguServiceManager::create(comphelper::getComponentContext(xMSF));
- Locale aCurrentLocale;
- LanguageType eLang = Application::GetSettings().GetLanguageTag().getLanguageType();
- SvxLanguageToLocale(aCurrentLocale, eLang);
+ const Locale& rCurrentLocale = Application::GetSettings().GetLanguageTag().getLocale();
Sequence<Any> aArgs(2);//second arguments has to be empty!
aArgs.getArray()[0] <<= SvxGetLinguPropertySet();
@@ -755,7 +753,7 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
uno::Reference<XServiceDisplayName> xDispName(aInfo.xSpell, UNO_QUERY);
if(xDispName.is())
- aInfo.sDisplayName = xDispName->getServiceDisplayName( aCurrentLocale );
+ aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
const Sequence< Locale > aLocales( aInfo.xSpell->getLocales() );
//! suppress display of entries with no supported languages (see feature 110994)
@@ -779,7 +777,7 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
uno::Reference<XServiceDisplayName> xDispName(aInfo.xGrammar, UNO_QUERY);
if(xDispName.is())
- aInfo.sDisplayName = xDispName->getServiceDisplayName( aCurrentLocale );
+ aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
const Sequence< Locale > aLocales( aInfo.xGrammar->getLocales() );
//! suppress display of entries with no supported languages (see feature 110994)
@@ -803,7 +801,7 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
uno::Reference<XServiceDisplayName> xDispName(aInfo.xHyph, UNO_QUERY);
if(xDispName.is())
- aInfo.sDisplayName = xDispName->getServiceDisplayName( aCurrentLocale );
+ aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
const Sequence< Locale > aLocales( aInfo.xHyph->getLocales() );
//! suppress display of entries with no supported languages (see feature 110994)
@@ -827,7 +825,7 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
uno::Reference<XServiceDisplayName> xDispName(aInfo.xThes, UNO_QUERY);
if(xDispName.is())
- aInfo.sDisplayName = xDispName->getServiceDisplayName( aCurrentLocale );
+ aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
const Sequence< Locale > aLocales( aInfo.xThes->getLocales() );
//! suppress display of entries with no supported languages (see feature 110994)
@@ -842,7 +840,7 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
const Locale* pAllLocales = aAllServiceLocales.getConstArray();
for(sal_Int32 nLocale = 0; nLocale < aAllServiceLocales.getLength(); nLocale++)
{
- sal_Int16 nLang = SvxLocaleToLanguage( pAllLocales[nLocale] );
+ sal_Int16 nLang = LanguageTag( pAllLocales[nLocale] ).getLanguageType();
aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cSpell, pAllLocales[nLocale]);
SetChecked( aCfgSvcs );
@@ -985,7 +983,7 @@ void SvxLinguData_Impl::Reconfigure( const OUString &rDisplayName, sal_Bool bEna
nLocales = aLocales.getLength();
for (i = 0; i < nLocales; ++i)
{
- sal_Int16 nLang = SvxLocaleToLanguage( pLocale[i] );
+ sal_Int16 nLang = LanguageTag( pLocale[i] ).getLanguageType();
if (!aCfgSpellTable.count( nLang ) && bEnable)
aCfgSpellTable[ nLang ] = Sequence< OUString >();
if (aCfgSpellTable.count( nLang ))
@@ -1001,7 +999,7 @@ void SvxLinguData_Impl::Reconfigure( const OUString &rDisplayName, sal_Bool bEna
nLocales = aLocales.getLength();
for (i = 0; i < nLocales; ++i)
{
- sal_Int16 nLang = SvxLocaleToLanguage( pLocale[i] );
+ sal_Int16 nLang = LanguageTag( pLocale[i] ).getLanguageType();
if (!aCfgGrammarTable.count( nLang ) && bEnable)
aCfgGrammarTable[ nLang ] = Sequence< OUString >();
if (aCfgGrammarTable.count( nLang ))
@@ -1017,7 +1015,7 @@ void SvxLinguData_Impl::Reconfigure( const OUString &rDisplayName, sal_Bool bEna
nLocales = aLocales.getLength();
for (i = 0; i < nLocales; ++i)
{
- sal_Int16 nLang = SvxLocaleToLanguage( pLocale[i] );
+ sal_Int16 nLang = LanguageTag( pLocale[i] ).getLanguageType();
if (!aCfgHyphTable.count( nLang ) && bEnable)
aCfgHyphTable[ nLang ] = Sequence< OUString >();
if (aCfgHyphTable.count( nLang ))
@@ -1033,7 +1031,7 @@ void SvxLinguData_Impl::Reconfigure( const OUString &rDisplayName, sal_Bool bEna
nLocales = aLocales.getLength();
for (i = 0; i < nLocales; ++i)
{
- sal_Int16 nLang = SvxLocaleToLanguage( pLocale[i] );
+ sal_Int16 nLang = LanguageTag( pLocale[i] ).getLanguageType();
if (!aCfgThesTable.count( nLang ) && bEnable)
aCfgThesTable[ nLang ] = Sequence< OUString >();
if (aCfgThesTable.count( nLang ))
@@ -1210,7 +1208,7 @@ sal_Bool SvxLinguTabPage::FillItemSet( SfxItemSet& rCoreSet )
sal_Int16 nLang = aIt->first;
const Sequence< OUString > aImplNames( aIt->second );
uno::Reference< XLinguServiceManager2 > xMgr( pLinguData->GetManager() );
- Locale aLocale( SvxCreateLocale(nLang) );
+ Locale aLocale( LanguageTag(nLang).getLocale() );
if (xMgr.is())
xMgr->setConfiguredServices( cSpell, aLocale, aImplNames );
}
@@ -1222,7 +1220,7 @@ sal_Bool SvxLinguTabPage::FillItemSet( SfxItemSet& rCoreSet )
sal_Int16 nLang = aIt->first;
const Sequence< OUString > aImplNames( aIt->second );
uno::Reference< XLinguServiceManager2 > xMgr( pLinguData->GetManager() );
- Locale aLocale( SvxCreateLocale(nLang) );
+ Locale aLocale( LanguageTag(nLang).getLocale() );
if (xMgr.is())
xMgr->setConfiguredServices( cGrammar, aLocale, aImplNames );
}
@@ -1234,7 +1232,7 @@ sal_Bool SvxLinguTabPage::FillItemSet( SfxItemSet& rCoreSet )
sal_Int16 nLang = aIt->first;
const Sequence< OUString > aImplNames( aIt->second );
uno::Reference< XLinguServiceManager2 > xMgr( pLinguData->GetManager() );
- Locale aLocale( SvxCreateLocale(nLang) );
+ Locale aLocale( LanguageTag(nLang).getLocale() );
if (xMgr.is())
xMgr->setConfiguredServices( cHyph, aLocale, aImplNames );
}
@@ -1246,7 +1244,7 @@ sal_Bool SvxLinguTabPage::FillItemSet( SfxItemSet& rCoreSet )
sal_Int16 nLang = aIt->first;
const Sequence< OUString > aImplNames( aIt->second );
uno::Reference< XLinguServiceManager2 > xMgr( pLinguData->GetManager() );
- Locale aLocale( SvxCreateLocale(nLang) );
+ Locale aLocale( LanguageTag(nLang).getLocale() );
if (xMgr.is())
xMgr->setConfiguredServices( cThes, aLocale, aImplNames );
}
@@ -1381,7 +1379,7 @@ void SvxLinguTabPage::AddDicBoxEntry(
aLinguDicsCLB.SetUpdateMode(sal_False);
String aTxt( ::GetDicInfoStr( rxDic->getName(),
- SvxLocaleToLanguage( rxDic->getLocale() ),
+ LanguageTag( rxDic->getLocale() ).getLanguageType(),
DictionaryType_NEGATIVE == rxDic->getDictionaryType() ) );
aLinguDicsCLB.InsertEntry( aTxt, (sal_uInt16)LISTBOX_APPEND ); // append at end
SvTreeListEntry* pEntry = aLinguDicsCLB.GetEntry( aLinguDicsCLB.GetEntryCount() - 1 );
@@ -1638,7 +1636,7 @@ IMPL_LINK( SvxLinguTabPage, ClickHdl_Impl, PushButton *, pBtn )
sal_Int32 nLocales = pLinguData->GetAllSupportedLocales().getLength();
for (sal_Int32 k = 0; k < nLocales; ++k)
{
- sal_Int16 nLang = SvxLocaleToLanguage( pAllLocales[k] );
+ sal_Int16 nLang = LanguageTag( pAllLocales[k] ).getLanguageType();
if (pLinguData->GetSpellTable().count( nLang ))
pLinguData->SetChecked( pLinguData->GetSpellTable()[ nLang ] );
if (pLinguData->GetGrammarTable().count( nLang ))
@@ -1990,7 +1988,7 @@ SvxEditModulesDlg::SvxEditModulesDlg(Window* pParent, SvxLinguData_Impl& rData)
aLanguageLB.Clear();
for(long i = 0; i < rLoc.getLength(); i++)
{
- sal_Int16 nLang = SvxLocaleToLanguage( pLocales[i] );
+ sal_Int16 nLang = LanguageTag( pLocales[i] ).getLanguageType();
aLanguageLB.InsertLanguage( nLang, lcl_SeqHasLang( aAvailLang, nLang ) );
}
LanguageType eSysLang = MsLangId::getSystemLanguage();
@@ -2099,8 +2097,7 @@ IMPL_LINK( SvxEditModulesDlg, LangSelectHdl_Impl, ListBox *, pBox )
{
LanguageType eCurLanguage = aLanguageLB.GetSelectLanguage();
static Locale aLastLocale;
- Locale aCurLocale;
- SvxLanguageToLocale(aCurLocale, eCurLanguage);
+ Locale aCurLocale( LanguageTag( eCurLanguage).getLocale());
SvTreeList *pModel = aModulesCLB.GetModel();
if (pBox)
@@ -2108,7 +2105,7 @@ IMPL_LINK( SvxEditModulesDlg, LangSelectHdl_Impl, ListBox *, pBox )
// save old probably changed settings
// before switching to new language entries
- sal_Int16 nLang = SvxLocaleToLanguage( aLastLocale );
+ sal_Int16 nLang = LanguageTag( aLastLocale ).getLanguageType();
sal_Int32 nStart = 0, nLocalIndex = 0;
Sequence< OUString > aChange;
@@ -2347,8 +2344,7 @@ IMPL_LINK( SvxEditModulesDlg, LangSelectHdl_Impl, ListBox *, pBox )
}
}
}
- aLastLocale.Language = aCurLocale.Language;
- aLastLocale.Country = aCurLocale.Country;
+ aLastLocale = aCurLocale;
return 0;
}