Commit 3d18a77a authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Get rid of libxml2 accessors in ::substringData() for Text, Comment and CDATA nodes.

parent 19c30897
......@@ -538,11 +538,10 @@ static HRESULT WINAPI domcdata_substringData(
LONG offset, LONG count, BSTR *p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
xmlChar *pContent;
LONG nLength = 0;
HRESULT hr = S_FALSE;
HRESULT hr;
BSTR data;
TRACE("%p\n", iface);
TRACE("%p %d %d %p\n", This, offset, count, p);
if(!p)
return E_INVALIDARG;
......@@ -552,26 +551,24 @@ static HRESULT WINAPI domcdata_substringData(
return E_INVALIDARG;
if(count == 0)
return hr;
return S_FALSE;
pContent = xmlNodeGetContent(This->node.node);
if(pContent)
hr = IXMLDOMCDATASection_get_data(iface, &data);
if(hr == S_OK)
{
nLength = xmlStrlen(pContent);
LONG len = SysStringLen(data);
if( offset < nLength)
if(offset < len)
{
BSTR sContent = bstr_from_xmlChar(pContent);
if(offset + count > nLength)
*p = SysAllocString(&sContent[offset]);
if(offset + count > len)
*p = SysAllocString(&data[offset]);
else
*p = SysAllocStringLen(&sContent[offset], count);
SysFreeString(sContent);
hr = S_OK;
*p = SysAllocStringLen(&data[offset], count);
}
else
hr = S_FALSE;
xmlFree(pContent);
SysFreeString(data);
}
return hr;
......
......@@ -532,11 +532,10 @@ static HRESULT WINAPI domcomment_substringData(
LONG offset, LONG count, BSTR *p)
{
domcomment *This = impl_from_IXMLDOMComment( iface );
xmlChar *pContent;
LONG nLength = 0;
HRESULT hr = S_FALSE;
HRESULT hr;
BSTR data;
TRACE("%p %d %d %p\n", iface, offset, count, p);
TRACE("%p %d %d %p\n", This, offset, count, p);
if(!p)
return E_INVALIDARG;
......@@ -548,24 +547,22 @@ static HRESULT WINAPI domcomment_substringData(
if(count == 0)
return S_FALSE;
pContent = xmlNodeGetContent(This->node.node);
if(pContent)
hr = IXMLDOMComment_get_data(iface, &data);
if(hr == S_OK)
{
nLength = xmlStrlen(pContent);
LONG len = SysStringLen(data);
if( offset < nLength)
if(offset < len)
{
BSTR sContent = bstr_from_xmlChar(pContent);
if(offset + count > nLength)
*p = SysAllocString(&sContent[offset]);
if(offset + count > len)
*p = SysAllocString(&data[offset]);
else
*p = SysAllocStringLen(&sContent[offset], count);
SysFreeString(sContent);
hr = S_OK;
*p = SysAllocStringLen(&data[offset], count);
}
else
hr = S_FALSE;
xmlFree(pContent);
SysFreeString(data);
}
return hr;
......
......@@ -540,11 +540,10 @@ static HRESULT WINAPI domtext_substringData(
LONG offset, LONG count, BSTR *p)
{
domtext *This = impl_from_IXMLDOMText( iface );
xmlChar *pContent;
LONG nLength = 0;
HRESULT hr = S_FALSE;
HRESULT hr;
BSTR data;
TRACE("%p\n", iface);
TRACE("%p %d %d %p\n", This, offset, count, p);
if(!p)
return E_INVALIDARG;
......@@ -554,26 +553,24 @@ static HRESULT WINAPI domtext_substringData(
return E_INVALIDARG;
if(count == 0)
return hr;
return S_FALSE;
pContent = xmlNodeGetContent(This->node.node);
if(pContent)
hr = IXMLDOMText_get_data(iface, &data);
if(hr == S_OK)
{
nLength = xmlStrlen(pContent);
LONG len = SysStringLen(data);
if( offset < nLength)
if(offset < len)
{
BSTR sContent = bstr_from_xmlChar(pContent);
if(offset + count > nLength)
*p = SysAllocString(&sContent[offset]);
if(offset + count > len)
*p = SysAllocString(&data[offset]);
else
*p = SysAllocStringLen(&sContent[offset], count);
SysFreeString(sContent);
hr = S_OK;
*p = SysAllocStringLen(&data[offset], count);
}
else
hr = S_FALSE;
xmlFree(pContent);
SysFreeString(data);
}
return hr;
......
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