From: Jactry Zeng Subject: [PATCH 7/8] riched20: Stub for ITextFont interface and implement ITextRange::GetFont and ITextSelection::GetFont. (resend) Message-Id: <54116D27.30704@jactry.com> Date: Thu, 11 Sep 2014 17:36:39 +0800 --- dlls/riched20/richole.c | 804 +++++++++++++++++++++++++++++++++++++++++- dlls/riched20/tests/richole.c | 93 +++++ 2 files changed, 893 insertions(+), 4 deletions(-) diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index b0edb22..42a038c 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -46,10 +46,12 @@ 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; typedef struct ITextRangeImpl ITextRangeImpl; +typedef struct ITextFontImpl ITextFontImpl; typedef struct IRichEditOleImpl { IRichEditOle IRichEditOle_iface; @@ -60,8 +62,19 @@ typedef struct IRichEditOleImpl { ITextSelectionImpl *txtSel; IOleClientSiteImpl *clientSite; struct list rangelist; + struct list fontlist; } IRichEditOleImpl; +struct ITextFontImpl { + ITextFont ITextFont_iface; + LONG ref; + struct list entry; + + IRichEditOleImpl *reOle; + ITextRangeImpl *txtRge; + ITextSelectionImpl *txtSel; +}; + struct ITextRangeImpl { ITextRange ITextRange_iface; LONG ref; @@ -140,12 +153,15 @@ IRichEditOle_fnRelease(IRichEditOle *me) if (!ref) { ITextRangeImpl *txtRge; + ITextFontImpl *txtFont; TRACE ("Destroying %p\n", This); This->txtSel->reOle = NULL; ITextSelection_Release(&This->txtSel->ITextSelection_iface); IOleClientSite_Release(&This->clientSite->IOleClientSite_iface); LIST_FOR_EACH_ENTRY(txtRge, &This->rangelist, ITextRangeImpl, entry) txtRge->reOle = NULL; + LIST_FOR_EACH_ENTRY(txtFont, &This->fontlist, ITextFontImpl, entry) + txtFont->reOle = NULL; heap_free(This); } return ref; @@ -457,6 +473,744 @@ 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); + else + ITextSelection_Release(&This->txtSel->ITextSelection_iface); + This->reOle = NULL; + This->txtRge = NULL; + This->txtSel = NULL; + list_remove(&This->entry); + heap_free(This); + } + return ref; +} + +static HRESULT WINAPI ITextFont_fnGetTypeInfoCount(ITextFont *me, UINT *pctinfo) +{ + ITextFontImpl *This = impl_from_ITextFont(me); + if (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 (!This->reOle) + 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 +}; +/* ITextFont interface */ + /* ITextRange interface */ static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface) { @@ -711,14 +1465,42 @@ static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim) return range_SetEnd(This->reOle->editor, cpLim, &This->start, &This->end); } +static HRESULT CreateITextFont(IRichEditOleImpl *reOle, ITextFontImpl **ptxtFont) +{ + ITextFontImpl *txtFont = NULL; + txtFont = heap_alloc(sizeof(ITextFontImpl)); + if (!txtFont) + return E_OUTOFMEMORY; + + txtFont->ITextFont_iface.lpVtbl = &tfvt; + txtFont->ref = 1; + txtFont->reOle = reOle; + list_add_head(&reOle->fontlist, &txtFont->entry); + *ptxtFont = txtFont; + return S_OK; +} + 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(This->reOle, &txtFont); + if (!hres) + { + txtFont->txtSel = NULL; + txtFont->txtRge = This; + ITextRange_AddRef(me); + *pFont = &txtFont->ITextFont_iface; + } + return hres; } static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont) @@ -1733,11 +2515,24 @@ static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim) static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + ITextFontImpl *txtFont = NULL; + HRESULT hres; + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); - return E_NOTIMPL; + TRACE("%p\n", This); + if (!pFont) + return E_INVALIDARG; + hres = CreateITextFont(This->reOle, &txtFont); + if (!hres) + { + txtFont->txtSel = This; + txtFont->txtRge = NULL; + ITextSelection_AddRef(me); + *pFont = &txtFont->ITextFont_iface; + } + return hres; } static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont) @@ -2371,6 +3166,7 @@ LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj) TRACE("Created %p\n",reo); *ppObj = reo; list_init(&reo->rangelist); + list_init(&reo->fontlist); return 1; } diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 46cea63..3d308c5 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -880,6 +880,97 @@ static void test_ITextSelection_SetEnd(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); +} + +static void test_ITextSelection_GetFont(void) +{ + HWND w; + IRichEditOle *reOle = NULL; + ITextDocument *txtDoc = NULL; + ITextSelection *txtSel = 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, &txtSel); + SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); + + first = 4, lim = 4; + SendMessageA(w, EM_SETSEL, first, lim); + refcount = get_refcount((IUnknown *)txtSel); + ok(refcount == 2, "got wrong ref count: %d\n", refcount); + + hres = ITextSelection_GetFont(txtSel, &txtFont); + ok(hres == S_OK, "ITextSelection_GetFont\n"); + refcount = get_refcount((IUnknown *)txtFont); + ok(refcount == 1, "got wrong ref count: %d\n", refcount); + refcount = get_refcount((IUnknown *)txtSel); + ok(refcount == 3, "got wrong ref count: %d\n", refcount); + + hres = ITextSelection_GetFont(txtSel, &txtFont1); + ok(hres == S_OK, "ITextSelection_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 *)txtSel); + ok(refcount == 3, "got wrong ref count: %d\n", refcount); + + release_interfaces(&w, &reOle, &txtDoc, &txtSel); + + 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 @@ -894,6 +985,7 @@ START_TEST(richole) test_ITextSelection_SetStart(); test_ITextSelection_SetEnd(); test_ITextSelection_Collapse(); + test_ITextSelection_GetFont(); test_ITextDocument_Range(); test_ITextRange_GetChar(); test_ITextRange_GetDuplicate(); @@ -901,4 +993,5 @@ START_TEST(richole) test_ITextRange_Collapse(); test_ITextRange_SetStart(); test_ITextRange_SetEnd(); + test_ITextRange_GetFont(); }