accessibility/source/extended/AccessibleBrowseBoxTable.cxx |   19 ++++++++-----
 1 file changed, 12 insertions(+), 7 deletions(-)

New commits:
commit bf15445b7102a4e2bea2f96891093bc4bf07c4c6
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Aug 23 17:46:37 2023 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Aug 23 22:21:59 2023 +0200

    tdf#99609 tdf#156473 a11y: Check whether row header exists
    
    Don't allow using `BBINDEX_ROWHEADERBAR` as the
    child index unconditionally, but only if the
    browse box actually has a row header.
    
    An `AccessibleTabListBox` doesn't have a header
    and instead returns the table when requesting the
    child at index 1 (`BBINDEX_ROWHEADERBAR`).
    
    Now that row headers are propagated to the Windows
    platform accessibility layer with
    
        commit 2b30d37bd555188733a006e1a5796461ab11d326
        Date:   Thu Aug 3 15:48:48 2023 +0100
    
            tdf#156473 wina11y: Fix invalid write due to row/col mismatch
    
    in place, NVDA confusingly started announcing all cells
    in the currently selected row as row headers for
    the currently selected cell in the Expert Configuration
    dialog, because of the table being returned without
    this change in place (while the cells in that table don't
    actually have any row headers).
    
    Related backtrace of how the table was returned
    for the row headers:
    
            1   accessibility::AccessibleTabListBox::getAccessibleChild         
 accessibletablistbox.cxx     90   0x7fffb8ab64bb
            2   accessibility::AccessibleBrowseBoxTable::implGetHeaderBar       
 AccessibleBrowseBoxTable.cxx 214  0x7fffb8a7e241
            3   
accessibility::AccessibleBrowseBoxTable::getAccessibleRowHeaders 
AccessibleBrowseBoxTable.cxx 116  0x7fffb8a7da02
            4   QtAccessibleWidget::rowHeaderCells                              
 QtAccessibleWidget.cxx       1808 0x7fffe3e51e97
            5   AtSpiAdaptor::tableCellInterface                                
 atspiadaptor.cpp             2801 0x7fffe2cee526
            6   AtSpiAdaptor::handleMessage                                     
 atspiadaptor.cpp             1450 0x7fffe2cde6ee
            7   QDBusConnectionPrivate::activateObject                          
 qdbusintegrator.cpp          1416 0x7fffe14cc216
            8   QDBusActivateObjectEvent::placeMetaCall                         
 qdbusintegrator.cpp          1572 0x7fffe14cceba
            9   QObject::event                                                  
 qobject.cpp                  1438 0x7fffe3621280
            10  QApplicationPrivate::notify_helper                              
 qapplication.cpp             3287 0x7fffe1ba2414
            11  QApplication::notify                                            
 qapplication.cpp             3238 0x7fffe1ba2224
            12  QCoreApplication::notifyInternal2                               
 qcoreapplication.cpp         1123 0x7fffe35a3c34
            13  QCoreApplication::sendEvent                                     
 qcoreapplication.cpp         1557 0x7fffe35a46f5
            14  QCoreApplicationPrivate::sendPostedEvents                       
 qcoreapplication.cpp         1924 0x7fffe35a55b2
            15  QCoreApplication::sendPostedEvents                              
 qcoreapplication.cpp         1781 0x7fffe35a4eba
            16  postEventSourceDispatch                                         
 qeventdispatcher_glib.cpp    240  0x7fffe39b26d3
            17  ??                                                              
                                   0x7fffe97135b4
            18  ??                                                              
                                   0x7fffe9716607
            19  g_main_context_iteration                                        
                                   0x7fffe9716bfc
            20  QEventDispatcherGlib::processEvents                             
 qeventdispatcher_glib.cpp    390  0x7fffe39b2f67
            ... <More>
    
    Also add an assert that
    `AccessibleBrowseBoxTable::implGetHeaderBar` only
    gets called with indices for row/col header, not
    arbitrary integers.
    
    Change-Id: Id7ebab9bfa8a7f05cb43da1bf5756e5980f4ed20
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156012
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/accessibility/source/extended/AccessibleBrowseBoxTable.cxx 
b/accessibility/source/extended/AccessibleBrowseBoxTable.cxx
index cdf918359a64..09c7448be4bd 100644
--- a/accessibility/source/extended/AccessibleBrowseBoxTable.cxx
+++ b/accessibility/source/extended/AccessibleBrowseBoxTable.cxx
@@ -205,19 +205,24 @@ AbsoluteScreenPixelRectangle 
AccessibleBrowseBoxTable::implGetBoundingBoxOnScree
 Reference< XAccessibleTable > AccessibleBrowseBoxTable::implGetHeaderBar(
         sal_Int32 nChildIndex )
 {
+    assert(nChildIndex == vcl::BBINDEX_ROWHEADERBAR || nChildIndex == 
vcl::BBINDEX_COLUMNHEADERBAR);
+
     Reference< XAccessible > xRet;
     Reference< XAccessibleContext > xContext( mxParent, uno::UNO_QUERY );
     if( xContext.is() )
     {
-        try
-        {
-            xRet = xContext->getAccessibleChild( nChildIndex );
-        }
-        catch (const lang::IndexOutOfBoundsException&)
+        if (nChildIndex == vcl::BBINDEX_COLUMNHEADERBAR || 
mpBrowseBox->HasRowHeader())
         {
-            OSL_FAIL( "implGetHeaderBar - wrong child index" );
+            try
+            {
+                xRet = xContext->getAccessibleChild( nChildIndex );
+            }
+            catch (const lang::IndexOutOfBoundsException&)
+            {
+                OSL_FAIL( "implGetHeaderBar - wrong child index" );
+            }
+            // RuntimeException goes to caller
         }
-        // RuntimeException goes to caller
     }
     return Reference< XAccessibleTable >( xRet, uno::UNO_QUERY );
 }

Reply via email to