Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/oleacc/client.c | 66 ++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 18 deletions(-)
diff --git a/dlls/oleacc/client.c b/dlls/oleacc/client.c index c01f060f3a5..ed7dd86b13b 100644 --- a/dlls/oleacc/client.c +++ b/dlls/oleacc/client.c @@ -46,6 +46,7 @@ struct win_class_vtbl { void (*init)(Client*); HRESULT (*get_state)(Client*, VARIANT, VARIANT*); HRESULT (*get_name)(Client*, VARIANT, BSTR*); + HRESULT (*get_kbd_shortcut)(Client*, VARIANT, BSTR*); };
static HRESULT acc_client_get_name_str(WCHAR *name, UINT len, BSTR *name_out) @@ -67,6 +68,26 @@ static HRESULT acc_client_get_name_str(WCHAR *name, UINT len, BSTR *name_out) return *name_out ? S_OK : E_OUTOFMEMORY; }
+static HRESULT acc_client_get_kbd_shortcut_str(WCHAR *name, UINT len, + BSTR *kbd_shortcut_out) +{ + UINT i; + + for(i=0; i<len; i++) { + if(name[i] == '&') + break; + } + if(i+1 >= len) + return S_FALSE; + + *kbd_shortcut_out = SysAllocString(L"Alt+!"); + if(!*kbd_shortcut_out) + return E_OUTOFMEMORY; + + (*kbd_shortcut_out)[4] = name[i+1]; + return S_OK; +} + static inline Client* impl_from_Client(IAccessible *iface) { return CONTAINING_RECORD(iface, Client, IAccessible_iface); @@ -305,32 +326,23 @@ static HRESULT WINAPI Client_get_accHelpTopic(IAccessible *iface, }
static HRESULT WINAPI Client_get_accKeyboardShortcut(IAccessible *iface, - VARIANT varID, BSTR *pszKeyboardShortcut) + VARIANT id, BSTR *kbd_shortcut_out) { Client *This = impl_from_Client(iface); WCHAR name[1024]; - UINT i, len; + UINT len;
- TRACE("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pszKeyboardShortcut); + TRACE("(%p)->(%s %p)\n", This, debugstr_variant(&id), kbd_shortcut_out);
- *pszKeyboardShortcut = NULL; - if(convert_child_id(&varID) != CHILDID_SELF) + *kbd_shortcut_out = NULL; + if (This->vtbl && This->vtbl->get_kbd_shortcut) + return This->vtbl->get_kbd_shortcut(This, id, kbd_shortcut_out); + + if(convert_child_id(&id) != 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, kbd_shortcut_out); }
static HRESULT WINAPI Client_get_accFocus(IAccessible *iface, VARIANT *focus) @@ -748,10 +760,28 @@ static HRESULT edit_get_name(Client *client, VARIANT id, BSTR *name_out) return acc_client_get_name_str(name, len, name_out); }
+static HRESULT edit_get_kbd_shortcut(Client *client, VARIANT id, BSTR *kbd_shortcut_out) +{ + WCHAR name[1024]; + HWND label; + UINT len; + + if(convert_child_id(&id) != CHILDID_SELF) + return E_INVALIDARG; + + label = acc_edit_find_label(client->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, kbd_shortcut_out); +} + static const win_class_vtbl edit_vtbl = { edit_init, edit_get_state, edit_get_name, + edit_get_kbd_shortcut, };
static const struct win_class_data classes[] = {