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

riched20: Add stub for ITextDocument2Old interface.

parent 617c9a67
......@@ -233,7 +233,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run* run, BOOL selected) DECLSPE
void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) DECLSPEC_HIDDEN;
void ME_CopyReObject(REOBJECT *dst, const REOBJECT *src, DWORD flags) DECLSPEC_HIDDEN;
void ME_DeleteReObject(struct re_object *re_object) DECLSPEC_HIDDEN;
void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj) DECLSPEC_HIDDEN;
void ME_GetITextDocument2OldInterface(IRichEditOle *iface, LPVOID *ppvObj) DECLSPEC_HIDDEN;
/* editor.c */
ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) DECLSPEC_HIDDEN;
......
......@@ -113,10 +113,36 @@ static ULONG get_refcount(IUnknown *iface)
return IUnknown_Release(iface);
}
#define CHECK_TYPEINFO(disp,expected_riid) _check_typeinfo((IDispatch *)disp, expected_riid, __LINE__)
static void _check_typeinfo(IDispatch* disp, REFIID expected_riid, int line)
{
ITypeInfo *typeinfo;
TYPEATTR *typeattr;
UINT count;
HRESULT hr;
count = 10;
hr = IDispatch_GetTypeInfoCount(disp, &count);
ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfoCount failed: 0x%08x.\n", hr);
ok_(__FILE__,line)(count == 1, "got wrong count: %u.\n", count);
hr = IDispatch_GetTypeInfo(disp, 0, LOCALE_SYSTEM_DEFAULT, &typeinfo);
ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfo failed: 0x%08x.\n", hr);
hr = ITypeInfo_GetTypeAttr(typeinfo, &typeattr);
ok_(__FILE__,line)(hr == S_OK, "ITypeInfo_GetTypeAttr failed: 0x%08x.\n", hr);
ok_(__FILE__,line)(IsEqualGUID(&typeattr->guid, expected_riid),
"Unexpected type guid: %s.\n", wine_dbgstr_guid(&typeattr->guid));
ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr);
ITypeInfo_Release(typeinfo);
}
static void test_Interfaces(void)
{
IRichEditOle *reOle = NULL, *reOle1 = NULL;
ITextDocument *txtDoc = NULL;
ITextDocument2Old *txtDoc2Old = NULL;
ITextSelection *txtSel = NULL, *txtSel2;
IUnknown *punk;
HRESULT hres;
......@@ -144,6 +170,7 @@ static void test_Interfaces(void)
(void **) &txtDoc);
ok(hres == S_OK, "IRichEditOle_QueryInterface\n");
ok(txtDoc != NULL, "IRichEditOle_QueryInterface\n");
CHECK_TYPEINFO(txtDoc, &IID_ITextDocument);
hres = ITextDocument_GetSelection(txtDoc, NULL);
ok(hres == E_INVALIDARG, "ITextDocument_GetSelection: 0x%x\n", hres);
......@@ -195,6 +222,16 @@ static void test_Interfaces(void)
hres = IRichEditOle_QueryInterface(reOle, &IID_IOleInPlaceSite, (void **) &punk);
ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old);
ok(hres == S_OK, "IRichEditOle_QueryInterface\n");
ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n");
ok((ITextDocument *)txtDoc2Old == txtDoc, "interface pointer isn't equal.\n");
EXPECT_REF(txtDoc2Old, 5);
EXPECT_REF(reOle, 5);
CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument);
ITextDocument2Old_Release(txtDoc2Old);
ITextDocument_Release(txtDoc);
IRichEditOle_Release(reOle);
refcount = IRichEditOle_Release(reOle);
......@@ -207,6 +244,19 @@ static void test_Interfaces(void)
ok(hres == CO_E_RELEASED, "ITextSelection after ITextDocument destroyed\n");
ITextSelection_Release(txtSel);
w = new_richedit(NULL);
res = SendMessageA(w, EM_GETOLEINTERFACE, 0, (LPARAM)&reOle);
ok(res, "SendMessage\n");
ok(reOle != NULL, "EM_GETOLEINTERFACE\n");
hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old);
ok(hres == S_OK, "IRichEditOle_QueryInterface failed: 0x%08x.\n", hres);
ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n");
CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument);
ITextDocument2Old_Release(txtDoc2Old);
IRichEditOle_Release(reOle);
DestroyWindow(w);
}
static void test_ITextDocument_Open(void)
......
......@@ -904,6 +904,7 @@ static void test_QueryInterface(void)
HRESULT hres;
IRichEditOle *reole, *txtsrv_reole;
ITextDocument *txtdoc, *txtsrv_txtdoc;
ITextDocument2Old *txtdoc2old, *txtsrv_txtdoc2old;
ULONG refcount;
if(!init_texthost(&txtserv, &host))
......@@ -930,6 +931,17 @@ static void test_QueryInterface(void)
ITextDocument_Release(txtdoc);
refcount = get_refcount((IUnknown *)txtserv);
ok(refcount == 2, "got wrong ref count: %d\n", refcount);
hres = IRichEditOle_QueryInterface(txtsrv_reole, &IID_ITextDocument2Old, (void **)&txtdoc2old);
ok(hres == S_OK, "IRichEditOle_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_reole);
ok(refcount == 3, "got wrong ref count: %d\n", refcount);
ITextDocument2Old_Release(txtdoc2old);
refcount = get_refcount((IUnknown *)txtserv);
ok(refcount == 2, "got wrong ref count: %d\n", refcount);
IRichEditOle_Release(txtsrv_reole);
refcount = get_refcount((IUnknown *)txtserv);
ok(refcount == 1, "got wrong ref count: %d\n", refcount);
......@@ -956,6 +968,28 @@ static void test_QueryInterface(void)
refcount = get_refcount((IUnknown *)txtserv);
ok(refcount == 1, "got wrong ref count: %d\n", refcount);
/* ITextDocument2Old */
hres = ITextServices_QueryInterface(txtserv, &IID_ITextDocument2Old, (void **)&txtsrv_txtdoc2old);
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);
refcount = get_refcount((IUnknown *)txtsrv_txtdoc2old);
ok(refcount == 2, "got wrong ref count: %d\n", refcount);
hres = ITextDocument2Old_QueryInterface(txtsrv_txtdoc2old, &IID_IRichEditOle, (void **)&reole);
ok(hres == S_OK, "ITextDocument2Old_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_txtdoc2old);
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);
ITextDocument2Old_Release(txtsrv_txtdoc2old);
refcount = get_refcount((IUnknown *)txtserv);
ok(refcount == 1, "got wrong ref count: %d\n", refcount);
ITextServices_Release(txtserv);
ITextHost_Release(host);
}
......
......@@ -78,12 +78,13 @@ 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) || IsEqualIID(riid, &IID_ITextDocument)) {
else if (IsEqualIID(riid, &IID_IRichEditOle) || IsEqualIID(riid, &IID_ITextDocument) ||
IsEqualIID(riid, &IID_ITextDocument2Old)) {
if (!This->editor->reOle)
if (!CreateIRichEditOle(This->outer_unk, This->editor, (void **)(&This->editor->reOle)))
return E_OUTOFMEMORY;
if (IsEqualIID(riid, &IID_ITextDocument))
ME_GetITextDocumentInterface(This->editor->reOle, ppv);
if (IsEqualIID(riid, &IID_ITextDocument) || IsEqualIID(riid, &IID_ITextDocument2Old))
ME_GetITextDocument2OldInterface(This->editor->reOle, ppv);
else
*ppv = This->editor->reOle;
} else {
......
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