riched20: Implement ITextRange::GetDuplicate.

This commit is contained in:
Jactry Zeng 2014-09-17 17:36:44 +08:00 committed by Alexandre Julliard
parent f06a57f678
commit da40589e71
2 changed files with 42 additions and 2 deletions

View File

@ -602,14 +602,19 @@ static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch)
return E_NOTIMPL;
}
static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange);
static HRESULT WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange)
{
ITextRangeImpl *This = impl_from_ITextRange(me);
if (!This->reOle)
return CO_E_RELEASED;
FIXME("not implemented %p\n", This);
return E_NOTIMPL;
TRACE("%p %p\n", This, ppRange);
if (!ppRange)
return E_INVALIDARG;
return CreateITextRange(This->reOle, This->start, This->end, ppRange);
}
static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **ppRange)

View File

@ -755,6 +755,40 @@ static void test_ITextSelection_GetStart_GetEnd(void)
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
}
static void test_ITextRange_GetDuplicate(void)
{
HWND w;
IRichEditOle *reOle = NULL;
ITextDocument *txtDoc = NULL;
ITextRange *txtRge = NULL;
ITextRange *txtRgeDup = NULL;
HRESULT hres;
LONG 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 = 0, lim = 4;
hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
hres = ITextRange_GetDuplicate(txtRge, &txtRgeDup);
ok(hres == S_OK, "ITextRange_GetDuplicate\n");
ok(txtRgeDup != txtRge, "A new pointer should be returned\n");
ITextRange_GetStart(txtRgeDup, &start);
ok(start == first, "got wrong value: %d\n", start);
ITextRange_GetEnd(txtRgeDup, &end);
ok(end == lim, "got wrong value: %d\n", end);
ITextRange_Release(txtRgeDup);
hres = ITextRange_GetDuplicate(txtRge, NULL);
ok(hres == E_INVALIDARG, "ITextRange_GetDuplicate\n");
ITextRange_Release(txtRge);
release_interfaces(&w, &reOle, &txtDoc, NULL);
}
START_TEST(richole)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
@ -770,4 +804,5 @@ START_TEST(richole)
test_ITextDocument_Range();
test_ITextRange_GetChar();
test_ITextRange_GetStart_GetEnd();
test_ITextRange_GetDuplicate();
}