4#include <QtGui/qtguiglobal.h>
5#if QT_CONFIG(accessibility)
11#include <QtGui/qaccessible.h>
12#include <QtCore/qloggingcategory.h>
13#include <QtCore/qstring.h>
17using namespace QWindowsUiAutomation;
20QWindowsUiaTextProvider::QWindowsUiaTextProvider(QAccessible::Id
id) :
21 QWindowsUiaBaseProvider(
id)
25QWindowsUiaTextProvider::~QWindowsUiaTextProvider()
29HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::QueryInterface(REFIID iid, LPVOID *iface)
31 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
37 const bool result = qWindowsComQueryUnknownInterfaceMulti<ITextProvider>(
this, iid, iface)
38 || qWindowsComQueryInterface<ITextProvider>(
this, iid, iface)
39 || qWindowsComQueryInterface<ITextProvider2>(
this, iid, iface);
40 return result ? S_OK : E_NOINTERFACE;
44HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::GetSelection(SAFEARRAY **
pRetVal)
46 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
52 QAccessibleInterface *accessible = accessibleInterface();
56 QAccessibleTextInterface *textInterface = accessible->textInterface();
60 int selCount = textInterface->selectionCount();
63 if ((*
pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, selCount))) {
64 for (LONG
i = 0;
i < selCount; ++
i) {
65 int startOffset = 0, endOffset = 0;
66 textInterface->selection((
int)
i, &startOffset, &endOffset);
67 auto *textRangeProvider =
new QWindowsUiaTextRangeProvider(
id(), startOffset, endOffset);
68 SafeArrayPutElement(*
pRetVal, &
i,
static_cast<IUnknown *
>(textRangeProvider));
69 textRangeProvider->Release();
74 if ((*
pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, 1))) {
76 int cursorPosition = textInterface->cursorPosition();
77 auto *textRangeProvider =
new QWindowsUiaTextRangeProvider(
id(), cursorPosition, cursorPosition);
78 SafeArrayPutElement(*
pRetVal, &
i,
static_cast<IUnknown *
>(textRangeProvider));
79 textRangeProvider->Release();
86HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::GetVisibleRanges(SAFEARRAY **
pRetVal)
88 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
94 QAccessibleInterface *accessible = accessibleInterface();
98 QAccessibleTextInterface *textInterface = accessible->textInterface();
103 if ((*
pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, 1))) {
105 auto *textRangeProvider =
new QWindowsUiaTextRangeProvider(
id(), 0, textInterface->characterCount());
106 SafeArrayPutElement(*
pRetVal, &
i,
static_cast<IUnknown *
>(textRangeProvider));
107 textRangeProvider->Release();
112HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::RangeFromChild(IRawElementProviderSimple * ,
115 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
125HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::RangeFromPoint(
UiaPoint point, ITextRangeProvider **
pRetVal)
127 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
133 QAccessibleInterface *accessible = accessibleInterface();
137 QAccessibleTextInterface *textInterface = accessible->textInterface();
146 nativeUiaPointToPoint(point,
window, &pt);
148 int offset = textInterface->offsetAtPoint(pt);
149 if ((
offset >= 0) && (offset < textInterface->characterCount())) {
156HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::get_DocumentRange(ITextRangeProvider **
pRetVal)
158 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
164 QAccessibleInterface *accessible = accessibleInterface();
168 QAccessibleTextInterface *textInterface = accessible->textInterface();
172 *
pRetVal =
new QWindowsUiaTextRangeProvider(
id(), 0, textInterface->characterCount());
179 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
188HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::RangeFromAnnotation(IRawElementProviderSimple * , ITextRangeProvider **
pRetVal)
190 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
198HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::GetCaretRange(BOOL *
isActive, ITextRangeProvider **
pRetVal)
200 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
207 QAccessibleInterface *accessible = accessibleInterface();
211 QAccessibleTextInterface *textInterface = accessible->textInterface();
215 *
isActive = accessible->state().focused;
217 int cursorPosition = textInterface->cursorPosition();
218 *
pRetVal =
new QWindowsUiaTextRangeProvider(
id(), cursorPosition, cursorPosition);
\inmodule QtCore\reentrant
Combined button and popup list for selecting options.
constexpr QBindableInterface iface
#define qCDebug(category,...)
GLenum GLuint GLintptr offset
#define UIA_E_ELEMENTNOTAVAILABLE
IRawElementProviderFragment __RPC__deref_out_opt IRawElementProviderFragment ** pRetVal
@ SupportedTextSelection_Single