Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/richole.c | 473 ++++++++++++++++++++++++++++++++++ dlls/riched20/tests/richole.c | 8 + 2 files changed, 481 insertions(+)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index 5c7be5eaa9..6c21a8721c 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -46,6 +46,7 @@ DEFINE_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xa DEFINE_GUID(IID_ITextHost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1); DEFINE_GUID(IID_ITextHost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1); DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d); +DEFINE_GUID(IID_ITextDocument2, 0x01c25500, 0x4268, 0x11d1, 0x88, 0x3a, 0x3c, 0x8b, 0x00, 0xc1, 0x00, 0x00); DEFINE_GUID(IID_ITextRange, 0x8cc497c2, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d); DEFINE_GUID(IID_ITextSelection, 0x8cc497c1, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d); DEFINE_GUID(IID_ITextFont, 0x8cc497c3, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d); @@ -209,6 +210,7 @@ typedef struct IRichEditOleImpl { IUnknown IUnknown_inner; IRichEditOle IRichEditOle_iface; ITextDocument ITextDocument_iface; + ITextDocument2 ITextDocument2_iface; IUnknown *outer_unk; LONG ref;
@@ -272,6 +274,11 @@ static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface) return CONTAINING_RECORD(iface, IRichEditOleImpl, ITextDocument_iface); }
+static inline IRichEditOleImpl *impl_from_ITextDocument2(ITextDocument2 *iface) +{ + return CONTAINING_RECORD(iface, IRichEditOleImpl, ITextDocument2_iface); +} + static inline IRichEditOleImpl *impl_from_IUnknown(IUnknown *iface) { return CONTAINING_RECORD(iface, IRichEditOleImpl, IUnknown_inner); @@ -945,6 +952,8 @@ static HRESULT WINAPI IRichEditOleImpl_inner_fnQueryInterface(IUnknown *iface, R *ppvObj = &This->IRichEditOle_iface; else if (IsEqualGUID(riid, &IID_ITextDocument)) *ppvObj = &This->ITextDocument_iface; + else if (IsEqualGUID(riid, &IID_ITextDocument2)) + *ppvObj = &This->ITextDocument2_iface; if (*ppvObj) { IUnknown_AddRef((IUnknown *)*ppvObj); @@ -4178,6 +4187,469 @@ static const ITextDocumentVtbl tdvt = { ITextDocument_fnRangeFromPoint };
+/* ITextDocument2 */ +static HRESULT WINAPI ITextDocument2_fnQueryInterface(ITextDocument2 *iface, + REFIID riid, void **obj) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + return IRichEditOle_QueryInterface(&This->IRichEditOle_iface, riid, obj); +} + +static ULONG WINAPI ITextDocument2_fnAddRef(ITextDocument2 *iface) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + return IRichEditOle_AddRef(&This->IRichEditOle_iface); +} + +static ULONG WINAPI ITextDocument2_fnRelease(ITextDocument2 *iface) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + return IRichEditOle_Release(&This->IRichEditOle_iface); +} + +static HRESULT WINAPI ITextDocument2_fnGetTypeInfoCount(ITextDocument2 *iface, UINT *info) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + return ITextDocument_GetTypeInfoCount(&This->ITextDocument_iface, info); +} + +static HRESULT WINAPI ITextDocument2_fnGetTypeInfo(ITextDocument2 *iface, UINT info, LCID lcid, + ITypeInfo **type_info) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + return ITextDocument_GetTypeInfo(&This->ITextDocument_iface, info, lcid, type_info); +} + +static HRESULT WINAPI ITextDocument2_fnGetIDsOfNames(ITextDocument2 *iface, REFIID riid, LPOLESTR *name, + UINT name_count, LCID lcid, DISPID *dispid) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + return ITextDocument_GetIDsOfNames(&This->ITextDocument_iface, riid, name, name_count, lcid, dispid); +} + +static HRESULT WINAPI ITextDocument2_fnInvoke(ITextDocument2 *iface, DISPID dispid, REFIID riid, + LCID lcid, WORD flags, DISPPARAMS *dispparams, + VARIANT *var_result, EXCEPINFO *excepinfo, + UINT *arg_err) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + return ITextDocument_Invoke(&This->ITextDocument_iface, dispid, riid, lcid, flags, dispparams, + var_result, excepinfo, arg_err); +} + +static HRESULT WINAPI ITextDocument2_fnGetName(ITextDocument2 *iface, BSTR *name) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%p)\n", This, name); + + return ITextDocument_GetName(&This->ITextDocument_iface, name); +} + +static HRESULT WINAPI ITextDocument2_fnGetSelection(ITextDocument2 *iface, ITextSelection **selection) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%p)\n", This, selection); + + return ITextDocument_GetSelection(&This->ITextDocument_iface, selection); +} + +static HRESULT WINAPI ITextDocument2_fnGetStoryCount(ITextDocument2 *iface, LONG *count) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%p)\n", This, count); + + return ITextDocument_GetStoryCount(&This->ITextDocument_iface, count); +} + +static HRESULT WINAPI ITextDocument2_fnGetStoryRanges(ITextDocument2 *iface, ITextStoryRanges **story_ranges) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%p)\n", This, story_ranges); + + return ITextDocument_GetStoryRanges(&This->ITextDocument_iface, story_ranges); +} + +static HRESULT WINAPI ITextDocument2_fnGetSaved(ITextDocument2 *iface, LONG *value) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%p)\n", This, value); + + return ITextDocument_GetSaved(&This->ITextDocument_iface, value); +} + +static HRESULT WINAPI ITextDocument2_fnSetSaved(ITextDocument2 *iface, LONG value) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%d)\n", This, value); + + return ITextDocument_SetSaved(&This->ITextDocument_iface, value); +} + +static HRESULT WINAPI ITextDocument2_fnGetDefaultTabStop(ITextDocument2 *iface, float *value) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%p)\n", This, value); + + return ITextDocument_GetDefaultTabStop(&This->ITextDocument_iface, value); +} + +static HRESULT WINAPI ITextDocument2_fnSetDefaultTabStop(ITextDocument2 *iface, float value) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%f)\n", This, value); + + return ITextDocument_SetDefaultTabStop(&This->ITextDocument_iface, value); +} + +static HRESULT WINAPI ITextDocument2_fnNew(ITextDocument2 *iface) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)\n", This); + + return ITextDocument_New(&This->ITextDocument_iface); +} + +static HRESULT WINAPI ITextDocument2_fnOpen(ITextDocument2 *iface, VARIANT *var, LONG flags, LONG codepage) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%p, %d, %d)\n", This, var, flags, codepage); + + return ITextDocument_Open(&This->ITextDocument_iface, var, flags, codepage); +} + +static HRESULT WINAPI ITextDocument2_fnSave(ITextDocument2 *iface, VARIANT *var, LONG flags, LONG codepage) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%p, %d, %d)\n", This, var, flags, codepage); + + return ITextDocument_Save(&This->ITextDocument_iface, var, flags, codepage); +} + +static HRESULT WINAPI ITextDocument2_fnFreeze(ITextDocument2 *iface, LONG *count) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%p)\n", This, count); + + return ITextDocument_Freeze(&This->ITextDocument_iface, count); +} + +static HRESULT WINAPI ITextDocument2_fnUnfreeze(ITextDocument2 *iface, LONG *count) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%p)\n", This, count); + + return ITextDocument_Unfreeze(&This->ITextDocument_iface, count); +} + +static HRESULT WINAPI ITextDocument2_fnBeginEditCollection(ITextDocument2 *iface) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)\n", This); + + return ITextDocument_BeginEditCollection(&This->ITextDocument_iface); +} + +static HRESULT WINAPI ITextDocument2_fnEndEditCollection(ITextDocument2 *iface) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)\n", This); + + return ITextDocument_EndEditCollection(&This->ITextDocument_iface); +} + +static HRESULT WINAPI ITextDocument2_fnUndo(ITextDocument2 *iface, LONG count, LONG *prop) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%d, %p)\n", This, count, prop); + + return ITextDocument_Undo(&This->ITextDocument_iface, count, prop); +} + +static HRESULT WINAPI ITextDocument2_fnRedo(ITextDocument2 *iface, LONG count, LONG *prop) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%d, %p)\n", This, count, prop); + + return ITextDocument_Redo(&This->ITextDocument_iface, count, prop); +} + +static HRESULT WINAPI ITextDocument2_fnRange(ITextDocument2 *iface, LONG cp_active, LONG cp_anchor, + ITextRange **range) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%d, %d, %p)\n", This, cp_active, cp_anchor, range); + + return ITextDocument_Range(&This->ITextDocument_iface, cp_active, cp_anchor, range); +} + +static HRESULT WINAPI ITextDocument2_fnRangeFromPoint(ITextDocument2 *iface, LONG x, LONG y, + ITextRange **range) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + TRACE("(%p)->(%d, %d, %p)\n", This, x, y, range); + + return ITextDocument_RangeFromPoint(&This->ITextDocument_iface, x, y, range); +} + +static HRESULT WINAPI ITextDocument2_fnAttachMsgFilter(ITextDocument2 *iface, IUnknown *filter) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%p): stub\n", This, filter); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnSetEffectColor(ITextDocument2 *iface, LONG index, COLORREF cr) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%d, 0x%x): stub\n", This, index, cr); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnGetEffectColor(ITextDocument2 *iface, LONG index, COLORREF *cr) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%d, %p): stub\n", This, index, cr); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnGetCaretType(ITextDocument2 *iface, LONG *type) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%p): stub\n", This, type); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnSetCaretType(ITextDocument2 *iface, LONG type) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%d): stub\n", This, type); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnGetImmContext(ITextDocument2 *iface, LONG *context) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%p): stub\n", This, context); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnReleaseImmContext(ITextDocument2 *iface, LONG context) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%d): stub\n", This, context); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnGetPreferredFont(ITextDocument2 *iface, LONG cp, LONG charrep, + LONG options, LONG current_charrep, LONG current_fontsize, + BSTR *bstr, LONG *pitch_family, LONG *new_fontsize) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%d, %d, %d, %d, %d, %p, %p, %p): stub\n", This, cp, charrep, options, current_charrep, + current_fontsize, bstr, pitch_family, new_fontsize); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnGetNotificationMode(ITextDocument2 *iface, LONG *mode) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%p): stub\n", This, mode); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnSetNotificationMode(ITextDocument2 *iface, LONG mode) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(0x%x): stub\n", This, mode); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnGetClientRect(ITextDocument2 *iface, LONG type, LONG *left, LONG *top, + LONG *right, LONG *bottom) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%d, %p, %p, %p, %p): stub\n", This, type, left, top, right, bottom); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnGetSelectionEx(ITextDocument2 *iface, ITextSelection **selection) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%p): stub\n", This, selection); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnGetWindow(ITextDocument2 *iface, LONG *hwnd) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%p): stub\n", This, hwnd); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnGetFEFlags(ITextDocument2 *iface, LONG *flags) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%p): stub\n", This, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnUpdateWindow(ITextDocument2 *iface) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p): stub\n", This); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnCheckTextLimit(ITextDocument2 *iface, LONG cch, LONG *exceed) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%d, %p): stub\n", This, cch, exceed); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnIMEInProgress(ITextDocument2 *iface, LONG mode) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(0x%x): stub\n", This, mode); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnSysBeep(ITextDocument2 *iface) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p): stub\n", This); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnUpdate(ITextDocument2 *iface, LONG mode) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(0x%x): stub\n", This, mode); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextDocument2_fnNotify(ITextDocument2 *iface, LONG notify) +{ + IRichEditOleImpl *This = impl_from_ITextDocument2(iface); + + FIXME("(%p)->(%d): stub\n", This, notify); + + return E_NOTIMPL; +} + +static const ITextDocument2Vtbl td2vt = { + ITextDocument2_fnQueryInterface, + ITextDocument2_fnAddRef, + ITextDocument2_fnRelease, + ITextDocument2_fnGetTypeInfoCount, + ITextDocument2_fnGetTypeInfo, + ITextDocument2_fnGetIDsOfNames, + ITextDocument2_fnInvoke, + ITextDocument2_fnGetName, + ITextDocument2_fnGetSelection, + ITextDocument2_fnGetStoryCount, + ITextDocument2_fnGetStoryRanges, + ITextDocument2_fnGetSaved, + ITextDocument2_fnSetSaved, + ITextDocument2_fnGetDefaultTabStop, + ITextDocument2_fnSetDefaultTabStop, + ITextDocument2_fnNew, + ITextDocument2_fnOpen, + ITextDocument2_fnSave, + ITextDocument2_fnFreeze, + ITextDocument2_fnUnfreeze, + ITextDocument2_fnBeginEditCollection, + ITextDocument2_fnEndEditCollection, + ITextDocument2_fnUndo, + ITextDocument2_fnRedo, + ITextDocument2_fnRange, + ITextDocument2_fnRangeFromPoint, + ITextDocument2_fnAttachMsgFilter, + ITextDocument2_fnSetEffectColor, + ITextDocument2_fnGetEffectColor, + ITextDocument2_fnGetCaretType, + ITextDocument2_fnSetCaretType, + ITextDocument2_fnGetImmContext, + ITextDocument2_fnReleaseImmContext, + ITextDocument2_fnGetPreferredFont, + ITextDocument2_fnGetNotificationMode, + ITextDocument2_fnSetNotificationMode, + ITextDocument2_fnGetClientRect, + ITextDocument2_fnGetSelectionEx, + ITextDocument2_fnGetWindow, + ITextDocument2_fnGetFEFlags, + ITextDocument2_fnUpdateWindow, + ITextDocument2_fnCheckTextLimit, + ITextDocument2_fnIMEInProgress, + ITextDocument2_fnSysBeep, + ITextDocument2_fnUpdate, + ITextDocument2_fnNotify +}; + /* ITextSelection */ static HRESULT WINAPI ITextSelection_fnQueryInterface( ITextSelection *me, @@ -5277,6 +5749,7 @@ LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *p reo->IUnknown_inner.lpVtbl = &reo_unk_vtbl; reo->IRichEditOle_iface.lpVtbl = &revt; reo->ITextDocument_iface.lpVtbl = &tdvt; + reo->ITextDocument2_iface.lpVtbl = &td2vt; reo->ref = 1; reo->editor = editor; reo->txtSel = NULL; diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index aaf52bcfdd..ab2af3fdb7 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -117,6 +117,7 @@ static void test_Interfaces(void) { IRichEditOle *reOle = NULL, *reOle1 = NULL; ITextDocument *txtDoc = NULL; + ITextDocument2 *txtDoc2 = NULL; ITextSelection *txtSel = NULL, *txtSel2; IUnknown *punk; HRESULT hres; @@ -195,6 +196,13 @@ 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_ITextDocument2, (void **)&txtDoc2); + ok(hres == S_OK, "IRichEditOle_QueryInterface\n"); + ok(txtDoc2 != NULL, "IRichEditOle_QueryInterface\n"); + EXPECT_REF(txtDoc2, 5); + EXPECT_REF(reOle, 5); + ITextDocument2_Release(txtDoc2); + ITextDocument_Release(txtDoc); IRichEditOle_Release(reOle); refcount = IRichEditOle_Release(reOle);