Jactry Zeng : riched20: Implement IOleWindow interface.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Mar 16 10:34:24 CDT 2015
Module: wine
Branch: master
Commit: bbb9755896f9660ace3c4e1c353baad180f00d3f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bbb9755896f9660ace3c4e1c353baad180f00d3f
Author: Jactry Zeng <jzeng at codeweavers.com>
Date: Mon Mar 16 17:27:21 2015 +0800
riched20: Implement IOleWindow interface.
---
dlls/riched20/richole.c | 51 ++++++++++++++++++++++++++++++++++++++++++
dlls/riched20/tests/richole.c | 52 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 103 insertions(+)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 1280016..47f2964 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -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;
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index ee31a16..22d2048 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -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();
}
More information about the wine-cvs
mailing list