From 7a68fad27389fa33fa6f5b6d47208271ae19b9be Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sat, 4 Sep 2010 17:56:25 +0200 Subject: [PATCH] msxml3: Don't use xmlnode's IXMLDOMNode iface in get_nodeName implementations. --- dlls/msxml3/attribute.c | 11 ++++++-- dlls/msxml3/cdata.c | 8 +++++- dlls/msxml3/comment.c | 7 ++++- dlls/msxml3/docfrag.c | 8 +++++- dlls/msxml3/domdoc.c | 7 ++++- dlls/msxml3/element.c | 5 +++- dlls/msxml3/entityref.c | 5 +++- dlls/msxml3/msxml_private.h | 18 ++++++++++++ dlls/msxml3/node.c | 55 ++++++++++--------------------------- dlls/msxml3/pi.c | 12 ++++++-- dlls/msxml3/text.c | 7 ++++- 11 files changed, 89 insertions(+), 54 deletions(-) diff --git a/dlls/msxml3/attribute.c b/dlls/msxml3/attribute.c index a004981d6c3..30a05cdb906 100644 --- a/dlls/msxml3/attribute.c +++ b/dlls/msxml3/attribute.c @@ -182,7 +182,10 @@ static HRESULT WINAPI domattr_get_nodeName( BSTR* p ) { domattr *This = impl_from_IXMLDOMAttribute( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p ); + + TRACE("(%p)->(%p)\n", This, p); + + return node_get_nodeName(&This->node, p); } static HRESULT WINAPI domattr_get_nodeValue( @@ -475,9 +478,11 @@ static HRESULT WINAPI domattr_get_name( IXMLDOMAttribute *iface, BSTR *p) { - /* name property returns the same value as nodeName */ domattr *This = impl_from_IXMLDOMAttribute( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p ); + + TRACE("(%p)->(%p)\n", This, p); + + return node_get_nodeName(&This->node, p); } static HRESULT WINAPI domattr_get_value( diff --git a/dlls/msxml3/cdata.c b/dlls/msxml3/cdata.c index 6baacc81e7b..903f36f9a9e 100644 --- a/dlls/msxml3/cdata.c +++ b/dlls/msxml3/cdata.c @@ -190,7 +190,13 @@ static HRESULT WINAPI domcdata_get_nodeName( BSTR* p ) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p ); + + static const WCHAR cdata_sectionW[] = + {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0}; + + TRACE("(%p)->(%p)\n", This, p); + + return return_bstr(cdata_sectionW, p); } static HRESULT WINAPI domcdata_get_nodeValue( diff --git a/dlls/msxml3/comment.c b/dlls/msxml3/comment.c index 68fa9b8a149..513ce0cb6ab 100644 --- a/dlls/msxml3/comment.c +++ b/dlls/msxml3/comment.c @@ -184,7 +184,12 @@ static HRESULT WINAPI domcomment_get_nodeName( BSTR* p ) { domcomment *This = impl_from_IXMLDOMComment( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p ); + + static const WCHAR commentW[] = {'#','c','o','m','m','e','n','t',0}; + + TRACE("(%p)->(%p)\n", This, p); + + return return_bstr(commentW, p); } static HRESULT WINAPI domcomment_get_nodeValue( diff --git a/dlls/msxml3/docfrag.c b/dlls/msxml3/docfrag.c index df6676e585f..5264d9697ab 100644 --- a/dlls/msxml3/docfrag.c +++ b/dlls/msxml3/docfrag.c @@ -183,7 +183,13 @@ static HRESULT WINAPI domfrag_get_nodeName( BSTR* p ) { domfrag *This = impl_from_IXMLDOMDocumentFragment( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p ); + + static const WCHAR document_fragmentW[] = + {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0}; + + TRACE("(%p)->(%p)\n", This, p); + + return return_bstr(document_fragmentW, p); } static HRESULT WINAPI domfrag_get_nodeValue( diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index b1228803062..6046c1e506e 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -686,7 +686,12 @@ static HRESULT WINAPI domdoc_get_nodeName( BSTR* name ) { domdoc *This = impl_from_IXMLDOMDocument3( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), name ); + + static const WCHAR documentW[] = {'#','d','o','c','u','m','e','n','t',0}; + + TRACE("(%p)->(%p)\n", This, name); + + return return_bstr(documentW, name); } diff --git a/dlls/msxml3/element.c b/dlls/msxml3/element.c index 890ea14ca19..4e5522c7d2d 100644 --- a/dlls/msxml3/element.c +++ b/dlls/msxml3/element.c @@ -194,7 +194,10 @@ static HRESULT WINAPI domelem_get_nodeName( BSTR* p ) { domelem *This = impl_from_IXMLDOMElement( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p ); + + TRACE("(%p)->(%p)\n", This, p); + + return node_get_nodeName(&This->node, p); } static HRESULT WINAPI domelem_get_nodeValue( diff --git a/dlls/msxml3/entityref.c b/dlls/msxml3/entityref.c index 63c962b6e92..db7d16264f9 100644 --- a/dlls/msxml3/entityref.c +++ b/dlls/msxml3/entityref.c @@ -182,7 +182,10 @@ static HRESULT WINAPI entityref_get_nodeName( BSTR* p ) { entityref *This = impl_from_IXMLDOMEntityReference( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p ); + + FIXME("(%p)->(%p)\n", This, p); + + return node_get_nodeName(&This->node, p); } static HRESULT WINAPI entityref_get_nodeValue( diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h index cea368616ab..b249d90292b 100644 --- a/dlls/msxml3/msxml_private.h +++ b/dlls/msxml3/msxml_private.h @@ -159,6 +159,8 @@ extern void destroy_xmlnode(xmlnode*); extern BOOL node_query_interface(xmlnode*,REFIID,void**); extern xmlnode *get_node_obj(IXMLDOMNode*); +extern HRESULT node_get_nodeName(xmlnode*,BSTR*); + extern HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document); static inline BSTR bstr_from_xmlChar(const xmlChar *str) @@ -177,6 +179,22 @@ static inline BSTR bstr_from_xmlChar(const xmlChar *str) return ret; } +static inline HRESULT return_bstr(const WCHAR *value, BSTR *p) +{ + if(!p) + return E_INVALIDARG; + + if(value) { + *p = SysAllocString(value); + if(!*p) + return E_OUTOFMEMORY; + }else { + *p = NULL; + } + + return S_OK; +} + #endif void* libxslt_handle; diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index 6143f13cfbe..f057a9586d2 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -178,56 +178,26 @@ static HRESULT WINAPI xmlnode_Invoke( return E_NOTIMPL; } -static HRESULT WINAPI xmlnode_get_nodeName( - IXMLDOMNode *iface, - BSTR* name) +HRESULT node_get_nodeName(xmlnode *This, BSTR *name) { - xmlnode *This = impl_from_IXMLDOMNode( iface ); - const xmlChar *str; - - TRACE("(%p)->(%p)\n", This, name ); - if (!name) return E_INVALIDARG; - if ( !This->node ) - return E_FAIL; - - switch( This->node->type ) - { - case XML_CDATA_SECTION_NODE: - str = (const xmlChar*) "#cdata-section"; - break; - case XML_COMMENT_NODE: - str = (const xmlChar*) "#comment"; - break; - case XML_DOCUMENT_FRAG_NODE: - str = (const xmlChar*) "#document-fragment"; - break; - case XML_TEXT_NODE: - str = (const xmlChar*) "#text"; - break; - case XML_DOCUMENT_NODE: - str = (const xmlChar*) "#document"; - break; - case XML_ATTRIBUTE_NODE: - case XML_ELEMENT_NODE: - case XML_PI_NODE: - str = This->node->name; - break; - default: - FIXME("nodeName not mapped correctly (%d)\n", This->node->type); - str = This->node->name; - break; - } - - *name = bstr_from_xmlChar( str ); + *name = bstr_from_xmlChar(This->node->name); if (!*name) return S_FALSE; return S_OK; } +static HRESULT WINAPI xmlnode_get_nodeName( + IXMLDOMNode *iface, + BSTR* name) +{ + ERR("Should not be called\n"); + return E_NOTIMPL; +} + static HRESULT WINAPI xmlnode_get_nodeValue( IXMLDOMNode *iface, VARIANT* value) @@ -1843,7 +1813,10 @@ static HRESULT WINAPI unknode_get_nodeName( BSTR* p ) { unknode *This = impl_from_unkIXMLDOMNode( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p ); + + FIXME("(%p)->(%p)\n", This, p); + + return node_get_nodeName(&This->node, p); } static HRESULT WINAPI unknode_get_nodeValue( diff --git a/dlls/msxml3/pi.c b/dlls/msxml3/pi.c index c86fd4673b0..aeb296e4bd1 100644 --- a/dlls/msxml3/pi.c +++ b/dlls/msxml3/pi.c @@ -183,7 +183,10 @@ static HRESULT WINAPI dom_pi_get_nodeName( BSTR* p ) { dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p ); + + TRACE("(%p)->(%p)\n", This, p); + + return node_get_nodeName(&This->node, p); } static HRESULT WINAPI dom_pi_get_nodeValue( @@ -492,9 +495,12 @@ static HRESULT WINAPI dom_pi_get_target( IXMLDOMProcessingInstruction *iface, BSTR *p) { - /* target returns the same value as nodeName property */ dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p ); + + TRACE("(%p)->(%p)\n", This, p); + + /* target returns the same value as nodeName property */ + return node_get_nodeName(&This->node, p); } static HRESULT WINAPI dom_pi_get_data( diff --git a/dlls/msxml3/text.c b/dlls/msxml3/text.c index b131be1c51f..ccfc36e2e15 100644 --- a/dlls/msxml3/text.c +++ b/dlls/msxml3/text.c @@ -192,7 +192,12 @@ static HRESULT WINAPI domtext_get_nodeName( BSTR* p ) { domtext *This = impl_from_IXMLDOMText( iface ); - return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p ); + + static const WCHAR textW[] = {'#','t','e','x','t',0}; + + TRACE("(%p)->(%p)\n", This, p); + + return return_bstr(textW, p); } static HRESULT WINAPI domtext_get_nodeValue(