diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2022-08-04 13:27:32 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2022-08-04 19:34:50 +0200 |
commit | 12f96c3d0f61018cfa83c940765311aa9015f60a (patch) | |
tree | 312ac99ee052c0c7a931fdf5906aea5953a36259 | |
parent | c03a262c477b73aa170c6a38703d0930486255e5 (diff) |
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.weghorn@posteo.de>
-rw-r--r-- | vcl/qt5/QtAccessibleWidget.cxx | 40 |
1 files changed, 36 insertions, 4 deletions
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 |