push d0760662e4c9af92a52cfc83b053a1228de45087
[wine/hacks.git] / dlls / mshtml / persist.c
blobc8a0c5731b349238d710059534072c53bf262669
1 /*
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
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winuser.h"
31 #include "ole2.h"
32 #include "shlguid.h"
33 #include "idispids.h"
35 #include "wine/debug.h"
36 #include "wine/unicode.h"
38 #include "mshtml_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
42 #define USER_AGENT "User-Agent:"
43 #define CONTENT_TYPE "Content-Type:"
45 static int fix_headers(char *buf, DWORD post_len)
47 char *ptr = buf, *ptr2;
49 while(*ptr && (ptr[0] != '\r' || ptr[1] != '\n')) {
50 for(ptr2=ptr+1; *ptr2 && (ptr2[0] != '\r' || ptr2[1] != '\n'); ptr2++);
52 if(*ptr2)
53 ptr2 += 2;
55 if(!strncasecmp(ptr, USER_AGENT, sizeof(USER_AGENT)-1)) {
56 FIXME("Ignoring User-Agent header\n");
57 memmove(ptr, ptr2, strlen(ptr2)+1);
58 }else if(!post_len && !strncasecmp(ptr, CONTENT_TYPE, sizeof(CONTENT_TYPE)-1)) {
59 TRACE("Ignoring Content-Type header\n");
60 memmove(ptr, ptr2, strlen(ptr2)+1);
61 }else {
62 ptr = ptr2;
66 *ptr = 0;
67 return ptr-buf;
70 static nsIInputStream *get_post_data_stream(IBindCtx *bctx)
72 nsIInputStream *ret = NULL;
73 IUnknown *unk;
74 IBindStatusCallback *callback;
75 IServiceProvider *service_provider;
76 BINDINFO bindinfo;
77 DWORD bindf = 0;
78 DWORD post_len = 0, headers_len = 0;
79 LPWSTR headers = NULL;
80 WCHAR emptystr[] = {0};
81 char *data;
82 HRESULT hres;
84 static WCHAR _BSCB_Holder_[] =
85 {'_','B','S','C','B','_','H','o','l','d','e','r','_',0};
88 /* FIXME: This should be done in URLMoniker */
89 if(!bctx)
90 return NULL;
92 hres = IBindCtx_GetObjectParam(bctx, _BSCB_Holder_, &unk);
93 if(FAILED(hres))
94 return NULL;
96 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&callback);
97 if(FAILED(hres)) {
98 IUnknown_Release(unk);
99 return NULL;
102 hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&service_provider);
103 IUnknown_Release(unk);
104 if(SUCCEEDED(hres)) {
105 IHttpNegotiate *http_negotiate;
107 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
108 (void**)&http_negotiate);
109 if(SUCCEEDED(hres)) {
110 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, emptystr,
111 emptystr, 0, &headers);
112 IHttpNegotiate_Release(http_negotiate);
114 if(SUCCEEDED(hres) && headers)
115 headers_len = WideCharToMultiByte(CP_ACP, 0, headers, -1, NULL, 0, NULL, NULL);
118 IServiceProvider_Release(service_provider);
121 memset(&bindinfo, 0, sizeof(bindinfo));
122 bindinfo.cbSize = sizeof(bindinfo);
124 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
126 if(SUCCEEDED(hres) && bindinfo.dwBindVerb == BINDVERB_POST)
127 post_len = bindinfo.cbstgmedData;
129 if(headers_len || post_len) {
130 int len = 0;
132 static const char content_length[] = "Content-Length: %u\r\n\r\n";
134 data = heap_alloc(headers_len+post_len+sizeof(content_length)+10);
136 if(headers_len) {
137 WideCharToMultiByte(CP_ACP, 0, headers, -1, data, headers_len, NULL, NULL);
138 len = fix_headers(data, post_len);
139 if(len >= 2 && (data[len-1] != '\n' || data[len-2] != '\r')) {
140 data[len++] = '\r';
141 data[len++] = '\n';
145 if(post_len) {
146 sprintf(data+len, content_length, post_len);
147 len += strlen(data+len);
149 memcpy(data+len, bindinfo.stgmedData.u.hGlobal, post_len);
152 TRACE("data = %s\n", debugstr_an(data, len+post_len));
154 if(len)
155 ret = create_nsstream(data, len+post_len);
158 CoTaskMemFree(headers);
159 ReleaseBindInfo(&bindinfo);
160 IBindStatusCallback_Release(callback);
162 return ret;
165 static BOOL use_gecko_script(LPCWSTR url)
167 static const WCHAR fileW[] = {'f','i','l','e',':'};
168 return strncmpiW(fileW, url, sizeof(fileW)/sizeof(WCHAR));
171 void set_current_mon(HTMLDocument *This, IMoniker *mon)
173 HRESULT hres;
175 if(This->mon) {
176 IMoniker_Release(This->mon);
177 This->mon = NULL;
180 if(This->url) {
181 CoTaskMemFree(This->url);
182 This->url = NULL;
185 if(!mon)
186 return;
188 IMoniker_AddRef(mon);
189 This->mon = mon;
191 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &This->url);
192 if(FAILED(hres))
193 WARN("GetDisplayName failed: %08x\n", hres);
195 set_script_mode(This, use_gecko_script(This->url) ? SCRIPTMODE_GECKO : SCRIPTMODE_ACTIVESCRIPT);
198 static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BOOL *bind_complete)
200 nsChannelBSC *bscallback;
201 LPOLESTR url = NULL;
202 task_t *task;
203 HRESULT hres;
204 nsresult nsres;
206 if(pibc) {
207 IUnknown *unk = NULL;
209 /* FIXME:
210 * Use params:
211 * "__PrecreatedObject"
212 * "BIND_CONTEXT_PARAM"
213 * "__HTMLLOADOPTIONS"
214 * "__DWNBINDINFO"
215 * "URL Context"
216 * "CBinding Context"
217 * "_ITransData_Object_"
218 * "_EnumFORMATETC_"
221 IBindCtx_GetObjectParam(pibc, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, &unk);
222 if(unk) {
223 IOleClientSite *client = NULL;
225 hres = IUnknown_QueryInterface(unk, &IID_IOleClientSite, (void**)&client);
226 if(SUCCEEDED(hres)) {
227 TRACE("Got client site %p\n", client);
228 IOleObject_SetClientSite(OLEOBJ(This), client);
229 IOleClientSite_Release(client);
232 IUnknown_Release(unk);
236 This->readystate = READYSTATE_LOADING;
237 call_property_onchanged(&This->cp_propnotif, DISPID_READYSTATE);
238 update_doc(This, UPDATE_TITLE);
240 HTMLDocument_LockContainer(This, TRUE);
242 hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url);
243 if(FAILED(hres)) {
244 WARN("GetDiaplayName failed: %08x\n", hres);
245 return hres;
248 TRACE("got url: %s\n", debugstr_w(url));
250 set_current_mon(This, mon);
252 if(This->client) {
253 VARIANT silent, offline;
254 IOleCommandTarget *cmdtrg = NULL;
256 hres = get_client_disp_property(This->client, DISPID_AMBIENT_SILENT, &silent);
257 if(SUCCEEDED(hres)) {
258 if(V_VT(&silent) != VT_BOOL)
259 WARN("V_VT(silent) = %d\n", V_VT(&silent));
260 else if(V_BOOL(&silent))
261 FIXME("silent == true\n");
264 hres = get_client_disp_property(This->client,
265 DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline);
266 if(SUCCEEDED(hres)) {
267 if(V_VT(&silent) != VT_BOOL)
268 WARN("V_VT(offline) = %d\n", V_VT(&silent));
269 else if(V_BOOL(&silent))
270 FIXME("offline == true\n");
273 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget,
274 (void**)&cmdtrg);
275 if(SUCCEEDED(hres)) {
276 VARIANT var;
278 V_VT(&var) = VT_I4;
279 V_I4(&var) = 0;
280 IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL);
282 IOleCommandTarget_Release(cmdtrg);
286 bscallback = create_channelbsc(mon);
288 if(This->frame) {
289 task = heap_alloc(sizeof(task_t));
291 task->doc = This;
292 task->task_id = TASK_SETPROGRESS;
293 task->next = NULL;
295 push_task(task);
298 task = heap_alloc(sizeof(task_t));
300 task->doc = This;
301 task->task_id = TASK_SETDOWNLOADSTATE;
302 task->next = NULL;
304 push_task(task);
306 if(This->nscontainer) {
307 nsIInputStream *post_data_stream = get_post_data_stream(pibc);
309 This->nscontainer->bscallback = bscallback;
310 nsres = nsIWebNavigation_LoadURI(This->nscontainer->navigation, url,
311 LOAD_FLAGS_NONE, NULL, post_data_stream, NULL);
312 This->nscontainer->bscallback = NULL;
314 if(post_data_stream)
315 nsIInputStream_Release(post_data_stream);
317 if(NS_SUCCEEDED(nsres)) {
318 /* FIXME: don't return here (URL Moniker needs to be good enough) */
320 IUnknown_Release((IUnknown*)bscallback);
321 CoTaskMemFree(url);
323 if(bind_complete)
324 *bind_complete = TRUE;
325 return S_OK;
326 }else if(nsres != WINE_NS_LOAD_FROM_MONIKER) {
327 WARN("LoadURI failed: %08x\n", nsres);
331 set_document_bscallback(This, bscallback);
332 IUnknown_Release((IUnknown*)bscallback);
333 CoTaskMemFree(url);
335 if(bind_complete)
336 *bind_complete = FALSE;
337 return S_OK;
340 static HRESULT get_doc_string(HTMLDocument *This, char **str, DWORD *len)
342 nsIDOMNode *nsnode;
343 LPCWSTR strw;
344 nsAString nsstr;
345 nsresult nsres;
347 if(!This->nsdoc) {
348 WARN("NULL nsdoc\n");
349 return E_UNEXPECTED;
352 nsres = nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMNode, (void**)&nsnode);
353 if(NS_FAILED(nsres)) {
354 ERR("Could not get nsIDOMNode failed: %08x\n", nsres);
355 return E_FAIL;
358 nsAString_Init(&nsstr, NULL);
359 nsnode_to_nsstring(nsnode, &nsstr);
360 nsIDOMNode_Release(nsnode);
362 nsAString_GetData(&nsstr, &strw);
363 TRACE("%s\n", debugstr_w(strw));
365 *len = WideCharToMultiByte(CP_ACP, 0, strw, -1, NULL, 0, NULL, NULL);
366 *str = heap_alloc(*len);
367 WideCharToMultiByte(CP_ACP, 0, strw, -1, *str, *len, NULL, NULL);
369 nsAString_Finish(&nsstr);
371 return S_OK;
375 /**********************************************************
376 * IPersistMoniker implementation
379 #define PERSISTMON_THIS(iface) DEFINE_THIS(HTMLDocument, PersistMoniker, iface)
381 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid,
382 void **ppvObject)
384 HTMLDocument *This = PERSISTMON_THIS(iface);
385 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
388 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
390 HTMLDocument *This = PERSISTMON_THIS(iface);
391 return IHTMLDocument2_AddRef(HTMLDOC(This));
394 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
396 HTMLDocument *This = PERSISTMON_THIS(iface);
397 return IHTMLDocument2_Release(HTMLDOC(This));
400 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
402 HTMLDocument *This = PERSISTMON_THIS(iface);
403 return IPersist_GetClassID(PERSIST(This), pClassID);
406 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
408 HTMLDocument *This = PERSISTMON_THIS(iface);
410 TRACE("(%p)\n", This);
412 return IPersistStreamInit_IsDirty(PERSTRINIT(This));
415 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
416 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
418 HTMLDocument *This = PERSISTMON_THIS(iface);
419 BOOL bind_complete = FALSE;
420 HRESULT hres;
422 TRACE("(%p)->(%x %p %p %08x)\n", This, fFullyAvailable, pimkName, pibc, grfMode);
424 hres = set_moniker(This, pimkName, pibc, &bind_complete);
425 if(FAILED(hres))
426 return hres;
428 if(!bind_complete)
429 return start_binding(This, (BSCallback*)This->bscallback, pibc);
431 return S_OK;
434 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName,
435 LPBC pbc, BOOL fRemember)
437 HTMLDocument *This = PERSISTMON_THIS(iface);
438 FIXME("(%p)->(%p %p %x)\n", This, pimkName, pbc, fRemember);
439 return E_NOTIMPL;
442 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
444 HTMLDocument *This = PERSISTMON_THIS(iface);
445 FIXME("(%p)->(%p %p)\n", This, pimkName, pibc);
446 return E_NOTIMPL;
449 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **ppimkName)
451 HTMLDocument *This = PERSISTMON_THIS(iface);
453 TRACE("(%p)->(%p)\n", This, ppimkName);
455 if(!This->mon)
456 return E_UNEXPECTED;
458 IMoniker_AddRef(This->mon);
459 *ppimkName = This->mon;
460 return S_OK;
463 static const IPersistMonikerVtbl PersistMonikerVtbl = {
464 PersistMoniker_QueryInterface,
465 PersistMoniker_AddRef,
466 PersistMoniker_Release,
467 PersistMoniker_GetClassID,
468 PersistMoniker_IsDirty,
469 PersistMoniker_Load,
470 PersistMoniker_Save,
471 PersistMoniker_SaveCompleted,
472 PersistMoniker_GetCurMoniker
475 /**********************************************************
476 * IMonikerProp implementation
479 #define MONPROP_THIS(iface) DEFINE_THIS(HTMLDocument, MonikerProp, iface)
481 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppvObject)
483 HTMLDocument *This = MONPROP_THIS(iface);
484 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
487 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
489 HTMLDocument *This = MONPROP_THIS(iface);
490 return IHTMLDocument2_AddRef(HTMLDOC(This));
493 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
495 HTMLDocument *This = MONPROP_THIS(iface);
496 return IHTMLDocument_Release(HTMLDOC(This));
499 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
501 HTMLDocument *This = MONPROP_THIS(iface);
503 TRACE("(%p)->(%d %s)\n", This, mkp, debugstr_w(val));
505 switch(mkp) {
506 case MIMETYPEPROP:
507 heap_free(This->mime);
508 This->mime = heap_strdupW(val);
509 break;
511 case CLASSIDPROP:
512 break;
514 default:
515 FIXME("mkp %d\n", mkp);
516 return E_NOTIMPL;
519 return S_OK;
522 static const IMonikerPropVtbl MonikerPropVtbl = {
523 MonikerProp_QueryInterface,
524 MonikerProp_AddRef,
525 MonikerProp_Release,
526 MonikerProp_PutProperty
529 /**********************************************************
530 * IPersistFile implementation
533 #define PERSISTFILE_THIS(iface) DEFINE_THIS(HTMLDocument, PersistFile, iface)
535 static HRESULT WINAPI PersistFile_QueryInterface(IPersistFile *iface, REFIID riid, void **ppvObject)
537 HTMLDocument *This = PERSISTFILE_THIS(iface);
538 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
541 static ULONG WINAPI PersistFile_AddRef(IPersistFile *iface)
543 HTMLDocument *This = PERSISTFILE_THIS(iface);
544 return IHTMLDocument2_AddRef(HTMLDOC(This));
547 static ULONG WINAPI PersistFile_Release(IPersistFile *iface)
549 HTMLDocument *This = PERSISTFILE_THIS(iface);
550 return IHTMLDocument2_Release(HTMLDOC(This));
553 static HRESULT WINAPI PersistFile_GetClassID(IPersistFile *iface, CLSID *pClassID)
555 HTMLDocument *This = PERSISTFILE_THIS(iface);
557 TRACE("(%p)->(%p)\n", This, pClassID);
559 if(!pClassID)
560 return E_INVALIDARG;
562 *pClassID = CLSID_HTMLDocument;
563 return S_OK;
566 static HRESULT WINAPI PersistFile_IsDirty(IPersistFile *iface)
568 HTMLDocument *This = PERSISTFILE_THIS(iface);
570 TRACE("(%p)\n", This);
572 return IPersistStreamInit_IsDirty(PERSTRINIT(This));
575 static HRESULT WINAPI PersistFile_Load(IPersistFile *iface, LPCOLESTR pszFileName, DWORD dwMode)
577 HTMLDocument *This = PERSISTFILE_THIS(iface);
578 FIXME("(%p)->(%s %08x)\n", This, debugstr_w(pszFileName), dwMode);
579 return E_NOTIMPL;
582 static HRESULT WINAPI PersistFile_Save(IPersistFile *iface, LPCOLESTR pszFileName, BOOL fRemember)
584 HTMLDocument *This = PERSISTFILE_THIS(iface);
585 char *str;
586 DWORD len, written=0;
587 HANDLE file;
588 HRESULT hres;
590 TRACE("(%p)->(%s %x)\n", This, debugstr_w(pszFileName), fRemember);
592 file = CreateFileW(pszFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
593 FILE_ATTRIBUTE_NORMAL, NULL);
594 if(file == INVALID_HANDLE_VALUE) {
595 WARN("Could not create file: %u\n", GetLastError());
596 return E_FAIL;
599 hres = get_doc_string(This, &str, &len);
600 if(SUCCEEDED(hres))
601 WriteFile(file, str, len, &written, NULL);
603 CloseHandle(file);
604 return hres;
607 static HRESULT WINAPI PersistFile_SaveCompleted(IPersistFile *iface, LPCOLESTR pszFileName)
609 HTMLDocument *This = PERSISTFILE_THIS(iface);
610 FIXME("(%p)->(%s)\n", This, debugstr_w(pszFileName));
611 return E_NOTIMPL;
614 static HRESULT WINAPI PersistFile_GetCurFile(IPersistFile *iface, LPOLESTR *pszFileName)
616 HTMLDocument *This = PERSISTFILE_THIS(iface);
617 FIXME("(%p)->(%p)\n", This, pszFileName);
618 return E_NOTIMPL;
621 static const IPersistFileVtbl PersistFileVtbl = {
622 PersistFile_QueryInterface,
623 PersistFile_AddRef,
624 PersistFile_Release,
625 PersistFile_GetClassID,
626 PersistFile_IsDirty,
627 PersistFile_Load,
628 PersistFile_Save,
629 PersistFile_SaveCompleted,
630 PersistFile_GetCurFile
633 #define PERSTRINIT_THIS(iface) DEFINE_THIS(HTMLDocument, PersistStreamInit, iface)
635 static HRESULT WINAPI PersistStreamInit_QueryInterface(IPersistStreamInit *iface,
636 REFIID riid, void **ppv)
638 HTMLDocument *This = PERSTRINIT_THIS(iface);
639 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
642 static ULONG WINAPI PersistStreamInit_AddRef(IPersistStreamInit *iface)
644 HTMLDocument *This = PERSTRINIT_THIS(iface);
645 return IHTMLDocument2_AddRef(HTMLDOC(This));
648 static ULONG WINAPI PersistStreamInit_Release(IPersistStreamInit *iface)
650 HTMLDocument *This = PERSTRINIT_THIS(iface);
651 return IHTMLDocument2_Release(HTMLDOC(This));
654 static HRESULT WINAPI PersistStreamInit_GetClassID(IPersistStreamInit *iface, CLSID *pClassID)
656 HTMLDocument *This = PERSTRINIT_THIS(iface);
657 return IPersist_GetClassID(PERSIST(This), pClassID);
660 static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
662 HTMLDocument *This = PERSTRINIT_THIS(iface);
664 TRACE("(%p)\n", This);
666 if(This->usermode == EDITMODE)
667 return editor_is_dirty(This);
669 return S_FALSE;
672 static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM pStm)
674 HTMLDocument *This = PERSTRINIT_THIS(iface);
675 IMoniker *mon;
676 HRESULT hres;
678 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
680 TRACE("(%p)->(%p)\n", This, pStm);
682 hres = CreateURLMoniker(NULL, about_blankW, &mon);
683 if(FAILED(hres)) {
684 WARN("CreateURLMoniker failed: %08x\n", hres);
685 return hres;
688 hres = set_moniker(This, mon, NULL, NULL);
689 IMoniker_Release(mon);
690 if(FAILED(hres))
691 return hres;
693 return channelbsc_load_stream(This->bscallback, pStm);
696 static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, LPSTREAM pStm,
697 BOOL fClearDirty)
699 HTMLDocument *This = PERSTRINIT_THIS(iface);
700 char *str;
701 DWORD len, written=0;
702 HRESULT hres;
704 TRACE("(%p)->(%p %x)\n", This, pStm, fClearDirty);
706 hres = get_doc_string(This, &str, &len);
707 if(FAILED(hres))
708 return hres;
710 hres = IStream_Write(pStm, str, len, &written);
711 if(FAILED(hres))
712 FIXME("Write failed: %08x\n", hres);
714 heap_free(str);
716 if(fClearDirty)
717 set_dirty(This, VARIANT_FALSE);
719 return S_OK;
722 static HRESULT WINAPI PersistStreamInit_GetSizeMax(IPersistStreamInit *iface,
723 ULARGE_INTEGER *pcbSize)
725 HTMLDocument *This = PERSTRINIT_THIS(iface);
726 FIXME("(%p)->(%p)\n", This, pcbSize);
727 return E_NOTIMPL;
730 static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
732 HTMLDocument *This = PERSTRINIT_THIS(iface);
733 FIXME("(%p)\n", This);
734 return E_NOTIMPL;
737 #undef PERSTRINIT_THIS
739 static const IPersistStreamInitVtbl PersistStreamInitVtbl = {
740 PersistStreamInit_QueryInterface,
741 PersistStreamInit_AddRef,
742 PersistStreamInit_Release,
743 PersistStreamInit_GetClassID,
744 PersistStreamInit_IsDirty,
745 PersistStreamInit_Load,
746 PersistStreamInit_Save,
747 PersistStreamInit_GetSizeMax,
748 PersistStreamInit_InitNew
751 /**********************************************************
752 * IPersistHistory implementation
755 #define PERSISTHIST_THIS(iface) DEFINE_THIS(HTMLDocument, PersistHistory, iface)
757 static HRESULT WINAPI PersistHistory_QueryInterface(IPersistHistory *iface, REFIID riid, void **ppvObject)
759 HTMLDocument *This = PERSISTHIST_THIS(iface);
760 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
763 static ULONG WINAPI PersistHistory_AddRef(IPersistHistory *iface)
765 HTMLDocument *This = PERSISTHIST_THIS(iface);
766 return IHTMLDocument2_AddRef(HTMLDOC(This));
769 static ULONG WINAPI PersistHistory_Release(IPersistHistory *iface)
771 HTMLDocument *This = PERSISTHIST_THIS(iface);
772 return IHTMLDocument2_Release(HTMLDOC(This));
775 static HRESULT WINAPI PersistHistory_GetClassID(IPersistHistory *iface, CLSID *pClassID)
777 HTMLDocument *This = PERSISTHIST_THIS(iface);
778 return IPersist_GetClassID(PERSIST(This), pClassID);
781 static HRESULT WINAPI PersistHistory_LoadHistory(IPersistHistory *iface, IStream *pStream, IBindCtx *pbc)
783 HTMLDocument *This = PERSISTHIST_THIS(iface);
784 FIXME("(%p)->(%p %p)\n", This, pStream, pbc);
785 return E_NOTIMPL;
788 static HRESULT WINAPI PersistHistory_SaveHistory(IPersistHistory *iface, IStream *pStream)
790 HTMLDocument *This = PERSISTHIST_THIS(iface);
791 FIXME("(%p)->(%p)\n", This, pStream);
792 return E_NOTIMPL;
795 static HRESULT WINAPI PersistHistory_SetPositionCookie(IPersistHistory *iface, DWORD dwPositioncookie)
797 HTMLDocument *This = PERSISTHIST_THIS(iface);
798 FIXME("(%p)->(%x)\n", This, dwPositioncookie);
799 return E_NOTIMPL;
802 static HRESULT WINAPI PersistHistory_GetPositionCookie(IPersistHistory *iface, DWORD *pdwPositioncookie)
804 HTMLDocument *This = PERSISTHIST_THIS(iface);
805 FIXME("(%p)->(%p)\n", This, pdwPositioncookie);
806 return E_NOTIMPL;
809 #undef PERSISTHIST_THIS
811 static const IPersistHistoryVtbl PersistHistoryVtbl = {
812 PersistHistory_QueryInterface,
813 PersistHistory_AddRef,
814 PersistHistory_Release,
815 PersistHistory_GetClassID,
816 PersistHistory_LoadHistory,
817 PersistHistory_SaveHistory,
818 PersistHistory_SetPositionCookie,
819 PersistHistory_GetPositionCookie
822 void HTMLDocument_Persist_Init(HTMLDocument *This)
824 This->lpPersistMonikerVtbl = &PersistMonikerVtbl;
825 This->lpPersistFileVtbl = &PersistFileVtbl;
826 This->lpMonikerPropVtbl = &MonikerPropVtbl;
827 This->lpPersistStreamInitVtbl = &PersistStreamInitVtbl;
828 This->lpPersistHistoryVtbl = &PersistHistoryVtbl;
830 This->bscallback = NULL;
831 This->mon = NULL;
832 This->url = NULL;
833 This->mime = NULL;