cui/source/options/optaccessibility.cxx                    |    7 +
 cui/source/options/optaccessibility.hxx                    |    1 
 cui/uiconfig/ui/optaccessibilitypage.ui                    |   54 ++++++++++++-
 officecfg/registry/schema/org/openoffice/Office/Common.xcs |   25 ++++++
 vcl/source/window/settings.cxx                             |   19 +++-
 5 files changed, 98 insertions(+), 8 deletions(-)

New commits:
commit 5bf38da0910f590159e8fa4fe359f98c7bd395a4
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sat Oct 15 20:10:04 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sat Oct 15 22:38:13 2022 +0200

    tdf#151522 add Accessibility::HighContrast
    
    0 Automatic, do what the system says
    1 Disable
    2 Enable
    
    Forcing Disable/Enable won't have (much of) an effect on the widgetry, but 
will
    affect how document content is rendered where typically content color
    is mapped to fore/back ground color.
    
    Change-Id: I71a2dcf8bc334080414a01691f942a5b7de7b84a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139753
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/cui/source/options/optaccessibility.cxx 
b/cui/source/options/optaccessibility.cxx
index 1f85254dae22..d0a3694a3c73 100644
--- a/cui/source/options/optaccessibility.cxx
+++ b/cui/source/options/optaccessibility.cxx
@@ -29,6 +29,7 @@ 
SvxAccessibilityOptionsTabPage::SvxAccessibilityOptionsTabPage(weld::Container*
     , 
m_xTextSelectionInReadonly(m_xBuilder->weld_check_button("textselinreadonly"))
     , m_xAnimatedGraphics(m_xBuilder->weld_check_button("animatedgraphics"))
     , m_xAnimatedTexts(m_xBuilder->weld_check_button("animatedtext"))
+    , m_xHighContrast(m_xBuilder->weld_combo_box("highcontrast"))
     , m_xAutomaticFontColor(m_xBuilder->weld_check_button("autofontcolor"))
     , m_xPagePreviews(m_xBuilder->weld_check_button("systempagepreviewcolor"))
 {
@@ -60,6 +61,8 @@ bool SvxAccessibilityOptionsTabPage::FillItemSet( SfxItemSet* 
)
         
officecfg::Office::Common::Accessibility::IsAutomaticFontColor::set(m_xAutomaticFontColor->get_active(),
 batch);
     if ( 
!officecfg::Office::Common::Accessibility::IsSelectionInReadonly::isReadOnly() )
         
officecfg::Office::Common::Accessibility::IsSelectionInReadonly::set(m_xTextSelectionInReadonly->get_active(),
 batch);
+    if ( !officecfg::Office::Common::Accessibility::HighContrast::isReadOnly() 
)
+        
officecfg::Office::Common::Accessibility::HighContrast::set(m_xHighContrast->get_active(),
 batch);
     batch->commit();
 
     AllSettings aAllSettings = Application::GetSettings();
@@ -96,6 +99,10 @@ void SvxAccessibilityOptionsTabPage::Reset( const 
SfxItemSet* )
     if( 
officecfg::Office::Common::Accessibility::IsSelectionInReadonly::isReadOnly() )
         m_xTextSelectionInReadonly->set_sensitive(false);
 
+    m_xHighContrast->set_active( 
officecfg::Office::Common::Accessibility::HighContrast::get() );
+    if( officecfg::Office::Common::Accessibility::HighContrast::isReadOnly() )
+        m_xHighContrast->set_sensitive(false);
+
     AllSettings aAllSettings = Application::GetSettings();
     const MiscSettings& aMiscSettings = aAllSettings.GetMiscSettings();
     m_xAccessibilityTool->set_active(aMiscSettings.GetEnableATToolSupport());
diff --git a/cui/source/options/optaccessibility.hxx 
b/cui/source/options/optaccessibility.hxx
index c53c17be1158..504e18327c7f 100644
--- a/cui/source/options/optaccessibility.hxx
+++ b/cui/source/options/optaccessibility.hxx
@@ -26,6 +26,7 @@ class SvxAccessibilityOptionsTabPage : public SfxTabPage
     std::unique_ptr<weld::CheckButton> m_xTextSelectionInReadonly;
     std::unique_ptr<weld::CheckButton> m_xAnimatedGraphics;
     std::unique_ptr<weld::CheckButton> m_xAnimatedTexts;
+    std::unique_ptr<weld::ComboBox> m_xHighContrast;
     std::unique_ptr<weld::CheckButton> m_xAutomaticFontColor;
     std::unique_ptr<weld::CheckButton> m_xPagePreviews;
 
diff --git a/cui/uiconfig/ui/optaccessibilitypage.ui 
b/cui/uiconfig/ui/optaccessibilitypage.ui
index 2643000fd246..07d89dcac65e 100644
--- a/cui/uiconfig/ui/optaccessibilitypage.ui
+++ b/cui/uiconfig/ui/optaccessibilitypage.ui
@@ -135,6 +135,56 @@
             <property name="margin-top">6</property>
             <property name="orientation">vertical</property>
             <property name="spacing">6</property>
+            <child>
+              <!-- n-columns=2 n-rows=1 -->
+              <object class="GtkGrid" id="highcontrastbox">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="column-spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="label13">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="label" translatable="yes" 
context="optaccessibilitypage|label13">High Contrast:</property>
+                    <property name="use-underline">True</property>
+                    <property name="mnemonic-widget">highcontrast</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="top-attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBoxText" id="highcontrast">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="active">0</property>
+                    <items>
+                      <item translatable="yes" 
context="optaccessibilitypage|highcontrast">Automatic</item>
+                      <item translatable="yes" 
context="optaccessibilitypage|highcontrast">Disable</item>
+                      <item translatable="yes" 
context="optaccessibilitypage|highcontrast">Enable</item>
+                    </items>
+                    <child internal-child="accessible">
+                      <object class="AtkObject" id="highcontrast-atkobject">
+                        <property name="AtkObject::accessible-description" 
translatable="yes" context="extended_tip|highcontrast">Controls if high 
contrast mode is used. Select from "Automatic", "Disable" and "Enable". 
"Automatic" uses high contrast according to system settings.</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left-attach">1</property>
+                    <property name="top-attach">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
             <child>
               <object class="GtkCheckButton" id="autofontcolor">
                 <property name="label" translatable="yes" 
context="optaccessibilitypage|autofontcolor">Use automatic font _color for 
screen display</property>
@@ -152,7 +202,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">0</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
@@ -172,7 +222,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 89adf15bd234..91d4c9351f8c 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -6188,6 +6188,31 @@
       <info>
         <desc>Specifies settings for the accessibility options.</desc>
       </info>
+      <prop oor:name="HighContrast" oor:type="xs:short" oor:nillable="false">
+        <!-- UIHints: Tools  Options - Accessibility Options -->
+        <info>
+          <desc>Indicates whether High Contrast accessibility mode should be 
active.</desc>
+          <label>High Contrast</label>
+        </info>
+        <constraints>
+          <enumeration oor:value="0">
+            <info>
+              <desc>Use the default setting for the current platform.</desc>
+            </info>
+          </enumeration>
+          <enumeration oor:value="1">
+            <info>
+              <desc>Disable</desc>
+            </info>
+          </enumeration>
+          <enumeration oor:value="2">
+            <info>
+              <desc>Enable</desc>
+            </info>
+          </enumeration>
+        </constraints>
+        <value>0</value>
+      </prop>
       <prop oor:name="IsForPagePreviews" oor:type="xs:boolean" 
oor:nillable="false">
         <info>
           <desc>Enables the use of high contrast colors, instead of displaying
diff --git a/vcl/source/window/settings.cxx b/vcl/source/window/settings.cxx
index 0f36ca84f852..cc0341aff24f 100644
--- a/vcl/source/window/settings.cxx
+++ b/vcl/source/window/settings.cxx
@@ -25,6 +25,8 @@
 #include <vcl/window.hxx>
 #include <vcl/settings.hxx>
 
+#include <officecfg/Office/Common.hxx>
+
 #include <unotools/configmgr.hxx>
 #include <unotools/confignode.hxx>
 
@@ -219,17 +221,22 @@ void Window::ImplUpdateGlobalSettings( AllSettings& 
rSettings, bool bCallHdl ) c
     aFont.SetFontHeight( defFontheight );
     aStyleSettings.SetGroupFont( aFont );
 
-    rSettings.SetStyleSettings( aStyleSettings );
-
     static const char* pEnvHC = getenv( "SAL_FORCE_HC" );
     const bool bForceHCMode = pEnvHC && *pEnvHC;
-    if( bForceHCMode )
-    {
-        aStyleSettings = rSettings.GetStyleSettings();
+    if (bForceHCMode)
         aStyleSettings.SetHighContrastMode( true );
-        rSettings.SetStyleSettings( aStyleSettings );
+    else
+    {
+        short nHighContrastMode = 
officecfg::Office::Common::Accessibility::HighContrast::get();
+        if (nHighContrastMode != 0) // 0 Automatic, 1 Disable, 2 Enable
+        {
+            const bool bEnable = nHighContrastMode == 2;
+            aStyleSettings.SetHighContrastMode(bEnable);
+        }
     }
 
+    rSettings.SetStyleSettings( aStyleSettings );
+
     if ( bCallHdl )
         GetpApp()->OverrideSystemSettings( rSettings );
 }

Reply via email to