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