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

This commit is contained in:
Nikolay Sivov 2010-02-16 02:53:09 +03:00 committed by Alexandre Julliard
parent 19c30897d4
commit 3d18a77ae7
3 changed files with 41 additions and 50 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;