[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - desktop/source i18nlangtag/source include/i18nlangtag unotools/source

Eike Rathke erack at redhat.com
Wed Dec 18 09:16:30 PST 2013


 desktop/source/app/langselect.cxx              |    2 +-
 i18nlangtag/source/isolang/mslangid.cxx        |    2 +-
 i18nlangtag/source/languagetag/languagetag.cxx |   19 ++++++++++++++++++-
 include/i18nlangtag/languagetag.hxx            |    3 +++
 include/i18nlangtag/mslangid.hxx               |   18 +++++++++++++++++-
 unotools/source/config/syslocaleoptions.cxx    |    4 ++--
 6 files changed, 42 insertions(+), 6 deletions(-)

New commits:
commit 72c08bbb00ac9c10b9e41a693728be9814b64a83
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Dec 18 18:08:09 2013 +0100

    resolved fdo#72778 keep setting system locale and LanguageTag in sync
    
    Change-Id: I3547786bf77b8f611bc08d0e52c66ac00e199f13
    (cherry picked from commit cc54c08a66046c00af3713fbe5e69995ccb7f73b)

diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx
index cef2851..49d001a 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 772822e..0f7cfaa 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 68ee64c..695343e 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 7e282bb..3c1a135 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 36931e5..a30bb1d2 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 67c7de5..4126b26 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 );
     }


More information about the Libreoffice-commits mailing list