Commit 3357fdd7 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

riched20: Implement Expand for tomStory case.

parent dedbd188
......@@ -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)
{
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);
FIXME("(%p)->(%d %p): stub\n", This, unit, delta);
TRACE("(%p)->(%d %p)\n", This, unit, delta);
if (!This->child.reole)
return CO_E_RELEASED;
return E_NOTIMPL;
return textrange_expand(me, unit, delta);
}
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;
}
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);
TRACE("(%p)->(%d %p)\n", This, unit, delta);
if (!This->reOle)
return CO_E_RELEASED;
FIXME("not implemented\n");
return E_NOTIMPL;
return textrange_expand((ITextRange*)me, unit, delta);
}
static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
......
......@@ -3251,6 +3251,92 @@ static void test_ITextSelection_GetDuplicate(void)
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)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
......@@ -3286,4 +3372,5 @@ START_TEST(richole)
test_InsertObject();
test_GetStoryLength();
test_ITextSelection_GetDuplicate();
test_Expand();
}
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