2 * Copyright 2005 Jacek Caban
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
33 #define NO_SHLWAPI_REG
36 #include "wine/debug.h"
38 #include "mshtml_private.h"
39 #include "htmlscript.h"
40 #include "htmlevent.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
46 /* Undocumented notification, see tests */
47 #define CMDID_EXPLORER_UPDATEHISTORY 38
54 } download_proc_task_t
;
56 static void notify_travellog_update(HTMLDocumentObj
*doc
)
58 IOleCommandTarget
*cmdtrg
;
64 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
71 IOleCommandTarget_Exec(cmdtrg
, &CGID_Explorer
, CMDID_EXPLORER_UPDATEHISTORY
, 0, &vin
, NULL
);
72 IOleCommandTarget_Release(cmdtrg
);
76 void set_current_uri(HTMLOuterWindow
*window
, IUri
*uri
)
79 IUri_Release(window
->uri
);
83 if(window
->uri_nofrag
) {
84 IUri_Release(window
->uri_nofrag
);
85 window
->uri_nofrag
= NULL
;
88 SysFreeString(window
->url
);
97 window
->uri_nofrag
= get_uri_nofrag(uri
);
98 if(!window
->uri_nofrag
) {
99 FIXME("get_uri_nofrag failed\n");
101 window
->uri_nofrag
= uri
;
104 IUri_GetDisplayUri(uri
, &window
->url
);
107 void set_current_mon(HTMLOuterWindow
*This
, IMoniker
*mon
, DWORD flags
)
109 IUriContainer
*uri_container
;
114 if(This
->browser
&& !(flags
& (BINDING_REPLACE
|BINDING_REFRESH
))) {
115 if(is_main_content_window(This
))
116 notify_travellog_update(This
->browser
->doc
);
118 TRACE("Skipping travellog update for frame navigation.\n");
120 IMoniker_Release(This
->mon
);
124 This
->load_flags
= flags
;
128 IMoniker_AddRef(mon
);
131 hres
= IMoniker_QueryInterface(mon
, &IID_IUriContainer
, (void**)&uri_container
);
132 if(SUCCEEDED(hres
)) {
133 hres
= IUriContainer_GetIUri(uri_container
, &uri
);
134 IUriContainer_Release(uri_container
);
136 WARN("GetIUri failed: %08lx\n", hres
);
144 hres
= IMoniker_GetDisplayName(mon
, NULL
, NULL
, &url
);
145 if(SUCCEEDED(hres
)) {
146 hres
= create_uri(url
, 0, &uri
);
148 WARN("CreateUri failed: %08lx\n", hres
);
149 set_current_uri(This
, NULL
);
150 This
->url
= SysAllocString(url
);
156 WARN("GetDisplayName failed: %08lx\n", hres
);
160 set_current_uri(This
, uri
);
164 if(is_main_content_window(This
))
165 update_browser_script_mode(This
->browser
, uri
);
168 HRESULT
create_uri(const WCHAR
*uri_str
, DWORD flags
, IUri
**uri
)
170 return CreateUri(uri_str
, flags
| Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME
, 0, uri
);
173 HRESULT
create_relative_uri(HTMLOuterWindow
*window
, const WCHAR
*rel_uri
, IUri
**uri
)
176 ? CoInternetCombineUrlEx(window
->uri
, rel_uri
, URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
, uri
, 0)
177 : create_uri(rel_uri
, 0, uri
);
180 void set_download_state(HTMLDocumentObj
*doc
, int state
)
183 IOleCommandTarget
*olecmd
;
186 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
187 if(SUCCEEDED(hres
)) {
193 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETDOWNLOADSTATE
,
194 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
195 IOleCommandTarget_Release(olecmd
);
199 doc
->download_state
= state
;
202 static void set_progress_proc(task_t
*_task
)
204 docobj_task_t
*task
= (docobj_task_t
*)_task
;
205 IOleCommandTarget
*olecmd
= NULL
;
206 HTMLDocumentObj
*doc
= task
->doc
;
209 TRACE("(%p)\n", doc
);
212 IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
215 VARIANT progress_max
, progress
;
217 V_VT(&progress_max
) = VT_I4
;
218 V_I4(&progress_max
) = 0; /* FIXME */
219 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETPROGRESSMAX
, OLECMDEXECOPT_DONTPROMPTUSER
,
220 &progress_max
, NULL
);
222 V_VT(&progress
) = VT_I4
;
223 V_I4(&progress
) = 0; /* FIXME */
224 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETPROGRESSPOS
, OLECMDEXECOPT_DONTPROMPTUSER
,
226 IOleCommandTarget_Release(olecmd
);
229 if(doc
->nscontainer
->usermode
== EDITMODE
&& doc
->hostui
) {
230 DOCHOSTUIINFO hostinfo
;
232 memset(&hostinfo
, 0, sizeof(DOCHOSTUIINFO
));
233 hostinfo
.cbSize
= sizeof(DOCHOSTUIINFO
);
234 hres
= IDocHostUIHandler_GetHostInfo(doc
->hostui
, &hostinfo
);
236 /* FIXME: use hostinfo */
237 TRACE("hostinfo = {%lu %08lx %08lx %s %s}\n",
238 hostinfo
.cbSize
, hostinfo
.dwFlags
, hostinfo
.dwDoubleClick
,
239 debugstr_w(hostinfo
.pchHostCss
), debugstr_w(hostinfo
.pchHostNS
));
243 static void set_downloading_proc(task_t
*_task
)
245 download_proc_task_t
*task
= (download_proc_task_t
*)_task
;
246 HTMLDocumentObj
*doc
= task
->doc
;
249 TRACE("(%p)\n", doc
);
251 set_statustext(doc
, IDS_STATUS_DOWNLOADINGFROM
, task
->url
);
253 if(task
->set_download
)
254 set_download_state(doc
, 1);
260 IAdviseSink_OnViewChange(doc
->view_sink
, DVASPECT_CONTENT
, -1);
263 IDropTarget
*drop_target
= NULL
;
265 hres
= IDocHostUIHandler_GetDropTarget(doc
->hostui
, NULL
/* FIXME */, &drop_target
);
266 if(SUCCEEDED(hres
) && drop_target
) {
267 FIXME("Use IDropTarget\n");
268 IDropTarget_Release(drop_target
);
273 static void set_downloading_task_destr(task_t
*_task
)
275 download_proc_task_t
*task
= (download_proc_task_t
*)_task
;
277 CoTaskMemFree(task
->url
);
281 void prepare_for_binding(HTMLDocumentObj
*This
, IMoniker
*mon
, DWORD flags
)
286 VARIANT silent
, offline
;
288 hres
= get_client_disp_property(This
->client
, DISPID_AMBIENT_SILENT
, &silent
);
289 if(SUCCEEDED(hres
)) {
290 if(V_VT(&silent
) != VT_BOOL
)
291 WARN("silent = %s\n", debugstr_variant(&silent
));
292 else if(V_BOOL(&silent
))
293 FIXME("silent == true\n");
296 hres
= get_client_disp_property(This
->client
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &offline
);
297 if(SUCCEEDED(hres
)) {
298 if(V_VT(&offline
) != VT_BOOL
)
299 WARN("offline = %s\n", debugstr_variant(&offline
));
300 else if(V_BOOL(&offline
))
301 FIXME("offline == true\n");
305 if(This
->basedoc
.window
->mon
) {
306 update_doc(This
, UPDATE_TITLE
|UPDATE_UI
);
308 update_doc(This
, UPDATE_TITLE
);
309 set_current_mon(This
->basedoc
.window
, mon
, flags
);
313 IOleCommandTarget
*cmdtrg
= NULL
;
315 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
316 if(SUCCEEDED(hres
)) {
319 if(flags
& BINDING_NAVIGATED
) {
320 V_VT(&var
) = VT_UNKNOWN
;
321 V_UNKNOWN(&var
) = (IUnknown
*)&This
->basedoc
.window
->base
.IHTMLWindow2_iface
;
322 V_VT(&out
) = VT_EMPTY
;
323 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 63, 0, &var
, &out
);
326 }else if(!(flags
& BINDING_FROMHIST
)) {
329 IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 37, 0, &var
, NULL
);
332 IOleCommandTarget_Release(cmdtrg
);
337 HRESULT
set_moniker(HTMLOuterWindow
*window
, IMoniker
*mon
, IUri
*nav_uri
, IBindCtx
*pibc
, nsChannelBSC
*async_bsc
,
340 download_proc_task_t
*download_task
;
341 HTMLDocumentObj
*doc_obj
= NULL
;
342 nsChannelBSC
*bscallback
;
348 if(is_main_content_window(window
))
349 doc_obj
= window
->browser
->doc
;
351 hres
= IMoniker_GetDisplayName(mon
, pibc
, NULL
, &url
);
353 WARN("GetDisplayName failed: %08lx\n", hres
);
360 hres
= create_uri(url
, 0, &uri
);
367 TRACE("got url: %s\n", debugstr_w(url
));
369 set_ready_state(window
, READYSTATE_LOADING
);
371 hres
= create_doc_uri(uri
, &nsuri
);
374 if(SUCCEEDED(hres
)) {
376 bscallback
= async_bsc
;
378 hres
= create_channelbsc(mon
, NULL
, NULL
, 0, TRUE
, &bscallback
);
381 if(SUCCEEDED(hres
)) {
382 if(window
->base
.inner_window
->doc
)
383 remove_target_tasks(window
->base
.inner_window
->task_magic
);
384 abort_window_bindings(window
->base
.inner_window
);
386 hres
= load_nsuri(window
, nsuri
, NULL
, bscallback
, LOAD_FLAGS_BYPASS_CACHE
);
387 nsISupports_Release((nsISupports
*)nsuri
); /* FIXME */
388 if(SUCCEEDED(hres
)) {
389 hres
= create_pending_window(window
, bscallback
);
390 TRACE("pending window for %p %p %p\n", window
, bscallback
, window
->pending_window
);
392 if(bscallback
!= async_bsc
)
393 IBindStatusCallback_Release(&bscallback
->bsc
.IBindStatusCallback_iface
);
402 HTMLDocument_LockContainer(doc_obj
, TRUE
);
407 task
= heap_alloc(sizeof(docobj_task_t
));
409 hres
= push_task(&task
->header
, set_progress_proc
, NULL
, doc_obj
->task_magic
);
416 download_task
= heap_alloc(sizeof(download_proc_task_t
));
417 download_task
->doc
= doc_obj
;
418 download_task
->set_download
= set_download
;
419 download_task
->url
= url
;
420 return push_task(&download_task
->header
, set_downloading_proc
, set_downloading_task_destr
, doc_obj
->task_magic
);
426 static void notif_readystate(HTMLOuterWindow
*window
)
431 window
->readystate_pending
= FALSE
;
433 if(is_main_content_window(window
))
434 call_property_onchanged(&window
->browser
->doc
->cp_container
, DISPID_READYSTATE
);
436 hres
= create_document_event(window
->base
.inner_window
->doc
, EVENTID_READYSTATECHANGE
, &event
);
437 if(SUCCEEDED(hres
)) {
438 event
->no_event_obj
= TRUE
;
439 dispatch_event(&window
->base
.inner_window
->doc
->node
.event_target
, event
);
440 IDOMEvent_Release(&event
->IDOMEvent_iface
);
443 if(window
->frame_element
) {
444 hres
= create_document_event(window
->frame_element
->element
.node
.doc
, EVENTID_READYSTATECHANGE
, &event
);
445 if(SUCCEEDED(hres
)) {
446 dispatch_event(&window
->frame_element
->element
.node
.event_target
, event
);
447 IDOMEvent_Release(&event
->IDOMEvent_iface
);
454 HTMLOuterWindow
*window
;
457 static void notif_readystate_proc(task_t
*_task
)
459 readystate_task_t
*task
= (readystate_task_t
*)_task
;
460 notif_readystate(task
->window
);
463 static void notif_readystate_destr(task_t
*_task
)
465 readystate_task_t
*task
= (readystate_task_t
*)_task
;
466 IHTMLWindow2_Release(&task
->window
->base
.IHTMLWindow2_iface
);
469 void set_ready_state(HTMLOuterWindow
*window
, READYSTATE readystate
)
471 READYSTATE prev_state
= window
->readystate
;
473 window
->readystate
= readystate
;
475 if(window
->readystate_locked
) {
476 readystate_task_t
*task
;
479 if(window
->readystate_pending
|| prev_state
== readystate
)
482 task
= heap_alloc(sizeof(*task
));
486 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
487 task
->window
= window
;
489 hres
= push_task(&task
->header
, notif_readystate_proc
, notif_readystate_destr
, window
->task_magic
);
491 window
->readystate_pending
= TRUE
;
495 notif_readystate(window
);
498 static HRESULT
get_doc_string(HTMLDocumentNode
*This
, char **str
)
507 WARN("NULL nsdoc\n");
511 nsres
= nsIDOMHTMLDocument_QueryInterface(This
->nsdoc
, &IID_nsIDOMNode
, (void**)&nsnode
);
512 if(NS_FAILED(nsres
)) {
513 ERR("Could not get nsIDOMNode failed: %08lx\n", nsres
);
517 nsAString_Init(&nsstr
, NULL
);
518 hres
= nsnode_to_nsstring(nsnode
, &nsstr
);
519 nsIDOMNode_Release(nsnode
);
521 nsAString_Finish(&nsstr
);
525 nsAString_GetData(&nsstr
, &strw
);
526 TRACE("%s\n", debugstr_w(strw
));
528 *str
= heap_strdupWtoA(strw
);
530 nsAString_Finish(&nsstr
);
533 return E_OUTOFMEMORY
;
538 /**********************************************************
539 * IPersistMoniker implementation
542 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IPersistMoniker(IPersistMoniker
*iface
)
544 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IPersistMoniker_iface
);
547 static HRESULT WINAPI
DocNodePersistMoniker_QueryInterface(IPersistMoniker
*iface
, REFIID riid
, void **ppv
)
549 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
550 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
553 static ULONG WINAPI
DocNodePersistMoniker_AddRef(IPersistMoniker
*iface
)
555 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
556 return htmldoc_addref(&This
->basedoc
);
559 static ULONG WINAPI
DocNodePersistMoniker_Release(IPersistMoniker
*iface
)
561 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
562 return htmldoc_release(&This
->basedoc
);
565 static HRESULT WINAPI
DocNodePersistMoniker_GetClassID(IPersistMoniker
*iface
, CLSID
*pClassID
)
567 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
568 return IPersistFile_GetClassID(&This
->IPersistFile_iface
, pClassID
);
571 static HRESULT WINAPI
DocNodePersistMoniker_IsDirty(IPersistMoniker
*iface
)
573 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
575 TRACE("(%p)\n", This
);
577 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
580 static HRESULT WINAPI
DocNodePersistMoniker_Load(IPersistMoniker
*iface
, BOOL fFullyAvailable
,
581 IMoniker
*pimkName
, LPBC pibc
, DWORD grfMode
)
583 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
584 return IPersistMoniker_Load(&This
->basedoc
.doc_obj
->IPersistMoniker_iface
, fFullyAvailable
, pimkName
, pibc
, grfMode
);
587 static HRESULT WINAPI
DocNodePersistMoniker_Save(IPersistMoniker
*iface
, IMoniker
*pimkName
,
588 LPBC pbc
, BOOL fRemember
)
590 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
591 FIXME("(%p)->(%p %p %x)\n", This
, pimkName
, pbc
, fRemember
);
595 static HRESULT WINAPI
DocNodePersistMoniker_SaveCompleted(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pibc
)
597 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
598 FIXME("(%p)->(%p %p)\n", This
, pimkName
, pibc
);
602 static HRESULT WINAPI
DocNodePersistMoniker_GetCurMoniker(IPersistMoniker
*iface
, IMoniker
**ppimkName
)
604 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
605 return IPersistMoniker_GetCurMoniker(&This
->basedoc
.doc_obj
->IPersistMoniker_iface
, ppimkName
);
608 static const IPersistMonikerVtbl DocNodePersistMonikerVtbl
= {
609 DocNodePersistMoniker_QueryInterface
,
610 DocNodePersistMoniker_AddRef
,
611 DocNodePersistMoniker_Release
,
612 DocNodePersistMoniker_GetClassID
,
613 DocNodePersistMoniker_IsDirty
,
614 DocNodePersistMoniker_Load
,
615 DocNodePersistMoniker_Save
,
616 DocNodePersistMoniker_SaveCompleted
,
617 DocNodePersistMoniker_GetCurMoniker
620 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IPersistMoniker(IPersistMoniker
*iface
)
622 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IPersistMoniker_iface
);
625 static HRESULT WINAPI
DocObjPersistMoniker_QueryInterface(IPersistMoniker
*iface
, REFIID riid
, void **ppv
)
627 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
628 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
631 static ULONG WINAPI
DocObjPersistMoniker_AddRef(IPersistMoniker
*iface
)
633 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
634 return htmldoc_addref(&This
->basedoc
);
637 static ULONG WINAPI
DocObjPersistMoniker_Release(IPersistMoniker
*iface
)
639 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
640 return htmldoc_release(&This
->basedoc
);
643 static HRESULT WINAPI
DocObjPersistMoniker_GetClassID(IPersistMoniker
*iface
, CLSID
*pClassID
)
645 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
646 return IPersistFile_GetClassID(&This
->IPersistFile_iface
, pClassID
);
649 static HRESULT WINAPI
DocObjPersistMoniker_IsDirty(IPersistMoniker
*iface
)
651 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
653 TRACE("(%p)\n", This
);
655 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
658 static HRESULT WINAPI
DocObjPersistMoniker_Load(IPersistMoniker
*iface
, BOOL fFullyAvailable
,
659 IMoniker
*pimkName
, LPBC pibc
, DWORD grfMode
)
661 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
665 TRACE("(%p)->(%x %p %p %08lx)\n", This
, fFullyAvailable
, pimkName
, pibc
, grfMode
);
668 IUnknown
*unk
= NULL
;
672 * "__PrecreatedObject"
673 * "BIND_CONTEXT_PARAM"
674 * "__HTMLLOADOPTIONS"
677 * "_ITransData_Object_"
681 hres
= IBindCtx_GetObjectParam(pibc
, (LPOLESTR
)SZ_HTML_CLIENTSITE_OBJECTPARAM
, &unk
);
682 if(SUCCEEDED(hres
) && unk
) {
683 IOleClientSite
*client
= NULL
;
685 hres
= IUnknown_QueryInterface(unk
, &IID_IOleClientSite
, (void**)&client
);
686 if(SUCCEEDED(hres
)) {
687 TRACE("Got client site %p\n", client
);
688 IOleObject_SetClientSite(&This
->IOleObject_iface
, client
);
689 IOleClientSite_Release(client
);
692 IUnknown_Release(unk
);
699 hres
= MimeOleObjectFromMoniker(0, pimkName
, pibc
, &IID_IUnknown
, (void**)&unk
, &mon
);
702 IUnknown_Release(unk
);
705 IMoniker_AddRef(mon
= pimkName
);
708 prepare_for_binding(This
, mon
, FALSE
);
709 call_docview_84(This
);
710 hres
= set_moniker(This
->basedoc
.window
, mon
, NULL
, pibc
, NULL
, TRUE
);
711 IMoniker_Release(mon
);
715 return start_binding(This
->basedoc
.window
->pending_window
, (BSCallback
*)This
->basedoc
.window
->pending_window
->bscallback
, pibc
);
718 static HRESULT WINAPI
DocObjPersistMoniker_Save(IPersistMoniker
*iface
, IMoniker
*pimkName
,
719 LPBC pbc
, BOOL fRemember
)
721 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
722 FIXME("(%p)->(%p %p %x)\n", This
, pimkName
, pbc
, fRemember
);
726 static HRESULT WINAPI
DocObjPersistMoniker_SaveCompleted(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pibc
)
728 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
729 FIXME("(%p)->(%p %p)\n", This
, pimkName
, pibc
);
733 static HRESULT WINAPI
DocObjPersistMoniker_GetCurMoniker(IPersistMoniker
*iface
, IMoniker
**ppimkName
)
735 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
737 TRACE("(%p)->(%p)\n", This
, ppimkName
);
739 if(!This
->basedoc
.window
|| !This
->basedoc
.window
->mon
)
742 IMoniker_AddRef(This
->basedoc
.window
->mon
);
743 *ppimkName
= This
->basedoc
.window
->mon
;
747 static const IPersistMonikerVtbl DocObjPersistMonikerVtbl
= {
748 DocObjPersistMoniker_QueryInterface
,
749 DocObjPersistMoniker_AddRef
,
750 DocObjPersistMoniker_Release
,
751 DocObjPersistMoniker_GetClassID
,
752 DocObjPersistMoniker_IsDirty
,
753 DocObjPersistMoniker_Load
,
754 DocObjPersistMoniker_Save
,
755 DocObjPersistMoniker_SaveCompleted
,
756 DocObjPersistMoniker_GetCurMoniker
759 /**********************************************************
760 * IMonikerProp implementation
763 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IMonikerProp(IMonikerProp
*iface
)
765 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IMonikerProp_iface
);
768 static HRESULT WINAPI
DocNodeMonikerProp_QueryInterface(IMonikerProp
*iface
, REFIID riid
, void **ppv
)
770 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IMonikerProp(iface
);
771 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
774 static ULONG WINAPI
DocNodeMonikerProp_AddRef(IMonikerProp
*iface
)
776 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IMonikerProp(iface
);
777 return htmldoc_addref(&This
->basedoc
);
780 static ULONG WINAPI
DocNodeMonikerProp_Release(IMonikerProp
*iface
)
782 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IMonikerProp(iface
);
783 return htmldoc_release(&This
->basedoc
);
786 static HRESULT WINAPI
DocNodeMonikerProp_PutProperty(IMonikerProp
*iface
, MONIKERPROPERTY mkp
, LPCWSTR val
)
788 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IMonikerProp(iface
);
789 return IMonikerProp_PutProperty(&This
->basedoc
.doc_obj
->IMonikerProp_iface
, mkp
, val
);
792 static const IMonikerPropVtbl DocNodeMonikerPropVtbl
= {
793 DocNodeMonikerProp_QueryInterface
,
794 DocNodeMonikerProp_AddRef
,
795 DocNodeMonikerProp_Release
,
796 DocNodeMonikerProp_PutProperty
799 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IMonikerProp(IMonikerProp
*iface
)
801 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IMonikerProp_iface
);
804 static HRESULT WINAPI
DocObjMonikerProp_QueryInterface(IMonikerProp
*iface
, REFIID riid
, void **ppv
)
806 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IMonikerProp(iface
);
807 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
810 static ULONG WINAPI
DocObjMonikerProp_AddRef(IMonikerProp
*iface
)
812 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IMonikerProp(iface
);
813 return htmldoc_addref(&This
->basedoc
);
816 static ULONG WINAPI
DocObjMonikerProp_Release(IMonikerProp
*iface
)
818 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IMonikerProp(iface
);
819 return htmldoc_release(&This
->basedoc
);
822 static HRESULT WINAPI
DocObjMonikerProp_PutProperty(IMonikerProp
*iface
, MONIKERPROPERTY mkp
, LPCWSTR val
)
824 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IMonikerProp(iface
);
826 TRACE("(%p)->(%d %s)\n", This
, mkp
, debugstr_w(val
));
830 heap_free(This
->mime
);
831 This
->mime
= heap_strdupW(val
);
838 FIXME("mkp %d\n", mkp
);
845 static const IMonikerPropVtbl DocObjMonikerPropVtbl
= {
846 DocObjMonikerProp_QueryInterface
,
847 DocObjMonikerProp_AddRef
,
848 DocObjMonikerProp_Release
,
849 DocObjMonikerProp_PutProperty
852 /**********************************************************
853 * IPersistFile implementation
856 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IPersistFile(IPersistFile
*iface
)
858 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IPersistFile_iface
);
861 static HRESULT WINAPI
DocNodePersistFile_QueryInterface(IPersistFile
*iface
, REFIID riid
, void **ppv
)
863 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
864 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
867 static ULONG WINAPI
DocNodePersistFile_AddRef(IPersistFile
*iface
)
869 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
870 return htmldoc_addref(&This
->basedoc
);
873 static ULONG WINAPI
DocNodePersistFile_Release(IPersistFile
*iface
)
875 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
876 return htmldoc_release(&This
->basedoc
);
879 static HRESULT WINAPI
DocNodePersistFile_GetClassID(IPersistFile
*iface
, CLSID
*pClassID
)
881 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
882 return IPersistFile_GetClassID(&This
->basedoc
.doc_obj
->IPersistFile_iface
, pClassID
);
885 static HRESULT WINAPI
DocNodePersistFile_IsDirty(IPersistFile
*iface
)
887 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
889 TRACE("(%p)\n", This
);
891 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
894 static HRESULT WINAPI
DocNodePersistFile_Load(IPersistFile
*iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
896 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
897 FIXME("(%p)->(%s %08lx)\n", This
, debugstr_w(pszFileName
), dwMode
);
901 static HRESULT WINAPI
DocNodePersistFile_Save(IPersistFile
*iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
903 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
909 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(pszFileName
), fRemember
);
911 file
= CreateFileW(pszFileName
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
912 FILE_ATTRIBUTE_NORMAL
, NULL
);
913 if(file
== INVALID_HANDLE_VALUE
) {
914 WARN("Could not create file: %lu\n", GetLastError());
918 hres
= get_doc_string(This
, &str
);
920 WriteFile(file
, str
, strlen(str
), &written
, NULL
);
926 static HRESULT WINAPI
DocNodePersistFile_SaveCompleted(IPersistFile
*iface
, LPCOLESTR pszFileName
)
928 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
929 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFileName
));
933 static HRESULT WINAPI
DocNodePersistFile_GetCurFile(IPersistFile
*iface
, LPOLESTR
*pszFileName
)
935 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
936 FIXME("(%p)->(%p)\n", This
, pszFileName
);
940 static const IPersistFileVtbl DocNodePersistFileVtbl
= {
941 DocNodePersistFile_QueryInterface
,
942 DocNodePersistFile_AddRef
,
943 DocNodePersistFile_Release
,
944 DocNodePersistFile_GetClassID
,
945 DocNodePersistFile_IsDirty
,
946 DocNodePersistFile_Load
,
947 DocNodePersistFile_Save
,
948 DocNodePersistFile_SaveCompleted
,
949 DocNodePersistFile_GetCurFile
952 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IPersistFile(IPersistFile
*iface
)
954 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IPersistFile_iface
);
957 static HRESULT WINAPI
DocObjPersistFile_QueryInterface(IPersistFile
*iface
, REFIID riid
, void **ppv
)
959 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
960 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
963 static ULONG WINAPI
DocObjPersistFile_AddRef(IPersistFile
*iface
)
965 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
966 return htmldoc_addref(&This
->basedoc
);
969 static ULONG WINAPI
DocObjPersistFile_Release(IPersistFile
*iface
)
971 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
972 return htmldoc_release(&This
->basedoc
);
975 static HRESULT WINAPI
DocObjPersistFile_GetClassID(IPersistFile
*iface
, CLSID
*pClassID
)
977 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
979 TRACE("(%p)->(%p)\n", This
, pClassID
);
984 *pClassID
= CLSID_HTMLDocument
;
988 static HRESULT WINAPI
DocObjPersistFile_IsDirty(IPersistFile
*iface
)
990 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
992 TRACE("(%p)\n", This
);
994 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
997 static HRESULT WINAPI
DocObjPersistFile_Load(IPersistFile
*iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
999 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
1000 FIXME("(%p)->(%s %08lx)\n", This
, debugstr_w(pszFileName
), dwMode
);
1004 static HRESULT WINAPI
DocObjPersistFile_Save(IPersistFile
*iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
1006 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
1008 if(!This
->basedoc
.doc_node
) {
1009 FIXME("No doc_node\n");
1010 return E_UNEXPECTED
;
1012 return IPersistFile_Save(&This
->basedoc
.doc_node
->IPersistFile_iface
, pszFileName
, fRemember
);
1015 static HRESULT WINAPI
DocObjPersistFile_SaveCompleted(IPersistFile
*iface
, LPCOLESTR pszFileName
)
1017 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
1018 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFileName
));
1022 static HRESULT WINAPI
DocObjPersistFile_GetCurFile(IPersistFile
*iface
, LPOLESTR
*pszFileName
)
1024 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
1025 FIXME("(%p)->(%p)\n", This
, pszFileName
);
1029 static const IPersistFileVtbl DocObjPersistFileVtbl
= {
1030 DocObjPersistFile_QueryInterface
,
1031 DocObjPersistFile_AddRef
,
1032 DocObjPersistFile_Release
,
1033 DocObjPersistFile_GetClassID
,
1034 DocObjPersistFile_IsDirty
,
1035 DocObjPersistFile_Load
,
1036 DocObjPersistFile_Save
,
1037 DocObjPersistFile_SaveCompleted
,
1038 DocObjPersistFile_GetCurFile
1041 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IPersistStreamInit(IPersistStreamInit
*iface
)
1043 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IPersistStreamInit_iface
);
1046 static HRESULT WINAPI
DocNodePersistStreamInit_QueryInterface(IPersistStreamInit
*iface
,
1047 REFIID riid
, void **ppv
)
1049 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistStreamInit(iface
);
1050 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
1053 static ULONG WINAPI
DocNodePersistStreamInit_AddRef(IPersistStreamInit
*iface
)
1055 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistStreamInit(iface
);
1056 return htmldoc_addref(&This
->basedoc
);
1059 static ULONG WINAPI
DocNodePersistStreamInit_Release(IPersistStreamInit
*iface
)
1061 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistStreamInit(iface
);
1062 return htmldoc_release(&This
->basedoc
);
1065 static HRESULT WINAPI
DocNodePersistStreamInit_GetClassID(IPersistStreamInit
*iface
, CLSID
*pClassID
)
1067 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistStreamInit(iface
);
1068 return IPersistFile_GetClassID(&This
->IPersistFile_iface
, pClassID
);
1071 static HRESULT WINAPI
DocNodePersistStreamInit_IsDirty(IPersistStreamInit
*iface
)
1073 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistStreamInit(iface
);
1074 return IPersistStreamInit_IsDirty(&This
->basedoc
.doc_obj
->IPersistStreamInit_iface
);
1077 static HRESULT WINAPI
DocNodePersistStreamInit_Load(IPersistStreamInit
*iface
, IStream
*pStm
)
1079 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistStreamInit(iface
);
1080 return IPersistStreamInit_Load(&This
->basedoc
.doc_obj
->IPersistStreamInit_iface
, pStm
);
1083 static HRESULT WINAPI
DocNodePersistStreamInit_Save(IPersistStreamInit
*iface
, IStream
*pStm
,
1086 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistStreamInit(iface
);
1091 TRACE("(%p)->(%p %x)\n", This
, pStm
, fClearDirty
);
1093 hres
= get_doc_string(This
, &str
);
1097 hres
= IStream_Write(pStm
, str
, strlen(str
), &written
);
1099 FIXME("Write failed: %08lx\n", hres
);
1104 set_dirty(This
->basedoc
.doc_obj
->nscontainer
, VARIANT_FALSE
);
1109 static HRESULT WINAPI
DocNodePersistStreamInit_GetSizeMax(IPersistStreamInit
*iface
,
1110 ULARGE_INTEGER
*pcbSize
)
1112 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistStreamInit(iface
);
1113 FIXME("(%p)->(%p)\n", This
, pcbSize
);
1117 static HRESULT WINAPI
DocNodePersistStreamInit_InitNew(IPersistStreamInit
*iface
)
1119 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistStreamInit(iface
);
1120 return IPersistStreamInit_InitNew(&This
->basedoc
.doc_obj
->IPersistStreamInit_iface
);
1123 static const IPersistStreamInitVtbl DocNodePersistStreamInitVtbl
= {
1124 DocNodePersistStreamInit_QueryInterface
,
1125 DocNodePersistStreamInit_AddRef
,
1126 DocNodePersistStreamInit_Release
,
1127 DocNodePersistStreamInit_GetClassID
,
1128 DocNodePersistStreamInit_IsDirty
,
1129 DocNodePersistStreamInit_Load
,
1130 DocNodePersistStreamInit_Save
,
1131 DocNodePersistStreamInit_GetSizeMax
,
1132 DocNodePersistStreamInit_InitNew
1135 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IPersistStreamInit(IPersistStreamInit
*iface
)
1137 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IPersistStreamInit_iface
);
1140 static HRESULT WINAPI
DocObjPersistStreamInit_QueryInterface(IPersistStreamInit
*iface
,
1141 REFIID riid
, void **ppv
)
1143 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1144 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
1147 static ULONG WINAPI
DocObjPersistStreamInit_AddRef(IPersistStreamInit
*iface
)
1149 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1150 return htmldoc_addref(&This
->basedoc
);
1153 static ULONG WINAPI
DocObjPersistStreamInit_Release(IPersistStreamInit
*iface
)
1155 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1156 return htmldoc_release(&This
->basedoc
);
1159 static HRESULT WINAPI
DocObjPersistStreamInit_GetClassID(IPersistStreamInit
*iface
, CLSID
*pClassID
)
1161 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1162 return IPersistFile_GetClassID(&This
->IPersistFile_iface
, pClassID
);
1165 static HRESULT WINAPI
DocObjPersistStreamInit_IsDirty(IPersistStreamInit
*iface
)
1167 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1169 TRACE("(%p)\n", This
);
1171 return browser_is_dirty(This
->nscontainer
);
1174 static HRESULT WINAPI
DocObjPersistStreamInit_Load(IPersistStreamInit
*iface
, IStream
*pStm
)
1176 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1180 TRACE("(%p)->(%p)\n", This
, pStm
);
1182 hres
= CreateURLMoniker(NULL
, L
"about:blank", &mon
);
1184 WARN("CreateURLMoniker failed: %08lx\n", hres
);
1188 prepare_for_binding(This
, mon
, FALSE
);
1189 hres
= set_moniker(This
->basedoc
.window
, mon
, NULL
, NULL
, NULL
, TRUE
);
1191 hres
= channelbsc_load_stream(This
->basedoc
.window
->pending_window
, mon
, pStm
);
1193 IMoniker_Release(mon
);
1197 static HRESULT WINAPI
DocObjPersistStreamInit_Save(IPersistStreamInit
*iface
, IStream
*pStm
,
1200 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1202 if(!This
->basedoc
.doc_node
) {
1203 FIXME("No doc_node\n");
1204 return E_UNEXPECTED
;
1206 return IPersistStreamInit_Save(&This
->basedoc
.doc_node
->IPersistStreamInit_iface
, pStm
, fClearDirty
);
1209 static HRESULT WINAPI
DocObjPersistStreamInit_GetSizeMax(IPersistStreamInit
*iface
,
1210 ULARGE_INTEGER
*pcbSize
)
1212 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1213 FIXME("(%p)->(%p)\n", This
, pcbSize
);
1217 static HRESULT WINAPI
DocObjPersistStreamInit_InitNew(IPersistStreamInit
*iface
)
1219 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1223 TRACE("(%p)\n", This
);
1225 hres
= CreateURLMoniker(NULL
, L
"about:blank", &mon
);
1227 WARN("CreateURLMoniker failed: %08lx\n", hres
);
1231 prepare_for_binding(This
, mon
, FALSE
);
1232 hres
= set_moniker(This
->basedoc
.window
, mon
, NULL
, NULL
, NULL
, FALSE
);
1234 hres
= channelbsc_load_stream(This
->basedoc
.window
->pending_window
, mon
, NULL
);
1236 IMoniker_Release(mon
);
1240 static const IPersistStreamInitVtbl DocObjPersistStreamInitVtbl
= {
1241 DocObjPersistStreamInit_QueryInterface
,
1242 DocObjPersistStreamInit_AddRef
,
1243 DocObjPersistStreamInit_Release
,
1244 DocObjPersistStreamInit_GetClassID
,
1245 DocObjPersistStreamInit_IsDirty
,
1246 DocObjPersistStreamInit_Load
,
1247 DocObjPersistStreamInit_Save
,
1248 DocObjPersistStreamInit_GetSizeMax
,
1249 DocObjPersistStreamInit_InitNew
1252 /**********************************************************
1253 * IPersistHistory implementation
1256 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IPersistHistory(IPersistHistory
*iface
)
1258 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IPersistHistory_iface
);
1261 static HRESULT WINAPI
DocNodePersistHistory_QueryInterface(IPersistHistory
*iface
, REFIID riid
, void **ppv
)
1263 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1264 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
1267 static ULONG WINAPI
DocNodePersistHistory_AddRef(IPersistHistory
*iface
)
1269 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1270 return htmldoc_addref(&This
->basedoc
);
1273 static ULONG WINAPI
DocNodePersistHistory_Release(IPersistHistory
*iface
)
1275 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1276 return htmldoc_release(&This
->basedoc
);
1279 static HRESULT WINAPI
DocNodePersistHistory_GetClassID(IPersistHistory
*iface
, CLSID
*pClassID
)
1281 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1282 return IPersistFile_GetClassID(&This
->IPersistFile_iface
, pClassID
);
1285 static HRESULT WINAPI
DocNodePersistHistory_LoadHistory(IPersistHistory
*iface
, IStream
*pStream
, IBindCtx
*pbc
)
1287 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1288 return IPersistHistory_LoadHistory(&This
->basedoc
.doc_obj
->IPersistHistory_iface
, pStream
, pbc
);
1291 static HRESULT WINAPI
DocNodePersistHistory_SaveHistory(IPersistHistory
*iface
, IStream
*pStream
)
1293 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1294 return IPersistHistory_SaveHistory(&This
->basedoc
.doc_obj
->IPersistHistory_iface
, pStream
);
1297 static HRESULT WINAPI
DocNodePersistHistory_SetPositionCookie(IPersistHistory
*iface
, DWORD dwPositioncookie
)
1299 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1300 FIXME("(%p)->(%lx)\n", This
, dwPositioncookie
);
1304 static HRESULT WINAPI
DocNodePersistHistory_GetPositionCookie(IPersistHistory
*iface
, DWORD
*pdwPositioncookie
)
1306 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1307 FIXME("(%p)->(%p)\n", This
, pdwPositioncookie
);
1311 static const IPersistHistoryVtbl DocNodePersistHistoryVtbl
= {
1312 DocNodePersistHistory_QueryInterface
,
1313 DocNodePersistHistory_AddRef
,
1314 DocNodePersistHistory_Release
,
1315 DocNodePersistHistory_GetClassID
,
1316 DocNodePersistHistory_LoadHistory
,
1317 DocNodePersistHistory_SaveHistory
,
1318 DocNodePersistHistory_SetPositionCookie
,
1319 DocNodePersistHistory_GetPositionCookie
1322 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IPersistHistory(IPersistHistory
*iface
)
1324 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IPersistHistory_iface
);
1327 static HRESULT WINAPI
DocObjPersistHistory_QueryInterface(IPersistHistory
*iface
, REFIID riid
, void **ppv
)
1329 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1330 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
1333 static ULONG WINAPI
DocObjPersistHistory_AddRef(IPersistHistory
*iface
)
1335 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1336 return htmldoc_addref(&This
->basedoc
);
1339 static ULONG WINAPI
DocObjPersistHistory_Release(IPersistHistory
*iface
)
1341 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1342 return htmldoc_release(&This
->basedoc
);
1345 static HRESULT WINAPI
DocObjPersistHistory_GetClassID(IPersistHistory
*iface
, CLSID
*pClassID
)
1347 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1348 return IPersistFile_GetClassID(&This
->IPersistFile_iface
, pClassID
);
1351 static HRESULT WINAPI
DocObjPersistHistory_LoadHistory(IPersistHistory
*iface
, IStream
*pStream
, IBindCtx
*pbc
)
1353 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1354 ULONG str_len
, read
;
1359 TRACE("(%p)->(%p %p)\n", This
, pStream
, pbc
);
1361 if(!This
->basedoc
.window
) {
1362 FIXME("No current window\n");
1363 return E_UNEXPECTED
;
1367 FIXME("pbc not supported\n");
1370 IOleCommandTarget
*cmdtrg
= NULL
;
1372 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1373 if(SUCCEEDED(hres
)) {
1374 IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 138, 0, NULL
, NULL
);
1375 IOleCommandTarget_Release(cmdtrg
);
1379 hres
= IStream_Read(pStream
, &str_len
, sizeof(str_len
), &read
);
1382 if(read
!= sizeof(str_len
))
1385 uri_str
= heap_alloc((str_len
+1)*sizeof(WCHAR
));
1387 return E_OUTOFMEMORY
;
1389 hres
= IStream_Read(pStream
, uri_str
, str_len
*sizeof(WCHAR
), &read
);
1390 if(SUCCEEDED(hres
) && read
!= str_len
*sizeof(WCHAR
))
1392 if(SUCCEEDED(hres
)) {
1393 uri_str
[str_len
] = 0;
1394 hres
= create_uri(uri_str
, 0, &uri
);
1400 hres
= load_uri(This
->basedoc
.window
, uri
, BINDING_FROMHIST
);
1405 static HRESULT WINAPI
DocObjPersistHistory_SaveHistory(IPersistHistory
*iface
, IStream
*pStream
)
1407 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1412 TRACE("(%p)->(%p)\n", This
, pStream
);
1414 if(!This
->basedoc
.window
|| !This
->basedoc
.window
->uri
) {
1415 FIXME("No current URI\n");
1419 /* NOTE: The format we store is *not* compatible with native MSHTML. We currently
1420 * store only URI of the page (as a length followed by a string) */
1421 hres
= IUri_GetDisplayUri(This
->basedoc
.window
->uri
, &display_uri
);
1425 len
= SysStringLen(display_uri
);
1426 hres
= IStream_Write(pStream
, &len
, sizeof(len
), &written
);
1428 hres
= IStream_Write(pStream
, display_uri
, len
*sizeof(WCHAR
), &written
);
1429 SysFreeString(display_uri
);
1433 static HRESULT WINAPI
DocObjPersistHistory_SetPositionCookie(IPersistHistory
*iface
, DWORD dwPositioncookie
)
1435 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1436 FIXME("(%p)->(%lx)\n", This
, dwPositioncookie
);
1440 static HRESULT WINAPI
DocObjPersistHistory_GetPositionCookie(IPersistHistory
*iface
, DWORD
*pdwPositioncookie
)
1442 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1443 FIXME("(%p)->(%p)\n", This
, pdwPositioncookie
);
1447 static const IPersistHistoryVtbl DocObjPersistHistoryVtbl
= {
1448 DocObjPersistHistory_QueryInterface
,
1449 DocObjPersistHistory_AddRef
,
1450 DocObjPersistHistory_Release
,
1451 DocObjPersistHistory_GetClassID
,
1452 DocObjPersistHistory_LoadHistory
,
1453 DocObjPersistHistory_SaveHistory
,
1454 DocObjPersistHistory_SetPositionCookie
,
1455 DocObjPersistHistory_GetPositionCookie
1458 /**********************************************************
1459 * IHlinkTarget implementation
1462 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IHlinkTarget(IHlinkTarget
*iface
)
1464 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IHlinkTarget_iface
);
1467 static HRESULT WINAPI
DocNodeHlinkTarget_QueryInterface(IHlinkTarget
*iface
, REFIID riid
, void **ppv
)
1469 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1470 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
1473 static ULONG WINAPI
DocNodeHlinkTarget_AddRef(IHlinkTarget
*iface
)
1475 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1476 return htmldoc_addref(&This
->basedoc
);
1479 static ULONG WINAPI
DocNodeHlinkTarget_Release(IHlinkTarget
*iface
)
1481 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1482 return htmldoc_release(&This
->basedoc
);
1485 static HRESULT WINAPI
DocNodeHlinkTarget_SetBrowseContext(IHlinkTarget
*iface
, IHlinkBrowseContext
*pihlbc
)
1487 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1488 FIXME("(%p)->(%p)\n", This
, pihlbc
);
1492 static HRESULT WINAPI
DocNodeHlinkTarget_GetBrowseContext(IHlinkTarget
*iface
, IHlinkBrowseContext
**ppihlbc
)
1494 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1495 FIXME("(%p)->(%p)\n", This
, ppihlbc
);
1499 static HRESULT WINAPI
DocNodeHlinkTarget_Navigate(IHlinkTarget
*iface
, DWORD grfHLNF
, LPCWSTR pwzJumpLocation
)
1501 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1503 TRACE("(%p)->(%08lx %s)\n", This
, grfHLNF
, debugstr_w(pwzJumpLocation
));
1506 FIXME("Unsupported grfHLNF=%08lx\n", grfHLNF
);
1508 FIXME("JumpLocation not supported\n");
1510 if(This
->basedoc
.doc_obj
->client
)
1511 return IOleObject_DoVerb(&This
->IOleObject_iface
, OLEIVERB_SHOW
, NULL
, NULL
, -1, NULL
, NULL
);
1513 return IHlinkTarget_Navigate(&This
->basedoc
.doc_obj
->IHlinkTarget_iface
, grfHLNF
, pwzJumpLocation
);
1516 static HRESULT WINAPI
DocNodeHlinkTarget_GetMoniker(IHlinkTarget
*iface
, LPCWSTR pwzLocation
, DWORD dwAssign
,
1517 IMoniker
**ppimkLocation
)
1519 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1520 FIXME("(%p)->(%s %08lx %p)\n", This
, debugstr_w(pwzLocation
), dwAssign
, ppimkLocation
);
1524 static HRESULT WINAPI
DocNodeHlinkTarget_GetFriendlyName(IHlinkTarget
*iface
, LPCWSTR pwzLocation
,
1525 LPWSTR
*ppwzFriendlyName
)
1527 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1528 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(pwzLocation
), ppwzFriendlyName
);
1532 static const IHlinkTargetVtbl DocNodeHlinkTargetVtbl
= {
1533 DocNodeHlinkTarget_QueryInterface
,
1534 DocNodeHlinkTarget_AddRef
,
1535 DocNodeHlinkTarget_Release
,
1536 DocNodeHlinkTarget_SetBrowseContext
,
1537 DocNodeHlinkTarget_GetBrowseContext
,
1538 DocNodeHlinkTarget_Navigate
,
1539 DocNodeHlinkTarget_GetMoniker
,
1540 DocNodeHlinkTarget_GetFriendlyName
1543 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IHlinkTarget(IHlinkTarget
*iface
)
1545 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IHlinkTarget_iface
);
1548 static HRESULT WINAPI
DocObjHlinkTarget_QueryInterface(IHlinkTarget
*iface
, REFIID riid
, void **ppv
)
1550 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1551 return htmldoc_query_interface(&This
->basedoc
, riid
, ppv
);
1554 static ULONG WINAPI
DocObjHlinkTarget_AddRef(IHlinkTarget
*iface
)
1556 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1557 return htmldoc_addref(&This
->basedoc
);
1560 static ULONG WINAPI
DocObjHlinkTarget_Release(IHlinkTarget
*iface
)
1562 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1563 return htmldoc_release(&This
->basedoc
);
1566 static HRESULT WINAPI
DocObjHlinkTarget_SetBrowseContext(IHlinkTarget
*iface
, IHlinkBrowseContext
*pihlbc
)
1568 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1569 FIXME("(%p)->(%p)\n", This
, pihlbc
);
1573 static HRESULT WINAPI
DocObjHlinkTarget_GetBrowseContext(IHlinkTarget
*iface
, IHlinkBrowseContext
**ppihlbc
)
1575 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1576 FIXME("(%p)->(%p)\n", This
, ppihlbc
);
1580 static HRESULT WINAPI
DocObjHlinkTarget_Navigate(IHlinkTarget
*iface
, DWORD grfHLNF
, LPCWSTR pwzJumpLocation
)
1582 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1584 TRACE("(%p)->(%08lx %s)\n", This
, grfHLNF
, debugstr_w(pwzJumpLocation
));
1587 FIXME("Unsupported grfHLNF=%08lx\n", grfHLNF
);
1589 FIXME("JumpLocation not supported\n");
1595 hres
= IUri_GetAbsoluteUri(This
->basedoc
.window
->uri
, &uri
);
1600 ShellExecuteW(NULL
, L
"open", uri
, NULL
, NULL
, SW_SHOW
);
1605 return IOleObject_DoVerb(&This
->IOleObject_iface
, OLEIVERB_SHOW
, NULL
, NULL
, -1, NULL
, NULL
);
1608 static HRESULT WINAPI
DocObjHlinkTarget_GetMoniker(IHlinkTarget
*iface
, LPCWSTR pwzLocation
, DWORD dwAssign
,
1609 IMoniker
**ppimkLocation
)
1611 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1612 FIXME("(%p)->(%s %08lx %p)\n", This
, debugstr_w(pwzLocation
), dwAssign
, ppimkLocation
);
1616 static HRESULT WINAPI
DocObjHlinkTarget_GetFriendlyName(IHlinkTarget
*iface
, LPCWSTR pwzLocation
,
1617 LPWSTR
*ppwzFriendlyName
)
1619 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1620 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(pwzLocation
), ppwzFriendlyName
);
1624 static const IHlinkTargetVtbl DocObjHlinkTargetVtbl
= {
1625 DocObjHlinkTarget_QueryInterface
,
1626 DocObjHlinkTarget_AddRef
,
1627 DocObjHlinkTarget_Release
,
1628 DocObjHlinkTarget_SetBrowseContext
,
1629 DocObjHlinkTarget_GetBrowseContext
,
1630 DocObjHlinkTarget_Navigate
,
1631 DocObjHlinkTarget_GetMoniker
,
1632 DocObjHlinkTarget_GetFriendlyName
1635 void HTMLDocumentNode_Persist_Init(HTMLDocumentNode
*This
)
1637 This
->IPersistMoniker_iface
.lpVtbl
= &DocNodePersistMonikerVtbl
;
1638 This
->IPersistFile_iface
.lpVtbl
= &DocNodePersistFileVtbl
;
1639 This
->IMonikerProp_iface
.lpVtbl
= &DocNodeMonikerPropVtbl
;
1640 This
->IPersistStreamInit_iface
.lpVtbl
= &DocNodePersistStreamInitVtbl
;
1641 This
->IPersistHistory_iface
.lpVtbl
= &DocNodePersistHistoryVtbl
;
1642 This
->IHlinkTarget_iface
.lpVtbl
= &DocNodeHlinkTargetVtbl
;
1645 void HTMLDocumentObj_Persist_Init(HTMLDocumentObj
*This
)
1647 This
->IPersistMoniker_iface
.lpVtbl
= &DocObjPersistMonikerVtbl
;
1648 This
->IPersistFile_iface
.lpVtbl
= &DocObjPersistFileVtbl
;
1649 This
->IMonikerProp_iface
.lpVtbl
= &DocObjMonikerPropVtbl
;
1650 This
->IPersistStreamInit_iface
.lpVtbl
= &DocObjPersistStreamInitVtbl
;
1651 This
->IPersistHistory_iface
.lpVtbl
= &DocObjPersistHistoryVtbl
;
1652 This
->IHlinkTarget_iface
.lpVtbl
= &DocObjHlinkTargetVtbl
;