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
qwindowsuiagridprovider.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 "qwindowsuiagridprovider.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
22QWindowsUiaGridProvider::QWindowsUiaGridProvider(QAccessible::Id id) :
23 QWindowsUiaBaseProvider(id)
24{
25}
26
27QWindowsUiaGridProvider::~QWindowsUiaGridProvider()
28{
29}
30
31// Returns the provider for an item within a table/tree.
32HRESULT STDMETHODCALLTYPE QWindowsUiaGridProvider::GetItem(int row, int column, IRawElementProviderSimple **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 if ((row >= 0) && (row < tableInterface->rowCount()) && (column >= 0) && (column < tableInterface->columnCount())) {
49 if (QAccessibleInterface *cell = tableInterface->cellAt(row, column))
50 *pRetVal = QWindowsUiaMainProvider::providerForAccessible(cell).Detach();
51 }
52 return S_OK;
53}
54
55// Returns the number of rows.
56HRESULT STDMETHODCALLTYPE QWindowsUiaGridProvider::get_RowCount(int *pRetVal)
57{
58 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
59
60 if (!pRetVal)
61 return E_INVALIDARG;
62 *pRetVal = 0;
63
64 QAccessibleInterface *accessible = accessibleInterface();
65 if (!accessible)
66 return UIA_E_ELEMENTNOTAVAILABLE;
67
68 QAccessibleTableInterface *tableInterface = accessible->tableInterface();
69 if (!tableInterface)
70 return UIA_E_ELEMENTNOTAVAILABLE;
71
72 *pRetVal = tableInterface->rowCount();
73 return S_OK;
74}
75
76// Returns the number of columns.
77HRESULT STDMETHODCALLTYPE QWindowsUiaGridProvider::get_ColumnCount(int *pRetVal)
78{
79 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
80
81 if (!pRetVal)
82 return E_INVALIDARG;
83 *pRetVal = 0;
84
85 QAccessibleInterface *accessible = accessibleInterface();
86 if (!accessible)
87 return UIA_E_ELEMENTNOTAVAILABLE;
88
89 QAccessibleTableInterface *tableInterface = accessible->tableInterface();
90 if (!tableInterface)
91 return UIA_E_ELEMENTNOTAVAILABLE;
92
93 *pRetVal = tableInterface->columnCount();
94 return S_OK;
95}
96
97QT_END_NAMESPACE
98
99#endif // QT_CONFIG(accessibility)