<div dir="ltr">Hi folks,<div><br></div><div>I wrote two patches for adding IRichEditOle/ITextDocument support for ITextServices::QueryInterface(for bug 17042[1]), but I'm</div><div>no sure is it the correct way. I need your review and comment! I will really appreciate it!</div><div><br></div><div>There are some tests for ITextServices::QueryInterface in dlls/riched20/txtsrv.c: test_QueryInterfaces():</div><div>1. </div><div><div>    refcount = get_refcount((IUnknown *)txtserv);</div><div>    ok(refcount == 1, "got wrong ref count: %d\n", refcount);</div><div><br></div><div>    /* IID_IRichEditOle */</div><div>    hres = ITextServices_QueryInterface(txtserv, &IID_IRichEditOle, (void **)&txtsrv_reOle);</div><div>    ok(hres == S_OK, "ITextServices_QueryInterface\n");</div><div><br></div><div>    refcount = get_refcount((IUnknown *)txtserv);</div><div>    ok(refcount == 2, "got wrong ref count: %d\n", refcount);</div></div><div><br></div><div>From this case we know ref count of ITextServices will increase after get a IRichEditOle interface from</div><div>ITextServices::QueryInterface.  ITextServices::QueryInterface(&IID_ITextDocument) is also similar.</div><div><br></div><div>2. </div><div>    refcount = get_refcount((IUnknown *)txtserv);</div><div>    ok(refcount == 2, "got wrong ref count: %d\n", refcount);</div><div><br></div><div>    if (SUCCEEDED(hres)) {</div><div>        refcount = get_refcount((IUnknown *)txtsrv_reOle);</div><div>        ok(refcount == 2, "got wrong ref count: %d\n", refcount);</div><div><br></div><div>        hres = IRichEditOle_QueryInterface(txtsrv_reOle, &IID_ITextDocument, (void **)&txtDoc);</div><div>        ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);</div><div>        refcount = get_refcount((IUnknown *)txtserv);</div><div>        ok(refcount == 3, "got wrong ref count: %d\n", refcount);</div><div>        refcount = get_refcount((IUnknown *)txtsrv_reOle);</div><div>        ok(refcount == 3, "got wrong ref count: %d\n", refcount);</div><div><br></div><div><div>From this case we know when a IRichEditOle was got by ITextServices::QueryInterface(&IID_IRichEditOle) then</div><div>we used IRichEditOle::QueryInterface to get another interface, the ref count of ITextServices will increase too.</div><div>For implementing this feature I added IUnknown *parent in IRichEditOleImpl and passed ITextServices interface into </div><div>CreateIRichEditOle when we call it in ITextServices::QueryInterface:</div><div>dlls/riched20/richole.c</div><div>---snip---</div><div><div>typedef struct IRichEditOleImpl {</div><div>    IRichEditOle IRichEditOle_iface;</div><div>    ITextDocument ITextDocument_iface;</div><div>    LONG ref;</div><div><br></div><div>    ME_TextEditor *editor;</div><div>    ITextSelectionImpl *txtSel;</div><div>    IOleClientSiteImpl *clientSite;</div><div>    struct list rangelist;</div><div>    IUnknown *parent;</div><div>} IRichEditOleImpl;</div></div><div>---snip---</div><div>dlls/riched20/txtsrv.c</div><div>---snip---</div><div><div>   else if (IsEqualIID(riid, &IID_IRichEditOle) || IsEqualIID(riid, &IID_ITextDocument)) {</div><div>       if (!This->editor->reOle)</div><div>           CreateIRichEditOle(This->editor, (LPVOID *)&(This->editor->reOle), iface);</div><div>       IRichEditOle_QueryInterface(This->editor->reOle, riid, (void **)ppv);</div><div>       return S_OK;</div><div>   } else {</div></div><div>---snip---</div><div><br></div><div>3. By some other tests, I found when a ITextServices was got by IRichEditOle::QueryInterface, then</div><div>we use ITextServices::QueryInterface to got another interface, the ref count of IRichEditOle will increase</div><div>too.</div><div><br></div><div>Thanks!</div><div><br></div><div>[1] <a href="https://bugs.winehq.org/show_bug.cgi?id=17042" target="_blank">https://bugs.winehq.org/show_bug.cgi?id=17042</a></div><div><br></div>-- <br><div dir="ltr"><div>Regards,<br></div><div>Jactry Zeng</div><div><br></div></div>
</div></div>