msxml3/domdoc: Add support for VT_ARRAY|VT_UI1 in domdoc_load().
This commit is contained in:
parent
17f72b8b67
commit
f730d13c84
|
@ -2113,6 +2113,8 @@ static HRESULT WINAPI domdoc_load(
|
|||
|
||||
TRACE("(%p)->(%s)\n", This, debugstr_variant(&source));
|
||||
|
||||
if (!isSuccessful)
|
||||
return E_POINTER;
|
||||
*isSuccessful = VARIANT_FALSE;
|
||||
|
||||
assert( &This->node );
|
||||
|
@ -2126,6 +2128,51 @@ static HRESULT WINAPI domdoc_load(
|
|||
if (!V_BSTRREF(&source)) return E_INVALIDARG;
|
||||
filename = *V_BSTRREF(&source);
|
||||
break;
|
||||
case VT_ARRAY|VT_UI1:
|
||||
{
|
||||
SAFEARRAY *psa = V_ARRAY(&source);
|
||||
char *str;
|
||||
LONG len;
|
||||
UINT dim = SafeArrayGetDim(psa);
|
||||
|
||||
switch (dim)
|
||||
{
|
||||
case 0:
|
||||
ERR("SAFEARRAY == NULL\n");
|
||||
hr = This->error = E_INVALIDARG;
|
||||
break;
|
||||
case 1:
|
||||
/* Only takes UTF-8 strings.
|
||||
* NOT NULL-terminated. */
|
||||
SafeArrayAccessData(psa, (void**)&str);
|
||||
SafeArrayGetUBound(psa, 1, &len);
|
||||
|
||||
if ((xmldoc = doparse(This, str, ++len, XML_CHAR_ENCODING_UTF8)))
|
||||
{
|
||||
hr = This->error = S_OK;
|
||||
*isSuccessful = VARIANT_TRUE;
|
||||
TRACE("parsed document %p\n", xmldoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
This->error = E_FAIL;
|
||||
TRACE("failed to parse document\n");
|
||||
}
|
||||
|
||||
SafeArrayUnaccessData(psa);
|
||||
|
||||
if(xmldoc)
|
||||
{
|
||||
xmldoc->_private = create_priv();
|
||||
return attach_xmldoc(This, xmldoc);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FIXME("unhandled SAFEARRAY dim: %d\n", dim);
|
||||
hr = This->error = E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VT_UNKNOWN:
|
||||
hr = IUnknown_QueryInterface(V_UNKNOWN(&source), &IID_IXMLDOMDocument3, (void**)&pNewDoc);
|
||||
if(hr == S_OK)
|
||||
|
|
|
@ -9946,13 +9946,15 @@ static void test_selection(void)
|
|||
static void test_load(void)
|
||||
{
|
||||
IXMLDOMDocument *doc;
|
||||
IXMLDOMNodeList *list;
|
||||
VARIANT_BOOL b;
|
||||
HANDLE hfile;
|
||||
VARIANT src;
|
||||
HRESULT hr;
|
||||
BOOL ret;
|
||||
BSTR path;
|
||||
BSTR path, bstr1, bstr2;
|
||||
DWORD written;
|
||||
void* ptr;
|
||||
|
||||
/* prepare a file */
|
||||
hfile = CreateFileA("test.xml", GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
|
@ -9992,6 +9994,96 @@ static void test_load(void)
|
|||
IXMLDOMDocument_Release(doc);
|
||||
|
||||
DeleteFileA("test.xml");
|
||||
|
||||
doc = create_document(&IID_IXMLDOMDocument);
|
||||
|
||||
hr = IXMLDOMDocument_loadXML(doc, _bstr_(szExampleXML), &b);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
ok(b == VARIANT_TRUE, "got %d\n", b);
|
||||
|
||||
hr = IXMLDOMDocument_selectNodes(doc, _bstr_("//*"), &list);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
bstr1 = _bstr_(list_to_string(list));
|
||||
|
||||
hr = IXMLDOMNodeList_reset(list);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
IXMLDOMDocument_Release(doc);
|
||||
|
||||
doc = create_document(&IID_IXMLDOMDocument);
|
||||
|
||||
VariantInit(&src);
|
||||
V_ARRAY(&src) = SafeArrayCreateVector(VT_UI1, 0, lstrlenA(szExampleXML));
|
||||
V_VT(&src) = VT_ARRAY|VT_UI1;
|
||||
ok(V_ARRAY(&src) != NULL, "SafeArrayCreateVector() returned NULL\n");
|
||||
ptr = NULL;
|
||||
hr = SafeArrayAccessData(V_ARRAY(&src), &ptr);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
ok(ptr != NULL, "SafeArrayAccessData() returned NULL\n");
|
||||
|
||||
memcpy(ptr, szExampleXML, lstrlenA(szExampleXML));
|
||||
hr = SafeArrayUnlock(V_ARRAY(&src));
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
hr = IXMLDOMDocument_load(doc, src, &b);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
ok(b == VARIANT_TRUE, "got %d\n", b);
|
||||
|
||||
hr = IXMLDOMDocument_selectNodes(doc, _bstr_("//*"), &list);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
bstr2 = _bstr_(list_to_string(list));
|
||||
|
||||
hr = IXMLDOMNodeList_reset(list);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
ok(lstrcmpW(bstr1, bstr2) == 0, "strings not equal: %s : %s\n",
|
||||
wine_dbgstr_w(bstr1), wine_dbgstr_w(bstr2));
|
||||
|
||||
IXMLDOMDocument_Release(doc);
|
||||
IXMLDOMNodeList_Release(list);
|
||||
VariantClear(&src);
|
||||
|
||||
/* UTF-16 isn't accepted */
|
||||
doc = create_document(&IID_IXMLDOMDocument);
|
||||
|
||||
V_ARRAY(&src) = SafeArrayCreateVector(VT_UI1, 0, lstrlenW(szComplete1) * sizeof(WCHAR));
|
||||
V_VT(&src) = VT_ARRAY|VT_UI1;
|
||||
ok(V_ARRAY(&src) != NULL, "SafeArrayCreateVector() returned NULL\n");
|
||||
ptr = NULL;
|
||||
hr = SafeArrayAccessData(V_ARRAY(&src), &ptr);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
ok(ptr != NULL, "SafeArrayAccessData() returned NULL\n");
|
||||
|
||||
memcpy(ptr, szComplete1, lstrlenW(szComplete1) * sizeof(WCHAR));
|
||||
hr = SafeArrayUnlock(V_ARRAY(&src));
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
hr = IXMLDOMDocument_load(doc, src, &b);
|
||||
todo_wine EXPECT_HR(hr, S_FALSE);
|
||||
todo_wine ok(b == VARIANT_FALSE, "got %d\n", b);
|
||||
|
||||
VariantClear(&src);
|
||||
|
||||
/* it doesn't like it as a VT_ARRAY|VT_UI2 either */
|
||||
V_ARRAY(&src) = SafeArrayCreateVector(VT_UI2, 0, lstrlenW(szComplete1));
|
||||
V_VT(&src) = VT_ARRAY|VT_UI2;
|
||||
ok(V_ARRAY(&src) != NULL, "SafeArrayCreateVector() returned NULL\n");
|
||||
ptr = NULL;
|
||||
hr = SafeArrayAccessData(V_ARRAY(&src), &ptr);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
ok(ptr != NULL, "SafeArrayAccessData() returned NULL\n");
|
||||
|
||||
memcpy(ptr, szComplete1, lstrlenW(szComplete1) * sizeof(WCHAR));
|
||||
hr = SafeArrayUnlock(V_ARRAY(&src));
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
hr = IXMLDOMDocument_load(doc, src, &b);
|
||||
todo_wine EXPECT_HR(hr, E_INVALIDARG);
|
||||
ok(b == VARIANT_FALSE, "got %d\n", b);
|
||||
|
||||
VariantClear(&src);
|
||||
IXMLDOMDocument_Release(doc);
|
||||
|
||||
free_bstrs();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue