accessibility/source/extended/accessibletablistboxtable.cxx |    7 ++++---
 vcl/source/treelist/svtabbx.cxx                             |    8 ++++----
 2 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 10129ea98f808c19990abe08aba2e62ed10ebf81
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Jul 21 09:00:09 2023 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Jul 21 15:03:08 2023 +0200

    tdf#99609 a11y: Fix bound rect reporting for tab list box
    
    As described in more detail for the case in
    Change-Id I35f7280d2c386a9a8e04e636ebf34850a733c84a
    ("tdf#99609 a11y: Announce the correct entry in tab list box"),
    this also needs to use `SvTabListBox::GetEntryOnPos` for the
    correct entry to be used.
    
    With this in place, Accerciser now highlights the correct entry
    when clicking on the corresponding object in its treeview of
    LO's a11y hierarchy.
    
    Change-Id: I850247cd384a6a9bb909f51b39c4743548ec1105
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154689
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx
index cad1a46bbb58..d9b3e2eaecb9 100644
--- a/vcl/source/treelist/svtabbx.cxx
+++ b/vcl/source/treelist/svtabbx.cxx
@@ -773,7 +773,7 @@ tools::Rectangle SvHeaderTabListBox::GetFieldRectPixelAbs( 
sal_Int32 _nRow, sal_
 {
     DBG_ASSERT( !_bIsHeader || 0 == _nRow, "invalid parameters" );
     tools::Rectangle aRect;
-    SvTreeListEntry* pEntry = GetEntry( _nRow );
+    SvTreeListEntry* pEntry = GetEntryOnPos(_nRow );
     if ( pEntry )
     {
         aRect = _bIsHeader ? calcHeaderRect( true, false ) : GetBoundingRect( 
pEntry );
commit 44de8e68c40be6c4bddeadd627d58251639487e2
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Jul 21 08:34:20 2023 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Jul 21 15:03:00 2023 +0200

    tdf#99609 a11y: Fix reporting selection in tab list table
    
    The previous calculation of row and column index
    in `AccessibleTabListBoxTable::getSelectedAccessibleChild`
    based on the selection index was wrong, so fix that.
    
    Only increase the the loop variable `nRow` in
    `AccessibleTabListBoxTable::implGetSelRow` at the end
    of the loop, since the comparison still needs to use
    the original value. (Index starts at 0. Trying to retrieve
    the first selected child at index 0 would otherwise
    fail, and always return the fallback value of row index 0,
    making NVDA always announce the first row as selected instead
    of the actually selected one.
    
    The issue could also be observed with Accerciser and the qt6
    VCL plugin. With the "org.openoffice.LDAP" row selected
    in the dialog, and the table object selected in Accerciser's
    treeview of the a11y hierarchy, the cells in the first
    row ("org.openoffice.VCL") would always be returned when
    querying the selection using the AT-SPI Selection interface:
    
        In [1]: sel = acc.querySelection()
        In [2]: sel.nSelectedChildren
        Out[2]: 4
        In [3]: sel.getSelectedChild(0).name
        Out[3]: 'org.openoffice.VCL'
    
    This works as expected now with this fix in place:
    
        In [4]: sel = acc.querySelection()
        In [5]: sel.nSelectedChildren
        Out[5]: 4
        In [6]: sel.getSelectedChild(0).name
        Out[6]: 'org.openoffice.LDAP'
    
    With this fix in place, NVDA now properly announces the
    currently focused row in the Expert Configuration
    dialog (i.e. both, the focused cell first, and then
    the whole row as selection).
    
    Change-Id: I394027695616b17f7290136d8ee10c06a0282e80
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154688
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/accessibility/source/extended/accessibletablistboxtable.cxx 
b/accessibility/source/extended/accessibletablistboxtable.cxx
index fd8c2bb045ed..a6997d37d5bf 100644
--- a/accessibility/source/extended/accessibletablistboxtable.cxx
+++ b/accessibility/source/extended/accessibletablistboxtable.cxx
@@ -237,10 +237,10 @@ namespace accessibility
             SvTreeListEntry* pEntry = m_pTabListBox->FirstSelected();
             while ( pEntry )
             {
-                ++nRow;
                 if ( nRow == nSelRow )
                     return m_pTabListBox->GetEntryPos( pEntry );
                 pEntry = m_pTabListBox->NextSelected( pEntry );
+                ++nRow;
             }
         }
 
@@ -324,8 +324,9 @@ namespace accessibility
         if ( nRows == 0 )
             throw IndexOutOfBoundsException();
 
-        sal_Int32 nRow = implGetSelRow( nSelectedChildIndex % nRows );
-        sal_Int32 nColumn = nSelectedChildIndex / nRows;
+        const sal_Int32 nColCount = implGetColumnCount();
+        const sal_Int32 nRow = implGetSelRow(nSelectedChildIndex / nColCount);
+        const sal_Int32 nColumn = nSelectedChildIndex % nColCount;
         return getAccessibleCellAt( nRow, nColumn );
     }
 
commit 452c17e08fd8f18d032788170d873b019c8e9716
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Jul 21 08:27:09 2023 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Jul 21 15:02:54 2023 +0200

    tdf#99609 a11y: Announce the correct entry in tab list box
    
    The tree view in in the Expert Configuration dialog
    has a lot of "<dummy>" entries to implement creating
    entries on demand when expanding an entry (see
    `SalInstanceTreeView`). While these
    are not visible in the user interface, these
    have the effect that calling
    `SvTreeListBox::GetEntry` with the row index does
    not actually return the correct entry, but an entry
    further down in the tree view if there are non-expanded
    nodes (as is the case e.g. right after opening
    the Expert Configuration dialog, without having
    done any search).
    
    Use `SvTabListBox::GetEntryOnPos` that does exactly
    what is needed and returns the correct entry.
    
    With this in place, Orca with the qt6 VCL plugin
    now correctly announces the focused entry in the
    Expert Configuration dialog.
    NVDA on Windows now also announces the focused
    entry correctly at first. It then still always incorrectly
    announces the first row as selected, but that's another
    issue that will be addressed separately.
    
    This fixes the remaining issue about the selected/focused
    states not being reported correctly mentioned in
    Change-Id I6b532bfd6c3f437e44b3d67da8a5cc5f77b562d2
    ("tdf#99609 a11y: Handle focused state for cells in tab list box"):
    
    > This at least makes the focused state being reported
    > properly for the first item ("org.openoffice.VCL")
    > in the Expoert Configuration dialog, but others still happen to not
    > have the focused state set properly when moving there with the arrow
    > down key, so there seems to be another issue somewhere.
    
    There are more uses of `GetEntry` that will be
    looked at separately.
    
    (Whether the dummy entries in the tree view should be exposed
    as cells of the table on the accessibility layer, as it is now,
    is another question, but leave it like that for now.
    With gtk3, which uses native Gtk widgets instead,
    the dummy entries are not exposed, which seems
    reasonable.)
    
    Change-Id: I35f7280d2c386a9a8e04e636ebf34850a733c84a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154687
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx
index 2699ec4cfcf6..cad1a46bbb58 100644
--- a/vcl/source/treelist/svtabbx.cxx
+++ b/vcl/source/treelist/svtabbx.cxx
@@ -354,7 +354,7 @@ std::u16string_view SvTabListBox::GetToken( 
std::u16string_view sStr, sal_Int32&
 
 OUString SvTabListBox::GetTabEntryText( sal_uInt32 nPos, sal_uInt16 nCol ) 
const
 {
-    SvTreeListEntry* pEntry = SvTreeListBox::GetEntry( nPos );
+    SvTreeListEntry* pEntry = GetEntryOnPos( nPos );
     DBG_ASSERT( pEntry, "GetTabEntryText(): Invalid entry " );
     OUStringBuffer aResult;
     if ( pEntry )
@@ -701,7 +701,7 @@ void SvHeaderTabListBox::SelectAll()
 
 void SvHeaderTabListBox::SelectRow( sal_Int32 _nRow, bool _bSelect, bool )
 {
-    Select( GetEntry( _nRow ), _bSelect );
+    Select( GetEntryOnPos( _nRow ), _bSelect );
 }
 
 void SvHeaderTabListBox::SelectColumn( sal_uInt16, bool )
@@ -720,7 +720,7 @@ sal_Int32 SvHeaderTabListBox::GetSelectedColumnCount() const
 
 bool SvHeaderTabListBox::IsRowSelected( sal_Int32 _nRow ) const
 {
-    SvTreeListEntry* pEntry = GetEntry( _nRow );
+    SvTreeListEntry* pEntry = GetEntryOnPos( _nRow );
     return ( pEntry && IsSelected( pEntry ) );
 }
 

Reply via email to