Nikolay Sivov : riched20: Implement SetStart().

Alexandre Julliard julliard at wine.codeweavers.com
Mon May 18 07:57:33 CDT 2015


Module: wine
Branch: master
Commit: 3a0670ed7e87d4e247060cdd822c4371c5b734ab
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3a0670ed7e87d4e247060cdd822c4371c5b734ab

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sun May 17 17:28:41 2015 +0300

riched20: Implement SetStart().

---

 dlls/riched20/richole.c       | 26 ++++++++++++++++++++---
 dlls/riched20/tests/richole.c | 48 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+), 3 deletions(-)

diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 39c4bb4f..1cb47c2 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -905,14 +905,34 @@ static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst)
     return S_OK;
 }
 
-static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG cpFirst)
+static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG start)
 {
     ITextRangeImpl *This = impl_from_ITextRange(me);
+    int len;
+
+    TRACE("(%p)->(%d)\n", This, start);
+
     if (!This->reOle)
         return CO_E_RELEASED;
 
-    FIXME("not implemented %p\n", This);
-    return E_NOTIMPL;
+    if (start == This->start)
+        return S_FALSE;
+
+    if (start < 0) {
+        This->start = 0;
+        return S_OK;
+    }
+
+    len = ME_GetTextLength(This->reOle->editor);
+    if (start > This->end)
+        This->end = len;
+
+    if (start > len)
+        This->start = len;
+    else
+        This->start = start;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index 6960c7a..2d46729 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -711,6 +711,54 @@ static void test_ITextRange_GetStart_GetEnd(void)
   hres = ITextRange_GetEnd(txtRge, &end);
   ok(hres == S_OK, "ITextRange_GetEnd\n");
   ok(end == 12, "got wrong end value: %d\n", end);
+
+  /* SetStart */
+  hres = ITextRange_SetStart(txtRge, 0);
+  ok(hres == S_OK, "got 0x%08x\n", hres);
+
+  /* same value */
+  hres = ITextRange_SetStart(txtRge, 0);
+  ok(hres == S_FALSE, "got 0x%08x\n", hres);
+
+  hres = ITextRange_SetStart(txtRge, 1);
+  ok(hres == S_OK, "got 0x%08x\n", hres);
+
+  /* negative resets to 0 */
+  hres = ITextRange_SetStart(txtRge, -1);
+  ok(hres == S_OK, "got 0x%08x\n", hres);
+
+  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, 10);
+  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 == 10, "got %d\n", start);
+
+  end = 0;
+  hres = ITextRange_GetEnd(txtRge, &end);
+  ok(hres == S_OK, "got 0x%08x\n", hres);
+  ok(end == 12, "got %d\n", end);
+
+  hres = ITextRange_SetStart(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 == 12, "got %d\n", start);
+
+  end = 0;
+  hres = ITextRange_GetEnd(txtRge, &end);
+  ok(hres == S_OK, "got 0x%08x\n", hres);
+  ok(end == 12, "got %d\n", end);
+
   ITextRange_Release(txtRge);
 
   release_interfaces(&w, &reOle, &txtDoc, NULL);




More information about the wine-cvs mailing list