vcl/unx/gtk4/a11y.cxx |   26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

New commits:
commit a5c84405caf6f3dc51919fd937dfe21c3d6d53d1
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Nov 6 16:59:36 2023 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Nov 7 07:59:28 2023 +0100

    gtk4 a11y: Map states to corresponding gtk a11y properties
    
    For those states in
    `com::sun::star::accessibility::AccessibleStateType::EDITABLE`
    that have a corresponding `GTK_ACCESSIBLE_PROPERTY_*`, set
    that property when creating a new `LoAccessible`.
    
    This e.g. makes Accerciser show the "multiline" and "multi selectable"
    AT-SPI states for a Writer paragraph when using the gtk4 VCL plugin.
    
    State updates are not handled yet, since a11y event handling is
    currently not implemented in the gtk4 VCL plugin yet.
    
    Change-Id: Ic033e66dd89021defca449bbe2251102bbd61015
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159005
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/unx/gtk4/a11y.cxx b/vcl/unx/gtk4/a11y.cxx
index 2aae5bdefae6..fc148d41c199 100644
--- a/vcl/unx/gtk4/a11y.cxx
+++ b/vcl/unx/gtk4/a11y.cxx
@@ -470,9 +470,33 @@ lo_accessible_new(GdkDisplay* pDisplay, GtkAccessible* 
pParent,
     ret->parent = pParent;
     ret->uno_accessible = rAccessible;
 
-    // set values from XAccessibleValue interface if that's implemented
     css::uno::Reference<css::accessibility::XAccessibleContext> xContext(
         ret->uno_accessible->getAccessibleContext());
+    assert(xContext.is() && "No accessible context");
+
+    // set state properties
+    const sal_Int64 nStates = xContext->getAccessibleStateSet();
+    gtk_accessible_update_property(
+        GTK_ACCESSIBLE(ret), GTK_ACCESSIBLE_PROPERTY_MODAL,
+        bool(nStates & 
com::sun::star::accessibility::AccessibleStateType::MODAL),
+        GTK_ACCESSIBLE_PROPERTY_MULTI_LINE,
+        bool(nStates & 
com::sun::star::accessibility::AccessibleStateType::MULTI_LINE),
+        GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE,
+        bool(nStates & 
com::sun::star::accessibility::AccessibleStateType::MULTI_SELECTABLE),
+        GTK_ACCESSIBLE_PROPERTY_READ_ONLY,
+        bool(!(nStates & 
com::sun::star::accessibility::AccessibleStateType::EDITABLE)), -1);
+    if (nStates & 
com::sun::star::accessibility::AccessibleStateType::HORIZONTAL)
+    {
+        gtk_accessible_update_property(GTK_ACCESSIBLE(ret), 
GTK_ACCESSIBLE_PROPERTY_ORIENTATION,
+                                       GTK_ORIENTATION_HORIZONTAL, -1);
+    }
+    else if ((nStates & 
com::sun::star::accessibility::AccessibleStateType::VERTICAL))
+    {
+        gtk_accessible_update_property(GTK_ACCESSIBLE(ret), 
GTK_ACCESSIBLE_PROPERTY_ORIENTATION,
+                                       GTK_ORIENTATION_VERTICAL, -1);
+    }
+
+    // set values from XAccessibleValue interface if that's implemented
     css::uno::Reference<css::accessibility::XAccessibleValue> 
xAccessibleValue(xContext,
                                                                                
css::uno::UNO_QUERY);
     if (xAccessibleValue.is())

Reply via email to