From: Esme Povirk esme@codeweavers.com
--- dlls/comctl32/syslink.c | 59 +++++++++++++++++++++++++++++++++-- dlls/comctl32/tests/syslink.c | 6 +++- 2 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/syslink.c b/dlls/comctl32/syslink.c index 76d95b77848..ac6192df724 100644 --- a/dlls/comctl32/syslink.c +++ b/dlls/comctl32/syslink.c @@ -177,6 +177,45 @@ static HRESULT WINAPI Accessible_GetTypeInfoCount(IAccessible *iface, UINT *coun return E_NOTIMPL; }
+static HRESULT Accessible_FindChild(SYSLINK_ACC *This, VARIANT childid, DOC_ITEM** result) +{ + DOC_ITEM *current; + int index; + + if (!This->infoPtr) + { + WARN("control was destroyed\n"); + return E_FAIL; + } + + if (V_VT(&childid) == VT_EMPTY) + index = 0; + else if (V_VT(&childid) == VT_I4) + index = V_I4(&childid); + else { + WARN("not implemented for vt %s\n", debugstr_vt(V_VT(&childid))); + return E_INVALIDARG; + } + + if (index == 0) + { + *result = NULL; + return S_OK; + } + + LIST_FOR_EACH_ENTRY(current, &This->infoPtr->Items, DOC_ITEM, entry) + { + if (!--index) + { + *result = current; + return S_OK; + } + } + + WARN("index out of range\n"); + return E_INVALIDARG; +} + static HRESULT WINAPI Accessible_get_accParent(IAccessible *iface, IDispatch** disp) { FIXME("%p\n", iface); @@ -215,8 +254,24 @@ static HRESULT WINAPI Accessible_get_accDescription(IAccessible *iface, VARIANT
static HRESULT WINAPI Accessible_get_accRole(IAccessible *iface, VARIANT childid, VARIANT *role) { - FIXME("%p\n", iface); - return E_NOTIMPL; + SYSLINK_ACC *This = impl_from_IAccessible(iface); + HRESULT hr; + DOC_ITEM* item; + + TRACE("%p, %s\n", iface, debugstr_variant(&childid)); + + hr = Accessible_FindChild(This, childid, &item); + if (FAILED(hr)) + return hr; + + V_VT(role) = VT_I4; + + if (item) + V_I4(role) = ROLE_SYSTEM_LINK; + else + V_I4(role) = ROLE_SYSTEM_CLIENT; + + return S_OK; }
static HRESULT WINAPI Accessible_get_accState(IAccessible *iface, VARIANT childid, VARIANT *state) diff --git a/dlls/comctl32/tests/syslink.c b/dlls/comctl32/tests/syslink.c index 4ce0daa8c0e..e8a76f8a5ae 100644 --- a/dlls/comctl32/tests/syslink.c +++ b/dlls/comctl32/tests/syslink.c @@ -311,12 +311,12 @@ static void test_msaa(void) V_VT(&varChild) = VT_I4; V_I4(&varChild) = CHILDID_SELF;
-todo_wine { hr = IAccessible_get_accRole(acc, varChild, &varResult); ok(hr == S_OK, "accRole failed, hr=%lx\n", hr); ok(V_VT(&varResult) == VT_I4, "accRole returned vt=%x\n", V_VT(&varResult)); ok(V_I4(&varResult) == ROLE_SYSTEM_CLIENT, "accRole returned %li\n", V_I4(&varResult));
+todo_wine { VariantClear(&varResult); hr = IAccessible_get_accState(acc, varChild, &varResult); ok(hr == S_OK, "accState failed, hr=%lx\n", hr); @@ -348,12 +348,14 @@ todo_wine { hr = IAccessible_get_accChild(acc, varChild, &child); ok(hr == S_FALSE, "accChild hr=%lx\n", hr); ok(!child, "accChild returned IDispatch\n"); +}
hr = IAccessible_get_accRole(acc, varChild, &varResult); ok(hr == S_OK, "accRole failed, hr=%lx\n", hr); ok(V_VT(&varResult) == VT_I4, "accRole returned vt=%x\n", V_VT(&varResult)); ok(V_I4(&varResult) == ROLE_SYSTEM_LINK, "accRole returned %li\n", V_I4(&varResult));
+todo_wine { VariantClear(&varResult); hr = IAccessible_get_accState(acc, varChild, &varResult); ok(hr == S_OK, "accState failed, hr=%lx\n", hr); @@ -385,12 +387,14 @@ todo_wine { hr = IAccessible_get_accChild(acc, varChild, &child); ok(hr == S_FALSE, "accChild hr=%lx\n", hr); ok(!child, "accChild returned IDispatch\n"); +}
hr = IAccessible_get_accRole(acc, varChild, &varResult); ok(hr == S_OK, "accRole failed, hr=%lx\n", hr); ok(V_VT(&varResult) == VT_I4, "accRole returned vt=%x\n", V_VT(&varResult)); ok(V_I4(&varResult) == ROLE_SYSTEM_LINK, "accRole returned %li\n", V_I4(&varResult));
+todo_wine { VariantClear(&varResult); hr = IAccessible_get_accState(acc, varChild, &varResult); ok(hr == S_OK, "accState failed, hr=%lx\n", hr);