msxml3: Implement IXMLParser Get/Set Factory.

This commit is contained in:
Alistair Leslie-Hughes 2013-03-06 16:01:45 +11:00 committed by Alexandre Julliard
parent 461951e3d4
commit 850d077a4b
2 changed files with 112 additions and 4 deletions

View File

@ -28,10 +28,81 @@
#include "xmlparser.h"
#include "wine/test.h"
static HRESULT WINAPI nodefact_QueryInterface(IXMLNodeFactory *iface,
REFIID riid, void **ppvObject)
{
*ppvObject = NULL;
if (IsEqualGUID(riid, &IID_IXMLNodeFactory) ||
IsEqualGUID(riid, &IID_IUnknown))
*ppvObject = iface;
else
return E_NOINTERFACE;
return S_OK;
}
static ULONG WINAPI nodefact_AddRef(IXMLNodeFactory *iface)
{
return 2;
}
static ULONG WINAPI nodefact_Release(IXMLNodeFactory *iface)
{
return 1;
}
static HRESULT WINAPI nodefact_NotifyEvent(IXMLNodeFactory *iface,
IXMLNodeSource *pSource, XML_NODEFACTORY_EVENT iEvt)
{
return E_NOTIMPL;
}
static HRESULT WINAPI nodefact_BeginChildren(IXMLNodeFactory *iface,
IXMLNodeSource *pSource, XML_NODE_INFO *pNodeInfo)
{
return E_NOTIMPL;
}
static HRESULT WINAPI nodefact_EndChildren(IXMLNodeFactory *iface,
IXMLNodeSource *pSource, BOOL fEmpty, XML_NODE_INFO *pNodeInfo)
{
return E_NOTIMPL;
}
static HRESULT WINAPI nodefact_Error(IXMLNodeFactory *iface,
IXMLNodeSource *pSource, HRESULT hrErrorCode, USHORT cNumRecs,
XML_NODE_INFO **ppNodeInfo)
{
return E_NOTIMPL;
}
static HRESULT WINAPI nodefact_CreateNode(IXMLNodeFactory *iface, IXMLNodeSource *pSource,
PVOID pNodeParent, USHORT cNumRecs, XML_NODE_INFO **ppNodeInfo)
{
return E_NOTIMPL;
}
static const IXMLNodeFactoryVtbl nodefactoryVtbl =
{
nodefact_QueryInterface,
nodefact_AddRef,
nodefact_Release,
nodefact_NotifyEvent,
nodefact_BeginChildren,
nodefact_EndChildren,
nodefact_Error,
nodefact_CreateNode
};
static IXMLNodeFactory thenodefactory = { &nodefactoryVtbl };
static void create_test(void)
{
HRESULT hr;
IXMLParser *parser;
IXMLNodeFactory *nodefactory;
DWORD flags;
hr = CoCreateInstance(&CLSID_XMLParser30, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLParser, (void**)&parser);
@ -50,6 +121,23 @@ static void create_test(void)
flags = IXMLParser_GetFlags(parser);
ok(flags == XMLFLAG_SAX, "Expected 0 got %d\n", flags);
hr = IXMLParser_GetFactory(parser, NULL);
ok(hr == E_INVALIDARG, "Expected S_OK got 0x%08x\n", hr);
hr = IXMLParser_GetFactory(parser, &nodefactory);
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
ok(nodefactory == NULL, "expected NULL\n");
hr = IXMLParser_SetFactory(parser, &thenodefactory);
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
hr = IXMLParser_GetFactory(parser, &nodefactory);
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
ok(nodefactory == &thenodefactory, "expected NULL\n");
hr = IXMLParser_SetFactory(parser, NULL);
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);
hr = IXMLParser_SetFlags(parser, 0);
ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr);

View File

@ -46,6 +46,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msxml);
typedef struct _xmlparser
{
IXMLParser IXMLParser_iface;
IXMLNodeFactory *nodefactory;
LONG ref;
int flags;
@ -95,6 +96,9 @@ static ULONG WINAPI xmlparser_Release(IXMLParser* iface)
TRACE("(%p)->(%d)\n", This, ref);
if ( ref == 0 )
{
if(This->nodefactory)
IXMLNodeFactory_Release(This->nodefactory);
heap_free( This );
}
@ -106,18 +110,33 @@ static HRESULT WINAPI xmlparser_SetFactory(IXMLParser *iface, IXMLNodeFactory *p
{
xmlparser *This = impl_from_IXMLParser( iface );
FIXME("(%p %p)\n", This, pNodeFactory);
TRACE("(%p %p)\n", This, pNodeFactory);
return E_NOTIMPL;
if(This->nodefactory)
IXMLNodeFactory_Release(This->nodefactory);
This->nodefactory = pNodeFactory;
if(This->nodefactory)
IXMLNodeFactory_AddRef(This->nodefactory);
return S_OK;
}
static HRESULT WINAPI xmlparser_GetFactory(IXMLParser *iface, IXMLNodeFactory **ppNodeFactory)
{
xmlparser *This = impl_from_IXMLParser( iface );
FIXME("(%p, %p)\n", This, ppNodeFactory);
TRACE("(%p, %p)\n", This, ppNodeFactory);
return E_NOTIMPL;
if(!ppNodeFactory)
return E_INVALIDARG;
*ppNodeFactory = This->nodefactory;
if(*ppNodeFactory)
IXMLNodeFactory_AddRef(*ppNodeFactory);
return S_OK;
}
static HRESULT WINAPI xmlparser_Abort(IXMLParser *iface, BSTR bstrErrorInfo)
@ -415,6 +434,7 @@ HRESULT XMLParser_create(IUnknown* pUnkOuter, void**ppObj)
return E_OUTOFMEMORY;
This->IXMLParser_iface.lpVtbl = &xmlparser_vtbl;
This->nodefactory = NULL;
This->flags = 0;
This->ref = 1;