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

msxml3: Support VT_BSTR|VT_BYREF as source in load().

parent 59f64b28
......@@ -2104,7 +2104,7 @@ static HRESULT doread( domdoc *This, LPWSTR filename )
static HRESULT WINAPI domdoc_load(
IXMLDOMDocument3 *iface,
VARIANT xmlSource,
VARIANT source,
VARIANT_BOOL* isSuccessful )
{
domdoc *This = impl_from_IXMLDOMDocument3( iface );
......@@ -2114,19 +2114,23 @@ static HRESULT WINAPI domdoc_load(
IStream *pStream = NULL;
xmlDocPtr xmldoc;
TRACE("(%p)->type %d\n", This, V_VT(&xmlSource) );
TRACE("(%p)->(%s)\n", This, debugstr_variant(&source));
*isSuccessful = VARIANT_FALSE;
assert( &This->node );
switch( V_VT(&xmlSource) )
switch( V_VT(&source) )
{
case VT_BSTR:
filename = V_BSTR(&xmlSource);
filename = V_BSTR(&source);
break;
case VT_BSTR|VT_BYREF:
if (!V_BSTRREF(&source)) return E_INVALIDARG;
filename = *V_BSTRREF(&source);
break;
case VT_UNKNOWN:
hr = IUnknown_QueryInterface(V_UNKNOWN(&xmlSource), &IID_IXMLDOMDocument3, (void**)&pNewDoc);
hr = IUnknown_QueryInterface(V_UNKNOWN(&source), &IID_IXMLDOMDocument3, (void**)&pNewDoc);
if(hr == S_OK)
{
if(pNewDoc)
......@@ -2141,7 +2145,7 @@ static HRESULT WINAPI domdoc_load(
return hr;
}
}
hr = IUnknown_QueryInterface(V_UNKNOWN(&xmlSource), &IID_IStream, (void**)&pStream);
hr = IUnknown_QueryInterface(V_UNKNOWN(&source), &IID_IStream, (void**)&pStream);
if(hr == S_OK)
{
IPersistStream *pDocStream;
......@@ -2170,14 +2174,12 @@ static HRESULT WINAPI domdoc_load(
else
{
/* ISequentialStream */
FIXME("Unknown type not supported (%d) (%p)(%p)\n", hr, pNewDoc, V_UNKNOWN(&xmlSource)->lpVtbl);
FIXME("Unknown type not supported (%d) (%p)(%p)\n", hr, pNewDoc, V_UNKNOWN(&source)->lpVtbl);
}
break;
default:
FIXME("VT type not supported (%d)\n", V_VT(&xmlSource));
}
TRACE("filename (%s)\n", debugstr_w(filename));
FIXME("VT type not supported (%d)\n", V_VT(&source));
}
if ( filename )
{
......
......@@ -286,6 +286,9 @@ const char *debugstr_variant(const VARIANT *v)
return wine_dbg_sprintf("{VT_UNKNOWN: %p}", V_UNKNOWN(v));
case VT_UINT:
return wine_dbg_sprintf("{VT_UINT: %u}", V_UINT(v));
case VT_BSTR|VT_BYREF:
return wine_dbg_sprintf("{VT_BSTR|VT_BYREF: ptr %p, data %s}",
V_BSTRREF(v), V_BSTRREF(v) ? debugstr_w(*V_BSTRREF(v)) : NULL);
default:
return wine_dbg_sprintf("{vt %d}", V_VT(v));
}
......
......@@ -5686,7 +5686,7 @@ static void test_save(void)
IXMLDOMDocument_Release(doc);
hfile = CreateFile("test.xml", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
hfile = CreateFileA("test.xml", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
ok(hfile != INVALID_HANDLE_VALUE, "Could not open file: %u\n", GetLastError());
if(hfile == INVALID_HANDLE_VALUE) return;
......@@ -6097,7 +6097,7 @@ static void test_TransformWithLoadingLocalFile(void)
GetTempPathA(MAX_PATH, lpPathBuffer);
strcat(lpPathBuffer, "customers.xml" );
file = CreateFile(lpPathBuffer, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
file = CreateFileA(lpPathBuffer, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
if(file == INVALID_HANDLE_VALUE)
return;
......@@ -8609,6 +8609,58 @@ static void test_selection(void)
free_bstrs();
}
static void test_load(void)
{
IXMLDOMDocument *doc;
VARIANT_BOOL b;
HANDLE hfile;
VARIANT src;
HRESULT hr;
BOOL ret;
BSTR path;
DWORD written;
/* prepare a file */
hfile = CreateFileA("test.xml", GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
ok(hfile != INVALID_HANDLE_VALUE, "failed to create test file\n");
if(hfile == INVALID_HANDLE_VALUE) return;
ret = WriteFile(hfile, szNonUnicodeXML, sizeof(szNonUnicodeXML)-1, &written, NULL);
ok(ret, "WriteFile failed\n");
CloseHandle(hfile);
doc = create_document(&IID_IXMLDOMDocument);
path = _bstr_("test.xml");
/* load from path: VT_BSTR */
V_VT(&src) = VT_BSTR;
V_BSTR(&src) = path;
hr = IXMLDOMDocument_load(doc, src, &b);
EXPECT_HR(hr, S_OK);
ok(b == VARIANT_TRUE, "got %d\n", b);
/* load from a path: VT_BSTR|VT_BYREF */
V_VT(&src) = VT_BSTR | VT_BYREF;
V_BSTRREF(&src) = &path;
hr = IXMLDOMDocument_load(doc, src, &b);
EXPECT_HR(hr, S_OK);
ok(b == VARIANT_TRUE, "got %d\n", b);
/* load from a path: VT_BSTR|VT_BYREF, null ptr */
V_VT(&src) = VT_BSTR | VT_BYREF;
V_BSTRREF(&src) = NULL;
hr = IXMLDOMDocument_load(doc, src, &b);
EXPECT_HR(hr, E_INVALIDARG);
ok(b == VARIANT_FALSE, "got %d\n", b);
IXMLDOMDocument_Release(doc);
DeleteFileA("test.xml");
free_bstrs();
}
START_TEST(domdoc)
{
IXMLDOMDocument *doc;
......@@ -8680,6 +8732,7 @@ START_TEST(domdoc)
test_get_nodeTypeString();
test_get_attributes();
test_selection();
test_load();
test_xsltemplate();
......
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