resolved fdo#72778 keep setting system locale and LanguageTag in sync

Change-Id: I3547786bf77b8f611bc08d0e52c66ac00e199f13
This commit is contained in:
Eike Rathke 2013-12-18 18:08:09 +01:00
parent fab34eb54f
commit cc54c08a66
6 changed files with 42 additions and 6 deletions

View File

@ -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));

View File

@ -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;
}

View File

@ -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 )
{

View File

@ -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:

View File

@ -172,12 +172,28 @@ 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 );
static void setConfiguredAsianFallback( LanguageType nLang );
// ---------------------------------------------------------------------------
/** 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

View File

@ -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 );
}