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()
30HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::GetSelection(SAFEARRAY **pRetVal)
32 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
38 QAccessibleInterface *accessible = accessibleInterface();
40 return UIA_E_ELEMENTNOTAVAILABLE;
42 QAccessibleTextInterface *textInterface = accessible->textInterface();
44 return UIA_E_ELEMENTNOTAVAILABLE;
46 int selCount = textInterface->selectionCount();
49 if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, selCount))) {
50 for (LONG
i = 0;
i < selCount; ++
i) {
51 int startOffset = 0, endOffset = 0;
52 textInterface->selection((
int)
i, &startOffset, &endOffset);
53 auto *textRangeProvider =
new QWindowsUiaTextRangeProvider(
id(), startOffset, endOffset);
54 SafeArrayPutElement(*pRetVal, &
i,
static_cast<IUnknown *
>(textRangeProvider));
55 textRangeProvider->Release();
60 if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, 1))) {
62 int cursorPosition = textInterface->cursorPosition();
63 auto *textRangeProvider =
new QWindowsUiaTextRangeProvider(
id(), cursorPosition, cursorPosition);
64 SafeArrayPutElement(*pRetVal, &
i,
static_cast<IUnknown *
>(textRangeProvider));
65 textRangeProvider->Release();
72HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::GetVisibleRanges(SAFEARRAY **pRetVal)
74 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
80 QAccessibleInterface *accessible = accessibleInterface();
82 return UIA_E_ELEMENTNOTAVAILABLE;
84 QAccessibleTextInterface *textInterface = accessible->textInterface();
86 return UIA_E_ELEMENTNOTAVAILABLE;
89 if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, 1))) {
91 auto *textRangeProvider =
new QWindowsUiaTextRangeProvider(
id(), 0, textInterface->characterCount());
92 SafeArrayPutElement(*pRetVal, &
i,
static_cast<IUnknown *
>(textRangeProvider));
93 textRangeProvider->Release();
98HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::RangeFromChild(IRawElementProviderSimple * ,
99 ITextRangeProvider **pRetVal)
101 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
111HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::RangeFromPoint(UiaPoint point, ITextRangeProvider **pRetVal)
113 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
119 QAccessibleInterface *accessible = accessibleInterface();
121 return UIA_E_ELEMENTNOTAVAILABLE;
123 QAccessibleTextInterface *textInterface = accessible->textInterface();
125 return UIA_E_ELEMENTNOTAVAILABLE;
129 return UIA_E_ELEMENTNOTAVAILABLE;
132 nativeUiaPointToPoint(point,
window, &pt);
134 int offset = textInterface->offsetAtPoint(pt);
135 if (offset < 0 || offset >= textInterface->characterCount())
136 return UIA_E_ELEMENTNOTAVAILABLE;
138 *pRetVal =
new QWindowsUiaTextRangeProvider(
id(),
offset,
offset);
143HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::get_DocumentRange(ITextRangeProvider **pRetVal)
145 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
151 QAccessibleInterface *accessible = accessibleInterface();
153 return UIA_E_ELEMENTNOTAVAILABLE;
155 QAccessibleTextInterface *textInterface = accessible->textInterface();
157 return UIA_E_ELEMENTNOTAVAILABLE;
159 *pRetVal =
new QWindowsUiaTextRangeProvider(
id(), 0, textInterface->characterCount());
164HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::get_SupportedTextSelection(SupportedTextSelection *pRetVal)
166 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
170 *pRetVal = SupportedTextSelection_Single;
175HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::RangeFromAnnotation(IRawElementProviderSimple * , ITextRangeProvider **pRetVal)
177 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
185HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::GetCaretRange(BOOL *
isActive, ITextRangeProvider **pRetVal)
187 qCDebug(lcQpaUiAutomation) << __FUNCTION__ <<
this;
194 QAccessibleInterface *accessible = accessibleInterface();
196 return UIA_E_ELEMENTNOTAVAILABLE;
198 QAccessibleTextInterface *textInterface = accessible->textInterface();
200 return UIA_E_ELEMENTNOTAVAILABLE;
202 *
isActive = accessible->state().focused;
204 int cursorPosition = textInterface->cursorPosition();
205 *pRetVal =
new QWindowsUiaTextRangeProvider(
id(), cursorPosition, cursorPosition);
\inmodule QtCore\reentrant
Combined button and popup list for selecting options.
#define qCDebug(category,...)
GLenum GLuint GLintptr offset