From 23221e48495262d0384c9169a0d8a01db8a5dab5 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Thu, 16 Jan 2014 21:42:47 +0100 Subject: fdo#71511: in autodetected a11y HC mode, pull background color from theme - ... and reload ColorConfig after tweaking relevant a11y settings - dark theme default to high contrast - as per fdo#35365, having a dark document background is inconvenient for non-a11y endusers - a11y standard require the (rather ugly) background for a11y - thus, when "automatically detect high contract mode of operating system" in Tools->Options->a11y is enabled, use the dark document backgroundby default, otherwise use a white default note that the autodetect HC option is somewhat broken anyway: it resets the icon theme hard, so there are not simple roundtrips enableing/disabling it for that, but those havent been there before either. (includes: Ia35a41717224dfb7437054bb885c61d7e0b189d7) Change-Id: Id8ad1eb3d57b3708ac5a241092208e3a8d98ade0 Reviewed-on: https://gerrit.libreoffice.org/7484 Reviewed-by: Michael Meeks Tested-by: Michael Meeks --- include/svtools/colorcfg.hxx | 1 + svtools/source/config/accessibilityoptions.cxx | 4 ++- svtools/source/config/colorcfg.cxx | 36 +++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/include/svtools/colorcfg.hxx b/include/svtools/colorcfg.hxx index 2872f4c03977..ddc84850bf71 100644 --- a/include/svtools/colorcfg.hxx +++ b/include/svtools/colorcfg.hxx @@ -105,6 +105,7 @@ public: // instead of the automatic color ColorConfigValue GetColorValue(ColorConfigEntry eEntry, sal_Bool bSmart = sal_True)const; static Color GetDefaultColor(ColorConfigEntry eEntry); + void Reload(); }; class SVT_DLLPUBLIC EditableColorConfig diff --git a/svtools/source/config/accessibilityoptions.cxx b/svtools/source/config/accessibilityoptions.cxx index 4294e7cc091a..84f0e1c30b7e 100644 --- a/svtools/source/config/accessibilityoptions.cxx +++ b/svtools/source/config/accessibilityoptions.cxx @@ -31,6 +31,8 @@ #include +#include + #include #include #include @@ -386,7 +388,7 @@ void SvtAccessibilityOptions_Impl::SetAutoDetectSystemHC(sal_Bool bSet) { xNode->setPropertyValue(s_sAutoDetectSystemHC, css::uno::makeAny(bSet)); ::comphelper::ConfigurationHelper::flush(m_xCfg); - + svtools::ColorConfig().Reload(); bIsModified = sal_True; } } diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index 850bd93868a4..a8e5ba89929a 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -23,7 +23,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -64,6 +66,7 @@ class ColorConfig_Impl : public utl::ConfigItem sal_Bool m_bEditMode; OUString m_sIsVisible; OUString m_sLoadedScheme; + bool m_bAutoDetectSystemHC; uno::Sequence< OUString> GetPropertyNames(const OUString& rScheme); public: @@ -91,6 +94,7 @@ public: void SetModified(){ConfigItem::SetModified();} void ClearModified(){ConfigItem::ClearModified();} void SettingsChanged(); + bool GetAutoDetectSystemHC() {return m_bAutoDetectSystemHC;} // #100822# DECL_LINK( DataChangedEventListener, VclWindowEvent* ); @@ -183,7 +187,8 @@ uno::Sequence< OUString> ColorConfig_Impl::GetPropertyNames(const OUString& rSch ColorConfig_Impl::ColorConfig_Impl(sal_Bool bEditMode) : ConfigItem("Office.UI/ColorScheme"), m_bEditMode(bEditMode), - m_sIsVisible("/IsVisible") + m_sIsVisible("/IsVisible"), + m_bAutoDetectSystemHC(true) { if(!m_bEditMode) { @@ -237,6 +242,15 @@ void ColorConfig_Impl::Load(const OUString& rScheme) if(pColorNames[nIndex].match(m_sIsVisible, pColorNames[nIndex].getLength() - m_sIsVisible.getLength())) m_aConfigValues[i / 2].bIsVisible = Any2Bool(pColors[nIndex++]); } + // fdo#71511: check if we are running in a11y autodetect + { + utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithComponentContext(comphelper::getProcessComponentContext(),OUString("org.openoffice.Office.Common/Accessibility") ); + if(aNode.isValid()) + { + uno::Any aValue = aNode.getNodeValue(OUString("AutoDetectSystemHC")); + aValue >>= m_bAutoDetectSystemHC; + } + } } void ColorConfig_Impl::Notify( const uno::Sequence& ) @@ -466,6 +480,21 @@ Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry) default: aRet = aAutoColors[eEntry]; } + // fdo#71511: if in autodetected a11y HC mode, do pull background color from theme + if(m_pImpl && m_pImpl->GetAutoDetectSystemHC()) + { + switch(eEntry) + { + case DOCCOLOR : + aRet = Application::GetSettings().GetStyleSettings().GetWindowColor(); + break; + case FONTCOLOR : + aRet = Application::GetSettings().GetStyleSettings().GetWindowTextColor(); + break; + default: + break; + } + } return aRet; } @@ -481,6 +510,11 @@ ColorConfigValue ColorConfig::GetColorValue(ColorConfigEntry eEntry, sal_Bool bS return aRet; } +void ColorConfig::Reload() +{ + m_pImpl->Load(OUString()); +} + EditableColorConfig::EditableColorConfig() : m_pImpl(new ColorConfig_Impl), m_bModified(sal_False) -- cgit v1.2.3