Commit 6a07cfeb authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Add support for IPersistStreamInit for IXMLDOMDocument.

parent f2f50885
...@@ -66,7 +66,7 @@ typedef struct _domdoc ...@@ -66,7 +66,7 @@ typedef struct _domdoc
{ {
xmlnode node; xmlnode node;
const struct IXMLDOMDocument2Vtbl *lpVtbl; const struct IXMLDOMDocument2Vtbl *lpVtbl;
const struct IPersistStreamVtbl *lpvtblIPersistStream; const struct IPersistStreamInitVtbl *lpvtblIPersistStreamInit;
const struct IObjectWithSiteVtbl *lpvtblIObjectWithSite; const struct IObjectWithSiteVtbl *lpvtblIObjectWithSite;
const struct IObjectSafetyVtbl *lpvtblIObjectSafety; const struct IObjectSafetyVtbl *lpvtblIObjectSafety;
const struct ISupportErrorInfoVtbl *lpvtblISupportErrorInfo; const struct ISupportErrorInfoVtbl *lpvtblISupportErrorInfo;
...@@ -296,9 +296,9 @@ static inline xmlDocPtr get_doc( domdoc *This ) ...@@ -296,9 +296,9 @@ static inline xmlDocPtr get_doc( domdoc *This )
return (xmlDocPtr)This->node.node; return (xmlDocPtr)This->node.node;
} }
static inline domdoc *impl_from_IPersistStream(IPersistStream *iface) static inline domdoc *impl_from_IPersistStreamInit(IPersistStreamInit *iface)
{ {
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpvtblIPersistStream)); return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpvtblIPersistStreamInit));
} }
static inline domdoc *impl_from_IObjectWithSite(IObjectWithSite *iface) static inline domdoc *impl_from_IObjectWithSite(IObjectWithSite *iface)
...@@ -319,29 +319,29 @@ static inline domdoc *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface) ...@@ -319,29 +319,29 @@ static inline domdoc *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
/************************************************************************ /************************************************************************
* xmldoc implementation of IPersistStream. * xmldoc implementation of IPersistStream.
*/ */
static HRESULT WINAPI xmldoc_IPersistStream_QueryInterface( static HRESULT WINAPI xmldoc_IPersistStreamInit_QueryInterface(
IPersistStream *iface, REFIID riid, LPVOID *ppvObj) IPersistStreamInit *iface, REFIID riid, LPVOID *ppvObj)
{ {
domdoc *this = impl_from_IPersistStream(iface); domdoc *this = impl_from_IPersistStreamInit(iface);
return IXMLDocument_QueryInterface((IXMLDocument *)this, riid, ppvObj); return IXMLDocument_QueryInterface((IXMLDocument *)this, riid, ppvObj);
} }
static ULONG WINAPI xmldoc_IPersistStream_AddRef( static ULONG WINAPI xmldoc_IPersistStreamInit_AddRef(
IPersistStream *iface) IPersistStreamInit *iface)
{ {
domdoc *this = impl_from_IPersistStream(iface); domdoc *this = impl_from_IPersistStreamInit(iface);
return IXMLDocument_AddRef((IXMLDocument *)this); return IXMLDocument_AddRef((IXMLDocument *)this);
} }
static ULONG WINAPI xmldoc_IPersistStream_Release( static ULONG WINAPI xmldoc_IPersistStreamInit_Release(
IPersistStream *iface) IPersistStreamInit *iface)
{ {
domdoc *this = impl_from_IPersistStream(iface); domdoc *this = impl_from_IPersistStreamInit(iface);
return IXMLDocument_Release((IXMLDocument *)this); return IXMLDocument_Release((IXMLDocument *)this);
} }
static HRESULT WINAPI xmldoc_IPersistStream_GetClassID( static HRESULT WINAPI xmldoc_IPersistStreamInit_GetClassID(
IPersistStream *iface, CLSID *classid) IPersistStreamInit *iface, CLSID *classid)
{ {
TRACE("(%p,%p): stub!\n", iface, classid); TRACE("(%p,%p): stub!\n", iface, classid);
...@@ -353,20 +353,20 @@ static HRESULT WINAPI xmldoc_IPersistStream_GetClassID( ...@@ -353,20 +353,20 @@ static HRESULT WINAPI xmldoc_IPersistStream_GetClassID(
return S_OK; return S_OK;
} }
static HRESULT WINAPI xmldoc_IPersistStream_IsDirty( static HRESULT WINAPI xmldoc_IPersistStreamInit_IsDirty(
IPersistStream *iface) IPersistStreamInit *iface)
{ {
domdoc *This = impl_from_IPersistStream(iface); domdoc *This = impl_from_IPersistStreamInit(iface);
FIXME("(%p): stub!\n", This); FIXME("(%p): stub!\n", This);
return S_FALSE; return S_FALSE;
} }
static HRESULT WINAPI xmldoc_IPersistStream_Load( static HRESULT WINAPI xmldoc_IPersistStreamInit_Load(
IPersistStream *iface, LPSTREAM pStm) IPersistStreamInit *iface, LPSTREAM pStm)
{ {
domdoc *This = impl_from_IPersistStream(iface); domdoc *This = impl_from_IPersistStreamInit(iface);
HRESULT hr; HRESULT hr;
HGLOBAL hglobal; HGLOBAL hglobal;
DWORD read, written, len; DWORD read, written, len;
...@@ -416,10 +416,10 @@ static HRESULT WINAPI xmldoc_IPersistStream_Load( ...@@ -416,10 +416,10 @@ static HRESULT WINAPI xmldoc_IPersistStream_Load(
return attach_xmldoc( &This->node, xmldoc ); return attach_xmldoc( &This->node, xmldoc );
} }
static HRESULT WINAPI xmldoc_IPersistStream_Save( static HRESULT WINAPI xmldoc_IPersistStreamInit_Save(
IPersistStream *iface, LPSTREAM pStm, BOOL fClearDirty) IPersistStreamInit *iface, LPSTREAM pStm, BOOL fClearDirty)
{ {
domdoc *This = impl_from_IPersistStream(iface); domdoc *This = impl_from_IPersistStreamInit(iface);
HRESULT hr; HRESULT hr;
BSTR xmlString; BSTR xmlString;
...@@ -441,24 +441,33 @@ static HRESULT WINAPI xmldoc_IPersistStream_Save( ...@@ -441,24 +441,33 @@ static HRESULT WINAPI xmldoc_IPersistStream_Save(
return hr; return hr;
} }
static HRESULT WINAPI xmldoc_IPersistStream_GetSizeMax( static HRESULT WINAPI xmldoc_IPersistStreamInit_GetSizeMax(
IPersistStream *iface, ULARGE_INTEGER *pcbSize) IPersistStreamInit *iface, ULARGE_INTEGER *pcbSize)
{ {
domdoc *This = impl_from_IPersistStream(iface); domdoc *This = impl_from_IPersistStreamInit(iface);
TRACE("(%p)->(%p): stub!\n", This, pcbSize); TRACE("(%p)->(%p): stub!\n", This, pcbSize);
return E_NOTIMPL; return E_NOTIMPL;
} }
static const IPersistStreamVtbl xmldoc_IPersistStream_VTable = static HRESULT WINAPI xmldoc_IPersistStreamInit_InitNew(
IPersistStreamInit *iface)
{ {
xmldoc_IPersistStream_QueryInterface, domdoc *This = impl_from_IPersistStreamInit(iface);
xmldoc_IPersistStream_AddRef, TRACE("(%p)\n", This);
xmldoc_IPersistStream_Release, return S_OK;
xmldoc_IPersistStream_GetClassID, }
xmldoc_IPersistStream_IsDirty,
xmldoc_IPersistStream_Load, static const IPersistStreamInitVtbl xmldoc_IPersistStreamInit_VTable =
xmldoc_IPersistStream_Save, {
xmldoc_IPersistStream_GetSizeMax, xmldoc_IPersistStreamInit_QueryInterface,
xmldoc_IPersistStreamInit_AddRef,
xmldoc_IPersistStreamInit_Release,
xmldoc_IPersistStreamInit_GetClassID,
xmldoc_IPersistStreamInit_IsDirty,
xmldoc_IPersistStreamInit_Load,
xmldoc_IPersistStreamInit_Save,
xmldoc_IPersistStreamInit_GetSizeMax,
xmldoc_IPersistStreamInit_InitNew
}; };
/* ISupportErrorInfo interface */ /* ISupportErrorInfo interface */
...@@ -520,9 +529,10 @@ static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument2 *iface, REFIID rii ...@@ -520,9 +529,10 @@ static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument2 *iface, REFIID rii
{ {
*ppvObject = IXMLDOMNode_from_impl(&This->node); *ppvObject = IXMLDOMNode_from_impl(&This->node);
} }
else if (IsEqualGUID(&IID_IPersistStream, riid)) else if (IsEqualGUID(&IID_IPersistStream, riid) ||
IsEqualGUID(&IID_IPersistStreamInit, riid))
{ {
*ppvObject = &(This->lpvtblIPersistStream); *ppvObject = &(This->lpvtblIPersistStreamInit);
} }
else if (IsEqualGUID(&IID_IObjectWithSite, riid)) else if (IsEqualGUID(&IID_IObjectWithSite, riid))
{ {
...@@ -1575,7 +1585,7 @@ static HRESULT WINAPI domdoc_load( ...@@ -1575,7 +1585,7 @@ static HRESULT WINAPI domdoc_load(
hr = IUnknown_QueryInterface(iface, &IID_IPersistStream, (void**)&pDocStream); hr = IUnknown_QueryInterface(iface, &IID_IPersistStream, (void**)&pDocStream);
if(hr == S_OK) if(hr == S_OK)
{ {
hr = xmldoc_IPersistStream_Load(pDocStream, pStream); hr = IPersistStream_Load(pDocStream, pStream);
IStream_Release(pStream); IStream_Release(pStream);
if(hr == S_OK) if(hr == S_OK)
{ {
...@@ -2337,7 +2347,7 @@ HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **docu ...@@ -2337,7 +2347,7 @@ HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **docu
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
doc->lpVtbl = &domdoc_vtbl; doc->lpVtbl = &domdoc_vtbl;
doc->lpvtblIPersistStream = &xmldoc_IPersistStream_VTable; doc->lpvtblIPersistStreamInit = &xmldoc_IPersistStreamInit_VTable;
doc->lpvtblIObjectWithSite = &domdocObjectSite; doc->lpvtblIObjectWithSite = &domdocObjectSite;
doc->lpvtblIObjectSafety = &domdocObjectSafetyVtbl; doc->lpvtblIObjectSafety = &domdocObjectSafetyVtbl;
doc->lpvtblISupportErrorInfo = &support_error_vtbl; doc->lpvtblISupportErrorInfo = &support_error_vtbl;
......
...@@ -1242,6 +1242,27 @@ if (0) ...@@ -1242,6 +1242,27 @@ if (0)
free_bstrs(); free_bstrs();
} }
static void test_persiststreaminit(void)
{
IXMLDOMDocument *doc;
IPersistStreamInit *streaminit;
HRESULT hr;
hr = CoCreateInstance( &CLSID_DOMDocument, NULL,
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void**)&doc );
ok( hr == S_OK, "failed with 0x%08x\n", hr );
if( hr != S_OK )
return;
hr = IXMLDOMDocument_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&streaminit);
ok( hr == S_OK, "failed with 0x%08x\n", hr );
hr = IPersistStreamInit_InitNew(streaminit);
ok( hr == S_OK, "failed with 0x%08x\n", hr );
IXMLDOMDocument_Release(doc);
}
static void test_domnode( void ) static void test_domnode( void )
{ {
HRESULT r; HRESULT r;
...@@ -5597,6 +5618,7 @@ START_TEST(domdoc) ...@@ -5597,6 +5618,7 @@ START_TEST(domdoc)
IXMLDOMDocument_Release(doc); IXMLDOMDocument_Release(doc);
test_domdoc(); test_domdoc();
test_persiststreaminit();
test_domnode(); test_domnode();
test_refs(); test_refs();
test_create(); test_create();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment