HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accSelection(VARIANT *pvarChildren) { #ifdef DEBUG_SHOW_ATCLIENT_COMMANDS showDebug(__FUNCTION__, accessible); #endif //DEBUG_SHOW_ATCLIENT_COMMANDS if (!accessible->isValid()) return E_FAIL; int cc = accessible->childCount(); QVector<int> sel(cc); int selIndex = 0; for (int i = 1; i <= cc; ++i) { QAccessibleInterface *child = 0; int i2 = accessible->navigate(Child, i, &child); bool isSelected = false; if (child) { isSelected = child->state(0) & Selected; delete child; child = 0; } else { isSelected = accessible->state(i2) & Selected; } if (isSelected) sel[selIndex++] = i; } sel.resize(selIndex); if (sel.isEmpty()) { (*pvarChildren).vt = VT_EMPTY; return S_FALSE; } if (sel.size() == 1) { (*pvarChildren).vt = VT_I4; (*pvarChildren).lVal = sel[0]; return S_OK; } IEnumVARIANT *iface = new QWindowsEnumerate(sel); IUnknown *uiface; iface->QueryInterface(IID_IUnknown, (void**)&uiface); (*pvarChildren).vt = VT_UNKNOWN; (*pvarChildren).punkVal = uiface; return S_OK; }
HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accSelection(VARIANT *pvarChildren) { showDebug(__FUNCTION__, accessible); if (!accessible->isValid()) return E_FAIL; int cc = accessible->childCount(); QVector<int> sel(cc); int selIndex = 0; for (int i = 0; i < cc; ++i) { bool isSelected = false; QAccessibleInterface *child = accessible->child(i); if (child) { isSelected = child->state().selected; delete child; } if (isSelected) sel[selIndex++] = i+1; } sel.resize(selIndex); if (sel.isEmpty()) { (*pvarChildren).vt = VT_EMPTY; return S_FALSE; } if (sel.size() == 1) { (*pvarChildren).vt = VT_I4; (*pvarChildren).lVal = sel[0]; return S_OK; } IEnumVARIANT *iface = new QWindowsEnumerate(sel); IUnknown *uiface; iface->QueryInterface(IID_IUnknown, (void**)&uiface); (*pvarChildren).vt = VT_UNKNOWN; (*pvarChildren).punkVal = uiface; return S_OK; }