Jactry Zeng : riched20: Implement ITextSelection::Collapse.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Sep 17 14:07:09 CDT 2014
Module: wine
Branch: master
Commit: 40456439e622c388e0f317219ab9bcaf688991a2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=40456439e622c388e0f317219ab9bcaf688991a2
Author: Jactry Zeng <wine at jactry.com>
Date: Wed Sep 17 17:38:47 2014 +0800
riched20: Implement ITextSelection::Collapse.
---
dlls/riched20/richole.c | 9 ++++--
dlls/riched20/tests/richole.c | 70 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 8e87879..f7e7870 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -1754,11 +1754,16 @@ static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pV
static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
{
ITextSelectionImpl *This = impl_from_ITextSelection(me);
+ LONG start, end;
+ HRESULT hres;
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented\n");
- return E_NOTIMPL;
+ ME_GetSelectionOfs(This->reOle->editor, &start, &end);
+ hres = range_Collapse(bStart, &start, &end);
+ if (SUCCEEDED(hres))
+ ME_SetSelection(This->reOle->editor, start, end);
+ return hres;
}
static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index 104b2aa..eed335c 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -872,6 +872,75 @@ static void test_ITextRange_Collapse(void)
release_interfaces(&w, &reOle, &txtDoc, NULL);
}
+static void test_ITextSelection_Collapse(void)
+{
+ HWND w;
+ IRichEditOle *reOle = NULL;
+ ITextDocument *txtDoc = NULL;
+ ITextSelection *txtSel = NULL;
+ HRESULT hres;
+ LONG first, lim, start, end;
+ static const CHAR test_text1[] = "TestSomeText";
+
+ create_interfaces(&w, &reOle, &txtDoc, &txtSel);
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
+
+ first = 4, lim = 8;
+ SendMessageA(w, EM_SETSEL, first, lim);
+ hres = ITextSelection_Collapse(txtSel, tomTrue);
+ ok(hres == S_OK, "ITextSelection_Collapse\n");
+ SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
+ ok(start == 4, "got wrong start value: %d\n", start);
+ ok(end == 4, "got wrong end value: %d\n", end);
+
+ SendMessageA(w, EM_SETSEL, first, lim);
+ hres = ITextSelection_Collapse(txtSel, tomStart);
+ ok(hres == S_OK, "ITextSelection_Collapse\n");
+ SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
+ ok(start == 4, "got wrong start value: %d\n", start);
+ ok(end == 4, "got wrong end value: %d\n", end);
+
+ SendMessageA(w, EM_SETSEL, first, lim);
+ hres = ITextSelection_Collapse(txtSel, tomFalse);
+ ok(hres == S_OK, "ITextSelection_Collapse\n");
+ SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
+ ok(start == 8, "got wrong start value: %d\n", start);
+ ok(end == 8, "got wrong end value: %d\n", end);
+
+ SendMessageA(w, EM_SETSEL, first, lim);
+ hres = ITextSelection_Collapse(txtSel, tomEnd);
+ ok(hres == S_OK, "ITextSelection_Collapse\n");
+ SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
+ ok(start == 8, "got wrong start value: %d\n", start);
+ ok(end == 8, "got wrong end value: %d\n", end);
+
+ /* tomStart is the default */
+ SendMessageA(w, EM_SETSEL, first, lim);
+ hres = ITextSelection_Collapse(txtSel, 256);
+ ok(hres == S_OK, "ITextSelection_Collapse\n");
+ SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
+ ok(start == 4, "got wrong start value: %d\n", start);
+ ok(end == 4, "got wrong end value: %d\n", end);
+
+ first = 6, lim = 6;
+ SendMessageA(w, EM_SETSEL, first, lim);
+ hres = ITextSelection_Collapse(txtSel, tomEnd);
+ ok(hres == S_FALSE, "ITextSelection_Collapse\n");
+ SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
+ ok(start == 6, "got wrong start value: %d\n", start);
+ ok(end == 6, "got wrong end value: %d\n", end);
+
+ first = 8, lim = 8;
+ SendMessageA(w, EM_SETSEL, first, lim);
+ hres = ITextSelection_Collapse(txtSel, tomStart);
+ ok(hres == S_FALSE, "ITextSelection_Collapse\n");
+ SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
+ ok(start == 8, "got wrong start value: %d\n", start);
+ ok(end == 8, "got wrong end value: %d\n", end);
+
+ release_interfaces(&w, &reOle, &txtDoc, &txtSel);
+}
+
START_TEST(richole)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
@@ -884,6 +953,7 @@ START_TEST(richole)
test_ITextSelection_GetText();
test_ITextSelection_GetChar();
test_ITextSelection_GetStart_GetEnd();
+ test_ITextSelection_Collapse();
test_ITextDocument_Range();
test_ITextRange_GetChar();
test_ITextRange_GetStart_GetEnd();
More information about the wine-cvs
mailing list