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
);
47 /* Undocumented notification, see tests */
48 #define CMDID_EXPLORER_UPDATEHISTORY 38
55 } download_proc_task_t
;
57 static BOOL
use_gecko_script(HTMLWindow
*window
)
62 hres
= IInternetSecurityManager_MapUrlToZone(window
->secmgr
, window
->url
, &zone
, 0);
64 WARN("Could not map %s to zone: %08x\n", debugstr_w(window
->url
), hres
);
68 TRACE("zone %d\n", zone
);
69 return zone
== URLZONE_UNTRUSTED
;
72 static void notify_travellog_update(HTMLDocumentObj
*doc
)
74 IOleCommandTarget
*cmdtrg
;
77 if(!doc
->is_webbrowser
)
80 /* Don't notify if we were in about: page */
81 if(doc
->basedoc
.window
->uri
) {
84 hres
= IUri_GetScheme(doc
->basedoc
.window
->uri
, &scheme
);
85 if(SUCCEEDED(hres
) && scheme
== URL_SCHEME_ABOUT
)
89 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
96 IOleCommandTarget_Exec(cmdtrg
, &CGID_Explorer
, CMDID_EXPLORER_UPDATEHISTORY
, 0, &vin
, NULL
);
97 IOleCommandTarget_Release(cmdtrg
);
101 void set_current_uri(HTMLWindow
*window
, IUri
*uri
)
104 IUri_Release(window
->uri
);
108 SysFreeString(window
->url
);
117 IUri_GetDisplayUri(uri
, &window
->url
);
120 void set_current_mon(HTMLWindow
*This
, IMoniker
*mon
)
122 IUriContainer
*uri_container
;
128 notify_travellog_update(This
->doc_obj
);
129 IMoniker_Release(This
->mon
);
136 IMoniker_AddRef(mon
);
139 hres
= IMoniker_QueryInterface(mon
, &IID_IUriContainer
, (void**)&uri_container
);
140 if(SUCCEEDED(hres
)) {
141 hres
= IUriContainer_GetIUri(uri_container
, &uri
);
142 IUriContainer_Release(uri_container
);
144 WARN("GetIUri failed: %08x\n", hres
);
152 hres
= IMoniker_GetDisplayName(mon
, NULL
, NULL
, &url
);
153 if(SUCCEEDED(hres
)) {
154 hres
= CreateUri(url
, 0, 0, &uri
);
156 WARN("CrateUri failed: %08x\n", hres
);
157 set_current_uri(This
, NULL
);
158 This
->url
= SysAllocString(url
);
164 WARN("GetDisplayName failed: %08x\n", hres
);
168 set_current_uri(This
, uri
);
171 set_script_mode(This
, use_gecko_script(This
) ? SCRIPTMODE_GECKO
: SCRIPTMODE_ACTIVESCRIPT
);
174 HRESULT
create_relative_uri(HTMLWindow
*window
, const WCHAR
*rel_uri
, IUri
**uri
)
177 ? CoInternetCombineUrlEx(window
->uri
, rel_uri
, URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
, uri
, 0)
178 : CreateUri(rel_uri
, 0, 0, uri
);
181 void set_download_state(HTMLDocumentObj
*doc
, int state
)
184 IOleCommandTarget
*olecmd
;
187 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
188 if(SUCCEEDED(hres
)) {
194 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETDOWNLOADSTATE
,
195 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
196 IOleCommandTarget_Release(olecmd
);
200 doc
->download_state
= state
;
203 static void set_progress_proc(task_t
*_task
)
205 docobj_task_t
*task
= (docobj_task_t
*)_task
;
206 IOleCommandTarget
*olecmd
= NULL
;
207 HTMLDocumentObj
*doc
= task
->doc
;
210 TRACE("(%p)\n", doc
);
213 IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
216 VARIANT progress_max
, progress
;
218 V_VT(&progress_max
) = VT_I4
;
219 V_I4(&progress_max
) = 0; /* FIXME */
220 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETPROGRESSMAX
, OLECMDEXECOPT_DONTPROMPTUSER
,
221 &progress_max
, NULL
);
223 V_VT(&progress
) = VT_I4
;
224 V_I4(&progress
) = 0; /* FIXME */
225 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETPROGRESSPOS
, OLECMDEXECOPT_DONTPROMPTUSER
,
227 IOleCommandTarget_Release(olecmd
);
230 if(doc
->usermode
== EDITMODE
&& doc
->hostui
) {
231 DOCHOSTUIINFO hostinfo
;
233 memset(&hostinfo
, 0, sizeof(DOCHOSTUIINFO
));
234 hostinfo
.cbSize
= sizeof(DOCHOSTUIINFO
);
235 hres
= IDocHostUIHandler_GetHostInfo(doc
->hostui
, &hostinfo
);
237 /* FIXME: use hostinfo */
238 TRACE("hostinfo = {%u %08x %08x %s %s}\n",
239 hostinfo
.cbSize
, hostinfo
.dwFlags
, hostinfo
.dwDoubleClick
,
240 debugstr_w(hostinfo
.pchHostCss
), debugstr_w(hostinfo
.pchHostNS
));
244 static void set_downloading_proc(task_t
*_task
)
246 download_proc_task_t
*task
= (download_proc_task_t
*)_task
;
247 HTMLDocumentObj
*doc
= task
->doc
;
250 TRACE("(%p)\n", doc
);
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 static void set_downloading_task_destr(task_t
*_task
)
276 download_proc_task_t
*task
= (download_proc_task_t
*)_task
;
278 CoTaskMemFree(task
->url
);
282 void prepare_for_binding(HTMLDocument
*This
, IMoniker
*mon
, BOOL navigated_binding
)
286 if(This
->doc_obj
->client
) {
287 VARIANT silent
, offline
;
289 hres
= get_client_disp_property(This
->doc_obj
->client
, DISPID_AMBIENT_SILENT
, &silent
);
290 if(SUCCEEDED(hres
)) {
291 if(V_VT(&silent
) != VT_BOOL
)
292 WARN("silent = %s\n", debugstr_variant(&silent
));
293 else if(V_BOOL(&silent
))
294 FIXME("silent == true\n");
297 hres
= get_client_disp_property(This
->doc_obj
->client
,
298 DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &offline
);
299 if(SUCCEEDED(hres
)) {
300 if(V_VT(&offline
) != VT_BOOL
)
301 WARN("offline = %s\n", debugstr_variant(&offline
));
302 else if(V_BOOL(&offline
))
303 FIXME("offline == true\n");
307 if(This
->window
->mon
) {
308 update_doc(This
, UPDATE_TITLE
|UPDATE_UI
);
310 update_doc(This
, UPDATE_TITLE
);
311 set_current_mon(This
->window
, mon
);
314 if(This
->doc_obj
->client
) {
315 IOleCommandTarget
*cmdtrg
= NULL
;
317 hres
= IOleClientSite_QueryInterface(This
->doc_obj
->client
, &IID_IOleCommandTarget
,
319 if(SUCCEEDED(hres
)) {
322 if(!navigated_binding
) {
325 IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 37, 0, &var
, NULL
);
327 V_VT(&var
) = VT_UNKNOWN
;
328 V_UNKNOWN(&var
) = (IUnknown
*)&This
->window
->IHTMLWindow2_iface
;
329 V_VT(&out
) = VT_EMPTY
;
330 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 63, 0, &var
, &out
);
335 IOleCommandTarget_Release(cmdtrg
);
340 HRESULT
set_moniker(HTMLDocument
*This
, IMoniker
*mon
, IBindCtx
*pibc
, nsChannelBSC
*async_bsc
, BOOL set_download
)
342 download_proc_task_t
*download_task
;
343 nsChannelBSC
*bscallback
;
348 hres
= IMoniker_GetDisplayName(mon
, pibc
, NULL
, &url
);
350 WARN("GetDiaplayName failed: %08x\n", hres
);
354 TRACE("got url: %s\n", debugstr_w(url
));
356 set_ready_state(This
->window
, READYSTATE_LOADING
);
358 hres
= create_doc_uri(This
->window
, url
, &nsuri
);
359 if(SUCCEEDED(hres
)) {
361 bscallback
= async_bsc
;
363 hres
= create_channelbsc(mon
, NULL
, NULL
, 0, &bscallback
);
366 if(SUCCEEDED(hres
)) {
367 remove_target_tasks(This
->task_magic
);
368 abort_document_bindings(This
->doc_node
);
370 hres
= load_nsuri(This
->window
, nsuri
, bscallback
, 0/*LOAD_INITIAL_DOCUMENT_URI*/);
371 nsISupports_Release((nsISupports
*)nsuri
); /* FIXME */
373 set_window_bscallback(This
->window
, bscallback
);
374 if(bscallback
!= async_bsc
)
375 IUnknown_Release((IUnknown
*)bscallback
);
383 HTMLDocument_LockContainer(This
->doc_obj
, TRUE
);
385 if(This
->doc_obj
->frame
) {
388 task
= heap_alloc(sizeof(docobj_task_t
));
389 task
->doc
= This
->doc_obj
;
390 push_task(&task
->header
, set_progress_proc
, NULL
, This
->doc_obj
->basedoc
.task_magic
);
393 download_task
= heap_alloc(sizeof(download_proc_task_t
));
394 download_task
->doc
= This
->doc_obj
;
395 download_task
->set_download
= set_download
;
396 download_task
->url
= url
;
397 push_task(&download_task
->header
, set_downloading_proc
, set_downloading_task_destr
, This
->doc_obj
->basedoc
.task_magic
);
402 void set_ready_state(HTMLWindow
*window
, READYSTATE readystate
)
404 window
->readystate
= readystate
;
406 if(window
->doc_obj
&& window
->doc_obj
->basedoc
.window
== window
)
407 call_property_onchanged(&window
->doc_obj
->basedoc
.cp_propnotif
, DISPID_READYSTATE
);
409 fire_event(window
->doc
, EVENTID_READYSTATECHANGE
, FALSE
, window
->doc
->node
.nsnode
, NULL
);
411 if(window
->frame_element
)
412 fire_event(window
->frame_element
->element
.node
.doc
, EVENTID_READYSTATECHANGE
,
413 TRUE
, window
->frame_element
->element
.node
.nsnode
, NULL
);
416 static HRESULT
get_doc_string(HTMLDocumentNode
*This
, char **str
)
425 WARN("NULL nsdoc\n");
429 nsres
= nsIDOMHTMLDocument_QueryInterface(This
->nsdoc
, &IID_nsIDOMNode
, (void**)&nsnode
);
430 if(NS_FAILED(nsres
)) {
431 ERR("Could not get nsIDOMNode failed: %08x\n", nsres
);
435 nsAString_Init(&nsstr
, NULL
);
436 hres
= nsnode_to_nsstring(nsnode
, &nsstr
);
437 nsIDOMNode_Release(nsnode
);
439 nsAString_Finish(&nsstr
);
443 nsAString_GetData(&nsstr
, &strw
);
444 TRACE("%s\n", debugstr_w(strw
));
446 *str
= heap_strdupWtoA(strw
);
448 nsAString_Finish(&nsstr
);
451 return E_OUTOFMEMORY
;
456 /**********************************************************
457 * IPersistMoniker implementation
460 static inline HTMLDocument
*impl_from_IPersistMoniker(IPersistMoniker
*iface
)
462 return CONTAINING_RECORD(iface
, HTMLDocument
, IPersistMoniker_iface
);
465 static HRESULT WINAPI
PersistMoniker_QueryInterface(IPersistMoniker
*iface
, REFIID riid
, void **ppv
)
467 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
468 return htmldoc_query_interface(This
, riid
, ppv
);
471 static ULONG WINAPI
PersistMoniker_AddRef(IPersistMoniker
*iface
)
473 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
474 return htmldoc_addref(This
);
477 static ULONG WINAPI
PersistMoniker_Release(IPersistMoniker
*iface
)
479 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
480 return htmldoc_release(This
);
483 static HRESULT WINAPI
PersistMoniker_GetClassID(IPersistMoniker
*iface
, CLSID
*pClassID
)
485 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
486 return IPersist_GetClassID(&This
->IPersistFile_iface
, pClassID
);
489 static HRESULT WINAPI
PersistMoniker_IsDirty(IPersistMoniker
*iface
)
491 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
493 TRACE("(%p)\n", This
);
495 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
498 static HRESULT WINAPI
PersistMoniker_Load(IPersistMoniker
*iface
, BOOL fFullyAvailable
,
499 IMoniker
*pimkName
, LPBC pibc
, DWORD grfMode
)
501 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
504 TRACE("(%p)->(%x %p %p %08x)\n", This
, fFullyAvailable
, pimkName
, pibc
, grfMode
);
507 IUnknown
*unk
= NULL
;
511 * "__PrecreatedObject"
512 * "BIND_CONTEXT_PARAM"
513 * "__HTMLLOADOPTIONS"
516 * "_ITransData_Object_"
520 IBindCtx_GetObjectParam(pibc
, (LPOLESTR
)SZ_HTML_CLIENTSITE_OBJECTPARAM
, &unk
);
522 IOleClientSite
*client
= NULL
;
524 hres
= IUnknown_QueryInterface(unk
, &IID_IOleClientSite
, (void**)&client
);
525 if(SUCCEEDED(hres
)) {
526 TRACE("Got client site %p\n", client
);
527 IOleObject_SetClientSite(&This
->IOleObject_iface
, client
);
528 IOleClientSite_Release(client
);
531 IUnknown_Release(unk
);
535 prepare_for_binding(This
, pimkName
, FALSE
);
536 call_docview_84(This
->doc_obj
);
537 hres
= set_moniker(This
, pimkName
, pibc
, NULL
, TRUE
);
541 return start_binding(This
->window
, NULL
, (BSCallback
*)This
->window
->bscallback
, pibc
);
544 static HRESULT WINAPI
PersistMoniker_Save(IPersistMoniker
*iface
, IMoniker
*pimkName
,
545 LPBC pbc
, BOOL fRemember
)
547 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
548 FIXME("(%p)->(%p %p %x)\n", This
, pimkName
, pbc
, fRemember
);
552 static HRESULT WINAPI
PersistMoniker_SaveCompleted(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pibc
)
554 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
555 FIXME("(%p)->(%p %p)\n", This
, pimkName
, pibc
);
559 static HRESULT WINAPI
PersistMoniker_GetCurMoniker(IPersistMoniker
*iface
, IMoniker
**ppimkName
)
561 HTMLDocument
*This
= impl_from_IPersistMoniker(iface
);
563 TRACE("(%p)->(%p)\n", This
, ppimkName
);
565 if(!This
->window
|| !This
->window
->mon
)
568 IMoniker_AddRef(This
->window
->mon
);
569 *ppimkName
= This
->window
->mon
;
573 static const IPersistMonikerVtbl PersistMonikerVtbl
= {
574 PersistMoniker_QueryInterface
,
575 PersistMoniker_AddRef
,
576 PersistMoniker_Release
,
577 PersistMoniker_GetClassID
,
578 PersistMoniker_IsDirty
,
581 PersistMoniker_SaveCompleted
,
582 PersistMoniker_GetCurMoniker
585 /**********************************************************
586 * IMonikerProp implementation
589 static inline HTMLDocument
*impl_from_IMonikerProp(IMonikerProp
*iface
)
591 return CONTAINING_RECORD(iface
, HTMLDocument
, IMonikerProp_iface
);
594 static HRESULT WINAPI
MonikerProp_QueryInterface(IMonikerProp
*iface
, REFIID riid
, void **ppv
)
596 HTMLDocument
*This
= impl_from_IMonikerProp(iface
);
597 return htmldoc_query_interface(This
, riid
, ppv
);
600 static ULONG WINAPI
MonikerProp_AddRef(IMonikerProp
*iface
)
602 HTMLDocument
*This
= impl_from_IMonikerProp(iface
);
603 return htmldoc_addref(This
);
606 static ULONG WINAPI
MonikerProp_Release(IMonikerProp
*iface
)
608 HTMLDocument
*This
= impl_from_IMonikerProp(iface
);
609 return htmldoc_release(This
);
612 static HRESULT WINAPI
MonikerProp_PutProperty(IMonikerProp
*iface
, MONIKERPROPERTY mkp
, LPCWSTR val
)
614 HTMLDocument
*This
= impl_from_IMonikerProp(iface
);
616 TRACE("(%p)->(%d %s)\n", This
, mkp
, debugstr_w(val
));
620 heap_free(This
->doc_obj
->mime
);
621 This
->doc_obj
->mime
= heap_strdupW(val
);
628 FIXME("mkp %d\n", mkp
);
635 static const IMonikerPropVtbl MonikerPropVtbl
= {
636 MonikerProp_QueryInterface
,
639 MonikerProp_PutProperty
642 /**********************************************************
643 * IPersistFile implementation
646 static inline HTMLDocument
*impl_from_IPersistFile(IPersistFile
*iface
)
648 return CONTAINING_RECORD(iface
, HTMLDocument
, IPersistFile_iface
);
651 static HRESULT WINAPI
PersistFile_QueryInterface(IPersistFile
*iface
, REFIID riid
, void **ppv
)
653 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
654 return htmldoc_query_interface(This
, riid
, ppv
);
657 static ULONG WINAPI
PersistFile_AddRef(IPersistFile
*iface
)
659 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
660 return htmldoc_addref(This
);
663 static ULONG WINAPI
PersistFile_Release(IPersistFile
*iface
)
665 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
666 return htmldoc_release(This
);
669 static HRESULT WINAPI
PersistFile_GetClassID(IPersistFile
*iface
, CLSID
*pClassID
)
671 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
673 TRACE("(%p)->(%p)\n", This
, pClassID
);
678 *pClassID
= CLSID_HTMLDocument
;
682 static HRESULT WINAPI
PersistFile_IsDirty(IPersistFile
*iface
)
684 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
686 TRACE("(%p)\n", This
);
688 return IPersistStreamInit_IsDirty(&This
->IPersistStreamInit_iface
);
691 static HRESULT WINAPI
PersistFile_Load(IPersistFile
*iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
693 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
694 FIXME("(%p)->(%s %08x)\n", This
, debugstr_w(pszFileName
), dwMode
);
698 static HRESULT WINAPI
PersistFile_Save(IPersistFile
*iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
700 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
706 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(pszFileName
), fRemember
);
708 file
= CreateFileW(pszFileName
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
709 FILE_ATTRIBUTE_NORMAL
, NULL
);
710 if(file
== INVALID_HANDLE_VALUE
) {
711 WARN("Could not create file: %u\n", GetLastError());
715 hres
= get_doc_string(This
->doc_node
, &str
);
717 WriteFile(file
, str
, strlen(str
), &written
, NULL
);
723 static HRESULT WINAPI
PersistFile_SaveCompleted(IPersistFile
*iface
, LPCOLESTR pszFileName
)
725 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
726 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFileName
));
730 static HRESULT WINAPI
PersistFile_GetCurFile(IPersistFile
*iface
, LPOLESTR
*pszFileName
)
732 HTMLDocument
*This
= impl_from_IPersistFile(iface
);
733 FIXME("(%p)->(%p)\n", This
, pszFileName
);
737 static const IPersistFileVtbl PersistFileVtbl
= {
738 PersistFile_QueryInterface
,
741 PersistFile_GetClassID
,
745 PersistFile_SaveCompleted
,
746 PersistFile_GetCurFile
749 static inline HTMLDocument
*impl_from_IPersistStreamInit(IPersistStreamInit
*iface
)
751 return CONTAINING_RECORD(iface
, HTMLDocument
, IPersistStreamInit_iface
);
754 static HRESULT WINAPI
PersistStreamInit_QueryInterface(IPersistStreamInit
*iface
,
755 REFIID riid
, void **ppv
)
757 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
758 return htmldoc_query_interface(This
, riid
, ppv
);
761 static ULONG WINAPI
PersistStreamInit_AddRef(IPersistStreamInit
*iface
)
763 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
764 return htmldoc_addref(This
);
767 static ULONG WINAPI
PersistStreamInit_Release(IPersistStreamInit
*iface
)
769 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
770 return htmldoc_release(This
);
773 static HRESULT WINAPI
PersistStreamInit_GetClassID(IPersistStreamInit
*iface
, CLSID
*pClassID
)
775 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
776 return IPersist_GetClassID(&This
->IPersistFile_iface
, pClassID
);
779 static HRESULT WINAPI
PersistStreamInit_IsDirty(IPersistStreamInit
*iface
)
781 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
783 TRACE("(%p)\n", This
);
785 if(This
->doc_obj
->usermode
== EDITMODE
)
786 return editor_is_dirty(This
);
791 static HRESULT WINAPI
PersistStreamInit_Load(IPersistStreamInit
*iface
, LPSTREAM pStm
)
793 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
797 static const WCHAR about_blankW
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
799 TRACE("(%p)->(%p)\n", This
, pStm
);
801 hres
= CreateURLMoniker(NULL
, about_blankW
, &mon
);
803 WARN("CreateURLMoniker failed: %08x\n", hres
);
807 prepare_for_binding(This
, mon
, FALSE
);
808 hres
= set_moniker(This
, mon
, NULL
, NULL
, TRUE
);
809 IMoniker_Release(mon
);
813 return channelbsc_load_stream(This
->window
->bscallback
, pStm
);
816 static HRESULT WINAPI
PersistStreamInit_Save(IPersistStreamInit
*iface
, LPSTREAM pStm
,
819 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
824 TRACE("(%p)->(%p %x)\n", This
, pStm
, fClearDirty
);
826 hres
= get_doc_string(This
->doc_node
, &str
);
830 hres
= IStream_Write(pStm
, str
, strlen(str
), &written
);
832 FIXME("Write failed: %08x\n", hres
);
837 set_dirty(This
, VARIANT_FALSE
);
842 static HRESULT WINAPI
PersistStreamInit_GetSizeMax(IPersistStreamInit
*iface
,
843 ULARGE_INTEGER
*pcbSize
)
845 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
846 FIXME("(%p)->(%p)\n", This
, pcbSize
);
850 static HRESULT WINAPI
PersistStreamInit_InitNew(IPersistStreamInit
*iface
)
852 HTMLDocument
*This
= impl_from_IPersistStreamInit(iface
);
856 static const WCHAR about_blankW
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
858 TRACE("(%p)\n", This
);
860 hres
= CreateURLMoniker(NULL
, about_blankW
, &mon
);
862 WARN("CreateURLMoniker failed: %08x\n", hres
);
866 prepare_for_binding(This
, mon
, FALSE
);
867 hres
= set_moniker(This
, mon
, NULL
, NULL
, FALSE
);
868 IMoniker_Release(mon
);
872 return channelbsc_load_stream(This
->window
->bscallback
, NULL
);
875 static const IPersistStreamInitVtbl PersistStreamInitVtbl
= {
876 PersistStreamInit_QueryInterface
,
877 PersistStreamInit_AddRef
,
878 PersistStreamInit_Release
,
879 PersistStreamInit_GetClassID
,
880 PersistStreamInit_IsDirty
,
881 PersistStreamInit_Load
,
882 PersistStreamInit_Save
,
883 PersistStreamInit_GetSizeMax
,
884 PersistStreamInit_InitNew
887 /**********************************************************
888 * IPersistHistory implementation
891 static inline HTMLDocument
*impl_from_IPersistHistory(IPersistHistory
*iface
)
893 return CONTAINING_RECORD(iface
, HTMLDocument
, IPersistHistory_iface
);
896 static HRESULT WINAPI
PersistHistory_QueryInterface(IPersistHistory
*iface
, REFIID riid
, void **ppv
)
898 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
899 return htmldoc_query_interface(This
, riid
, ppv
);
902 static ULONG WINAPI
PersistHistory_AddRef(IPersistHistory
*iface
)
904 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
905 return htmldoc_addref(This
);
908 static ULONG WINAPI
PersistHistory_Release(IPersistHistory
*iface
)
910 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
911 return htmldoc_release(This
);
914 static HRESULT WINAPI
PersistHistory_GetClassID(IPersistHistory
*iface
, CLSID
*pClassID
)
916 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
917 return IPersist_GetClassID(&This
->IPersistFile_iface
, pClassID
);
920 static HRESULT WINAPI
PersistHistory_LoadHistory(IPersistHistory
*iface
, IStream
*pStream
, IBindCtx
*pbc
)
922 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
923 FIXME("(%p)->(%p %p)\n", This
, pStream
, pbc
);
927 static HRESULT WINAPI
PersistHistory_SaveHistory(IPersistHistory
*iface
, IStream
*pStream
)
929 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
930 FIXME("(%p)->(%p)\n", This
, pStream
);
934 static HRESULT WINAPI
PersistHistory_SetPositionCookie(IPersistHistory
*iface
, DWORD dwPositioncookie
)
936 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
937 FIXME("(%p)->(%x)\n", This
, dwPositioncookie
);
941 static HRESULT WINAPI
PersistHistory_GetPositionCookie(IPersistHistory
*iface
, DWORD
*pdwPositioncookie
)
943 HTMLDocument
*This
= impl_from_IPersistHistory(iface
);
944 FIXME("(%p)->(%p)\n", This
, pdwPositioncookie
);
948 static const IPersistHistoryVtbl PersistHistoryVtbl
= {
949 PersistHistory_QueryInterface
,
950 PersistHistory_AddRef
,
951 PersistHistory_Release
,
952 PersistHistory_GetClassID
,
953 PersistHistory_LoadHistory
,
954 PersistHistory_SaveHistory
,
955 PersistHistory_SetPositionCookie
,
956 PersistHistory_GetPositionCookie
959 void HTMLDocument_Persist_Init(HTMLDocument
*This
)
961 This
->IPersistMoniker_iface
.lpVtbl
= &PersistMonikerVtbl
;
962 This
->IPersistFile_iface
.lpVtbl
= &PersistFileVtbl
;
963 This
->IMonikerProp_iface
.lpVtbl
= &MonikerPropVtbl
;
964 This
->IPersistStreamInit_iface
.lpVtbl
= &PersistStreamInitVtbl
;
965 This
->IPersistHistory_iface
.lpVtbl
= &PersistHistoryVtbl
;