mirror of
https://github.com/reactos/wine.git
synced 2025-01-26 22:24:37 +00:00
msxml3: Implement IXMLDOMCDATASection_substringData.
This commit is contained in:
parent
777aa3382d
commit
c7f3dfc1a1
@ -539,8 +539,45 @@ static HRESULT WINAPI domcdata_substringData(
|
||||
IXMLDOMCDATASection *iface,
|
||||
long offset, long count, BSTR *p)
|
||||
{
|
||||
FIXME("\n");
|
||||
return E_NOTIMPL;
|
||||
domcdata *This = impl_from_IXMLDOMCDATASection( 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 domcdata_appendData(
|
||||
|
@ -2454,6 +2454,52 @@ static void test_xmlTypes(void)
|
||||
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
|
||||
SysFreeString(str);
|
||||
|
||||
/* test substringData */
|
||||
hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, 4, NULL);
|
||||
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
|
||||
|
||||
/* test substringData - Invalid offset */
|
||||
str = (BSTR)&szElement;
|
||||
hr = IXMLDOMCDATASection_substringData(pCDataSec, -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 = IXMLDOMCDATASection_substringData(pCDataSec, 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 = IXMLDOMCDATASection_substringData(pCDataSec, 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 = IXMLDOMCDATASection_substringData(pCDataSec, 2, 0, &str);
|
||||
ok(hr == S_FALSE, "ret %08x\n", hr );
|
||||
ok( str == NULL, "incorrect string\n");
|
||||
|
||||
/* test substringData - Start of string */
|
||||
hr = IXMLDOMCDATASection_substringData(pCDataSec, 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 = IXMLDOMCDATASection_substringData(pCDataSec, 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 = IXMLDOMCDATASection_substringData(pCDataSec, 20, 4, &str);
|
||||
ok(hr == S_OK, "ret %08x\n", hr );
|
||||
ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
|
||||
SysFreeString(str);
|
||||
|
||||
IXMLDOMCDATASection_Release(pCDataSec);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user