[Libreoffice-commits] core.git: vcl/inc vcl/qt5
Michael Weghorn (via logerrit)
logerrit at kemper.freedesktop.org
Tue Sep 21 19:38:17 UTC 2021
vcl/inc/qt5/Qt5AccessibleWidget.hxx | 18 +++++
vcl/qt5/Qt5AccessibleWidget.cxx | 111 ++++++++++++++++++++++++++++++++++++
2 files changed, 129 insertions(+)
New commits:
commit 6735a37747a3443ebd1c29c870a5eb26990350f2
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Tue Sep 21 14:47:51 2021 +0200
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Tue Sep 21 21:37:40 2021 +0200
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 at 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 at posteo.de>
diff --git a/vcl/inc/qt5/Qt5AccessibleWidget.hxx b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
index 54c967bf0ab1..54dab2e672f5 100644
--- a/vcl/inc/qt5/Qt5AccessibleWidget.hxx
+++ b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
@@ -19,6 +19,7 @@
#include <QtGui/QAccessible>
#include <QtGui/QAccessibleActionInterface>
#include <QtGui/QAccessibleInterface>
+#include <QtGui/QAccessibleTableCellInterface>
#include <QtGui/QAccessibleTableInterface>
#include <QtGui/QAccessibleTextInterface>
#include <QtGui/QAccessibleValueInterface>
@@ -27,6 +28,11 @@
#include <com/sun/star/accessibility/XAccessible.hpp>
+namespace com::sun::star::accessibility
+{
+class XAccessibleTable;
+}
+
class Qt5Frame;
class Qt5Widget;
@@ -35,6 +41,7 @@ class Qt5AccessibleWidget final : public QObject,
public QAccessibleActionInterface,
public QAccessibleTextInterface,
public QAccessibleEditableTextInterface,
+ public QAccessibleTableCellInterface,
public QAccessibleTableInterface,
public QAccessibleValueInterface
{
@@ -129,12 +136,23 @@ public:
virtual bool unselectColumn(int column) override;
virtual bool unselectRow(int row) override;
+ // QAccessibleTableCellInterface
+ virtual QList<QAccessibleInterface*> columnHeaderCells() const override;
+ virtual int columnIndex() const override;
+ virtual bool isSelected() const override;
+ virtual int columnExtent() const override;
+ virtual QList<QAccessibleInterface*> rowHeaderCells() const override;
+ virtual int rowExtent() const override;
+ virtual int rowIndex() const override;
+ virtual QAccessibleInterface* table() const override;
+
// Factory
static QAccessibleInterface* customFactory(const QString& classname, QObject* object);
private:
css::uno::Reference<css::accessibility::XAccessible> m_xAccessible;
css::uno::Reference<css::accessibility::XAccessibleContext> getAccessibleContextImpl() const;
+ css::uno::Reference<css::accessibility::XAccessibleTable> getAccessibleTableForParent() const;
QObject* m_pObject;
};
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: */
More information about the Libreoffice-commits
mailing list