Module: wine Branch: master Commit: da40589e7157854cbe278f45e3eaefbf25963c6e URL: http://source.winehq.org/git/wine.git/?a=commit;h=da40589e7157854cbe278f45e3...
Author: Jactry Zeng wine@jactry.com Date: Wed Sep 17 17:36:44 2014 +0800
riched20: Implement ITextRange::GetDuplicate.
---
dlls/riched20/richole.c | 9 +++++++-- dlls/riched20/tests/richole.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index ddaee28..d8e206c 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -602,14 +602,19 @@ static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch) return E_NOTIMPL; }
+static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange); + static HRESULT WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange) { ITextRangeImpl *This = impl_from_ITextRange(me); if (!This->reOle) return CO_E_RELEASED;
- FIXME("not implemented %p\n", This); - return E_NOTIMPL; + TRACE("%p %p\n", This, ppRange); + if (!ppRange) + return E_INVALIDARG; + + return CreateITextRange(This->reOle, This->start, This->end, ppRange); }
static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **ppRange) diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 312ab28..2fd12a5 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -755,6 +755,40 @@ static void test_ITextSelection_GetStart_GetEnd(void) release_interfaces(&w, &reOle, &txtDoc, &txtSel); }
+static void test_ITextRange_GetDuplicate(void) +{ + HWND w; + IRichEditOle *reOle = NULL; + ITextDocument *txtDoc = NULL; + ITextRange *txtRge = NULL; + ITextRange *txtRgeDup = NULL; + HRESULT hres; + LONG 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 = 0, lim = 4; + hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); + ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres); + + hres = ITextRange_GetDuplicate(txtRge, &txtRgeDup); + ok(hres == S_OK, "ITextRange_GetDuplicate\n"); + ok(txtRgeDup != txtRge, "A new pointer should be returned\n"); + ITextRange_GetStart(txtRgeDup, &start); + ok(start == first, "got wrong value: %d\n", start); + ITextRange_GetEnd(txtRgeDup, &end); + ok(end == lim, "got wrong value: %d\n", end); + + ITextRange_Release(txtRgeDup); + + hres = ITextRange_GetDuplicate(txtRge, NULL); + ok(hres == E_INVALIDARG, "ITextRange_GetDuplicate\n"); + + ITextRange_Release(txtRge); + release_interfaces(&w, &reOle, &txtDoc, NULL); +} + START_TEST(richole) { /* Must explicitly LoadLibrary(). The test has no references to functions in @@ -770,4 +804,5 @@ START_TEST(richole) test_ITextDocument_Range(); test_ITextRange_GetChar(); test_ITextRange_GetStart_GetEnd(); + test_ITextRange_GetDuplicate(); }