Added msxml3-write_out_doc patchset

This commit is contained in:
Alistair Leslie-Hughes 2024-01-24 13:13:27 +11:00
parent 78b6fcffa8
commit a878cd75dd
2 changed files with 132 additions and 0 deletions

View File

@ -0,0 +1,129 @@
From 9409a546aa17e178a6f1ce07cdaa8e0186429239 Mon Sep 17 00:00:00 2001
From: Jefferson Carpenter <jeffersoncarpenter2@gmail.com>
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

View File

@ -0,0 +1,3 @@
Fixes: [51965] msxml3: IMXWrite::output to support DOMDocument.
#TODO: Update tests.