diff options
-rw-r--r-- | i18npool/source/isolang/inwnt.cxx | 4 | ||||
-rw-r--r-- | unotools/inc/unotools/syslocaleoptions.hxx | 4 | ||||
-rw-r--r-- | unotools/source/config/syslocaleoptions.cxx | 115 | ||||
-rw-r--r-- | unotools/source/misc/syslocale.cxx | 59 | ||||
-rw-r--r-- | vcl/source/app/settings.cxx | 113 | ||||
-rw-r--r-- | vcl/source/app/svapp.cxx | 3 |
6 files changed, 139 insertions, 159 deletions
diff --git a/i18npool/source/isolang/inwnt.cxx b/i18npool/source/isolang/inwnt.cxx index 7d5e4d3216e7..2550eb3acd10 100644 --- a/i18npool/source/isolang/inwnt.cxx +++ b/i18npool/source/isolang/inwnt.cxx @@ -104,11 +104,7 @@ LanguageType MsLangId::getPlatformSystemUILanguage() { // TODO: this could be distinguished, #if(WINVER >= 0x0500) // needs _run_ time differentiation though, not at compile time. -#if 0 getPlatformSystemLanguageImpl( nImplSystemUILanguage, &GetUserDefaultUILanguage, &GetSystemDefaultUILanguage); -#endif - getPlatformSystemLanguageImpl( nImplSystemUILanguage, - &GetUserDefaultLangID, &GetSystemDefaultLangID); return nImplSystemUILanguage; } diff --git a/unotools/inc/unotools/syslocaleoptions.hxx b/unotools/inc/unotools/syslocaleoptions.hxx index 2da102c161cc..6bb81fdd3ee0 100644 --- a/unotools/inc/unotools/syslocaleoptions.hxx +++ b/unotools/inc/unotools/syslocaleoptions.hxx @@ -107,11 +107,15 @@ public: 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; /// The config string may be empty to denote the SYSTEM locale const ::rtl::OUString& GetUILocaleConfigString() const; void SetUILocaleConfigString( const ::rtl::OUString& rStr ); com::sun::star::lang::Locale GetUILocale() const; + com::sun::star::lang::Locale GetRealUILocale() const; + LanguageType GetRealUILanguage() 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/syslocaleoptions.cxx b/unotools/source/config/syslocaleoptions.cxx index 6c4071709e02..f358fe24df4f 100644 --- a/unotools/source/config/syslocaleoptions.cxx +++ b/unotools/source/config/syslocaleoptions.cxx @@ -62,8 +62,32 @@ namespace : public rtl::Static<Link, CurrencyChangeLink> {}; } +com::sun::star::lang::Locale lcl_str_to_locale( const ::rtl::OUString rStr ) +{ + com::sun::star::lang::Locale aRet; + if ( rStr.getLength() ) + { + 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 { + Locale m_aRealLocale; + Locale m_aRealUILocale; + LanguageType m_eRealLanguage; + LanguageType m_eRealUILanguage; OUString m_aLocaleString; // en-US or de-DE or empty for SYSTEM OUString m_aUILocaleString; // en-US or de-DE or empty for SYSTEM OUString m_aCurrencyString; // USD-en-US or EUR-de-DE @@ -75,7 +99,9 @@ class SvtSysLocaleOptions_Impl : public utl::ConfigItem sal_Bool m_bROCurrency; sal_Bool m_bRODecimalSeparator; - static const Sequence< /* const */ OUString > GetPropertyNames(); + static const Sequence< /* const */ OUString > GetPropertyNames(); + void MakeRealLocale(); + void MakeRealUILocale(); public: SvtSysLocaleOptions_Impl(); @@ -100,6 +126,10 @@ public: void SetDecimalSeparatorAsLocale( sal_Bool bSet); sal_Bool IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const; + const Locale& GetRealLocale() { return m_aRealLocale; } + const Locale& GetRealUILocale() { return m_aRealUILocale; } + LanguageType GetRealLanguage() { return m_eRealLanguage; } + LanguageType GetRealUILanguage() { return m_eRealUILanguage; } }; @@ -217,6 +247,9 @@ SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl() // UpdateMiscSettings_Impl(); EnableNotification( aNames ); } + + MakeRealLocale(); + MakeRealUILocale(); } @@ -226,6 +259,37 @@ SvtSysLocaleOptions_Impl::~SvtSysLocaleOptions_Impl() Commit(); } +void SvtSysLocaleOptions_Impl::MakeRealLocale() +{ + m_aRealLocale = lcl_str_to_locale( m_aLocaleString ); + if ( m_aRealLocale.Language.getLength() ) + { + m_eRealLanguage = MsLangId::convertLocaleToLanguage( m_aRealLocale ); + } + else + { + m_eRealLanguage = MsLangId::getSystemLanguage(); + MsLangId::convertLanguageToLocale( m_eRealLanguage, m_aRealLocale ); + } +} + +void SvtSysLocaleOptions_Impl::MakeRealUILocale() +{ + if ( !m_aRealUILocale.Language.getLength() ) + { + // as we can't switch UILocale at runtime, we only store changes in the configuration + m_aRealUILocale = lcl_str_to_locale( m_aUILocaleString ); + if ( m_aRealUILocale.Language.getLength() ) + { + m_eRealUILanguage = MsLangId::convertLocaleToLanguage( m_aRealUILocale ); + } + else + { + m_eRealUILanguage = MsLangId::getSystemUILanguage(); + MsLangId::convertLanguageToLocale( m_eRealUILanguage, m_aRealUILocale ); + } + } +} sal_Bool SvtSysLocaleOptions_Impl::IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const { @@ -322,6 +386,8 @@ void SvtSysLocaleOptions_Impl::SetLocaleString( const OUString& rStr ) if (!m_bROLocale && rStr != m_aLocaleString ) { m_aLocaleString = rStr; + MakeRealLocale(); + MsLangId::setConfiguredSystemLanguage( m_eRealLanguage ); SetModified(); ULONG nHint = SYSLOCALEOPTIONS_HINT_LOCALE; if ( !m_aCurrencyString.getLength() ) @@ -335,8 +401,13 @@ void SvtSysLocaleOptions_Impl::SetUILocaleString( const OUString& rStr ) if (!m_bROUILocale && rStr != m_aUILocaleString ) { m_aUILocaleString = rStr; +/* + // as we can't switch UILocale at runtime, we only store changes in the configuration + MakeRealUILocale(); + MsLangId::setConfiguredSystemLanguage( m_eRealUILanguage ); SetModified(); NotifyListeners( SYSLOCALEOPTIONS_HINT_UILOCALE ); +*/ } } @@ -376,6 +447,7 @@ void SvtSysLocaleOptions_Impl::Notify( const Sequence< rtl::OUString >& seqPrope nHint |= SYSLOCALEOPTIONS_HINT_LOCALE; if ( !m_aCurrencyString.getLength() ) nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY; + MakeRealLocale(); } if( seqPropertyNames[nProp] == PROPERTYNAME_UILOCALE ) { @@ -383,6 +455,7 @@ void SvtSysLocaleOptions_Impl::Notify( const Sequence< rtl::OUString >& seqPrope seqValues[nProp] >>= m_aUILocaleString; m_bROUILocale = seqROStates[nProp]; nHint |= SYSLOCALEOPTIONS_HINT_UILOCALE; + MakeRealUILocale(); } else if( seqPropertyNames[nProp] == PROPERTYNAME_CURRENCY ) { @@ -599,26 +672,6 @@ void SvtSysLocaleOptions::ConfigurationChanged( utl::ConfigurationBroadcaster* p ::utl::detail::Options::ConfigurationChanged( p, nHint ); } -com::sun::star::lang::Locale lcl_str_to_locale( const ::rtl::OUString rStr ) -{ - com::sun::star::lang::Locale aRet; - if ( rStr.getLength() ) - { - 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; -} - com::sun::star::lang::Locale SvtSysLocaleOptions::GetLocale() const { return lcl_str_to_locale( GetLocaleConfigString() ); @@ -628,3 +681,23 @@ com::sun::star::lang::Locale SvtSysLocaleOptions::GetUILocale() const { return lcl_str_to_locale( GetUILocaleConfigString() ); } + +com::sun::star::lang::Locale SvtSysLocaleOptions::GetRealLocale() const +{ + return pOptions->GetRealLocale(); +} + +com::sun::star::lang::Locale SvtSysLocaleOptions::GetRealUILocale() const +{ + return pOptions->GetRealUILocale(); +} + +LanguageType SvtSysLocaleOptions::GetRealLanguage() const +{ + return pOptions->GetRealLanguage(); +} + +LanguageType SvtSysLocaleOptions::GetRealUILanguage() const +{ + return pOptions->GetRealUILanguage(); +}
\ No newline at end of file diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx index f108cd2ed3df..8e9d75c6ce0c 100644 --- a/unotools/source/misc/syslocale.cxx +++ b/unotools/source/misc/syslocale.cxx @@ -54,57 +54,19 @@ public: SvtSysLocaleOptions aSysLocaleOptions; LocaleDataWrapper* pLocaleData; CharClass* pCharClass; - com::sun::star::lang::Locale maLocale; - com::sun::star::lang::Locale maUILocale; - LanguageType meLanguage; - LanguageType meUILanguage; SvtSysLocale_Impl(); virtual ~SvtSysLocale_Impl(); CharClass* GetCharClass(); virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ); - void GetLocale(); - void GetUILocale(); }; -void SvtSysLocale_Impl::GetLocale() -{ - // ask configuration - maLocale = aSysLocaleOptions.GetLocale(); - if ( maLocale.Language.getLength() ) - { - meLanguage = MsLangId::convertLocaleToLanguage( maLocale ); - } - else - { - meLanguage = MsLangId::getSystemLanguage(); - MsLangId::convertLanguageToLocale( meLanguage, maLocale ); - } -} - -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) { - GetLocale(); - GetUILocale(); - - pLocaleData = new LocaleDataWrapper( ::comphelper::getProcessServiceFactory(), maLocale ); + pLocaleData = new LocaleDataWrapper( ::comphelper::getProcessServiceFactory(), aSysLocaleOptions.GetRealLocale() ); // listen for further changes aSysLocaleOptions.AddListener( this ); @@ -121,7 +83,7 @@ SvtSysLocale_Impl::~SvtSysLocale_Impl() CharClass* SvtSysLocale_Impl::GetCharClass() { if ( !pCharClass ) - pCharClass = new CharClass(::comphelper::getProcessServiceFactory(), maLocale ); + pCharClass = new CharClass(::comphelper::getProcessServiceFactory(), aSysLocaleOptions.GetRealLocale() ); return pCharClass; } @@ -130,13 +92,10 @@ void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, sa MutexGuard aGuard( SvtSysLocale::GetMutex() ); if ( nHint & SYSLOCALEOPTIONS_HINT_LOCALE ) { - GetLocale(); - pLocaleData->setLocale( maLocale ); - GetCharClass()->setLocale( maLocale ); + com::sun::star::lang::Locale aLocale( aSysLocaleOptions.GetRealLocale() ); + pLocaleData->setLocale( aLocale ); + GetCharClass()->setLocale( aLocale ); } - - if ( nHint & SYSLOCALEOPTIONS_HINT_UILOCALE ) - GetUILocale(); } // ==================================================================== @@ -210,22 +169,22 @@ SvtSysLocaleOptions& SvtSysLocale::GetOptions() const com::sun::star::lang::Locale SvtSysLocale::GetLocale() const { - return pImpl->maLocale; + return pImpl->aSysLocaleOptions.GetRealLocale(); } LanguageType SvtSysLocale::GetLanguage() const { - return pImpl->meLanguage; + return pImpl->aSysLocaleOptions.GetRealLanguage(); } com::sun::star::lang::Locale SvtSysLocale::GetUILocale() const { - return pImpl->maUILocale; + return pImpl->aSysLocaleOptions.GetRealUILocale(); } LanguageType SvtSysLocale::GetUILanguage() const { - return pImpl->meUILanguage; + return pImpl->aSysLocaleOptions.GetRealUILanguage(); } diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 9ecbef93656c..09262dff7eec 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -1525,7 +1525,7 @@ ImplAllSettingsData::ImplAllSettingsData() mnSystemUpdate = SETTINGS_ALLSETTINGS; mnWindowUpdate = SETTINGS_ALLSETTINGS; meLanguage = LANGUAGE_SYSTEM; - meUILanguage = LANGUAGE_SYSTEM; + meUILanguage = LANGUAGE_SYSTEM; mpLocaleDataWrapper = NULL; mpUILocaleDataWrapper = NULL; mpCollatorWrapper = NULL; @@ -1544,15 +1544,12 @@ ImplAllSettingsData::ImplAllSettingsData( const ImplAllSettingsData& rData ) : maMiscSettings( rData.maMiscSettings ), maNotificationSettings( rData.maNotificationSettings ), maHelpSettings( rData.maHelpSettings ), - maLocale( rData.maLocale ), - maUILocale( rData.maUILocale ) - + maLocale( rData.maLocale ) { mnRefCount = 1; mnSystemUpdate = rData.mnSystemUpdate; mnWindowUpdate = rData.mnWindowUpdate; meLanguage = rData.meLanguage; - meUILanguage = rData.meUILanguage; // Pointer couldn't shared and objects haven't a copy ctor // So we create the cache objects new, if the GetFunction is // called @@ -1748,11 +1745,7 @@ ULONG AllSettings::Update( ULONG nFlags, const AllSettings& rSet ) if ( nFlags & SETTINGS_UILOCALE ) { - if ( mpData->meUILanguage || rSet.mpData->meUILanguage ) - { - SetUILanguage( rSet.mpData->meUILanguage ); - nChangeFlags |= SETTINGS_UILOCALE; - } + DBG_ERROR("UILocale can't be changed!"); } return nChangeFlags; @@ -1791,9 +1784,6 @@ ULONG AllSettings::GetChangeFlags( const AllSettings& rSet ) const if ( mpData->meLanguage || rSet.mpData->meLanguage ) nChangeFlags |= SETTINGS_LOCALE; - if ( mpData->meUILanguage || rSet.mpData->meUILanguage ) - nChangeFlags |= SETTINGS_UILOCALE; - return nChangeFlags; } @@ -1815,18 +1805,13 @@ BOOL AllSettings::operator ==( const AllSettings& rSet ) const (mpData->maNotificationSettings == rSet.mpData->maNotificationSettings) && (mpData->maHelpSettings == rSet.mpData->maHelpSettings) && (mpData->mnSystemUpdate == rSet.mpData->mnSystemUpdate) && + (mpData->maLocale == rSet.mpData->maLocale) && (mpData->mnWindowUpdate == rSet.mpData->mnWindowUpdate) ) { - // special treatment for Locale, because maLocale is only - // initialized after first call of GetLocale(). - ::com::sun::star::lang::Locale aEmptyLocale; - if ( ( ImplCompareLocales( mpData->maLocale, aEmptyLocale ) && ImplCompareLocales( rSet.mpData->maLocale, aEmptyLocale ) ) - || ImplCompareLocales( GetLocale(), rSet.GetLocale() ) ) - { - return TRUE; - } + return TRUE; } - return FALSE; + else + return FALSE; } // ----------------------------------------------------------------------- @@ -1855,70 +1840,39 @@ void AllSettings::SetLocale( const ::com::sun::star::lang::Locale& rLocale ) // ----------------------------------------------------------------------- -void AllSettings::SetUILocale( const ::com::sun::star::lang::Locale& rLocale ) +void AllSettings::SetUILocale( const ::com::sun::star::lang::Locale& ) { - CopyData(); - - mpData->maUILocale = rLocale; - - if ( !rLocale.Language.getLength() ) - mpData->meUILanguage = LANGUAGE_SYSTEM; - else - mpData->meUILanguage = MsLangId::convertLocaleToLanguage( rLocale ); - if ( mpData->mpUILocaleDataWrapper ) - { - delete mpData->mpUILocaleDataWrapper; - mpData->mpUILocaleDataWrapper = NULL; - } - if ( mpData->mpUII18nHelper ) - { - delete mpData->mpUII18nHelper; - mpData->mpUII18nHelper = NULL; - } + // there is only one UILocale per process } // ----------------------------------------------------------------------- void AllSettings::SetLanguage( LanguageType eLang ) { - CopyData(); - - mpData->meLanguage = eLang; - - // Will be calculated in GetLocale() - mpData->maLocale = ::com::sun::star::lang::Locale(); - if ( mpData->mpLocaleDataWrapper ) + if ( eLang != mpData->meLanguage ) { - delete mpData->mpLocaleDataWrapper; - mpData->mpLocaleDataWrapper = NULL; - } - if ( mpData->mpI18nHelper ) - { - delete mpData->mpI18nHelper; - mpData->mpI18nHelper = NULL; + CopyData(); + + mpData->meLanguage = eLang; + MsLangId::convertLanguageToLocale( GetLanguage(), ((AllSettings*)this)->mpData->maLocale ); + if ( mpData->mpLocaleDataWrapper ) + { + delete mpData->mpLocaleDataWrapper; + mpData->mpLocaleDataWrapper = NULL; + } + if ( mpData->mpI18nHelper ) + { + delete mpData->mpI18nHelper; + mpData->mpI18nHelper = NULL; + } } } // ----------------------------------------------------------------------- -void AllSettings::SetUILanguage( LanguageType eLang ) +void AllSettings::SetUILanguage( LanguageType ) { - CopyData(); - - mpData->meUILanguage = eLang; - - // Will be calculated in GetUILocale() - mpData->maUILocale = ::com::sun::star::lang::Locale(); - if ( mpData->mpUILocaleDataWrapper ) - { - delete mpData->mpUILocaleDataWrapper; - mpData->mpUILocaleDataWrapper = NULL; - } - if ( mpData->mpUII18nHelper ) - { - delete mpData->mpUII18nHelper; - mpData->mpUII18nHelper = NULL; - } + // there is only one UILanguage per process } // ----------------------------------------------------------------------- @@ -1980,6 +1934,7 @@ const ::com::sun::star::lang::Locale& AllSettings::GetLocale() const const ::com::sun::star::lang::Locale& AllSettings::GetUILocale() const { + // the UILocale is never changed if ( !mpData->maUILocale.Language.getLength() ) mpData->maUILocale = mpData->maSysLocale.GetUILocale(); @@ -1990,8 +1945,9 @@ const ::com::sun::star::lang::Locale& AllSettings::GetUILocale() const LanguageType AllSettings::GetLanguage() const { + // meLanguage == LANGUAGE_SYSTEM means: use settings from SvtSysLocale if ( mpData->meLanguage == LANGUAGE_SYSTEM ) - mpData->meLanguage = mpData->maSysLocale.GetLanguage(); + return mpData->maSysLocale.GetLanguage(); return mpData->meLanguage; } @@ -2000,10 +1956,8 @@ LanguageType AllSettings::GetLanguage() const LanguageType AllSettings::GetUILanguage() const { - if ( mpData->meUILanguage == LANGUAGE_SYSTEM ) - mpData->meUILanguage = mpData->maSysLocale.GetUILanguage(); - - return mpData->meUILanguage; + // the UILanguage is never changed + return mpData->maSysLocale.GetUILanguage(); } // ----------------------------------------------------------------------- @@ -2086,11 +2040,8 @@ void AllSettings::LocaleSettingsChanged( sal_uInt32 nHint ) } } - if ( nHint & SYSLOCALEOPTIONS_HINT_LOCALE ) + if ( (nHint & SYSLOCALEOPTIONS_HINT_LOCALE) ) aAllSettings.SetLocale( aAllSettings.mpData->maSysLocale.GetOptions().GetLocale() ); - if ( nHint & SYSLOCALEOPTIONS_HINT_UILOCALE ) - aAllSettings.SetLocale( aAllSettings.mpData->maSysLocale.GetOptions().GetUILocale() ); - Application::SetSettings( aAllSettings ); } diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 19b8ea1ff14d..40f6d17f36ae 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -46,7 +46,6 @@ #include <tools/tools.h> #include <tools/debug.hxx> #include <tools/time.hxx> -#include <i18npool/mslangid.hxx> #include <vcl/svdata.hxx> #include <vcl/settings.hxx> #ifndef _ACCMGR_HXX @@ -705,8 +704,6 @@ bool Application::ValidateSystemFont() void Application::SetSettings( const AllSettings& rSettings ) { - MsLangId::setConfiguredSystemLanguage( rSettings.GetLanguage()); - MsLangId::setConfiguredSystemUILanguage( rSettings.GetUILanguage()); ImplSVData* pSVData = ImplGetSVData(); if ( !pSVData->maAppData.mpSettings ) { |