mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
msxml3: Implement IXMLDOMText::deleteData().
This commit is contained in:
parent
173c4884ac
commit
a03bc72690
@ -868,6 +868,77 @@ static void test_domdoc( void )
|
||||
ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
|
||||
SysFreeString(str);
|
||||
|
||||
/* delete data */
|
||||
/* invalid arguments */
|
||||
r = IXMLDOMText_deleteData(nodetext, -1, 1);
|
||||
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
||||
|
||||
r = IXMLDOMText_deleteData(nodetext, 0, 0);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
|
||||
r = IXMLDOMText_deleteData(nodetext, 0, -1);
|
||||
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
||||
|
||||
r = IXMLDOMText_get_length(nodetext, &nLength);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
ok(nLength == 43, "expected 43 got %d\n", nLength);
|
||||
|
||||
r = IXMLDOMText_deleteData(nodetext, nLength, 1);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
|
||||
r = IXMLDOMText_deleteData(nodetext, nLength+1, 1);
|
||||
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
||||
|
||||
/* delete from start */
|
||||
r = IXMLDOMText_deleteData(nodetext, 0, 5);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
|
||||
r = IXMLDOMText_get_length(nodetext, &nLength);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
ok(nLength == 38, "expected 38 got %d\n", nLength);
|
||||
|
||||
r = IXMLDOMText_get_text(nodetext, &str);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
/* whitespace preserving needs to be handled here */
|
||||
todo_wine ok( !lstrcmpW( str, _bstr_("This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
|
||||
SysFreeString(str);
|
||||
|
||||
/* delete from end */
|
||||
r = IXMLDOMText_deleteData(nodetext, 35, 3);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
|
||||
r = IXMLDOMText_get_length(nodetext, &nLength);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
ok(nLength == 35, "expected 35 got %d\n", nLength);
|
||||
|
||||
r = IXMLDOMText_get_text(nodetext, &str);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
todo_wine ok( !lstrcmpW( str, _bstr_("This &is a Middle; test <>\\Append") ), "incorrect get_text string\n");
|
||||
SysFreeString(str);
|
||||
|
||||
/* delete from inside */
|
||||
r = IXMLDOMText_deleteData(nodetext, 1, 33);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
|
||||
r = IXMLDOMText_get_length(nodetext, &nLength);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
ok(nLength == 2, "expected 2 got %d\n", nLength);
|
||||
|
||||
r = IXMLDOMText_get_text(nodetext, &str);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
todo_wine ok( !lstrcmpW( str, _bstr_("") ), "incorrect get_text string\n");
|
||||
SysFreeString(str);
|
||||
|
||||
/* delete whole data ... */
|
||||
r = IXMLDOMText_get_length(nodetext, &nLength);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
|
||||
r = IXMLDOMText_deleteData(nodetext, 0, nLength);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
/* ... and try again with empty string */
|
||||
r = IXMLDOMText_deleteData(nodetext, 0, nLength);
|
||||
ok(r == S_OK, "ret %08x\n", r );
|
||||
|
||||
/* test put_data */
|
||||
V_VT(&var) = VT_BSTR;
|
||||
V_BSTR(&var) = SysAllocString(szstr1);
|
||||
|
@ -686,8 +686,47 @@ static HRESULT WINAPI domtext_deleteData(
|
||||
IXMLDOMText *iface,
|
||||
LONG offset, LONG count)
|
||||
{
|
||||
FIXME("\n");
|
||||
return E_NOTIMPL;
|
||||
HRESULT hr;
|
||||
LONG len = -1;
|
||||
BSTR str;
|
||||
|
||||
TRACE("%p %d %d\n", iface, offset, count);
|
||||
|
||||
hr = IXMLDOMText_get_length(iface, &len);
|
||||
if(hr != S_OK) return hr;
|
||||
|
||||
if((offset < 0) || (offset > len) || (count < 0))
|
||||
return E_INVALIDARG;
|
||||
|
||||
if(len == 0) return S_OK;
|
||||
|
||||
/* cutting start or end */
|
||||
if((offset == 0) || ((count + offset) >= len))
|
||||
{
|
||||
if(offset == 0)
|
||||
IXMLDOMText_substringData(iface, count, len - count, &str);
|
||||
else
|
||||
IXMLDOMText_substringData(iface, 0, offset, &str);
|
||||
hr = IXMLDOMText_put_data(iface, str);
|
||||
}
|
||||
else
|
||||
/* cutting from the inside */
|
||||
{
|
||||
BSTR str_end;
|
||||
|
||||
IXMLDOMText_substringData(iface, 0, offset, &str);
|
||||
IXMLDOMText_substringData(iface, offset + count, len - count, &str_end);
|
||||
|
||||
hr = IXMLDOMText_put_data(iface, str);
|
||||
if(hr == S_OK)
|
||||
hr = IXMLDOMText_appendData(iface, str_end);
|
||||
|
||||
SysFreeString(str_end);
|
||||
}
|
||||
|
||||
SysFreeString(str);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI domtext_replaceData(
|
||||
|
Loading…
Reference in New Issue
Block a user