diff options
author | Eike Rathke <erack@redhat.com> | 2012-11-21 18:34:53 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2012-11-21 18:35:53 +0100 |
commit | b8a467b70756b83c8aeb77f385ea1e368350d370 (patch) | |
tree | eb0c2a0f560899b634ef8598f9022f4af24f1427 | |
parent | be677b568690415ff90e7937d7269d3b41b39c16 (diff) |
obtain LanguageTag from SvtSysLocale
Change-Id: Iaee25f1d92349704eaae45e6582d31dfa718ddcb
-rw-r--r-- | linguistic/source/misc.cxx | 2 | ||||
-rw-r--r-- | svl/source/config/ctloptions.cxx | 2 | ||||
-rw-r--r-- | svl/source/config/languageoptions.cxx | 2 | ||||
-rw-r--r-- | svl/source/items/style.cxx | 2 | ||||
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 16 | ||||
-rw-r--r-- | svtools/source/table/cellvalueconversion.cxx | 4 | ||||
-rw-r--r-- | unotools/inc/unotools/syslocale.hxx | 9 | ||||
-rw-r--r-- | unotools/inc/unotools/syslocaleoptions.hxx | 14 | ||||
-rw-r--r-- | unotools/source/config/compatibility.cxx | 2 | ||||
-rw-r--r-- | unotools/source/config/fontcfg.cxx | 4 | ||||
-rw-r--r-- | unotools/source/config/syslocaleoptions.cxx | 44 | ||||
-rw-r--r-- | unotools/source/misc/syslocale.cxx | 28 | ||||
-rw-r--r-- | vcl/source/app/settings.cxx | 10 |
13 files changed, 47 insertions, 92 deletions
diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx index 02c5ef885b9d..53afb419e952 100644 --- a/linguistic/source/misc.cxx +++ b/linguistic/source/misc.cxx @@ -77,7 +77,7 @@ osl::Mutex & GetLinguMutex() LocaleDataWrapper & GetLocaleDataWrapper( sal_Int16 nLang ) { static LocaleDataWrapper aLclDtaWrp( - CreateLocale( SvtSysLocale().GetUILanguage() ) ); + CreateLocale( SvtSysLocale().GetLanguageTag().getLanguageType() ) ); const Locale &rLcl = aLclDtaWrp.getLoadedLocale(); Locale aLcl( CreateLocale( nLang ) ); diff --git a/svl/source/config/ctloptions.cxx b/svl/source/config/ctloptions.cxx index 36d8df1a7507..9a4fcb1d2caa 100644 --- a/svl/source/config/ctloptions.cxx +++ b/svl/source/config/ctloptions.cxx @@ -293,7 +293,7 @@ void SvtCTLOptions_Impl::Load() ((eSystemLanguage != LANGUAGE_SYSTEM) && ( nWinScript & SCRIPTTYPE_COMPLEX ))) ) { m_bCTLFontEnabled = sal_True; - sal_uInt16 nLanguage = SvtSysLocale().GetLanguage(); + sal_uInt16 nLanguage = SvtSysLocale().GetLanguageTag().getLanguageType(); //enable sequence checking for the appropriate languages m_bCTLSequenceChecking = m_bCTLRestricted = m_bCTLTypeAndReplace = (MsLangId::needsSequenceChecking( nLanguage) || diff --git a/svl/source/config/languageoptions.cxx b/svl/source/config/languageoptions.cxx index c73318c91658..cdf61e81f271 100644 --- a/svl/source/config/languageoptions.cxx +++ b/svl/source/config/languageoptions.cxx @@ -149,7 +149,7 @@ sal_uInt16 SvtLanguageOptions::GetScriptTypeOfLanguage( sal_uInt16 nLang ) if( LANGUAGE_DONTKNOW == nLang ) nLang = LANGUAGE_ENGLISH_US; else if( LANGUAGE_SYSTEM == nLang ) - nLang = SvtSysLocale().GetLanguage(); + nLang = SvtSysLocale().GetLanguageTag().getLanguageType(); sal_Int16 nScriptType = MsLangId::getScriptType( nLang ); sal_uInt16 nScript; diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index 1c8a7c858bbf..1bc6d17e050c 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -334,7 +334,7 @@ XubString SfxStyleSheetBase::GetDescription( SfxMapUnit eMetric ) const SfxPoolItem* pItem = aIter.FirstItem(); IntlWrapper aIntlWrapper(comphelper::getProcessServiceFactory(), - SvtSysLocale().GetLanguage()); + SvtSysLocale().GetLanguageTag().getLocale()); while ( pItem ) { XubString aItemPresentation; diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index f6094178aea0..af30c94595ca 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -636,13 +636,13 @@ sal_uInt32 SvNumberFormatter::GetIndexPuttingAndConverting( String & rString, // #62389# empty format string (of Writer) => General standard format if (!rString.Len()) ; // nothing - else if (eLnge == LANGUAGE_SYSTEM && eSysLnge != SvtSysLocale().GetLanguage()) + else if (eLnge == LANGUAGE_SYSTEM && eSysLnge != SvtSysLocale().GetLanguageTag().getLanguageType()) { sal_uInt32 nOrig = GetEntryKey( rString, eSysLnge ); if (nOrig == NUMBERFORMAT_ENTRY_NOT_FOUND) nKey = nOrig; // none avaliable, maybe user-defined else - nKey = GetFormatForLanguageIfBuiltIn( nOrig, SvtSysLocale().GetLanguage() ); + nKey = GetFormatForLanguageIfBuiltIn( nOrig, SvtSysLocale().GetLanguageTag().getLanguageType() ); if (nKey == nOrig) { @@ -651,7 +651,7 @@ sal_uInt32 SvNumberFormatter::GetIndexPuttingAndConverting( String & rString, // language and wouldn't match eSysLnge anymore, do that on a copy. String aTmp( rString); rNewInserted = PutandConvertEntrySystem( aTmp, rCheckPos, rType, - nKey, eLnge, SvtSysLocale().GetLanguage()); + nKey, eLnge, SvtSysLocale().GetLanguageTag().getLanguageType()); if (rCheckPos > 0) { SAL_WARN( "svl.numbers", "SvNumberFormatter::GetIndexPuttingAndConverting: bad format code string for current locale"); @@ -702,7 +702,7 @@ void SvNumberFormatter::DeleteEntry(sal_uInt32 nKey) bool SvNumberFormatter::Load( SvStream& rStream ) { - LanguageType eSysLang = SvtSysLocale().GetLanguage(); + LanguageType eSysLang = SvtSysLocale().GetLanguageTag().getLanguageType(); SvNumberFormatter* pConverter = NULL; ImpSvNumMultipleReadHeader aHdr( rStream ); @@ -802,7 +802,7 @@ bool SvNumberFormatter::Save( SvStream& rStream ) const // As of 364i we store what SYSTEM locale really was, before it was hard // coded LANGUAGE_SYSTEM. rStream << (sal_uInt16) SV_NUMBERFORMATTER_VERSION; - rStream << (sal_uInt16) SvtSysLocale().GetLanguage() << (sal_uInt16) IniLnge; + rStream << (sal_uInt16) SvtSysLocale().GetLanguageTag().getLanguageType() << (sal_uInt16) IniLnge; const SvNumberFormatTable* pTable = &aFTable; SvNumberFormatTable::const_iterator it = pTable->begin(); while (it != pTable->end()) @@ -3167,7 +3167,7 @@ void SvNumberFormatter::SetDefaultSystemCurrency( const String& rAbbrev, Languag { ::osl::MutexGuard aGuard( GetMutex() ); if ( eLang == LANGUAGE_SYSTEM ) - eLang = SvtSysLocale().GetLanguage(); + eLang = SvtSysLocale().GetLanguageTag().getLanguageType(); const NfCurrencyTable& rTable = GetTheCurrencyTable(); sal_uInt16 nCount = rTable.size(); if ( rAbbrev.Len() ) @@ -3562,10 +3562,10 @@ void SvNumberFormatter::ImpInitCurrencyTable() RTL_LOGFILE_CONTEXT_AUTHOR( aTimeLog, "svl", "er93726", "SvNumberFormatter::ImpInitCurrencyTable" ); - LanguageType eSysLang = SvtSysLocale().GetLanguage(); + LanguageType eSysLang = SvtSysLocale().GetLanguageTag().getLanguageType(); LocaleDataWrapper* pLocaleData = new LocaleDataWrapper( ::comphelper::getProcessComponentContext(), - LanguageTag( eSysLang ).getLocale() ); + SvtSysLocale().GetLanguageTag().getLocale() ); // get user configured currency String aConfiguredCurrencyAbbrev; LanguageType eConfiguredCurrencyLanguage = LANGUAGE_SYSTEM; diff --git a/svtools/source/table/cellvalueconversion.cxx b/svtools/source/table/cellvalueconversion.cxx index fba286c45f73..d47210bb9edf 100644 --- a/svtools/source/table/cellvalueconversion.cxx +++ b/svtools/source/table/cellvalueconversion.cxx @@ -146,7 +146,7 @@ namespace svt ENSURE_OR_THROW( i_formatter.is(), "StandardFormatNormalizer: no formatter!" ); Reference< XNumberFormatsSupplier > const xSupplier( i_formatter->getNumberFormatsSupplier(), UNO_SET_THROW ); Reference< XNumberFormatTypes > const xTypes( xSupplier->getNumberFormats(), UNO_QUERY_THROW ); - m_nFormatKey = xTypes->getStandardFormat( i_numberFormatType, SvtSysLocale().GetLocale() ); + m_nFormatKey = xTypes->getStandardFormat( i_numberFormatType, SvtSysLocale().GetLanguageTag().getLocale() ); } catch( const Exception& ) { @@ -341,7 +341,7 @@ namespace svt // a supplier of number formats Sequence< Any > aInitArgs(1); - aInitArgs[0] <<= SvtSysLocale().GetLocale(); + aInitArgs[0] <<= SvtSysLocale().GetLanguageTag().getLocale(); Reference< XNumberFormatsSupplier > const xSupplier( io_data.aContext.createComponentWithArguments( "com.sun.star.util.NumberFormatsSupplier", aInitArgs ), diff --git a/unotools/inc/unotools/syslocale.hxx b/unotools/inc/unotools/syslocale.hxx index d10e2c969329..e148504d0940 100644 --- a/unotools/inc/unotools/syslocale.hxx +++ b/unotools/inc/unotools/syslocale.hxx @@ -23,15 +23,14 @@ #include "unotools/unotoolsdllapi.h" #include <unotools/localedatawrapper.hxx> #include <unotools/charclass.hxx> +#include <i18npool/languagetag.hxx> #include <sal/types.h> -#include <i18npool/lang.h> #include <rtl/textenc.h> class SvtSysLocale_Impl; class SvtSysLocaleOptions; namespace osl { class Mutex; } -class LocaleDataWrapper; /** SvtSysLocale provides a refcounted single instance of an application wide @@ -65,10 +64,8 @@ public: const LocaleDataWrapper* GetLocaleDataPtr() const; const CharClass* GetCharClassPtr() const; SvtSysLocaleOptions& GetOptions() const; - com::sun::star::lang::Locale GetLocale() const; - LanguageType GetLanguage() const; - com::sun::star::lang::Locale GetUILocale() const; - LanguageType GetUILanguage() const; + const LanguageTag& GetLanguageTag() const; + const LanguageTag& GetUILanguageTag() const; /** Get the best MIME encoding matching the system locale, or if that isn't determinable one that matches the UI locale, or UTF8 if everything else diff --git a/unotools/inc/unotools/syslocaleoptions.hxx b/unotools/inc/unotools/syslocaleoptions.hxx index a7d1f84bbe9a..d9bb17e36eda 100644 --- a/unotools/inc/unotools/syslocaleoptions.hxx +++ b/unotools/inc/unotools/syslocaleoptions.hxx @@ -26,9 +26,9 @@ #include <tools/solar.h> #include <tools/link.hxx> #include <i18npool/lang.h> +#include <i18npool/languagetag.hxx> #include <tools/string.hxx> #include <unotools/options.hxx> -#include <com/sun/star/lang/Locale.hpp> // bits for broadcasting hints of changes in a SfxSimpleHint, may be combined const sal_uLong SYSLOCALEOPTIONS_HINT_LOCALE = 0x00000001; @@ -99,14 +99,16 @@ public: /// The config string may be empty to denote the SYSTEM locale const ::rtl::OUString& GetLocaleConfigString() const; void SetLocaleConfigString( const ::rtl::OUString& rStr ); - com::sun::star::lang::Locale GetLocale() const; - com::sun::star::lang::Locale GetRealLocale() const; - LanguageType GetRealLanguage() const; + /** Get locale set, if empty denotes SYSTEM locale, not resolved + to the real locale. */ + LanguageTag GetLanguageTag() const; + /** Get locale set, always resolved to the real locale. */ + const LanguageTag& GetRealLanguageTag() const; /// The config string may be empty to denote the SYSTEM locale void SetUILocaleConfigString( const ::rtl::OUString& rStr ); - com::sun::star::lang::Locale GetRealUILocale() const; - LanguageType GetRealUILanguage() const; + /** Get UI locale set, always resolved to the real locale. */ + const LanguageTag& GetRealUILanguageTag() const; /// The config string may be empty to denote the default currency of the locale const ::rtl::OUString& GetCurrencyConfigString() const; diff --git a/unotools/source/config/compatibility.cxx b/unotools/source/config/compatibility.cxx index 8278137c61bb..e5079a9886d2 100644 --- a/unotools/source/config/compatibility.cxx +++ b/unotools/source/config/compatibility.cxx @@ -404,7 +404,7 @@ SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl() if ( !bDefaultFound && aItem.sName.equals( COMPATIBILITY_DEFAULT_NAME ) != sal_False ) { SvtSysLocale aSysLocale; - com::sun::star::lang::Locale aLocale = aSysLocale.GetLocale(); + com::sun::star::lang::Locale aLocale = aSysLocale.GetLanguageTag().getLocale(); if ( aLocale.Language == "zh" || aLocale.Language == "ja" || aLocale.Language == "ko" ) aItem.bExpandWordSpace = false; diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index 314fed44faa3..ce1f465f2a6c 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -252,7 +252,7 @@ OUString DefaultFontConfiguration::getUserInterfaceFont( const Locale& rLocale ) { Locale aLocale = rLocale; if( aLocale.Language.isEmpty() ) - aLocale = SvtSysLocale().GetUILocale(); + aLocale = SvtSysLocale().GetUILanguageTag().getLocale(); OUString aUIFont = getDefaultFont( aLocale, DEFAULTFONT_UI_SANS ); @@ -1160,7 +1160,7 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const String& rFontNam aLocale.Variant = rLocale.Variant.toAsciiUpperCase(); if( aLocale.Language.isEmpty() ) - aLocale = SvtSysLocale().GetUILocale(); + aLocale = SvtSysLocale().GetUILanguageTag().getLocale(); while( !aLocale.Language.isEmpty() ) { diff --git a/unotools/source/config/syslocaleoptions.cxx b/unotools/source/config/syslocaleoptions.cxx index 10c7574d5623..785cf33611d0 100644 --- a/unotools/source/config/syslocaleoptions.cxx +++ b/unotools/source/config/syslocaleoptions.cxx @@ -49,26 +49,6 @@ namespace : public rtl::Static<Link, CurrencyChangeLink> {}; } -static com::sun::star::lang::Locale lcl_str_to_locale( const ::rtl::OUString rStr ) -{ - com::sun::star::lang::Locale aRet; - if ( !rStr.isEmpty() ) - { - aRet = com::sun::star::lang::Locale(); - sal_Int32 nSep = rStr.indexOf('-'); - if (nSep < 0) - aRet.Language = rStr; - else - { - aRet.Language = rStr.copy(0, nSep); - if (nSep < rStr.getLength()) - aRet.Country = rStr.copy(nSep+1, rStr.getLength() - (nSep+1)); - } - } - - return aRet; -} - class SvtSysLocaleOptions_Impl : public utl::ConfigItem { LanguageTag m_aRealLocale; @@ -121,10 +101,8 @@ public: void SetIgnoreLanguageChange( sal_Bool bSet); sal_Bool IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const; - const Locale& GetRealLocale() { return m_aRealLocale.getLocale(); } - const Locale& GetRealUILocale() { return m_aRealUILocale.getLocale(); } - LanguageType GetRealLanguage() { return m_aRealLocale.getLanguageType(); } - LanguageType GetRealUILanguage() { return m_aRealUILocale.getLanguageType(); } + const LanguageTag& GetRealLocale() { return m_aRealLocale; } + const LanguageTag& GetRealUILocale() { return m_aRealUILocale; } }; @@ -755,30 +733,20 @@ void SvtSysLocaleOptions::ConfigurationChanged( utl::ConfigurationBroadcaster* p ::utl::detail::Options::ConfigurationChanged( p, nHint ); } -com::sun::star::lang::Locale SvtSysLocaleOptions::GetLocale() const +LanguageTag SvtSysLocaleOptions::GetLanguageTag() const { - return lcl_str_to_locale( GetLocaleConfigString() ); + return LanguageTag( GetLocaleConfigString() ); } -com::sun::star::lang::Locale SvtSysLocaleOptions::GetRealLocale() const +const LanguageTag & SvtSysLocaleOptions::GetRealLanguageTag() const { return pOptions->GetRealLocale(); } -com::sun::star::lang::Locale SvtSysLocaleOptions::GetRealUILocale() const +const LanguageTag & SvtSysLocaleOptions::GetRealUILanguageTag() const { return pOptions->GetRealUILocale(); } -LanguageType SvtSysLocaleOptions::GetRealLanguage() const -{ - return pOptions->GetRealLanguage(); -} - -LanguageType SvtSysLocaleOptions::GetRealUILanguage() const -{ - return pOptions->GetRealUILanguage(); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx index a769e8ba4593..c8b0fe10e0af 100644 --- a/unotools/source/misc/syslocale.cxx +++ b/unotools/source/misc/syslocale.cxx @@ -20,9 +20,7 @@ #include <unotools/syslocale.hxx> #include <unotools/syslocaleoptions.hxx> -#include <unotools/localedatawrapper.hxx> #include <comphelper/processfactory.hxx> -#include <i18npool/mslangid.hxx> #include <rtl/tencinfo.h> #include <rtl/locale.h> #include <osl/nlsupport.h> @@ -57,7 +55,7 @@ private: SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(NULL) { - pLocaleData = new LocaleDataWrapper( aSysLocaleOptions.GetRealLocale() ); + pLocaleData = new LocaleDataWrapper( aSysLocaleOptions.GetRealLanguageTag().getLocale() ); setDateAcceptancePatternsConfig(); // listen for further changes @@ -75,7 +73,7 @@ SvtSysLocale_Impl::~SvtSysLocale_Impl() CharClass* SvtSysLocale_Impl::GetCharClass() { if ( !pCharClass ) - pCharClass = new CharClass( aSysLocaleOptions.GetRealLocale() ); + pCharClass = new CharClass( aSysLocaleOptions.GetRealLanguageTag().getLocale() ); return pCharClass; } @@ -85,7 +83,7 @@ void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, sa if ( nHint & SYSLOCALEOPTIONS_HINT_LOCALE ) { - com::sun::star::lang::Locale aLocale( aSysLocaleOptions.GetRealLocale() ); + com::sun::star::lang::Locale aLocale( aSysLocaleOptions.GetRealLanguageTag().getLocale() ); pLocaleData->setLocale( aLocale ); GetCharClass()->setLocale( aLocale ); } @@ -185,24 +183,14 @@ SvtSysLocaleOptions& SvtSysLocale::GetOptions() const return pImpl->aSysLocaleOptions; } -com::sun::star::lang::Locale SvtSysLocale::GetLocale() const +const LanguageTag& SvtSysLocale::GetLanguageTag() const { - return pImpl->aSysLocaleOptions.GetRealLocale(); + return pImpl->aSysLocaleOptions.GetRealLanguageTag(); } -LanguageType SvtSysLocale::GetLanguage() const +const LanguageTag& SvtSysLocale::GetUILanguageTag() const { - return pImpl->aSysLocaleOptions.GetRealLanguage(); -} - -com::sun::star::lang::Locale SvtSysLocale::GetUILocale() const -{ - return pImpl->aSysLocaleOptions.GetRealUILocale(); -} - -LanguageType SvtSysLocale::GetUILanguage() const -{ - return pImpl->aSysLocaleOptions.GetRealUILanguage(); + return pImpl->aSysLocaleOptions.GetRealUILanguageTag(); } //------------------------------------------------------------------------ @@ -216,7 +204,7 @@ rtl_TextEncoding SvtSysLocale::GetBestMimeEncoding() { // If the system locale is unknown to us, e.g. LC_ALL=xx, match the UI // language if possible. - ::com::sun::star::lang::Locale aLocale( SvtSysLocale().GetUILocale() ); + ::com::sun::star::lang::Locale aLocale( SvtSysLocale().GetUILanguageTag().getLocale() ); rtl_Locale * pLocale = rtl_locale_register( aLocale.Language.getStr(), aLocale.Country.getStr(), aLocale.Variant.getStr() ); rtl_TextEncoding nEnc = osl_getTextEncodingFromLocale( pLocale ); diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 82440fde45e2..aa42cb6c8ecd 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -1540,7 +1540,7 @@ bool AllSettings::GetLayoutRTL() const const ::com::sun::star::lang::Locale& AllSettings::GetLocale() const { if ( mpData->maLocale.Language.isEmpty() ) - mpData->maLocale = mpData->maSysLocale.GetLocale(); + mpData->maLocale = mpData->maSysLocale.GetLanguageTag().getLocale(); return mpData->maLocale; } @@ -1551,7 +1551,7 @@ const ::com::sun::star::lang::Locale& AllSettings::GetUILocale() const { // the UILocale is never changed if ( mpData->maUILocale.Language.isEmpty() ) - mpData->maUILocale = mpData->maSysLocale.GetUILocale(); + mpData->maUILocale = mpData->maSysLocale.GetUILanguageTag().getLocale(); return mpData->maUILocale; } @@ -1562,7 +1562,7 @@ LanguageType AllSettings::GetLanguage() const { // meLanguage == LANGUAGE_SYSTEM means: use settings from SvtSysLocale if ( mpData->meLanguage == LANGUAGE_SYSTEM ) - return mpData->maSysLocale.GetLanguage(); + return mpData->maSysLocale.GetLanguageTag().getLanguageType(); return mpData->meLanguage; } @@ -1572,7 +1572,7 @@ LanguageType AllSettings::GetLanguage() const LanguageType AllSettings::GetUILanguage() const { // the UILanguage is never changed - return mpData->maSysLocale.GetUILanguage(); + return mpData->maSysLocale.GetUILanguageTag().getLanguageType(); } // ----------------------------------------------------------------------- @@ -1628,7 +1628,7 @@ void AllSettings::LocaleSettingsChanged( sal_uInt32 nHint ) } if ( (nHint & SYSLOCALEOPTIONS_HINT_LOCALE) ) - aAllSettings.SetLocale( aAllSettings.mpData->maSysLocale.GetOptions().GetLocale() ); + aAllSettings.SetLocale( aAllSettings.mpData->maSysLocale.GetOptions().GetLanguageTag().getLocale() ); Application::SetSettings( aAllSettings ); } |