Sweden-Number/dlls/mshtml/persist.c

266 lines
7.3 KiB
C

/*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdarg.h>
#include <stdio.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "docobj.h"
#include "mshtml.h"
#include "mshtmhst.h"
#include "wine/debug.h"
#include "mshtml_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
/**********************************************************
* IPersistMoniker implementation
*/
#define PERSISTMON_THIS \
HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpPersistMonikerVtbl));
static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid,
void **ppvObject)
{
PERSISTMON_THIS
return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
}
static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
{
PERSISTMON_THIS
return IHTMLDocument2_AddRef(HTMLDOC(This));
}
static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
{
PERSISTMON_THIS
return IHTMLDocument2_Release(HTMLDOC(This));
}
static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
{
PERSISTMON_THIS
return IPersist_GetClassID(PERSIST(This), pClassID);
}
static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
{
FIXME("(%p)\n", iface);
return E_NOTIMPL;
}
static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
IMoniker *pimkName, LPBC pibc, DWORD grfMode)
{
PERSISTMON_THIS
LPWSTR url;
HRESULT hres;
nsresult nsres;
FIXME("(%p)->(%x %p %p %08lx)\n", iface, fFullyAvailable, pimkName, pibc, grfMode);
/* FIXME:
* This is a HACK, we should use moniker's BindToStorage instead of Gecko's LoadURI.
*/
if(This->nscontainer) {
hres = IMoniker_GetDisplayName(pimkName, pibc, NULL, &url);
if(FAILED(hres)) {
WARN("GetDiaplayName failed: %08lx\n", hres);
return hres;
}
TRACE("got url: %s\n", debugstr_w(url));
if(This->hwnd) {
nsres = nsIWebNavigation_LoadURI(This->nscontainer->navigation, url,
LOAD_FLAGS_NONE, NULL, NULL, NULL);
if(NS_FAILED(nsres))
WARN("LoadURI failed: %08lx\n", nsres);
}else {
This->nscontainer->url = url;
}
}
return S_OK;
}
static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName,
LPBC pbc, BOOL fRemember)
{
FIXME("(%p)->(%p %p %x)\n", iface, pimkName, pbc, fRemember);
return E_NOTIMPL;
}
static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
{
FIXME("(%p)->(%p %p)\n", iface, pimkName, pibc);
return E_NOTIMPL;
}
static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **ppimkName)
{
FIXME("(%p)->(%p)\n", iface, ppimkName);
return E_NOTIMPL;
}
static const IPersistMonikerVtbl PersistMonikerVtbl = {
PersistMoniker_QueryInterface,
PersistMoniker_AddRef,
PersistMoniker_Release,
PersistMoniker_GetClassID,
PersistMoniker_IsDirty,
PersistMoniker_Load,
PersistMoniker_Save,
PersistMoniker_SaveCompleted,
PersistMoniker_GetCurMoniker
};
/**********************************************************
* IMonikerProp implementation
*/
#define MONPROP_THIS \
HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpMonikerPropVtbl));
static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppvObject)
{
MONPROP_THIS
return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
}
static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
{
MONPROP_THIS
return IHTMLDocument2_AddRef(HTMLDOC(This));
}
static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
{
MONPROP_THIS
return IHTMLDocument_Release(HTMLDOC(This));
}
static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
{
FIXME("(%p)->(%d %s)\n", iface, mkp, debugstr_w(val));
return E_NOTIMPL;
}
static const IMonikerPropVtbl MonikerPropVtbl = {
MonikerProp_QueryInterface,
MonikerProp_AddRef,
MonikerProp_Release,
MonikerProp_PutProperty
};
/**********************************************************
* IPersistFile implementation
*/
#define PERSISTFILE_THIS \
HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpPersistFileVtbl));
static HRESULT WINAPI PersistFile_QueryInterface(IPersistFile *iface, REFIID riid, void **ppvObject)
{
PERSISTFILE_THIS
return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
}
static ULONG WINAPI PersistFile_AddRef(IPersistFile *iface)
{
PERSISTFILE_THIS
return IHTMLDocument2_AddRef(HTMLDOC(This));
}
static ULONG WINAPI PersistFile_Release(IPersistFile *iface)
{
PERSISTFILE_THIS
return IHTMLDocument2_Release(HTMLDOC(This));
}
static HRESULT WINAPI PersistFile_GetClassID(IPersistFile *iface, CLSID *pClassID)
{
TRACE("(%p)->(%p)\n", iface, pClassID);
if(!pClassID)
return E_INVALIDARG;
memcpy(pClassID, &CLSID_HTMLDocument, sizeof(CLSID));
return S_OK;
}
static HRESULT WINAPI PersistFile_IsDirty(IPersistFile *iface)
{
FIXME("(%p)\n", iface);
return E_NOTIMPL;
}
static HRESULT WINAPI PersistFile_Load(IPersistFile *iface, LPCOLESTR pszFileName, DWORD dwMode)
{
FIXME("(%p)->(%s %08lx)\n", iface, debugstr_w(pszFileName), dwMode);
return E_NOTIMPL;
}
static HRESULT WINAPI PersistFile_Save(IPersistFile *iface, LPCOLESTR pszFileName, BOOL fRemember)
{
FIXME("(%p)->(%s %x)\n", iface, debugstr_w(pszFileName), fRemember);
return E_NOTIMPL;
}
static HRESULT WINAPI PersistFile_SaveCompleted(IPersistFile *iface, LPCOLESTR pszFileName)
{
FIXME("(%p)->(%s)\n", iface, debugstr_w(pszFileName));
return E_NOTIMPL;
}
static HRESULT WINAPI PersistFile_GetCurFile(IPersistFile *iface, LPOLESTR *pszFileName)
{
FIXME("(%p)->(%p)\n", iface, pszFileName);
return E_NOTIMPL;
}
static const IPersistFileVtbl PersistFileVtbl = {
PersistFile_QueryInterface,
PersistFile_AddRef,
PersistFile_Release,
PersistFile_GetClassID,
PersistFile_IsDirty,
PersistFile_Load,
PersistFile_Save,
PersistFile_SaveCompleted,
PersistFile_GetCurFile
};
void HTMLDocument_Persist_Init(HTMLDocument *This)
{
This->lpPersistMonikerVtbl = &PersistMonikerVtbl;
This->lpPersistFileVtbl = &PersistFileVtbl;
This->lpMonikerPropVtbl = &MonikerPropVtbl;
}