From 73e01cce0760454777401a9dd5c9a1f4f3dee14c Mon Sep 17 00:00:00 2001 From: Jactry Zeng Date: Tue, 23 Sep 2014 15:36:31 +0800 Subject: [PATCH 2/2] riched20: Add IID_ITextDocument support for ITextServices::QueryInterface. To: wine-patches Reply-To: wine-devel --- dlls/riched20/tests/txtsrv.c | 30 ++++++++++++++++++++++++++++-- dlls/riched20/txtsrv.c | 5 +++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 003a274..7b7db20 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -873,8 +873,8 @@ static ULONG get_refcount(IUnknown *iface) static void test_QueryInterface(void) { HRESULT hres; - IRichEditOle *txtsrv_reOle; - ITextDocument *txtDoc; + IRichEditOle *txtsrv_reOle, *reOle; + ITextDocument *txtsrv_txtDoc, *txtDoc; ULONG refcount; if(!init_texthost()) @@ -911,6 +911,32 @@ static void test_QueryInterface(void) win_skip("IRichEditOle not available\n"); } + /* IID_ITextDocument */ + hres = ITextServices_QueryInterface(txtserv, &IID_ITextDocument, (void **)&txtsrv_txtDoc); + ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres); + + refcount = get_refcount((IUnknown *)txtserv); + ok(refcount == 2, "got wrong ref count: %d\n", refcount); + + if (SUCCEEDED(hres)) { + refcount = get_refcount((IUnknown *)txtsrv_txtDoc); + ok(refcount == 2, "got wrong ref count: %d\n", refcount); + + hres = ITextDocument_QueryInterface(txtsrv_txtDoc, &IID_IRichEditOle, (void **)&reOle); + ok(hres == S_OK, "ITextDocument_QueryInterface: 0x%08x\n", hres); + refcount = get_refcount((IUnknown *)txtserv); + ok(refcount == 3, "got wrong ref count: %d\n", refcount); + refcount = get_refcount((IUnknown *)txtsrv_txtDoc); + ok(refcount == 3, "got wrong ref count: %d\n", refcount); + + IRichEditOle_Release(reOle); + refcount = get_refcount((IUnknown *)txtserv); + ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ITextDocument_Release(txtsrv_txtDoc); + refcount = get_refcount((IUnknown *)txtserv); + ok(refcount == 1, "got wrong ref count: %d\n", refcount); + } + free_texthost(); } diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c index 15fcdd8..ae38640 100644 --- a/dlls/riched20/txtsrv.c +++ b/dlls/riched20/txtsrv.c @@ -33,6 +33,7 @@ #include "textserv.h" #include "wine/debug.h" #include "editstr.h" +#include "tom.h" #ifdef __i386__ /* thiscall functions are i386-specific */ @@ -79,10 +80,10 @@ static HRESULT WINAPI ITextServicesImpl_QueryInterface(IUnknown *iface, REFIID r *ppv = &This->IUnknown_inner; else if (IsEqualIID(riid, &IID_ITextServices)) *ppv = &This->ITextServices_iface; - else if (IsEqualIID(riid, &IID_IRichEditOle)) { + else if (IsEqualIID(riid, &IID_IRichEditOle) || IsEqualIID(riid, &IID_ITextDocument)) { if (!This->editor->reOle) CreateIRichEditOle(This->editor, (LPVOID *)&(This->editor->reOle), iface); - IRichEditOle_QueryInterface(This->editor->reOle, &IID_IRichEditOle, (void **)ppv); + IRichEditOle_QueryInterface(This->editor->reOle, riid, (void **)ppv); return S_OK; } else { *ppv = NULL; -- 2.0.2