msxml3: Return stream reference from get_output() if stream is set.

This commit is contained in:
Nikolay Sivov 2012-06-22 22:36:04 +04:00 committed by Alexandre Julliard
parent 729afb18fe
commit 6ab3f1ae99
2 changed files with 21 additions and 3 deletions

View File

@ -755,6 +755,8 @@ static HRESULT WINAPI mxwriter_get_output(IMXWriter *iface, VARIANT *dest)
TRACE("(%p)->(%p)\n", This, dest); TRACE("(%p)->(%p)\n", This, dest);
if (!dest) return E_POINTER;
if (!This->dest) if (!This->dest)
{ {
HRESULT hr = flush_output_buffer(This); HRESULT hr = flush_output_buffer(This);
@ -766,10 +768,13 @@ static HRESULT WINAPI mxwriter_get_output(IMXWriter *iface, VARIANT *dest)
return S_OK; return S_OK;
} }
else
FIXME("not implemented when stream is set up\n");
return E_NOTIMPL; /* we only support IStream output so far */
V_VT(dest) = VT_UNKNOWN;
V_UNKNOWN(dest) = (IUnknown*)This->dest;
IStream_AddRef(This->dest);
return S_OK;
} }
static HRESULT WINAPI mxwriter_put_encoding(IMXWriter *iface, BSTR encoding) static HRESULT WINAPI mxwriter_put_encoding(IMXWriter *iface, BSTR encoding)

View File

@ -2821,6 +2821,7 @@ static void test_mxwriter_flush(void)
VARIANT dest; VARIANT dest;
HRESULT hr; HRESULT hr;
char *buff; char *buff;
LONG ref;
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER, hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
&IID_IMXWriter, (void**)&writer); &IID_IMXWriter, (void**)&writer);
@ -2930,6 +2931,18 @@ static void test_mxwriter_flush(void)
todo_wine todo_wine
ok(pos2.QuadPart != 0, "unexpected stream beginning\n"); ok(pos2.QuadPart != 0, "unexpected stream beginning\n");
hr = IMXWriter_get_output(writer, NULL);
EXPECT_HR(hr, E_POINTER);
ref = get_refcount(stream);
V_VT(&dest) = VT_EMPTY;
hr = IMXWriter_get_output(writer, &dest);
EXPECT_HR(hr, S_OK);
ok(V_VT(&dest) == VT_UNKNOWN, "got vt type %d\n", V_VT(&dest));
ok(V_UNKNOWN(&dest) == (IUnknown*)stream, "got pointer %p\n", V_UNKNOWN(&dest));
ok(ref+1 == get_refcount(stream), "expected increased refcount\n");
VariantClear(&dest);
hr = ISAXContentHandler_endDocument(content); hr = ISAXContentHandler_endDocument(content);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);