Nikolay Sivov : riched20: Implement SetEnd().
Alexandre Julliard
julliard at wine.codeweavers.com
Mon May 18 07:57:33 CDT 2015
Module: wine
Branch: master
Commit: f0959dc1759a8434ccab66eecd0b671693a1a96a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f0959dc1759a8434ccab66eecd0b671693a1a96a
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun May 17 17:30:06 2015 +0300
riched20: Implement SetEnd().
---
dlls/riched20/richole.c | 23 ++++++++++++--
dlls/riched20/tests/richole.c | 70 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 90 insertions(+), 3 deletions(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 1cb47c2..4f85325 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -948,14 +948,31 @@ static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
return S_OK;
}
-static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim)
+static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG end)
{
ITextRangeImpl *This = impl_from_ITextRange(me);
+ int len;
+
+ TRACE("(%p)->(%d)\n", This, end);
+
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented %p\n", This);
- return E_NOTIMPL;
+ if (end == This->end)
+ return S_FALSE;
+
+ if (end < This->start) {
+ This->start = This->end = max(0, end);
+ return S_OK;
+ }
+
+ len = ME_GetTextLength(This->reOle->editor);
+ if (end > len)
+ This->end = len + 1;
+ else
+ This->end = end;
+
+ return S_OK;
}
static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **font)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index 2d46729..0af617b 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -759,6 +759,76 @@ static void test_ITextRange_GetStart_GetEnd(void)
ok(hres == S_OK, "got 0x%08x\n", hres);
ok(end == 12, "got %d\n", end);
+ /* SetEnd */
+ hres = ITextRange_SetStart(txtRge, 0);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+
+ /* same value */
+ hres = ITextRange_SetEnd(txtRge, 5);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+
+ hres = ITextRange_SetEnd(txtRge, 5);
+ ok(hres == S_FALSE, "got 0x%08x\n", hres);
+
+ /* negative resets to 0 */
+ hres = ITextRange_SetEnd(txtRge, -1);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+
+ end = -1;
+ hres = ITextRange_GetEnd(txtRge, &end);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+ ok(end == 0, "got %d\n", end);
+
+ start = -1;
+ hres = ITextRange_GetStart(txtRge, &start);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+ ok(start == 0, "got %d\n", start);
+
+ /* greater than initial end, but less than total char count */
+ hres = ITextRange_SetStart(txtRge, 3);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+
+ hres = ITextRange_SetEnd(txtRge, 1);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+
+ start = 0;
+ hres = ITextRange_GetStart(txtRge, &start);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+ ok(start == 1, "got %d\n", start);
+
+ end = 0;
+ hres = ITextRange_GetEnd(txtRge, &end);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+ ok(end == 1, "got %d\n", end);
+
+ /* more than total count */
+ hres = ITextRange_SetEnd(txtRge, 50);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+
+ start = 0;
+ hres = ITextRange_GetStart(txtRge, &start);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+ ok(start == 1, "got %d\n", start);
+
+ end = 0;
+ hres = ITextRange_GetEnd(txtRge, &end);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+ ok(end == 13, "got %d\n", end);
+
+ /* zero */
+ hres = ITextRange_SetEnd(txtRge, 0);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+
+ start = 0;
+ hres = ITextRange_GetStart(txtRge, &start);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+ ok(start == 0, "got %d\n", start);
+
+ end = 0;
+ hres = ITextRange_GetEnd(txtRge, &end);
+ ok(hres == S_OK, "got 0x%08x\n", hres);
+ ok(end == 0, "got %d\n", end);
+
ITextRange_Release(txtRge);
release_interfaces(&w, &reOle, &txtDoc, NULL);
More information about the wine-cvs
mailing list