Commit a28ace9a authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Support more variant types in putProperty().

parent a41446b1
...@@ -2602,99 +2602,85 @@ static HRESULT internal_parseURL( ...@@ -2602,99 +2602,85 @@ static HRESULT internal_parseURL(
return detach_bsc(bsc); return detach_bsc(bsc);
} }
static HRESULT internal_putProperty( static HRESULT saxreader_put_handler_from_variant(saxreader *This, enum saxhandler_type type, const VARIANT *v, BOOL vb)
saxreader* This,
const WCHAR *prop,
VARIANT value,
BOOL vbInterface)
{ {
TRACE("(%p)->(%s %s)\n", This, debugstr_w(prop), debugstr_variant(&value)); const IID *riid;
if(!memcmp(prop, PropertyDeclHandlerW, sizeof(PropertyDeclHandlerW)))
{
if(This->isParsing) return E_FAIL;
switch (V_VT(&value)) if (V_VT(v) == VT_EMPTY)
{ return saxreader_put_handler(This, type, NULL, vb);
case VT_EMPTY:
saxreader_put_handler(This, SAXDeclHandler, NULL, vbInterface);
break;
case VT_UNKNOWN:
{
IUnknown *handler = NULL;
if (V_UNKNOWN(&value)) switch (type)
{ {
HRESULT hr; case SAXDeclHandler:
riid = vb ? &IID_IVBSAXDeclHandler : &IID_ISAXDeclHandler;
break;
case SAXLexicalHandler:
riid = vb ? &IID_IVBSAXLexicalHandler : &IID_ISAXLexicalHandler;
break;
default:
ERR("wrong handler type %d\n", type);
return E_FAIL;
}
if (vbInterface) switch (V_VT(v))
hr = IUnknown_QueryInterface(V_UNKNOWN(&value), &IID_IVBSAXDeclHandler, (void**)&handler); {
else case VT_DISPATCH:
hr = IUnknown_QueryInterface(V_UNKNOWN(&value), &IID_ISAXDeclHandler, (void**)&handler); case VT_UNKNOWN:
if (FAILED(hr)) return hr; {
} IUnknown *handler = NULL;
saxreader_put_handler(This, SAXDeclHandler, handler, vbInterface); if (V_UNKNOWN(v))
if (handler) IUnknown_Release(handler); {
break; HRESULT hr = IUnknown_QueryInterface(V_UNKNOWN(v), riid, (void**)&handler);
} if (FAILED(hr)) return hr;
default:
return E_INVALIDARG;
} }
return S_OK; saxreader_put_handler(This, type, handler, vb);
if (handler) IUnknown_Release(handler);
break;
}
default:
ERR("value type %d not supported\n", V_VT(v));
return E_INVALIDARG;
} }
if(!memcmp(prop, PropertyLexicalHandlerW, sizeof(PropertyLexicalHandlerW))) return S_OK;
{ }
if(This->isParsing) return E_FAIL;
switch (V_VT(&value)) static HRESULT internal_putProperty(
{ saxreader* This,
case VT_EMPTY: const WCHAR *prop,
saxreader_put_handler(This, SAXLexicalHandler, NULL, vbInterface); VARIANT value,
break; BOOL vbInterface)
case VT_UNKNOWN: {
{ VARIANT *v;
IUnknown *handler = NULL;
if (V_UNKNOWN(&value)) TRACE("(%p)->(%s %s)\n", This, debugstr_w(prop), debugstr_variant(&value));
{
HRESULT hr;
if (vbInterface) if (This->isParsing) return E_FAIL;
hr = IUnknown_QueryInterface(V_UNKNOWN(&value), &IID_IVBSAXLexicalHandler, (void**)&handler);
else
hr = IUnknown_QueryInterface(V_UNKNOWN(&value), &IID_ISAXLexicalHandler, (void**)&handler);
if (FAILED(hr)) return hr;
}
saxreader_put_handler(This, SAXLexicalHandler, handler, vbInterface); v = V_VT(&value) == (VT_VARIANT|VT_BYREF) ? V_VARIANTREF(&value) : &value;
if (handler) IUnknown_Release(handler); if(!memcmp(prop, PropertyDeclHandlerW, sizeof(PropertyDeclHandlerW)))
break; return saxreader_put_handler_from_variant(This, SAXDeclHandler, v, vbInterface);
}
default:
return E_INVALIDARG;
}
return S_OK; if(!memcmp(prop, PropertyLexicalHandlerW, sizeof(PropertyLexicalHandlerW)))
} return saxreader_put_handler_from_variant(This, SAXLexicalHandler, v, vbInterface);
if(!memcmp(prop, PropertyMaxXMLSizeW, sizeof(PropertyMaxXMLSizeW))) if(!memcmp(prop, PropertyMaxXMLSizeW, sizeof(PropertyMaxXMLSizeW)))
{ {
if (V_VT(&value) == VT_I4 && V_I4(&value) == 0) return S_OK; if (V_VT(v) == VT_I4 && V_I4(v) == 0) return S_OK;
FIXME("(%p)->(%s): max-xml-size unsupported\n", This, debugstr_variant(&value)); FIXME("(%p)->(%s): max-xml-size unsupported\n", This, debugstr_variant(v));
return E_NOTIMPL; return E_NOTIMPL;
} }
if(!memcmp(prop, PropertyMaxElementDepthW, sizeof(PropertyMaxElementDepthW))) if(!memcmp(prop, PropertyMaxElementDepthW, sizeof(PropertyMaxElementDepthW)))
{ {
if (V_VT(&value) == VT_I4 && V_I4(&value) == 0) return S_OK; if (V_VT(v) == VT_I4 && V_I4(v) == 0) return S_OK;
FIXME("(%p)->(%s): max-element-depth unsupported\n", This, debugstr_variant(&value)); FIXME("(%p)->(%s): max-element-depth unsupported\n", This, debugstr_variant(v));
return E_NOTIMPL; return E_NOTIMPL;
} }
FIXME("(%p)->(%s:%s): unsupported property\n", This, debugstr_w(prop), debugstr_variant(&value)); FIXME("(%p)->(%s:%s): unsupported property\n", This, debugstr_w(prop), debugstr_variant(v));
if(!memcmp(prop, PropertyCharsetW, sizeof(PropertyCharsetW))) if(!memcmp(prop, PropertyCharsetW, sizeof(PropertyCharsetW)))
return E_NOTIMPL; return E_NOTIMPL;
......
...@@ -2523,6 +2523,7 @@ static void test_saxreader_properties(void) ...@@ -2523,6 +2523,7 @@ static void test_saxreader_properties(void)
while (ptr->prop_name) while (ptr->prop_name)
{ {
VARIANT varref;
LONG ref; LONG ref;
init_saxlexicalhandler(&lexicalhandler, S_OK); init_saxlexicalhandler(&lexicalhandler, S_OK);
...@@ -2535,6 +2536,7 @@ static void test_saxreader_properties(void) ...@@ -2535,6 +2536,7 @@ static void test_saxreader_properties(void)
ok(V_VT(&v) == VT_UNKNOWN, "got %d\n", V_VT(&v)); ok(V_VT(&v) == VT_UNKNOWN, "got %d\n", V_VT(&v));
ok(V_UNKNOWN(&v) == NULL, "got %p\n", V_UNKNOWN(&v)); ok(V_UNKNOWN(&v) == NULL, "got %p\n", V_UNKNOWN(&v));
/* VT_UNKNOWN */
V_VT(&v) = VT_UNKNOWN; V_VT(&v) = VT_UNKNOWN;
V_UNKNOWN(&v) = ptr->iface; V_UNKNOWN(&v) = ptr->iface;
ref = get_refcount(ptr->iface); ref = get_refcount(ptr->iface);
...@@ -2542,6 +2544,36 @@ static void test_saxreader_properties(void) ...@@ -2542,6 +2544,36 @@ static void test_saxreader_properties(void)
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
ok(ref < get_refcount(ptr->iface), "expected inreased refcount\n"); ok(ref < get_refcount(ptr->iface), "expected inreased refcount\n");
/* VT_DISPATCH */
V_VT(&v) = VT_DISPATCH;
V_UNKNOWN(&v) = ptr->iface;
ref = get_refcount(ptr->iface);
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
EXPECT_HR(hr, S_OK);
ok(ref == get_refcount(ptr->iface), "got wrong refcount %d, expected %d\n", get_refcount(ptr->iface), ref);
/* VT_VARIANT|VT_BYREF with VT_UNKNOWN in referenced variant */
V_VT(&varref) = VT_UNKNOWN;
V_UNKNOWN(&varref) = ptr->iface;
V_VT(&v) = VT_VARIANT|VT_BYREF;
V_VARIANTREF(&v) = &varref;
ref = get_refcount(ptr->iface);
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
EXPECT_HR(hr, S_OK);
ok(ref == get_refcount(ptr->iface), "got wrong refcount %d, expected %d\n", get_refcount(ptr->iface), ref);
/* VT_VARIANT|VT_BYREF with VT_DISPATCH in referenced variant */
V_VT(&varref) = VT_DISPATCH;
V_UNKNOWN(&varref) = ptr->iface;
V_VT(&v) = VT_VARIANT|VT_BYREF;
V_VARIANTREF(&v) = &varref;
ref = get_refcount(ptr->iface);
hr = ISAXXMLReader_putProperty(reader, _bstr_(ptr->prop_name), v);
EXPECT_HR(hr, S_OK);
ok(ref == get_refcount(ptr->iface), "got wrong refcount %d, expected %d\n", get_refcount(ptr->iface), ref);
V_VT(&v) = VT_EMPTY; V_VT(&v) = VT_EMPTY;
V_UNKNOWN(&v) = (IUnknown*)0xdeadbeef; V_UNKNOWN(&v) = (IUnknown*)0xdeadbeef;
......
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