diff options
-rw-r--r-- | desktop/source/app/langselect.cxx | 2 | ||||
-rw-r--r-- | i18nlangtag/source/isolang/mslangid.cxx | 2 | ||||
-rw-r--r-- | i18nlangtag/source/languagetag/languagetag.cxx | 19 | ||||
-rw-r--r-- | include/i18nlangtag/languagetag.hxx | 3 | ||||
-rw-r--r-- | include/i18nlangtag/mslangid.hxx | 18 | ||||
-rw-r--r-- | unotools/source/config/syslocaleoptions.cxx | 4 |
6 files changed, 42 insertions, 6 deletions
diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx index cef285121767..49d001a087dc 100644 --- a/desktop/source/app/langselect.cxx +++ b/desktop/source/app/langselect.cxx @@ -197,7 +197,7 @@ bool prepareLocale() { } MsLangId::setConfiguredSystemUILanguage(tag.getLanguageType(false)); OUString setupSysLoc(officecfg::Setup::L10N::ooSetupSystemLocale::get()); - MsLangId::setConfiguredSystemLanguage( + LanguageTag::setConfiguredSystemLanguage( setupSysLoc.isEmpty() ? MsLangId::getSystemLanguage() : LanguageTag(setupSysLoc).getLanguageType(false)); diff --git a/i18nlangtag/source/isolang/mslangid.cxx b/i18nlangtag/source/isolang/mslangid.cxx index 4f864923090c..e27e13bb6c24 100644 --- a/i18nlangtag/source/isolang/mslangid.cxx +++ b/i18nlangtag/source/isolang/mslangid.cxx @@ -37,7 +37,7 @@ LanguageType MsLangId::nConfiguredAsianFallback = LANGUAGE_SYSTEM; LanguageType MsLangId::nConfiguredComplexFallback = LANGUAGE_SYSTEM; // static -void MsLangId::setConfiguredSystemLanguage( LanguageType nLang ) +void MsLangId::LanguageTagAccess::setConfiguredSystemLanguage( LanguageType nLang ) { nConfiguredSystemLanguage = nLang; } diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx index 68ee64c6208e..695343e5824c 100644 --- a/i18nlangtag/source/languagetag/languagetag.cxx +++ b/i18nlangtag/source/languagetag/languagetag.cxx @@ -364,7 +364,6 @@ private: /** Convert Locale to BCP 47 string without resolving system and creating temporary LanguageTag instances. */ static OUString convertToBcp47( const com::sun::star::lang::Locale& rLocale ); - }; @@ -713,6 +712,24 @@ LanguageTag::ImplPtr LanguageTagImpl::registerOnTheFly( LanguageType nRegisterID return pImpl; } +// static +void LanguageTag::setConfiguredSystemLanguage( LanguageType nLang ) +{ + if (nLang == LANGUAGE_DONTKNOW || nLang == LANGUAGE_SYSTEM) + { + SAL_WARN( "i18nlangtag", + "LanguageTag::setConfiguredSystemLanguage: refusing to set unresolved system locale 0x" << + ::std::hex << nLang); + return; + } + SAL_INFO( "i18nlangtag", "LanguageTag::setConfiguredSystemLanguage: setting to 0x" << ::std::hex << nLang); + MsLangId::LanguageTagAccess::setConfiguredSystemLanguage( nLang); + // Resest system locale to none and let registerImpl() do the rest to + // initialize a new one. + theSystemLocale::get().reset(); + LanguageTag aLanguageTag( LANGUAGE_SYSTEM); + aLanguageTag.registerImpl(); +} static bool lcl_isKnownOnTheFlyID( LanguageType nLang ) { diff --git a/include/i18nlangtag/languagetag.hxx b/include/i18nlangtag/languagetag.hxx index 7e282bbd56c5..3c1a135fab5a 100644 --- a/include/i18nlangtag/languagetag.hxx +++ b/include/i18nlangtag/languagetag.hxx @@ -498,6 +498,9 @@ public: /** If nLang is a generated on-the-fly LangID */ static bool isOnTheFlyID( LanguageType nLang ); + /** @ATTENTION: _ONLY_ to be called by the application's configuration! */ + static void setConfiguredSystemLanguage( LanguageType nLang ); + typedef ::boost::shared_ptr< LanguageTagImpl > ImplPtr; private: diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx index 36931e5aadf7..a30bb1d20cbc 100644 --- a/include/i18nlangtag/mslangid.hxx +++ b/include/i18nlangtag/mslangid.hxx @@ -172,7 +172,6 @@ public: /** @ATTENTION: these are _ONLY_ to be called by the application's configuration! */ - static void setConfiguredSystemLanguage( LanguageType nLang ); static void setConfiguredSystemUILanguage( LanguageType nLang ); static void setConfiguredWesternFallback( LanguageType nLang ); static void setConfiguredComplexFallback( LanguageType nLang ); @@ -180,6 +179,23 @@ public: // --------------------------------------------------------------------------- + /** Encapsulated methods that shall only be accessed through + class LanguageTag. + */ + class LanguageTagAccess + { + private: + + friend class LanguageTag; + + /** Configured system locale needs always be synchronized with + LanguageTag's system locale. + */ + I18NLANGTAG_DLLPRIVATE static void setConfiguredSystemLanguage( LanguageType nLang ); + }; + +// --------------------------------------------------------------------------- + struct LanguagetagMapping { OUString maBcp47; diff --git a/unotools/source/config/syslocaleoptions.cxx b/unotools/source/config/syslocaleoptions.cxx index 67c7de50d0fb..4126b26ca5b6 100644 --- a/unotools/source/config/syslocaleoptions.cxx +++ b/unotools/source/config/syslocaleoptions.cxx @@ -401,7 +401,7 @@ void SvtSysLocaleOptions_Impl::SetLocaleString( const OUString& rStr ) { m_aLocaleString = rStr; MakeRealLocale(); - MsLangId::setConfiguredSystemLanguage( m_aRealLocale.getLanguageType() ); + LanguageTag::setConfiguredSystemLanguage( m_aRealLocale.getLanguageType() ); SetModified(); sal_uLong nHint = SYSLOCALEOPTIONS_HINT_LOCALE; if ( m_aCurrencyString.isEmpty() ) @@ -418,7 +418,7 @@ void SvtSysLocaleOptions_Impl::SetUILocaleString( const OUString& rStr ) // as we can't switch UILocale at runtime, we only store changes in the configuration MakeRealUILocale(); - MsLangId::setConfiguredSystemLanguage( m_aRealUILocale.getLanguageType() ); + LanguageTag::setConfiguredSystemLanguage( m_aRealUILocale.getLanguageType() ); SetModified(); NotifyListeners( SYSLOCALEOPTIONS_HINT_UILOCALE ); } |