Commit 4610dc79 authored by Daniel Lehman's avatar Daniel Lehman Committed by Alexandre Julliard

msxml3: Support ISequentialStream in domdoc_transformNodeToObject.

parent 16ceadd2
......@@ -1524,8 +1524,10 @@ static HRESULT WINAPI domdoc_transformNodeToObject(
case VT_UNKNOWN:
case VT_DISPATCH:
{
ISequentialStream *stream;
IXMLDOMDocument *doc;
HRESULT hr;
BSTR str;
if (!V_UNKNOWN(&output))
return E_INVALIDARG;
......@@ -1535,7 +1537,6 @@ static HRESULT WINAPI domdoc_transformNodeToObject(
if (IUnknown_QueryInterface(V_UNKNOWN(&output), &IID_IXMLDOMDocument, (void **)&doc) == S_OK)
{
VARIANT_BOOL b;
BSTR str;
if (FAILED(hr = node_transform_node(&This->node, stylesheet, &str)))
return hr;
......@@ -1544,6 +1545,12 @@ static HRESULT WINAPI domdoc_transformNodeToObject(
SysFreeString(str);
return hr;
}
else if (IUnknown_QueryInterface(V_UNKNOWN(&output), &IID_ISequentialStream, (void**)&stream) == S_OK)
{
hr = node_transform_node_params(&This->node, stylesheet, NULL, stream, NULL);
ISequentialStream_Release(stream);
return hr;
}
else
{
FIXME("Unsupported destination type.\n");
......
......@@ -1512,9 +1512,9 @@ HRESULT node_transform_node_params(const xmlnode *This, IXMLDOMNode *stylesheet,
xmlnode *sheet;
if (!libxslt_handle) return E_NOTIMPL;
if (!stylesheet || !p) return E_INVALIDARG;
if (!stylesheet || (!p && !stream)) return E_INVALIDARG;
*p = NULL;
if (p) *p = NULL;
sheet = get_node_obj(stylesheet);
if(!sheet) return E_FAIL;
......@@ -1572,7 +1572,7 @@ HRESULT node_transform_node_params(const xmlnode *This, IXMLDOMNode *stylesheet,
else
xmlFreeDoc(sheet_doc);
if(!*p) *p = SysAllocStringLen(NULL, 0);
if (p && !*p) *p = SysAllocStringLen(NULL, 0);
return hr;
#else
......
......@@ -13030,7 +13030,12 @@ static void test_transformNodeToObject(void)
{
IUnknown transformdest = { &transformdestvtbl };
IXMLDOMDocument *doc, *doc2, *doc3;
ISequentialStream *sstream;
LARGE_INTEGER off;
WCHAR buffer[256];
IStream *istream;
VARIANT_BOOL b;
ULONG nread;
HRESULT hr;
VARIANT v;
......@@ -13063,6 +13068,51 @@ static void test_transformNodeToObject(void)
hr = IXMLDOMDocument_transformNodeToObject(doc, (IXMLDOMNode *)doc2, v);
ok(hr == S_OK, "Failed to transform node, hr %#x.\n", hr);
/* IStream */
istream = SHCreateMemStream(NULL, 0);
V_VT(&v) = VT_UNKNOWN;
V_UNKNOWN(&v) = (IUnknown *)istream;
hr = IXMLDOMDocument_transformNodeToObject(doc, (IXMLDOMNode *)doc2, v);
ok(hr == S_OK, "Failed to transform node, hr %#x.\n", hr);
off.QuadPart = 0;
hr = IStream_Seek(istream, off, STREAM_SEEK_SET, NULL);
ok(hr == S_OK, "Failed to seek, hr %#x.\n", hr);
nread = 0;
memset(buffer, 0xcc, sizeof(buffer));
hr = IStream_Read(istream, buffer, sizeof(buffer), &nread);
ok(hr == S_OK, "Failed to read, hr %#x.\n", hr);
buffer[nread/2] = 0;
ok(buffer[0] == 0xfeff, "got %x\n", buffer[0]);
ok(compareIgnoreReturns(&buffer[1], _bstr_(szTransformOutput)), "got output %s\n", wine_dbgstr_w(buffer));
IStream_Release(istream);
/* ISequentialStream */
istream = SHCreateMemStream(NULL, 0);
sstream = NULL;
hr = IStream_QueryInterface(istream, &IID_ISequentialStream, (void**)&sstream);
ok(hr == S_OK, "Failed to QI, hr %#x.\n", hr);
V_VT(&v) = VT_UNKNOWN;
V_UNKNOWN(&v) = (IUnknown *)sstream;
hr = IXMLDOMDocument_transformNodeToObject(doc, (IXMLDOMNode *)doc2, v);
ok(hr == S_OK, "Failed to transform node, hr %#x.\n", hr);
off.QuadPart = 0;
hr = IStream_Seek(istream, off, STREAM_SEEK_SET, NULL);
ok(hr == S_OK, "Failed to seek, hr %#x.\n", hr);
nread = 0;
memset(buffer, 0xcc, sizeof(buffer));
hr = ISequentialStream_Read(sstream, buffer, sizeof(buffer), &nread);
ok(hr == S_OK, "Failed to read, hr %#x.\n", hr);
buffer[nread/2] = 0;
ok(buffer[0] == 0xfeff, "got %x\n", buffer[0]);
ok(compareIgnoreReturns(&buffer[1], _bstr_(szTransformOutput)), "got output %s\n", wine_dbgstr_w(buffer));
ISequentialStream_Release(sstream);
IStream_Release(istream);
IXMLDOMDocument_Release(doc3);
IXMLDOMDocument_Release(doc2);
IXMLDOMDocument_Release(doc);
......
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