summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2021-09-21 14:47:51 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2021-09-21 21:37:40 +0200
commit6735a37747a3443ebd1c29c870a5eb26990350f2 (patch)
tree613808100227a7bf71b820a53bf94eed1b60f16f /vcl/qt5
parent0ae1c36f319b0c84d5e592f44738e67945eab3a1 (diff)
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 <m.weghorn@posteo.de> 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 <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/Qt5AccessibleWidget.cxx111
1 files changed, 111 insertions, 0 deletions
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<XAccessibleContext> Qt5AccessibleWidget::getAccessibleContextImpl() co
return xAc;
}
+css::uno::Reference<css::accessibility::XAccessibleTable>
+Qt5AccessibleWidget::getAccessibleTableForParent() const
+{
+ Reference<XAccessibleContext> xAcc = getAccessibleContextImpl();
+ if (!xAcc.is())
+ return nullptr;
+
+ Reference<XAccessible> xParent = xAcc->getAccessibleParent();
+ if (!xParent.is())
+ return nullptr;
+
+ Reference<XAccessibleContext> xParentContext = xParent->getAccessibleContext();
+ if (!xParentContext.is())
+ return nullptr;
+
+ return Reference<XAccessibleTable>(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<QAccessibleEditableTextInterface*>(this);
if (t == QAccessible::ValueInterface)
return static_cast<QAccessibleValueInterface*>(this);
+ if (t == QAccessible::TableCellInterface)
+ return static_cast<QAccessibleTableCellInterface*>(this);
if (t == QAccessible::TableInterface)
return static_cast<QAccessibleTableInterface*>(this);
return nullptr;
@@ -1343,4 +1363,95 @@ bool Qt5AccessibleWidget::unselectRow(int row)
return xTableSelection->unselectRow(row);
}
+QList<QAccessibleInterface*> Qt5AccessibleWidget::columnHeaderCells() const
+{
+ SAL_WARN("vcl.qt5", "Unsupported QAccessibleTableCellInterface::columnHeaderCells");
+ return QList<QAccessibleInterface*>();
+}
+
+int Qt5AccessibleWidget::columnIndex() const
+{
+ Reference<XAccessibleContext> xAcc = getAccessibleContextImpl();
+ if (!xAcc.is())
+ return -1;
+
+ Reference<XAccessibleTable> xTable = getAccessibleTableForParent();
+ if (!xTable.is())
+ return -1;
+
+ const sal_Int32 nIndexInParent = xAcc->getAccessibleIndexInParent();
+ return xTable->getAccessibleColumn(nIndexInParent);
+}
+
+bool Qt5AccessibleWidget::isSelected() const
+{
+ Reference<XAccessibleContext> xAcc = getAccessibleContextImpl();
+ if (!xAcc.is())
+ return false;
+
+ Reference<XAccessibleTable> 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<XAccessibleContext> xAcc = getAccessibleContextImpl();
+ if (!xAcc.is())
+ return -1;
+
+ Reference<XAccessibleTable> xTable = getAccessibleTableForParent();
+ if (!xTable.is())
+ return -1;
+
+ const sal_Int32 nColumn = columnIndex();
+ const sal_Int32 nRow = rowIndex();
+ return xTable->getAccessibleColumnExtentAt(nRow, nColumn);
+}
+
+QList<QAccessibleInterface*> Qt5AccessibleWidget::rowHeaderCells() const
+{
+ SAL_WARN("vcl.qt5", "Unsupported QAccessibleTableCellInterface::rowHeaderCells");
+ return QList<QAccessibleInterface*>();
+}
+
+int Qt5AccessibleWidget::rowExtent() const
+{
+ Reference<XAccessibleContext> xAcc = getAccessibleContextImpl();
+ if (!xAcc.is())
+ return -1;
+
+ Reference<XAccessibleTable> 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<XAccessibleContext> xAcc = getAccessibleContextImpl();
+ if (!xAcc.is())
+ return -1;
+
+ Reference<XAccessibleTable> 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: */