Commit 49eac508 authored by Gijs Vermeulen's avatar Gijs Vermeulen Committed by Alexandre Julliard

msxml3: Support retrieving more than one element in IEnumVARIANT::Next() for IXMLElementCollection.

parent 4ad0e748
...@@ -656,7 +656,7 @@ static void test_xmlelem_collection(void) ...@@ -656,7 +656,7 @@ static void test_xmlelem_collection(void)
WCHAR path[MAX_PATH]; WCHAR path[MAX_PATH];
LONG length, type; LONG length, type;
ULONG num_vars; ULONG num_vars;
VARIANT var, dummy, vIndex, vName; VARIANT var[3], dummy, vIndex, vName;
BSTR url, str; BSTR url, str;
static const CHAR szBankXML[] = "bank.xml"; static const CHAR szBankXML[] = "bank.xml";
static const WCHAR szNumber[] = {'N','U','M','B','E','R',0}; static const WCHAR szNumber[] = {'N','U','M','B','E','R',0};
...@@ -738,16 +738,16 @@ static void test_xmlelem_collection(void) ...@@ -738,16 +738,16 @@ static void test_xmlelem_collection(void)
IUnknown_Release(unk); IUnknown_Release(unk);
/* <Number>1234</Number> */ /* <Number>1234</Number> */
hr = IEnumVARIANT_Next(enumVar, 1, &var, &num_vars); hr = IEnumVARIANT_Next(enumVar, 1, &var[0], &num_vars);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(V_VT(&var) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var)); ok(V_VT(&var[0]) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var[0]));
ok(num_vars == 1, "Expected 1, got %d\n", num_vars); ok(num_vars == 1, "Expected 1, got %d\n", num_vars);
hr = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IXMLElement, (LPVOID *)&child); hr = IDispatch_QueryInterface(V_DISPATCH(&var[0]), &IID_IXMLElement, (LPVOID *)&child);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(child != NULL, "Expected non-NULL child\n"); ok(child != NULL, "Expected non-NULL child\n");
VariantClear(&var); VariantClear(&var[0]);
hr = IXMLElement_get_type(child, &type); hr = IXMLElement_get_type(child, &type);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
...@@ -760,11 +760,13 @@ static void test_xmlelem_collection(void) ...@@ -760,11 +760,13 @@ static void test_xmlelem_collection(void)
IXMLElement_Release(child); IXMLElement_Release(child);
/* <Name>Captain Ahab</Name> */ /* <Name>Captain Ahab</Name> */
hr = IEnumVARIANT_Next(enumVar, 1, &var, &num_vars); hr = IEnumVARIANT_Next(enumVar, 1, &var[0], &num_vars);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(V_VT(&var) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var)); ok(V_VT(&var[0]) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var[0]));
ok(num_vars == 1, "Expected 1, got %d\n", num_vars); ok(num_vars == 1, "Expected 1, got %d\n", num_vars);
VariantClear(&var[0]);
/* try advance further, no children left */ /* try advance further, no children left */
V_VT(&dummy) = VT_I4; V_VT(&dummy) = VT_I4;
hr = IEnumVARIANT_Next(enumVar, 1, &dummy, &num_vars); hr = IEnumVARIANT_Next(enumVar, 1, &dummy, &num_vars);
...@@ -777,11 +779,42 @@ static void test_xmlelem_collection(void) ...@@ -777,11 +779,42 @@ static void test_xmlelem_collection(void)
ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr); ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
ok(V_VT(&dummy) == VT_EMPTY, "Expected 0, got %d\n", V_VT(&dummy)); ok(V_VT(&dummy) == VT_EMPTY, "Expected 0, got %d\n", V_VT(&dummy));
hr = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IXMLElement, (LPVOID *)&child); hr = IEnumVARIANT_Reset(enumVar);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
/* retrieve multiple elements */
hr = IEnumVARIANT_Next(enumVar, 2, var, &num_vars);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(V_VT(&var[0]) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var[0]));
ok(V_VT(&var[1]) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var[1]));
ok(num_vars == 2, "Expected 2, got %d\n", num_vars);
V_VT(&dummy) = VT_I4;
hr = IEnumVARIANT_Next(enumVar, 1, &dummy, &num_vars);
ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
ok(V_VT(&dummy) == VT_EMPTY, "Expected 0, got %d\n", V_VT(&dummy));
ok(num_vars == 0, "Expected 0, got %d\n", num_vars);
hr = IEnumVARIANT_Reset(enumVar);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
VariantClear(&var[1]);
VariantClear(&var[0]);
/* request more elements than available */
hr = IEnumVARIANT_Next(enumVar, 3, var, &num_vars);
ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
ok(V_VT(&var[0]) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var[0]));
ok(V_VT(&var[1]) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var[1]));
ok(V_VT(&var[2]) == VT_EMPTY, "Expected 0, got %d\n", V_VT(&var[2]));
ok(num_vars == 2, "Expected 2, got %d\n", num_vars);
hr = IDispatch_QueryInterface(V_DISPATCH(&var[1]), &IID_IXMLElement, (LPVOID *)&child);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(child != NULL, "Expected non-NULL child\n"); ok(child != NULL, "Expected non-NULL child\n");
VariantClear(&var); VariantClear(&var[1]);
VariantClear(&var[0]);
hr = IXMLElement_get_type(child, &type); hr = IXMLElement_get_type(child, &type);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
......
...@@ -753,28 +753,32 @@ static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Next( ...@@ -753,28 +753,32 @@ static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Next(
IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *fetched) IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *fetched)
{ {
xmlelem_collection *This = impl_from_IEnumVARIANT(iface); xmlelem_collection *This = impl_from_IEnumVARIANT(iface);
xmlNodePtr ptr = This->current; HRESULT hr;
TRACE("(%p)->(%d %p %p)\n", This, celt, rgVar, fetched); TRACE("(%p)->(%d %p %p)\n", This, celt, rgVar, fetched);
if (!rgVar) if (!rgVar)
return E_INVALIDARG; return E_INVALIDARG;
/* FIXME: handle celt */ if (fetched) *fetched = 0;
if (fetched)
*fetched = 1;
if (This->current) if (!This->current)
This->current = This->current->next;
else
{ {
V_VT(rgVar) = VT_EMPTY; V_VT(rgVar) = VT_EMPTY;
if (fetched) *fetched = 0;
return S_FALSE; return S_FALSE;
} }
V_VT(rgVar) = VT_DISPATCH; while (celt > 0 && This->current)
return XMLElement_create(ptr, (LPVOID *)&V_DISPATCH(rgVar), FALSE); {
V_VT(rgVar) = VT_DISPATCH;
hr = XMLElement_create(This->current, (void **)&V_DISPATCH(rgVar), FALSE);
if (FAILED(hr)) return hr;
This->current = This->current->next;
if (--celt && This->current) ++rgVar;
if (fetched) ++*fetched;
}
return celt == 0 ? S_OK : S_FALSE;
} }
static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Skip( static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Skip(
......
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