include/svx/colorbox.hxx                     |    1 +
 sw/inc/strings.hrc                           |    5 +++++
 sw/source/uibase/sidebar/PageStylesPanel.cxx |    8 ++++++++
 sw/uiconfig/swriter/ui/pagestylespanel.ui    |   25 ++++++++++++++++---------
 4 files changed, 30 insertions(+), 9 deletions(-)

New commits:
commit 8950ae3095c43d6217cb53d1e8969ccf3a0b56ac
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Aug 7 07:54:46 2024 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Wed Aug 7 16:10:44 2024 +0200

    sw a11y: Add a11y names for bg settings in side bar
    
    Set a11y names for UI elements related to the page
    background in Writer's "Page" sidebar deck, section
    "Styles."
    
    Some of those combo boxes/menu buttons are reused for
    multiple background types, so set an a11y name
    depending on the currently selected background
    type in C++ code instead of a static one in the .ui
    file for these.
    
    This allows screen readers to announce what those
    comboboxes/menu buttons are for when they receive
    focus.
    
    Lack of some of those led to gla11y failures in pending
    Gerrit change [1], but is actually a preexisting issue
    as mentioned in [2].
    
    (The gla11y issue even showed up after simply resaving
    pagestylespanel.ui with glade 3.40, see CI failure for [3],
    a previous change doing that in preparation for this
    commit, but now squashed into this commit.)
    
    [1] https://gerrit.libreoffice.org/c/core/+/171430
    [2] 
https://gerrit.libreoffice.org/c/core/+/171430/comments/6fac1506_50ddcce5
    [3] https://gerrit.libreoffice.org/c/core/+/171582
    
    Change-Id: I4e78c61cfd5d5b9f198887eec53be368cb6a0716
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171583
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/include/svx/colorbox.hxx b/include/svx/colorbox.hxx
index 56e4511aac99..fe134531d39a 100644
--- a/include/svx/colorbox.hxx
+++ b/include/svx/colorbox.hxx
@@ -86,6 +86,7 @@ public:
     void hide() { m_xButton->hide(); }
     void set_visible(bool bShow) { m_xButton->set_visible(bShow); }
     void set_help_id(const OUString& rHelpId) { 
m_xButton->set_help_id(rHelpId); }
+    void set_accessible_name(const OUString& rName) { 
m_xButton->set_accessible_name(rName); };
     void connect_focus_in(const Link<weld::Widget&, void>& rLink)
     {
         m_xButton->connect_focus_in(rLink);
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 97b7b4545054..7724887cc467 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -1504,6 +1504,11 @@
 #define STR_TABLE_PANEL_ALIGN_CENTER            
NC_("sidebartableedit|aligncenterlabel", "Center")
 #define STR_TABLE_PANEL_ALIGN_MANUAL            
NC_("sidebartableedit|alignmanuallabel", "Manual")
 
+#define STR_BACKGROUND_COLOR NC_("STR_BACKGROUND_COLOR", "Background color")
+#define STR_GRADIENT_COLOR_1 NC_("STR_GRADIENT_COLOR_1", "First gradient 
color")
+#define STR_BACKGROUND_BITMAP NC_("STR_BACKGROUND_BITMAP", "Background bitmap")
+#define STR_BACKGROUND_PATTERN NC_("STR_BACKGROUND_PATTERN", "Background 
pattern")
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/sidebar/PageStylesPanel.cxx 
b/sw/source/uibase/sidebar/PageStylesPanel.cxx
index dd03db6fb9ca..881ce78d3eb3 100644
--- a/sw/source/uibase/sidebar/PageStylesPanel.cxx
+++ b/sw/source/uibase/sidebar/PageStylesPanel.cxx
@@ -33,6 +33,8 @@
 #include <sfx2/bindings.hxx>
 #include <sfx2/objsh.hxx>
 #include <cmdid.h>
+#include <strings.hrc>
+#include <swtypes.hxx>
 
 using namespace ::com::sun::star;
 
@@ -180,6 +182,7 @@ void PageStylesPanel::Update()
             mxBgBitmapLB->hide();
             mxBgGradientLB->hide();
             mxBgHatchingLB->hide();
+            mxBgColorLB->set_accessible_name(SwResId(STR_BACKGROUND_COLOR));
             mxBgColorLB->show();
             const Color aColor = GetColorSetOrDefault();
             mxBgColorLB->SelectEntry(aColor);
@@ -189,6 +192,7 @@ void PageStylesPanel::Update()
         {
             mxBgBitmapLB->hide();
             mxBgHatchingLB->hide();
+            mxBgColorLB->set_accessible_name(SwResId(STR_GRADIENT_COLOR_1));
             mxBgColorLB->show();
             mxBgGradientLB->show();
 
@@ -220,6 +224,10 @@ void PageStylesPanel::Update()
             mxBgColorLB->hide();
             mxBgGradientLB->hide();
             mxBgHatchingLB->hide();
+
+            const OUString sAccName = (eXFS == BITMAP) ? 
SwResId(STR_BACKGROUND_BITMAP)
+                                                       : 
SwResId(STR_BACKGROUND_PATTERN);
+            mxBgBitmapLB->set_accessible_name(sAccName);
             mxBgBitmapLB->show();
             mxBgBitmapLB->clear();
             OUString aBitmapName;
diff --git a/sw/uiconfig/swriter/ui/pagestylespanel.ui 
b/sw/uiconfig/swriter/ui/pagestylespanel.ui
index a60f61f1c339..f966e4be5cd9 100644
--- a/sw/uiconfig/swriter/ui/pagestylespanel.ui
+++ b/sw/uiconfig/swriter/ui/pagestylespanel.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2 -->
+<!-- Generated with glade 3.40.0 -->
 <interface domain="sw">
   <requires lib="gtk+" version="3.20"/>
   <object class="GtkListStore" id="liststore4">
@@ -159,9 +159,11 @@
             </child>
             <child>
               <object class="GtkCellRendererPixbuf" id="cellrenderertext4"/>
-              <attributes>
-                <attribute name="surface">3</attribute>
-              </attributes>
+            </child>
+            <child internal-child="accessible">
+              <object class="AtkObject" id="lbhatching-atkobject">
+                <property name="AtkObject::accessible-name" translatable="yes" 
context="pagestylespanel|hatching|accessible_name">Background 
Hatching</property>
+              </object>
             </child>
           </object>
           <packing>
@@ -185,9 +187,6 @@
             </child>
             <child>
               <object class="GtkCellRendererPixbuf" id="cellrenderertext6"/>
-              <attributes>
-                <attribute name="surface">3</attribute>
-              </attributes>
             </child>
           </object>
           <packing>
@@ -205,10 +204,14 @@
             <property name="hexpand">True</property>
             <property name="xalign">0</property>
             <property name="draw-indicator">True</property>
-            <property name="label" translatable="no"></property>
             <child>
               <placeholder/>
             </child>
+            <child internal-child="accessible">
+              <object class="AtkObject" id="lbcolor-atkobject">
+                <property name="AtkObject::accessible-name" translatable="yes" 
context="pagestylespanel|background_color|accessible_name">Background 
Color</property>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="left-attach">1</property>
@@ -225,10 +228,14 @@
             <property name="hexpand">True</property>
             <property name="xalign">0</property>
             <property name="draw-indicator">True</property>
-            <property name="label" translatable="no"></property>
             <child>
               <placeholder/>
             </child>
+            <child internal-child="accessible">
+              <object class="AtkObject" id="lbgradient-atkobject">
+                <property name="AtkObject::accessible-name" translatable="yes" 
context="pagestylespanel|second_gradient_color">Second gradient color</property>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="left-attach">1</property>

Reply via email to