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
23 DEFINE_OLEGUID(CGID_DocHostCmdPriv
, 0x000214D4L
, 0, 0);
25 #define DOCHOST_DOCCANNAVIGATE 0
27 /* Undocumented notification, see mshtml tests */
28 #define CMDID_EXPLORER_UPDATEHISTORY 38
30 static ATOM doc_view_atom
= 0;
32 void push_dochost_task(DocHost
*This
, task_header_t
*task
, task_proc_t proc
, task_destr_t destr
, BOOL send
)
39 is_empty
= list_empty(&This
->task_queue
);
40 list_add_tail(&This
->task_queue
, &task
->entry
);
43 SendMessageW(This
->frame_hwnd
, WM_DOCHOSTTASK
, 0, 0);
45 PostMessageW(This
->frame_hwnd
, WM_DOCHOSTTASK
, 0, 0);
48 LRESULT
process_dochost_tasks(DocHost
*This
)
52 while(!list_empty(&This
->task_queue
)) {
53 task
= LIST_ENTRY(This
->task_queue
.next
, task_header_t
, entry
);
54 list_remove(&task
->entry
);
56 task
->proc(This
, task
);
63 void abort_dochost_tasks(DocHost
*This
, task_proc_t proc
)
65 task_header_t
*task
, *cursor
;
67 LIST_FOR_EACH_ENTRY_SAFE(task
, cursor
, &This
->task_queue
, task_header_t
, entry
) {
68 if(proc
&& proc
!= task
->proc
)
71 list_remove(&task
->entry
);
76 static void notif_complete(DocHost
*This
, DISPID dispid
)
78 DISPPARAMS dispparams
;
83 dispparams
.cNamedArgs
= 0;
84 dispparams
.rgdispidNamedArgs
= NULL
;
85 dispparams
.rgvarg
= params
;
87 V_VT(params
) = (VT_BYREF
|VT_VARIANT
);
88 V_BYREF(params
) = &url
;
90 V_VT(params
+1) = VT_DISPATCH
;
91 V_DISPATCH(params
+1) = (IDispatch
*)This
->wb
;
94 V_BSTR(&url
) = SysAllocString(This
->url
);
96 TRACE("%d >>>\n", dispid
);
97 call_sink(This
->cps
.wbe2
, dispid
, &dispparams
);
98 TRACE("%d <<<\n", dispid
);
100 SysFreeString(V_BSTR(&url
));
101 This
->busy
= VARIANT_FALSE
;
104 static void object_available(DocHost
*This
)
109 TRACE("(%p)\n", This
);
111 if(!This
->document
) {
112 WARN("document == NULL\n");
116 hres
= IUnknown_QueryInterface(This
->document
, &IID_IHlinkTarget
, (void**)&hlink
);
117 if(SUCCEEDED(hres
)) {
118 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
119 IHlinkTarget_Release(hlink
);
121 FIXME("Navigate failed\n");
123 IOleObject
*ole_object
;
126 TRACE("No IHlink iface\n");
128 hres
= IUnknown_QueryInterface(This
->document
, &IID_IOleObject
, (void**)&ole_object
);
130 FIXME("Could not get IOleObject iface: %08x\n", hres
);
134 GetClientRect(This
->hwnd
, &rect
);
135 hres
= IOleObject_DoVerb(ole_object
, OLEIVERB_SHOW
, NULL
, &This
->IOleClientSite_iface
, -1, This
->hwnd
, &rect
);
136 IOleObject_Release(ole_object
);
138 FIXME("DoVerb failed: %08x\n", hres
);
142 static HRESULT
get_doc_ready_state(DocHost
*This
, READYSTATE
*ret
)
144 DISPPARAMS dp
= {NULL
,NULL
,0,0};
150 hres
= IUnknown_QueryInterface(This
->document
, &IID_IDispatch
, (void**)&disp
);
154 hres
= IDispatch_Invoke(disp
, DISPID_READYSTATE
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
, DISPATCH_PROPERTYGET
,
155 &dp
, &var
, &ei
, NULL
);
156 IDispatch_Release(disp
);
158 WARN("Invoke(DISPID_READYSTATE failed: %08x\n", hres
);
162 if(V_VT(&var
) != VT_I4
) {
163 WARN("V_VT(var) = %d\n", V_VT(&var
));
172 static void advise_prop_notif(DocHost
*This
, BOOL set
)
174 IConnectionPointContainer
*cp_container
;
175 IConnectionPoint
*cp
;
178 hres
= IUnknown_QueryInterface(This
->document
, &IID_IConnectionPointContainer
, (void**)&cp_container
);
182 hres
= IConnectionPointContainer_FindConnectionPoint(cp_container
, &IID_IPropertyNotifySink
, &cp
);
183 IConnectionPointContainer_Release(cp_container
);
188 hres
= IConnectionPoint_Advise(cp
, (IUnknown
*)&This
->IPropertyNotifySink_iface
, &This
->prop_notif_cookie
);
190 hres
= IConnectionPoint_Unadvise(cp
, This
->prop_notif_cookie
);
191 IConnectionPoint_Release(cp
);
194 This
->is_prop_notif
= set
;
197 void set_doc_state(DocHost
*This
, READYSTATE doc_state
)
199 This
->doc_state
= doc_state
;
200 if(doc_state
> This
->ready_state
)
201 This
->ready_state
= doc_state
;
204 static void update_ready_state(DocHost
*This
, READYSTATE ready_state
)
206 if(ready_state
> READYSTATE_LOADING
&& This
->travellog
.loading_pos
!= -1) {
207 WARN("histupdate not notified\n");
208 This
->travellog
.position
= This
->travellog
.loading_pos
;
209 This
->travellog
.loading_pos
= -1;
212 if(ready_state
> READYSTATE_LOADING
&& This
->doc_state
<= READYSTATE_LOADING
&& !This
->browser_service
/* FIXME */)
213 notif_complete(This
, DISPID_NAVIGATECOMPLETE2
);
215 if(ready_state
== READYSTATE_COMPLETE
&& This
->doc_state
< READYSTATE_COMPLETE
) {
216 set_doc_state(This
, READYSTATE_COMPLETE
);
217 if(!This
->browser_service
) /* FIXME: Not fully correct */
218 notif_complete(This
, DISPID_DOCUMENTCOMPLETE
);
220 set_doc_state(This
, ready_state
);
225 task_header_t header
;
227 READYSTATE ready_state
;
228 } ready_state_task_t
;
230 static void ready_state_task_destr(task_header_t
*_task
)
232 ready_state_task_t
*task
= (ready_state_task_t
*)_task
;
234 IUnknown_Release(task
->doc
);
238 static void ready_state_proc(DocHost
*This
, task_header_t
*_task
)
240 ready_state_task_t
*task
= (ready_state_task_t
*)_task
;
242 if(task
->doc
== This
->document
)
243 update_ready_state(This
, task
->ready_state
);
246 static void push_ready_state_task(DocHost
*This
, READYSTATE ready_state
)
248 ready_state_task_t
*task
= heap_alloc(sizeof(ready_state_task_t
));
250 IUnknown_AddRef(This
->document
);
251 task
->doc
= This
->document
;
252 task
->ready_state
= ready_state
;
254 push_dochost_task(This
, &task
->header
, ready_state_proc
, ready_state_task_destr
, FALSE
);
257 static void object_available_task_destr(task_header_t
*task
)
262 static void object_available_proc(DocHost
*This
, task_header_t
*task
)
264 object_available(This
);
267 HRESULT
dochost_object_available(DocHost
*This
, IUnknown
*doc
)
269 READYSTATE ready_state
;
274 IUnknown_AddRef(doc
);
275 This
->document
= doc
;
277 hres
= IUnknown_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
278 if(SUCCEEDED(hres
)) {
281 hres
= IOleObject_GetUserClassID(oleobj
, &clsid
);
283 TRACE("Got clsid %s\n",
284 IsEqualGUID(&clsid
, &CLSID_HTMLDocument
) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid
));
286 hres
= IOleObject_SetClientSite(oleobj
, &This
->IOleClientSite_iface
);
288 FIXME("SetClientSite failed: %08x\n", hres
);
290 IOleObject_Release(oleobj
);
292 FIXME("Could not get IOleObject iface: %08x\n", hres
);
295 /* FIXME: Call SetAdvise */
297 task
= heap_alloc(sizeof(*task
));
298 push_dochost_task(This
, task
, object_available_proc
, object_available_task_destr
, FALSE
);
300 hres
= get_doc_ready_state(This
, &ready_state
);
301 if(SUCCEEDED(hres
)) {
302 if(ready_state
== READYSTATE_COMPLETE
)
303 push_ready_state_task(This
, READYSTATE_COMPLETE
);
304 if(ready_state
!= READYSTATE_COMPLETE
|| This
->doc_navigate
)
305 advise_prop_notif(This
, TRUE
);
306 }else if(!This
->doc_navigate
) {
307 /* If we can't get document's ready state, there is not much we can do.
308 * Assume that document is complete at this point. */
309 push_ready_state_task(This
, READYSTATE_COMPLETE
);
315 static LRESULT
resize_document(DocHost
*This
, LONG width
, LONG height
)
317 RECT rect
= {0, 0, width
, height
};
319 TRACE("(%p)->(%d %d)\n", This
, width
, height
);
322 IOleDocumentView_SetRect(This
->view
, &rect
);
327 static LRESULT WINAPI
doc_view_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
331 static const WCHAR wszTHIS
[] = {'T','H','I','S',0};
333 if(msg
== WM_CREATE
) {
334 This
= *(DocHost
**)lParam
;
335 SetPropW(hwnd
, wszTHIS
, This
);
337 This
= GetPropW(hwnd
, wszTHIS
);
342 return resize_document(This
, LOWORD(lParam
), HIWORD(lParam
));
345 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);
348 static void free_travellog_entry(travellog_entry_t
*entry
)
351 IStream_Release(entry
->stream
);
352 heap_free(entry
->url
);
355 static IStream
*get_travellog_stream(DocHost
*This
)
357 IPersistHistory
*persist_history
;
361 hres
= IUnknown_QueryInterface(This
->document
, &IID_IPersistHistory
, (void**)&persist_history
);
365 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
367 hres
= IPersistHistory_SaveHistory(persist_history
, stream
);
368 IPersistHistory_Release(persist_history
);
370 IStream_Release(stream
);
377 static void dump_travellog(DocHost
*This
)
381 for(i
=0; i
< This
->travellog
.length
; i
++)
382 TRACE("%d: %s %s\n", i
, i
== This
->travellog
.position
? "=>" : " ", debugstr_w(This
->travellog
.log
[i
].url
));
383 if(i
== This
->travellog
.position
)
384 TRACE("%d: =>\n", i
);
387 static void update_travellog(DocHost
*This
)
389 travellog_entry_t
*new_entry
;
391 if(This
->travellog
.loading_pos
== -1) {
392 /* Clear forward history. */
393 if(!This
->travellog
.log
) {
394 This
->travellog
.log
= heap_alloc(4 * sizeof(*This
->travellog
.log
));
395 if(!This
->travellog
.log
)
398 This
->travellog
.size
= 4;
399 }else if(This
->travellog
.size
< This
->travellog
.position
+1) {
400 travellog_entry_t
*new_travellog
;
402 new_travellog
= heap_realloc(This
->travellog
.log
, This
->travellog
.size
*2*sizeof(*This
->travellog
.log
));
406 This
->travellog
.log
= new_travellog
;
407 This
->travellog
.size
*= 2;
410 while(This
->travellog
.length
> This
->travellog
.position
)
411 free_travellog_entry(This
->travellog
.log
+ --This
->travellog
.length
);
414 new_entry
= This
->travellog
.log
+ This
->travellog
.position
;
416 new_entry
->url
= heap_strdupW(This
->url
);
417 TRACE("Adding %s at %d\n", debugstr_w(This
->url
), This
->travellog
.position
);
421 new_entry
->stream
= get_travellog_stream(This
);
423 if(This
->travellog
.loading_pos
== -1) {
424 This
->travellog
.position
++;
426 This
->travellog
.position
= This
->travellog
.loading_pos
;
427 This
->travellog
.loading_pos
= -1;
429 if(This
->travellog
.position
> This
->travellog
.length
)
430 This
->travellog
.length
= This
->travellog
.position
;
432 dump_travellog(This
);
435 void create_doc_view_hwnd(DocHost
*This
)
439 static const WCHAR wszShell_DocObject_View
[] =
440 {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
443 static WNDCLASSEXW wndclass
= {
447 0, 0 /* native uses 4*/, NULL
, NULL
, NULL
,
448 (HBRUSH
)(COLOR_WINDOW
+ 1), NULL
,
449 wszShell_DocObject_View
,
453 wndclass
.hInstance
= ieframe_instance
;
455 doc_view_atom
= RegisterClassExW(&wndclass
);
458 This
->container_vtbl
->GetDocObjRect(This
, &rect
);
459 This
->hwnd
= CreateWindowExW(0, wszShell_DocObject_View
,
460 wszShell_DocObject_View
,
461 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
| WS_TABSTOP
,
462 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
, This
->frame_hwnd
,
463 NULL
, ieframe_instance
, This
);
466 void deactivate_document(DocHost
*This
)
468 IOleInPlaceObjectWindowless
*winobj
;
469 IOleObject
*oleobj
= NULL
;
470 IHlinkTarget
*hlink
= NULL
;
473 if(!This
->document
) return;
475 if(This
->doc_navigate
) {
476 IUnknown_Release(This
->doc_navigate
);
477 This
->doc_navigate
= NULL
;
480 if(This
->is_prop_notif
)
481 advise_prop_notif(This
, FALSE
);
484 IOleDocumentView_UIActivate(This
->view
, FALSE
);
486 hres
= IUnknown_QueryInterface(This
->document
, &IID_IOleInPlaceObjectWindowless
,
488 if(SUCCEEDED(hres
)) {
489 IOleInPlaceObjectWindowless_InPlaceDeactivate(winobj
);
490 IOleInPlaceObjectWindowless_Release(winobj
);
494 IOleDocumentView_Show(This
->view
, FALSE
);
495 IOleDocumentView_CloseView(This
->view
, 0);
496 IOleDocumentView_SetInPlaceSite(This
->view
, NULL
);
497 IOleDocumentView_Release(This
->view
);
501 hres
= IUnknown_QueryInterface(This
->document
, &IID_IOleObject
, (void**)&oleobj
);
503 IOleObject_Close(oleobj
, OLECLOSE_NOSAVE
);
505 hres
= IUnknown_QueryInterface(This
->document
, &IID_IHlinkTarget
, (void**)&hlink
);
506 if(SUCCEEDED(hres
)) {
507 IHlinkTarget_SetBrowseContext(hlink
, NULL
);
508 IHlinkTarget_Release(hlink
);
512 IOleClientSite
*client_site
= NULL
;
514 IOleObject_GetClientSite(oleobj
, &client_site
);
516 if(client_site
== &This
->IOleClientSite_iface
)
517 IOleObject_SetClientSite(oleobj
, NULL
);
518 IOleClientSite_Release(client_site
);
521 IOleObject_Release(oleobj
);
524 IUnknown_Release(This
->document
);
525 This
->document
= NULL
;
528 HRESULT
refresh_document(DocHost
*This
)
530 IOleCommandTarget
*cmdtrg
;
534 if(!This
->document
) {
535 FIXME("no document\n");
539 hres
= IUnknown_QueryInterface(This
->document
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
543 V_VT(&vin
) = VT_EMPTY
;
544 V_VT(&vout
) = VT_EMPTY
;
545 hres
= IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_REFRESH
, OLECMDEXECOPT_PROMPTUSER
, &vin
, &vout
);
546 IOleCommandTarget_Release(cmdtrg
);
554 void release_dochost_client(DocHost
*This
)
557 DestroyWindow(This
->hwnd
);
562 IDocHostUIHandler_Release(This
->hostui
);
566 if(This
->client_disp
) {
567 IDispatch_Release(This
->client_disp
);
568 This
->client_disp
= NULL
;
572 IOleInPlaceFrame_Release(This
->frame
);
577 static inline DocHost
*impl_from_IOleCommandTarget(IOleCommandTarget
*iface
)
579 return CONTAINING_RECORD(iface
, DocHost
, IOleCommandTarget_iface
);
582 static HRESULT WINAPI
ClOleCommandTarget_QueryInterface(IOleCommandTarget
*iface
,
583 REFIID riid
, void **ppv
)
585 DocHost
*This
= impl_from_IOleCommandTarget(iface
);
586 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
589 static ULONG WINAPI
ClOleCommandTarget_AddRef(IOleCommandTarget
*iface
)
591 DocHost
*This
= impl_from_IOleCommandTarget(iface
);
592 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
595 static ULONG WINAPI
ClOleCommandTarget_Release(IOleCommandTarget
*iface
)
597 DocHost
*This
= impl_from_IOleCommandTarget(iface
);
598 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
601 static HRESULT WINAPI
ClOleCommandTarget_QueryStatus(IOleCommandTarget
*iface
,
602 const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
604 DocHost
*This
= impl_from_IOleCommandTarget(iface
);
606 FIXME("(%p)->(%s %u %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), cCmds
, prgCmds
,
608 while (prgCmds
&& (cCmds
> i
)) {
609 FIXME("command_%u: %u, 0x%x\n", i
, prgCmds
[i
].cmdID
, prgCmds
[i
].cmdf
);
615 static HRESULT WINAPI
ClOleCommandTarget_Exec(IOleCommandTarget
*iface
,
616 const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
,
619 DocHost
*This
= impl_from_IOleCommandTarget(iface
);
621 TRACE("(%p)->(%s %d %d %s %s)\n", This
, debugstr_guid(pguidCmdGroup
), nCmdID
, nCmdexecopt
,
622 debugstr_variant(pvaIn
), debugstr_variant(pvaOut
));
626 case OLECMDID_UPDATECOMMANDS
:
627 case OLECMDID_SETDOWNLOADSTATE
:
628 return This
->container_vtbl
->exec(This
, pguidCmdGroup
, nCmdID
, nCmdexecopt
, pvaIn
, pvaOut
);
630 FIXME("Unimplemented cmdid %d\n", nCmdID
);
635 if(IsEqualGUID(pguidCmdGroup
, &CGID_DocHostCmdPriv
)) {
637 case DOCHOST_DOCCANNAVIGATE
:
638 if(!pvaIn
|| V_VT(pvaIn
) != VT_UNKNOWN
)
641 if(This
->doc_navigate
)
642 IUnknown_Release(This
->doc_navigate
);
643 IUnknown_AddRef(V_UNKNOWN(pvaIn
));
644 This
->doc_navigate
= V_UNKNOWN(pvaIn
);
649 SAFEARRAY
*sa
= V_ARRAY(pvaIn
);
650 VARIANT status_code
, url
, htmlwindow
;
654 if(V_VT(pvaIn
) != VT_ARRAY
|| !sa
|| (SafeArrayGetDim(sa
) != 1))
658 hres
= SafeArrayGetElement(sa
, &ind
, &status_code
);
659 if(FAILED(hres
) || V_VT(&status_code
)!=VT_I4
)
663 hres
= SafeArrayGetElement(sa
, &ind
, &url
);
664 if(FAILED(hres
) || V_VT(&url
)!=VT_BSTR
)
668 hres
= SafeArrayGetElement(sa
, &ind
, &htmlwindow
);
669 if(FAILED(hres
) || V_VT(&htmlwindow
)!=VT_UNKNOWN
|| !V_UNKNOWN(&htmlwindow
))
672 hres
= IUnknown_QueryInterface(V_UNKNOWN(&htmlwindow
), &IID_IHTMLWindow2
, (void**)&win2
);
676 handle_navigation_error(This
, V_I4(&status_code
), V_BSTR(&url
), win2
);
677 IHTMLWindow2_Release(win2
);
682 FIXME("unsupported command %d of CGID_DocHostCmdPriv\n", nCmdID
);
687 if(IsEqualGUID(pguidCmdGroup
, &CGID_Explorer
)) {
689 case CMDID_EXPLORER_UPDATEHISTORY
:
690 update_travellog(This
);
694 FIXME("Unimplemented cmdid %d of CGID_Explorer\n", nCmdID
);
699 if(IsEqualGUID(pguidCmdGroup
, &CGID_ShellDocView
)) {
702 FIXME("Unimplemented cmdid %d of CGID_ShellDocView\n", nCmdID
);
707 if(IsEqualGUID(&CGID_DocHostCommandHandler
, pguidCmdGroup
))
708 return This
->container_vtbl
->exec(This
, pguidCmdGroup
, nCmdID
, nCmdexecopt
, pvaIn
, pvaOut
);
710 FIXME("Unimplemented cmdid %d of group %s\n", nCmdID
, debugstr_guid(pguidCmdGroup
));
714 static const IOleCommandTargetVtbl OleCommandTargetVtbl
= {
715 ClOleCommandTarget_QueryInterface
,
716 ClOleCommandTarget_AddRef
,
717 ClOleCommandTarget_Release
,
718 ClOleCommandTarget_QueryStatus
,
719 ClOleCommandTarget_Exec
722 static inline DocHost
*impl_from_IDocHostUIHandler2(IDocHostUIHandler2
*iface
)
724 return CONTAINING_RECORD(iface
, DocHost
, IDocHostUIHandler2_iface
);
727 static HRESULT WINAPI
DocHostUIHandler_QueryInterface(IDocHostUIHandler2
*iface
,
728 REFIID riid
, void **ppv
)
730 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
731 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
734 static ULONG WINAPI
DocHostUIHandler_AddRef(IDocHostUIHandler2
*iface
)
736 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
737 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
740 static ULONG WINAPI
DocHostUIHandler_Release(IDocHostUIHandler2
*iface
)
742 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
743 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
746 static HRESULT WINAPI
DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2
*iface
,
747 DWORD dwID
, POINT
*ppt
, IUnknown
*pcmdtReserved
, IDispatch
*pdispReserved
)
749 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
752 TRACE("(%p)->(%d %p %p %p)\n", This
, dwID
, ppt
, pcmdtReserved
, pdispReserved
);
755 hres
= IDocHostUIHandler_ShowContextMenu(This
->hostui
, dwID
, ppt
, pcmdtReserved
,
761 FIXME("default action not implemented\n");
765 static HRESULT WINAPI
DocHostUIHandler_GetHostInfo(IDocHostUIHandler2
*iface
,
766 DOCHOSTUIINFO
*pInfo
)
768 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
771 TRACE("(%p)->(%p)\n", This
, pInfo
);
774 hres
= IDocHostUIHandler_GetHostInfo(This
->hostui
, pInfo
);
779 pInfo
->dwFlags
= DOCHOSTUIFLAG_DISABLE_HELP_MENU
| DOCHOSTUIFLAG_OPENNEWWIN
780 | DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8
| DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
781 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION
;
785 static HRESULT WINAPI
DocHostUIHandler_ShowUI(IDocHostUIHandler2
*iface
, DWORD dwID
,
786 IOleInPlaceActiveObject
*pActiveObject
, IOleCommandTarget
*pCommandTarget
,
787 IOleInPlaceFrame
*pFrame
, IOleInPlaceUIWindow
*pDoc
)
789 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
790 FIXME("(%p)->(%d %p %p %p %p)\n", This
, dwID
, pActiveObject
, pCommandTarget
,
795 static HRESULT WINAPI
DocHostUIHandler_HideUI(IDocHostUIHandler2
*iface
)
797 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
798 FIXME("(%p)\n", This
);
802 static HRESULT WINAPI
DocHostUIHandler_UpdateUI(IDocHostUIHandler2
*iface
)
804 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
806 TRACE("(%p)\n", This
);
811 return IDocHostUIHandler_UpdateUI(This
->hostui
);
814 static HRESULT WINAPI
DocHostUIHandler_EnableModeless(IDocHostUIHandler2
*iface
,
817 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
818 FIXME("(%p)->(%x)\n", This
, fEnable
);
822 static HRESULT WINAPI
DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2
*iface
,
825 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
826 FIXME("(%p)->(%x)\n", This
, fActivate
);
830 static HRESULT WINAPI
DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2
*iface
,
833 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
834 FIXME("(%p)->(%x)\n", This
, fActivate
);
838 static HRESULT WINAPI
DocHostUIHandler_ResizeBorder(IDocHostUIHandler2
*iface
,
839 LPCRECT prcBorder
, IOleInPlaceUIWindow
*pUIWindow
, BOOL fRameWindow
)
841 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
842 FIXME("(%p)->(%p %p %X)\n", This
, prcBorder
, pUIWindow
, fRameWindow
);
846 static HRESULT WINAPI
DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2
*iface
,
847 LPMSG lpMsg
, const GUID
*pguidCmdGroup
, DWORD nCmdID
)
849 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
850 HRESULT hr
= S_FALSE
;
851 TRACE("(%p)->(%p %p %d)\n", This
, lpMsg
, pguidCmdGroup
, nCmdID
);
854 hr
= IDocHostUIHandler_TranslateAccelerator(This
->hostui
, lpMsg
, pguidCmdGroup
, nCmdID
);
859 static HRESULT WINAPI
DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2
*iface
,
860 LPOLESTR
*pchKey
, DWORD dw
)
862 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
864 TRACE("(%p)->(%p %d)\n", This
, pchKey
, dw
);
867 return IDocHostUIHandler_GetOptionKeyPath(This
->hostui
, pchKey
, dw
);
872 static HRESULT WINAPI
DocHostUIHandler_GetDropTarget(IDocHostUIHandler2
*iface
,
873 IDropTarget
*pDropTarget
, IDropTarget
**ppDropTarget
)
875 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
876 FIXME("(%p)\n", This
);
880 static HRESULT WINAPI
DocHostUIHandler_GetExternal(IDocHostUIHandler2
*iface
,
881 IDispatch
**ppDispatch
)
883 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
885 TRACE("(%p)->(%p)\n", This
, ppDispatch
);
888 return IDocHostUIHandler_GetExternal(This
->hostui
, ppDispatch
);
890 if(!This
->shell_ui_helper
) {
893 hres
= create_shell_ui_helper(&This
->shell_ui_helper
);
898 *ppDispatch
= (IDispatch
*)This
->shell_ui_helper
;
899 IDispatch_AddRef(*ppDispatch
);
903 static HRESULT WINAPI
DocHostUIHandler_TranslateUrl(IDocHostUIHandler2
*iface
,
904 DWORD dwTranslate
, OLECHAR
*pchURLIn
, OLECHAR
**ppchURLOut
)
906 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
908 TRACE("(%p)->(%d %s %p)\n", This
, dwTranslate
, debugstr_w(pchURLIn
), ppchURLOut
);
911 return IDocHostUIHandler_TranslateUrl(This
->hostui
, dwTranslate
,
912 pchURLIn
, ppchURLOut
);
917 static HRESULT WINAPI
DocHostUIHandler_FilterDataObject(IDocHostUIHandler2
*iface
,
918 IDataObject
*pDO
, IDataObject
**ppDORet
)
920 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
921 FIXME("(%p)->(%p %p)\n", This
, pDO
, ppDORet
);
925 static HRESULT WINAPI
DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2
*iface
,
926 LPOLESTR
*pchKey
, DWORD dw
)
928 DocHost
*This
= impl_from_IDocHostUIHandler2(iface
);
929 IDocHostUIHandler2
*handler
;
932 TRACE("(%p)->(%p %d)\n", This
, pchKey
, dw
);
937 hres
= IDocHostUIHandler_QueryInterface(This
->hostui
, &IID_IDocHostUIHandler2
,
939 if(SUCCEEDED(hres
)) {
940 hres
= IDocHostUIHandler2_GetOverrideKeyPath(handler
, pchKey
, dw
);
941 IDocHostUIHandler2_Release(handler
);
948 static const IDocHostUIHandler2Vtbl DocHostUIHandler2Vtbl
= {
949 DocHostUIHandler_QueryInterface
,
950 DocHostUIHandler_AddRef
,
951 DocHostUIHandler_Release
,
952 DocHostUIHandler_ShowContextMenu
,
953 DocHostUIHandler_GetHostInfo
,
954 DocHostUIHandler_ShowUI
,
955 DocHostUIHandler_HideUI
,
956 DocHostUIHandler_UpdateUI
,
957 DocHostUIHandler_EnableModeless
,
958 DocHostUIHandler_OnDocWindowActivate
,
959 DocHostUIHandler_OnFrameWindowActivate
,
960 DocHostUIHandler_ResizeBorder
,
961 DocHostUIHandler_TranslateAccelerator
,
962 DocHostUIHandler_GetOptionKeyPath
,
963 DocHostUIHandler_GetDropTarget
,
964 DocHostUIHandler_GetExternal
,
965 DocHostUIHandler_TranslateUrl
,
966 DocHostUIHandler_FilterDataObject
,
967 DocHostUIHandler_GetOverrideKeyPath
970 static inline DocHost
*impl_from_IPropertyNotifySink(IPropertyNotifySink
*iface
)
972 return CONTAINING_RECORD(iface
, DocHost
, IPropertyNotifySink_iface
);
975 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
976 REFIID riid
, void **ppv
)
978 DocHost
*This
= impl_from_IPropertyNotifySink(iface
);
979 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
982 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
984 DocHost
*This
= impl_from_IPropertyNotifySink(iface
);
985 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
988 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
990 DocHost
*This
= impl_from_IPropertyNotifySink(iface
);
991 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
994 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
996 DocHost
*This
= impl_from_IPropertyNotifySink(iface
);
998 TRACE("(%p)->(%d)\n", This
, dispID
);
1001 case DISPID_READYSTATE
: {
1002 READYSTATE ready_state
;
1005 hres
= get_doc_ready_state(This
, &ready_state
);
1009 if(ready_state
== READYSTATE_COMPLETE
&& !This
->doc_navigate
)
1010 advise_prop_notif(This
, FALSE
);
1012 update_ready_state(This
, ready_state
);
1016 FIXME("unimplemented dispid %d\n", dispID
);
1023 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
1025 DocHost
*This
= impl_from_IPropertyNotifySink(iface
);
1026 FIXME("(%p)->(%d)\n", This
, dispID
);
1030 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
1031 PropertyNotifySink_QueryInterface
,
1032 PropertyNotifySink_AddRef
,
1033 PropertyNotifySink_Release
,
1034 PropertyNotifySink_OnChanged
,
1035 PropertyNotifySink_OnRequestEdit
1038 void DocHost_Init(DocHost
*This
, IWebBrowser2
*wb
, const IDocHostContainerVtbl
* container
)
1040 This
->IDocHostUIHandler2_iface
.lpVtbl
= &DocHostUIHandler2Vtbl
;
1041 This
->IOleCommandTarget_iface
.lpVtbl
= &OleCommandTargetVtbl
;
1042 This
->IPropertyNotifySink_iface
.lpVtbl
= &PropertyNotifySinkVtbl
;
1045 This
->container_vtbl
= container
;
1047 This
->ready_state
= READYSTATE_UNINITIALIZED
;
1048 list_init(&This
->task_queue
);
1050 This
->travellog
.loading_pos
= -1;
1052 DocHost_ClientSite_Init(This
);
1053 DocHost_Frame_Init(This
);
1055 ConnectionPointContainer_Init(&This
->cps
, (IUnknown
*)wb
);
1056 IEHTMLWindow_Init(This
);
1057 NewWindowManager_Init(This
);
1060 void DocHost_Release(DocHost
*This
)
1062 if(This
->shell_ui_helper
)
1063 IShellUIHelper2_Release(This
->shell_ui_helper
);
1065 abort_dochost_tasks(This
, NULL
);
1066 release_dochost_client(This
);
1067 DocHost_ClientSite_Release(This
);
1069 ConnectionPointContainer_Destroy(&This
->cps
);
1071 while(This
->travellog
.length
)
1072 free_travellog_entry(This
->travellog
.log
+ --This
->travellog
.length
);
1073 heap_free(This
->travellog
.log
);
1075 heap_free(This
->url
);