mshtml: Added IHTMLTxtRange::moveEnd implementation.

oldstable
Jacek Caban 2007-09-12 23:36:04 +02:00 committed by Alexandre Julliard
parent 11591e7720
commit d6c14fba3e
2 changed files with 64 additions and 2 deletions

View File

@ -155,6 +155,17 @@ static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, l
_test_range_text(line, range, NULL);
}
#define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, long cnt, long excnt)
{
long c = 0xdeadbeef;
HRESULT hres;
hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
ok_(__FILE__,line) (c == excnt, "count=%ld, expected %ld\n", c, excnt);
}
#define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
{
@ -245,6 +256,17 @@ static void test_txtrange(IHTMLDocument2 *doc)
test_range_text(range, "test abc 123\r\nit's text");
test_range_move(range, characterW, 3, 3);
test_range_moveend(range, characterW, 1, 1);
test_range_text(range, "t");
test_range_moveend(range, characterW, 3, 3);
test_range_text(range, "t ab");
test_range_moveend(range, characterW, -2, -2);
test_range_text(range, "t ");
test_range_move(range, characterW, 6, 6);
test_range_moveend(range, characterW, 3, 3);
test_range_text(range, "123");
test_range_moveend(range, characterW, 2, 2);
test_range_text(range, "123\r\ni");
IHTMLTxtRange_Release(range);
IHTMLTxtRange_Release(body_range);

View File

@ -1095,8 +1095,48 @@ static HRESULT WINAPI HTMLTxtRange_moveEnd(IHTMLTxtRange *iface, BSTR Unit,
long Count, long *ActualCount)
{
HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
FIXME("(%p)->(%s %ld %p)\n", This, debugstr_w(Unit), Count, ActualCount);
return E_NOTIMPL;
range_unit_t unit;
TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(Unit), Count, ActualCount);
unit = string_to_unit(Unit);
if(unit == RU_UNKNOWN)
return E_INVALIDARG;
if(!Count) {
*ActualCount = 0;
return S_OK;
}
switch(unit) {
case RU_CHAR: {
dompos_t cur_pos, new_pos;
PRBool collapsed;
get_cur_pos(This, FALSE, &cur_pos);
nsIDOMRange_GetCollapsed(This->nsrange, &collapsed);
if(Count > 0) {
*ActualCount = move_next_chars(Count, &cur_pos, collapsed, &new_pos);
set_range_pos(This, FALSE, &new_pos);
}else {
*ActualCount = -move_prev_chars(This, -Count, &cur_pos, TRUE, &new_pos);
if(*ActualCount == Count)
set_range_pos(This, FALSE, &new_pos);
else
IHTMLTxtRange_collapse(HTMLTXTRANGE(This), TRUE);
}
dompos_release(&cur_pos);
dompos_release(&new_pos);
break;
}
default:
FIXME("unimplemented unit %s\n", debugstr_w(Unit));
}
return S_OK;
}
static HRESULT WINAPI HTMLTxtRange_select(IHTMLTxtRange *iface)