2005-04-11 16:11:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Jacek Caban
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-04-11 16:11:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
2005-08-11 18:36:48 +00:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2005-04-11 16:11:52 +00:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
2005-08-25 15:19:19 +00:00
|
|
|
#include "shlguid.h"
|
2006-11-02 16:30:27 +00:00
|
|
|
#include "idispids.h"
|
2005-04-11 16:11:52 +00:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2006-02-15 10:52:33 +00:00
|
|
|
#include "wine/unicode.h"
|
2005-04-11 16:11:52 +00:00
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
2008-09-24 16:19:46 +00:00
|
|
|
static BOOL use_gecko_script(LPCWSTR url)
|
|
|
|
{
|
|
|
|
static const WCHAR fileW[] = {'f','i','l','e',':'};
|
2009-09-09 19:32:11 +00:00
|
|
|
static const WCHAR aboutW[] = {'a','b','o','u','t',':'};
|
|
|
|
|
|
|
|
return strncmpiW(fileW, url, sizeof(fileW)/sizeof(WCHAR))
|
|
|
|
&& strncmpiW(aboutW, url, sizeof(aboutW)/sizeof(WCHAR));
|
2008-09-24 16:19:46 +00:00
|
|
|
}
|
|
|
|
|
2007-06-11 15:27:19 +00:00
|
|
|
void set_current_mon(HTMLDocument *This, IMoniker *mon)
|
|
|
|
{
|
2007-06-11 15:37:20 +00:00
|
|
|
HRESULT hres;
|
|
|
|
|
2009-09-16 20:12:06 +00:00
|
|
|
if(This->doc_obj->mon) {
|
|
|
|
IMoniker_Release(This->doc_obj->mon);
|
|
|
|
This->doc_obj->mon = NULL;
|
2007-06-11 15:37:20 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 20:12:06 +00:00
|
|
|
if(This->doc_obj->url) {
|
|
|
|
CoTaskMemFree(This->doc_obj->url);
|
|
|
|
This->doc_obj->url = NULL;
|
2007-06-11 15:37:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!mon)
|
|
|
|
return;
|
|
|
|
|
|
|
|
IMoniker_AddRef(mon);
|
2009-09-16 20:12:06 +00:00
|
|
|
This->doc_obj->mon = mon;
|
2007-06-11 15:37:20 +00:00
|
|
|
|
2009-09-16 20:12:06 +00:00
|
|
|
hres = IMoniker_GetDisplayName(mon, NULL, NULL, &This->doc_obj->url);
|
2007-06-11 15:37:20 +00:00
|
|
|
if(FAILED(hres))
|
|
|
|
WARN("GetDisplayName failed: %08x\n", hres);
|
2008-09-24 16:19:46 +00:00
|
|
|
|
2009-09-16 20:12:06 +00:00
|
|
|
set_script_mode(This->window, use_gecko_script(This->doc_obj->url) ? SCRIPTMODE_GECKO : SCRIPTMODE_ACTIVESCRIPT);
|
2007-06-11 15:27:19 +00:00
|
|
|
}
|
|
|
|
|
2007-05-12 14:13:16 +00:00
|
|
|
static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BOOL *bind_complete)
|
2005-04-11 16:11:52 +00:00
|
|
|
{
|
2008-03-23 01:16:03 +00:00
|
|
|
nsChannelBSC *bscallback;
|
2006-06-20 17:01:33 +00:00
|
|
|
LPOLESTR url = NULL;
|
2006-09-24 21:12:06 +00:00
|
|
|
task_t *task;
|
2005-08-01 10:59:45 +00:00
|
|
|
HRESULT hres;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2005-08-22 09:23:14 +00:00
|
|
|
if(pibc) {
|
|
|
|
IUnknown *unk = NULL;
|
|
|
|
|
|
|
|
/* FIXME:
|
|
|
|
* Use params:
|
|
|
|
* "__PrecreatedObject"
|
|
|
|
* "BIND_CONTEXT_PARAM"
|
|
|
|
* "__HTMLLOADOPTIONS"
|
|
|
|
* "__DWNBINDINFO"
|
|
|
|
* "URL Context"
|
|
|
|
* "CBinding Context"
|
|
|
|
* "_ITransData_Object_"
|
|
|
|
* "_EnumFORMATETC_"
|
|
|
|
*/
|
|
|
|
|
2006-02-10 14:14:14 +00:00
|
|
|
IBindCtx_GetObjectParam(pibc, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, &unk);
|
2005-08-22 09:23:14 +00:00
|
|
|
if(unk) {
|
|
|
|
IOleClientSite *client = NULL;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IOleClientSite, (void**)&client);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
TRACE("Got client site %p\n", client);
|
|
|
|
IOleObject_SetClientSite(OLEOBJ(This), client);
|
|
|
|
IOleClientSite_Release(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
}
|
|
|
|
}
|
2005-08-25 15:19:19 +00:00
|
|
|
|
2009-09-16 20:12:41 +00:00
|
|
|
This->doc_obj->readystate = READYSTATE_LOADING;
|
2007-06-29 00:47:59 +00:00
|
|
|
call_property_onchanged(&This->cp_propnotif, DISPID_READYSTATE);
|
2007-06-10 09:39:39 +00:00
|
|
|
update_doc(This, UPDATE_TITLE);
|
2006-08-22 14:15:09 +00:00
|
|
|
|
2009-09-16 20:10:03 +00:00
|
|
|
HTMLDocument_LockContainer(This->doc_obj, TRUE);
|
2005-08-22 09:23:14 +00:00
|
|
|
|
2007-05-11 11:16:15 +00:00
|
|
|
hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url);
|
2005-08-11 18:36:48 +00:00
|
|
|
if(FAILED(hres)) {
|
2006-10-05 21:50:39 +00:00
|
|
|
WARN("GetDiaplayName failed: %08x\n", hres);
|
2005-08-11 18:36:48 +00:00
|
|
|
return hres;
|
|
|
|
}
|
2005-08-01 10:59:45 +00:00
|
|
|
|
2005-08-11 18:36:48 +00:00
|
|
|
TRACE("got url: %s\n", debugstr_w(url));
|
|
|
|
|
2007-06-11 15:27:19 +00:00
|
|
|
set_current_mon(This, mon);
|
|
|
|
|
2009-09-16 20:10:03 +00:00
|
|
|
if(This->doc_obj->client) {
|
2006-11-02 16:30:27 +00:00
|
|
|
VARIANT silent, offline;
|
2007-06-11 15:26:31 +00:00
|
|
|
IOleCommandTarget *cmdtrg = NULL;
|
2006-11-02 16:30:27 +00:00
|
|
|
|
2009-09-16 20:10:03 +00:00
|
|
|
hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_SILENT, &silent);
|
2006-11-02 16:30:27 +00:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
if(V_VT(&silent) != VT_BOOL)
|
|
|
|
WARN("V_VT(silent) = %d\n", V_VT(&silent));
|
|
|
|
else if(V_BOOL(&silent))
|
|
|
|
FIXME("silent == true\n");
|
|
|
|
}
|
|
|
|
|
2009-09-16 20:10:03 +00:00
|
|
|
hres = get_client_disp_property(This->doc_obj->client,
|
2006-11-02 16:30:27 +00:00
|
|
|
DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
if(V_VT(&silent) != VT_BOOL)
|
|
|
|
WARN("V_VT(offline) = %d\n", V_VT(&silent));
|
|
|
|
else if(V_BOOL(&silent))
|
|
|
|
FIXME("offline == true\n");
|
|
|
|
}
|
2007-06-11 15:26:31 +00:00
|
|
|
|
2009-09-16 20:10:03 +00:00
|
|
|
hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget,
|
2007-06-11 15:26:31 +00:00
|
|
|
(void**)&cmdtrg);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
VARIANT var;
|
|
|
|
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = 0;
|
|
|
|
IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL);
|
|
|
|
|
|
|
|
IOleCommandTarget_Release(cmdtrg);
|
|
|
|
}
|
2006-11-02 16:30:27 +00:00
|
|
|
}
|
|
|
|
|
2008-03-23 01:16:03 +00:00
|
|
|
bscallback = create_channelbsc(mon);
|
2006-06-02 22:39:39 +00:00
|
|
|
|
2009-09-16 20:10:03 +00:00
|
|
|
if(This->doc_obj->frame) {
|
2007-12-05 20:52:31 +00:00
|
|
|
task = heap_alloc(sizeof(task_t));
|
2006-11-02 16:34:01 +00:00
|
|
|
|
|
|
|
task->doc = This;
|
|
|
|
task->task_id = TASK_SETPROGRESS;
|
|
|
|
task->next = NULL;
|
|
|
|
|
|
|
|
push_task(task);
|
|
|
|
}
|
|
|
|
|
2007-12-05 20:52:31 +00:00
|
|
|
task = heap_alloc(sizeof(task_t));
|
2006-09-24 21:12:06 +00:00
|
|
|
|
|
|
|
task->doc = This;
|
|
|
|
task->task_id = TASK_SETDOWNLOADSTATE;
|
|
|
|
task->next = NULL;
|
|
|
|
|
|
|
|
push_task(task);
|
|
|
|
|
2009-09-16 20:09:17 +00:00
|
|
|
if(This->doc_obj->nscontainer) {
|
|
|
|
This->doc_obj->nscontainer->bscallback = bscallback;
|
|
|
|
nsres = nsIWebNavigation_LoadURI(This->doc_obj->nscontainer->navigation, url,
|
2009-08-24 18:12:51 +00:00
|
|
|
LOAD_FLAGS_NONE, NULL, NULL, NULL);
|
2009-09-16 20:09:17 +00:00
|
|
|
This->doc_obj->nscontainer->bscallback = NULL;
|
2009-08-22 17:40:01 +00:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
WARN("LoadURI failed: %08x\n", nsres);
|
2008-03-23 01:16:03 +00:00
|
|
|
IUnknown_Release((IUnknown*)bscallback);
|
2006-02-15 10:52:33 +00:00
|
|
|
CoTaskMemFree(url);
|
2009-08-22 17:40:01 +00:00
|
|
|
return E_FAIL;
|
2006-02-15 10:52:33 +00:00
|
|
|
}
|
2006-06-02 22:39:39 +00:00
|
|
|
}
|
2005-08-09 20:46:05 +00:00
|
|
|
|
2009-10-26 22:03:53 +00:00
|
|
|
set_window_bscallback(This->window, bscallback);
|
2008-03-23 01:16:03 +00:00
|
|
|
IUnknown_Release((IUnknown*)bscallback);
|
2006-06-02 22:39:39 +00:00
|
|
|
CoTaskMemFree(url);
|
|
|
|
|
2007-05-12 14:13:16 +00:00
|
|
|
if(bind_complete)
|
|
|
|
*bind_complete = FALSE;
|
2007-05-11 11:16:15 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-21 19:27:42 +00:00
|
|
|
static HRESULT get_doc_string(HTMLDocumentNode *This, char **str)
|
2007-05-11 11:16:15 +00:00
|
|
|
{
|
|
|
|
nsIDOMNode *nsnode;
|
|
|
|
LPCWSTR strw;
|
|
|
|
nsAString nsstr;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2008-10-08 18:27:59 +00:00
|
|
|
if(!This->nsdoc) {
|
|
|
|
WARN("NULL nsdoc\n");
|
|
|
|
return E_UNEXPECTED;
|
2007-05-11 11:16:15 +00:00
|
|
|
}
|
|
|
|
|
2008-10-08 18:27:59 +00:00
|
|
|
nsres = nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMNode, (void**)&nsnode);
|
2007-05-11 11:16:15 +00:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not get nsIDOMNode failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Init(&nsstr, NULL);
|
|
|
|
nsnode_to_nsstring(nsnode, &nsstr);
|
|
|
|
nsIDOMNode_Release(nsnode);
|
|
|
|
|
2007-12-17 00:38:30 +00:00
|
|
|
nsAString_GetData(&nsstr, &strw);
|
2007-05-11 11:16:15 +00:00
|
|
|
TRACE("%s\n", debugstr_w(strw));
|
|
|
|
|
2009-08-11 17:15:59 +00:00
|
|
|
*str = heap_strdupWtoA(strw);
|
2007-05-11 11:16:15 +00:00
|
|
|
|
|
|
|
nsAString_Finish(&nsstr);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************
|
|
|
|
* IPersistMoniker implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PERSISTMON_THIS(iface) DEFINE_THIS(HTMLDocument, PersistMoniker, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTMON_THIS(iface);
|
|
|
|
return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTMON_THIS(iface);
|
|
|
|
return IHTMLDocument2_AddRef(HTMLDOC(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTMON_THIS(iface);
|
|
|
|
return IHTMLDocument2_Release(HTMLDOC(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTMON_THIS(iface);
|
|
|
|
return IPersist_GetClassID(PERSIST(This), pClassID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTMON_THIS(iface);
|
2007-06-10 09:35:55 +00:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return IPersistStreamInit_IsDirty(PERSTRINIT(This));
|
2007-05-11 11:16:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
|
|
|
|
IMoniker *pimkName, LPBC pibc, DWORD grfMode)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTMON_THIS(iface);
|
2007-05-12 14:13:16 +00:00
|
|
|
BOOL bind_complete = FALSE;
|
2007-05-11 11:16:15 +00:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%x %p %p %08x)\n", This, fFullyAvailable, pimkName, pibc, grfMode);
|
|
|
|
|
2007-05-12 14:13:16 +00:00
|
|
|
hres = set_moniker(This, pimkName, pibc, &bind_complete);
|
2007-05-11 11:16:15 +00:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2007-05-12 14:13:16 +00:00
|
|
|
if(!bind_complete)
|
2009-10-26 22:03:53 +00:00
|
|
|
return start_binding(This, (BSCallback*)This->window->bscallback, pibc);
|
2007-05-12 14:13:16 +00:00
|
|
|
|
|
|
|
return S_OK;
|
2005-04-11 16:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName,
|
|
|
|
LPBC pbc, BOOL fRemember)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTMON_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p %p %x)\n", This, pimkName, pbc, fRemember);
|
2005-04-11 16:11:52 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTMON_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p %p)\n", This, pimkName, pibc);
|
2005-04-11 16:11:52 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **ppimkName)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTMON_THIS(iface);
|
2007-06-11 15:29:13 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, ppimkName);
|
|
|
|
|
2009-09-16 20:12:06 +00:00
|
|
|
if(!This->doc_obj->mon)
|
2007-06-11 15:29:13 +00:00
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
2009-09-16 20:12:06 +00:00
|
|
|
IMoniker_AddRef(This->doc_obj->mon);
|
|
|
|
*ppimkName = This->doc_obj->mon;
|
2007-06-11 15:29:13 +00:00
|
|
|
return S_OK;
|
2005-04-11 16:11:52 +00:00
|
|
|
}
|
|
|
|
|
2005-06-01 19:57:42 +00:00
|
|
|
static const IPersistMonikerVtbl PersistMonikerVtbl = {
|
2005-04-11 16:11:52 +00:00
|
|
|
PersistMoniker_QueryInterface,
|
|
|
|
PersistMoniker_AddRef,
|
|
|
|
PersistMoniker_Release,
|
|
|
|
PersistMoniker_GetClassID,
|
|
|
|
PersistMoniker_IsDirty,
|
|
|
|
PersistMoniker_Load,
|
|
|
|
PersistMoniker_Save,
|
|
|
|
PersistMoniker_SaveCompleted,
|
|
|
|
PersistMoniker_GetCurMoniker
|
|
|
|
};
|
|
|
|
|
|
|
|
/**********************************************************
|
|
|
|
* IMonikerProp implementation
|
|
|
|
*/
|
|
|
|
|
2005-08-09 20:46:05 +00:00
|
|
|
#define MONPROP_THIS(iface) DEFINE_THIS(HTMLDocument, MonikerProp, iface)
|
2005-04-11 16:11:52 +00:00
|
|
|
|
|
|
|
static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = MONPROP_THIS(iface);
|
2005-04-11 16:11:52 +00:00
|
|
|
return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = MONPROP_THIS(iface);
|
2005-04-11 16:11:52 +00:00
|
|
|
return IHTMLDocument2_AddRef(HTMLDOC(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = MONPROP_THIS(iface);
|
2005-04-11 16:11:52 +00:00
|
|
|
return IHTMLDocument_Release(HTMLDOC(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = MONPROP_THIS(iface);
|
2007-12-31 00:32:48 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s)\n", This, mkp, debugstr_w(val));
|
|
|
|
|
|
|
|
switch(mkp) {
|
|
|
|
case MIMETYPEPROP:
|
2009-09-16 20:12:56 +00:00
|
|
|
heap_free(This->doc_obj->mime);
|
|
|
|
This->doc_obj->mime = heap_strdupW(val);
|
2007-12-31 00:32:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLASSIDPROP:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("mkp %d\n", mkp);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2005-04-11 16:11:52 +00:00
|
|
|
}
|
|
|
|
|
2005-06-01 19:57:42 +00:00
|
|
|
static const IMonikerPropVtbl MonikerPropVtbl = {
|
2005-04-11 16:11:52 +00:00
|
|
|
MonikerProp_QueryInterface,
|
|
|
|
MonikerProp_AddRef,
|
|
|
|
MonikerProp_Release,
|
|
|
|
MonikerProp_PutProperty
|
|
|
|
};
|
|
|
|
|
|
|
|
/**********************************************************
|
|
|
|
* IPersistFile implementation
|
|
|
|
*/
|
|
|
|
|
2005-08-09 20:46:05 +00:00
|
|
|
#define PERSISTFILE_THIS(iface) DEFINE_THIS(HTMLDocument, PersistFile, iface)
|
2005-04-11 16:11:52 +00:00
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_QueryInterface(IPersistFile *iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTFILE_THIS(iface);
|
2005-04-11 16:11:52 +00:00
|
|
|
return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistFile_AddRef(IPersistFile *iface)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTFILE_THIS(iface);
|
2005-04-11 16:11:52 +00:00
|
|
|
return IHTMLDocument2_AddRef(HTMLDOC(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistFile_Release(IPersistFile *iface)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTFILE_THIS(iface);
|
2005-04-11 16:11:52 +00:00
|
|
|
return IHTMLDocument2_Release(HTMLDOC(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_GetClassID(IPersistFile *iface, CLSID *pClassID)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTFILE_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pClassID);
|
2005-04-11 16:11:52 +00:00
|
|
|
|
|
|
|
if(!pClassID)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2008-03-05 21:35:16 +00:00
|
|
|
*pClassID = CLSID_HTMLDocument;
|
2005-04-11 16:11:52 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_IsDirty(IPersistFile *iface)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTFILE_THIS(iface);
|
2007-06-10 09:35:55 +00:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return IPersistStreamInit_IsDirty(PERSTRINIT(This));
|
2005-04-11 16:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_Load(IPersistFile *iface, LPCOLESTR pszFileName, DWORD dwMode)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTFILE_THIS(iface);
|
2006-10-05 21:50:39 +00:00
|
|
|
FIXME("(%p)->(%s %08x)\n", This, debugstr_w(pszFileName), dwMode);
|
2005-04-11 16:11:52 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_Save(IPersistFile *iface, LPCOLESTR pszFileName, BOOL fRemember)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTFILE_THIS(iface);
|
2007-04-12 19:26:17 +00:00
|
|
|
char *str;
|
2009-08-11 17:15:59 +00:00
|
|
|
DWORD written=0;
|
2007-04-12 19:26:17 +00:00
|
|
|
HANDLE file;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %x)\n", This, debugstr_w(pszFileName), fRemember);
|
|
|
|
|
|
|
|
file = CreateFileW(pszFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
if(file == INVALID_HANDLE_VALUE) {
|
|
|
|
WARN("Could not create file: %u\n", GetLastError());
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2009-10-21 19:27:42 +00:00
|
|
|
hres = get_doc_string(This->doc_node, &str);
|
2008-10-08 18:27:59 +00:00
|
|
|
if(SUCCEEDED(hres))
|
2009-08-11 17:15:59 +00:00
|
|
|
WriteFile(file, str, strlen(str), &written, NULL);
|
2007-04-12 19:26:17 +00:00
|
|
|
|
|
|
|
CloseHandle(file);
|
2008-10-08 18:27:59 +00:00
|
|
|
return hres;
|
2005-04-11 16:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_SaveCompleted(IPersistFile *iface, LPCOLESTR pszFileName)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTFILE_THIS(iface);
|
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(pszFileName));
|
2005-04-11 16:11:52 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_GetCurFile(IPersistFile *iface, LPOLESTR *pszFileName)
|
|
|
|
{
|
2005-08-09 20:46:05 +00:00
|
|
|
HTMLDocument *This = PERSISTFILE_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pszFileName);
|
2005-04-11 16:11:52 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-06-01 19:57:42 +00:00
|
|
|
static const IPersistFileVtbl PersistFileVtbl = {
|
2005-04-11 16:11:52 +00:00
|
|
|
PersistFile_QueryInterface,
|
|
|
|
PersistFile_AddRef,
|
|
|
|
PersistFile_Release,
|
|
|
|
PersistFile_GetClassID,
|
|
|
|
PersistFile_IsDirty,
|
|
|
|
PersistFile_Load,
|
|
|
|
PersistFile_Save,
|
|
|
|
PersistFile_SaveCompleted,
|
|
|
|
PersistFile_GetCurFile
|
|
|
|
};
|
|
|
|
|
2006-09-24 21:41:01 +00:00
|
|
|
#define PERSTRINIT_THIS(iface) DEFINE_THIS(HTMLDocument, PersistStreamInit, iface)
|
2006-05-23 20:16:26 +00:00
|
|
|
|
|
|
|
static HRESULT WINAPI PersistStreamInit_QueryInterface(IPersistStreamInit *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSTRINIT_THIS(iface);
|
|
|
|
return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistStreamInit_AddRef(IPersistStreamInit *iface)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSTRINIT_THIS(iface);
|
|
|
|
return IHTMLDocument2_AddRef(HTMLDOC(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistStreamInit_Release(IPersistStreamInit *iface)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSTRINIT_THIS(iface);
|
2007-05-11 11:16:15 +00:00
|
|
|
return IHTMLDocument2_Release(HTMLDOC(This));
|
2006-05-23 20:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistStreamInit_GetClassID(IPersistStreamInit *iface, CLSID *pClassID)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSTRINIT_THIS(iface);
|
|
|
|
return IPersist_GetClassID(PERSIST(This), pClassID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSTRINIT_THIS(iface);
|
2007-06-10 22:21:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
2009-09-16 20:12:25 +00:00
|
|
|
if(This->doc_obj->usermode == EDITMODE)
|
2007-09-12 09:42:01 +00:00
|
|
|
return editor_is_dirty(This);
|
2007-06-10 22:21:14 +00:00
|
|
|
|
|
|
|
return S_FALSE;
|
2006-05-23 20:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM pStm)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSTRINIT_THIS(iface);
|
2007-05-11 11:17:41 +00:00
|
|
|
IMoniker *mon;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pStm);
|
|
|
|
|
|
|
|
hres = CreateURLMoniker(NULL, about_blankW, &mon);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("CreateURLMoniker failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2007-05-12 14:13:16 +00:00
|
|
|
hres = set_moniker(This, mon, NULL, NULL);
|
2007-05-11 11:17:41 +00:00
|
|
|
IMoniker_Release(mon);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2009-10-26 22:03:53 +00:00
|
|
|
return channelbsc_load_stream(This->window->bscallback, pStm);
|
2006-05-23 20:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, LPSTREAM pStm,
|
|
|
|
BOOL fClearDirty)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSTRINIT_THIS(iface);
|
2006-10-02 18:33:08 +00:00
|
|
|
char *str;
|
2009-08-11 17:15:59 +00:00
|
|
|
DWORD written=0;
|
2006-10-02 18:33:08 +00:00
|
|
|
HRESULT hres;
|
|
|
|
|
2008-01-10 11:53:38 +00:00
|
|
|
TRACE("(%p)->(%p %x)\n", This, pStm, fClearDirty);
|
2006-10-02 18:33:08 +00:00
|
|
|
|
2009-10-21 19:27:42 +00:00
|
|
|
hres = get_doc_string(This->doc_node, &str);
|
2007-04-12 19:26:17 +00:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2006-10-02 18:33:08 +00:00
|
|
|
|
2009-08-11 17:15:59 +00:00
|
|
|
hres = IStream_Write(pStm, str, strlen(str), &written);
|
2006-10-02 18:33:08 +00:00
|
|
|
if(FAILED(hres))
|
2006-10-05 21:50:39 +00:00
|
|
|
FIXME("Write failed: %08x\n", hres);
|
2006-10-02 18:33:08 +00:00
|
|
|
|
2007-12-05 20:52:31 +00:00
|
|
|
heap_free(str);
|
2008-01-10 11:53:38 +00:00
|
|
|
|
|
|
|
if(fClearDirty)
|
|
|
|
set_dirty(This, VARIANT_FALSE);
|
|
|
|
|
2006-10-02 18:33:08 +00:00
|
|
|
return S_OK;
|
2006-05-23 20:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistStreamInit_GetSizeMax(IPersistStreamInit *iface,
|
|
|
|
ULARGE_INTEGER *pcbSize)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSTRINIT_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pcbSize);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSTRINIT_THIS(iface);
|
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PERSTRINIT_THIS
|
|
|
|
|
|
|
|
static const IPersistStreamInitVtbl PersistStreamInitVtbl = {
|
|
|
|
PersistStreamInit_QueryInterface,
|
|
|
|
PersistStreamInit_AddRef,
|
|
|
|
PersistStreamInit_Release,
|
|
|
|
PersistStreamInit_GetClassID,
|
|
|
|
PersistStreamInit_IsDirty,
|
|
|
|
PersistStreamInit_Load,
|
|
|
|
PersistStreamInit_Save,
|
|
|
|
PersistStreamInit_GetSizeMax,
|
|
|
|
PersistStreamInit_InitNew
|
|
|
|
};
|
|
|
|
|
2009-04-15 17:58:05 +00:00
|
|
|
/**********************************************************
|
|
|
|
* IPersistHistory implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PERSISTHIST_THIS(iface) DEFINE_THIS(HTMLDocument, PersistHistory, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistHistory_QueryInterface(IPersistHistory *iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTHIST_THIS(iface);
|
|
|
|
return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistHistory_AddRef(IPersistHistory *iface)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTHIST_THIS(iface);
|
|
|
|
return IHTMLDocument2_AddRef(HTMLDOC(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistHistory_Release(IPersistHistory *iface)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTHIST_THIS(iface);
|
|
|
|
return IHTMLDocument2_Release(HTMLDOC(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistHistory_GetClassID(IPersistHistory *iface, CLSID *pClassID)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTHIST_THIS(iface);
|
|
|
|
return IPersist_GetClassID(PERSIST(This), pClassID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistHistory_LoadHistory(IPersistHistory *iface, IStream *pStream, IBindCtx *pbc)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTHIST_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p %p)\n", This, pStream, pbc);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistHistory_SaveHistory(IPersistHistory *iface, IStream *pStream)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTHIST_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pStream);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistHistory_SetPositionCookie(IPersistHistory *iface, DWORD dwPositioncookie)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTHIST_THIS(iface);
|
|
|
|
FIXME("(%p)->(%x)\n", This, dwPositioncookie);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistHistory_GetPositionCookie(IPersistHistory *iface, DWORD *pdwPositioncookie)
|
|
|
|
{
|
|
|
|
HTMLDocument *This = PERSISTHIST_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pdwPositioncookie);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PERSISTHIST_THIS
|
|
|
|
|
|
|
|
static const IPersistHistoryVtbl PersistHistoryVtbl = {
|
|
|
|
PersistHistory_QueryInterface,
|
|
|
|
PersistHistory_AddRef,
|
|
|
|
PersistHistory_Release,
|
|
|
|
PersistHistory_GetClassID,
|
|
|
|
PersistHistory_LoadHistory,
|
|
|
|
PersistHistory_SaveHistory,
|
|
|
|
PersistHistory_SetPositionCookie,
|
|
|
|
PersistHistory_GetPositionCookie
|
|
|
|
};
|
|
|
|
|
2005-04-11 16:11:52 +00:00
|
|
|
void HTMLDocument_Persist_Init(HTMLDocument *This)
|
|
|
|
{
|
|
|
|
This->lpPersistMonikerVtbl = &PersistMonikerVtbl;
|
|
|
|
This->lpPersistFileVtbl = &PersistFileVtbl;
|
|
|
|
This->lpMonikerPropVtbl = &MonikerPropVtbl;
|
2006-05-23 20:16:26 +00:00
|
|
|
This->lpPersistStreamInitVtbl = &PersistStreamInitVtbl;
|
2009-04-15 17:58:05 +00:00
|
|
|
This->lpPersistHistoryVtbl = &PersistHistoryVtbl;
|
2005-04-11 16:11:52 +00:00
|
|
|
}
|