Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwindowsuiatableprovider.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include <QtGui/qtguiglobal.h>
6#if QT_CONFIG(accessibility)
7
8#include "qwindowsuiatableprovider.h"
9#include "qwindowsuiamainprovider.h"
10#include "qwindowsuiautils.h"
11#include "qwindowscontext.h"
12
13#include <QtGui/qaccessible.h>
14#include <QtCore/qloggingcategory.h>
15#include <QtCore/qstring.h>
16
17QT_BEGIN_NAMESPACE
18
19using namespace QWindowsUiAutomation;
20
21
22QWindowsUiaTableProvider::QWindowsUiaTableProvider(QAccessible::Id id) :
23 QWindowsUiaBaseProvider(id)
24{
25}
26
27QWindowsUiaTableProvider::~QWindowsUiaTableProvider()
28{
29}
30
31// Gets the providers for all the row headers in the table.
32HRESULT STDMETHODCALLTYPE QWindowsUiaTableProvider::GetRowHeaders(SAFEARRAY **pRetVal)
33{
34 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
35
36 if (!pRetVal)
37 return E_INVALIDARG;
38 *pRetVal = nullptr;
39
40 QAccessibleInterface *accessible = accessibleInterface();
41 if (!accessible)
42 return UIA_E_ELEMENTNOTAVAILABLE;
43
44 QAccessibleTableInterface *tableInterface = accessible->tableInterface();
45 if (!tableInterface)
46 return UIA_E_ELEMENTNOTAVAILABLE;
47
48 QList<QAccessibleInterface *> headers;
49
50 for (int i = 0; i < tableInterface->rowCount(); ++i) {
51 if (QAccessibleInterface *cell = tableInterface->cellAt(i, 0)) {
52 if (QAccessibleTableCellInterface *tableCellInterface = cell->tableCellInterface()) {
53 headers.append(tableCellInterface->rowHeaderCells());
54 }
55 }
56 }
57 if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
58 for (LONG i = 0; i < headers.size(); ++i) {
59 if (ComPtr<IRawElementProviderSimple> provider =
60 QWindowsUiaMainProvider::providerForAccessible(headers.at(i))) {
61 SafeArrayPutElement(*pRetVal, &i, provider.Get());
62 }
63 }
64 }
65 return S_OK;
66}
67
68// Gets the providers for all the column headers in the table.
69HRESULT STDMETHODCALLTYPE QWindowsUiaTableProvider::GetColumnHeaders(SAFEARRAY **pRetVal)
70{
71 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
72
73 if (!pRetVal)
74 return E_INVALIDARG;
75 *pRetVal = nullptr;
76
77 QAccessibleInterface *accessible = accessibleInterface();
78 if (!accessible)
79 return UIA_E_ELEMENTNOTAVAILABLE;
80
81 QAccessibleTableInterface *tableInterface = accessible->tableInterface();
82 if (!tableInterface)
83 return UIA_E_ELEMENTNOTAVAILABLE;
84
85 QList<QAccessibleInterface *> headers;
86
87 for (int i = 0; i < tableInterface->columnCount(); ++i) {
88 if (QAccessibleInterface *cell = tableInterface->cellAt(0, i)) {
89 if (QAccessibleTableCellInterface *tableCellInterface = cell->tableCellInterface()) {
90 headers.append(tableCellInterface->columnHeaderCells());
91 }
92 }
93 }
94 if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
95 for (LONG i = 0; i < headers.size(); ++i) {
96 if (ComPtr<IRawElementProviderSimple> provider =
97 QWindowsUiaMainProvider::providerForAccessible(headers.at(i))) {
98 SafeArrayPutElement(*pRetVal, &i, provider.Get());
99 }
100 }
101 }
102 return S_OK;
103}
104
105// Returns the primary direction of traversal for the table.
106HRESULT STDMETHODCALLTYPE QWindowsUiaTableProvider::get_RowOrColumnMajor(enum RowOrColumnMajor *pRetVal)
107{
108 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
109
110 if (!pRetVal)
111 return E_INVALIDARG;
112 *pRetVal = RowOrColumnMajor_Indeterminate;
113 return S_OK;
114}
115
116QT_END_NAMESPACE
117
118#endif // QT_CONFIG(accessibility)