Commit 6241b9d6 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

msxml3: Don't use xmlnode's IXMLDOMNode iface in get_xml implementations.

parent d147ee13
......@@ -446,7 +446,10 @@ static HRESULT WINAPI domattr_get_xml(
BSTR* p)
{
domattr *This = impl_from_IXMLDOMAttribute( iface );
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
TRACE("(%p)->(%p)\n", This, p);
return node_get_xml(&This->node, FALSE, FALSE, p);
}
static HRESULT WINAPI domattr_transformNode(
......
......@@ -457,7 +457,10 @@ static HRESULT WINAPI domcdata_get_xml(
BSTR* p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
TRACE("(%p)->(%p)\n", This, p);
return node_get_xml(&This->node, FALSE, FALSE, p);
}
static HRESULT WINAPI domcdata_transformNode(
......
......@@ -450,7 +450,10 @@ static HRESULT WINAPI domcomment_get_xml(
BSTR* p)
{
domcomment *This = impl_from_IXMLDOMComment( iface );
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
TRACE("(%p)->(%p)\n", This, p);
return node_get_xml(&This->node, FALSE, FALSE, p);
}
static HRESULT WINAPI domcomment_transformNode(
......
......@@ -454,7 +454,10 @@ static HRESULT WINAPI domfrag_get_xml(
BSTR* p)
{
domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
TRACE("(%p)->(%p)\n", This, p);
return node_get_xml(&This->node, FALSE, FALSE, p);
}
static HRESULT WINAPI domfrag_transformNode(
......
......@@ -1268,10 +1268,13 @@ static HRESULT WINAPI domdoc_put_dataType(
static HRESULT WINAPI domdoc_get_xml(
IXMLDOMDocument3 *iface,
BSTR* xmlString )
BSTR* p)
{
domdoc *This = impl_from_IXMLDOMDocument3( iface );
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), xmlString );
TRACE("(%p)->(%p)\n", This, p);
return node_get_xml(&This->node, TRUE, TRUE, p);
}
......
......@@ -475,7 +475,10 @@ static HRESULT WINAPI domelem_get_xml(
BSTR* p)
{
domelem *This = impl_from_IXMLDOMElement( iface );
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
TRACE("(%p)->(%p)\n", This, p);
return node_get_xml(&This->node, TRUE, FALSE, p);
}
static HRESULT WINAPI domelem_transformNode(
......
......@@ -448,7 +448,10 @@ static HRESULT WINAPI entityref_get_xml(
BSTR* p)
{
entityref *This = impl_from_IXMLDOMEntityReference( iface );
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
TRACE("(%p)->(%p)\n", This, p);
return node_get_xml(&This->node, FALSE, FALSE, p);
}
static HRESULT WINAPI entityref_transformNode(
......
......@@ -106,6 +106,7 @@ BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
#include <libxml/parser.h>
#endif
#include <libxml/xmlerror.h>
/* constructors */
......@@ -190,6 +191,7 @@ extern HRESULT node_get_next_sibling(xmlnode*,IXMLDOMNode**);
extern HRESULT node_insert_before(xmlnode*,IXMLDOMNode*,const VARIANT*,IXMLDOMNode**);
extern HRESULT node_replace_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode*,IXMLDOMNode**);
extern HRESULT node_put_text(xmlnode*,BSTR);
extern HRESULT node_get_xml(xmlnode*,BOOL,BOOL,BSTR*);
extern HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document);
......
......@@ -978,63 +978,45 @@ static BSTR EnsureNoEncoding(BSTR sInput)
* reproduce behaviour exactly.
*
*/
static HRESULT WINAPI xmlnode_get_xml(
IXMLDOMNode *iface,
BSTR* xmlString)
HRESULT node_get_xml(xmlnode *This, BOOL ensure_eol, BOOL ensure_no_encoding, BSTR *ret)
{
xmlnode *This = impl_from_IXMLDOMNode( iface );
xmlBufferPtr pXmlBuf;
xmlBufferPtr xml_buf;
xmlNodePtr xmldecl;
int nSize;
int size;
TRACE("(%p %d)->(%p)\n", This, This->node->type, xmlString);
if(!xmlString)
if(!ret)
return E_INVALIDARG;
*xmlString = NULL;
*ret = NULL;
xml_buf = xmlBufferCreate();
if(!xml_buf)
return E_OUTOFMEMORY;
xmldecl = xmldoc_unlink_xmldecl( This->node->doc );
pXmlBuf = xmlBufferCreate();
if(pXmlBuf)
{
nSize = xmlNodeDump(pXmlBuf, This->node->doc, This->node, 0, 1);
if(nSize > 0)
{
const xmlChar *pContent;
BSTR bstrContent;
size = xmlNodeDump(xml_buf, This->node->doc, This->node, 0, 1);
if(size > 0) {
const xmlChar *buf_content;
BSTR content;
/* Attribute Nodes return a space in front of their name */
pContent = xmlBufferContent(pXmlBuf);
if( ((const char*)pContent)[0] == ' ')
bstrContent = bstr_from_xmlChar(pContent+1);
else
bstrContent = bstr_from_xmlChar(pContent);
buf_content = xmlBufferContent(xml_buf);
switch(This->node->type)
{
case XML_ELEMENT_NODE:
*xmlString = EnsureCorrectEOL(bstrContent);
break;
case XML_DOCUMENT_NODE:
*xmlString = EnsureCorrectEOL(bstrContent);
*xmlString = EnsureNoEncoding(*xmlString);
break;
default:
*xmlString = bstrContent;
}
}
content = bstr_from_xmlChar(buf_content + (buf_content[0] == ' ' ? 1 : 0));
if(ensure_eol)
content = EnsureCorrectEOL(content);
if(ensure_no_encoding)
content = EnsureNoEncoding(content);
xmlBufferFree(pXmlBuf);
*ret = content;
}else {
*ret = SysAllocStringLen(NULL, 0);
}
xmlBufferFree(xml_buf);
xmldoc_link_xmldecl( This->node->doc, xmldecl );
/* Always returns a string. */
if(*xmlString == NULL) *xmlString = SysAllocStringLen( NULL, 0 );
return S_OK;
return *ret ? S_OK : E_OUTOFMEMORY;
}
static HRESULT WINAPI xmlnode_transformNode(
......@@ -1283,7 +1265,7 @@ static const struct IXMLDOMNodeVtbl xmlnode_vtbl =
xmlnode_put_nodeTypedValue,
NULL,
xmlnode_put_dataType,
xmlnode_get_xml,
NULL,
xmlnode_transformNode,
xmlnode_selectNodes,
xmlnode_selectSingleNode,
......@@ -1731,7 +1713,10 @@ static HRESULT WINAPI unknode_get_xml(
BSTR* p)
{
unknode *This = impl_from_unkIXMLDOMNode( iface );
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
FIXME("(%p)->(%p)\n", This, p);
return node_get_xml(&This->node, FALSE, FALSE, p);
}
static HRESULT WINAPI unknode_transformNode(
......
......@@ -464,7 +464,10 @@ static HRESULT WINAPI dom_pi_get_xml(
BSTR* p)
{
dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
TRACE("(%p)->(%p)\n", This, p);
return node_get_xml(&This->node, FALSE, FALSE, p);
}
static HRESULT WINAPI dom_pi_transformNode(
......
......@@ -463,7 +463,10 @@ static HRESULT WINAPI domtext_get_xml(
BSTR* p)
{
domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
TRACE("(%p)->(%p)\n", This, p);
return node_get_xml(&This->node, FALSE, FALSE, p);
}
static HRESULT WINAPI domtext_transformNode(
......
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