vcl/inc/accessibility/accessiblelistboxentry.hxx    |    2 +
 vcl/source/accessibility/accessiblelistboxentry.cxx |   26 ++++++++++++++++----
 2 files changed, 23 insertions(+), 5 deletions(-)

New commits:
commit 31ab6a0cc7a47c82c2aaa073116c74d7104669ca
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Jul 22 13:58:20 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Jul 22 19:41:11 2025 +0200

    IconView/ListBox a11y: Ignore non-children for getAccessibleAtPoint
    
    XAccessibleComponent::getAccessibleAtPoint is supposed
    to return the *direct child* at the given relative
    coordinates, or an empty reference, see the doc.
    
    Therefore, ignore the accessible for any entry returned
    by SvTreeListBox::GetEntry in
    AccessibleListBoxEntry::getAccessibleAtPoint
    that is not an actual child (i.e. that doesn't have `this`
    as parent).
    
    This fixes a freeze (due to some logic querying the same object
    over and over again) seen when using Accerciser's "Inspect object
    under mouse" feature while the mouse is over one of the elements
    in Math's operator sidebar (e.g. over the "+ Sign") when using
    the qt6 VCL plugin on Linux.
    
    Instead, the area of the element hovered actually gets highlighted
    on screen now.
    
    Change-Id: Ifda410eb2d8220361bfe161e9dcb18a4120a6806
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188164
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/source/accessibility/accessiblelistboxentry.cxx 
b/vcl/source/accessibility/accessiblelistboxentry.cxx
index 761d03f970f1..ea022d70d1be 100644
--- a/vcl/source/accessibility/accessiblelistboxentry.cxx
+++ b/vcl/source/accessibility/accessiblelistboxentry.cxx
@@ -454,7 +454,8 @@ Reference< XAccessible > SAL_CALL 
AccessibleListBoxEntry::getAccessibleAtPoint(
     assert(xListBox.is());
     rtl::Reference<AccessibleListBoxEntry> pAccEntry = 
xListBox->implGetAccessible(*pEntry);
     tools::Rectangle aRect = pAccEntry->GetBoundingBox_Impl();
-    if (aRect.Contains(vcl::unohelper::ConvertToVCLPoint(_aPoint)))
+    if (aRect.Contains(vcl::unohelper::ConvertToVCLPoint(_aPoint))
+        && pAccEntry->implGetParentAccessible().get() == this)
         return pAccEntry;
 
     return {};
commit 4a90d52040fdd8c975bc442b9cc24514c2330820
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Jul 22 13:52:39 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Jul 22 19:41:04 2025 +0200

    vcl a11y: Slightly simplify AccessibleListBoxEntry::getAccessibleAtPoint
    
    Drop local var.
    No need to call rtl::Reference::get().
    
    Change-Id: I673633e00e80d9f77c87831a7e56d3662588f7cd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188163
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/source/accessibility/accessiblelistboxentry.cxx 
b/vcl/source/accessibility/accessiblelistboxentry.cxx
index 86fb024deb46..761d03f970f1 100644
--- a/vcl/source/accessibility/accessiblelistboxentry.cxx
+++ b/vcl/source/accessibility/accessiblelistboxentry.cxx
@@ -450,14 +450,14 @@ Reference< XAccessible > SAL_CALL 
AccessibleListBoxEntry::getAccessibleAtPoint(
     if ( !pEntry )
         throw RuntimeException(u"AccessibleListBoxEntry::getAccessibleAtPoint 
- pEntry cannot be empty!"_ustr);
 
-    Reference< XAccessible > xAcc;
     rtl::Reference<AccessibleListBox> xListBox(m_wListBox);
     assert(xListBox.is());
-    auto pAccEntry = xListBox->implGetAccessible(*pEntry);
+    rtl::Reference<AccessibleListBoxEntry> pAccEntry = 
xListBox->implGetAccessible(*pEntry);
     tools::Rectangle aRect = pAccEntry->GetBoundingBox_Impl();
     if (aRect.Contains(vcl::unohelper::ConvertToVCLPoint(_aPoint)))
-        xAcc = pAccEntry.get();
-    return xAcc;
+        return pAccEntry;
+
+    return {};
 }
 
 void SAL_CALL AccessibleListBoxEntry::grabFocus(  )
commit 51affcf888153d774d8505e924e27322dda973f9
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Jul 22 12:43:29 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Jul 22 19:40:58 2025 +0200

    IconView/ListBox a11y: Don't support XAccessibleText w/o text
    
    AccessibleListBoxEntry is used for both, entries that
    actually can contain text as well as for ones that don't
    actually support/have text (typically IconView entries).
    
    So far, the XAccessibleText interface was always
    reported as supported anyway.
    
    With Orca on Linux with the qt6 VCL plugin, this resulted
    in Orca announcing "blank" instead of the accessible name
    e.g. for items in Writer's "Insert" -> "Fontwork" dialog
    (when used without SAL_VCL_QT_USE_WELDED_WIDGETS=1, i.e.
    using the VCL implementation, not the native Qt one) or
    for items in the IconViews newly used in the
    "Format" -> "Page Style" dialog, tab "Borders" since
    
        commit 4d6429c0368f9b2ec796dd8468defbee194a8b4c
        Date:   Thu Jul 17 14:52:51 2025 +0530
    
            tdf#167536 Switch to IconView for presets and shadows in border page
    
    despite follow-up commit
    
        commit 7fc56525ed18de950d3892d69942f8dc8d15f22b
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Mon Jul 21 23:49:37 2025 +0200
    
            tdf#167536 cui: Set a11y names for IconView items in borders tab 
page
    
    to set the a11y names again (which had made announcement
    work again for the gtk3 VCL plugin that uses a native
    GtkIconView, but not qt6 using the VCL implementation).
    
    This is because Orca gives higher priority to text provided
    using the AT-SPI Text interface (to which the XAccessibleText
    interface is bridged on Linux with qt6).
    
    Don't report support for XAccessibleText any more if the entry
    doesn't contain any text item, which makes Orca announce the
    accessible names again, as it used to do for the ValueSet items
    used before the above-mentioned 4d6429c0368f9b2ec796dd8468defbee194a8b4c
    since Orca commit [1]
    
        commit db2395fbca4fff4dd452ef8369cb8f253eec20e2
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Tue Feb 25 14:06:12 2025 +0100
    
            soffice: Don't announce "blank" as text for non-text objects
    
            While "blank" may be useful as an information that a
            text object (like a LibreOffice Writer paragraph)
            does not contain any text, it's not useful for non-text
            objects. Therefore, only try to get the text content
            of the current line and return "blank" if it's empty
            in the soffice SpeechGenerator._generate_text_line method
            if the object supports the AtSpiText interface.
    
            Otherwise, this causes the
    
                result += (self._generate_text_line(obj, **args) or \
                    self._generate_accessible_label_and_name(obj, **args))
    
            logic in SpeechGenerator._generate_list_item to use
            "blank" for non-text items instead of their accessible label/name.
    
            Sample scenario:
    
            1) start LibreOffice Writer (gtk3 or qt6 variant,
              tested with current LO development version as of
              commit 8b998ed161f0c7e72530e5f02aa9be13edb4f703)
            2) open the "Format" -> "Paragraph" dialog
            3) go to the "Borders" tab
            4) move focus to the "Shadow Style" section, list of
              items labelled by the "Position" label
            5) move between the items using the arrow keys
    
            Result without this commit in place:
            Orca announces "blank" for each of the items.
    
            Result with this commit in place:
            Orca announces the actual name
            ("None", "Cast Shadow to Bottom Right",...)..
    
    [1] 
https://gitlab.gnome.org/GNOME/orca/-/commit/db2395fbca4fff4dd452ef8369cb8f253eec20e2
    
    Change-Id: Ifd1f6034e00cea9f56883830483c9b2bbc874aec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188162
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/inc/accessibility/accessiblelistboxentry.hxx 
b/vcl/inc/accessibility/accessiblelistboxentry.hxx
index 55d44ce4c578..1520a8f4fe2f 100644
--- a/vcl/inc/accessibility/accessiblelistboxentry.hxx
+++ b/vcl/inc/accessibility/accessiblelistboxentry.hxx
@@ -92,6 +92,8 @@ protected:
     virtual css::awt::Rectangle implGetBounds() override;
 
 private:
+    css::uno::Any SAL_CALL queryInterface(const css::uno::Type& rType) 
override;
+
     // XServiceInfo
     virtual OUString SAL_CALL getImplementationName() override;
     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) 
override;
diff --git a/vcl/source/accessibility/accessiblelistboxentry.cxx 
b/vcl/source/accessibility/accessiblelistboxentry.cxx
index 67d150e852b0..86fb024deb46 100644
--- a/vcl/source/accessibility/accessiblelistboxentry.cxx
+++ b/vcl/source/accessibility/accessiblelistboxentry.cxx
@@ -178,6 +178,21 @@ void SAL_CALL AccessibleListBoxEntry::disposing()
     m_pTreeListBox = nullptr;
 }
 
+uno::Any SAL_CALL AccessibleListBoxEntry::queryInterface(const uno::Type& 
rType)
+{
+    if (rType == cppu::UnoType<XAccessibleText>::get())
+    {
+        // don't support XAccessibleText interface if there's no text item
+        // (e.g. for IconView items), as screen readers may give text a higher
+        // priority than accessible name and just say something like "blank" 
otherwise
+        SvTreeListEntry* pEntry = 
m_pTreeListBox->GetEntryFromPath(m_aEntryPath);
+        if (pEntry && !pEntry->GetFirstItem(SvLBoxItemType::String))
+            return uno::Any();
+    }
+
+    return AccessibleListBoxEntry_BASE::queryInterface(rType);
+}
+
 // XServiceInfo
 
 OUString SAL_CALL AccessibleListBoxEntry::getImplementationName()

Reply via email to