vcl/qt5/QtAccessibleWidget.cxx |   40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

New commits:
commit 12f96c3d0f61018cfa83c940765311aa9015f60a
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Aug 4 13:27:32 2022 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Aug 4 19:34:50 2022 +0200

    qt a11y: implement QtAccessibleWidget::{row,column}HeaderCells
    
    Implement these methods inherited from
    `QAccessibleTableCellInterface` by retrieving all
    row/column headers from the table (= cell's parent object) and
    only returning those for the row/column that the cell itself is
    in.
    
    Tested with Accerciser and the qt6 VCL plugin as follows:
    
    1) start LO Writer, "Table" -> "Insert Table"
    2) select to create table with  2 rows, 2 columns
    3) make sure "Heading" is checked, "Heading rows": 1
    4) "Insert"
    5) in the first row, type "First heading" into first column, "Second 
heading" into second column
    5) start Accerciser
    7) select the table element in Accerciser's treeview of the a11y
       hierarchy
    8) type these in Accerciser's IPython console:
    
        In [10]: acc.queryTable().getColumnHeader(0).name
        Out[10]: 'A1'
        In [11]: 
acc.queryTable().getColumnHeader(0).get_child_at_index(0).queryText().getText(0,
 -1)
        Out[11]: 'First heading'
        In [12]: acc.queryTable().getColumnHeader(1).name
        Out[12]: 'B1'
        In [13]: 
acc.queryTable().getColumnHeader(1).get_child_at_index(0).queryText().getText(0,
 -1)
        Out[13]: 'Second heading'
    
    Change-Id: I69b9bd10bfe4076de9e4a05fe4aff97d1bfa4118
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137794
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx
index 0e9c083043a2..493292537050 100644
--- a/vcl/qt5/QtAccessibleWidget.cxx
+++ b/vcl/qt5/QtAccessibleWidget.cxx
@@ -1371,8 +1371,24 @@ bool QtAccessibleWidget::unselectRow(int row)
 // QAccessibleTableCellInterface
 QList<QAccessibleInterface*> QtAccessibleWidget::columnHeaderCells() const
 {
-    SAL_WARN("vcl.qt", "Unsupported 
QAccessibleTableCellInterface::columnHeaderCells");
-    return QList<QAccessibleInterface*>();
+    Reference<XAccessibleTable> xTable = getAccessibleTableForParent();
+    if (!xTable.is())
+        return QList<QAccessibleInterface*>();
+
+    Reference<XAccessibleTable> xHeaders = 
xTable->getAccessibleColumnHeaders();
+    if (!xHeaders.is())
+        return QList<QAccessibleInterface*>();
+
+    const sal_Int32 nCol = columnIndex();
+    QList<QAccessibleInterface*> aHeaderCells;
+    for (sal_Int32 nRow = 0; nRow < xHeaders->getAccessibleRowCount(); nRow++)
+    {
+        Reference<XAccessible> xCell = xHeaders->getAccessibleCellAt(nRow, 
nCol);
+        QAccessibleInterface* pInterface
+            = QAccessible::queryAccessibleInterface(new QtXAccessible(xCell));
+        aHeaderCells.push_back(pInterface);
+    }
+    return aHeaderCells;
 }
 
 int QtAccessibleWidget::columnIndex() const
@@ -1421,8 +1437,24 @@ int QtAccessibleWidget::columnExtent() const
 
 QList<QAccessibleInterface*> QtAccessibleWidget::rowHeaderCells() const
 {
-    SAL_WARN("vcl.qt", "Unsupported 
QAccessibleTableCellInterface::rowHeaderCells");
-    return QList<QAccessibleInterface*>();
+    Reference<XAccessibleTable> xTable = getAccessibleTableForParent();
+    if (!xTable.is())
+        return QList<QAccessibleInterface*>();
+
+    Reference<XAccessibleTable> xHeaders = xTable->getAccessibleRowHeaders();
+    if (!xHeaders.is())
+        return QList<QAccessibleInterface*>();
+
+    const sal_Int32 nRow = rowIndex();
+    QList<QAccessibleInterface*> aHeaderCells;
+    for (sal_Int32 nCol = 0; nCol < xHeaders->getAccessibleColumnCount(); 
nCol++)
+    {
+        Reference<XAccessible> xCell = xHeaders->getAccessibleCellAt(nRow, 
nCol);
+        QAccessibleInterface* pInterface
+            = QAccessible::queryAccessibleInterface(new QtXAccessible(xCell));
+        aHeaderCells.push_back(pInterface);
+    }
+    return aHeaderCells;
 }
 
 int QtAccessibleWidget::rowExtent() const

Reply via email to