From a878cd75dd68b49c3ea9c84a4a54e072269c4c40 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 24 Jan 2024 13:13:27 +1100 Subject: [PATCH] Added msxml3-write_out_doc patchset --- ...DOMDocument-mxwriter-destination-in-.patch | 129 ++++++++++++++++++ patches/msxml3-write_out_doc/definition | 3 + 2 files changed, 132 insertions(+) create mode 100644 patches/msxml3-write_out_doc/0001-msxml3-Write-to-DOMDocument-mxwriter-destination-in-.patch create mode 100644 patches/msxml3-write_out_doc/definition diff --git a/patches/msxml3-write_out_doc/0001-msxml3-Write-to-DOMDocument-mxwriter-destination-in-.patch b/patches/msxml3-write_out_doc/0001-msxml3-Write-to-DOMDocument-mxwriter-destination-in-.patch new file mode 100644 index 00000000..8d83685c --- /dev/null +++ b/patches/msxml3-write_out_doc/0001-msxml3-Write-to-DOMDocument-mxwriter-destination-in-.patch @@ -0,0 +1,129 @@ +From 9409a546aa17e178a6f1ce07cdaa8e0186429239 Mon Sep 17 00:00:00 2001 +From: Jefferson Carpenter +Date: Thu, 4 Nov 2021 22:30:05 +0000 +Subject: [PATCH] msxml3: Write to DOMDocument mxwriter destination in + endDocument. + +--- + dlls/msxml3/mxwriter.c | 41 +++++++++++++++++++++++++++++++++-- + dlls/msxml3/tests/saxreader.c | 1 + + 2 files changed, 40 insertions(+), 2 deletions(-) + +diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c +index 4a2844bcf08..8caf8979692 100644 +--- a/dlls/msxml3/mxwriter.c ++++ b/dlls/msxml3/mxwriter.c +@@ -189,6 +189,7 @@ typedef struct + BSTR element; + + IStream *dest; ++ IXMLDOMDocument *dest_doc; + + output_buffer buffer; + } mxwriter; +@@ -850,6 +851,7 @@ static ULONG WINAPI mxwriter_Release(IMXWriter *iface) + free_output_buffer(&This->buffer); + + if (This->dest) IStream_Release(This->dest); ++ if (This->dest_doc) IXMLDOMDocument_Release(This->dest_doc); + SysFreeString(This->version); + SysFreeString(This->encoding); + +@@ -914,6 +916,8 @@ static HRESULT WINAPI mxwriter_put_output(IMXWriter *iface, VARIANT dest) + { + if (This->dest) IStream_Release(This->dest); + This->dest = NULL; ++ if (This->dest_doc) IXMLDOMDocument_Release(This->dest_doc); ++ This->dest_doc = NULL; + close_output_buffer(This); + break; + } +@@ -929,12 +933,33 @@ static HRESULT WINAPI mxwriter_put_output(IMXWriter *iface, VARIANT dest) + + if (This->dest) IStream_Release(This->dest); + This->dest = stream; ++ if (This->dest_doc) IXMLDOMDocument_Release(This->dest_doc); ++ This->dest_doc = NULL; + break; + } + + FIXME("unhandled interface type for VT_UNKNOWN destination\n"); + return E_NOTIMPL; + } ++ case VT_DISPATCH: ++ { ++ IXMLDOMDocument *doc; ++ ++ hr = IDispatch_QueryInterface(V_DISPATCH(&dest), &IID_IXMLDOMDocument, (void**)&doc); ++ if (hr == S_OK) ++ { ++ close_output_buffer(This); ++ ++ if (This->dest) IStream_Release(This->dest); ++ This->dest = NULL; ++ if (This->dest_doc) IXMLDOMDocument_Release(This->dest_doc); ++ This->dest_doc = doc; ++ break; ++ } ++ ++ FIXME("unhandled interface type for VT_DISPATCH destination\n"); ++ return E_NOTIMPL; ++ } + default: + FIXME("unhandled destination type %s\n", debugstr_variant(&dest)); + return E_NOTIMPL; +@@ -1201,7 +1226,7 @@ static HRESULT WINAPI SAXContentHandler_putDocumentLocator( + { + mxwriter *This = impl_from_ISAXContentHandler( iface ); + FIXME("(%p)->(%p)\n", This, locator); +- return E_NOTIMPL; ++ return S_OK; + } + + static HRESULT WINAPI SAXContentHandler_startDocument(ISAXContentHandler *iface) +@@ -1239,10 +1264,21 @@ static HRESULT WINAPI SAXContentHandler_startDocument(ISAXContentHandler *iface) + + static HRESULT WINAPI SAXContentHandler_endDocument(ISAXContentHandler *iface) + { ++ HRESULT hr; ++ VARIANT dest; ++ VARIANT_BOOL success; + mxwriter *This = impl_from_ISAXContentHandler( iface ); + TRACE("(%p)\n", This); + This->prop_changed = FALSE; +- return flush_output_buffer(This); ++ ++ hr = flush_output_buffer(This); ++ if (FAILED(hr)) return hr; ++ ++ if (This->dest_doc) { ++ mxwriter_get_output(&This->IMXWriter_iface, &dest); ++ return IXMLDOMDocument_loadXML(This->dest_doc, V_BSTR(&dest), &success); ++ } ++ return S_OK; + } + + static HRESULT WINAPI SAXContentHandler_startPrefixMapping( +@@ -2630,6 +2666,7 @@ HRESULT MXWriter_create(MSXML_VERSION version, void **ppObj) + This->newline = FALSE; + + This->dest = NULL; ++ This->dest_doc = NULL; + + hr = init_output_buffer(This->xml_enc, &This->buffer); + if (hr != S_OK) { +diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c +index e123d4eba5a..f933ffe85a2 100644 +--- a/dlls/msxml3/tests/saxreader.c ++++ b/dlls/msxml3/tests/saxreader.c +@@ -4563,6 +4563,7 @@ static void test_mxwriter_domdoc(void) + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ++ if (!node) return; + hr = IXMLDOMNode_get_nodeName(node, &str); + todo_wine { + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); +-- +2.43.0 + diff --git a/patches/msxml3-write_out_doc/definition b/patches/msxml3-write_out_doc/definition new file mode 100644 index 00000000..946bf7c4 --- /dev/null +++ b/patches/msxml3-write_out_doc/definition @@ -0,0 +1,3 @@ +Fixes: [51965] msxml3: IMXWrite::output to support DOMDocument. + +#TODO: Update tests.