Commit a7c9fbc6 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

msxml3: Implemented IXMLDOMText substringData.

parent b2ad268a
......@@ -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 );
......
......@@ -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(
......
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