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
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
35 #define NO_SHLWAPI_REG
38 #include "wine/debug.h"
40 #include "mshtml_private.h"
41 #include "htmlevent.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
52 } download_proc_task_t
;
54 static BOOL
use_gecko_script(HTMLWindow
*window
)
59 hres
= IInternetSecurityManager_MapUrlToZone(window
->secmgr
, window
->url
, &zone
, 0);
61 WARN("Could not map %s to zone: %08x\n", debugstr_w(window
->url
), hres
);
65 TRACE("zone %d\n", zone
);
66 if(zone
== URLZONE_LOCAL_MACHINE
|| zone
== URLZONE_TRUSTED
|| !window
->uri
)
69 hres
= IUri_GetScheme(window
->uri
, &scheme
);
70 return FAILED(hres
) || scheme
!= URL_SCHEME_ABOUT
;
73 void set_current_uri(HTMLWindow
*window
, IUri
*uri
)
76 IUri_Release(window
->uri
);
81 SysFreeString(window
->url
);
91 IUri_GetDisplayUri(uri
, &window
->url
);
94 void set_current_mon(HTMLWindow
*This
, IMoniker
*mon
)
96 IUriContainer
*uri_container
;
101 IMoniker_Release(This
->mon
);
109 IMoniker_AddRef(mon
);
112 hres
= IMoniker_QueryInterface(mon
, &IID_IUriContainer
, (void**)&uri_container
);
113 if(SUCCEEDED(hres
)) {
114 hres
= IUriContainer_GetIUri(uri_container
, &uri
);
115 IUriContainer_Release(uri_container
);
117 WARN("GetIUri failed: %08x\n", hres
);
125 hres
= IMoniker_GetDisplayName(mon
, NULL
, NULL
, &url
);
126 if(SUCCEEDED(hres
)) {
127 hres
= CreateUri(url
, 0, 0, &uri
);
129 WARN("CrateUri failed: %08x\n", hres
);
130 set_current_uri(This
, NULL
);
131 This
->url
= SysAllocString(url
);
137 WARN("GetDisplayName failed: %08x\n", hres
);
141 set_current_uri(This
, uri
);
144 set_script_mode(This
, use_gecko_script(This
) ? SCRIPTMODE_GECKO
: SCRIPTMODE_ACTIVESCRIPT
);
147 void set_download_state(HTMLDocumentObj
*doc
, int state
)
150 IOleCommandTarget
*olecmd
;
153 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
154 if(SUCCEEDED(hres
)) {
160 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETDOWNLOADSTATE
,
161 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
162 IOleCommandTarget_Release(olecmd
);
166 doc
->download_state
= state
;
169 static void set_progress_proc(task_t
*_task
)
171 docobj_task_t
*task
= (docobj_task_t
*)_task
;
172 IOleCommandTarget
*olecmd
= NULL
;
173 HTMLDocumentObj
*doc
= task
->doc
;
176 TRACE("(%p)\n", doc
);
179 IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
182 VARIANT progress_max
, progress
;
184 V_VT(&progress_max
) = VT_I4
;
185 V_I4(&progress_max
) = 0; /* FIXME */
186 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETPROGRESSMAX
, OLECMDEXECOPT_DONTPROMPTUSER
,
187 &progress_max
, NULL
);
189 V_VT(&progress
) = VT_I4
;
190 V_I4(&progress
) = 0; /* FIXME */
191 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETPROGRESSPOS
, OLECMDEXECOPT_DONTPROMPTUSER
,
193 IOleCommandTarget_Release(olecmd
);
196 if(doc
->usermode
== EDITMODE
&& doc
->hostui
) {
197 DOCHOSTUIINFO hostinfo
;
199 memset(&hostinfo
, 0, sizeof(DOCHOSTUIINFO
));
200 hostinfo
.cbSize
= sizeof(DOCHOSTUIINFO
);
201 hres
= IDocHostUIHandler_GetHostInfo(doc
->hostui
, &hostinfo
);
203 /* FIXME: use hostinfo */
204 TRACE("hostinfo = {%u %08x %08x %s %s}\n",
205 hostinfo
.cbSize
, hostinfo
.dwFlags
, hostinfo
.dwDoubleClick
,
206 debugstr_w(hostinfo
.pchHostCss
), debugstr_w(hostinfo
.pchHostNS
));
210 static void set_downloading_proc(task_t
*_task
)
212 download_proc_task_t
*task
= (download_proc_task_t
*)_task
;
213 HTMLDocumentObj
*doc
= task
->doc
;
216 TRACE("(%p)\n", doc
);
218 set_statustext(doc
, IDS_STATUS_DOWNLOADINGFROM
, task
->url
);
220 if(task
->set_download
)
221 set_download_state(doc
, 1);
227 IAdviseSink_OnViewChange(doc
->view_sink
, DVASPECT_CONTENT
, -1);
230 IDropTarget
*drop_target
= NULL
;
232 hres
= IDocHostUIHandler_GetDropTarget(doc
->hostui
, NULL
/* FIXME */, &drop_target
);
233 if(SUCCEEDED(hres
)) {
234 FIXME("Use IDropTarget\n");
235 IDropTarget_Release(drop_target
);
240 static void set_downloading_task_destr(task_t
*_task
)
242 download_proc_task_t
*task
= (download_proc_task_t
*)_task
;
244 CoTaskMemFree(task
->url
);
248 void prepare_for_binding(HTMLDocument
*This
, IMoniker
*mon
, BOOL navigated_binding
)
252 if(This
->doc_obj
->client
) {
253 VARIANT silent
, offline
;
255 hres
= get_client_disp_property(This
->doc_obj
->client
, DISPID_AMBIENT_SILENT
, &silent
);
256 if(SUCCEEDED(hres
)) {
257 if(V_VT(&silent
) != VT_BOOL
)
258 WARN("V_VT(silent) = %d\n", V_VT(&silent
));
259 else if(V_BOOL(&silent
))
260 FIXME("silent == true\n");
263 hres
= get_client_disp_property(This
->doc_obj
->client
,
264 DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &offline
);
265 if(SUCCEEDED(hres
)) {
266 if(V_VT(&offline
) != VT_BOOL
)
267 WARN("V_VT(offline) = %d\n", V_VT(&offline
));
268 else if(V_BOOL(&offline
))
269 FIXME("offline == true\n");
273 if(This
->window
->mon
) {
274 update_doc(This
, UPDATE_TITLE
|UPDATE_UI
);
276 update_doc(This
, UPDATE_TITLE
);
277 set_current_mon(This
->window
, mon
);
280 if(This
->doc_obj
->client
) {
281 IOleCommandTarget
*cmdtrg
= NULL
;
283 hres
= IOleClientSite_QueryInterface(This
->doc_obj
->client
, &IID_IOleCommandTarget
,
285 if(SUCCEEDED(hres
)) {
288 if(!navigated_binding
) {
291 IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 37, 0, &var
, NULL
);
293 V_VT(&var
) = VT_UNKNOWN
;
294 V_UNKNOWN(&var
) = (IUnknown
*)&This
->window
->IHTMLWindow2_iface
;
295 V_VT(&out
) = VT_EMPTY
;
296 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 63, 0, &var
, &out
);
301 IOleCommandTarget_Release(cmdtrg
);
306 HRESULT
set_moniker(HTMLDocument
*This
, IMoniker
*mon
, IBindCtx
*pibc
, nsChannelBSC
*async_bsc
, BOOL set_download
)
308 download_proc_task_t
*download_task
;
309 nsChannelBSC
*bscallback
;
314 hres
= IMoniker_GetDisplayName(mon
, pibc
, NULL
, &url
);
316 WARN("GetDiaplayName failed: %08x\n", hres
);
320 TRACE("got url: %s\n", debugstr_w(url
));
322 set_ready_state(This
->window
, READYSTATE_LOADING
);
324 hres
= create_doc_uri(This
->window
, url
, &nsuri
);
325 if(SUCCEEDED(hres
)) {
327 bscallback
= async_bsc
;
329 hres
= create_channelbsc(mon
, NULL
, NULL
, 0, &bscallback
);
332 if(SUCCEEDED(hres
)) {
333 remove_target_tasks(This
->task_magic
);
334 abort_document_bindings(This
->doc_node
);
336 hres
= load_nsuri(This
->window
, nsuri
, bscallback
, 0/*LOAD_INITIAL_DOCUMENT_URI*/);
337 nsISupports_Release((nsISupports
*)nsuri
); /* FIXME */
339 set_window_bscallback(This
->window
, bscallback
);
340 if(bscallback
!= async_bsc
)
341 IUnknown_Release((IUnknown
*)bscallback
);
349 HTMLDocument_LockContainer(This
->doc_obj
, TRUE
);
351 if(This
->doc_obj
->frame
) {
354 task
= heap_alloc(sizeof(docobj_task_t
));
355 task
->doc
= This
->doc_obj
;
356 push_task(&task
->header
, set_progress_proc
, NULL
, This
->doc_obj
->basedoc
.task_magic
);
359 download_task
= heap_alloc(sizeof(download_proc_task_t
));
360 download_task
->doc
= This
->doc_obj
;
361 download_task
->set_download
= set_download
;
362 download_task
->url
= url
;
363 push_task(&download_task
->header
, set_downloading_proc
, set_downloading_task_destr
, This
->doc_obj
->basedoc
.task_magic
);
368 void set_ready_state(HTMLWindow
*window
, READYSTATE readystate
)
370 window
->readystate
= readystate
;
372 if(window
->doc_obj
&& window
->doc_obj
->basedoc
.window
== window
)
373 call_property_onchanged(&window
->doc_obj
->basedoc
.cp_propnotif
, DISPID_READYSTATE
);
375 fire_event(window
->doc
, EVENTID_READYSTATECHANGE
, FALSE
, window
->doc
->node
.nsnode
, NULL
);
377 if(window
->frame_element
)
378 fire_event(window
->frame_element
->element
.node
.doc
, EVENTID_READYSTATECHANGE
,
379 TRUE
, window
->frame_element
->element
.node
.nsnode
, NULL
);
382 static HRESULT
get_doc_string(HTMLDocumentNode
*This
, char **str
)
391 WARN("NULL nsdoc\n");
395 nsres
= nsIDOMHTMLDocument_QueryInterface(This
->nsdoc
, &IID_nsIDOMNode
, (void**)&nsnode
);
396 if(NS_FAILED(nsres
)) {
397 ERR("Could not get nsIDOMNode failed: %08x\n", nsres
);
401 nsAString_Init(&nsstr
, NULL
);
402 hres
= nsnode_to_nsstring(nsnode
, &nsstr
);
403 nsIDOMNode_Release(nsnode
);
405 nsAString_Finish(&nsstr
);
409 nsAString_GetData(&nsstr
, &strw
);
410 TRACE("%s\n", debugstr_w(strw
));
412 *str
= heap_strdupWtoA(strw
);
414 nsAString_Finish(&nsstr
);
417 return E_OUTOFMEMORY
;
422 /**********************************************************
423 * IPersistMoniker implementation
426 static inline HTMLDocument
*impl_from_IPersistMoniker(IPersistMoniker
*iface
)
428 return CONTAINING_RECORD(iface
, HTMLDocument
, IPersistMoniker_iface
);
431 static HRESULT WINAPI
PersistMoniker_QueryInterface(IPersistMoniker
*iface
, REFIID riid
, void **ppv
)
433 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
434 return htmldoc_query_interface(This
, riid
, ppv
);
437 static ULONG WINAPI
PersistMoniker_AddRef(IPersistMoniker
*iface
)
439 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
440 return htmldoc_addref(This
);
443 static ULONG WINAPI
PersistMoniker_Release(IPersistMoniker
*iface
)
445 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
446 return htmldoc_release(This
);
449 static HRESULT WINAPI
PersistMoniker_GetClassID(IPersistMoniker
*iface
, CLSID
*pClassID
)
451 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
452 return IPersist_GetClassID(&This
->IPersistFile_iface
, pClassID
);
455 static HRESULT WINAPI
PersistMoniker_IsDirty(IPersistMoniker
*iface
)
457 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
459 TRACE("(%p)\n", This
);
461 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
464 static HRESULT WINAPI
PersistMoniker_Load(IPersistMoniker
*iface
, BOOL fFullyAvailable
,
465 IMoniker
*pimkName
, LPBC pibc
, DWORD grfMode
)
467 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
470 TRACE("(%p)->(%x %p %p %08x)\n", This
, fFullyAvailable
, pimkName
, pibc
, grfMode
);
473 IUnknown
*unk
= NULL
;
477 * "__PrecreatedObject"
478 * "BIND_CONTEXT_PARAM"
479 * "__HTMLLOADOPTIONS"
482 * "_ITransData_Object_"
486 IBindCtx_GetObjectParam(pibc
, (LPOLESTR
)SZ_HTML_CLIENTSITE_OBJECTPARAM
, &unk
);
488 IOleClientSite
*client
= NULL
;
490 hres
= IUnknown_QueryInterface(unk
, &IID_IOleClientSite
, (void**)&client
);
491 if(SUCCEEDED(hres
)) {
492 TRACE("Got client site %p\n", client
);
493 IOleObject_SetClientSite(&This
->IOleObject_iface
, client
);
494 IOleClientSite_Release(client
);
497 IUnknown_Release(unk
);
501 prepare_for_binding(This
, pimkName
, FALSE
);
502 hres
= set_moniker(This
, pimkName
, pibc
, NULL
, TRUE
);
506 return start_binding(This
->window
, NULL
, (BSCallback
*)This
->window
->bscallback
, pibc
);
509 static HRESULT WINAPI
PersistMoniker_Save(IPersistMoniker
*iface
, IMoniker
*pimkName
,
510 LPBC pbc
, BOOL fRemember
)
512 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
513 FIXME("(%p)->(%p %p %x)\n", This
, pimkName
, pbc
, fRemember
);
517 static HRESULT WINAPI
PersistMoniker_SaveCompleted(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pibc
)
519 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
520 FIXME("(%p)->(%p %p)\n", This
, pimkName
, pibc
);
524 static HRESULT WINAPI
PersistMoniker_GetCurMoniker(IPersistMoniker
*iface
, IMoniker
**ppimkName
)
526 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
528 TRACE("(%p)->(%p)\n", This
, ppimkName
);
530 if(!This
->window
|| !This
->window
->mon
)
533 IMoniker_AddRef(This
->window
->mon
);
534 *ppimkName
= This
->window
->mon
;
538 static const IPersistMonikerVtbl PersistMonikerVtbl
= {
539 PersistMoniker_QueryInterface
,
540 PersistMoniker_AddRef
,
541 PersistMoniker_Release
,
542 PersistMoniker_GetClassID
,
543 PersistMoniker_IsDirty
,
546 PersistMoniker_SaveCompleted
,
547 PersistMoniker_GetCurMoniker
550 /**********************************************************
551 * IMonikerProp implementation
554 static inline HTMLDocument
*impl_from_IMonikerProp(IMonikerProp
*iface
)
556 return CONTAINING_RECORD(iface
, HTMLDocument
, IMonikerProp_iface
);
559 static HRESULT WINAPI
MonikerProp_QueryInterface(IMonikerProp
*iface
, REFIID riid
, void **ppv
)
561 HTMLDocument
*This
= impl_from_IMonikerProp(iface
);
562 return htmldoc_query_interface(This
, riid
, ppv
);
565 static ULONG WINAPI
MonikerProp_AddRef(IMonikerProp
*iface
)
567 HTMLDocument
*This
= impl_from_IMonikerProp(iface
);
568 return htmldoc_addref(This
);
571 static ULONG WINAPI
MonikerProp_Release(IMonikerProp
*iface
)
573 HTMLDocument
*This
= impl_from_IMonikerProp(iface
);
574 return htmldoc_release(This
);
577 static HRESULT WINAPI
MonikerProp_PutProperty(IMonikerProp
*iface
, MONIKERPROPERTY mkp
, LPCWSTR val
)
579 HTMLDocument
*This
= impl_from_IMonikerProp(iface
);
581 TRACE("(%p)->(%d %s)\n", This
, mkp
, debugstr_w(val
));
585 heap_free(This
->doc_obj
->mime
);
586 This
->doc_obj
->mime
= heap_strdupW(val
);
593 FIXME("mkp %d\n", mkp
);
600 static const IMonikerPropVtbl MonikerPropVtbl
= {
601 MonikerProp_QueryInterface
,
604 MonikerProp_PutProperty
607 /**********************************************************
608 * IPersistFile implementation
611 static inline HTMLDocument
*impl_from_IPersistFile(IPersistFile
*iface
)
613 return CONTAINING_RECORD(iface
, HTMLDocument
, IPersistFile_iface
);
616 static HRESULT WINAPI
PersistFile_QueryInterface(IPersistFile
*iface
, REFIID riid
, void **ppv
)
618 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
619 return htmldoc_query_interface(This
, riid
, ppv
);
622 static ULONG WINAPI
PersistFile_AddRef(IPersistFile
*iface
)
624 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
625 return htmldoc_addref(This
);
628 static ULONG WINAPI
PersistFile_Release(IPersistFile
*iface
)
630 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
631 return htmldoc_release(This
);
634 static HRESULT WINAPI
PersistFile_GetClassID(IPersistFile
*iface
, CLSID
*pClassID
)
636 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
638 TRACE("(%p)->(%p)\n", This
, pClassID
);
643 *pClassID
= CLSID_HTMLDocument
;
647 static HRESULT WINAPI
PersistFile_IsDirty(IPersistFile
*iface
)
649 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
651 TRACE("(%p)\n", This
);
653 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
656 static HRESULT WINAPI
PersistFile_Load(IPersistFile
*iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
658 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
659 FIXME("(%p)->(%s %08x)\n", This
, debugstr_w(pszFileName
), dwMode
);
663 static HRESULT WINAPI
PersistFile_Save(IPersistFile
*iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
665 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
671 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(pszFileName
), fRemember
);
673 file
= CreateFileW(pszFileName
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
674 FILE_ATTRIBUTE_NORMAL
, NULL
);
675 if(file
== INVALID_HANDLE_VALUE
) {
676 WARN("Could not create file: %u\n", GetLastError());
680 hres
= get_doc_string(This
->doc_node
, &str
);
682 WriteFile(file
, str
, strlen(str
), &written
, NULL
);
688 static HRESULT WINAPI
PersistFile_SaveCompleted(IPersistFile
*iface
, LPCOLESTR pszFileName
)
690 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
691 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFileName
));
695 static HRESULT WINAPI
PersistFile_GetCurFile(IPersistFile
*iface
, LPOLESTR
*pszFileName
)
697 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
698 FIXME("(%p)->(%p)\n", This
, pszFileName
);
702 static const IPersistFileVtbl PersistFileVtbl
= {
703 PersistFile_QueryInterface
,
706 PersistFile_GetClassID
,
710 PersistFile_SaveCompleted
,
711 PersistFile_GetCurFile
714 static inline HTMLDocument
*impl_from_IPersistStreamInit(IPersistStreamInit
*iface
)
716 return CONTAINING_RECORD(iface
, HTMLDocument
, IPersistStreamInit_iface
);
719 static HRESULT WINAPI
PersistStreamInit_QueryInterface(IPersistStreamInit
*iface
,
720 REFIID riid
, void **ppv
)
722 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
723 return htmldoc_query_interface(This
, riid
, ppv
);
726 static ULONG WINAPI
PersistStreamInit_AddRef(IPersistStreamInit
*iface
)
728 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
729 return htmldoc_addref(This
);
732 static ULONG WINAPI
PersistStreamInit_Release(IPersistStreamInit
*iface
)
734 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
735 return htmldoc_release(This
);
738 static HRESULT WINAPI
PersistStreamInit_GetClassID(IPersistStreamInit
*iface
, CLSID
*pClassID
)
740 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
741 return IPersist_GetClassID(&This
->IPersistFile_iface
, pClassID
);
744 static HRESULT WINAPI
PersistStreamInit_IsDirty(IPersistStreamInit
*iface
)
746 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
748 TRACE("(%p)\n", This
);
750 if(This
->doc_obj
->usermode
== EDITMODE
)
751 return editor_is_dirty(This
);
756 static HRESULT WINAPI
PersistStreamInit_Load(IPersistStreamInit
*iface
, LPSTREAM pStm
)
758 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
762 static const WCHAR about_blankW
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
764 TRACE("(%p)->(%p)\n", This
, pStm
);
766 hres
= CreateURLMoniker(NULL
, about_blankW
, &mon
);
768 WARN("CreateURLMoniker failed: %08x\n", hres
);
772 prepare_for_binding(This
, mon
, FALSE
);
773 hres
= set_moniker(This
, mon
, NULL
, NULL
, TRUE
);
774 IMoniker_Release(mon
);
778 return channelbsc_load_stream(This
->window
->bscallback
, pStm
);
781 static HRESULT WINAPI
PersistStreamInit_Save(IPersistStreamInit
*iface
, LPSTREAM pStm
,
784 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
789 TRACE("(%p)->(%p %x)\n", This
, pStm
, fClearDirty
);
791 hres
= get_doc_string(This
->doc_node
, &str
);
795 hres
= IStream_Write(pStm
, str
, strlen(str
), &written
);
797 FIXME("Write failed: %08x\n", hres
);
802 set_dirty(This
, VARIANT_FALSE
);
807 static HRESULT WINAPI
PersistStreamInit_GetSizeMax(IPersistStreamInit
*iface
,
808 ULARGE_INTEGER
*pcbSize
)
810 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
811 FIXME("(%p)->(%p)\n", This
, pcbSize
);
815 static HRESULT WINAPI
PersistStreamInit_InitNew(IPersistStreamInit
*iface
)
817 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
821 static const WCHAR about_blankW
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
823 TRACE("(%p)\n", This
);
825 hres
= CreateURLMoniker(NULL
, about_blankW
, &mon
);
827 WARN("CreateURLMoniker failed: %08x\n", hres
);
831 prepare_for_binding(This
, mon
, FALSE
);
832 hres
= set_moniker(This
, mon
, NULL
, NULL
, FALSE
);
833 IMoniker_Release(mon
);
837 return channelbsc_load_stream(This
->window
->bscallback
, NULL
);
840 static const IPersistStreamInitVtbl PersistStreamInitVtbl
= {
841 PersistStreamInit_QueryInterface
,
842 PersistStreamInit_AddRef
,
843 PersistStreamInit_Release
,
844 PersistStreamInit_GetClassID
,
845 PersistStreamInit_IsDirty
,
846 PersistStreamInit_Load
,
847 PersistStreamInit_Save
,
848 PersistStreamInit_GetSizeMax
,
849 PersistStreamInit_InitNew
852 /**********************************************************
853 * IPersistHistory implementation
856 static inline HTMLDocument
*impl_from_IPersistHistory(IPersistHistory
*iface
)
858 return CONTAINING_RECORD(iface
, HTMLDocument
, IPersistHistory_iface
);
861 static HRESULT WINAPI
PersistHistory_QueryInterface(IPersistHistory
*iface
, REFIID riid
, void **ppv
)
863 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
864 return htmldoc_query_interface(This
, riid
, ppv
);
867 static ULONG WINAPI
PersistHistory_AddRef(IPersistHistory
*iface
)
869 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
870 return htmldoc_addref(This
);
873 static ULONG WINAPI
PersistHistory_Release(IPersistHistory
*iface
)
875 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
876 return htmldoc_release(This
);
879 static HRESULT WINAPI
PersistHistory_GetClassID(IPersistHistory
*iface
, CLSID
*pClassID
)
881 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
882 return IPersist_GetClassID(&This
->IPersistFile_iface
, pClassID
);
885 static HRESULT WINAPI
PersistHistory_LoadHistory(IPersistHistory
*iface
, IStream
*pStream
, IBindCtx
*pbc
)
887 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
888 FIXME("(%p)->(%p %p)\n", This
, pStream
, pbc
);
892 static HRESULT WINAPI
PersistHistory_SaveHistory(IPersistHistory
*iface
, IStream
*pStream
)
894 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
895 FIXME("(%p)->(%p)\n", This
, pStream
);
899 static HRESULT WINAPI
PersistHistory_SetPositionCookie(IPersistHistory
*iface
, DWORD dwPositioncookie
)
901 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
902 FIXME("(%p)->(%x)\n", This
, dwPositioncookie
);
906 static HRESULT WINAPI
PersistHistory_GetPositionCookie(IPersistHistory
*iface
, DWORD
*pdwPositioncookie
)
908 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
909 FIXME("(%p)->(%p)\n", This
, pdwPositioncookie
);
913 static const IPersistHistoryVtbl PersistHistoryVtbl
= {
914 PersistHistory_QueryInterface
,
915 PersistHistory_AddRef
,
916 PersistHistory_Release
,
917 PersistHistory_GetClassID
,
918 PersistHistory_LoadHistory
,
919 PersistHistory_SaveHistory
,
920 PersistHistory_SetPositionCookie
,
921 PersistHistory_GetPositionCookie
924 void HTMLDocument_Persist_Init(HTMLDocument
*This
)
926 This
->IPersistMoniker_iface
.lpVtbl
= &PersistMonikerVtbl
;
927 This
->IPersistFile_iface
.lpVtbl
= &PersistFileVtbl
;
928 This
->IMonikerProp_iface
.lpVtbl
= &MonikerPropVtbl
;
929 This
->IPersistStreamInit_iface
.lpVtbl
= &PersistStreamInitVtbl
;
930 This
->IPersistHistory_iface
.lpVtbl
= &PersistHistoryVtbl
;