riched20: Implement GetStoryLength().

This commit is contained in:
Nikolay Sivov 2015-06-06 19:34:56 +03:00 committed by Alexandre Julliard
parent 7be1159479
commit 9c6bcec509
2 changed files with 88 additions and 6 deletions

View File

@ -312,6 +312,15 @@ static HRESULT create_textfont(ITextRange*, const ITextFontImpl*, ITextFont**);
static HRESULT create_textpara(ITextRange*, ITextPara**);
static ITextSelectionImpl *CreateTextSelection(IRichEditOleImpl*);
static HRESULT textrange_get_storylength(ME_TextEditor *editor, LONG *length)
{
if (!length)
return E_INVALIDARG;
*length = ME_GetTextLength(editor) + 1;
return S_OK;
}
static void textranges_update_ranges(IRichEditOleImpl *reole, LONG start, LONG end, enum range_update_op op)
{
ITextRangeImpl *range;
@ -1897,14 +1906,16 @@ static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *pPara)
return E_NOTIMPL;
}
static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch)
static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *length)
{
ITextRangeImpl *This = impl_from_ITextRange(me);
TRACE("(%p)->(%p)\n", This, length);
if (!This->child.reole)
return CO_E_RELEASED;
FIXME("not implemented %p\n", This);
return E_NOTIMPL;
return textrange_get_storylength(This->child.reole->editor, length);
}
static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *value)
@ -4364,14 +4375,16 @@ static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pP
return E_NOTIMPL;
}
static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *length)
{
ITextSelectionImpl *This = impl_from_ITextSelection(me);
TRACE("(%p)->(%p)\n", This, length);
if (!This->reOle)
return CO_E_RELEASED;
FIXME("not implemented\n");
return E_NOTIMPL;
return textrange_get_storylength(This->reOle->editor, length);
}
static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *value)

View File

@ -3109,6 +3109,74 @@ static void test_InsertObject(void)
release_interfaces(&hwnd, &reole, &doc, NULL);
}
static void test_GetStoryLength(void)
{
static const CHAR test_text1[] = "TestSomeText";
IRichEditOle *reOle = NULL;
ITextDocument *doc = NULL;
ITextSelection *selection;
ITextRange *range;
LONG value;
HRESULT hr;
HWND hwnd;
create_interfaces(&hwnd, &reOle, &doc, &selection);
SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
SendMessageA(hwnd, EM_SETSEL, 1, 2);
hr = ITextDocument_Range(doc, 0, 4, &range);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = ITextRange_GetStoryLength(range, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
value = 0;
hr = ITextRange_GetStoryLength(range, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 13, "got %d\n", value);
hr = ITextSelection_GetStoryLength(selection, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
value = 0;
hr = ITextSelection_GetStoryLength(selection, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 13, "got %d\n", value);
SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"");
value = 0;
hr = ITextRange_GetStoryLength(range, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 1, "got %d\n", value);
value = 0;
hr = ITextSelection_GetStoryLength(selection, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 1, "got %d\n", value);
release_interfaces(&hwnd, &reOle, &doc, NULL);
hr = ITextRange_GetStoryLength(range, NULL);
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
value = 100;
hr = ITextRange_GetStoryLength(range, &value);
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
ok(value == 100, "got %d\n", value);
hr = ITextSelection_GetStoryLength(selection, NULL);
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
value = 100;
hr = ITextSelection_GetStoryLength(selection, &value);
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
ok(value == 100, "got %d\n", value);
ITextSelection_Release(selection);
ITextRange_Release(range);
}
START_TEST(richole)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
@ -3142,4 +3210,5 @@ START_TEST(richole)
test_GetStoryType();
test_SetFont();
test_InsertObject();
test_GetStoryLength();
}