diff options
author | Mathias Bauer <mba@openoffice.org> | 2009-10-16 00:05:16 +0200 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2009-10-16 00:05:16 +0200 |
commit | ad482351a6c12cddb06575f6a9a00ec1b72d92fb (patch) | |
tree | e97f35e966aef21423e70f325a66943664ed62a9 /unotools/source/misc | |
parent | 9a4d0581c72653e60562d1b8e2121772d21f8a9e (diff) |
#i103496#: split svtools; improve ConfitItems
Diffstat (limited to 'unotools/source/misc')
-rw-r--r-- | unotools/source/misc/syslocale.cxx | 96 |
1 files changed, 61 insertions, 35 deletions
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx index a299867f83e8..f108cd2ed3df 100644 --- a/unotools/source/misc/syslocale.cxx +++ b/unotools/source/misc/syslocale.cxx @@ -50,53 +50,61 @@ sal_Int32 SvtSysLocale::nRefCount = 0; class SvtSysLocale_Impl : public utl::ConfigurationListener { - friend class SvtSysLocale; - +public: SvtSysLocaleOptions aSysLocaleOptions; LocaleDataWrapper* pLocaleData; CharClass* pCharClass; com::sun::star::lang::Locale maLocale; + com::sun::star::lang::Locale maUILocale; + LanguageType meLanguage; + LanguageType meUILanguage; -public: - SvtSysLocale_Impl(); - virtual ~SvtSysLocale_Impl(); + SvtSysLocale_Impl(); + virtual ~SvtSysLocale_Impl(); - CharClass* GetCharClass(); - SvtSysLocaleOptions& GetOptions() { return aSysLocaleOptions; } - void ConfigurationChanged( utl::ConfigurationBroadcaster* ); - com::sun::star::lang::Locale GetLocale(); + CharClass* GetCharClass(); + virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ); + void GetLocale(); + void GetUILocale(); }; -com::sun::star::lang::Locale SvtSysLocale_Impl::GetLocale() +void SvtSysLocale_Impl::GetLocale() { // ask configuration - rtl::OUString aLocaleString = aSysLocaleOptions.GetLocaleConfigString(); - if (!aLocaleString.getLength()) - // if no configuration is set, use system locale - return maLocale; - - com::sun::star::lang::Locale aLocale; - sal_Int32 nSep = aLocaleString.indexOf('-'); - if (nSep < 0) - aLocale.Language = aLocaleString; + maLocale = aSysLocaleOptions.GetLocale(); + if ( maLocale.Language.getLength() ) + { + meLanguage = MsLangId::convertLocaleToLanguage( maLocale ); + } else { - aLocale.Language = aLocaleString.copy(0, nSep); - if (nSep < aLocaleString.getLength()) - aLocale.Country = aLocaleString.copy(nSep+1, aLocaleString.getLength() - (nSep+1)); + meLanguage = MsLangId::getSystemLanguage(); + MsLangId::convertLanguageToLocale( meLanguage, maLocale ); } +} - return aLocale; +void SvtSysLocale_Impl::GetUILocale() +{ + maLocale = aSysLocaleOptions.GetLocale(); + if ( maUILocale.Language.getLength() ) + { + meUILanguage = MsLangId::convertLocaleToLanguage( maUILocale ); + } + else + { + meUILanguage = MsLangId::getSystemUILanguage(); + MsLangId::convertLanguageToLocale( meUILanguage, maUILocale ); + } } // ----------------------------------------------------------------------- SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(NULL) { - // first initialize maLocale with system locale - MsLangId::convertLanguageToLocale( MsLangId::getSystemLanguage(), maLocale ); + GetLocale(); + GetUILocale(); - pLocaleData = new LocaleDataWrapper( ::comphelper::getProcessServiceFactory(), GetLocale() ); + pLocaleData = new LocaleDataWrapper( ::comphelper::getProcessServiceFactory(), maLocale ); // listen for further changes aSysLocaleOptions.AddListener( this ); @@ -113,16 +121,22 @@ SvtSysLocale_Impl::~SvtSysLocale_Impl() CharClass* SvtSysLocale_Impl::GetCharClass() { if ( !pCharClass ) - pCharClass = new CharClass(::comphelper::getProcessServiceFactory(), GetLocale() ); + pCharClass = new CharClass(::comphelper::getProcessServiceFactory(), maLocale ); return pCharClass; } -void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster* ) +void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 nHint ) { MutexGuard aGuard( SvtSysLocale::GetMutex() ); - lang::Locale aLocale = GetLocale(); - pLocaleData->setLocale( aLocale ); - GetCharClass()->setLocale( aLocale ); + if ( nHint & SYSLOCALEOPTIONS_HINT_LOCALE ) + { + GetLocale(); + pLocaleData->setLocale( maLocale ); + GetCharClass()->setLocale( maLocale ); + } + + if ( nHint & SYSLOCALEOPTIONS_HINT_UILOCALE ) + GetUILocale(); } // ==================================================================== @@ -191,15 +205,27 @@ const CharClass* SvtSysLocale::GetCharClassPtr() const SvtSysLocaleOptions& SvtSysLocale::GetOptions() const { - return pImpl->GetOptions(); + return pImpl->aSysLocaleOptions; } com::sun::star::lang::Locale SvtSysLocale::GetLocale() const { - return pImpl->GetLocale(); + return pImpl->maLocale; } LanguageType SvtSysLocale::GetLanguage() const { - return MsLangId::convertLocaleToLanguage( pImpl->GetLocale() ); -}
\ No newline at end of file + return pImpl->meLanguage; +} + +com::sun::star::lang::Locale SvtSysLocale::GetUILocale() const +{ + return pImpl->maUILocale; +} + +LanguageType SvtSysLocale::GetUILanguage() const +{ + return pImpl->meUILanguage; +} + + |