summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-12-18 18:08:09 +0100
committerEike Rathke <erack@redhat.com>2013-12-18 18:15:24 +0100
commit72c08bbb00ac9c10b9e41a693728be9814b64a83 (patch)
tree6f3ef4a0b163ddd7856ab0c0442120a6c65d2011
parentd9168242f5f8800f88d4947bd1fbfc30a969429c (diff)
resolved fdo#72778 keep setting system locale and LanguageTag in sync
Change-Id: I3547786bf77b8f611bc08d0e52c66ac00e199f13 (cherry picked from commit cc54c08a66046c00af3713fbe5e69995ccb7f73b)
-rw-r--r--desktop/source/app/langselect.cxx2
-rw-r--r--i18nlangtag/source/isolang/mslangid.cxx2
-rw-r--r--i18nlangtag/source/languagetag/languagetag.cxx19
-rw-r--r--include/i18nlangtag/languagetag.hxx3
-rw-r--r--include/i18nlangtag/mslangid.hxx18
-rw-r--r--unotools/source/config/syslocaleoptions.cxx4
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 772822ea9652..0f7cfaa685a0 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 );
}