From 6735a37747a3443ebd1c29c870a5eb26990350f2 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Tue, 21 Sep 2021 14:47:51 +0200 Subject: qt5 a11y: Implement QAccessibleTableCellInterface Let 'Qt5AccessibleWidget' derive from 'QAccessibleTableCellInterface' and implement the most important methods. This is e.g. one of the steps needed to make Orca announce the focused cell in Calc. Since there's no specific XInterface for table cells make use of the fact that a table cell's parent is a table and query information from there, similar to how the following commit does for winaccessibility: commit 97a88e30e2e084ab860635ff4e0a03442d8a12af Author: Michael Weghorn Date: Wed Sep 8 14:37:53 2021 +0100 tdf#100086 tdf#124832 wina11y: Implement IAccessibleTableCell Change-Id: I160bc04f3e4fcf7b77723540aba6945b8fdf36ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122395 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- vcl/qt5/Qt5AccessibleWidget.cxx | 111 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) (limited to 'vcl/qt5') diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx index f49bb59ce0b4..f7d833407a75 100644 --- a/vcl/qt5/Qt5AccessibleWidget.cxx +++ b/vcl/qt5/Qt5AccessibleWidget.cxx @@ -100,6 +100,24 @@ Reference Qt5AccessibleWidget::getAccessibleContextImpl() co return xAc; } +css::uno::Reference +Qt5AccessibleWidget::getAccessibleTableForParent() const +{ + Reference xAcc = getAccessibleContextImpl(); + if (!xAcc.is()) + return nullptr; + + Reference xParent = xAcc->getAccessibleParent(); + if (!xParent.is()) + return nullptr; + + Reference xParentContext = xParent->getAccessibleContext(); + if (!xParentContext.is()) + return nullptr; + + return Reference(xParentContext, UNO_QUERY); +} + QWindow* Qt5AccessibleWidget::window() const { return nullptr; } int Qt5AccessibleWidget::childCount() const @@ -725,6 +743,8 @@ void* Qt5AccessibleWidget::interface_cast(QAccessible::InterfaceType t) return static_cast(this); if (t == QAccessible::ValueInterface) return static_cast(this); + if (t == QAccessible::TableCellInterface) + return static_cast(this); if (t == QAccessible::TableInterface) return static_cast(this); return nullptr; @@ -1343,4 +1363,95 @@ bool Qt5AccessibleWidget::unselectRow(int row) return xTableSelection->unselectRow(row); } +QList Qt5AccessibleWidget::columnHeaderCells() const +{ + SAL_WARN("vcl.qt5", "Unsupported QAccessibleTableCellInterface::columnHeaderCells"); + return QList(); +} + +int Qt5AccessibleWidget::columnIndex() const +{ + Reference xAcc = getAccessibleContextImpl(); + if (!xAcc.is()) + return -1; + + Reference xTable = getAccessibleTableForParent(); + if (!xTable.is()) + return -1; + + const sal_Int32 nIndexInParent = xAcc->getAccessibleIndexInParent(); + return xTable->getAccessibleColumn(nIndexInParent); +} + +bool Qt5AccessibleWidget::isSelected() const +{ + Reference xAcc = getAccessibleContextImpl(); + if (!xAcc.is()) + return false; + + Reference xTable = getAccessibleTableForParent(); + if (!xTable.is()) + return false; + + const sal_Int32 nColumn = columnIndex(); + const sal_Int32 nRow = rowIndex(); + return xTable->isAccessibleSelected(nRow, nColumn); +} + +int Qt5AccessibleWidget::columnExtent() const +{ + Reference xAcc = getAccessibleContextImpl(); + if (!xAcc.is()) + return -1; + + Reference xTable = getAccessibleTableForParent(); + if (!xTable.is()) + return -1; + + const sal_Int32 nColumn = columnIndex(); + const sal_Int32 nRow = rowIndex(); + return xTable->getAccessibleColumnExtentAt(nRow, nColumn); +} + +QList Qt5AccessibleWidget::rowHeaderCells() const +{ + SAL_WARN("vcl.qt5", "Unsupported QAccessibleTableCellInterface::rowHeaderCells"); + return QList(); +} + +int Qt5AccessibleWidget::rowExtent() const +{ + Reference xAcc = getAccessibleContextImpl(); + if (!xAcc.is()) + return -1; + + Reference xTable = getAccessibleTableForParent(); + if (!xTable.is()) + return -1; + + const sal_Int32 nColumn = columnIndex(); + const sal_Int32 nRow = rowIndex(); + return xTable->getAccessibleRowExtentAt(nRow, nColumn); +} + +int Qt5AccessibleWidget::rowIndex() const +{ + Reference xAcc = getAccessibleContextImpl(); + if (!xAcc.is()) + return -1; + + Reference xTable = getAccessibleTableForParent(); + if (!xTable.is()) + return -1; + + const sal_Int32 nIndexInParent = xAcc->getAccessibleIndexInParent(); + return xTable->getAccessibleRow(nIndexInParent); +} + +QAccessibleInterface* Qt5AccessibleWidget::table() const +{ + SAL_WARN("vcl.qt5", "Unsupported QAccessibleTableCellInterface::table"); + return nullptr; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit