Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/oleacc/client.c | 63 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 13 deletions(-)
diff --git a/dlls/oleacc/client.c b/dlls/oleacc/client.c index ef6967752b4..22b8c225dd9 100644 --- a/dlls/oleacc/client.c +++ b/dlls/oleacc/client.c @@ -30,6 +30,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(oleacc); typedef struct { HRESULT (*get_state)(IAccessible *, VARIANT, VARIANT *); HRESULT (*get_name)(IAccessible *, VARIANT, BSTR *); + HRESULT (*get_kbd_shortcut)(IAccessible *, VARIANT, BSTR *); } WinClassVtbl;
typedef struct { @@ -65,6 +66,26 @@ static HRESULT acc_client_get_name_str(WCHAR *name, UINT len, BSTR *pszName) return *pszName ? S_OK : E_OUTOFMEMORY; }
+static HRESULT acc_client_get_kbd_shortcut_str(WCHAR *name, UINT len, + BSTR *pszKeyboardShortcut) +{ + UINT i; + + for(i=0; i<len; i++) { + if(name[i] == '&') + break; + } + if(i+1 >= len) + return S_FALSE; + + *pszKeyboardShortcut = SysAllocString(L"Alt+!"); + if(!*pszKeyboardShortcut) + return E_OUTOFMEMORY; + + (*pszKeyboardShortcut)[4] = name[i+1]; + return S_OK; +} + static inline Client* impl_from_Client(IAccessible *iface) { return CONTAINING_RECORD(iface, Client, IAccessible_iface); @@ -313,28 +334,20 @@ static HRESULT WINAPI Client_get_accKeyboardShortcut(IAccessible *iface, { Client *This = impl_from_Client(iface); WCHAR name[1024]; - UINT i, len; + UINT len;
TRACE("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pszKeyboardShortcut);
+ if (This->vtbl.get_kbd_shortcut) + return This->vtbl.get_kbd_shortcut(iface, varID, pszKeyboardShortcut); + *pszKeyboardShortcut = NULL; if(convert_child_id(&varID) != CHILDID_SELF) return E_INVALIDARG;
len = SendMessageW(This->hwnd, WM_GETTEXT, ARRAY_SIZE(name), (LPARAM)name); - for(i=0; i<len; i++) { - if(name[i] == '&') - break; - } - if(i+1 >= len) - return S_FALSE; - - *pszKeyboardShortcut = SysAllocString(L"Alt+!"); - if(!*pszKeyboardShortcut) - return E_OUTOFMEMORY;
- (*pszKeyboardShortcut)[4] = name[i+1]; - return S_OK; + return acc_client_get_kbd_shortcut_str(name, len, pszKeyboardShortcut); }
static HRESULT WINAPI Client_get_accFocus(IAccessible *iface, VARIANT *focus) @@ -781,6 +794,29 @@ static HRESULT edit_get_state(IAccessible *iface, VARIANT var_id, VARIANT *out_s return S_OK; }
+static HRESULT edit_get_kbd_shortcut(IAccessible *iface, VARIANT var_id, + BSTR *out_kbd_shortcut) +{ + Client *This = impl_from_Client(iface); + WCHAR name[1024]; + HWND label; + UINT len; + + TRACE("(%p)->(%s %p)\n", This, debugstr_variant(&var_id), out_kbd_shortcut); + + *out_kbd_shortcut = NULL; + if(convert_child_id(&var_id) != CHILDID_SELF || !IsWindow(This->hwnd)) + return E_INVALIDARG; + + label = acc_edit_find_label(This->hwnd, TRUE); + if(!label) + return S_FALSE; + + len = SendMessageW(label, WM_GETTEXT, ARRAY_SIZE(name), (LPARAM)name); + + return acc_client_get_kbd_shortcut_str(name, len, out_kbd_shortcut); +} + HRESULT create_edit_client_object(HWND hwnd, const IID *iid, void **obj) { IAccessible *acc; @@ -794,6 +830,7 @@ HRESULT create_edit_client_object(HWND hwnd, const IID *iid, void **obj) client->role = ROLE_SYSTEM_TEXT; client->vtbl.get_state = &edit_get_state; client->vtbl.get_name = &edit_get_name; + client->vtbl.get_kbd_shortcut = &edit_get_kbd_shortcut;
hres = IAccessible_QueryInterface(acc, iid, obj); IAccessible_Release(acc);