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
)
78 unlink_ref(&window
->uri
);
79 unlink_ref(&window
->uri_nofrag
);
80 SysFreeString(window
->url
);
89 window
->uri_nofrag
= get_uri_nofrag(uri
);
90 if(!window
->uri_nofrag
) {
91 FIXME("get_uri_nofrag failed\n");
93 window
->uri_nofrag
= uri
;
96 IUri_GetDisplayUri(uri
, &window
->url
);
99 void set_current_mon(HTMLOuterWindow
*This
, IMoniker
*mon
, DWORD flags
)
101 IUriContainer
*uri_container
;
106 if(This
->browser
&& !(flags
& (BINDING_REPLACE
|BINDING_REFRESH
))) {
107 if(is_main_content_window(This
))
108 notify_travellog_update(This
->browser
->doc
);
110 TRACE("Skipping travellog update for frame navigation.\n");
112 IMoniker_Release(This
->mon
);
116 This
->load_flags
= flags
;
120 IMoniker_AddRef(mon
);
123 hres
= IMoniker_QueryInterface(mon
, &IID_IUriContainer
, (void**)&uri_container
);
124 if(SUCCEEDED(hres
)) {
125 hres
= IUriContainer_GetIUri(uri_container
, &uri
);
126 IUriContainer_Release(uri_container
);
128 WARN("GetIUri failed: %08lx\n", hres
);
136 hres
= IMoniker_GetDisplayName(mon
, NULL
, NULL
, &url
);
137 if(SUCCEEDED(hres
)) {
138 hres
= create_uri(url
, 0, &uri
);
140 WARN("CreateUri failed: %08lx\n", hres
);
141 set_current_uri(This
, NULL
);
142 This
->url
= SysAllocString(url
);
148 WARN("GetDisplayName failed: %08lx\n", hres
);
152 set_current_uri(This
, uri
);
156 if(is_main_content_window(This
))
157 update_browser_script_mode(This
->browser
, uri
);
160 HRESULT
create_uri(const WCHAR
*uri_str
, DWORD flags
, IUri
**uri
)
162 return CreateUri(uri_str
, flags
| Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME
, 0, uri
);
165 HRESULT
create_relative_uri(HTMLOuterWindow
*window
, const WCHAR
*rel_uri
, IUri
**uri
)
168 ? CoInternetCombineUrlEx(window
->uri
, rel_uri
, URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
, uri
, 0)
169 : create_uri(rel_uri
, 0, uri
);
172 void set_download_state(HTMLDocumentObj
*doc
, int state
)
175 IOleCommandTarget
*olecmd
;
178 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
179 if(SUCCEEDED(hres
)) {
185 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETDOWNLOADSTATE
,
186 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
187 IOleCommandTarget_Release(olecmd
);
191 doc
->download_state
= state
;
194 static void set_progress_proc(task_t
*_task
)
196 docobj_task_t
*task
= (docobj_task_t
*)_task
;
197 IOleCommandTarget
*olecmd
= NULL
;
198 HTMLDocumentObj
*doc
= task
->doc
;
201 TRACE("(%p)\n", doc
);
203 IUnknown_AddRef(doc
->outer_unk
);
206 IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
209 VARIANT progress_max
, progress
;
211 V_VT(&progress_max
) = VT_I4
;
212 V_I4(&progress_max
) = 0; /* FIXME */
213 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETPROGRESSMAX
, OLECMDEXECOPT_DONTPROMPTUSER
,
214 &progress_max
, NULL
);
216 V_VT(&progress
) = VT_I4
;
217 V_I4(&progress
) = 0; /* FIXME */
218 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETPROGRESSPOS
, OLECMDEXECOPT_DONTPROMPTUSER
,
220 IOleCommandTarget_Release(olecmd
);
223 if(doc
->nscontainer
->usermode
== EDITMODE
&& doc
->hostui
) {
224 DOCHOSTUIINFO hostinfo
;
226 memset(&hostinfo
, 0, sizeof(DOCHOSTUIINFO
));
227 hostinfo
.cbSize
= sizeof(DOCHOSTUIINFO
);
228 hres
= IDocHostUIHandler_GetHostInfo(doc
->hostui
, &hostinfo
);
230 /* FIXME: use hostinfo */
231 TRACE("hostinfo = {%lu %08lx %08lx %s %s}\n",
232 hostinfo
.cbSize
, hostinfo
.dwFlags
, hostinfo
.dwDoubleClick
,
233 debugstr_w(hostinfo
.pchHostCss
), debugstr_w(hostinfo
.pchHostNS
));
236 IUnknown_Release(doc
->outer_unk
);
239 static void set_progress_destr(task_t
*_task
)
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 IUnknown_AddRef(doc
->outer_unk
);
252 set_statustext(doc
, IDS_STATUS_DOWNLOADINGFROM
, task
->url
);
254 if(task
->set_download
)
255 set_download_state(doc
, 1);
261 IAdviseSink_OnViewChange(doc
->view_sink
, DVASPECT_CONTENT
, -1);
264 IDropTarget
*drop_target
= NULL
;
266 hres
= IDocHostUIHandler_GetDropTarget(doc
->hostui
, NULL
/* FIXME */, &drop_target
);
267 if(SUCCEEDED(hres
) && drop_target
) {
268 FIXME("Use IDropTarget\n");
269 IDropTarget_Release(drop_target
);
274 IUnknown_Release(doc
->outer_unk
);
277 static void set_downloading_task_destr(task_t
*_task
)
279 download_proc_task_t
*task
= (download_proc_task_t
*)_task
;
281 CoTaskMemFree(task
->url
);
284 void prepare_for_binding(HTMLDocumentObj
*This
, IMoniker
*mon
, DWORD flags
)
289 VARIANT silent
, offline
;
291 hres
= get_client_disp_property(This
->client
, DISPID_AMBIENT_SILENT
, &silent
);
292 if(SUCCEEDED(hres
)) {
293 if(V_VT(&silent
) != VT_BOOL
)
294 WARN("silent = %s\n", debugstr_variant(&silent
));
295 else if(V_BOOL(&silent
))
296 FIXME("silent == true\n");
299 hres
= get_client_disp_property(This
->client
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &offline
);
300 if(SUCCEEDED(hres
)) {
301 if(V_VT(&offline
) != VT_BOOL
)
302 WARN("offline = %s\n", debugstr_variant(&offline
));
303 else if(V_BOOL(&offline
))
304 FIXME("offline == true\n");
308 if(This
->window
->mon
) {
309 update_doc(This
, UPDATE_TITLE
|UPDATE_UI
);
311 update_doc(This
, UPDATE_TITLE
);
312 set_current_mon(This
->window
, mon
, flags
);
316 IOleCommandTarget
*cmdtrg
= NULL
;
318 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
319 if(SUCCEEDED(hres
)) {
322 if(flags
& BINDING_NAVIGATED
) {
323 V_VT(&var
) = VT_UNKNOWN
;
324 V_UNKNOWN(&var
) = (IUnknown
*)&This
->window
->base
.IHTMLWindow2_iface
;
325 V_VT(&out
) = VT_EMPTY
;
326 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 63, 0, &var
, &out
);
329 }else if(!(flags
& BINDING_FROMHIST
)) {
332 IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 37, 0, &var
, NULL
);
335 IOleCommandTarget_Release(cmdtrg
);
340 HRESULT
set_moniker(HTMLOuterWindow
*window
, IMoniker
*mon
, IUri
*nav_uri
, IBindCtx
*pibc
, nsChannelBSC
*async_bsc
,
343 download_proc_task_t
*download_task
;
344 nsChannelBSC
*bscallback
;
350 hres
= IMoniker_GetDisplayName(mon
, pibc
, NULL
, &url
);
352 WARN("GetDisplayName failed: %08lx\n", hres
);
359 hres
= create_uri(url
, 0, &uri
);
366 TRACE("got url: %s\n", debugstr_w(url
));
368 set_ready_state(window
, READYSTATE_LOADING
);
370 hres
= create_doc_uri(uri
, &nsuri
);
379 bscallback
= async_bsc
;
381 hres
= create_channelbsc(mon
, NULL
, NULL
, 0, TRUE
, &bscallback
);
383 if(SUCCEEDED(hres
)) {
384 if(window
->base
.inner_window
->doc
)
385 remove_target_tasks(window
->base
.inner_window
->task_magic
);
386 abort_window_bindings(window
->base
.inner_window
);
388 hres
= load_nsuri(window
, nsuri
, NULL
, bscallback
, LOAD_FLAGS_BYPASS_CACHE
);
389 if(SUCCEEDED(hres
)) {
390 hres
= create_pending_window(window
, bscallback
);
391 TRACE("pending window for %p %p %p\n", window
, bscallback
, window
->pending_window
);
393 if(bscallback
!= async_bsc
)
394 IBindStatusCallback_Release(&bscallback
->bsc
.IBindStatusCallback_iface
);
396 nsISupports_Release((nsISupports
*)nsuri
); /* FIXME */
403 if(is_main_content_window(window
)) {
404 HTMLDocumentObj
*doc_obj
= window
->browser
->doc
;
406 HTMLDocument_LockContainer(doc_obj
, TRUE
);
411 task
= malloc(sizeof(docobj_task_t
));
413 hres
= push_task(&task
->header
, set_progress_proc
, set_progress_destr
, doc_obj
->task_magic
);
420 if(doc_obj
->nscontainer
->usermode
== EDITMODE
)
421 window
->load_flags
= BINDING_REFRESH
;
423 download_task
= malloc(sizeof(download_proc_task_t
));
424 download_task
->doc
= doc_obj
;
425 download_task
->set_download
= set_download
;
426 download_task
->url
= url
;
427 return push_task(&download_task
->header
, set_downloading_proc
, set_downloading_task_destr
, doc_obj
->task_magic
);
433 static void notif_readystate(HTMLOuterWindow
*window
)
435 HTMLInnerWindow
*inner_window
= window
->base
.inner_window
;
436 HTMLFrameBase
*frame_element
= window
->frame_element
;
440 window
->readystate_pending
= FALSE
;
442 IHTMLWindow2_AddRef(&inner_window
->base
.IHTMLWindow2_iface
);
444 IHTMLDOMNode_AddRef(&frame_element
->element
.node
.IHTMLDOMNode_iface
);
446 if(is_main_content_window(window
))
447 call_property_onchanged(&window
->browser
->doc
->cp_container
, DISPID_READYSTATE
);
449 hres
= create_document_event(inner_window
->doc
, EVENTID_READYSTATECHANGE
, &event
);
450 if(SUCCEEDED(hres
)) {
451 event
->no_event_obj
= TRUE
;
452 dispatch_event(&inner_window
->doc
->node
.event_target
, event
);
453 IDOMEvent_Release(&event
->IDOMEvent_iface
);
455 IHTMLWindow2_Release(&inner_window
->base
.IHTMLWindow2_iface
);
458 hres
= create_document_event(frame_element
->element
.node
.doc
, EVENTID_READYSTATECHANGE
, &event
);
459 if(SUCCEEDED(hres
)) {
460 dispatch_event(&frame_element
->element
.node
.event_target
, event
);
461 IDOMEvent_Release(&event
->IDOMEvent_iface
);
463 IHTMLDOMNode_Release(&frame_element
->element
.node
.IHTMLDOMNode_iface
);
467 static void notif_readystate_proc(event_task_t
*task
)
469 notif_readystate(task
->window
->base
.outer_window
);
472 static void notif_readystate_destr(event_task_t
*task
)
476 void set_ready_state(HTMLOuterWindow
*window
, READYSTATE readystate
)
478 READYSTATE prev_state
= window
->readystate
;
480 window
->readystate
= readystate
;
482 if(window
->readystate_locked
) {
486 if(window
->readystate_pending
|| prev_state
== readystate
)
489 task
= malloc(sizeof(*task
));
493 hres
= push_event_task(task
, window
->base
.inner_window
, notif_readystate_proc
, notif_readystate_destr
, window
->task_magic
);
495 window
->readystate_pending
= TRUE
;
499 notif_readystate(window
);
502 static HRESULT
get_doc_string(HTMLDocumentNode
*This
, char **str
)
510 if(!This
->dom_document
) {
511 WARN("NULL dom_document\n");
515 nsres
= nsIDOMDocument_QueryInterface(This
->dom_document
, &IID_nsIDOMNode
, (void**)&nsnode
);
516 if(NS_FAILED(nsres
)) {
517 ERR("Could not get nsIDOMNode failed: %08lx\n", nsres
);
521 nsAString_Init(&nsstr
, NULL
);
522 hres
= nsnode_to_nsstring(nsnode
, &nsstr
);
523 nsIDOMNode_Release(nsnode
);
525 nsAString_Finish(&nsstr
);
529 nsAString_GetData(&nsstr
, &strw
);
530 TRACE("%s\n", debugstr_w(strw
));
532 *str
= strdupWtoA(strw
);
534 nsAString_Finish(&nsstr
);
537 return E_OUTOFMEMORY
;
542 /**********************************************************
543 * IPersistMoniker implementation
546 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IPersistMoniker(IPersistMoniker
*iface
)
548 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IPersistMoniker_iface
);
551 static HRESULT WINAPI
DocNodePersistMoniker_QueryInterface(IPersistMoniker
*iface
, REFIID riid
, void **ppv
)
553 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
554 return IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
557 static ULONG WINAPI
DocNodePersistMoniker_AddRef(IPersistMoniker
*iface
)
559 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
560 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
563 static ULONG WINAPI
DocNodePersistMoniker_Release(IPersistMoniker
*iface
)
565 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
566 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
569 static HRESULT WINAPI
DocNodePersistMoniker_GetClassID(IPersistMoniker
*iface
, CLSID
*pClassID
)
571 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
572 return IPersistFile_GetClassID(&This
->IPersistFile_iface
, pClassID
);
575 static HRESULT WINAPI
DocNodePersistMoniker_IsDirty(IPersistMoniker
*iface
)
577 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
579 TRACE("(%p)\n", This
);
581 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
584 static HRESULT WINAPI
DocNodePersistMoniker_Load(IPersistMoniker
*iface
, BOOL fFullyAvailable
,
585 IMoniker
*pimkName
, LPBC pibc
, DWORD grfMode
)
587 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
588 return IPersistMoniker_Load(&This
->doc_obj
->IPersistMoniker_iface
, fFullyAvailable
, pimkName
, pibc
, grfMode
);
591 static HRESULT WINAPI
DocNodePersistMoniker_Save(IPersistMoniker
*iface
, IMoniker
*pimkName
,
592 LPBC pbc
, BOOL fRemember
)
594 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
595 FIXME("(%p)->(%p %p %x)\n", This
, pimkName
, pbc
, fRemember
);
599 static HRESULT WINAPI
DocNodePersistMoniker_SaveCompleted(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pibc
)
601 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
602 FIXME("(%p)->(%p %p)\n", This
, pimkName
, pibc
);
606 static HRESULT WINAPI
DocNodePersistMoniker_GetCurMoniker(IPersistMoniker
*iface
, IMoniker
**ppimkName
)
608 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistMoniker(iface
);
609 return IPersistMoniker_GetCurMoniker(&This
->doc_obj
->IPersistMoniker_iface
, ppimkName
);
612 static const IPersistMonikerVtbl DocNodePersistMonikerVtbl
= {
613 DocNodePersistMoniker_QueryInterface
,
614 DocNodePersistMoniker_AddRef
,
615 DocNodePersistMoniker_Release
,
616 DocNodePersistMoniker_GetClassID
,
617 DocNodePersistMoniker_IsDirty
,
618 DocNodePersistMoniker_Load
,
619 DocNodePersistMoniker_Save
,
620 DocNodePersistMoniker_SaveCompleted
,
621 DocNodePersistMoniker_GetCurMoniker
624 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IPersistMoniker(IPersistMoniker
*iface
)
626 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IPersistMoniker_iface
);
629 static HRESULT WINAPI
DocObjPersistMoniker_QueryInterface(IPersistMoniker
*iface
, REFIID riid
, void **ppv
)
631 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
632 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
635 static ULONG WINAPI
DocObjPersistMoniker_AddRef(IPersistMoniker
*iface
)
637 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
638 return IUnknown_AddRef(This
->outer_unk
);
641 static ULONG WINAPI
DocObjPersistMoniker_Release(IPersistMoniker
*iface
)
643 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
644 return IUnknown_Release(This
->outer_unk
);
647 static HRESULT WINAPI
DocObjPersistMoniker_GetClassID(IPersistMoniker
*iface
, CLSID
*pClassID
)
649 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
650 return IPersistFile_GetClassID(&This
->IPersistFile_iface
, pClassID
);
653 static HRESULT WINAPI
DocObjPersistMoniker_IsDirty(IPersistMoniker
*iface
)
655 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
657 TRACE("(%p)\n", This
);
659 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
662 static HRESULT WINAPI
DocObjPersistMoniker_Load(IPersistMoniker
*iface
, BOOL fFullyAvailable
,
663 IMoniker
*pimkName
, LPBC pibc
, DWORD grfMode
)
665 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
669 TRACE("(%p)->(%x %p %p %08lx)\n", This
, fFullyAvailable
, pimkName
, pibc
, grfMode
);
672 IUnknown
*unk
= NULL
;
676 * "__PrecreatedObject"
677 * "BIND_CONTEXT_PARAM"
678 * "__HTMLLOADOPTIONS"
681 * "_ITransData_Object_"
685 hres
= IBindCtx_GetObjectParam(pibc
, (LPOLESTR
)SZ_HTML_CLIENTSITE_OBJECTPARAM
, &unk
);
686 if(SUCCEEDED(hres
) && unk
) {
687 IOleClientSite
*client
= NULL
;
689 hres
= IUnknown_QueryInterface(unk
, &IID_IOleClientSite
, (void**)&client
);
690 if(SUCCEEDED(hres
)) {
691 TRACE("Got client site %p\n", client
);
692 IOleObject_SetClientSite(&This
->IOleObject_iface
, client
);
693 IOleClientSite_Release(client
);
696 IUnknown_Release(unk
);
703 hres
= MimeOleObjectFromMoniker(0, pimkName
, pibc
, &IID_IUnknown
, (void**)&unk
, &mon
);
706 IUnknown_Release(unk
);
709 IMoniker_AddRef(mon
= pimkName
);
712 prepare_for_binding(This
, mon
, FALSE
);
713 call_docview_84(This
);
714 hres
= set_moniker(This
->window
, mon
, NULL
, pibc
, NULL
, TRUE
);
715 IMoniker_Release(mon
);
719 return start_binding(This
->window
->pending_window
, (BSCallback
*)This
->window
->pending_window
->bscallback
, pibc
);
722 static HRESULT WINAPI
DocObjPersistMoniker_Save(IPersistMoniker
*iface
, IMoniker
*pimkName
,
723 LPBC pbc
, BOOL fRemember
)
725 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
726 FIXME("(%p)->(%p %p %x)\n", This
, pimkName
, pbc
, fRemember
);
730 static HRESULT WINAPI
DocObjPersistMoniker_SaveCompleted(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pibc
)
732 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
733 FIXME("(%p)->(%p %p)\n", This
, pimkName
, pibc
);
737 static HRESULT WINAPI
DocObjPersistMoniker_GetCurMoniker(IPersistMoniker
*iface
, IMoniker
**ppimkName
)
739 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistMoniker(iface
);
741 TRACE("(%p)->(%p)\n", This
, ppimkName
);
743 if(!This
->window
|| !This
->window
->mon
)
746 IMoniker_AddRef(This
->window
->mon
);
747 *ppimkName
= This
->window
->mon
;
751 static const IPersistMonikerVtbl DocObjPersistMonikerVtbl
= {
752 DocObjPersistMoniker_QueryInterface
,
753 DocObjPersistMoniker_AddRef
,
754 DocObjPersistMoniker_Release
,
755 DocObjPersistMoniker_GetClassID
,
756 DocObjPersistMoniker_IsDirty
,
757 DocObjPersistMoniker_Load
,
758 DocObjPersistMoniker_Save
,
759 DocObjPersistMoniker_SaveCompleted
,
760 DocObjPersistMoniker_GetCurMoniker
763 /**********************************************************
764 * IMonikerProp implementation
767 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IMonikerProp(IMonikerProp
*iface
)
769 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IMonikerProp_iface
);
772 static HRESULT WINAPI
DocNodeMonikerProp_QueryInterface(IMonikerProp
*iface
, REFIID riid
, void **ppv
)
774 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IMonikerProp(iface
);
775 return IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
778 static ULONG WINAPI
DocNodeMonikerProp_AddRef(IMonikerProp
*iface
)
780 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IMonikerProp(iface
);
781 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
784 static ULONG WINAPI
DocNodeMonikerProp_Release(IMonikerProp
*iface
)
786 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IMonikerProp(iface
);
787 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
790 static HRESULT WINAPI
DocNodeMonikerProp_PutProperty(IMonikerProp
*iface
, MONIKERPROPERTY mkp
, LPCWSTR val
)
792 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IMonikerProp(iface
);
793 return IMonikerProp_PutProperty(&This
->doc_obj
->IMonikerProp_iface
, mkp
, val
);
796 static const IMonikerPropVtbl DocNodeMonikerPropVtbl
= {
797 DocNodeMonikerProp_QueryInterface
,
798 DocNodeMonikerProp_AddRef
,
799 DocNodeMonikerProp_Release
,
800 DocNodeMonikerProp_PutProperty
803 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IMonikerProp(IMonikerProp
*iface
)
805 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IMonikerProp_iface
);
808 static HRESULT WINAPI
DocObjMonikerProp_QueryInterface(IMonikerProp
*iface
, REFIID riid
, void **ppv
)
810 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IMonikerProp(iface
);
811 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
814 static ULONG WINAPI
DocObjMonikerProp_AddRef(IMonikerProp
*iface
)
816 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IMonikerProp(iface
);
817 return IUnknown_AddRef(This
->outer_unk
);
820 static ULONG WINAPI
DocObjMonikerProp_Release(IMonikerProp
*iface
)
822 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IMonikerProp(iface
);
823 return IUnknown_Release(This
->outer_unk
);
826 static HRESULT WINAPI
DocObjMonikerProp_PutProperty(IMonikerProp
*iface
, MONIKERPROPERTY mkp
, LPCWSTR val
)
828 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IMonikerProp(iface
);
830 TRACE("(%p)->(%d %s)\n", This
, mkp
, debugstr_w(val
));
835 This
->mime
= wcsdup(val
);
842 FIXME("mkp %d\n", mkp
);
849 static const IMonikerPropVtbl DocObjMonikerPropVtbl
= {
850 DocObjMonikerProp_QueryInterface
,
851 DocObjMonikerProp_AddRef
,
852 DocObjMonikerProp_Release
,
853 DocObjMonikerProp_PutProperty
856 /**********************************************************
857 * IPersistFile implementation
860 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IPersistFile(IPersistFile
*iface
)
862 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IPersistFile_iface
);
865 static HRESULT WINAPI
DocNodePersistFile_QueryInterface(IPersistFile
*iface
, REFIID riid
, void **ppv
)
867 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
868 return IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
871 static ULONG WINAPI
DocNodePersistFile_AddRef(IPersistFile
*iface
)
873 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
874 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
877 static ULONG WINAPI
DocNodePersistFile_Release(IPersistFile
*iface
)
879 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
880 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
883 static HRESULT WINAPI
DocNodePersistFile_GetClassID(IPersistFile
*iface
, CLSID
*pClassID
)
885 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
886 return IPersistFile_GetClassID(&This
->doc_obj
->IPersistFile_iface
, pClassID
);
889 static HRESULT WINAPI
DocNodePersistFile_IsDirty(IPersistFile
*iface
)
891 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
893 TRACE("(%p)\n", This
);
895 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
898 static HRESULT WINAPI
DocNodePersistFile_Load(IPersistFile
*iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
900 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
901 FIXME("(%p)->(%s %08lx)\n", This
, debugstr_w(pszFileName
), dwMode
);
905 static HRESULT WINAPI
DocNodePersistFile_Save(IPersistFile
*iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
907 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
913 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(pszFileName
), fRemember
);
915 file
= CreateFileW(pszFileName
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
916 FILE_ATTRIBUTE_NORMAL
, NULL
);
917 if(file
== INVALID_HANDLE_VALUE
) {
918 WARN("Could not create file: %lu\n", GetLastError());
922 hres
= get_doc_string(This
, &str
);
924 WriteFile(file
, str
, strlen(str
), &written
, NULL
);
930 static HRESULT WINAPI
DocNodePersistFile_SaveCompleted(IPersistFile
*iface
, LPCOLESTR pszFileName
)
932 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
933 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFileName
));
937 static HRESULT WINAPI
DocNodePersistFile_GetCurFile(IPersistFile
*iface
, LPOLESTR
*pszFileName
)
939 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistFile(iface
);
940 FIXME("(%p)->(%p)\n", This
, pszFileName
);
944 static const IPersistFileVtbl DocNodePersistFileVtbl
= {
945 DocNodePersistFile_QueryInterface
,
946 DocNodePersistFile_AddRef
,
947 DocNodePersistFile_Release
,
948 DocNodePersistFile_GetClassID
,
949 DocNodePersistFile_IsDirty
,
950 DocNodePersistFile_Load
,
951 DocNodePersistFile_Save
,
952 DocNodePersistFile_SaveCompleted
,
953 DocNodePersistFile_GetCurFile
956 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IPersistFile(IPersistFile
*iface
)
958 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IPersistFile_iface
);
961 static HRESULT WINAPI
DocObjPersistFile_QueryInterface(IPersistFile
*iface
, REFIID riid
, void **ppv
)
963 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
964 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
967 static ULONG WINAPI
DocObjPersistFile_AddRef(IPersistFile
*iface
)
969 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
970 return IUnknown_AddRef(This
->outer_unk
);
973 static ULONG WINAPI
DocObjPersistFile_Release(IPersistFile
*iface
)
975 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
976 return IUnknown_Release(This
->outer_unk
);
979 static HRESULT WINAPI
DocObjPersistFile_GetClassID(IPersistFile
*iface
, CLSID
*pClassID
)
981 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
983 TRACE("(%p)->(%p)\n", This
, pClassID
);
988 *pClassID
= CLSID_HTMLDocument
;
992 static HRESULT WINAPI
DocObjPersistFile_IsDirty(IPersistFile
*iface
)
994 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
996 TRACE("(%p)\n", This
);
998 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
1001 static HRESULT WINAPI
DocObjPersistFile_Load(IPersistFile
*iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
1003 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
1004 FIXME("(%p)->(%s %08lx)\n", This
, debugstr_w(pszFileName
), dwMode
);
1008 static HRESULT WINAPI
DocObjPersistFile_Save(IPersistFile
*iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
1010 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistFile(iface
);
1012 return IPersistFile_Save(&This
->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 IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
1053 static ULONG WINAPI
DocNodePersistStreamInit_AddRef(IPersistStreamInit
*iface
)
1055 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistStreamInit(iface
);
1056 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
1059 static ULONG WINAPI
DocNodePersistStreamInit_Release(IPersistStreamInit
*iface
)
1061 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistStreamInit(iface
);
1062 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
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
->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
->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
->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
->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 IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
1147 static ULONG WINAPI
DocObjPersistStreamInit_AddRef(IPersistStreamInit
*iface
)
1149 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1150 return IUnknown_AddRef(This
->outer_unk
);
1153 static ULONG WINAPI
DocObjPersistStreamInit_Release(IPersistStreamInit
*iface
)
1155 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1156 return IUnknown_Release(This
->outer_unk
);
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
->window
, mon
, NULL
, NULL
, NULL
, TRUE
);
1191 hres
= channelbsc_load_stream(This
->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 return IPersistStreamInit_Save(&This
->doc_node
->IPersistStreamInit_iface
, pStm
, fClearDirty
);
1205 static HRESULT WINAPI
DocObjPersistStreamInit_GetSizeMax(IPersistStreamInit
*iface
,
1206 ULARGE_INTEGER
*pcbSize
)
1208 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1209 FIXME("(%p)->(%p)\n", This
, pcbSize
);
1213 static HRESULT WINAPI
DocObjPersistStreamInit_InitNew(IPersistStreamInit
*iface
)
1215 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistStreamInit(iface
);
1219 TRACE("(%p)\n", This
);
1221 hres
= CreateURLMoniker(NULL
, L
"about:blank", &mon
);
1223 WARN("CreateURLMoniker failed: %08lx\n", hres
);
1227 prepare_for_binding(This
, mon
, FALSE
);
1228 hres
= set_moniker(This
->window
, mon
, NULL
, NULL
, NULL
, FALSE
);
1230 hres
= channelbsc_load_stream(This
->window
->pending_window
, mon
, NULL
);
1232 IMoniker_Release(mon
);
1236 static const IPersistStreamInitVtbl DocObjPersistStreamInitVtbl
= {
1237 DocObjPersistStreamInit_QueryInterface
,
1238 DocObjPersistStreamInit_AddRef
,
1239 DocObjPersistStreamInit_Release
,
1240 DocObjPersistStreamInit_GetClassID
,
1241 DocObjPersistStreamInit_IsDirty
,
1242 DocObjPersistStreamInit_Load
,
1243 DocObjPersistStreamInit_Save
,
1244 DocObjPersistStreamInit_GetSizeMax
,
1245 DocObjPersistStreamInit_InitNew
1248 /**********************************************************
1249 * IPersistHistory implementation
1252 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IPersistHistory(IPersistHistory
*iface
)
1254 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IPersistHistory_iface
);
1257 static HRESULT WINAPI
DocNodePersistHistory_QueryInterface(IPersistHistory
*iface
, REFIID riid
, void **ppv
)
1259 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1260 return IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
1263 static ULONG WINAPI
DocNodePersistHistory_AddRef(IPersistHistory
*iface
)
1265 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1266 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
1269 static ULONG WINAPI
DocNodePersistHistory_Release(IPersistHistory
*iface
)
1271 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1272 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
1275 static HRESULT WINAPI
DocNodePersistHistory_GetClassID(IPersistHistory
*iface
, CLSID
*pClassID
)
1277 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1278 return IPersistFile_GetClassID(&This
->IPersistFile_iface
, pClassID
);
1281 static HRESULT WINAPI
DocNodePersistHistory_LoadHistory(IPersistHistory
*iface
, IStream
*pStream
, IBindCtx
*pbc
)
1283 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1284 return IPersistHistory_LoadHistory(&This
->doc_obj
->IPersistHistory_iface
, pStream
, pbc
);
1287 static HRESULT WINAPI
DocNodePersistHistory_SaveHistory(IPersistHistory
*iface
, IStream
*pStream
)
1289 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1290 return IPersistHistory_SaveHistory(&This
->doc_obj
->IPersistHistory_iface
, pStream
);
1293 static HRESULT WINAPI
DocNodePersistHistory_SetPositionCookie(IPersistHistory
*iface
, DWORD dwPositioncookie
)
1295 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1296 FIXME("(%p)->(%lx)\n", This
, dwPositioncookie
);
1300 static HRESULT WINAPI
DocNodePersistHistory_GetPositionCookie(IPersistHistory
*iface
, DWORD
*pdwPositioncookie
)
1302 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IPersistHistory(iface
);
1303 FIXME("(%p)->(%p)\n", This
, pdwPositioncookie
);
1307 static const IPersistHistoryVtbl DocNodePersistHistoryVtbl
= {
1308 DocNodePersistHistory_QueryInterface
,
1309 DocNodePersistHistory_AddRef
,
1310 DocNodePersistHistory_Release
,
1311 DocNodePersistHistory_GetClassID
,
1312 DocNodePersistHistory_LoadHistory
,
1313 DocNodePersistHistory_SaveHistory
,
1314 DocNodePersistHistory_SetPositionCookie
,
1315 DocNodePersistHistory_GetPositionCookie
1318 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IPersistHistory(IPersistHistory
*iface
)
1320 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IPersistHistory_iface
);
1323 static HRESULT WINAPI
DocObjPersistHistory_QueryInterface(IPersistHistory
*iface
, REFIID riid
, void **ppv
)
1325 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1326 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
1329 static ULONG WINAPI
DocObjPersistHistory_AddRef(IPersistHistory
*iface
)
1331 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1332 return IUnknown_AddRef(This
->outer_unk
);
1335 static ULONG WINAPI
DocObjPersistHistory_Release(IPersistHistory
*iface
)
1337 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1338 return IUnknown_Release(This
->outer_unk
);
1341 static HRESULT WINAPI
DocObjPersistHistory_GetClassID(IPersistHistory
*iface
, CLSID
*pClassID
)
1343 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1344 return IPersistFile_GetClassID(&This
->IPersistFile_iface
, pClassID
);
1347 static HRESULT WINAPI
DocObjPersistHistory_LoadHistory(IPersistHistory
*iface
, IStream
*pStream
, IBindCtx
*pbc
)
1349 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1350 ULONG str_len
, read
;
1355 TRACE("(%p)->(%p %p)\n", This
, pStream
, pbc
);
1358 FIXME("No current window\n");
1359 return E_UNEXPECTED
;
1363 FIXME("pbc not supported\n");
1366 IOleCommandTarget
*cmdtrg
= NULL
;
1368 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1369 if(SUCCEEDED(hres
)) {
1370 IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 138, 0, NULL
, NULL
);
1371 IOleCommandTarget_Release(cmdtrg
);
1375 hres
= IStream_Read(pStream
, &str_len
, sizeof(str_len
), &read
);
1378 if(read
!= sizeof(str_len
))
1381 uri_str
= malloc((str_len
+ 1) * sizeof(WCHAR
));
1383 return E_OUTOFMEMORY
;
1385 hres
= IStream_Read(pStream
, uri_str
, str_len
*sizeof(WCHAR
), &read
);
1386 if(SUCCEEDED(hres
) && read
!= str_len
*sizeof(WCHAR
))
1388 if(SUCCEEDED(hres
)) {
1389 uri_str
[str_len
] = 0;
1390 hres
= create_uri(uri_str
, 0, &uri
);
1396 hres
= load_uri(This
->window
, uri
, BINDING_FROMHIST
);
1401 static HRESULT WINAPI
DocObjPersistHistory_SaveHistory(IPersistHistory
*iface
, IStream
*pStream
)
1403 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1408 TRACE("(%p)->(%p)\n", This
, pStream
);
1410 if(!This
->window
|| !This
->window
->uri
) {
1411 FIXME("No current URI\n");
1415 /* NOTE: The format we store is *not* compatible with native MSHTML. We currently
1416 * store only URI of the page (as a length followed by a string) */
1417 hres
= IUri_GetDisplayUri(This
->window
->uri
, &display_uri
);
1421 len
= SysStringLen(display_uri
);
1422 hres
= IStream_Write(pStream
, &len
, sizeof(len
), &written
);
1424 hres
= IStream_Write(pStream
, display_uri
, len
*sizeof(WCHAR
), &written
);
1425 SysFreeString(display_uri
);
1429 static HRESULT WINAPI
DocObjPersistHistory_SetPositionCookie(IPersistHistory
*iface
, DWORD dwPositioncookie
)
1431 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1432 FIXME("(%p)->(%lx)\n", This
, dwPositioncookie
);
1436 static HRESULT WINAPI
DocObjPersistHistory_GetPositionCookie(IPersistHistory
*iface
, DWORD
*pdwPositioncookie
)
1438 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IPersistHistory(iface
);
1439 FIXME("(%p)->(%p)\n", This
, pdwPositioncookie
);
1443 static const IPersistHistoryVtbl DocObjPersistHistoryVtbl
= {
1444 DocObjPersistHistory_QueryInterface
,
1445 DocObjPersistHistory_AddRef
,
1446 DocObjPersistHistory_Release
,
1447 DocObjPersistHistory_GetClassID
,
1448 DocObjPersistHistory_LoadHistory
,
1449 DocObjPersistHistory_SaveHistory
,
1450 DocObjPersistHistory_SetPositionCookie
,
1451 DocObjPersistHistory_GetPositionCookie
1454 /**********************************************************
1455 * IHlinkTarget implementation
1458 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IHlinkTarget(IHlinkTarget
*iface
)
1460 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IHlinkTarget_iface
);
1463 static HRESULT WINAPI
DocNodeHlinkTarget_QueryInterface(IHlinkTarget
*iface
, REFIID riid
, void **ppv
)
1465 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1466 return IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
1469 static ULONG WINAPI
DocNodeHlinkTarget_AddRef(IHlinkTarget
*iface
)
1471 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1472 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
1475 static ULONG WINAPI
DocNodeHlinkTarget_Release(IHlinkTarget
*iface
)
1477 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1478 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
1481 static HRESULT WINAPI
DocNodeHlinkTarget_SetBrowseContext(IHlinkTarget
*iface
, IHlinkBrowseContext
*pihlbc
)
1483 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1484 FIXME("(%p)->(%p)\n", This
, pihlbc
);
1488 static HRESULT WINAPI
DocNodeHlinkTarget_GetBrowseContext(IHlinkTarget
*iface
, IHlinkBrowseContext
**ppihlbc
)
1490 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1491 FIXME("(%p)->(%p)\n", This
, ppihlbc
);
1495 static HRESULT WINAPI
DocNodeHlinkTarget_Navigate(IHlinkTarget
*iface
, DWORD grfHLNF
, LPCWSTR pwzJumpLocation
)
1497 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1499 TRACE("(%p)->(%08lx %s)\n", This
, grfHLNF
, debugstr_w(pwzJumpLocation
));
1502 FIXME("Unsupported grfHLNF=%08lx\n", grfHLNF
);
1504 FIXME("JumpLocation not supported\n");
1506 if(This
->doc_obj
->client
)
1507 return IOleObject_DoVerb(&This
->IOleObject_iface
, OLEIVERB_SHOW
, NULL
, NULL
, -1, NULL
, NULL
);
1509 return IHlinkTarget_Navigate(&This
->doc_obj
->IHlinkTarget_iface
, grfHLNF
, pwzJumpLocation
);
1512 static HRESULT WINAPI
DocNodeHlinkTarget_GetMoniker(IHlinkTarget
*iface
, LPCWSTR pwzLocation
, DWORD dwAssign
,
1513 IMoniker
**ppimkLocation
)
1515 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1516 FIXME("(%p)->(%s %08lx %p)\n", This
, debugstr_w(pwzLocation
), dwAssign
, ppimkLocation
);
1520 static HRESULT WINAPI
DocNodeHlinkTarget_GetFriendlyName(IHlinkTarget
*iface
, LPCWSTR pwzLocation
,
1521 LPWSTR
*ppwzFriendlyName
)
1523 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IHlinkTarget(iface
);
1524 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(pwzLocation
), ppwzFriendlyName
);
1528 static const IHlinkTargetVtbl DocNodeHlinkTargetVtbl
= {
1529 DocNodeHlinkTarget_QueryInterface
,
1530 DocNodeHlinkTarget_AddRef
,
1531 DocNodeHlinkTarget_Release
,
1532 DocNodeHlinkTarget_SetBrowseContext
,
1533 DocNodeHlinkTarget_GetBrowseContext
,
1534 DocNodeHlinkTarget_Navigate
,
1535 DocNodeHlinkTarget_GetMoniker
,
1536 DocNodeHlinkTarget_GetFriendlyName
1539 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IHlinkTarget(IHlinkTarget
*iface
)
1541 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IHlinkTarget_iface
);
1544 static HRESULT WINAPI
DocObjHlinkTarget_QueryInterface(IHlinkTarget
*iface
, REFIID riid
, void **ppv
)
1546 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1547 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
1550 static ULONG WINAPI
DocObjHlinkTarget_AddRef(IHlinkTarget
*iface
)
1552 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1553 return IUnknown_AddRef(This
->outer_unk
);
1556 static ULONG WINAPI
DocObjHlinkTarget_Release(IHlinkTarget
*iface
)
1558 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1559 return IUnknown_Release(This
->outer_unk
);
1562 static HRESULT WINAPI
DocObjHlinkTarget_SetBrowseContext(IHlinkTarget
*iface
, IHlinkBrowseContext
*pihlbc
)
1564 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1565 FIXME("(%p)->(%p)\n", This
, pihlbc
);
1569 static HRESULT WINAPI
DocObjHlinkTarget_GetBrowseContext(IHlinkTarget
*iface
, IHlinkBrowseContext
**ppihlbc
)
1571 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1572 FIXME("(%p)->(%p)\n", This
, ppihlbc
);
1576 static HRESULT WINAPI
DocObjHlinkTarget_Navigate(IHlinkTarget
*iface
, DWORD grfHLNF
, LPCWSTR pwzJumpLocation
)
1578 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1580 TRACE("(%p)->(%08lx %s)\n", This
, grfHLNF
, debugstr_w(pwzJumpLocation
));
1583 FIXME("Unsupported grfHLNF=%08lx\n", grfHLNF
);
1585 FIXME("JumpLocation not supported\n");
1591 hres
= IUri_GetAbsoluteUri(This
->window
->uri
, &uri
);
1596 ShellExecuteW(NULL
, L
"open", uri
, NULL
, NULL
, SW_SHOW
);
1601 return IOleObject_DoVerb(&This
->IOleObject_iface
, OLEIVERB_SHOW
, NULL
, NULL
, -1, NULL
, NULL
);
1604 static HRESULT WINAPI
DocObjHlinkTarget_GetMoniker(IHlinkTarget
*iface
, LPCWSTR pwzLocation
, DWORD dwAssign
,
1605 IMoniker
**ppimkLocation
)
1607 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1608 FIXME("(%p)->(%s %08lx %p)\n", This
, debugstr_w(pwzLocation
), dwAssign
, ppimkLocation
);
1612 static HRESULT WINAPI
DocObjHlinkTarget_GetFriendlyName(IHlinkTarget
*iface
, LPCWSTR pwzLocation
,
1613 LPWSTR
*ppwzFriendlyName
)
1615 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IHlinkTarget(iface
);
1616 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(pwzLocation
), ppwzFriendlyName
);
1620 static const IHlinkTargetVtbl DocObjHlinkTargetVtbl
= {
1621 DocObjHlinkTarget_QueryInterface
,
1622 DocObjHlinkTarget_AddRef
,
1623 DocObjHlinkTarget_Release
,
1624 DocObjHlinkTarget_SetBrowseContext
,
1625 DocObjHlinkTarget_GetBrowseContext
,
1626 DocObjHlinkTarget_Navigate
,
1627 DocObjHlinkTarget_GetMoniker
,
1628 DocObjHlinkTarget_GetFriendlyName
1631 void HTMLDocumentNode_Persist_Init(HTMLDocumentNode
*This
)
1633 This
->IPersistMoniker_iface
.lpVtbl
= &DocNodePersistMonikerVtbl
;
1634 This
->IPersistFile_iface
.lpVtbl
= &DocNodePersistFileVtbl
;
1635 This
->IMonikerProp_iface
.lpVtbl
= &DocNodeMonikerPropVtbl
;
1636 This
->IPersistStreamInit_iface
.lpVtbl
= &DocNodePersistStreamInitVtbl
;
1637 This
->IPersistHistory_iface
.lpVtbl
= &DocNodePersistHistoryVtbl
;
1638 This
->IHlinkTarget_iface
.lpVtbl
= &DocNodeHlinkTargetVtbl
;
1641 void HTMLDocumentObj_Persist_Init(HTMLDocumentObj
*This
)
1643 This
->IPersistMoniker_iface
.lpVtbl
= &DocObjPersistMonikerVtbl
;
1644 This
->IPersistFile_iface
.lpVtbl
= &DocObjPersistFileVtbl
;
1645 This
->IMonikerProp_iface
.lpVtbl
= &DocObjMonikerPropVtbl
;
1646 This
->IPersistStreamInit_iface
.lpVtbl
= &DocObjPersistStreamInitVtbl
;
1647 This
->IPersistHistory_iface
.lpVtbl
= &DocObjPersistHistoryVtbl
;
1648 This
->IHlinkTarget_iface
.lpVtbl
= &DocObjHlinkTargetVtbl
;