riched20: Implement Expand for tomStory case.

This commit is contained in:
Nikolay Sivov 2015-06-16 16:15:09 +03:00 committed by Alexandre Julliard
parent dedbd18836
commit 3357fdd70a
2 changed files with 123 additions and 5 deletions

View File

@ -909,6 +909,35 @@ static void textfont_cache_range_props(ITextFontImpl *font)
} }
} }
static HRESULT textrange_expand(ITextRange *range, LONG unit, LONG *delta)
{
LONG expand_start, expand_end;
switch (unit)
{
case tomStory:
expand_start = 0;
ITextRange_GetStoryLength(range, &expand_end);
break;
default:
FIXME("unit %d is not supported\n", unit);
return E_NOTIMPL;
}
if (delta) {
LONG start, end;
ITextRange_GetStart(range, &start);
ITextRange_GetEnd(range, &end);
*delta = expand_end - expand_start - (end - start);
}
ITextRange_SetStart(range, expand_start);
ITextRange_SetEnd(range, expand_end);
return S_OK;
}
static HRESULT WINAPI IRichEditOleImpl_inner_fnQueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppvObj) static HRESULT WINAPI IRichEditOleImpl_inner_fnQueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppvObj)
{ {
IRichEditOleImpl *This = impl_from_IUnknown(iface); IRichEditOleImpl *This = impl_from_IUnknown(iface);
@ -1970,12 +1999,12 @@ static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG unit, LONG *delta
{ {
ITextRangeImpl *This = impl_from_ITextRange(me); ITextRangeImpl *This = impl_from_ITextRange(me);
FIXME("(%p)->(%d %p): stub\n", This, unit, delta); TRACE("(%p)->(%d %p)\n", This, unit, delta);
if (!This->child.reole) if (!This->child.reole)
return CO_E_RELEASED; return CO_E_RELEASED;
return E_NOTIMPL; return textrange_expand(me, unit, delta);
} }
static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG unit, LONG *index) static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG unit, LONG *index)
@ -4494,14 +4523,16 @@ static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
return hres; return hres;
} }
static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta) static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG unit, LONG *delta)
{ {
ITextSelectionImpl *This = impl_from_ITextSelection(me); ITextSelectionImpl *This = impl_from_ITextSelection(me);
TRACE("(%p)->(%d %p)\n", This, unit, delta);
if (!This->reOle) if (!This->reOle)
return CO_E_RELEASED; return CO_E_RELEASED;
FIXME("not implemented\n"); return textrange_expand((ITextRange*)me, unit, delta);
return E_NOTIMPL;
} }
static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex) static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)

View File

@ -3251,6 +3251,92 @@ static void test_ITextSelection_GetDuplicate(void)
ITextRange_Release(range); ITextRange_Release(range);
} }
static void test_Expand(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_Expand(range, tomStory, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = ITextRange_GetStart(range, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 0, "got %d\n", value);
hr = ITextRange_GetEnd(range, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 13, "got %d\n", value);
hr = ITextSelection_Expand(selection, tomStory, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = ITextSelection_GetStart(selection, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 0, "got %d\n", value);
hr = ITextSelection_GetEnd(selection, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 13, "got %d\n", value);
hr = ITextRange_SetStart(range, 1);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = ITextRange_SetEnd(range, 2);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = ITextSelection_SetStart(selection, 1);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = ITextSelection_SetEnd(selection, 2);
ok(hr == S_OK, "got 0x%08x\n", hr);
value = 0;
hr = ITextRange_Expand(range, tomStory, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 12, "got %d\n", value);
hr = ITextRange_GetStart(range, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 0, "got %d\n", value);
hr = ITextRange_GetEnd(range, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 13, "got %d\n", value);
value = 0;
hr = ITextSelection_Expand(selection, tomStory, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 12, "got %d\n", value);
hr = ITextSelection_GetStart(selection, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 0, "got %d\n", value);
hr = ITextSelection_GetEnd(selection, &value);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(value == 13, "got %d\n", value);
release_interfaces(&hwnd, &reole, &doc, NULL);
hr = ITextRange_Expand(range, tomStory, NULL);
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
hr = ITextRange_Expand(range, tomStory, &value);
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
hr = ITextSelection_Expand(selection, tomStory, NULL);
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
hr = ITextSelection_Expand(selection, tomStory, &value);
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
ITextSelection_Release(selection);
ITextRange_Release(range);
}
START_TEST(richole) START_TEST(richole)
{ {
/* Must explicitly LoadLibrary(). The test has no references to functions in /* Must explicitly LoadLibrary(). The test has no references to functions in
@ -3286,4 +3372,5 @@ START_TEST(richole)
test_InsertObject(); test_InsertObject();
test_GetStoryLength(); test_GetStoryLength();
test_ITextSelection_GetDuplicate(); test_ITextSelection_GetDuplicate();
test_Expand();
} }