From f2b3256297241da458a471d591e582c14d6ab73c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 26 Jul 2021 12:04:33 +0200 Subject: use officecfg for SvtSystemLanguageOptions Change-Id: Icf5cf974e4235d9a961e08bfc5689ec58930236e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119515 Tested-by: Noel Grandin Reviewed-by: Noel Grandin --- include/svl/languageoptions.hxx | 19 ++--------------- svl/source/config/cjkoptions.cxx | 11 ++++++---- svl/source/config/languageoptions.cxx | 40 ++++++----------------------------- 3 files changed, 15 insertions(+), 55 deletions(-) diff --git a/include/svl/languageoptions.hxx b/include/svl/languageoptions.hxx index 5fc9c8624dc4..9ae8475dd9eb 100644 --- a/include/svl/languageoptions.hxx +++ b/include/svl/languageoptions.hxx @@ -112,24 +112,9 @@ public: /** #i42730# Gives access to the Windows 16bit system locale */ -class SvtSystemLanguageOptions final : public utl::ConfigItem +namespace SvtSystemLanguageOptions { -private: - OUString m_sWin16SystemLocale; - - bool isKeyboardLayoutTypeInstalled(sal_Int16 scriptType) const; - - virtual void ImplCommit() override; - -public: - SvtSystemLanguageOptions(); - virtual ~SvtSystemLanguageOptions() override; - - virtual void Notify( const css::uno::Sequence< OUString >& rPropertyNames ) override; - - LanguageType GetWin16SystemLanguage() const; - - bool isCJKKeyboardLayoutInstalled() const; + bool isCJKKeyboardLayoutInstalled(); }; #endif // INCLUDED_SVL_LANGUAGEOPTIONS_HXX diff --git a/svl/source/config/cjkoptions.cxx b/svl/source/config/cjkoptions.cxx index 71054f564de4..84c972875f3a 100644 --- a/svl/source/config/cjkoptions.cxx +++ b/svl/source/config/cjkoptions.cxx @@ -22,11 +22,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include "itemholder2.hxx" @@ -199,10 +201,11 @@ void SvtCJKOptions_Impl::Load() if (!bAutoEnableCJK) { - SvtSystemLanguageOptions aSystemLocaleSettings; - //windows secondary system locale is CJK - LanguageType eSystemLanguage = aSystemLocaleSettings.GetWin16SystemLanguage(); + OUString sWin16SystemLocale = officecfg::System::L10N::SystemLocale::get(); + LanguageType eSystemLanguage = LANGUAGE_NONE; + if( !sWin16SystemLocale.isEmpty() ) + eSystemLanguage = LanguageTag::convertToLanguageTypeWithFallback( sWin16SystemLocale ); if (eSystemLanguage != LANGUAGE_SYSTEM) { SvtScriptType nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage ); @@ -211,7 +214,7 @@ void SvtCJKOptions_Impl::Load() //CJK keyboard is installed if (!bAutoEnableCJK) - bAutoEnableCJK = aSystemLocaleSettings.isCJKKeyboardLayoutInstalled(); + bAutoEnableCJK = SvtSystemLanguageOptions::isCJKKeyboardLayoutInstalled(); } if (bAutoEnableCJK) diff --git a/svl/source/config/languageoptions.cxx b/svl/source/config/languageoptions.cxx index 4f3f7671eda7..faaa93e2ddba 100644 --- a/svl/source/config/languageoptions.cxx +++ b/svl/source/config/languageoptions.cxx @@ -193,40 +193,9 @@ sal_Int16 SvtLanguageOptions::GetI18NScriptTypeOfLanguage( LanguageType nLang ) return FromSvtScriptTypeToI18N( GetScriptTypeOfLanguage( nLang ) ); } -SvtSystemLanguageOptions::SvtSystemLanguageOptions() : - utl::ConfigItem( "System/L10N") -{ - uno::Sequence< OUString > aPropertyNames { "SystemLocale" }; - uno::Sequence< uno::Any > aValues = GetProperties( aPropertyNames ); - - if ( aValues.hasElements() ) - { - aValues[0]>>= m_sWin16SystemLocale; - } -} - -SvtSystemLanguageOptions::~SvtSystemLanguageOptions() -{ -} - -void SvtSystemLanguageOptions::ImplCommit() -{ - //does nothing -} -void SvtSystemLanguageOptions::Notify( const css::uno::Sequence< OUString >& ) -{ - // no listeners supported yet -} -LanguageType SvtSystemLanguageOptions::GetWin16SystemLanguage() const -{ - if( m_sWin16SystemLocale.isEmpty() ) - return LANGUAGE_NONE; - return LanguageTag::convertToLanguageTypeWithFallback( m_sWin16SystemLocale ); -} - -bool SvtSystemLanguageOptions::isKeyboardLayoutTypeInstalled(sal_Int16 scriptType) const +static bool isKeyboardLayoutTypeInstalled(sal_Int16 scriptType) { bool isInstalled = false; #ifdef _WIN32 @@ -257,9 +226,12 @@ bool SvtSystemLanguageOptions::isKeyboardLayoutTypeInstalled(sal_Int16 scriptTyp return isInstalled; } -bool SvtSystemLanguageOptions::isCJKKeyboardLayoutInstalled() const +namespace SvtSystemLanguageOptions { - return isKeyboardLayoutTypeInstalled(css::i18n::ScriptType::ASIAN); + bool isCJKKeyboardLayoutInstalled() + { + return isKeyboardLayoutTypeInstalled(css::i18n::ScriptType::ASIAN); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit