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
4#include <QtGui/qtguiglobal.h>
5#if QT_CONFIG(accessibility)
6
7#include "qwindowsuiatableitemprovider.h"
8#include "qwindowsuiamainprovider.h"
9#include "qwindowsuiautils.h"
10#include "qwindowscontext.h"
11
12#include <QtGui/qaccessible.h>
13#include <QtCore/qloggingcategory.h>
14#include <QtCore/qstring.h>
15
16QT_BEGIN_NAMESPACE
17
18using namespace QWindowsUiAutomation;
19
20
21QWindowsUiaTableItemProvider::QWindowsUiaTableItemProvider(QAccessible::Id id) :
22 QWindowsUiaBaseProvider(id)
23{
24}
25
26QWindowsUiaTableItemProvider::~QWindowsUiaTableItemProvider()
27{
28}
29
30// Returns the providers for the row headers associated with the item.
31HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetRowHeaderItems(SAFEARRAY **pRetVal)
32{
33 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
34
35 if (!pRetVal)
36 return E_INVALIDARG;
37 *pRetVal = nullptr;
38
39 QAccessibleInterface *accessible = accessibleInterface();
40 if (!accessible)
41 return UIA_E_ELEMENTNOTAVAILABLE;
42
43 QAccessibleTableCellInterface *tableCellInterface = accessible->tableCellInterface();
44 if (!tableCellInterface)
45 return UIA_E_ELEMENTNOTAVAILABLE;
46
47 const auto headers = tableCellInterface->rowHeaderCells();
48
49 if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
50 for (LONG i = 0; i < headers.size(); ++i) {
51 if (ComPtr<IRawElementProviderSimple> provider =
52 QWindowsUiaMainProvider::providerForAccessible(headers.at(i))) {
53 SafeArrayPutElement(*pRetVal, &i, provider.Get());
54 }
55 }
56 }
57 return S_OK;
58}
59
60// Returns the providers for the column headers associated with the item.
61HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetColumnHeaderItems(SAFEARRAY **pRetVal)
62{
63 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
64
65 if (!pRetVal)
66 return E_INVALIDARG;
67 *pRetVal = nullptr;
68
69 QAccessibleInterface *accessible = accessibleInterface();
70 if (!accessible)
71 return UIA_E_ELEMENTNOTAVAILABLE;
72
73 QAccessibleTableCellInterface *tableCellInterface = accessible->tableCellInterface();
74 if (!tableCellInterface)
75 return UIA_E_ELEMENTNOTAVAILABLE;
76
77 const auto headers = tableCellInterface->columnHeaderCells();
78
79 if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
80 for (LONG i = 0; i < headers.size(); ++i) {
81 if (ComPtr<IRawElementProviderSimple> provider =
82 QWindowsUiaMainProvider::providerForAccessible(headers.at(i))) {
83 SafeArrayPutElement(*pRetVal, &i, provider.Get());
84 }
85 }
86 }
87 return S_OK;
88}
89
90QT_END_NAMESPACE
91
92#endif // QT_CONFIG(accessibility)