msxml3: Implement IXMLDOMComment_substringData.
This commit is contained in:
parent
741fa21f95
commit
777aa3382d
|
@ -538,8 +538,45 @@ static HRESULT WINAPI domcomment_substringData(
|
|||
IXMLDOMComment *iface,
|
||||
long offset, long count, BSTR *p)
|
||||
{
|
||||
FIXME("\n");
|
||||
return E_NOTIMPL;
|
||||
domcomment *This = impl_from_IXMLDOMComment( iface );
|
||||
xmlnode *pDOMNode = impl_from_IXMLDOMNode( This->node );
|
||||
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 domcomment_appendData(
|
||||
|
|
|
@ -2189,6 +2189,52 @@ static void test_xmlTypes(void)
|
|||
ok(hr == S_OK, "ret %08x\n", hr );
|
||||
ok(len == 21, "expected 21 got %ld\n", len);
|
||||
|
||||
/* test substringData */
|
||||
hr = IXMLDOMComment_substringData(pComment, 0, 4, NULL);
|
||||
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
||||
|
||||
/* test substringData - Invalid offset */
|
||||
str = (BSTR)&szElement;
|
||||
hr = IXMLDOMComment_substringData(pComment, -1, 4, &str);
|
||||
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
||||
ok( str == NULL, "incorrect string\n");
|
||||
|
||||
/* test substringData - Invalid offset */
|
||||
str = (BSTR)&szElement;
|
||||
hr = IXMLDOMComment_substringData(pComment, 30, 0, &str);
|
||||
ok(hr == S_FALSE, "ret %08x\n", hr );
|
||||
ok( str == NULL, "incorrect string\n");
|
||||
|
||||
/* test substringData - Invalid size */
|
||||
str = (BSTR)&szElement;
|
||||
hr = IXMLDOMComment_substringData(pComment, 0, -1, &str);
|
||||
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
||||
ok( str == NULL, "incorrect string\n");
|
||||
|
||||
/* test substringData - Invalid size */
|
||||
str = (BSTR)&szElement;
|
||||
hr = IXMLDOMComment_substringData(pComment, 2, 0, &str);
|
||||
ok(hr == S_FALSE, "ret %08x\n", hr );
|
||||
ok( str == NULL, "incorrect string\n");
|
||||
|
||||
/* test substringData - Start of string */
|
||||
hr = IXMLDOMComment_substringData(pComment, 0, 4, &str);
|
||||
ok(hr == S_OK, "ret %08x\n", hr );
|
||||
ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
|
||||
SysFreeString(str);
|
||||
|
||||
/* test substringData - Middle of string */
|
||||
hr = IXMLDOMComment_substringData(pComment, 13, 4, &str);
|
||||
ok(hr == S_OK, "ret %08x\n", hr );
|
||||
ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
|
||||
SysFreeString(str);
|
||||
|
||||
/* test substringData - End of string */
|
||||
hr = IXMLDOMComment_substringData(pComment, 20, 4, &str);
|
||||
ok(hr == S_OK, "ret %08x\n", hr );
|
||||
ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
|
||||
SysFreeString(str);
|
||||
|
||||
IXMLDOMComment_Release(pComment);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue