1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
12 #include <vclpluginapi.h>
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/QAccessibleTableInterface>
23 #include <QtGui/QAccessibleTextInterface>
24 #include <QtGui/QAccessibleValueInterface>
25 #include <QtGui/QColor>
26 #include <QtGui/QWindow>
28 #include <com/sun/star/accessibility/XAccessible.hpp>
33 class Qt5AccessibleWidget final
: public QObject
,
34 public QAccessibleInterface
,
35 public QAccessibleActionInterface
,
36 public QAccessibleTextInterface
,
37 public QAccessibleEditableTextInterface
,
38 public QAccessibleTableInterface
,
39 public QAccessibleValueInterface
44 Qt5AccessibleWidget(const css::uno::Reference
<css::accessibility::XAccessible
> xAccessible
,
46 QWindow
* window() const override
;
47 int childCount() const override
;
48 int indexOfChild(const QAccessibleInterface
* child
) const override
;
49 QVector
<QPair
<QAccessibleInterface
*, QAccessible::Relation
>>
50 relations(QAccessible::Relation match
= QAccessible::AllRelations
) const override
;
51 QAccessibleInterface
* focusChild() const override
;
53 QRect
rect() const override
;
55 QAccessibleInterface
* parent() const override
;
56 QAccessibleInterface
* child(int index
) const override
;
58 QString
text(QAccessible::Text t
) const override
;
59 QAccessible::Role
role() const override
;
60 QAccessible::State
state() const override
;
62 QColor
foregroundColor() const override
;
63 QColor
backgroundColor() const override
;
65 bool isValid() const override
;
66 QObject
* object() const override
;
67 void setText(QAccessible::Text t
, const QString
& text
) override
;
68 QAccessibleInterface
* childAt(int x
, int y
) const override
;
70 void* interface_cast(QAccessible::InterfaceType t
) override
;
72 // QAccessibleActionInterface
73 QStringList
actionNames() const override
;
74 void doAction(const QString
& actionName
) override
;
75 QStringList
keyBindingsForAction(const QString
& actionName
) const override
;
77 static QAccessibleValueInterface
* valueInterface();
78 static QAccessibleTextInterface
* textInterface();
80 // QAccessibleTextInterface
81 void addSelection(int startOffset
, int endOffset
) override
;
82 QString
attributes(int offset
, int* startOffset
, int* endOffset
) const override
;
83 int characterCount() const override
;
84 QRect
characterRect(int offset
) const override
;
85 int cursorPosition() const override
;
86 int offsetAtPoint(const QPoint
& point
) const override
;
87 void removeSelection(int selectionIndex
) override
;
88 void scrollToSubstring(int startIndex
, int endIndex
) override
;
89 void selection(int selectionIndex
, int* startOffset
, int* endOffset
) const override
;
90 int selectionCount() const override
;
91 void setCursorPosition(int position
) override
;
92 void setSelection(int selectionIndex
, int startOffset
, int endOffset
) override
;
93 QString
text(int startOffset
, int endOffset
) const override
;
94 QString
textAfterOffset(int offset
, QAccessible::TextBoundaryType boundaryType
,
95 int* startOffset
, int* endOffset
) const override
;
96 QString
textAtOffset(int offset
, QAccessible::TextBoundaryType boundaryType
, int* startOffset
,
97 int* endOffset
) const override
;
98 QString
textBeforeOffset(int offset
, QAccessible::TextBoundaryType boundaryType
,
99 int* startOffset
, int* endOffset
) const override
;
101 // QAccessibleEditableTextInterface
102 virtual void deleteText(int startOffset
, int endOffset
) override
;
103 virtual void insertText(int offset
, const QString
& text
) override
;
104 virtual void replaceText(int startOffset
, int endOffset
, const QString
& text
) override
;
106 // QAccessibleValueInterface
107 QVariant
currentValue() const override
;
108 QVariant
maximumValue() const override
;
109 QVariant
minimumStepSize() const override
;
110 QVariant
minimumValue() const override
;
111 void setCurrentValue(const QVariant
& value
) override
;
113 // QAccessibleTableInterface
114 virtual QAccessibleInterface
* caption() const override
;
115 virtual QAccessibleInterface
* cellAt(int row
, int column
) const override
;
116 virtual int columnCount() const override
;
117 virtual QString
columnDescription(int column
) const override
;
118 virtual bool isColumnSelected(int column
) const override
;
119 virtual bool isRowSelected(int row
) const override
;
120 virtual void modelChange(QAccessibleTableModelChangeEvent
* event
) override
;
121 virtual int rowCount() const override
;
122 virtual QString
rowDescription(int row
) const override
;
123 virtual bool selectColumn(int column
) override
;
124 virtual bool selectRow(int row
) override
;
125 virtual int selectedCellCount() const override
;
126 virtual QList
<QAccessibleInterface
*> selectedCells() const override
;
127 virtual int selectedColumnCount() const override
;
128 virtual QList
<int> selectedColumns() const override
;
129 virtual int selectedRowCount() const override
;
130 virtual QList
<int> selectedRows() const override
;
131 virtual QAccessibleInterface
* summary() const override
;
132 virtual bool unselectColumn(int column
) override
;
133 virtual bool unselectRow(int row
) override
;
136 static QAccessibleInterface
* customFactory(const QString
& classname
, QObject
* object
);
139 css::uno::Reference
<css::accessibility::XAccessible
> m_xAccessible
;
140 css::uno::Reference
<css::accessibility::XAccessibleContext
> getAccessibleContextImpl() const;
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */