msxml3: Implemented IXMLDOMText substringData.

This commit is contained in:
Alistair Leslie-Hughes 2008-02-29 22:39:30 +11:00 committed by Alexandre Julliard
parent b2ad268a8b
commit a7c9fbc65c
2 changed files with 85 additions and 2 deletions

View file

@ -592,6 +592,52 @@ static void test_domdoc( void )
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
SysFreeString(str);
/* test substringData */
r = IXMLDOMText_substringData(nodetext, 0, 4, NULL);
ok(r == E_INVALIDARG, "ret %08x\n", r );
/* test substringData - Invalid offset */
str = (BSTR)&szElement;
r = IXMLDOMText_substringData(nodetext, -1, 4, &str);
ok(r == E_INVALIDARG, "ret %08x\n", r );
ok( str == NULL, "incorrect string\n");
/* test substringData - Invalid offset */
str = (BSTR)&szElement;
r = IXMLDOMText_substringData(nodetext, 30, 0, &str);
ok(r == S_FALSE, "ret %08x\n", r );
ok( str == NULL, "incorrect string\n");
/* test substringData - Invalid size */
str = (BSTR)&szElement;
r = IXMLDOMText_substringData(nodetext, 0, -1, &str);
ok(r == E_INVALIDARG, "ret %08x\n", r );
ok( str == NULL, "incorrect string\n");
/* test substringData - Invalid size */
str = (BSTR)&szElement;
r = IXMLDOMText_substringData(nodetext, 2, 0, &str);
ok(r == S_FALSE, "ret %08x\n", r );
ok( str == NULL, "incorrect string\n");
/* test substringData - Start of string */
r = IXMLDOMText_substringData(nodetext, 0, 4, &str);
ok(r == S_OK, "ret %08x\n", r );
ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
SysFreeString(str);
/* test substringData - Middle of string */
r = IXMLDOMText_substringData(nodetext, 13, 4, &str);
ok(r == S_OK, "ret %08x\n", r );
ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
SysFreeString(str);
/* test substringData - End of string */
r = IXMLDOMText_substringData(nodetext, 20, 4, &str);
ok(r == S_OK, "ret %08x\n", r );
ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
SysFreeString(str);
IXMLDOMText_Release( nodetext );
}
SysFreeString( str );

View file

@ -539,8 +539,45 @@ static HRESULT WINAPI domtext_substringData(
IXMLDOMText *iface,
long offset, long count, BSTR *p)
{
FIXME("\n");
return E_NOTIMPL;
domtext *This = impl_from_IXMLDOMText( iface );
xmlnode *pDOMNode = impl_from_IXMLDOMNode( (IXMLDOMNode*)This->element );
xmlChar *pContent;
long nLength = 0;
HRESULT hr = S_FALSE;
TRACE("%p\n", iface);
if(!p)
return E_INVALIDARG;
*p = NULL;
if(offset < 0 || count < 0)
return E_INVALIDARG;
if(count == 0)
return hr;
pContent = xmlNodeGetContent(pDOMNode->node);
if(pContent)
{
nLength = xmlStrlen(pContent);
if( offset < nLength)
{
BSTR sContent = bstr_from_xmlChar(pContent);
if(offset + count > nLength)
*p = SysAllocString(&sContent[offset]);
else
*p = SysAllocStringLen(&sContent[offset], count);
SysFreeString(sContent);
hr = S_OK;
}
xmlFree(pContent);
}
return hr;
}
static HRESULT WINAPI domtext_appendData(