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
qwindowsuiatableitemprovider.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 "qwindowsuiatableitemprovider.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
22QWindowsUiaTableItemProvider::QWindowsUiaTableItemProvider(QAccessible::Id id) :
23 QWindowsUiaBaseProvider(id)
24{
25}
26
27QWindowsUiaTableItemProvider::~QWindowsUiaTableItemProvider()
28{
29}
30
31// Returns the providers for the row headers associated with the item.
32HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetRowHeaderItems(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 QAccessibleTableCellInterface *tableCellInterface = accessible->tableCellInterface();
45 if (!tableCellInterface)
46 return UIA_E_ELEMENTNOTAVAILABLE;
47
48 const auto headers = tableCellInterface->rowHeaderCells();
49
50 if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
51 for (LONG i = 0; i < headers.size(); ++i) {
52 if (ComPtr<IRawElementProviderSimple> provider =
53 QWindowsUiaMainProvider::providerForAccessible(headers.at(i))) {
54 SafeArrayPutElement(*pRetVal, &i, provider.Get());
55 }
56 }
57 }
58 return S_OK;
59}
60
61// Returns the providers for the column headers associated with the item.
62HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetColumnHeaderItems(SAFEARRAY **pRetVal)
63{
64 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
65
66 if (!pRetVal)
67 return E_INVALIDARG;
68 *pRetVal = nullptr;
69
70 QAccessibleInterface *accessible = accessibleInterface();
71 if (!accessible)
72 return UIA_E_ELEMENTNOTAVAILABLE;
73
74 QAccessibleTableCellInterface *tableCellInterface = accessible->tableCellInterface();
75 if (!tableCellInterface)
76 return UIA_E_ELEMENTNOTAVAILABLE;
77
78 const auto headers = tableCellInterface->columnHeaderCells();
79
80 if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
81 for (LONG i = 0; i < headers.size(); ++i) {
82 if (ComPtr<IRawElementProviderSimple> provider =
83 QWindowsUiaMainProvider::providerForAccessible(headers.at(i))) {
84 SafeArrayPutElement(*pRetVal, &i, provider.Get());
85 }
86 }
87 }
88 return S_OK;
89}
90
91QT_END_NAMESPACE
92
93#endif // QT_CONFIG(accessibility)