xmllite: Support get/set for XmlResolver property.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-03-14 09:37:46 +03:00 committed by Alexandre Julliard
parent e625e86ee1
commit aaac0db600
2 changed files with 79 additions and 1 deletions

View File

@ -243,6 +243,7 @@ typedef struct
XmlReaderResumeState resumestate;
XmlNodeType nodetype;
DtdProcessing dtdmode;
IXmlResolver *resolver;
UINT line, pos; /* reader position in XML stream */
struct list attrs; /* attributes list for current node */
struct attribute *attr; /* current attribute */
@ -2472,6 +2473,7 @@ static ULONG WINAPI xmlreader_Release(IXmlReader *iface)
{
IMalloc *imalloc = This->imalloc;
if (This->input) IUnknown_Release(&This->input->IXmlReaderInput_iface);
if (This->resolver) IXmlResolver_Release(This->resolver);
reader_clear_attrs(This);
reader_clear_elements(This);
reader_free_strvalues(This);
@ -2556,6 +2558,11 @@ static HRESULT WINAPI xmlreader_GetProperty(IXmlReader* iface, UINT property, LO
switch (property)
{
case XmlReaderProperty_XmlResolver:
*value = (LONG_PTR)This->resolver;
if (This->resolver)
IXmlResolver_AddRef(This->resolver);
break;
case XmlReaderProperty_DtdProcessing:
*value = This->dtdmode;
break;
@ -2574,10 +2581,17 @@ static HRESULT WINAPI xmlreader_SetProperty(IXmlReader* iface, UINT property, LO
{
xmlreader *This = impl_from_IXmlReader(iface);
TRACE("(%p)->(%s %lu)\n", This, debugstr_reader_prop(property), value);
TRACE("(%p)->(%s 0x%lx)\n", This, debugstr_reader_prop(property), value);
switch (property)
{
case XmlReaderProperty_XmlResolver:
if (This->resolver)
IXmlResolver_Release(This->resolver);
This->resolver = (IXmlResolver*)value;
if (This->resolver)
IXmlResolver_AddRef(This->resolver);
break;
case XmlReaderProperty_DtdProcessing:
if (value < 0 || value > _DtdProcessing_Last) return E_INVALIDARG;
This->dtdmode = value;
@ -2974,6 +2988,7 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc)
reader->instate = XmlReadInState_Initial;
reader->resumestate = XmlReadResumeState_Initial;
reader->dtdmode = DtdProcessing_Prohibit;
reader->resolver = NULL;
reader->line = reader->pos = 0;
reader->imalloc = imalloc;
if (imalloc) IMalloc_AddRef(imalloc);

View File

@ -386,8 +386,51 @@ static BOOL init_pointers(void)
return TRUE;
}
static HRESULT WINAPI resolver_QI(IXmlResolver *iface, REFIID riid, void **obj)
{
ok(0, "unexpected call, riid %s\n", wine_dbgstr_guid(riid));
if (IsEqualIID(riid, &IID_IXmlResolver) || IsEqualIID(riid, &IID_IUnknown))
{
*obj = iface;
IXmlResolver_AddRef(iface);
return S_OK;
}
*obj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI resolver_AddRef(IXmlResolver *iface)
{
return 2;
}
static ULONG WINAPI resolver_Release(IXmlResolver *iface)
{
return 1;
}
static HRESULT WINAPI resolver_ResolveUri(IXmlResolver *iface, const WCHAR *base_uri,
const WCHAR *public_id, const WCHAR *system_id, IUnknown **input)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static const IXmlResolverVtbl resolvervtbl =
{
resolver_QI,
resolver_AddRef,
resolver_Release,
resolver_ResolveUri
};
static IXmlResolver testresolver = { &resolvervtbl };
static void test_reader_create(void)
{
IXmlResolver *resolver;
HRESULT hr;
IXmlReader *reader;
IUnknown *input;
@ -411,6 +454,26 @@ static void test_reader_create(void)
ok(hr == S_FALSE, "got %08x\n", hr);
ok(nodetype == XmlNodeType_None, "got %d\n", nodetype);
resolver = (void*)0xdeadbeef;
hr = IXmlReader_GetProperty(reader, XmlReaderProperty_XmlResolver, (LONG_PTR*)&resolver);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(resolver == NULL, "got %p\n", resolver);
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver, 0);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver, (LONG_PTR)&testresolver);
ok(hr == S_OK, "got 0x%08x\n", hr);
resolver = NULL;
hr = IXmlReader_GetProperty(reader, XmlReaderProperty_XmlResolver, (LONG_PTR*)&resolver);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(resolver == &testresolver, "got %p\n", resolver);
IXmlResolver_Release(resolver);
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver, 0);
ok(hr == S_OK, "got 0x%08x\n", hr);
dtd = 2;
hr = IXmlReader_GetProperty(reader, XmlReaderProperty_DtdProcessing, (LONG_PTR*)&dtd);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);