From d178e7ba68b721a513bea994cb5b84cb00cf01b6 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 28 May 2015 09:59:02 +0300 Subject: [PATCH] riched20: Added GetStoryType(). --- dlls/riched20/riched_tom.idl | 2 ++ dlls/riched20/richole.c | 24 +++++++++++++----- dlls/riched20/tests/richole.c | 57 +++++++++++++++++++++++++++++++++++++++++++ include/tom.idl | 2 ++ 4 files changed, 79 insertions(+), 6 deletions(-) diff --git a/dlls/riched20/riched_tom.idl b/dlls/riched20/riched_tom.idl index 7aab8bb7784..cd033396afe 100644 --- a/dlls/riched20/riched_tom.idl +++ b/dlls/riched20/riched_tom.idl @@ -147,6 +147,8 @@ typedef enum tagTomConstants tomMatchWord = 2, tomMatchCase = 4, tomMatchPattern = 8, + + /* ITextRange story type values */ tomUnknownStory = 0, tomMainTextStory = 1, tomFootnotesStory = 2, diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index 5b0c7fc6898..e35f56167fc 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -1683,14 +1683,20 @@ static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch) return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *pValue) +static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *value) { ITextRangeImpl *This = impl_from_ITextRange(me); + + TRACE("(%p)->(%p)\n", This, value); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; + if (!value) + return E_INVALIDARG; + + *value = tomUnknownStory; + return S_OK; } static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end) @@ -4125,14 +4131,20 @@ static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG * return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue) +static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *value) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + TRACE("(%p)->(%p)\n", This, value); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); - return E_NOTIMPL; + if (!value) + return E_INVALIDARG; + + *value = tomUnknownStory; + return S_OK; } static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart) diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index f2ad6e2b2c0..35fd59c91b9 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -2867,6 +2867,62 @@ static void test_Select(void) ITextSelection_Release(selection); } +static void test_GetStoryType(void) +{ + static const CHAR test_text1[] = "TestSomeText"; + IRichEditOle *reOle = NULL; + ITextDocument *doc = NULL; + ITextSelection *selection; + ITextRange *range; + LONG value; + HRESULT hr; + HWND hwnd; + + create_interfaces(&hwnd, &reOle, &doc, &selection); + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); + SendMessageA(hwnd, EM_SETSEL, 1, 2); + + hr = ITextDocument_Range(doc, 0, 4, &range); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = ITextRange_GetStoryType(range, NULL); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + + value = tomTextFrameStory; + hr = ITextRange_GetStoryType(range, &value); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(value == tomUnknownStory, "got %d\n", value); + + hr = ITextSelection_GetStoryType(selection, NULL); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + + value = tomTextFrameStory; + hr = ITextSelection_GetStoryType(selection, &value); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(value == tomUnknownStory, "got %d\n", value); + + release_interfaces(&hwnd, &reOle, &doc, NULL); + + hr = ITextRange_GetStoryType(range, NULL); + ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + + value = 123; + hr = ITextRange_GetStoryType(range, &value); + ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(value == 123, "got %d\n", value); + + hr = ITextSelection_GetStoryType(selection, NULL); + ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + + value = 123; + hr = ITextSelection_GetStoryType(selection, &value); + ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(value == 123, "got %d\n", value); + + ITextRange_Release(range); + ITextSelection_Release(selection); +} + START_TEST(richole) { /* Must explicitly LoadLibrary(). The test has no references to functions in @@ -2897,4 +2953,5 @@ START_TEST(richole) test_InRange(); test_ITextRange_IsEqual(); test_Select(); + test_GetStoryType(); } diff --git a/include/tom.idl b/include/tom.idl index 245a41b323f..64209b3db1a 100644 --- a/include/tom.idl +++ b/include/tom.idl @@ -134,6 +134,8 @@ typedef enum tagTomConstants tomMatchWord = 2, tomMatchCase = 4, tomMatchPattern = 8, + + /* ITextRange story type values */ tomUnknownStory = 0, tomMainTextStory = 1, tomFootnotesStory = 2, -- 2.11.4.GIT