Commit bbb97558 authored by Jactry Zeng's avatar Jactry Zeng Committed by Alexandre Julliard

riched20: Implement IOleWindow interface.

parent 879261dd
......@@ -82,6 +82,7 @@ struct ITextSelectionImpl {
struct IOleClientSiteImpl {
IOleClientSite IOleClientSite_iface;
IOleWindow IOleWindow_iface;
LONG ref;
IRichEditOleImpl *reOle;
......@@ -219,12 +220,15 @@ static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface
static HRESULT WINAPI
IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
{
IOleClientSiteImpl *This = impl_from_IOleClientSite(me);
TRACE("%p %s\n", me, debugstr_guid(riid) );
*ppvObj = NULL;
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IOleClientSite))
*ppvObj = me;
else if (IsEqualGUID(riid, &IID_IOleWindow))
*ppvObj = &This->IOleWindow_iface;
if (*ppvObj)
{
IOleClientSite_AddRef(me);
......@@ -325,6 +329,52 @@ static const IOleClientSiteVtbl ocst = {
IOleClientSite_fnRequestNewObjectLayout
};
/* IOleWindow interface */
static inline IOleClientSiteImpl *impl_from_IOleWindow(IOleWindow *iface)
{
return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleWindow_iface);
}
static HRESULT WINAPI IOleWindow_fnQueryInterface(IOleWindow *iface, REFIID riid, void **ppvObj)
{
IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
}
static ULONG WINAPI IOleWindow_fnAddRef(IOleWindow *iface)
{
IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
return IOleClientSite_AddRef(&This->IOleClientSite_iface);
}
static ULONG WINAPI IOleWindow_fnRelease(IOleWindow *iface)
{
IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
return IOleClientSite_Release(&This->IOleClientSite_iface);
}
static HRESULT WINAPI IOleWindow_fnContextSensitiveHelp(IOleWindow *iface, BOOL fEnterMode)
{
IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
FIXME("not implemented: (%p)->(%d)\n", This, fEnterMode);
return E_NOTIMPL;
}
static HRESULT WINAPI IOleWindow_fnGetWindow(IOleWindow *iface, HWND *phwnd)
{
IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
FIXME("not implemented: (%p)->(%p)\n", This, phwnd);
return E_NOTIMPL;
}
static const IOleWindowVtbl olewinvt = {
IOleWindow_fnQueryInterface,
IOleWindow_fnAddRef,
IOleWindow_fnRelease,
IOleWindow_fnGetWindow,
IOleWindow_fnContextSensitiveHelp
};
static IOleClientSiteImpl *
CreateOleClientSite(IRichEditOleImpl *reOle)
{
......@@ -333,6 +383,7 @@ CreateOleClientSite(IRichEditOleImpl *reOle)
return NULL;
clientSite->IOleClientSite_iface.lpVtbl = &ocst;
clientSite->IOleWindow_iface.lpVtbl = &olewinvt;
clientSite->ref = 1;
clientSite->reOle = reOle;
return clientSite;
......
......@@ -949,6 +949,57 @@ static void test_ITextSelection_Collapse(void)
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
}
static void test_IOleClientSite_QueryInterface(void)
{
HWND w;
IRichEditOle *reOle = NULL, *reOle1 = NULL;
ITextDocument *txtDoc = NULL;
IOleClientSite *clientSite = NULL, *clientSite1 = NULL, *clientSite2 = NULL;
IOleWindow *oleWin = NULL, *oleWin1 = NULL;
HRESULT hres;
LONG refcount1, refcount2;
create_interfaces(&w, &reOle, &txtDoc, NULL);
hres = IRichEditOle_GetClientSite(reOle, &clientSite);
ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
refcount1 = get_refcount((IUnknown *)clientSite);
todo_wine ok(refcount1 == 1, "got wrong ref count: %d\n", refcount1);
hres = IOleClientSite_QueryInterface(clientSite, &IID_IRichEditOle, (void **)&reOle1);
ok(hres == E_NOINTERFACE, "IOleClientSite_QueryInterface: %x\n", hres);
hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleClientSite, (void **)&clientSite1);
ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
ok(clientSite == clientSite1, "Should not return a new pointer.\n");
refcount1 = get_refcount((IUnknown *)clientSite);
todo_wine ok(refcount1 == 2, "got wrong ref count: %d\n", refcount1);
/* IOleWindow interface */
hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin);
ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
refcount1 = get_refcount((IUnknown *)clientSite);
refcount2 = get_refcount((IUnknown *)oleWin);
ok(refcount1 == refcount2, "got wrong ref count.\n");
hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin1);
ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
ok(oleWin == oleWin1, "Should not return a new pointer.\n");
refcount1 = get_refcount((IUnknown *)clientSite);
refcount2 = get_refcount((IUnknown *)oleWin);
ok(refcount1 == refcount2, "got wrong ref count.\n");
hres = IOleWindow_QueryInterface(oleWin, &IID_IOleClientSite, (void **)&clientSite2);
ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08x\n", hres);
ok(clientSite2 == clientSite1, "got wrong pointer\n");
IOleWindow_Release(oleWin1);
IOleWindow_Release(oleWin);
IOleClientSite_Release(clientSite2);
IOleClientSite_Release(clientSite1);
IOleClientSite_Release(clientSite);
release_interfaces(&w, &reOle, &txtDoc, NULL);
}
START_TEST(richole)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
......@@ -967,4 +1018,5 @@ START_TEST(richole)
test_ITextRange_GetStart_GetEnd();
test_ITextRange_GetDuplicate();
test_ITextRange_Collapse();
test_IOleClientSite_QueryInterface();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment