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 QObject,
40 public QAccessibleInterface,
41 public QAccessibleActionInterface,
42 public QAccessibleTextInterface,
43 public QAccessibleEditableTextInterface,
44 public QAccessibleTableCellInterface,
45 public QAccessibleTableInterface,
46 public QAccessibleValueInterface
47{
48 Q_OBJECT
49
50public:
51 QtAccessibleWidget(const css::uno::Reference<css::accessibility::XAccessible> xAccessible,
52 QObject* pObject);
53 QWindow* window() const override;
54 int childCount() const override;
55 int indexOfChild(const QAccessibleInterface* child) const override;
56 QVector<QPair<QAccessibleInterface*, QAccessible::Relation>>
57 relations(QAccessible::Relation match = QAccessible::AllRelations) const override;
58 QAccessibleInterface* focusChild() const override;
59
60 QRect rect() const override;
61
62 QAccessibleInterface* parent() const override;
63 QAccessibleInterface* child(int index) const override;
64
65 QString text(QAccessible::Text t) const override;
66 QAccessible::Role role() const override;
67 QAccessible::State state() const override;
68
69 QColor foregroundColor() const override;
70 QColor backgroundColor() const override;
71
72 bool isValid() const override;
73 QObject* object() const override;
74 void setText(QAccessible::Text t, const QString& text) override;
75 QAccessibleInterface* childAt(int x, int y) const override;
76
77 void* interface_cast(QAccessible::InterfaceType t) override;
78
79 // QAccessibleActionInterface
80 QStringList actionNames() const override;
81 void doAction(const QString& actionName) override;
82 QStringList keyBindingsForAction(const QString& actionName) const override;
83
84 // QAccessibleTextInterface
85 void addSelection(int startOffset, int endOffset) override;
86 QString attributes(int offset, int* startOffset, int* endOffset) const override;
87 int characterCount() const override;
88 QRect characterRect(int offset) const override;
89 int cursorPosition() const override;
90 int offsetAtPoint(const QPoint& point) const override;
91 void removeSelection(int selectionIndex) override;
92 void scrollToSubstring(int startIndex, int endIndex) override;
93 void selection(int selectionIndex, int* startOffset, int* endOffset) const override;
94 int selectionCount() const override;
95 void setCursorPosition(int position) override;
96 void setSelection(int selectionIndex, int startOffset, int endOffset) override;
97 QString text(int startOffset, int endOffset) const override;
98 QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType,
99 int* startOffset, int* endOffset) const override;
100 QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, int* startOffset,
101 int* endOffset) const override;
102 QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType,
103 int* startOffset, int* endOffset) const override;
104
105 // QAccessibleEditableTextInterface
106 virtual void deleteText(int startOffset, int endOffset) override;
107 virtual void insertText(int offset, const QString& text) override;
108 virtual void replaceText(int startOffset, int endOffset, const QString& text) override;
109
110 // QAccessibleValueInterface
111 QVariant currentValue() const override;
112 QVariant maximumValue() const override;
113 QVariant minimumStepSize() const override;
114 QVariant minimumValue() const override;
115 void setCurrentValue(const QVariant& value) override;
116
117 // QAccessibleTableInterface
118 virtual QAccessibleInterface* caption() const override;
119 virtual QAccessibleInterface* cellAt(int row, int column) const override;
120 virtual int columnCount() const override;
121 virtual QString columnDescription(int column) const override;
122 virtual bool isColumnSelected(int column) const override;
123 virtual bool isRowSelected(int row) const override;
124 virtual void modelChange(QAccessibleTableModelChangeEvent* event) override;
125 virtual int rowCount() const override;
126 virtual QString rowDescription(int row) const override;
127 virtual bool selectColumn(int column) override;
128 virtual bool selectRow(int row) override;
129 virtual int selectedCellCount() const override;
130 virtual QList<QAccessibleInterface*> selectedCells() const override;
131 virtual int selectedColumnCount() const override;
132 virtual QList<int> selectedColumns() const override;
133 virtual int selectedRowCount() const override;
134 virtual QList<int> selectedRows() const override;
135 virtual QAccessibleInterface* summary() const override;
136 virtual bool unselectColumn(int column) override;
137 virtual bool unselectRow(int row) override;
138
139 // QAccessibleTableCellInterface
140 virtual QList<QAccessibleInterface*> columnHeaderCells() const override;
141 virtual int columnIndex() const override;
142 virtual bool isSelected() const override;
143 virtual int columnExtent() const override;
144 virtual QList<QAccessibleInterface*> rowHeaderCells() const override;
145 virtual int rowExtent() const override;
146 virtual int rowIndex() const override;
147 virtual QAccessibleInterface* table() const override;
148
149 // Factory
150 static QAccessibleInterface* customFactory(const QString& classname, QObject* object);
151
152private:
153 css::uno::Reference<css::accessibility::XAccessible> m_xAccessible;
154 css::uno::Reference<css::accessibility::XAccessibleContext> getAccessibleContextImpl() const;
155 css::uno::Reference<css::accessibility::XAccessibleTable> getAccessibleTableForParent() const;
156
157 template <class Interface> bool accessibleProvidesInterface() const
158 {
159 css::uno::Reference<css::accessibility::XAccessibleContext> xContext
161 css::uno::Reference<Interface> xInterface(xContext, css::uno::UNO_QUERY);
162 return xInterface.is();
163 }
164
165 QObject* m_pObject;
166};
167
168/* 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
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
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 QList< QAccessibleInterface * > columnHeaderCells() const override
QString attributes(int offset, int *startOffset, int *endOffset) const 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
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
static QAccessibleInterface * customFactory(const QString &classname, QObject *object)
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 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