include/svx/AccessibleTextHelper.hxx              |   12 ++++++++++++
 include/svx/weldeditview.hxx                      |    2 +-
 svx/source/accessibility/AccessibleTextHelper.cxx |   15 +++++++++++++++
 svx/source/dialog/weldeditview.cxx                |   14 ++++++++++++++
 vcl/unx/gtk3/a11y/atkwrapper.cxx                  |    2 ++
 5 files changed, 44 insertions(+), 1 deletion(-)

New commits:
commit dff76b069e26a6d3487f74c5784d6f6cf273a19e
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Nov 6 13:07:35 2023 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Nov 7 07:51:37 2023 +0100

    tdf#135236 a11y: Notify a11y layer of WeldEditView sel change
    
    Extend `WeldEditView::EditViewSelectionChange` to not only
    invalidate the view, but also notify the `AccessibleTextHelper`
    of the selection update, so the corresponding events are sent
    on the a11y layer.
    
    This e.g. causes the `CARET_CHANGED` events to be sent as
    needed when moving the cursor/caret using the arrow keys in the
    "Not in dictionary" text edit in Writer's spelling dialog
    ("Tools" -> "Spelling"), so the Orca screen reader on Linux
    with the gtk3 or qt6 VCL plugin announces the new caret position,
    which was no longer the case since the spelling dialog was welded
    in
    
        commit 243b5b392906042ab03800e0b5765e6f3513372c
        Date:   Fri Jun 14 21:56:44 2019 +0100
    
            weld SpellDialog
    
    The newly added `AccessibleTextHelper::UpdateSelection` is a
    simplified version of `AccessibleTextHelper::UpdateChildren`.
    
    Change-Id: I5f0898c3ccb9fd527a6ff672be49157cb6e518b1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158992
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/svx/AccessibleTextHelper.hxx 
b/include/svx/AccessibleTextHelper.hxx
index 724cb0c8a7e6..963ae41e5b30 100644
--- a/include/svx/AccessibleTextHelper.hxx
+++ b/include/svx/AccessibleTextHelper.hxx
@@ -276,6 +276,18 @@ public:
     */
     void UpdateChildren();
 
+    /** Update the selection.
+
+        @attention Might fire state change events, therefore,
+        don't hold any mutex except solar mutex, which you are
+        required to lock before. This method should only be called
+        from the main office thread.
+
+        Call this method if the selection has changed and the
+        the AccessibleTextHelper isn't notified internally.
+    */
+    void UpdateSelection();
+
     /** Drop all references and enter disposed state
 
         This method drops all references to external objects (also
diff --git a/include/svx/weldeditview.hxx b/include/svx/weldeditview.hxx
index 004be7b609fb..43002a95e58c 100644
--- a/include/svx/weldeditview.hxx
+++ b/include/svx/weldeditview.hxx
@@ -87,7 +87,7 @@ protected:
 
     virtual void EditViewInvalidate(const tools::Rectangle& rRect) override { 
Invalidate(rRect); }
 
-    virtual void EditViewSelectionChange() override { Invalidate(); }
+    virtual void EditViewSelectionChange() override;
 
     virtual OutputDevice& EditViewOutputDevice() const override
     {
diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx 
b/svx/source/accessibility/AccessibleTextHelper.cxx
index d836f2ee4970..f12281793b78 100644
--- a/svx/source/accessibility/AccessibleTextHelper.cxx
+++ b/svx/source/accessibility/AccessibleTextHelper.cxx
@@ -1672,6 +1672,21 @@ namespace accessibility
 
         mpImpl->UpdateSelection();
 
+#ifdef DBG_UTIL
+        mpImpl->CheckInvariants();
+#endif
+    }
+
+    void AccessibleTextHelper::UpdateSelection()
+    {
+#ifdef DBG_UTIL
+        // precondition: solar mutex locked
+        DBG_TESTSOLARMUTEX();
+        mpImpl->CheckInvariants();
+#endif
+
+        mpImpl->UpdateSelection();
+
 #ifdef DBG_UTIL
         mpImpl->CheckInvariants();
 #endif
diff --git a/svx/source/dialog/weldeditview.cxx 
b/svx/source/dialog/weldeditview.cxx
index 415e9e7d109d..46ab95eb9a18 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -1669,6 +1669,20 @@ 
css::uno::Reference<css::datatransfer::clipboard::XClipboard> WeldEditView::GetC
     return weld::CustomWidgetController::GetClipboard();
 }
 
+void WeldEditView::EditViewSelectionChange()
+{
+    Invalidate();
+
+#if !ENABLE_WASM_STRIP_ACCESSIBILITY
+    if (m_xAccessible.is())
+    {
+        ::accessibility::AccessibleTextHelper* pHelper = 
m_xAccessible->GetTextHelper();
+        if (pHelper)
+            pHelper->UpdateSelection();
+    }
+#endif
+}
+
 namespace
 {
 class WeldEditViewUIObject final : public DrawingAreaUIObject
commit 0769e5e698a9cff77a815118dad82bc763520679
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Nov 6 12:02:22 2023 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Nov 7 07:51:30 2023 +0100

    tdf#135236 gtk3 a11y: Restore AtkObject's focus_event
    
    After
    
        commit 14e6a810e14e28ab82fe65d66e604ce562016845
        Date:   Mon Aug 15 13:14:08 2022 +0100
    
            fix "invalid class cast from 'OOoAtkObj' to 'GtkWidgetAccessible'"
    
    , Orca with the gtk3 VCL plugin was no longer announcing focus
    (and content) for the "Not in dictionary" text edit in Writer's
    spelling dialog ("Tools" -> "Spelling") when moving the focus
    there e.g. using the Tab key.
    
    Make it work again by restoring the `focus_event` function
    from `AtkObject`, similar to how
    
        commit f0827c392641b45647241b3a22e24a95e2b595e3
        Date:   Fri Aug 19 16:13:04 2022 +0100
    
            Resolves: tdf#150496 we want the AtkObject get_parent function
    
            GtkAccessible overrode it, but we expect the AtkObject 
implementation
    
    did for the `get_parent` function to fix the announcement
    of Writer paragraphs after the above-mentioned commit.
    
    The other functions that `gtk_widget_accessible_class_init`
    overrides [1] are already explicitly set to the wrapper
    ones (s. the lines above the ones added in this commit), so
    don't need additional changes.
    
    [1] 
https://gitlab.gnome.org/GNOME/gtk/-/blob/c47425c62efb99be8cd2f0eea651dda76a99ba04/gtk/a11y/gtkwidgetaccessible.c#L542-557
    
    Change-Id: Iae3b47f7fa7fe5ca90acb045a077cf0af52dd7fa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158990
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/unx/gtk3/a11y/atkwrapper.cxx b/vcl/unx/gtk3/a11y/atkwrapper.cxx
index 729da012e067..8caf40020d13 100644
--- a/vcl/unx/gtk3/a11y/atkwrapper.cxx
+++ b/vcl/unx/gtk3/a11y/atkwrapper.cxx
@@ -704,6 +704,8 @@ atk_object_wrapper_class_init (AtkObjectWrapperClass *klass)
   // but we want the original behaviour we got from atk_object_real_get_parent 
when we inherited
   // from AtkObject
   atk_class->get_parent = orig_atk_klass->get_parent;
+  // and likewise for focus_event
+  atk_class->focus_event = orig_atk_klass->focus_event;
   g_type_class_unref(orig_atk_klass);
 }
 

Reply via email to