Jacek Caban : msxml3: Don't use xmlnode' s IXMLDOMNode iface in get_xml implementations.
Alexandre Julliard
julliard at winehq.org
Fri Oct 29 10:58:22 CDT 2010
Module: wine
Branch: master
Commit: 6241b9d6525f340233bf1578c44df4e88bd7d82e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6241b9d6525f340233bf1578c44df4e88bd7d82e
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Oct 29 16:27:09 2010 +0200
msxml3: Don't use xmlnode's IXMLDOMNode iface in get_xml implementations.
---
dlls/msxml3/attribute.c | 5 ++-
dlls/msxml3/cdata.c | 5 ++-
dlls/msxml3/comment.c | 5 ++-
dlls/msxml3/docfrag.c | 5 ++-
dlls/msxml3/domdoc.c | 7 +++-
dlls/msxml3/element.c | 5 ++-
dlls/msxml3/entityref.c | 5 ++-
dlls/msxml3/msxml_private.h | 2 +
dlls/msxml3/node.c | 75 +++++++++++++++++-------------------------
dlls/msxml3/pi.c | 5 ++-
dlls/msxml3/text.c | 5 ++-
11 files changed, 69 insertions(+), 55 deletions(-)
diff --git a/dlls/msxml3/attribute.c b/dlls/msxml3/attribute.c
index 724dec6..c63cf6e 100644
--- a/dlls/msxml3/attribute.c
+++ b/dlls/msxml3/attribute.c
@@ -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(
diff --git a/dlls/msxml3/cdata.c b/dlls/msxml3/cdata.c
index 84d631f..c346f1b 100644
--- a/dlls/msxml3/cdata.c
+++ b/dlls/msxml3/cdata.c
@@ -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(
diff --git a/dlls/msxml3/comment.c b/dlls/msxml3/comment.c
index 3c80011..9f8c0e3 100644
--- a/dlls/msxml3/comment.c
+++ b/dlls/msxml3/comment.c
@@ -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(
diff --git a/dlls/msxml3/docfrag.c b/dlls/msxml3/docfrag.c
index f9c1ed5..ccc6744 100644
--- a/dlls/msxml3/docfrag.c
+++ b/dlls/msxml3/docfrag.c
@@ -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(
diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c
index 8a21402..d62d02b 100644
--- a/dlls/msxml3/domdoc.c
+++ b/dlls/msxml3/domdoc.c
@@ -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);
}
diff --git a/dlls/msxml3/element.c b/dlls/msxml3/element.c
index 396ca52..615499d 100644
--- a/dlls/msxml3/element.c
+++ b/dlls/msxml3/element.c
@@ -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(
diff --git a/dlls/msxml3/entityref.c b/dlls/msxml3/entityref.c
index 3460bd0..501ff62 100644
--- a/dlls/msxml3/entityref.c
+++ b/dlls/msxml3/entityref.c
@@ -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(
diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h
index 7fcfea7..310b9ad 100644
--- a/dlls/msxml3/msxml_private.h
+++ b/dlls/msxml3/msxml_private.h
@@ -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);
diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c
index 0d12209..72e6be9 100644
--- a/dlls/msxml3/node.c
+++ b/dlls/msxml3/node.c
@@ -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);
+ /* Attribute Nodes return a space in front of their name */
+ 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(
diff --git a/dlls/msxml3/pi.c b/dlls/msxml3/pi.c
index 4fee700..4ba7607 100644
--- a/dlls/msxml3/pi.c
+++ b/dlls/msxml3/pi.c
@@ -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(
diff --git a/dlls/msxml3/text.c b/dlls/msxml3/text.c
index a98b52c..38a44c3 100644
--- a/dlls/msxml3/text.c
+++ b/dlls/msxml3/text.c
@@ -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(
More information about the wine-cvs
mailing list