Signed-off-by: Daniel Lehman dlehman25@gmail.com --- i have another version that doesn't skip the BOM in node_transform_write_to_bstr, if preferred --- dlls/msxml3/domdoc.c | 16 +++++++++++++++- dlls/msxml3/tests/domdoc.c | 23 +++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index d447bd2b1d8..de5ea51a675 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -1525,7 +1525,9 @@ static HRESULT WINAPI domdoc_transformNodeToObject( case VT_DISPATCH: { IXMLDOMDocument *doc; + IStream *stream; 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,19 @@ static HRESULT WINAPI domdoc_transformNodeToObject( SysFreeString(str); return hr; } + else if (IUnknown_QueryInterface(V_UNKNOWN(&output), &IID_IStream, (void**)&stream) == S_OK) + { + if (SUCCEEDED(hr = node_transform_node(&This->node, stylesheet, &str))) + { + static const char utf16BOM[] = {0xff,0xfe}; + if (SUCCEEDED(hr = IStream_Write( stream, utf16BOM, sizeof(utf16BOM), NULL))) + hr = IStream_Write( stream, str, SysStringByteLen(str), NULL ); + SysFreeString(str); + } + + IStream_Release(stream); + return hr; + } else { FIXME("Unsupported destination type.\n"); diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 101a775ca36..3ed08b04b30 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13030,7 +13030,11 @@ static void test_transformNodeToObject(void) { IUnknown transformdest = { &transformdestvtbl }; IXMLDOMDocument *doc, *doc2, *doc3; + LARGE_INTEGER off; + WCHAR buffer[256]; + IStream *istream; VARIANT_BOOL b; + ULONG nread; HRESULT hr; VARIANT v;
@@ -13063,6 +13067,25 @@ 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 = 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); + IXMLDOMDocument_Release(doc3); IXMLDOMDocument_Release(doc2); IXMLDOMDocument_Release(doc);
On 11/11/20 10:36 AM, Daniel Lehman wrote:
Signed-off-by: Daniel Lehman dlehman25@gmail.com
i have another version that doesn't skip the BOM in node_transform_write_to_bstr, if preferred
dlls/msxml3/domdoc.c | 16 +++++++++++++++- dlls/msxml3/tests/domdoc.c | 23 +++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-)
Is it possible to reuse node_transform_node_params() that supports stream output? BSTR case workaround implies that output should already contain BOM.
Or do you mean node_transform_node_params() is already broken for BSTR output, because it skips BOM?
Is it possible to reuse node_transform_node_params() that supports stream output? BSTR case workaround implies that output should already contain BOM.
my other version uses node_transform_node_params and leaves the BOM that's already there. i'll send it separately
Or do you mean node_transform_node_params() is already broken for BSTR output, because it skips BOM?
i didn't think it was broken. it needs to skip the BOM for other cases