d3dxof: Turn some TRACEs into WARNs in case of parsing error.
[wine/multimedia.git] / dlls / shdocvw / dochost.c
blobe8982e4f12abf4069e4ca89f7c2e030622bfe157
1 /*
2 * Copyright 2005-2006 Jacek 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
19 #include "wine/debug.h"
20 #include "shdocvw.h"
21 #include "hlink.h"
22 #include "exdispid.h"
23 #include "mshtml.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
27 static ATOM doc_view_atom = 0;
29 void push_dochost_task(DocHost *This, task_header_t *task, task_proc_t proc, BOOL send)
31 task->proc = proc;
33 /* FIXME: Don't use lParam */
34 if(send)
35 SendMessageW(This->frame_hwnd, WM_DOCHOSTTASK, 0, (LPARAM)task);
36 else
37 PostMessageW(This->frame_hwnd, WM_DOCHOSTTASK, 0, (LPARAM)task);
40 LRESULT process_dochost_task(DocHost *This, LPARAM lparam)
42 task_header_t *task = (task_header_t*)lparam;
44 task->proc(This, task);
46 heap_free(task);
47 return 0;
50 static void notif_complete(DocHost *This, DISPID dispid)
52 DISPPARAMS dispparams;
53 VARIANTARG params[2];
54 VARIANT url;
56 dispparams.cArgs = 2;
57 dispparams.cNamedArgs = 0;
58 dispparams.rgdispidNamedArgs = NULL;
59 dispparams.rgvarg = params;
61 V_VT(params) = (VT_BYREF|VT_VARIANT);
62 V_BYREF(params) = &url;
64 V_VT(params+1) = VT_DISPATCH;
65 V_DISPATCH(params+1) = This->disp;
67 V_VT(&url) = VT_BSTR;
68 V_BSTR(&url) = SysAllocString(This->url);
70 TRACE("%d >>>\n", dispid);
71 call_sink(This->cps.wbe2, dispid, &dispparams);
72 TRACE("%d <<<\n", dispid);
74 SysFreeString(V_BSTR(&url));
75 This->busy = VARIANT_FALSE;
78 static void object_available(DocHost *This)
80 IHlinkTarget *hlink;
81 HRESULT hres;
83 TRACE("(%p)\n", This);
85 if(!This->document) {
86 WARN("document == NULL\n");
87 return;
90 hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
91 if(FAILED(hres)) {
92 FIXME("Could not get IHlinkTarget interface\n");
93 return;
96 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
97 IHlinkTarget_Release(hlink);
98 if(FAILED(hres))
99 FIXME("Navigate failed\n");
102 static HRESULT get_doc_ready_state(DocHost *This, READYSTATE *ret)
104 DISPPARAMS dp = {NULL,NULL,0,0};
105 IDispatch *disp;
106 EXCEPINFO ei;
107 VARIANT var;
108 HRESULT hres;
110 hres = IUnknown_QueryInterface(This->document, &IID_IDispatch, (void**)&disp);
111 if(FAILED(hres))
112 return hres;
114 hres = IDispatch_Invoke(disp, DISPID_READYSTATE, &IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET,
115 &dp, &var, &ei, NULL);
116 IDispatch_Release(disp);
117 if(FAILED(hres)) {
118 WARN("Invoke(DISPID_READYSTATE failed: %08x\n", hres);
119 return hres;
122 if(V_VT(&var) != VT_I4) {
123 WARN("V_VT(var) = %d\n", V_VT(&var));
124 VariantClear(&var);
125 return E_FAIL;
128 *ret = V_I4(&var);
129 return S_OK;
132 static void advise_prop_notif(DocHost *This, BOOL set)
134 IConnectionPointContainer *cp_container;
135 IConnectionPoint *cp;
136 HRESULT hres;
138 hres = IUnknown_QueryInterface(This->document, &IID_IConnectionPointContainer, (void**)&cp_container);
139 if(FAILED(hres))
140 return;
142 hres = IConnectionPointContainer_FindConnectionPoint(cp_container, &IID_IPropertyNotifySink, &cp);
143 IConnectionPointContainer_Release(cp_container);
144 if(FAILED(hres))
145 return;
147 if(set)
148 hres = IConnectionPoint_Advise(cp, (IUnknown*)PROPNOTIF(This), &This->prop_notif_cookie);
149 else
150 hres = IConnectionPoint_Unadvise(cp, This->prop_notif_cookie);
151 IConnectionPoint_Release(cp);
153 if(SUCCEEDED(hres))
154 This->is_prop_notif = set;
157 static void update_ready_state(DocHost *This, READYSTATE ready_state)
159 if(ready_state > READYSTATE_LOADING && This->ready_state <= READYSTATE_LOADING) {
160 notif_complete(This, DISPID_NAVIGATECOMPLETE2);
161 This->ready_state = ready_state;
164 if(ready_state == READYSTATE_COMPLETE && This->ready_state < READYSTATE_COMPLETE) {
165 This->ready_state = READYSTATE_COMPLETE;
166 notif_complete(This, DISPID_DOCUMENTCOMPLETE);
170 typedef struct {
171 task_header_t header;
172 IUnknown *doc;
173 READYSTATE ready_state;
174 } ready_state_task_t;
176 static void ready_state_proc(DocHost *This, task_header_t *_task)
178 ready_state_task_t *task = (ready_state_task_t*)_task;
180 if(task->doc == This->document)
181 update_ready_state(This, task->ready_state);
183 IUnknown_Release(task->doc);
186 static void push_ready_state_task(DocHost *This, READYSTATE ready_state)
188 ready_state_task_t *task = heap_alloc(sizeof(ready_state_task_t));
190 IUnknown_AddRef(This->document);
191 task->doc = This->document;
192 task->ready_state = ready_state;
194 push_dochost_task(This, &task->header, ready_state_proc, FALSE);
197 static void object_available_proc(DocHost *This, task_header_t *task)
199 object_available(This);
202 HRESULT dochost_object_available(DocHost *This, IUnknown *doc)
204 READYSTATE ready_state;
205 task_header_t *task;
206 IOleObject *oleobj;
207 HRESULT hres;
209 IUnknown_AddRef(doc);
210 This->document = doc;
212 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
213 if(SUCCEEDED(hres)) {
214 CLSID clsid;
216 hres = IOleObject_GetUserClassID(oleobj, &clsid);
217 if(SUCCEEDED(hres))
218 TRACE("Got clsid %s\n",
219 IsEqualGUID(&clsid, &CLSID_HTMLDocument) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid));
221 hres = IOleObject_SetClientSite(oleobj, CLIENTSITE(This));
222 if(FAILED(hres))
223 FIXME("SetClientSite failed: %08x\n", hres);
225 IOleObject_Release(oleobj);
226 }else {
227 FIXME("Could not get IOleObject iface: %08x\n", hres);
230 /* FIXME: Call SetAdvise */
232 task = heap_alloc(sizeof(*task));
233 push_dochost_task(This, task, object_available_proc, FALSE);
235 hres = get_doc_ready_state(This, &ready_state);
236 if(SUCCEEDED(hres)) {
237 if(ready_state == READYSTATE_COMPLETE)
238 push_ready_state_task(This, READYSTATE_COMPLETE);
239 else
240 advise_prop_notif(This, TRUE);
243 return S_OK;
246 static LRESULT resize_document(DocHost *This, LONG width, LONG height)
248 RECT rect = {0, 0, width, height};
250 TRACE("(%p)->(%d %d)\n", This, width, height);
252 if(This->view)
253 IOleDocumentView_SetRect(This->view, &rect);
255 return 0;
258 static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
260 DocHost *This;
262 static const WCHAR wszTHIS[] = {'T','H','I','S',0};
264 if(msg == WM_CREATE) {
265 This = *(DocHost**)lParam;
266 SetPropW(hwnd, wszTHIS, This);
267 }else {
268 This = GetPropW(hwnd, wszTHIS);
271 switch(msg) {
272 case WM_SIZE:
273 return resize_document(This, LOWORD(lParam), HIWORD(lParam));
276 return DefWindowProcW(hwnd, msg, wParam, lParam);
279 void create_doc_view_hwnd(DocHost *This)
281 RECT rect;
283 static const WCHAR wszShell_DocObject_View[] =
284 {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
286 if(!doc_view_atom) {
287 static WNDCLASSEXW wndclass = {
288 sizeof(wndclass),
289 CS_PARENTDC,
290 doc_view_proc,
291 0, 0 /* native uses 4*/, NULL, NULL, NULL,
292 (HBRUSH)(COLOR_WINDOW + 1), NULL,
293 wszShell_DocObject_View,
294 NULL
297 wndclass.hInstance = shdocvw_hinstance;
299 doc_view_atom = RegisterClassExW(&wndclass);
302 GetClientRect(This->frame_hwnd, &rect); /* FIXME */
303 This->hwnd = CreateWindowExW(0, wszShell_DocObject_View,
304 wszShell_DocObject_View,
305 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP,
306 rect.left, rect.top, rect.right, rect.bottom, This->frame_hwnd,
307 NULL, shdocvw_hinstance, This);
310 void deactivate_document(DocHost *This)
312 IOleInPlaceObjectWindowless *winobj;
313 IOleObject *oleobj = NULL;
314 IHlinkTarget *hlink = NULL;
315 HRESULT hres;
317 if(This->is_prop_notif)
318 advise_prop_notif(This, FALSE);
320 if(This->view)
321 IOleDocumentView_UIActivate(This->view, FALSE);
323 hres = IUnknown_QueryInterface(This->document, &IID_IOleInPlaceObjectWindowless,
324 (void**)&winobj);
325 if(SUCCEEDED(hres)) {
326 IOleInPlaceObjectWindowless_InPlaceDeactivate(winobj);
327 IOleInPlaceObjectWindowless_Release(winobj);
330 if(This->view) {
331 IOleDocumentView_Show(This->view, FALSE);
332 IOleDocumentView_CloseView(This->view, 0);
333 IOleDocumentView_SetInPlaceSite(This->view, NULL);
334 IOleDocumentView_Release(This->view);
335 This->view = NULL;
338 hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj);
339 if(SUCCEEDED(hres))
340 IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
342 hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
343 if(SUCCEEDED(hres)) {
344 IHlinkTarget_SetBrowseContext(hlink, NULL);
345 IHlinkTarget_Release(hlink);
348 if(oleobj) {
349 IOleClientSite *client_site = NULL;
351 IOleObject_GetClientSite(oleobj, &client_site);
352 if(client_site) {
353 if(client_site == CLIENTSITE(This))
354 IOleObject_SetClientSite(oleobj, NULL);
355 IOleClientSite_Release(client_site);
358 IOleObject_Release(oleobj);
361 IUnknown_Release(This->document);
362 This->document = NULL;
365 void release_dochost_client(DocHost *This)
367 if(This->hwnd) {
368 DestroyWindow(This->hwnd);
369 This->hwnd = NULL;
372 if(This->hostui) {
373 IDocHostUIHandler_Release(This->hostui);
374 This->hostui = NULL;
377 if(This->client_disp) {
378 IDispatch_Release(This->client_disp);
379 This->client_disp = NULL;
382 if(This->frame) {
383 IOleInPlaceFrame_Release(This->frame);
384 This->frame = NULL;
388 #define OLECMD_THIS(iface) DEFINE_THIS(DocHost, OleCommandTarget, iface)
390 static HRESULT WINAPI ClOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
391 REFIID riid, void **ppv)
393 DocHost *This = OLECMD_THIS(iface);
394 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
397 static ULONG WINAPI ClOleCommandTarget_AddRef(IOleCommandTarget *iface)
399 DocHost *This = OLECMD_THIS(iface);
400 return IOleClientSite_AddRef(CLIENTSITE(This));
403 static ULONG WINAPI ClOleCommandTarget_Release(IOleCommandTarget *iface)
405 DocHost *This = OLECMD_THIS(iface);
406 return IOleClientSite_Release(CLIENTSITE(This));
409 static HRESULT WINAPI ClOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
410 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
412 DocHost *This = OLECMD_THIS(iface);
413 ULONG i= 0;
414 FIXME("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
415 pCmdText);
416 while (prgCmds && (cCmds > i)) {
417 FIXME("command_%u: %u, 0x%x\n", i, prgCmds[i].cmdID, prgCmds[i].cmdf);
418 i++;
420 return E_NOTIMPL;
423 static HRESULT WINAPI ClOleCommandTarget_Exec(IOleCommandTarget *iface,
424 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
425 VARIANT *pvaOut)
427 DocHost *This = OLECMD_THIS(iface);
428 FIXME("(%p)->(%s %d %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
429 nCmdexecopt, pvaIn, pvaOut);
430 return E_NOTIMPL;
433 #undef OLECMD_THIS
435 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
436 ClOleCommandTarget_QueryInterface,
437 ClOleCommandTarget_AddRef,
438 ClOleCommandTarget_Release,
439 ClOleCommandTarget_QueryStatus,
440 ClOleCommandTarget_Exec
443 #define DOCHOSTUI_THIS(iface) DEFINE_THIS(DocHost, DocHostUIHandler, iface)
445 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface,
446 REFIID riid, void **ppv)
448 DocHost *This = DOCHOSTUI_THIS(iface);
449 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
452 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
454 DocHost *This = DOCHOSTUI_THIS(iface);
455 return IOleClientSite_AddRef(CLIENTSITE(This));
458 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
460 DocHost *This = DOCHOSTUI_THIS(iface);
461 return IOleClientSite_Release(CLIENTSITE(This));
464 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface,
465 DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
467 DocHost *This = DOCHOSTUI_THIS(iface);
468 HRESULT hres;
470 TRACE("(%p)->(%d %p %p %p)\n", This, dwID, ppt, pcmdtReserved, pdispReserved);
472 if(This->hostui) {
473 hres = IDocHostUIHandler_ShowContextMenu(This->hostui, dwID, ppt, pcmdtReserved,
474 pdispReserved);
475 if(hres == S_OK)
476 return S_OK;
479 FIXME("default action not implemented\n");
480 return E_NOTIMPL;
483 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface,
484 DOCHOSTUIINFO *pInfo)
486 DocHost *This = DOCHOSTUI_THIS(iface);
487 HRESULT hres;
489 TRACE("(%p)->(%p)\n", This, pInfo);
491 if(This->hostui) {
492 hres = IDocHostUIHandler_GetHostInfo(This->hostui, pInfo);
493 if(SUCCEEDED(hres))
494 return hres;
497 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_OPENNEWWIN
498 | DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
499 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
500 return S_OK;
503 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
504 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
505 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
507 DocHost *This = DOCHOSTUI_THIS(iface);
508 FIXME("(%p)->(%d %p %p %p %p)\n", This, dwID, pActiveObject, pCommandTarget,
509 pFrame, pDoc);
510 return E_NOTIMPL;
513 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
515 DocHost *This = DOCHOSTUI_THIS(iface);
516 FIXME("(%p)\n", This);
517 return E_NOTIMPL;
520 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
522 DocHost *This = DOCHOSTUI_THIS(iface);
524 TRACE("(%p)\n", This);
526 if(!This->hostui)
527 return S_FALSE;
529 return IDocHostUIHandler_UpdateUI(This->hostui);
532 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface,
533 BOOL fEnable)
535 DocHost *This = DOCHOSTUI_THIS(iface);
536 FIXME("(%p)->(%x)\n", This, fEnable);
537 return E_NOTIMPL;
540 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface,
541 BOOL fActivate)
543 DocHost *This = DOCHOSTUI_THIS(iface);
544 FIXME("(%p)->(%x)\n", This, fActivate);
545 return E_NOTIMPL;
548 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface,
549 BOOL fActivate)
551 DocHost *This = DOCHOSTUI_THIS(iface);
552 FIXME("(%p)->(%x)\n", This, fActivate);
553 return E_NOTIMPL;
556 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface,
557 LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
559 DocHost *This = DOCHOSTUI_THIS(iface);
560 FIXME("(%p)->(%p %p %X)\n", This, prcBorder, pUIWindow, fRameWindow);
561 return E_NOTIMPL;
564 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface,
565 LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
567 DocHost *This = DOCHOSTUI_THIS(iface);
568 FIXME("(%p)->(%p %p %d)\n", This, lpMsg, pguidCmdGroup, nCmdID);
569 return E_NOTIMPL;
572 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
573 LPOLESTR *pchKey, DWORD dw)
575 DocHost *This = DOCHOSTUI_THIS(iface);
577 TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
579 if(This->hostui)
580 return IDocHostUIHandler_GetOptionKeyPath(This->hostui, pchKey, dw);
582 return S_OK;
585 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
586 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
588 DocHost *This = DOCHOSTUI_THIS(iface);
589 FIXME("(%p)\n", This);
590 return E_NOTIMPL;
593 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface,
594 IDispatch **ppDispatch)
596 DocHost *This = DOCHOSTUI_THIS(iface);
598 TRACE("(%p)->(%p)\n", This, ppDispatch);
600 if(This->hostui)
601 return IDocHostUIHandler_GetExternal(This->hostui, ppDispatch);
603 FIXME("default action not implemented\n");
604 return E_NOTIMPL;
607 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface,
608 DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
610 DocHost *This = DOCHOSTUI_THIS(iface);
612 TRACE("(%p)->(%d %s %p)\n", This, dwTranslate, debugstr_w(pchURLIn), ppchURLOut);
614 if(This->hostui)
615 return IDocHostUIHandler_TranslateUrl(This->hostui, dwTranslate,
616 pchURLIn, ppchURLOut);
618 return S_FALSE;
621 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface,
622 IDataObject *pDO, IDataObject **ppDORet)
624 DocHost *This = DOCHOSTUI_THIS(iface);
625 FIXME("(%p)->(%p %p)\n", This, pDO, ppDORet);
626 return E_NOTIMPL;
629 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
630 LPOLESTR *pchKey, DWORD dw)
632 DocHost *This = DOCHOSTUI_THIS(iface);
633 IDocHostUIHandler2 *handler;
634 HRESULT hres;
636 TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
638 if(!This->hostui)
639 return S_OK;
641 hres = IDocHostUIHandler_QueryInterface(This->hostui, &IID_IDocHostUIHandler2,
642 (void**)&handler);
643 if(SUCCEEDED(hres)) {
644 hres = IDocHostUIHandler2_GetOverrideKeyPath(handler, pchKey, dw);
645 IDocHostUIHandler2_Release(handler);
646 return hres;
649 return S_OK;
652 #undef DOCHOSTUI_THIS
654 static const IDocHostUIHandler2Vtbl DocHostUIHandler2Vtbl = {
655 DocHostUIHandler_QueryInterface,
656 DocHostUIHandler_AddRef,
657 DocHostUIHandler_Release,
658 DocHostUIHandler_ShowContextMenu,
659 DocHostUIHandler_GetHostInfo,
660 DocHostUIHandler_ShowUI,
661 DocHostUIHandler_HideUI,
662 DocHostUIHandler_UpdateUI,
663 DocHostUIHandler_EnableModeless,
664 DocHostUIHandler_OnDocWindowActivate,
665 DocHostUIHandler_OnFrameWindowActivate,
666 DocHostUIHandler_ResizeBorder,
667 DocHostUIHandler_TranslateAccelerator,
668 DocHostUIHandler_GetOptionKeyPath,
669 DocHostUIHandler_GetDropTarget,
670 DocHostUIHandler_GetExternal,
671 DocHostUIHandler_TranslateUrl,
672 DocHostUIHandler_FilterDataObject,
673 DocHostUIHandler_GetOverrideKeyPath
676 #define PROPNOTIF_THIS(iface) DEFINE_THIS(DocHost, IPropertyNotifySink, iface)
678 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
679 REFIID riid, void **ppv)
681 DocHost *This = PROPNOTIF_THIS(iface);
682 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
685 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
687 DocHost *This = PROPNOTIF_THIS(iface);
688 return IOleClientSite_AddRef(CLIENTSITE(This));
691 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
693 DocHost *This = PROPNOTIF_THIS(iface);
694 return IOleClientSite_Release(CLIENTSITE(This));
697 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
699 DocHost *This = PROPNOTIF_THIS(iface);
701 TRACE("(%p)->(%d)\n", This, dispID);
703 switch(dispID) {
704 case DISPID_READYSTATE: {
705 READYSTATE ready_state;
706 HRESULT hres;
708 hres = get_doc_ready_state(This, &ready_state);
709 if(FAILED(hres))
710 return hres;
712 if(ready_state == READYSTATE_COMPLETE)
713 advise_prop_notif(This, FALSE);
715 push_ready_state_task(This, ready_state);
716 break;
718 default:
719 FIXME("unimplemented dispid %d\n", dispID);
720 return E_NOTIMPL;
723 return S_OK;
726 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
728 DocHost *This = PROPNOTIF_THIS(iface);
729 FIXME("(%p)->(%d)\n", This, dispID);
730 return E_NOTIMPL;
733 #undef PROPNOTIF_THIS
735 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
736 PropertyNotifySink_QueryInterface,
737 PropertyNotifySink_AddRef,
738 PropertyNotifySink_Release,
739 PropertyNotifySink_OnChanged,
740 PropertyNotifySink_OnRequestEdit
743 void DocHost_Init(DocHost *This, IDispatch *disp)
745 This->lpDocHostUIHandlerVtbl = &DocHostUIHandler2Vtbl;
746 This->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;
747 This->lpIPropertyNotifySinkVtbl = &PropertyNotifySinkVtbl;
749 This->disp = disp;
751 This->client_disp = NULL;
753 This->document = NULL;
754 This->hostui = NULL;
755 This->frame = NULL;
757 This->hwnd = NULL;
758 This->frame_hwnd = NULL;
759 This->url = NULL;
761 This->silent = VARIANT_FALSE;
762 This->offline = VARIANT_FALSE;
764 This->ready_state = READYSTATE_UNINITIALIZED;
765 This->is_prop_notif = FALSE;
767 DocHost_ClientSite_Init(This);
768 DocHost_Frame_Init(This);
770 ConnectionPointContainer_Init(&This->cps, (IUnknown*)disp);
773 void DocHost_Release(DocHost *This)
775 release_dochost_client(This);
776 DocHost_ClientSite_Release(This);
778 ConnectionPointContainer_Destroy(&This->cps);
780 CoTaskMemFree(This->url);