msxml3: Implemented IXMLDOMText_insertData.
This commit is contained in:
parent
b77af27067
commit
036953842d
|
@ -653,6 +653,47 @@ static void test_domdoc( void )
|
||||||
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
|
ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
|
||||||
|
/* test insertData */
|
||||||
|
str = SysAllocStringLen(NULL, 0);
|
||||||
|
r = IXMLDOMText_insertData(nodetext, -1, str);
|
||||||
|
ok(r == S_OK, "ret %08x\n", r );
|
||||||
|
|
||||||
|
r = IXMLDOMText_insertData(nodetext, -1, NULL);
|
||||||
|
ok(r == S_OK, "ret %08x\n", r );
|
||||||
|
|
||||||
|
r = IXMLDOMText_insertData(nodetext, 1000, str);
|
||||||
|
ok(r == S_OK, "ret %08x\n", r );
|
||||||
|
|
||||||
|
r = IXMLDOMText_insertData(nodetext, 1000, NULL);
|
||||||
|
ok(r == S_OK, "ret %08x\n", r );
|
||||||
|
|
||||||
|
r = IXMLDOMText_insertData(nodetext, 0, NULL);
|
||||||
|
ok(r == S_OK, "ret %08x\n", r );
|
||||||
|
|
||||||
|
r = IXMLDOMText_insertData(nodetext, 0, str);
|
||||||
|
ok(r == S_OK, "ret %08x\n", r );
|
||||||
|
SysFreeString(str);
|
||||||
|
|
||||||
|
r = IXMLDOMText_insertData(nodetext, -1, _bstr_("Inserting"));
|
||||||
|
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
||||||
|
|
||||||
|
r = IXMLDOMText_insertData(nodetext, 1000, _bstr_("Inserting"));
|
||||||
|
ok(r == E_INVALIDARG, "ret %08x\n", r );
|
||||||
|
|
||||||
|
r = IXMLDOMText_insertData(nodetext, 0, _bstr_("Begin "));
|
||||||
|
ok(r == S_OK, "ret %08x\n", r );
|
||||||
|
|
||||||
|
r = IXMLDOMText_insertData(nodetext, 17, _bstr_("Middle"));
|
||||||
|
ok(r == S_OK, "ret %08x\n", r );
|
||||||
|
|
||||||
|
r = IXMLDOMText_insertData(nodetext, 39, _bstr_(" End"));
|
||||||
|
ok(r == S_OK, "ret %08x\n", r );
|
||||||
|
|
||||||
|
r = IXMLDOMText_get_text(nodetext, &str);
|
||||||
|
ok(r == S_OK, "ret %08x\n", r );
|
||||||
|
ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
|
||||||
|
SysFreeString(str);
|
||||||
|
|
||||||
IXMLDOMText_Release( nodetext );
|
IXMLDOMText_Release( nodetext );
|
||||||
}
|
}
|
||||||
SysFreeString( str );
|
SysFreeString( str );
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* DOM text node implementation
|
* DOM text node implementation
|
||||||
*
|
*
|
||||||
* Copyright 2006 Huw Davies
|
* Copyright 2006 Huw Davies
|
||||||
|
* Copyright 2007-2008 Alistair Leslie-Hughes
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -617,8 +618,69 @@ static HRESULT WINAPI domtext_insertData(
|
||||||
IXMLDOMText *iface,
|
IXMLDOMText *iface,
|
||||||
long offset, BSTR p)
|
long offset, BSTR p)
|
||||||
{
|
{
|
||||||
FIXME("\n");
|
domtext *This = impl_from_IXMLDOMText( iface );
|
||||||
return E_NOTIMPL;
|
xmlnode *pDOMNode = impl_from_IXMLDOMNode( (IXMLDOMNode*)This->element );
|
||||||
|
xmlChar *pXmlContent;
|
||||||
|
BSTR sNewString;
|
||||||
|
HRESULT hr = S_FALSE;
|
||||||
|
long nLength = 0, nLengthP = 0;
|
||||||
|
xmlChar *str = NULL;
|
||||||
|
|
||||||
|
TRACE("%p\n", This);
|
||||||
|
|
||||||
|
/* If have a NULL or empty string, dont do anything. */
|
||||||
|
if(SysStringLen(p) == 0)
|
||||||
|
return S_OK;
|
||||||
|
|
||||||
|
if(offset < 0)
|
||||||
|
{
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
pXmlContent = xmlNodeGetContent(pDOMNode->node);
|
||||||
|
if(pXmlContent)
|
||||||
|
{
|
||||||
|
BSTR sContent = bstr_from_xmlChar( pXmlContent );
|
||||||
|
nLength = SysStringLen(sContent);
|
||||||
|
nLengthP = SysStringLen(p);
|
||||||
|
|
||||||
|
if(nLength < offset)
|
||||||
|
{
|
||||||
|
SysFreeString(sContent);
|
||||||
|
xmlFree(pXmlContent);
|
||||||
|
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
sNewString = SysAllocStringLen(NULL, nLength + nLengthP + 1);
|
||||||
|
if(sNewString)
|
||||||
|
{
|
||||||
|
if(offset > 0)
|
||||||
|
memcpy(sNewString, sContent, offset * sizeof(WCHAR));
|
||||||
|
|
||||||
|
memcpy(&sNewString[offset], p, nLengthP * sizeof(WCHAR));
|
||||||
|
|
||||||
|
if(offset+nLengthP < nLength)
|
||||||
|
memcpy(&sNewString[offset+nLengthP], &sContent[offset], (nLength-offset) * sizeof(WCHAR));
|
||||||
|
|
||||||
|
sNewString[nLengthP + nLength] = 0;
|
||||||
|
|
||||||
|
str = xmlChar_from_wchar((WCHAR*)sNewString);
|
||||||
|
if(str)
|
||||||
|
{
|
||||||
|
xmlNodeSetContent(pDOMNode->node, str);
|
||||||
|
hr = S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
SysFreeString(sNewString);
|
||||||
|
}
|
||||||
|
|
||||||
|
SysFreeString(sContent);
|
||||||
|
|
||||||
|
xmlFree(pXmlContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI domtext_deleteData(
|
static HRESULT WINAPI domtext_deleteData(
|
||||||
|
|
Loading…
Reference in New Issue