include/vcl/customweld.hxx         |    6 ++++++
 include/vcl/weld.hxx               |    2 ++
 svx/source/dialog/weldeditview.cxx |   14 ++++++++++++--
 vcl/inc/qt5/QtInstanceWidget.hxx   |    2 ++
 vcl/inc/salvtables.hxx             |    2 ++
 vcl/qt5/QtInstanceWidget.cxx       |   10 ++++++++++
 vcl/source/app/salvtables.cxx      |    2 ++
 vcl/unx/gtk3/gtkinst.cxx           |   15 +++++++++++++++
 8 files changed, 51 insertions(+), 2 deletions(-)

New commits:
commit 57f6105c90019f6a2070ab52335d7a4e852466ff
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Jul 31 13:25:45 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Aug 2 06:47:12 2024 +0200

    tdf#155447 a11y: Set accessible ID for WeldEditView
    
    Let `WeldEditAccessible` derive from `XAccessibleContext2`
    and implement `XAccessibleContext2::getAccessibleId`
    by returning the accessible ID set in the underlying
    drawing area.
    
    This makes an accessible ID of "sentence" show up
    in Accerciser for the corresponding edit view in
    Writer's spell check dialog when using the qt6 VCL plugin,
    since that is the ID set in the .ui file
    (cui/uiconfig/ui/spellingdialog.ui).
    
    It's not set for gtk3 yet, which uses native GTK
    widgets, and where the accessible ID is not set for the
    drawing area yet.
    
    Change-Id: I5cf8958118c84c01ecb3545381a05b306ca53163
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171320
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/include/vcl/customweld.hxx b/include/vcl/customweld.hxx
index c7504fb94d95..580542b983f2 100644
--- a/include/vcl/customweld.hxx
+++ b/include/vcl/customweld.hxx
@@ -83,6 +83,12 @@ public:
     {
         return m_pDrawingArea->get_accessible_description();
     }
+    OUString GetAccessibleId() const
+    {
+        if (m_pDrawingArea)
+            return m_pDrawingArea->get_accessible_id();
+        return OUString();
+    }
     void CaptureMouse() { m_pDrawingArea->grab_add(); }
     bool IsMouseCaptured() const { return m_pDrawingArea->has_grab(); }
     Point GetPointerPosPixel() const { return 
m_pDrawingArea->get_pointer_position(); }
diff --git a/svx/source/dialog/weldeditview.cxx 
b/svx/source/dialog/weldeditview.cxx
index b24b00717cb8..14767992e9c2 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -24,7 +24,7 @@
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
 #include <com/sun/star/accessibility/XAccessible.hpp>
 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
-#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext2.hpp>
 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -503,7 +503,7 @@ public:
 
 typedef cppu::WeakImplHelper<css::lang::XServiceInfo, 
css::accessibility::XAccessible,
                              css::accessibility::XAccessibleComponent,
-                             css::accessibility::XAccessibleContext,
+                             css::accessibility::XAccessibleContext2,
                              css::accessibility::XAccessibleEventBroadcaster>
     WeldEditAccessibleBaseClass;
 
@@ -752,6 +752,16 @@ public:
         return aRet;
     }
 
+    virtual OUString SAL_CALL getAccessibleId() override
+    {
+        SolarMutexGuard aGuard;
+
+        if (m_pController)
+            return m_pController->GetAccessibleId();
+
+        return OUString();
+    }
+
     virtual OUString SAL_CALL getAccessibleName() override
     {
         SolarMutexGuard aGuard;
commit 0dd7751df292f5135be13b13e74e415b20053c67
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Jul 31 12:49:50 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Aug 2 06:47:03 2024 +0200

    tdf#155447 a11y: Introduce weld::Widget::get_accessible_id()
    
    This will be used in an upcoming commit to implement
    reporting of the accessible ID for `WeldEditView`.
    
    For Qt 6, this uses the API introduced in qtbase commit [1]
    
        commit b8b7c58402740204da72e1b1f4ea7321b7bfa540
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Mon Jul 15 16:53:58 2024 +0200
    
            a11y: Add property for QWidget's accessible ID
    
    For GTK 4, there is currently no corresponding API;
    issue [2] suggests to add it.
    
    [1] 
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=b8b7c58402740204da72e1b1f4ea7321b7bfa540
    [2] https://gitlab.gnome.org/GNOME/gtk/-/issues/6870
    
    Change-Id: I9bf38b3c2d6d0cf627ac4288695dcc1137c3d120
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171319
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 8002dfd5bca8..434f4f3e2d5e 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -214,6 +214,8 @@ public:
 
     virtual OUString get_accessible_description() const = 0;
 
+    virtual OUString get_accessible_id() const = 0;
+
     // After this call this widget is only accessibility labelled by pLabel and
     // pLabel only accessibility labels this widget
     virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) = 0;
diff --git a/vcl/inc/qt5/QtInstanceWidget.hxx b/vcl/inc/qt5/QtInstanceWidget.hxx
index 0e8ff5ccafc9..5a8feb35d8e5 100644
--- a/vcl/inc/qt5/QtInstanceWidget.hxx
+++ b/vcl/inc/qt5/QtInstanceWidget.hxx
@@ -114,6 +114,8 @@ public:
 
     virtual OUString get_accessible_description() const override;
 
+    virtual OUString get_accessible_id() const override;
+
     virtual void set_accessible_relation_labeled_by(weld::Widget*) override;
 
     virtual void set_tooltip_text(const OUString&) override;
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 708e4753fd89..3c6112c4299e 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -314,6 +314,8 @@ public:
 
     virtual OUString get_accessible_description() const override;
 
+    virtual OUString get_accessible_id() const override;
+
     virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) 
override;
 
     virtual void set_tooltip_text(const OUString& rTip) override;
diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx
index 9c5c8864fd4b..e2990c2d4199 100644
--- a/vcl/qt5/QtInstanceWidget.cxx
+++ b/vcl/qt5/QtInstanceWidget.cxx
@@ -117,6 +117,16 @@ OUString QtInstanceWidget::get_accessible_description() 
const
     return toOUString(m_pWidget->accessibleDescription());
 }
 
+OUString QtInstanceWidget::get_accessible_id() const
+{
+    assert(m_pWidget);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
+    return toOUString(m_pWidget->accessibleIdentifier());
+#else
+    return OUString();
+#endif
+}
+
 void QtInstanceWidget::set_accessible_relation_labeled_by(weld::Widget*) {}
 
 void QtInstanceWidget::set_tooltip_text(const OUString&) {}
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 92aa6fd3c01c..f97e2561f566 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -492,6 +492,8 @@ OUString SalInstanceWidget::get_accessible_description() 
const
     return m_xWidget->GetAccessibleDescription();
 }
 
+OUString SalInstanceWidget::get_accessible_id() const { return 
m_xWidget->get_id(); }
+
 void SalInstanceWidget::set_accessible_relation_labeled_by(weld::Widget* 
pLabel)
 {
     if (vcl::Window* pOldLabel = m_xWidget->GetAccessibleRelationLabeledBy())
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 69370451a878..b3cac1450506 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -3857,6 +3857,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 = gtk_widget_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 set_accessible_relation_labeled_by(weld::Widget* pLabel) 
override
     {
         GtkWidget* pGtkLabel = pLabel ? 
dynamic_cast<GtkInstanceWidget&>(*pLabel).getWidget() : nullptr;

Reply via email to