vcl/unx/gtk3/gtkinst.cxx |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

New commits:
commit 1d1640dbeda76fcecd7b81200a60c267cea5f2f7
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Jul 31 14:41:47 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Aug 2 06:47:20 2024 +0200

    tdf155447 gtk3 a11y: Report accessible ID for drawing area
    
    Override `GtkInstanceWidget::get_accessible_id()`
    for `GtkInstanceDrawingArea`, similar to what
    is done for the handling of the accessible name
    and description.
    
    While accessible name and description don't
    have to explicitly be set on the AtkObject
    because they can be retrieved from the
    underlying XAccessible on demand as
    `AtkObjectClass::get_name` and `AtkObjectClass::get_description`
    are overriden (s. LO's `atk_object_wrapper_class_init`, and
    the ATK implementations of `atk_object_get_name`
    and `atk_object_get_description` [1]),
    there's no such function to override for the
    accessible ID (s. ATK's `atk_object_get_accessible_id`),
    so explicitly set it for the drawing area's
    AtkObject each time the accessible is queried in
    `GtkInstanceDrawingArea::GetAtkObject`.
    
    With this in place, the accessible ID
    "sentence" shows up in Accerciser with gtk3 for
    the corresponding edit view in Writer's spell check
    dialog, as is already the case for qt6 since
    
        Change-Id: I5cf8958118c84c01ecb3545381a05b306ca53163
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Wed Jul 31 13:25:45 2024 +0200
    
            tdf#155447 a11y: Set accessible ID for WeldEditView
    
    [1] 
https://gitlab.gnome.org/GNOME/at-spi2-core/-/blob/fddfd5ae5d44b09c3e587f41f450e05b95262bd9/atk/atkobject.c#L686-729
    [2] 
https://gitlab.gnome.org/GNOME/at-spi2-core/-/blob/fddfd5ae5d44b09c3e587f41f450e05b95262bd9/atk/atkobject.c#L1717-1733
    
    Change-Id: Ib1e889a06dccf4522148d8a17b62259dc08e2b85
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171321
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index b3cac1450506..804703b505b2 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -51,6 +51,7 @@
 #if !GTK_CHECK_VERSION(4, 0, 0)
 #include "a11y/atkwrapper.hxx"
 #endif
+#include <com/sun/star/accessibility/XAccessibleContext2.hpp>
 #include <com/sun/star/awt/XVclWindowPeer.hpp>
 #include <com/sun/star/datatransfer/XTransferable.hpp>
 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
@@ -18704,6 +18705,24 @@ public:
             if (m_pAccessible)
                 g_object_ref(m_pAccessible);
         }
+
+#if ATK_CHECK_VERSION(2, 34, 0)
+        // if set, take over accessible ID from the XAccessible to the 
GtkWidget
+        // (While e.g. accessible name and description can be handled on 
demand by overriding
+        // AtkObjectClass::get_name and AtkObjectClass::get_description, s. 
atk_object_wrapper_class_init),
+        // there's no such function to override for the accessible ID)
+        if (m_pAccessible && m_xAccessible.is())
+        {
+            css::uno::Reference<css::accessibility::XAccessibleContext2> 
xContext(
+                m_xAccessible->getAccessibleContext(), UNO_QUERY);
+            if (xContext.is())
+            {
+                const OUString sId = xContext->getAccessibleId();
+                atk_object_set_accessible_id(
+                    m_pAccessible, OUStringToOString(sId, 
RTL_TEXTENCODING_UTF8).getStr());
+            }
+        }
+#endif
         return m_pAccessible;
     }
 #endif
@@ -18860,6 +18879,21 @@ public:
 #endif
     }
 
+    virtual OUString get_accessible_id() const override
+    {
+#if !GTK_CHECK_VERSION(4, 0, 0)
+#if ATK_CHECK_VERSION(2, 34, 0)
+        AtkObject* pAtkObject = default_drawing_area_get_accessible(m_pWidget);
+        const char* pStr = pAtkObject ? 
atk_object_get_accessible_id(pAtkObject) : nullptr;
+        return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
+#else
+        return OUString();
+#endif
+#else
+        return OUString();
+#endif
+    }
+
     virtual void enable_drag_source(rtl::Reference<TransferDataContainer>& 
rHelper, sal_uInt8 eDNDConstants) override
     {
         do_enable_drag_source(rHelper, eDNDConstants);

Reply via email to