Commit 4f58e116 authored by Adam Martinson's avatar Adam Martinson Committed by Alexandre Julliard

msxml3: Add support for VT_BSTR|VT_BYREF in domdoc_save().

parent 5ab513bd
......@@ -2423,16 +2423,11 @@ static HRESULT WINAPI domdoc_save(
xmlNodePtr xmldecl;
HRESULT ret = S_OK;
TRACE("(%p)->(var(vt %d, %s))\n", This, V_VT(&destination),
V_VT(&destination) == VT_BSTR ? debugstr_w(V_BSTR(&destination)) : NULL);
TRACE("(%p)->(%s)\n", This, debugstr_variant(&destination));
if(V_VT(&destination) != VT_BSTR && V_VT(&destination) != VT_UNKNOWN)
switch (V_VT(&destination))
{
FIXME("Unhandled vt %d\n", V_VT(&destination));
return S_FALSE;
}
if(V_VT(&destination) == VT_UNKNOWN)
case VT_UNKNOWN:
{
IUnknown *pUnk = V_UNKNOWN(&destination);
IXMLDOMDocument2 *document;
......@@ -2468,11 +2463,14 @@ static HRESULT WINAPI domdoc_save(
}
}
}
else
break;
case VT_BSTR:
case VT_BSTR | VT_BYREF:
{
/* save with file path */
HANDLE handle = CreateFileW( V_BSTR(&destination), GENERIC_WRITE, 0,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
HANDLE handle = CreateFileW( (V_VT(&destination) & VT_BYREF)? *V_BSTRREF(&destination) : V_BSTR(&destination),
GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if( handle == INVALID_HANDLE_VALUE )
{
WARN("failed to create file\n");
......@@ -2488,6 +2486,12 @@ static HRESULT WINAPI domdoc_save(
return E_FAIL;
}
}
break;
default:
FIXME("Unhandled VARIANT: %s\n", debugstr_variant(&destination));
return S_FALSE;
}
xmldecl = xmldoc_unlink_xmldecl(get_doc(This));
if (xmlSaveDoc(ctx, get_doc(This)) == -1) ret = S_FALSE;
......
......@@ -6859,7 +6859,7 @@ static void test_save(void)
IXMLDOMDocument *doc, *doc2;
IXMLDOMElement *root;
VARIANT file, vDoc;
BSTR sOrig, sNew;
BSTR sOrig, sNew, filename;
char buffer[100];
DWORD read = 0;
HANDLE hfile;
......@@ -6909,6 +6909,25 @@ static void test_save(void)
hr = IXMLDOMDocument_save(doc, file);
EXPECT_HR(hr, S_OK);
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;
ReadFile(hfile, buffer, sizeof(buffer), &read, NULL);
ok(read != 0, "could not read file\n");
ok(buffer[0] != '<' || buffer[1] != '?', "File contains processing instruction\n");
CloseHandle(hfile);
DeleteFile("test.xml");
/* save to path VT_BSTR | VT_BYREF */
filename = _bstr_("test.xml");
V_VT(&file) = VT_BSTR | VT_BYREF;
V_BSTRREF(&file) = &filename;
hr = IXMLDOMDocument_save(doc, file);
EXPECT_HR(hr, S_OK);
IXMLDOMDocument_Release(doc);
hfile = CreateFileA("test.xml", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
......
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