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

This commit is contained in:
Jacek Caban 2010-10-29 16:27:09 +02:00 committed by Alexandre Julliard
parent d147ee1392
commit 6241b9d652
11 changed files with 69 additions and 55 deletions

View File

@ -446,7 +446,10 @@ static HRESULT WINAPI domattr_get_xml(
BSTR* p) BSTR* p)
{ {
domattr *This = impl_from_IXMLDOMAttribute( iface ); 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( static HRESULT WINAPI domattr_transformNode(

View File

@ -457,7 +457,10 @@ static HRESULT WINAPI domcdata_get_xml(
BSTR* p) BSTR* p)
{ {
domcdata *This = impl_from_IXMLDOMCDATASection( iface ); 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( static HRESULT WINAPI domcdata_transformNode(

View File

@ -450,7 +450,10 @@ static HRESULT WINAPI domcomment_get_xml(
BSTR* p) BSTR* p)
{ {
domcomment *This = impl_from_IXMLDOMComment( iface ); 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( static HRESULT WINAPI domcomment_transformNode(

View File

@ -454,7 +454,10 @@ static HRESULT WINAPI domfrag_get_xml(
BSTR* p) BSTR* p)
{ {
domfrag *This = impl_from_IXMLDOMDocumentFragment( iface ); 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( static HRESULT WINAPI domfrag_transformNode(

View File

@ -1268,10 +1268,13 @@ static HRESULT WINAPI domdoc_put_dataType(
static HRESULT WINAPI domdoc_get_xml( static HRESULT WINAPI domdoc_get_xml(
IXMLDOMDocument3 *iface, IXMLDOMDocument3 *iface,
BSTR* xmlString ) BSTR* p)
{ {
domdoc *This = impl_from_IXMLDOMDocument3( iface ); 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);
} }

View File

@ -475,7 +475,10 @@ static HRESULT WINAPI domelem_get_xml(
BSTR* p) BSTR* p)
{ {
domelem *This = impl_from_IXMLDOMElement( iface ); 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( static HRESULT WINAPI domelem_transformNode(

View File

@ -448,7 +448,10 @@ static HRESULT WINAPI entityref_get_xml(
BSTR* p) BSTR* p)
{ {
entityref *This = impl_from_IXMLDOMEntityReference( iface ); 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( static HRESULT WINAPI entityref_transformNode(

View File

@ -106,6 +106,7 @@ BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
#include <libxml/parser.h> #include <libxml/parser.h>
#endif #endif
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
/* constructors */ /* 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_insert_before(xmlnode*,IXMLDOMNode*,const VARIANT*,IXMLDOMNode**);
extern HRESULT node_replace_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode*,IXMLDOMNode**); extern HRESULT node_replace_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode*,IXMLDOMNode**);
extern HRESULT node_put_text(xmlnode*,BSTR); 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); extern HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document);

View File

@ -978,63 +978,45 @@ static BSTR EnsureNoEncoding(BSTR sInput)
* reproduce behaviour exactly. * reproduce behaviour exactly.
* *
*/ */
static HRESULT WINAPI xmlnode_get_xml( HRESULT node_get_xml(xmlnode *This, BOOL ensure_eol, BOOL ensure_no_encoding, BSTR *ret)
IXMLDOMNode *iface,
BSTR* xmlString)
{ {
xmlnode *This = impl_from_IXMLDOMNode( iface ); xmlBufferPtr xml_buf;
xmlBufferPtr pXmlBuf;
xmlNodePtr xmldecl; xmlNodePtr xmldecl;
int nSize; int size;
TRACE("(%p %d)->(%p)\n", This, This->node->type, xmlString); if(!ret)
if(!xmlString)
return E_INVALIDARG; return E_INVALIDARG;
*xmlString = NULL; *ret = NULL;
xml_buf = xmlBufferCreate();
if(!xml_buf)
return E_OUTOFMEMORY;
xmldecl = xmldoc_unlink_xmldecl( This->node->doc ); xmldecl = xmldoc_unlink_xmldecl( This->node->doc );
pXmlBuf = xmlBufferCreate(); size = xmlNodeDump(xml_buf, This->node->doc, This->node, 0, 1);
if(pXmlBuf) if(size > 0) {
{ const xmlChar *buf_content;
nSize = xmlNodeDump(pXmlBuf, This->node->doc, This->node, 0, 1); BSTR content;
if(nSize > 0)
{
const xmlChar *pContent;
BSTR bstrContent;
/* Attribute Nodes return a space in front of their name */ /* Attribute Nodes return a space in front of their name */
pContent = xmlBufferContent(pXmlBuf); buf_content = xmlBufferContent(xml_buf);
if( ((const char*)pContent)[0] == ' ')
bstrContent = bstr_from_xmlChar(pContent+1);
else
bstrContent = bstr_from_xmlChar(pContent);
switch(This->node->type) content = bstr_from_xmlChar(buf_content + (buf_content[0] == ' ' ? 1 : 0));
{ if(ensure_eol)
case XML_ELEMENT_NODE: content = EnsureCorrectEOL(content);
*xmlString = EnsureCorrectEOL(bstrContent); if(ensure_no_encoding)
break; content = EnsureNoEncoding(content);
case XML_DOCUMENT_NODE:
*xmlString = EnsureCorrectEOL(bstrContent);
*xmlString = EnsureNoEncoding(*xmlString);
break;
default:
*xmlString = bstrContent;
}
}
xmlBufferFree(pXmlBuf); *ret = content;
}else {
*ret = SysAllocStringLen(NULL, 0);
} }
xmlBufferFree(xml_buf);
xmldoc_link_xmldecl( This->node->doc, xmldecl ); xmldoc_link_xmldecl( This->node->doc, xmldecl );
return *ret ? S_OK : E_OUTOFMEMORY;
/* Always returns a string. */
if(*xmlString == NULL) *xmlString = SysAllocStringLen( NULL, 0 );
return S_OK;
} }
static HRESULT WINAPI xmlnode_transformNode( static HRESULT WINAPI xmlnode_transformNode(
@ -1283,7 +1265,7 @@ static const struct IXMLDOMNodeVtbl xmlnode_vtbl =
xmlnode_put_nodeTypedValue, xmlnode_put_nodeTypedValue,
NULL, NULL,
xmlnode_put_dataType, xmlnode_put_dataType,
xmlnode_get_xml, NULL,
xmlnode_transformNode, xmlnode_transformNode,
xmlnode_selectNodes, xmlnode_selectNodes,
xmlnode_selectSingleNode, xmlnode_selectSingleNode,
@ -1731,7 +1713,10 @@ static HRESULT WINAPI unknode_get_xml(
BSTR* p) BSTR* p)
{ {
unknode *This = impl_from_unkIXMLDOMNode( iface ); 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( static HRESULT WINAPI unknode_transformNode(

View File

@ -464,7 +464,10 @@ static HRESULT WINAPI dom_pi_get_xml(
BSTR* p) BSTR* p)
{ {
dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface ); 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( static HRESULT WINAPI dom_pi_transformNode(

View File

@ -463,7 +463,10 @@ static HRESULT WINAPI domtext_get_xml(
BSTR* p) BSTR* p)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); 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( static HRESULT WINAPI domtext_transformNode(