1 /* 2 * Copyright 2014 Piotr Caban for CodeWeavers 3 * 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. 8 * 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. 13 * 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 17 */ 18 19 #define COBJMACROS 20 21 #include "oleacc_private.h" 22 23 #include "wine/unicode.h" 24 #include "wine/debug.h" 25 #include "wine/heap.h" 26 27 WINE_DEFAULT_DEBUG_CHANNEL(oleacc); 28 29 typedef struct { 30 IAccessible IAccessible_iface; 31 IOleWindow IOleWindow_iface; 32 IEnumVARIANT IEnumVARIANT_iface; 33 34 LONG ref; 35 } Window; 36 37 static inline Window* impl_from_Window(IAccessible *iface) 38 { 39 return CONTAINING_RECORD(iface, Window, IAccessible_iface); 40 } 41 42 static HRESULT WINAPI Window_QueryInterface(IAccessible *iface, REFIID riid, void **ppv) 43 { 44 Window *This = impl_from_Window(iface); 45 46 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); 47 48 if(IsEqualIID(riid, &IID_IAccessible) || 49 IsEqualIID(riid, &IID_IDispatch) || 50 IsEqualIID(riid, &IID_IUnknown)) { 51 *ppv = iface; 52 }else if(IsEqualIID(riid, &IID_IOleWindow)) { 53 *ppv = &This->IOleWindow_iface; 54 }else if(IsEqualIID(riid, &IID_IEnumVARIANT)) { 55 *ppv = &This->IEnumVARIANT_iface; 56 }else { 57 WARN("no interface: %s\n", debugstr_guid(riid)); 58 *ppv = NULL; 59 return E_NOINTERFACE; 60 } 61 62 IAccessible_AddRef(iface); 63 return S_OK; 64 } 65 66 static ULONG WINAPI Window_AddRef(IAccessible *iface) 67 { 68 Window *This = impl_from_Window(iface); 69 ULONG ref = InterlockedIncrement(&This->ref); 70 71 TRACE("(%p) ref = %u\n", This, ref); 72 return ref; 73 } 74 75 static ULONG WINAPI Window_Release(IAccessible *iface) 76 { 77 Window *This = impl_from_Window(iface); 78 ULONG ref = InterlockedDecrement(&This->ref); 79 80 TRACE("(%p) ref = %u\n", This, ref); 81 82 if(!ref) 83 heap_free(This); 84 return ref; 85 } 86 87 static HRESULT WINAPI Window_GetTypeInfoCount(IAccessible *iface, UINT *pctinfo) 88 { 89 Window *This = impl_from_Window(iface); 90 FIXME("(%p)->(%p)\n", This, pctinfo); 91 return E_NOTIMPL; 92 } 93 94 static HRESULT WINAPI Window_GetTypeInfo(IAccessible *iface, 95 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) 96 { 97 Window *This = impl_from_Window(iface); 98 FIXME("(%p)->(%u %x %p)\n", This, iTInfo, lcid, ppTInfo); 99 return E_NOTIMPL; 100 } 101 102 static HRESULT WINAPI Window_GetIDsOfNames(IAccessible *iface, REFIID riid, 103 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) 104 { 105 Window *This = impl_from_Window(iface); 106 FIXME("(%p)->(%s %p %u %x %p)\n", This, debugstr_guid(riid), 107 rgszNames, cNames, lcid, rgDispId); 108 return E_NOTIMPL; 109 } 110 111 static HRESULT WINAPI Window_Invoke(IAccessible *iface, DISPID dispIdMember, 112 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, 113 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) 114 { 115 Window *This = impl_from_Window(iface); 116 FIXME("(%p)->(%x %s %x %x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), 117 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); 118 return E_NOTIMPL; 119 } 120 121 static HRESULT WINAPI Window_get_accParent(IAccessible *iface, IDispatch **ppdispParent) 122 { 123 Window *This = impl_from_Window(iface); 124 FIXME("(%p)->(%p)\n", This, ppdispParent); 125 return E_NOTIMPL; 126 } 127 128 static HRESULT WINAPI Window_get_accChildCount(IAccessible *iface, LONG *pcountChildren) 129 { 130 Window *This = impl_from_Window(iface); 131 FIXME("(%p)->(%p)\n", This, pcountChildren); 132 return E_NOTIMPL; 133 } 134 135 static HRESULT WINAPI Window_get_accChild(IAccessible *iface, 136 VARIANT varChildID, IDispatch **ppdispChild) 137 { 138 Window *This = impl_from_Window(iface); 139 FIXME("(%p)->(%s %p)\n", This, debugstr_variant(&varChildID), ppdispChild); 140 return E_NOTIMPL; 141 } 142 143 static HRESULT WINAPI Window_get_accName(IAccessible *iface, VARIANT varID, BSTR *pszName) 144 { 145 Window *This = impl_from_Window(iface); 146 FIXME("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pszName); 147 return E_NOTIMPL; 148 } 149 150 static HRESULT WINAPI Window_get_accValue(IAccessible *iface, VARIANT varID, BSTR *pszValue) 151 { 152 Window *This = impl_from_Window(iface); 153 FIXME("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pszValue); 154 return E_NOTIMPL; 155 } 156 157 static HRESULT WINAPI Window_get_accDescription(IAccessible *iface, 158 VARIANT varID, BSTR *pszDescription) 159 { 160 Window *This = impl_from_Window(iface); 161 FIXME("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pszDescription); 162 return E_NOTIMPL; 163 } 164 165 static HRESULT WINAPI Window_get_accRole(IAccessible *iface, VARIANT varID, VARIANT *pvarRole) 166 { 167 Window *This = impl_from_Window(iface); 168 FIXME("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pvarRole); 169 return E_NOTIMPL; 170 } 171 172 static HRESULT WINAPI Window_get_accState(IAccessible *iface, VARIANT varID, VARIANT *pvarState) 173 { 174 Window *This = impl_from_Window(iface); 175 FIXME("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pvarState); 176 return E_NOTIMPL; 177 } 178 179 static HRESULT WINAPI Window_get_accHelp(IAccessible *iface, VARIANT varID, BSTR *pszHelp) 180 { 181 Window *This = impl_from_Window(iface); 182 FIXME("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pszHelp); 183 return E_NOTIMPL; 184 } 185 186 static HRESULT WINAPI Window_get_accHelpTopic(IAccessible *iface, 187 BSTR *pszHelpFile, VARIANT varID, LONG *pidTopic) 188 { 189 Window *This = impl_from_Window(iface); 190 FIXME("(%p)->(%p %s %p)\n", This, pszHelpFile, debugstr_variant(&varID), pidTopic); 191 return E_NOTIMPL; 192 } 193 194 static HRESULT WINAPI Window_get_accKeyboardShortcut(IAccessible *iface, 195 VARIANT varID, BSTR *pszKeyboardShortcut) 196 { 197 Window *This = impl_from_Window(iface); 198 FIXME("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pszKeyboardShortcut); 199 return E_NOTIMPL; 200 } 201 202 static HRESULT WINAPI Window_get_accFocus(IAccessible *iface, VARIANT *pvarID) 203 { 204 Window *This = impl_from_Window(iface); 205 FIXME("(%p)->(%p)\n", This, pvarID); 206 return E_NOTIMPL; 207 } 208 209 static HRESULT WINAPI Window_get_accSelection(IAccessible *iface, VARIANT *pvarID) 210 { 211 Window *This = impl_from_Window(iface); 212 FIXME("(%p)->(%p)\n", This, pvarID); 213 return E_NOTIMPL; 214 } 215 216 static HRESULT WINAPI Window_get_accDefaultAction(IAccessible *iface, 217 VARIANT varID, BSTR *pszDefaultAction) 218 { 219 Window *This = impl_from_Window(iface); 220 FIXME("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pszDefaultAction); 221 return E_NOTIMPL; 222 } 223 224 static HRESULT WINAPI Window_accSelect(IAccessible *iface, LONG flagsSelect, VARIANT varID) 225 { 226 Window *This = impl_from_Window(iface); 227 FIXME("(%p)->(%x %s)\n", This, flagsSelect, debugstr_variant(&varID)); 228 return E_NOTIMPL; 229 } 230 231 static HRESULT WINAPI Window_accLocation(IAccessible *iface, LONG *pxLeft, 232 LONG *pyTop, LONG *pcxWidth, LONG *pcyHeight, VARIANT varID) 233 { 234 Window *This = impl_from_Window(iface); 235 FIXME("(%p)->(%p %p %p %p %s)\n", This, pxLeft, pyTop, 236 pcxWidth, pcyHeight, debugstr_variant(&varID)); 237 return E_NOTIMPL; 238 } 239 240 static HRESULT WINAPI Window_accNavigate(IAccessible *iface, 241 LONG navDir, VARIANT varStart, VARIANT *pvarEnd) 242 { 243 Window *This = impl_from_Window(iface); 244 FIXME("(%p)->(%d %s %p)\n", This, navDir, debugstr_variant(&varStart), pvarEnd); 245 return E_NOTIMPL; 246 } 247 248 static HRESULT WINAPI Window_accHitTest(IAccessible *iface, 249 LONG xLeft, LONG yTop, VARIANT *pvarID) 250 { 251 Window *This = impl_from_Window(iface); 252 FIXME("(%p)->(%d %d %p)\n", This, xLeft, yTop, pvarID); 253 return E_NOTIMPL; 254 } 255 256 static HRESULT WINAPI Window_accDoDefaultAction(IAccessible *iface, VARIANT varID) 257 { 258 Window *This = impl_from_Window(iface); 259 FIXME("(%p)->(%s)\n", This, debugstr_variant(&varID)); 260 return E_NOTIMPL; 261 } 262 263 static HRESULT WINAPI Window_put_accName(IAccessible *iface, VARIANT varID, BSTR pszName) 264 { 265 Window *This = impl_from_Window(iface); 266 FIXME("(%p)->(%s %s)\n", This, debugstr_variant(&varID), debugstr_w(pszName)); 267 return E_NOTIMPL; 268 } 269 270 static HRESULT WINAPI Window_put_accValue(IAccessible *iface, VARIANT varID, BSTR pszValue) 271 { 272 Window *This = impl_from_Window(iface); 273 FIXME("(%p)->(%s %s)\n", This, debugstr_variant(&varID), debugstr_w(pszValue)); 274 return E_NOTIMPL; 275 } 276 277 static const IAccessibleVtbl WindowVtbl = { 278 Window_QueryInterface, 279 Window_AddRef, 280 Window_Release, 281 Window_GetTypeInfoCount, 282 Window_GetTypeInfo, 283 Window_GetIDsOfNames, 284 Window_Invoke, 285 Window_get_accParent, 286 Window_get_accChildCount, 287 Window_get_accChild, 288 Window_get_accName, 289 Window_get_accValue, 290 Window_get_accDescription, 291 Window_get_accRole, 292 Window_get_accState, 293 Window_get_accHelp, 294 Window_get_accHelpTopic, 295 Window_get_accKeyboardShortcut, 296 Window_get_accFocus, 297 Window_get_accSelection, 298 Window_get_accDefaultAction, 299 Window_accSelect, 300 Window_accLocation, 301 Window_accNavigate, 302 Window_accHitTest, 303 Window_accDoDefaultAction, 304 Window_put_accName, 305 Window_put_accValue 306 }; 307 308 static inline Window* impl_from_Window_OleWindow(IOleWindow *iface) 309 { 310 return CONTAINING_RECORD(iface, Window, IOleWindow_iface); 311 } 312 313 static HRESULT WINAPI Window_OleWindow_QueryInterface(IOleWindow *iface, REFIID riid, void **ppv) 314 { 315 Window *This = impl_from_Window_OleWindow(iface); 316 return IAccessible_QueryInterface(&This->IAccessible_iface, riid, ppv); 317 } 318 319 static ULONG WINAPI Window_OleWindow_AddRef(IOleWindow *iface) 320 { 321 Window *This = impl_from_Window_OleWindow(iface); 322 return IAccessible_AddRef(&This->IAccessible_iface); 323 } 324 325 static ULONG WINAPI Window_OleWindow_Release(IOleWindow *iface) 326 { 327 Window *This = impl_from_Window_OleWindow(iface); 328 return IAccessible_Release(&This->IAccessible_iface); 329 } 330 331 static HRESULT WINAPI Window_OleWindow_GetWindow(IOleWindow *iface, HWND *phwnd) 332 { 333 Window *This = impl_from_Window_OleWindow(iface); 334 FIXME("(%p)->(%p)\n", This, phwnd); 335 return E_NOTIMPL; 336 } 337 338 static HRESULT WINAPI Window_OleWindow_ContextSensitiveHelp(IOleWindow *iface, BOOL fEnterMode) 339 { 340 Window *This = impl_from_Window_OleWindow(iface); 341 FIXME("(%p)->(%x)\n", This, fEnterMode); 342 return E_NOTIMPL; 343 } 344 345 static const IOleWindowVtbl WindowOleWindowVtbl = { 346 Window_OleWindow_QueryInterface, 347 Window_OleWindow_AddRef, 348 Window_OleWindow_Release, 349 Window_OleWindow_GetWindow, 350 Window_OleWindow_ContextSensitiveHelp 351 }; 352 353 static inline Window* impl_from_Window_EnumVARIANT(IEnumVARIANT *iface) 354 { 355 return CONTAINING_RECORD(iface, Window, IEnumVARIANT_iface); 356 } 357 358 static HRESULT WINAPI Window_EnumVARIANT_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv) 359 { 360 Window *This = impl_from_Window_EnumVARIANT(iface); 361 return IAccessible_QueryInterface(&This->IAccessible_iface, riid, ppv); 362 } 363 364 static ULONG WINAPI Window_EnumVARIANT_AddRef(IEnumVARIANT *iface) 365 { 366 Window *This = impl_from_Window_EnumVARIANT(iface); 367 return IAccessible_AddRef(&This->IAccessible_iface); 368 } 369 370 static ULONG WINAPI Window_EnumVARIANT_Release(IEnumVARIANT *iface) 371 { 372 Window *This = impl_from_Window_EnumVARIANT(iface); 373 return IAccessible_Release(&This->IAccessible_iface); 374 } 375 376 static HRESULT WINAPI Window_EnumVARIANT_Next(IEnumVARIANT *iface, 377 ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched) 378 { 379 Window *This = impl_from_Window_EnumVARIANT(iface); 380 FIXME("(%p)->(%u %p %p)\n", This, celt, rgVar, pCeltFetched); 381 return E_NOTIMPL; 382 } 383 384 static HRESULT WINAPI Window_EnumVARIANT_Skip(IEnumVARIANT *iface, ULONG celt) 385 { 386 Window *This = impl_from_Window_EnumVARIANT(iface); 387 FIXME("(%p)->(%u)\n", This, celt); 388 return E_NOTIMPL; 389 } 390 391 static HRESULT WINAPI Window_EnumVARIANT_Reset(IEnumVARIANT *iface) 392 { 393 Window *This = impl_from_Window_EnumVARIANT(iface); 394 FIXME("(%p)\n", This); 395 return E_NOTIMPL; 396 } 397 398 static HRESULT WINAPI Window_EnumVARIANT_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum) 399 { 400 Window *This = impl_from_Window_EnumVARIANT(iface); 401 FIXME("(%p)->(%p)\n", This, ppEnum); 402 return E_NOTIMPL; 403 } 404 405 static const IEnumVARIANTVtbl WindowEnumVARIANTVtbl = { 406 Window_EnumVARIANT_QueryInterface, 407 Window_EnumVARIANT_AddRef, 408 Window_EnumVARIANT_Release, 409 Window_EnumVARIANT_Next, 410 Window_EnumVARIANT_Skip, 411 Window_EnumVARIANT_Reset, 412 Window_EnumVARIANT_Clone 413 }; 414 415 HRESULT create_window_object(HWND hwnd, const IID *iid, void **obj) 416 { 417 Window *window; 418 HRESULT hres; 419 420 if(!IsWindow(hwnd)) 421 return E_FAIL; 422 423 window = heap_alloc_zero(sizeof(Window)); 424 if(!window) 425 return E_OUTOFMEMORY; 426 427 window->IAccessible_iface.lpVtbl = &WindowVtbl; 428 window->IOleWindow_iface.lpVtbl = &WindowOleWindowVtbl; 429 window->IEnumVARIANT_iface.lpVtbl = &WindowEnumVARIANTVtbl; 430 window->ref = 1; 431 432 hres = IAccessible_QueryInterface(&window->IAccessible_iface, iid, obj); 433 IAccessible_Release(&window->IAccessible_iface); 434 return hres; 435 } 436