From: Jactry Zeng Subject: [PATCH 1/2] riched20: Stub for ITextFont interface and implement ITextRange::GetFont. (try 3) Message-Id: <541C288B.1040205@codeweavers.com> Date: Fri, 19 Sep 2014 20:58:51 +0800 Superseded patch 106605. ChangeLog: try 3: - Remove an unuseful initialization in CreateITextFont(). - Set txtSel and txtRge as NULL in CreateITextFont(). try 2: - Remove reOle reference. - Add get_reOle() for get reOle from txtSel or txtRge. - Remove linked list. --- dlls/riched20/richole.c | 786 +++++++++++++++++++++++++++++++++++++++++- dlls/riched20/tests/richole.c | 47 +++ 2 files changed, 831 insertions(+), 2 deletions(-) diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index f7e7870..992f6e0 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -46,6 +46,7 @@ DEFINE_GUID(IID_ITextHost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0x DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d); 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); typedef struct ITextSelectionImpl ITextSelectionImpl; typedef struct IOleClientSiteImpl IOleClientSiteImpl; @@ -62,6 +63,14 @@ typedef struct IRichEditOleImpl { struct list rangelist; } IRichEditOleImpl; +typedef struct ITextFontImpl { + ITextFont ITextFont_iface; + LONG ref; + + ITextRangeImpl *txtRge; + ITextSelectionImpl *txtSel; +} ITextFontImpl; + struct ITextRangeImpl { ITextRange ITextRange_iface; LONG ref; @@ -457,6 +466,767 @@ static const IRichEditOleVtbl revt = { IRichEditOle_fnImportDataObject }; +/* ITextFont interface */ +static inline ITextFontImpl *impl_from_ITextFont(ITextFont *iface) +{ + return CONTAINING_RECORD(iface, ITextFontImpl, ITextFont_iface); +} + +static HRESULT WINAPI ITextFont_fnQueryInterface(ITextFont *me, REFIID riid, void **ppvObj) +{ + *ppvObj = NULL; + if (IsEqualGUID(riid, &IID_IUnknown) + || IsEqualGUID(riid, &IID_ITextFont) + || IsEqualGUID(riid, &IID_IDispatch)) + { + *ppvObj = me; + ITextFont_AddRef(me); + return S_OK; + } + + return E_NOINTERFACE; +} + +static ULONG WINAPI ITextFont_fnAddRef(ITextFont *me) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI ITextFont_fnRelease(ITextFont *me) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE ("%p ref=%u\n", This, ref); + if (ref == 0) + { + if (This->txtRge) + { + ITextRange_Release(&This->txtRge->ITextRange_iface); + This->txtRge = NULL; + } + else + { + ITextSelection_Release(&This->txtSel->ITextSelection_iface); + This->txtSel = NULL; + } + heap_free(This); + } + return ref; +} + +static IRichEditOleImpl *get_reOle(ITextFontImpl *txtFont) +{ + if (txtFont->txtRge) + return txtFont->txtRge->reOle; + else + return txtFont->txtSel->reOle; +} + +static HRESULT WINAPI ITextFont_fnGetTypeInfoCount(ITextFont *me, UINT *pctinfo) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetTypeInfo(ITextFont *me, UINT iTInfo, LCID lcid, + ITypeInfo **ppTInfo) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetIDsOfNames(ITextFont *me, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnInvoke(ITextFont *me, DISPID dispIdMember, REFIID riid, + LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, + UINT *puArgErr) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetDuplicate(ITextFont *me, ITextFont **ppFont) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetDuplicate(ITextFont *me, ITextFont *pFont) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnCanChange(ITextFont *me, LONG *pB) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnIsEqual(ITextFont *me, ITextFont *pFont, LONG *pB) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnReset(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetStyle(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetStyle(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetAllCaps(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetAllCaps(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetAnimation(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetAnimation(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetBackColor(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetBackColor(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetBold(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!pValue) + return E_INVALIDARG; + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("Stub\n"); + *pValue = tomFalse; + return S_OK; +} + +static HRESULT WINAPI ITextFont_fnSetBold(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetEmboss(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetEmboss(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetForeColor(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!pValue) + return E_INVALIDARG; + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("Stub\n"); + *pValue = tomAutoColor; + return S_OK; +} + +static HRESULT WINAPI ITextFont_fnSetForeColor(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetHidden(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetHidden(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetEngrave(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetEngrave(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetItalic(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!pValue) + return E_INVALIDARG; + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("Stub\n"); + *pValue = tomFalse; + return S_OK; +} + +static HRESULT WINAPI ITextFont_fnSetItalic(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetKerning(ITextFont *me, float *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetKerning(ITextFont *me, float Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetLanguageID(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetLanguageID(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetName(ITextFont *me, BSTR *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + WCHAR font[] = {'S', 'y', 's', 't', 'e', 'm', 0}; + if (!pValue) + return E_INVALIDARG; + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("Stub\n"); + *pValue = SysAllocString(font); + return S_OK; +} + +static HRESULT WINAPI ITextFont_fnSetName(ITextFont *me, BSTR Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetOutline(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetOutline(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetPosition(ITextFont *me, float *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetPosition(ITextFont *me, float Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetProtected(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetProtected(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetShadow(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetShadow(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetSize(ITextFont *me, float *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!pValue) + return E_INVALIDARG; + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("Stub\n"); + *pValue = 12.0; + return S_OK; +} + +static HRESULT WINAPI ITextFont_fnSetSize(ITextFont *me, float Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetSmallCaps(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetSmallCaps(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetSpacing(ITextFont *me, float *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetSpacing(ITextFont *me, float Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetStrikeThrough(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!pValue) + return E_INVALIDARG; + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("Stub\n"); + *pValue = tomFalse; + return S_OK; +} + +static HRESULT WINAPI ITextFont_fnSetStrikeThrough(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetSubscript(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!pValue) + return E_INVALIDARG; + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("Stub\n"); + *pValue = tomFalse; + return S_OK; +} + +static HRESULT WINAPI ITextFont_fnSetSubscript(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetSuperscript(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (pValue) + return E_INVALIDARG; + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("Stub\n"); + *pValue = tomFalse; + return S_OK; +} + +static HRESULT WINAPI ITextFont_fnSetSuperscript(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetUnderline(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!pValue) + return E_INVALIDARG; + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("Stub\n"); + *pValue = tomNone; + return S_OK; +} + +static HRESULT WINAPI ITextFont_fnSetUnderline(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnGetWeight(ITextFont *me, LONG *pValue) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextFont_fnSetWeight(ITextFont *me, LONG Value) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!get_reOle(This)) + return CO_E_RELEASED; + + FIXME("not implemented: %p\n", This); + return E_NOTIMPL; +} + +static const ITextFontVtbl tfvt = { + ITextFont_fnQueryInterface, + ITextFont_fnAddRef, + ITextFont_fnRelease, + ITextFont_fnGetTypeInfoCount, + ITextFont_fnGetTypeInfo, + ITextFont_fnGetIDsOfNames, + ITextFont_fnInvoke, + ITextFont_fnGetDuplicate, + ITextFont_fnSetDuplicate, + ITextFont_fnCanChange, + ITextFont_fnIsEqual, + ITextFont_fnReset, + ITextFont_fnGetStyle, + ITextFont_fnSetStyle, + ITextFont_fnGetAllCaps, + ITextFont_fnSetAllCaps, + ITextFont_fnGetAnimation, + ITextFont_fnSetAnimation, + ITextFont_fnGetBackColor, + ITextFont_fnSetBackColor, + ITextFont_fnGetBold, + ITextFont_fnSetBold, + ITextFont_fnGetEmboss, + ITextFont_fnSetEmboss, + ITextFont_fnGetForeColor, + ITextFont_fnSetForeColor, + ITextFont_fnGetHidden, + ITextFont_fnSetHidden, + ITextFont_fnGetEngrave, + ITextFont_fnSetEngrave, + ITextFont_fnGetItalic, + ITextFont_fnSetItalic, + ITextFont_fnGetKerning, + ITextFont_fnSetKerning, + ITextFont_fnGetLanguageID, + ITextFont_fnSetLanguageID, + ITextFont_fnGetName, + ITextFont_fnSetName, + ITextFont_fnGetOutline, + ITextFont_fnSetOutline, + ITextFont_fnGetPosition, + ITextFont_fnSetPosition, + ITextFont_fnGetProtected, + ITextFont_fnSetProtected, + ITextFont_fnGetShadow, + ITextFont_fnSetShadow, + ITextFont_fnGetSize, + ITextFont_fnSetSize, + ITextFont_fnGetSmallCaps, + ITextFont_fnSetSmallCaps, + ITextFont_fnGetSpacing, + ITextFont_fnSetSpacing, + ITextFont_fnGetStrikeThrough, + ITextFont_fnSetStrikeThrough, + ITextFont_fnGetSubscript, + ITextFont_fnSetSubscript, + ITextFont_fnGetSuperscript, + ITextFont_fnSetSuperscript, + ITextFont_fnGetUnderline, + ITextFont_fnSetUnderline, + ITextFont_fnGetWeight, + ITextFont_fnSetWeight +}; + +static HRESULT CreateITextFont(ITextFontImpl **ptxtFont) +{ + ITextFontImpl *txtFont = heap_alloc(sizeof(ITextFontImpl)); + if (!txtFont) + return E_OUTOFMEMORY; + + txtFont->ITextFont_iface.lpVtbl = &tfvt; + txtFont->ref = 1; + txtFont->txtSel = NULL; + txtFont->txtRge = NULL; + *ptxtFont = txtFont; + return S_OK; +} + /* ITextRange interface */ static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface) { @@ -686,11 +1456,23 @@ static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim) static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **pFont) { ITextRangeImpl *This = impl_from_ITextRange(me); + ITextFontImpl *txtFont = NULL; + HRESULT hres; + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; + TRACE("%p\n", This); + if (!pFont) + return E_INVALIDARG; + hres = CreateITextFont(&txtFont); + if (SUCCEEDED(hres)) + { + txtFont->txtRge = This; + ITextRange_AddRef(me); + *pFont = &txtFont->ITextFont_iface; + } + return hres; } static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont) diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index eed335c..b25ec02 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -941,6 +941,52 @@ static void test_ITextSelection_Collapse(void) release_interfaces(&w, &reOle, &txtDoc, &txtSel); } +static void test_ITextRange_GetFont(void) +{ + HWND w; + IRichEditOle *reOle = NULL; + ITextDocument *txtDoc = NULL; + ITextRange *txtRge = NULL; + ITextFont *txtFont = NULL, *txtFont1 = NULL; + HRESULT hres; + int first, lim; + int refcount; + static const CHAR test_text1[] = "TestSomeText"; + LONG value; + + create_interfaces(&w, &reOle, &txtDoc, NULL); + SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); + + first = 4, lim = 4; + ITextDocument_Range(txtDoc, first, lim, &txtRge); + refcount = get_refcount((IUnknown *)txtRge); + ok(refcount == 1, "got wrong ref count: %d\n", refcount); + + hres = ITextRange_GetFont(txtRge, &txtFont); + ok(hres == S_OK, "ITextRange_GetFont\n"); + refcount = get_refcount((IUnknown *)txtFont); + ok(refcount == 1, "got wrong ref count: %d\n", refcount); + refcount = get_refcount((IUnknown *)txtRge); + ok(refcount == 2, "got wrong ref count: %d\n", refcount); + + hres = ITextRange_GetFont(txtRge, &txtFont1); + ok(hres == S_OK, "ITextRange_GetFont\n"); + ok(txtFont1 != txtFont, "A new pointer should be return\n"); + refcount = get_refcount((IUnknown *)txtFont1); + ok(refcount == 1, "got wrong ref count: %d\n", refcount); + ITextFont_Release(txtFont1); + refcount = get_refcount((IUnknown *)txtRge); + ok(refcount == 2, "got wrong ref count: %d\n", refcount); + + ITextRange_Release(txtRge); + release_interfaces(&w, &reOle, &txtDoc, NULL); + + hres = ITextFont_GetOutline(txtFont, &value); + ok(hres == CO_E_RELEASED, "ITextFont after ITextDocument destroyed\n"); + + ITextFont_Release(txtFont); +} + START_TEST(richole) { /* Must explicitly LoadLibrary(). The test has no references to functions in @@ -959,4 +1005,5 @@ START_TEST(richole) test_ITextRange_GetStart_GetEnd(); test_ITextRange_GetDuplicate(); test_ITextRange_Collapse(); + test_ITextRange_GetFont(); }