Commit 6167c612 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

msxml3: Allow IXMLDOMDocument to save as another IXMLDOMDocument.

parent a1cce928
......@@ -1559,12 +1559,37 @@ static HRESULT WINAPI domdoc_save(
TRACE("(%p)->(var(vt %x, %s))\n", This, V_VT(&destination),
V_VT(&destination) == VT_BSTR ? debugstr_w(V_BSTR(&destination)) : NULL);
if(V_VT(&destination) != VT_BSTR)
if(V_VT(&destination) != VT_BSTR && V_VT(&destination) != VT_UNKNOWN)
{
FIXME("Unhandled vt %x\n", V_VT(&destination));
FIXME("Unhandled vt %d\n", V_VT(&destination));
return S_FALSE;
}
if(V_VT(&destination) == VT_UNKNOWN)
{
IUnknown *pUnk = V_UNKNOWN(&destination);
IXMLDOMDocument *pDocument;
ret = IXMLDOMDocument_QueryInterface(pUnk, &IID_IXMLDOMDocument2, (void**)&pDocument);
if(ret == S_OK)
{
BSTR bXML;
VARIANT_BOOL bSuccessful;
ret = IXMLDOMDocument_get_xml(iface, &bXML);
if(ret == S_OK)
{
ret = IXMLDOMDocument_loadXML(pDocument, bXML, &bSuccessful);
SysFreeString(bXML);
}
IXMLDOMDocument_Release(pDocument);
}
return ret;
}
handle = CreateFileW( V_BSTR(&destination), GENERIC_WRITE, 0,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if( handle == INVALID_HANDLE_VALUE )
......
......@@ -3013,6 +3013,60 @@ static void test_nodeTypeTests( void )
free_bstrs();
}
static void test_DocumentSaveToDocument(void)
{
IXMLDOMDocument *doc = NULL;
IXMLDOMDocument *doc2 = NULL;
IXMLDOMElement *pRoot;
HRESULT hr;
hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
if( hr != S_OK )
return;
hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc2 );
if( hr != S_OK )
{
IXMLDOMDocument_Release(doc);
return;
}
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
ok(hr == S_OK, "ret %08x\n", hr );
if(hr == S_OK)
{
hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
ok(hr == S_OK, "ret %08x\n", hr );
if(hr == S_OK)
{
VARIANT vDoc;
BSTR sOrig;
BSTR sNew;
V_VT(&vDoc) = VT_UNKNOWN;
V_UNKNOWN(&vDoc) = (IUnknown*)doc2;
hr = IXMLDOMDocument_save(doc, vDoc);
ok(hr == S_OK, "ret %08x\n", hr );
hr = IXMLDOMDocument_get_xml(doc, &sOrig);
ok(hr == S_OK, "ret %08x\n", hr );
hr = IXMLDOMDocument_get_xml(doc2, &sNew);
ok(hr == S_OK, "ret %08x\n", hr );
ok( !lstrcmpW( sOrig, sNew ), "New document is not the same as origial\n");
SysFreeString(sOrig);
SysFreeString(sNew);
}
}
IXMLDOMDocument_Release(doc2);
IXMLDOMDocument_Release(doc);
}
START_TEST(domdoc)
{
HRESULT r;
......@@ -3034,6 +3088,7 @@ START_TEST(domdoc)
test_cloneNode();
test_xmlTypes();
test_nodeTypeTests();
test_DocumentSaveToDocument();
CoUninitialize();
}
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