Commit 52fee149 authored by Jactry Zeng's avatar Jactry Zeng Committed by Alexandre Julliard

riched20: Implement ITextSelection::GetStart and ITextSelection::GetEnd.

parent b56c96a6
......@@ -1630,11 +1630,15 @@ static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITex
static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
{
ITextSelectionImpl *This = impl_from_ITextSelection(me);
LONG lim;
if (!This->reOle)
return CO_E_RELEASED;
FIXME("not implemented\n");
return E_NOTIMPL;
if (!pcpFirst)
return E_INVALIDARG;
ME_GetSelectionOfs(This->reOle->editor, pcpFirst, &lim);
TRACE("%d\n", *pcpFirst);
return S_OK;
}
static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
......@@ -1650,11 +1654,15 @@ static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst
static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
{
ITextSelectionImpl *This = impl_from_ITextSelection(me);
LONG first;
if (!This->reOle)
return CO_E_RELEASED;
FIXME("not implemented\n");
return E_NOTIMPL;
if (!pcpLim)
return E_INVALIDARG;
ME_GetSelectionOfs(This->reOle->editor, &first, pcpLim);
TRACE("%d\n", *pcpLim);
return S_OK;
}
static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
......
......@@ -695,6 +695,66 @@ static void test_ITextRange_GetStart_GetEnd(void)
release_interfaces(&w, &reOle, &txtDoc, NULL);
}
static void test_ITextSelection_GetStart_GetEnd(void)
{
HWND w;
IRichEditOle *reOle = NULL;
ITextDocument *txtDoc = NULL;
ITextSelection *txtSel = NULL;
HRESULT hres;
int 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 = 2, lim = 5;
SendMessageA(w, EM_SETSEL, first, lim);
start = 0xdeadbeef;
hres = ITextSelection_GetStart(txtSel, &start);
ok(hres == S_OK, "ITextSelection_GetStart\n");
ok(start == 2, "got wrong start value: %d\n", start);
end = 0xdeadbeef;
hres = ITextSelection_GetEnd(txtSel, &end);
ok(hres == S_OK, "ITextSelection_GetEnd\n");
ok(end == 5, "got wrong end value: %d\n", end);
first = 5, lim = 2;
SendMessageA(w, EM_SETSEL, first, lim);
start = 0xdeadbeef;
hres = ITextSelection_GetStart(txtSel, &start);
ok(hres == S_OK, "ITextSelection_GetStart\n");
ok(start == 2, "got wrong start value: %d\n", start);
end = 0xdeadbeef;
hres = ITextSelection_GetEnd(txtSel, &end);
ok(hres == S_OK, "ITextSelection_GetEnd\n");
ok(end == 5, "got wrong end value: %d\n", end);
first = 0, lim = -1;
SendMessageA(w, EM_SETSEL, first, lim);
start = 0xdeadbeef;
hres = ITextSelection_GetStart(txtSel, &start);
ok(hres == S_OK, "ITextSelection_GetStart\n");
ok(start == 0, "got wrong start value: %d\n", start);
end = 0xdeadbeef;
hres = ITextSelection_GetEnd(txtSel, &end);
ok(hres == S_OK, "ITextSelection_GetEnd\n");
ok(end == 13, "got wrong end value: %d\n", end);
first = 13, lim = 13;
SendMessageA(w, EM_SETSEL, first, lim);
start = 0xdeadbeef;
hres = ITextSelection_GetStart(txtSel, &start);
ok(hres == S_OK, "ITextSelection_GetStart\n");
ok(start == 12, "got wrong start value: %d\n", start);
end = 0xdeadbeef;
hres = ITextSelection_GetEnd(txtSel, &end);
ok(hres == S_OK, "ITextSelection_GetEnd\n");
ok(end == 12, "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
......@@ -706,6 +766,7 @@ START_TEST(richole)
test_ITextDocument_Open();
test_ITextSelection_GetText();
test_ITextSelection_GetChar();
test_ITextSelection_GetStart_GetEnd();
test_ITextDocument_Range();
test_ITextRange_GetChar();
test_ITextRange_GetStart_GetEnd();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment