LibreOffice Module vcl (master) 1
qt5/QtAccessibleWidget.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#pragma once
11
12#include <vclpluginapi.h>
13
14#include <QtCore/QObject>
15#include <QtCore/QPair>
16#include <QtCore/QString>
17#include <QtCore/QStringList>
18#include <QtCore/QVector>
19#include <QtGui/QAccessible>
20#include <QtGui/QAccessibleActionInterface>
21#include <QtGui/QAccessibleInterface>
22#include <QtGui/QAccessibleTableCellInterface>
23#include <QtGui/QAccessibleTableInterface>
24#include <QtGui/QAccessibleTextInterface>
25#include <QtGui/QAccessibleValueInterface>
26#include <QtGui/QColor>
27#include <QtGui/QWindow>
28
29#include <com/sun/star/accessibility/XAccessible.hpp>
30
32{
33class XAccessibleTable;
34}
35
36class QtFrame;
37class QtWidget;
38
39class QtAccessibleWidget final : public QAccessibleInterface,
40 public QAccessibleActionInterface,
41 public QAccessibleTextInterface,
42 public QAccessibleEditableTextInterface,
43#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
44 public QAccessibleSelectionInterface,
45#endif
46 public QAccessibleTableCellInterface,
47 public QAccessibleTableInterface,
48 public QAccessibleValueInterface
49{
50public:
51 QtAccessibleWidget(const css::uno::Reference<css::accessibility::XAccessible> xAccessible,
52 QObject* pObject);
53
54 void invalidate();
55
56 // QAccessibleInterface
57 QWindow* window() const override;
58 int childCount() const override;
59 int indexOfChild(const QAccessibleInterface* child) const override;
60 QVector<QPair<QAccessibleInterface*, QAccessible::Relation>>
61 relations(QAccessible::Relation match = QAccessible::AllRelations) const override;
62 QAccessibleInterface* focusChild() const override;
63
64 QRect rect() const override;
65
66 QAccessibleInterface* parent() const override;
67 QAccessibleInterface* child(int index) const override;
68
69 QString text(QAccessible::Text t) const override;
70 QAccessible::Role role() const override;
71 QAccessible::State state() const override;
72
73 QColor foregroundColor() const override;
74 QColor backgroundColor() const override;
75
76 bool isValid() const override;
77 QObject* object() const override;
78 void setText(QAccessible::Text t, const QString& text) override;
79 QAccessibleInterface* childAt(int x, int y) const override;
80
81 void* interface_cast(QAccessible::InterfaceType t) override;
82
83 // QAccessibleActionInterface
84 QStringList actionNames() const override;
85 void doAction(const QString& actionName) override;
86 QStringList keyBindingsForAction(const QString& actionName) const override;
87
88 // QAccessibleTextInterface
89 void addSelection(int startOffset, int endOffset) override;
90 QString attributes(int offset, int* startOffset, int* endOffset) const override;
91 int characterCount() const override;
92 QRect characterRect(int offset) const override;
93 int cursorPosition() const override;
94 int offsetAtPoint(const QPoint& point) const override;
95 void removeSelection(int selectionIndex) override;
96 void scrollToSubstring(int startIndex, int endIndex) override;
97 void selection(int selectionIndex, int* startOffset, int* endOffset) const override;
98 int selectionCount() const override;
99 void setCursorPosition(int position) override;
100 void setSelection(int selectionIndex, int startOffset, int endOffset) override;
101 QString text(int startOffset, int endOffset) const override;
102 QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType,
103 int* startOffset, int* endOffset) const override;
104 QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, int* startOffset,
105 int* endOffset) const override;
106 QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType,
107 int* startOffset, int* endOffset) const override;
108
109 // QAccessibleEditableTextInterface
110 virtual void deleteText(int startOffset, int endOffset) override;
111 virtual void insertText(int offset, const QString& text) override;
112 virtual void replaceText(int startOffset, int endOffset, const QString& text) override;
113
114 // QAccessibleValueInterface
115 QVariant currentValue() const override;
116 QVariant maximumValue() const override;
117 QVariant minimumStepSize() const override;
118 QVariant minimumValue() const override;
119 void setCurrentValue(const QVariant& value) override;
120
121 // QAccessibleTableInterface
122 virtual QAccessibleInterface* caption() const override;
123 virtual QAccessibleInterface* cellAt(int row, int column) const override;
124 virtual int columnCount() const override;
125 virtual QString columnDescription(int column) const override;
126 virtual bool isColumnSelected(int column) const override;
127 virtual bool isRowSelected(int row) const override;
128 virtual void modelChange(QAccessibleTableModelChangeEvent* event) override;
129 virtual int rowCount() const override;
130 virtual QString rowDescription(int row) const override;
131 virtual bool selectColumn(int column) override;
132 virtual bool selectRow(int row) override;
133 virtual int selectedCellCount() const override;
134 virtual QList<QAccessibleInterface*> selectedCells() const override;
135 virtual int selectedColumnCount() const override;
136 virtual QList<int> selectedColumns() const override;
137 virtual int selectedRowCount() const override;
138 virtual QList<int> selectedRows() const override;
139 virtual QAccessibleInterface* summary() const override;
140 virtual bool unselectColumn(int column) override;
141 virtual bool unselectRow(int row) override;
142
143 // QAccessibleTableCellInterface
144 virtual QList<QAccessibleInterface*> columnHeaderCells() const override;
145 virtual int columnIndex() const override;
146 virtual bool isSelected() const override;
147 virtual int columnExtent() const override;
148 virtual QList<QAccessibleInterface*> rowHeaderCells() const override;
149 virtual int rowExtent() const override;
150 virtual int rowIndex() const override;
151 virtual QAccessibleInterface* table() const override;
152
153#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
154 // QAccessibleSelectionInterface
155 virtual int selectedItemCount() const override;
156 virtual QList<QAccessibleInterface*> selectedItems() const override;
157 virtual QAccessibleInterface* selectedItem(int selectionIndex) const override;
158 virtual bool isSelected(QAccessibleInterface* item) const override;
159 virtual bool select(QAccessibleInterface* item) override;
160 virtual bool unselect(QAccessibleInterface* item) override;
161 virtual bool selectAll() override;
162 virtual bool clear() override;
163#else
164 // no override, but used in QAccessibleTableInterface methods
165 int selectedItemCount() const;
166 QList<QAccessibleInterface*> selectedItems() const;
167#endif
168
169 // Factory
170 static QAccessibleInterface* customFactory(const QString& classname, QObject* object);
171
172private:
173 css::uno::Reference<css::accessibility::XAccessible> m_xAccessible;
174 css::uno::Reference<css::accessibility::XAccessibleContext> getAccessibleContextImpl() const;
175 css::uno::Reference<css::accessibility::XAccessibleTable> getAccessibleTableForParent() const;
176
177 template <class Interface> bool accessibleProvidesInterface() const
178 {
179 css::uno::Reference<css::accessibility::XAccessibleContext> xContext
181 css::uno::Reference<Interface> xInterface(xContext, css::uno::UNO_QUERY);
182 return xInterface.is();
183 }
184
185 QObject* m_pObject;
186};
187
188/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual QString columnDescription(int column) const override
virtual QList< int > selectedColumns() const override
void setSelection(int selectionIndex, int startOffset, int endOffset) override
int childCount() const override
QRect rect() const override
QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const override
bool accessibleProvidesInterface() const
virtual int selectedRowCount() const override
virtual int rowIndex() const override
virtual bool unselect(QAccessibleInterface *item) override
QString text(QAccessible::Text t) const override
virtual QList< QAccessibleInterface * > selectedCells() const override
QString text(int startOffset, int endOffset) const override
void setCursorPosition(int position) override
QAccessibleInterface * parent() const override
int cursorPosition() const override
virtual bool selectRow(int row) override
QColor backgroundColor() const override
css::uno::Reference< css::accessibility::XAccessibleContext > getAccessibleContextImpl() const
virtual bool isSelected(QAccessibleInterface *item) const override
QStringList actionNames() const override
void doAction(const QString &actionName) override
QWindow * window() const override
bool isValid() const override
QObject * object() const override
virtual bool isColumnSelected(int column) const override
int offsetAtPoint(const QPoint &point) const override
void setText(QAccessible::Text t, const QString &text) override
QVariant currentValue() const override
QRect characterRect(int offset) const override
virtual bool selectAll() override
virtual QList< QAccessibleInterface * > columnHeaderCells() const override
QString attributes(int offset, int *startOffset, int *endOffset) const override
virtual bool clear() override
QVariant maximumValue() const override
QVector< QPair< QAccessibleInterface *, QAccessible::Relation > > relations(QAccessible::Relation match=QAccessible::AllRelations) const override
virtual void insertText(int offset, const QString &text) override
void * interface_cast(QAccessible::InterfaceType t) override
virtual int columnExtent() const override
QAccessible::State state() const override
QtAccessibleWidget(const css::uno::Reference< css::accessibility::XAccessible > xAccessible, QObject *pObject)
QStringList keyBindingsForAction(const QString &actionName) const override
css::uno::Reference< css::accessibility::XAccessibleTable > getAccessibleTableForParent() const
virtual QAccessibleInterface * caption() const override
virtual bool isSelected() const override
QColor foregroundColor() const override
virtual QString rowDescription(int row) const override
QAccessibleInterface * childAt(int x, int y) const override
virtual QList< int > selectedRows() const override
virtual void replaceText(int startOffset, int endOffset, const QString &text) override
int indexOfChild(const QAccessibleInterface *child) const override
virtual int columnIndex() const override
void addSelection(int startOffset, int endOffset) override
virtual bool unselectColumn(int column) override
QAccessibleInterface * child(int index) const override
virtual QList< QAccessibleInterface * > selectedItems() const override
QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const override
void removeSelection(int selectionIndex) override
virtual QAccessibleInterface * cellAt(int row, int column) const override
QVariant minimumStepSize() const override
virtual bool select(QAccessibleInterface *item) override
static QAccessibleInterface * customFactory(const QString &classname, QObject *object)
virtual QAccessibleInterface * selectedItem(int selectionIndex) const override
virtual void modelChange(QAccessibleTableModelChangeEvent *event) override
virtual QAccessibleInterface * summary() const override
QVariant minimumValue() const override
void setCurrentValue(const QVariant &value) override
virtual QList< QAccessibleInterface * > rowHeaderCells() const override
void scrollToSubstring(int startIndex, int endIndex) override
int characterCount() const override
QAccessibleInterface * focusChild() const override
virtual int rowCount() const override
virtual int selectedColumnCount() const override
virtual int rowExtent() const override
virtual bool unselectRow(int row) override
virtual int selectedItemCount() const override
virtual int columnCount() const override
void selection(int selectionIndex, int *startOffset, int *endOffset) const override
virtual int selectedCellCount() const override
virtual void deleteText(int startOffset, int endOffset) override
css::uno::Reference< css::accessibility::XAccessible > m_xAccessible
virtual bool isRowSelected(int row) const override
QAccessible::Role role() const override
virtual bool selectColumn(int column) override
virtual QAccessibleInterface * table() const override
QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const override
int selectionCount() const override