riched20: Implement ITextRange::GetStart and ITextRange::GetEnd.

This commit is contained in:
Jactry Zeng 2014-09-16 18:38:56 +08:00 committed by Alexandre Julliard
parent 1e434b52d0
commit b56c96a619
2 changed files with 75 additions and 4 deletions

View File

@ -638,8 +638,11 @@ static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst)
if (!This->reOle)
return CO_E_RELEASED;
FIXME("not implemented %p\n", This);
return E_NOTIMPL;
if (!pcpFirst)
return E_INVALIDARG;
*pcpFirst = This->start;
TRACE("%d\n", *pcpFirst);
return S_OK;
}
static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG cpFirst)
@ -658,8 +661,11 @@ static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
if (!This->reOle)
return CO_E_RELEASED;
FIXME("not implemented %p\n", This);
return E_NOTIMPL;
if (!pcpLim)
return E_INVALIDARG;
*pcpLim = This->end;
TRACE("%d\n", *pcpLim);
return S_OK;
}
static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim)

View File

@ -631,6 +631,70 @@ static void test_ITextSelection_GetChar(void)
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
}
static void test_ITextRange_GetStart_GetEnd(void)
{
HWND w;
IRichEditOle *reOle = NULL;
ITextDocument *txtDoc = NULL;
ITextRange *txtRge = NULL;
HRESULT hres;
int 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 = 1, lim = 6;
ITextDocument_Range(txtDoc, first, lim, &txtRge);
start = 0xdeadbeef;
hres = ITextRange_GetStart(txtRge, &start);
ok(hres == S_OK, "ITextRange_GetStart\n");
ok(start == 1, "got wrong start value: %d\n", start);
end = 0xdeadbeef;
hres = ITextRange_GetEnd(txtRge, &end);
ok(hres == S_OK, "ITextRange_GetEnd\n");
ok(end == 6, "got wrong end value: %d\n", end);
ITextRange_Release(txtRge);
first = 6, lim = 1;
ITextDocument_Range(txtDoc, first, lim, &txtRge);
start = 0xdeadbeef;
hres = ITextRange_GetStart(txtRge, &start);
ok(hres == S_OK, "ITextRange_GetStart\n");
ok(start == 1, "got wrong start value: %d\n", start);
end = 0xdeadbeef;
hres = ITextRange_GetEnd(txtRge, &end);
ok(hres == S_OK, "ITextRange_GetEnd\n");
ok(end == 6, "got wrong end value: %d\n", end);
ITextRange_Release(txtRge);
first = -1, lim = 13;
ITextDocument_Range(txtDoc, first, lim, &txtRge);
start = 0xdeadbeef;
hres = ITextRange_GetStart(txtRge, &start);
ok(hres == S_OK, "ITextRange_GetStart\n");
ok(start == 0, "got wrong start value: %d\n", start);
end = 0xdeadbeef;
hres = ITextRange_GetEnd(txtRge, &end);
ok(hres == S_OK, "ITextRange_GetEnd\n");
ok(end == 13, "got wrong end value: %d\n", end);
ITextRange_Release(txtRge);
first = 13, lim = 13;
ITextDocument_Range(txtDoc, first, lim, &txtRge);
start = 0xdeadbeef;
hres = ITextRange_GetStart(txtRge, &start);
ok(hres == S_OK, "ITextRange_GetStart\n");
ok(start == 12, "got wrong start value: %d\n", start);
end = 0xdeadbeef;
hres = ITextRange_GetEnd(txtRge, &end);
ok(hres == S_OK, "ITextRange_GetEnd\n");
ok(end == 12, "got wrong end value: %d\n", end);
ITextRange_Release(txtRge);
release_interfaces(&w, &reOle, &txtDoc, NULL);
}
START_TEST(richole)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
@ -644,4 +708,5 @@ START_TEST(richole)
test_ITextSelection_GetChar();
test_ITextDocument_Range();
test_ITextRange_GetChar();
test_ITextRange_GetStart_GetEnd();
}