From b56c96a619efa56dd8b224ce17ba54beb6503346 Mon Sep 17 00:00:00 2001 From: Jactry Zeng Date: Tue, 16 Sep 2014 18:38:56 +0800 Subject: [PATCH] riched20: Implement ITextRange::GetStart and ITextRange::GetEnd. --- dlls/riched20/richole.c | 14 +++++--- dlls/riched20/tests/richole.c | 65 +++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 4 deletions(-) diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index 963368f269e..dab26f3e998 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -638,8 +638,11 @@ static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst) if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; + if (!pcpFirst) + return E_INVALIDARG; + *pcpFirst = This->start; + TRACE("%d\n", *pcpFirst); + return S_OK; } static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG cpFirst) @@ -658,8 +661,11 @@ static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim) if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; + if (!pcpLim) + return E_INVALIDARG; + *pcpLim = This->end; + TRACE("%d\n", *pcpLim); + return S_OK; } static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim) diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 2e9b45a8c36..681c5f7950e 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -631,6 +631,70 @@ static void test_ITextSelection_GetChar(void) release_interfaces(&w, &reOle, &txtDoc, &txtSel); } +static void test_ITextRange_GetStart_GetEnd(void) +{ + HWND w; + IRichEditOle *reOle = NULL; + ITextDocument *txtDoc = NULL; + ITextRange *txtRge = NULL; + HRESULT hres; + int first, lim, start, end; + static const CHAR test_text1[] = "TestSomeText"; + + create_interfaces(&w, &reOle, &txtDoc, NULL); + SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); + + first = 1, lim = 6; + ITextDocument_Range(txtDoc, first, lim, &txtRge); + start = 0xdeadbeef; + hres = ITextRange_GetStart(txtRge, &start); + ok(hres == S_OK, "ITextRange_GetStart\n"); + ok(start == 1, "got wrong start value: %d\n", start); + end = 0xdeadbeef; + hres = ITextRange_GetEnd(txtRge, &end); + ok(hres == S_OK, "ITextRange_GetEnd\n"); + ok(end == 6, "got wrong end value: %d\n", end); + ITextRange_Release(txtRge); + + first = 6, lim = 1; + ITextDocument_Range(txtDoc, first, lim, &txtRge); + start = 0xdeadbeef; + hres = ITextRange_GetStart(txtRge, &start); + ok(hres == S_OK, "ITextRange_GetStart\n"); + ok(start == 1, "got wrong start value: %d\n", start); + end = 0xdeadbeef; + hres = ITextRange_GetEnd(txtRge, &end); + ok(hres == S_OK, "ITextRange_GetEnd\n"); + ok(end == 6, "got wrong end value: %d\n", end); + ITextRange_Release(txtRge); + + first = -1, lim = 13; + ITextDocument_Range(txtDoc, first, lim, &txtRge); + start = 0xdeadbeef; + hres = ITextRange_GetStart(txtRge, &start); + ok(hres == S_OK, "ITextRange_GetStart\n"); + ok(start == 0, "got wrong start value: %d\n", start); + end = 0xdeadbeef; + hres = ITextRange_GetEnd(txtRge, &end); + ok(hres == S_OK, "ITextRange_GetEnd\n"); + ok(end == 13, "got wrong end value: %d\n", end); + ITextRange_Release(txtRge); + + first = 13, lim = 13; + ITextDocument_Range(txtDoc, first, lim, &txtRge); + start = 0xdeadbeef; + hres = ITextRange_GetStart(txtRge, &start); + ok(hres == S_OK, "ITextRange_GetStart\n"); + ok(start == 12, "got wrong start value: %d\n", start); + end = 0xdeadbeef; + hres = ITextRange_GetEnd(txtRge, &end); + ok(hres == S_OK, "ITextRange_GetEnd\n"); + ok(end == 12, "got wrong end value: %d\n", end); + ITextRange_Release(txtRge); + + release_interfaces(&w, &reOle, &txtDoc, NULL); +} + START_TEST(richole) { /* Must explicitly LoadLibrary(). The test has no references to functions in @@ -644,4 +708,5 @@ START_TEST(richole) test_ITextSelection_GetChar(); test_ITextDocument_Range(); test_ITextRange_GetChar(); + test_ITextRange_GetStart_GetEnd(); }