From 6d19ac5cb361e2d1b1f839fb06a6be754bde1e51 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sun, 17 May 2015 17:27:42 +0300 Subject: [PATCH] riched20: Added stub ITextPara. --- dlls/riched20/richole.c | 519 +++++++++++++++++++++++++++++++++- dlls/riched20/tests/richole.c | 51 ++++ 2 files changed, 566 insertions(+), 4 deletions(-) diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index 3611d07432c..39c4bb4f032 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -46,6 +46,7 @@ DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xa 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); +DEFINE_GUID(IID_ITextPara, 0x8cc497c4, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d); typedef struct ITextSelectionImpl ITextSelectionImpl; typedef struct IOleClientSiteImpl IOleClientSiteImpl; @@ -87,6 +88,13 @@ typedef struct ITextFontImpl { ITextRange *range; } ITextFontImpl; +typedef struct ITextParaImpl { + ITextPara ITextPara_iface; + LONG ref; + + ITextRange *range; +} ITextParaImpl; + struct IOleClientSiteImpl { IOleClientSite IOleClientSite_iface; IOleWindow IOleWindow_iface; @@ -131,7 +139,13 @@ static inline ITextFontImpl *impl_from_ITextFont(ITextFont *iface) return CONTAINING_RECORD(iface, ITextFontImpl, ITextFont_iface); } +static inline ITextParaImpl *impl_from_ITextPara(ITextPara *iface) +{ + return CONTAINING_RECORD(iface, ITextParaImpl, ITextPara_iface); +} + static HRESULT create_textfont(ITextRange*, ITextFont**); +static HRESULT create_textpara(ITextRange*, ITextPara**); static HRESULT WINAPI IRichEditOleImpl_inner_fnQueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppvObj) { @@ -949,14 +963,19 @@ static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont) return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **ppPara) +static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **para) { ITextRangeImpl *This = impl_from_ITextRange(me); + + TRACE("(%p)->(%p)\n", This, para); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; + if (!para) + return E_INVALIDARG; + + return create_textpara(me, para); } static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *pPara) @@ -1966,6 +1985,498 @@ static HRESULT create_textfont(ITextRange *range, ITextFont **ret) return S_OK; } +/* ITextPara */ +static HRESULT WINAPI TextPara_QueryInterface(ITextPara *iface, REFIID riid, void **ppv) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + + if (IsEqualIID(riid, &IID_ITextPara) || + IsEqualIID(riid, &IID_IDispatch) || + IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = iface; + ITextPara_AddRef(iface); + return S_OK; + } + + *ppv = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI TextPara_AddRef(ITextPara *iface) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + ULONG ref = InterlockedIncrement(&This->ref); + TRACE("(%p)->(%u)\n", This, ref); + return ref; +} + +static ULONG WINAPI TextPara_Release(ITextPara *iface) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(%u)\n", This, ref); + + if (!ref) + { + ITextRange_Release(This->range); + heap_free(This); + } + + return ref; +} + +static HRESULT WINAPI TextPara_GetTypeInfoCount(ITextPara *iface, UINT *pctinfo) +{ + FIXME("stub\n"); + *pctinfo = 0; + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetTypeInfo(ITextPara *iface, UINT iTInfo, LCID lcid, + ITypeInfo **ppTInfo) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetIDsOfNames(ITextPara *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_Invoke( + ITextPara *iface, + DISPID dispIdMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS *pDispParams, + VARIANT *pVarResult, + EXCEPINFO *pExcepInfo, + UINT *puArgErr) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetDuplicate(ITextPara *iface, ITextPara **ret) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, ret); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetDuplicate(ITextPara *iface, ITextPara *para) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, para); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_CanChange(ITextPara *iface, LONG *ret) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, ret); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_IsEqual(ITextPara *iface, ITextPara *para, LONG *ret) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p %p)\n", This, para, ret); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_Reset(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetStyle(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetStyle(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetAlignment(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetAlignment(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetHyphenation(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetHyphenation(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetFirstLineIndent(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetKeepTogether(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetKeepTogether(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetKeepWithNext(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetKeepWithNext(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetLeftIndent(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetLineSpacing(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetLineSpacingRule(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetListAlignment(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetListAlignment(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetListLevelIndex(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetListLevelIndex(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetListStart(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetListStart(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetListTab(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetListTab(ITextPara *iface, FLOAT value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetListType(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetListType(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetNoLineNumber(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetNoLineNumber(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetPageBreakBefore(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetPageBreakBefore(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetRightIndent(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetRightIndent(ITextPara *iface, FLOAT value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetIndents(ITextPara *iface, FLOAT StartIndent, FLOAT LeftIndent, FLOAT RightIndent) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f %.2f %.2f)\n", This, StartIndent, LeftIndent, RightIndent); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetLineSpacing(ITextPara *iface, LONG LineSpacingRule, FLOAT LineSpacing) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d %.2f)\n", This, LineSpacingRule, LineSpacing); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetSpaceAfter(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetSpaceAfter(ITextPara *iface, FLOAT value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetSpaceBefore(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetSpaceBefore(ITextPara *iface, FLOAT value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetWidowControl(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetWidowControl(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetTabCount(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_AddTab(ITextPara *iface, FLOAT tbPos, LONG tbAlign, LONG tbLeader) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f %d %d)\n", This, tbPos, tbAlign, tbLeader); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_ClearAllTabs(ITextPara *iface) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_DeleteTab(ITextPara *iface, FLOAT pos) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f)\n", This, pos); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetTab(ITextPara *iface, LONG iTab, FLOAT *ptbPos, LONG *ptbAlign, LONG *ptbLeader) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d %p %p %p)\n", This, iTab, ptbPos, ptbAlign, ptbLeader); + return E_NOTIMPL; +} + +static ITextParaVtbl textparavtbl = { + TextPara_QueryInterface, + TextPara_AddRef, + TextPara_Release, + TextPara_GetTypeInfoCount, + TextPara_GetTypeInfo, + TextPara_GetIDsOfNames, + TextPara_Invoke, + TextPara_GetDuplicate, + TextPara_SetDuplicate, + TextPara_CanChange, + TextPara_IsEqual, + TextPara_Reset, + TextPara_GetStyle, + TextPara_SetStyle, + TextPara_GetAlignment, + TextPara_SetAlignment, + TextPara_GetHyphenation, + TextPara_SetHyphenation, + TextPara_GetFirstLineIndent, + TextPara_GetKeepTogether, + TextPara_SetKeepTogether, + TextPara_GetKeepWithNext, + TextPara_SetKeepWithNext, + TextPara_GetLeftIndent, + TextPara_GetLineSpacing, + TextPara_GetLineSpacingRule, + TextPara_GetListAlignment, + TextPara_SetListAlignment, + TextPara_GetListLevelIndex, + TextPara_SetListLevelIndex, + TextPara_GetListStart, + TextPara_SetListStart, + TextPara_GetListTab, + TextPara_SetListTab, + TextPara_GetListType, + TextPara_SetListType, + TextPara_GetNoLineNumber, + TextPara_SetNoLineNumber, + TextPara_GetPageBreakBefore, + TextPara_SetPageBreakBefore, + TextPara_GetRightIndent, + TextPara_SetRightIndent, + TextPara_SetIndents, + TextPara_SetLineSpacing, + TextPara_GetSpaceAfter, + TextPara_SetSpaceAfter, + TextPara_GetSpaceBefore, + TextPara_SetSpaceBefore, + TextPara_GetWidowControl, + TextPara_SetWidowControl, + TextPara_GetTabCount, + TextPara_AddTab, + TextPara_ClearAllTabs, + TextPara_DeleteTab, + TextPara_GetTab +}; + +static HRESULT create_textpara(ITextRange *range, ITextPara **ret) +{ + ITextParaImpl *para; + + *ret = NULL; + para = heap_alloc(sizeof(*para)); + if (!para) + return E_OUTOFMEMORY; + + para->ITextPara_iface.lpVtbl = &textparavtbl; + para->ref = 1; + para->range = range; + ITextRange_AddRef(range); + + *ret = ¶->ITextPara_iface; + return S_OK; +} + /* ITextDocument */ static HRESULT WINAPI ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid, @@ -2501,7 +3012,7 @@ static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pF return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **ppPara) +static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **para) { ITextSelectionImpl *This = impl_from_ITextSelection(me); if (!This->reOle) diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index bced652adfb..6960c7a8db4 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -1140,6 +1140,56 @@ static void test_GetFont(void) release_interfaces(&hwnd, &reOle, &doc, NULL); } +static void test_GetPara(void) +{ + static const CHAR test_text1[] = "TestSomeText"; + IRichEditOle *reOle = NULL; + ITextDocument *doc = NULL; + ITextRange *range = NULL; + ITextPara *para, *para2; + HRESULT hr; + HWND hwnd; + + create_interfaces(&hwnd, &reOle, &doc, NULL); + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); + + EXPECT_REF(reOle, 3); + EXPECT_REF(doc, 3); + + hr = ITextDocument_Range(doc, 0, 4, &range); + ok(hr == S_OK, "got 0x%08x\n", hr); + + EXPECT_REF(reOle, 3); + EXPECT_REF(doc, 3); + EXPECT_REF(range, 1); + + hr = ITextRange_GetPara(range, NULL); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + + hr = ITextRange_GetPara(range, ¶); + ok(hr == S_OK, "got 0x%08x\n", hr); + + EXPECT_REF(reOle, 3); + EXPECT_REF(doc, 3); + EXPECT_REF(range, 2); + EXPECT_REF(para, 1); + + hr = ITextRange_GetPara(range, ¶2); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(para != para2, "got %p, %p\n", para, para2); + + EXPECT_REF(reOle, 3); + EXPECT_REF(doc, 3); + EXPECT_REF(range, 3); + EXPECT_REF(para, 1); + EXPECT_REF(para2, 1); + + ITextPara_Release(para); + ITextPara_Release(para2); + ITextRange_Release(range); + release_interfaces(&hwnd, &reOle, &doc, NULL); +} + START_TEST(richole) { /* Must explicitly LoadLibrary(). The test has no references to functions in @@ -1162,4 +1212,5 @@ START_TEST(richole) test_IOleWindow_GetWindow(); test_IOleInPlaceSite_GetWindow(); test_GetFont(); + test_GetPara(); }