2 * Copyright 2014 Piotr Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "oleacc_private.h"
24 #include "wine/debug.h"
25 #include "wine/heap.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(oleacc
);
30 IAccessible IAccessible_iface
;
31 IOleWindow IOleWindow_iface
;
32 IEnumVARIANT IEnumVARIANT_iface
;
33 IServiceProvider IServiceProvider_iface
;
40 static inline Window
* impl_from_Window(IAccessible
*iface
)
42 return CONTAINING_RECORD(iface
, Window
, IAccessible_iface
);
45 static HRESULT WINAPI
Window_QueryInterface(IAccessible
*iface
, REFIID riid
, void **ppv
)
47 Window
*This
= impl_from_Window(iface
);
49 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
51 if(IsEqualIID(riid
, &IID_IAccessible
) ||
52 IsEqualIID(riid
, &IID_IDispatch
) ||
53 IsEqualIID(riid
, &IID_IUnknown
)) {
55 }else if(IsEqualIID(riid
, &IID_IOleWindow
)) {
56 *ppv
= &This
->IOleWindow_iface
;
57 }else if(IsEqualIID(riid
, &IID_IEnumVARIANT
)) {
58 *ppv
= &This
->IEnumVARIANT_iface
;
59 }else if(IsEqualIID(riid
, &IID_IServiceProvider
)) {
60 *ppv
= &This
->IServiceProvider_iface
;
62 WARN("no interface: %s\n", debugstr_guid(riid
));
67 IAccessible_AddRef(iface
);
71 static ULONG WINAPI
Window_AddRef(IAccessible
*iface
)
73 Window
*This
= impl_from_Window(iface
);
74 ULONG ref
= InterlockedIncrement(&This
->ref
);
76 TRACE("(%p) ref = %lu\n", This
, ref
);
80 static ULONG WINAPI
Window_Release(IAccessible
*iface
)
82 Window
*This
= impl_from_Window(iface
);
83 ULONG ref
= InterlockedDecrement(&This
->ref
);
85 TRACE("(%p) ref = %lu\n", This
, ref
);
92 static HRESULT WINAPI
Window_GetTypeInfoCount(IAccessible
*iface
, UINT
*pctinfo
)
94 Window
*This
= impl_from_Window(iface
);
95 FIXME("(%p)->(%p)\n", This
, pctinfo
);
99 static HRESULT WINAPI
Window_GetTypeInfo(IAccessible
*iface
,
100 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
102 Window
*This
= impl_from_Window(iface
);
103 FIXME("(%p)->(%u %lx %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
107 static HRESULT WINAPI
Window_GetIDsOfNames(IAccessible
*iface
, REFIID riid
,
108 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
110 Window
*This
= impl_from_Window(iface
);
111 FIXME("(%p)->(%s %p %u %lx %p)\n", This
, debugstr_guid(riid
),
112 rgszNames
, cNames
, lcid
, rgDispId
);
116 static HRESULT WINAPI
Window_Invoke(IAccessible
*iface
, DISPID dispIdMember
,
117 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
118 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
120 Window
*This
= impl_from_Window(iface
);
121 FIXME("(%p)->(%lx %s %lx %x %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
122 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
126 static HRESULT WINAPI
Window_get_accParent(IAccessible
*iface
, IDispatch
**ppdispParent
)
128 Window
*This
= impl_from_Window(iface
);
129 FIXME("(%p)->(%p)\n", This
, ppdispParent
);
133 static HRESULT WINAPI
Window_get_accChildCount(IAccessible
*iface
, LONG
*pcountChildren
)
135 Window
*This
= impl_from_Window(iface
);
136 FIXME("(%p)->(%p)\n", This
, pcountChildren
);
140 static HRESULT WINAPI
Window_get_accChild(IAccessible
*iface
,
141 VARIANT varChildID
, IDispatch
**ppdispChild
)
143 Window
*This
= impl_from_Window(iface
);
144 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varChildID
), ppdispChild
);
148 static HRESULT WINAPI
Window_get_accName(IAccessible
*iface
, VARIANT varID
, BSTR
*pszName
)
150 Window
*This
= impl_from_Window(iface
);
151 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszName
);
155 static HRESULT WINAPI
Window_get_accValue(IAccessible
*iface
, VARIANT varID
, BSTR
*pszValue
)
157 Window
*This
= impl_from_Window(iface
);
158 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszValue
);
162 static HRESULT WINAPI
Window_get_accDescription(IAccessible
*iface
,
163 VARIANT varID
, BSTR
*pszDescription
)
165 Window
*This
= impl_from_Window(iface
);
166 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszDescription
);
170 static HRESULT WINAPI
Window_get_accRole(IAccessible
*iface
, VARIANT varID
, VARIANT
*pvarRole
)
172 Window
*This
= impl_from_Window(iface
);
173 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pvarRole
);
177 static HRESULT WINAPI
Window_get_accState(IAccessible
*iface
, VARIANT varID
, VARIANT
*pvarState
)
179 Window
*This
= impl_from_Window(iface
);
180 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pvarState
);
184 static HRESULT WINAPI
Window_get_accHelp(IAccessible
*iface
, VARIANT varID
, BSTR
*pszHelp
)
186 Window
*This
= impl_from_Window(iface
);
187 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszHelp
);
191 static HRESULT WINAPI
Window_get_accHelpTopic(IAccessible
*iface
,
192 BSTR
*pszHelpFile
, VARIANT varID
, LONG
*pidTopic
)
194 Window
*This
= impl_from_Window(iface
);
195 FIXME("(%p)->(%p %s %p)\n", This
, pszHelpFile
, debugstr_variant(&varID
), pidTopic
);
199 static HRESULT WINAPI
Window_get_accKeyboardShortcut(IAccessible
*iface
,
200 VARIANT varID
, BSTR
*pszKeyboardShortcut
)
202 Window
*This
= impl_from_Window(iface
);
203 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszKeyboardShortcut
);
207 static HRESULT WINAPI
Window_get_accFocus(IAccessible
*iface
, VARIANT
*pvarID
)
209 Window
*This
= impl_from_Window(iface
);
210 FIXME("(%p)->(%p)\n", This
, pvarID
);
214 static HRESULT WINAPI
Window_get_accSelection(IAccessible
*iface
, VARIANT
*pvarID
)
216 Window
*This
= impl_from_Window(iface
);
217 FIXME("(%p)->(%p)\n", This
, pvarID
);
221 static HRESULT WINAPI
Window_get_accDefaultAction(IAccessible
*iface
,
222 VARIANT varID
, BSTR
*pszDefaultAction
)
224 Window
*This
= impl_from_Window(iface
);
225 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszDefaultAction
);
229 static HRESULT WINAPI
Window_accSelect(IAccessible
*iface
, LONG flagsSelect
, VARIANT varID
)
231 Window
*This
= impl_from_Window(iface
);
232 FIXME("(%p)->(%lx %s)\n", This
, flagsSelect
, debugstr_variant(&varID
));
236 static HRESULT WINAPI
Window_accLocation(IAccessible
*iface
, LONG
*pxLeft
,
237 LONG
*pyTop
, LONG
*pcxWidth
, LONG
*pcyHeight
, VARIANT varID
)
239 Window
*This
= impl_from_Window(iface
);
240 FIXME("(%p)->(%p %p %p %p %s)\n", This
, pxLeft
, pyTop
,
241 pcxWidth
, pcyHeight
, debugstr_variant(&varID
));
245 static HRESULT WINAPI
Window_accNavigate(IAccessible
*iface
,
246 LONG navDir
, VARIANT varStart
, VARIANT
*pvarEnd
)
248 Window
*This
= impl_from_Window(iface
);
249 FIXME("(%p)->(%ld %s %p)\n", This
, navDir
, debugstr_variant(&varStart
), pvarEnd
);
253 static HRESULT WINAPI
Window_accHitTest(IAccessible
*iface
, LONG x
, LONG y
, VARIANT
*v
)
255 Window
*This
= impl_from_Window(iface
);
261 TRACE("(%p)->(%ld %ld %p)\n", This
, x
, y
, v
);
264 if (!GetClientRect(This
->hwnd
, &rect
))
266 if (!ClientToScreen(This
->hwnd
, (POINT
*)&rect
) ||
267 !ClientToScreen(This
->hwnd
, &((POINT
*)&rect
)[1]))
271 if (PtInRect(&rect
, pt
))
273 hr
= AccessibleObjectFromWindow(This
->hwnd
, OBJID_CLIENT
, &IID_IDispatch
, (void**)&disp
);
279 V_VT(v
) = VT_DISPATCH
;
280 V_DISPATCH(v
) = disp
;
284 FIXME("non-client area not handled yet\n");
288 static HRESULT WINAPI
Window_accDoDefaultAction(IAccessible
*iface
, VARIANT varID
)
290 Window
*This
= impl_from_Window(iface
);
291 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&varID
));
295 static HRESULT WINAPI
Window_put_accName(IAccessible
*iface
, VARIANT varID
, BSTR pszName
)
297 Window
*This
= impl_from_Window(iface
);
298 FIXME("(%p)->(%s %s)\n", This
, debugstr_variant(&varID
), debugstr_w(pszName
));
302 static HRESULT WINAPI
Window_put_accValue(IAccessible
*iface
, VARIANT varID
, BSTR pszValue
)
304 Window
*This
= impl_from_Window(iface
);
305 FIXME("(%p)->(%s %s)\n", This
, debugstr_variant(&varID
), debugstr_w(pszValue
));
309 static const IAccessibleVtbl WindowVtbl
= {
310 Window_QueryInterface
,
313 Window_GetTypeInfoCount
,
315 Window_GetIDsOfNames
,
317 Window_get_accParent
,
318 Window_get_accChildCount
,
322 Window_get_accDescription
,
326 Window_get_accHelpTopic
,
327 Window_get_accKeyboardShortcut
,
329 Window_get_accSelection
,
330 Window_get_accDefaultAction
,
335 Window_accDoDefaultAction
,
340 static inline Window
* impl_from_Window_OleWindow(IOleWindow
*iface
)
342 return CONTAINING_RECORD(iface
, Window
, IOleWindow_iface
);
345 static HRESULT WINAPI
Window_OleWindow_QueryInterface(IOleWindow
*iface
, REFIID riid
, void **ppv
)
347 Window
*This
= impl_from_Window_OleWindow(iface
);
348 return IAccessible_QueryInterface(&This
->IAccessible_iface
, riid
, ppv
);
351 static ULONG WINAPI
Window_OleWindow_AddRef(IOleWindow
*iface
)
353 Window
*This
= impl_from_Window_OleWindow(iface
);
354 return IAccessible_AddRef(&This
->IAccessible_iface
);
357 static ULONG WINAPI
Window_OleWindow_Release(IOleWindow
*iface
)
359 Window
*This
= impl_from_Window_OleWindow(iface
);
360 return IAccessible_Release(&This
->IAccessible_iface
);
363 static HRESULT WINAPI
Window_OleWindow_GetWindow(IOleWindow
*iface
, HWND
*hwnd
)
365 Window
*This
= impl_from_Window_OleWindow(iface
);
367 TRACE("(%p)->(%p)\n", This
, hwnd
);
373 static HRESULT WINAPI
Window_OleWindow_ContextSensitiveHelp(IOleWindow
*iface
, BOOL fEnterMode
)
375 Window
*This
= impl_from_Window_OleWindow(iface
);
376 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
380 static const IOleWindowVtbl WindowOleWindowVtbl
= {
381 Window_OleWindow_QueryInterface
,
382 Window_OleWindow_AddRef
,
383 Window_OleWindow_Release
,
384 Window_OleWindow_GetWindow
,
385 Window_OleWindow_ContextSensitiveHelp
388 static inline Window
* impl_from_Window_EnumVARIANT(IEnumVARIANT
*iface
)
390 return CONTAINING_RECORD(iface
, Window
, IEnumVARIANT_iface
);
393 static HRESULT WINAPI
Window_EnumVARIANT_QueryInterface(IEnumVARIANT
*iface
, REFIID riid
, void **ppv
)
395 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
396 return IAccessible_QueryInterface(&This
->IAccessible_iface
, riid
, ppv
);
399 static ULONG WINAPI
Window_EnumVARIANT_AddRef(IEnumVARIANT
*iface
)
401 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
402 return IAccessible_AddRef(&This
->IAccessible_iface
);
405 static ULONG WINAPI
Window_EnumVARIANT_Release(IEnumVARIANT
*iface
)
407 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
408 return IAccessible_Release(&This
->IAccessible_iface
);
411 static HRESULT WINAPI
Window_EnumVARIANT_Next(IEnumVARIANT
*iface
,
412 ULONG celt
, VARIANT
*rgVar
, ULONG
*pCeltFetched
)
414 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
415 FIXME("(%p)->(%lu %p %p)\n", This
, celt
, rgVar
, pCeltFetched
);
419 static HRESULT WINAPI
Window_EnumVARIANT_Skip(IEnumVARIANT
*iface
, ULONG celt
)
421 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
422 FIXME("(%p)->(%lu)\n", This
, celt
);
426 static HRESULT WINAPI
Window_EnumVARIANT_Reset(IEnumVARIANT
*iface
)
428 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
429 FIXME("(%p)\n", This
);
433 static HRESULT WINAPI
Window_EnumVARIANT_Clone(IEnumVARIANT
*iface
, IEnumVARIANT
**ppEnum
)
435 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
436 FIXME("(%p)->(%p)\n", This
, ppEnum
);
440 static const IEnumVARIANTVtbl WindowEnumVARIANTVtbl
= {
441 Window_EnumVARIANT_QueryInterface
,
442 Window_EnumVARIANT_AddRef
,
443 Window_EnumVARIANT_Release
,
444 Window_EnumVARIANT_Next
,
445 Window_EnumVARIANT_Skip
,
446 Window_EnumVARIANT_Reset
,
447 Window_EnumVARIANT_Clone
450 static inline Window
* impl_from_Window_ServiceProvider(IServiceProvider
*iface
)
452 return CONTAINING_RECORD(iface
, Window
, IServiceProvider_iface
);
455 static HRESULT WINAPI
Window_ServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
457 Window
*This
= impl_from_Window_ServiceProvider(iface
);
458 return IAccessible_QueryInterface(&This
->IAccessible_iface
, riid
, ppv
);
461 static ULONG WINAPI
Window_ServiceProvider_AddRef(IServiceProvider
*iface
)
463 Window
*This
= impl_from_Window_ServiceProvider(iface
);
464 return IAccessible_AddRef(&This
->IAccessible_iface
);
467 static ULONG WINAPI
Window_ServiceProvider_Release(IServiceProvider
*iface
)
469 Window
*This
= impl_from_Window_ServiceProvider(iface
);
470 return IAccessible_Release(&This
->IAccessible_iface
);
473 static HRESULT WINAPI
Window_ServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guid_service
,
474 REFIID riid
, void **ppv
)
476 Window
*This
= impl_from_Window_ServiceProvider(iface
);
478 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_guid(guid_service
), debugstr_guid(riid
), ppv
);
481 if (IsEqualIID(guid_service
, &IIS_IsOleaccProxy
))
482 return IAccessible_QueryInterface(&This
->IAccessible_iface
, riid
, ppv
);
487 static const IServiceProviderVtbl WindowServiceProviderVtbl
= {
488 Window_ServiceProvider_QueryInterface
,
489 Window_ServiceProvider_AddRef
,
490 Window_ServiceProvider_Release
,
491 Window_ServiceProvider_QueryService
494 static const struct win_class_data classes
[] = {
495 {WC_LISTBOXW
, 0x10000, TRUE
},
496 {L
"#32768", 0x10001, TRUE
}, /* menu */
500 HRESULT
create_window_object(HWND hwnd
, const IID
*iid
, void **obj
)
508 window
= heap_alloc_zero(sizeof(Window
));
510 return E_OUTOFMEMORY
;
512 find_class_data(hwnd
, classes
);
514 window
->IAccessible_iface
.lpVtbl
= &WindowVtbl
;
515 window
->IOleWindow_iface
.lpVtbl
= &WindowOleWindowVtbl
;
516 window
->IEnumVARIANT_iface
.lpVtbl
= &WindowEnumVARIANTVtbl
;
517 window
->IServiceProvider_iface
.lpVtbl
= &WindowServiceProviderVtbl
;
521 hres
= IAccessible_QueryInterface(&window
->IAccessible_iface
, iid
, obj
);
522 IAccessible_Release(&window
->IAccessible_iface
);