[Libreoffice-commits] core.git: vcl/inc vcl/qt5
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Oct 31 07:41:30 UTC 2018
vcl/inc/qt5/Qt5AccessibleWidget.hxx | 24 ++++++
vcl/inc/qt5/Qt5Tools.hxx | 14 +++
vcl/qt5/Qt5AccessibleWidget.cxx | 139 ++++++++++++++++++++++++++++++++++++
3 files changed, 176 insertions(+), 1 deletion(-)
New commits:
commit aca430292fc287e110fe3a7a91c6a61371ab8689
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue Oct 30 20:58:01 2018 +0100
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Wed Oct 31 08:41:02 2018 +0100
qt5 a11y: Implement QAccessibleTableInterface
Change-Id: Ic632a2253afb960cda43f84905dd519e9052c0eb
Reviewed-on: https://gerrit.libreoffice.org/62668
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/vcl/inc/qt5/Qt5AccessibleWidget.hxx b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
index e358f966b622..af4b3c858983 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/QAccessibleTableInterface>
#include <QtGui/QAccessibleTextInterface>
#include <QtGui/QAccessibleValueInterface>
#include <QtGui/QColor>
@@ -33,6 +34,7 @@ class VCLPLUG_QT5_PUBLIC Qt5AccessibleWidget : public QObject,
public QAccessibleInterface,
public QAccessibleActionInterface,
public QAccessibleTextInterface,
+ public QAccessibleTableInterface,
public QAccessibleValueInterface
{
Q_OBJECT
@@ -101,6 +103,28 @@ public:
QVariant minimumValue() const override;
void setCurrentValue(const QVariant& value) override;
+ // QAccessibleTableInterface
+ virtual QAccessibleInterface* caption() const override;
+ virtual QAccessibleInterface* cellAt(int row, int column) const override;
+ virtual int columnCount() const override;
+ virtual QString columnDescription(int column) const override;
+ virtual bool isColumnSelected(int column) const override;
+ virtual bool isRowSelected(int row) const override;
+ virtual void modelChange(QAccessibleTableModelChangeEvent* event) override;
+ virtual int rowCount() const override;
+ virtual QString rowDescription(int row) const override;
+ virtual bool selectColumn(int column) override;
+ virtual bool selectRow(int row) override;
+ virtual int selectedCellCount() const override;
+ virtual QList<QAccessibleInterface*> selectedCells() const override;
+ virtual int selectedColumnCount() const override;
+ virtual QList<int> selectedColumns() const override;
+ virtual int selectedRowCount() const override;
+ virtual QList<int> selectedRows() const override;
+ virtual QAccessibleInterface* summary() const override;
+ virtual bool unselectColumn(int column) override;
+ virtual bool unselectRow(int row) override;
+
// Factory
static QAccessibleInterface* customFactory(const QString& classname, QObject* object);
diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx
index c919b401e191..57bf94793955 100644
--- a/vcl/inc/qt5/Qt5Tools.hxx
+++ b/vcl/inc/qt5/Qt5Tools.hxx
@@ -19,9 +19,9 @@
#pragma once
-#include <QtCore/QString>
#include <QtCore/QRect>
#include <QtCore/QSize>
+#include <QtCore/QString>
#include <QtGui/QImage>
#include <rtl/string.hxx>
@@ -29,6 +29,8 @@
#include <tools/color.hxx>
#include <tools/gen.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
#include <memory>
inline OUString toOUString(const QString& s)
@@ -62,6 +64,16 @@ inline QColor toQColor(const Color& rColor)
255 - rColor.GetTransparency());
}
+inline QList<int> toQList(const css::uno::Sequence<sal_Int32>& aSequence)
+{
+ QList<int> aList;
+ for (sal_Int32 i = 0; i < aSequence.getLength(); i++)
+ {
+ aList.append(aSequence[i]);
+ }
+ return aList;
+}
+
static constexpr QImage::Format Qt5_DefaultFormat32 = QImage::Format_ARGB32;
inline QImage::Format getBitFormat(sal_uInt16 nBitCount)
diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index b75cda8cc454..bf066f96df54 100644
--- a/vcl/qt5/Qt5AccessibleWidget.cxx
+++ b/vcl/qt5/Qt5AccessibleWidget.cxx
@@ -39,6 +39,7 @@
#include <com/sun/star/accessibility/XAccessibleKeyBinding.hpp>
#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
#include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
+#include <com/sun/star/accessibility/XAccessibleTable.hpp>
#include <com/sun/star/accessibility/XAccessibleText.hpp>
#include <com/sun/star/accessibility/XAccessibleValue.hpp>
#include <com/sun/star/awt/FontWeight.hpp>
@@ -624,6 +625,8 @@ void* Qt5AccessibleWidget::interface_cast(QAccessible::InterfaceType t)
return static_cast<QAccessibleTextInterface*>(this);
if (t == QAccessible::ValueInterface)
return static_cast<QAccessibleValueInterface*>(this);
+ if (t == QAccessible::TableInterface)
+ return static_cast<QAccessibleTableInterface*>(this);
return nullptr;
}
@@ -638,6 +641,8 @@ void Qt5AccessibleWidget::setText(QAccessible::Text /* t */, const QString& /* t
QAccessibleInterface* Qt5AccessibleWidget::childAt(int x, int y) const
{
+ if (!m_xAccessible.is())
+ return nullptr;
Reference<XAccessibleComponent> xAccessibleComponent(m_xAccessible->getAccessibleContext(),
UNO_QUERY);
return QAccessible::queryAccessibleInterface(
@@ -924,4 +929,138 @@ void Qt5AccessibleWidget::setCurrentValue(const QVariant& value)
xValue->setCurrentValue(Any(value.toDouble()));
}
+// QAccessibleTable
+QAccessibleInterface* Qt5AccessibleWidget::caption() const
+{
+ Reference<XAccessibleTable> xTable(m_xAccessible->getAccessibleContext(), UNO_QUERY);
+ if (!xTable.is())
+ return nullptr;
+ return QAccessible::queryAccessibleInterface(
+ new Qt5XAccessible(xTable->getAccessibleCaption()));
+}
+
+QAccessibleInterface* Qt5AccessibleWidget::cellAt(int row, int column) const
+{
+ Reference<XAccessibleTable> xTable(m_xAccessible->getAccessibleContext(), UNO_QUERY);
+ if (!xTable.is())
+ return nullptr;
+ return QAccessible::queryAccessibleInterface(
+ new Qt5XAccessible(xTable->getAccessibleCellAt(row, column)));
+}
+
+int Qt5AccessibleWidget::columnCount() const
+{
+ Reference<XAccessibleTable> xTable(m_xAccessible->getAccessibleContext(), UNO_QUERY);
+ if (!xTable.is())
+ return 0;
+ return xTable->getAccessibleColumnCount();
+}
+
+QString Qt5AccessibleWidget::columnDescription(int column) const
+{
+ Reference<XAccessibleTable> xTable(m_xAccessible->getAccessibleContext(), UNO_QUERY);
+ if (!xTable.is())
+ return QString();
+ return toQString(xTable->getAccessibleColumnDescription(column));
+}
+
+bool Qt5AccessibleWidget::isColumnSelected(int /* column */) const { return true; }
+
+bool Qt5AccessibleWidget::isRowSelected(int /* row */) const { return true; }
+
+void Qt5AccessibleWidget::modelChange(QAccessibleTableModelChangeEvent* event) {}
+
+int Qt5AccessibleWidget::rowCount() const
+{
+ Reference<XAccessibleTable> xTable(m_xAccessible->getAccessibleContext(), UNO_QUERY);
+ if (!xTable.is())
+ return 0;
+ return xTable->getAccessibleRowCount();
+}
+
+QString Qt5AccessibleWidget::rowDescription(int row) const
+{
+ Reference<XAccessibleTable> xTable(m_xAccessible->getAccessibleContext(), UNO_QUERY);
+ if (!xTable.is())
+ return QString();
+ return toQString(xTable->getAccessibleRowDescription(row));
+}
+
+bool Qt5AccessibleWidget::selectColumn(int /* column */)
+{
+ SAL_INFO("vcl.qt5", "Unsupported QAccessibleTableInterface::selectColumn");
+ return false;
+}
+
+bool Qt5AccessibleWidget::selectRow(int /* row */)
+{
+ SAL_INFO("vcl.qt5", "Unsupported QAccessibleTableInterface::selectRow");
+ return false;
+}
+
+int Qt5AccessibleWidget::selectedCellCount() const
+{
+ SAL_INFO("vcl.qt5", "Unsupported QAccessibleTableInterface::selectedCellCount");
+ return 0;
+}
+
+QList<QAccessibleInterface*> Qt5AccessibleWidget::selectedCells() const
+{
+ SAL_INFO("vcl.qt5", "Unsupported QAccessibleTableInterface::selectedCells");
+ return QList<QAccessibleInterface*>();
+}
+
+int Qt5AccessibleWidget::selectedColumnCount() const
+{
+ Reference<XAccessibleTable> xTable(m_xAccessible->getAccessibleContext(), UNO_QUERY);
+ if (!xTable.is())
+ return 0;
+ return xTable->getSelectedAccessibleColumns().getLength();
+}
+
+QList<int> Qt5AccessibleWidget::selectedColumns() const
+{
+ Reference<XAccessibleTable> xTable(m_xAccessible->getAccessibleContext(), UNO_QUERY);
+ if (!xTable.is())
+ return QList<int>();
+ return toQList(xTable->getSelectedAccessibleColumns());
+}
+
+int Qt5AccessibleWidget::selectedRowCount() const
+{
+ Reference<XAccessibleTable> xTable(m_xAccessible->getAccessibleContext(), UNO_QUERY);
+ if (!xTable.is())
+ return 0;
+ return xTable->getSelectedAccessibleRows().getLength();
+}
+
+QList<int> Qt5AccessibleWidget::selectedRows() const
+{
+ Reference<XAccessibleTable> xTable(m_xAccessible->getAccessibleContext(), UNO_QUERY);
+ if (!xTable.is())
+ return QList<int>();
+ return toQList(xTable->getSelectedAccessibleRows());
+}
+
+QAccessibleInterface* Qt5AccessibleWidget::summary() const
+{
+ Reference<XAccessibleTable> xTable(m_xAccessible->getAccessibleContext(), UNO_QUERY);
+ if (!xTable.is())
+ return nullptr;
+ return QAccessible::queryAccessibleInterface(
+ new Qt5XAccessible(xTable->getAccessibleSummary()));
+}
+
+bool Qt5AccessibleWidget::unselectColumn(int column)
+{
+ SAL_INFO("vcl.qt5", "Unsupported QAccessibleTableInterface::unselectColumn");
+ return false;
+}
+
+bool Qt5AccessibleWidget::unselectRow(int row)
+{
+ SAL_INFO("vcl.qt5", "Unsupported QAccessibleTableInterface::unselectRow");
+ return false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list