msxml: Implement IXMLDOMElement for text elements by using

create_element instead of create_basic_node.
This commit is contained in:
Robert Shearman 2006-06-14 02:38:09 +01:00 committed by Alexandre Julliard
parent 09ddab1481
commit 1df06e5c4a
1 changed files with 48 additions and 52 deletions

View File

@ -41,8 +41,8 @@ typedef struct _domtext
{ {
const struct IXMLDOMTextVtbl *lpVtbl; const struct IXMLDOMTextVtbl *lpVtbl;
LONG ref; LONG ref;
IUnknown *node_unk; IUnknown *element_unk;
IXMLDOMNode *node; IXMLDOMElement *element;
} domtext; } domtext;
static inline domtext *impl_from_IXMLDOMText( IXMLDOMText *iface ) static inline domtext *impl_from_IXMLDOMText( IXMLDOMText *iface )
@ -50,11 +50,6 @@ static inline domtext *impl_from_IXMLDOMText( IXMLDOMText *iface )
return (domtext *)((char*)iface - FIELD_OFFSET(domtext, lpVtbl)); return (domtext *)((char*)iface - FIELD_OFFSET(domtext, lpVtbl));
} }
static inline xmlNodePtr get_text( domtext *This )
{
return xmlNodePtr_from_domnode( This->node, XML_TEXT_NODE );
}
static HRESULT WINAPI domtext_QueryInterface( static HRESULT WINAPI domtext_QueryInterface(
IXMLDOMText *iface, IXMLDOMText *iface,
REFIID riid, REFIID riid,
@ -69,9 +64,10 @@ static HRESULT WINAPI domtext_QueryInterface(
*ppvObject = iface; *ppvObject = iface;
} }
else if ( IsEqualGUID( riid, &IID_IDispatch ) || else if ( IsEqualGUID( riid, &IID_IDispatch ) ||
IsEqualGUID( riid, &IID_IXMLDOMNode ) ) IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
IsEqualGUID( riid, &IID_IXMLDOMElement ) )
{ {
return IUnknown_QueryInterface(This->node_unk, riid, ppvObject); return IUnknown_QueryInterface(This->element_unk, riid, ppvObject);
} }
else else
{ {
@ -100,7 +96,7 @@ static ULONG WINAPI domtext_Release(
ref = InterlockedDecrement( &This->ref ); ref = InterlockedDecrement( &This->ref );
if ( ref == 0 ) if ( ref == 0 )
{ {
IUnknown_Release( This->node_unk ); IUnknown_Release( This->element_unk );
HeapFree( GetProcessHeap(), 0, This ); HeapFree( GetProcessHeap(), 0, This );
} }
@ -148,7 +144,7 @@ static HRESULT WINAPI domtext_get_nodeName(
BSTR* p ) BSTR* p )
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_nodeName( This->node, p ); return IXMLDOMNode_get_nodeName( This->element, p );
} }
static HRESULT WINAPI domtext_get_nodeValue( static HRESULT WINAPI domtext_get_nodeValue(
@ -156,7 +152,7 @@ static HRESULT WINAPI domtext_get_nodeValue(
VARIANT* var1 ) VARIANT* var1 )
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_nodeValue( This->node, var1 ); return IXMLDOMNode_get_nodeValue( This->element, var1 );
} }
static HRESULT WINAPI domtext_put_nodeValue( static HRESULT WINAPI domtext_put_nodeValue(
@ -164,7 +160,7 @@ static HRESULT WINAPI domtext_put_nodeValue(
VARIANT var1 ) VARIANT var1 )
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_put_nodeValue( This->node, var1 ); return IXMLDOMNode_put_nodeValue( This->element, var1 );
} }
static HRESULT WINAPI domtext_get_nodeType( static HRESULT WINAPI domtext_get_nodeType(
@ -172,7 +168,7 @@ static HRESULT WINAPI domtext_get_nodeType(
DOMNodeType* domNodeType ) DOMNodeType* domNodeType )
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_nodeType( This->node, domNodeType ); return IXMLDOMNode_get_nodeType( This->element, domNodeType );
} }
static HRESULT WINAPI domtext_get_parentNode( static HRESULT WINAPI domtext_get_parentNode(
@ -180,7 +176,7 @@ static HRESULT WINAPI domtext_get_parentNode(
IXMLDOMNode** parent ) IXMLDOMNode** parent )
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_parentNode( This->node, parent ); return IXMLDOMNode_get_parentNode( This->element, parent );
} }
static HRESULT WINAPI domtext_get_childNodes( static HRESULT WINAPI domtext_get_childNodes(
@ -188,7 +184,7 @@ static HRESULT WINAPI domtext_get_childNodes(
IXMLDOMNodeList** outList) IXMLDOMNodeList** outList)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_childNodes( This->node, outList ); return IXMLDOMNode_get_childNodes( This->element, outList );
} }
static HRESULT WINAPI domtext_get_firstChild( static HRESULT WINAPI domtext_get_firstChild(
@ -196,7 +192,7 @@ static HRESULT WINAPI domtext_get_firstChild(
IXMLDOMNode** domNode) IXMLDOMNode** domNode)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_firstChild( This->node, domNode ); return IXMLDOMNode_get_firstChild( This->element, domNode );
} }
static HRESULT WINAPI domtext_get_lastChild( static HRESULT WINAPI domtext_get_lastChild(
@ -204,7 +200,7 @@ static HRESULT WINAPI domtext_get_lastChild(
IXMLDOMNode** domNode) IXMLDOMNode** domNode)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_lastChild( This->node, domNode ); return IXMLDOMNode_get_lastChild( This->element, domNode );
} }
static HRESULT WINAPI domtext_get_previousSibling( static HRESULT WINAPI domtext_get_previousSibling(
@ -212,7 +208,7 @@ static HRESULT WINAPI domtext_get_previousSibling(
IXMLDOMNode** domNode) IXMLDOMNode** domNode)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_previousSibling( This->node, domNode ); return IXMLDOMNode_get_previousSibling( This->element, domNode );
} }
static HRESULT WINAPI domtext_get_nextSibling( static HRESULT WINAPI domtext_get_nextSibling(
@ -220,7 +216,7 @@ static HRESULT WINAPI domtext_get_nextSibling(
IXMLDOMNode** domNode) IXMLDOMNode** domNode)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_nextSibling( This->node, domNode ); return IXMLDOMNode_get_nextSibling( This->element, domNode );
} }
static HRESULT WINAPI domtext_get_attributes( static HRESULT WINAPI domtext_get_attributes(
@ -228,7 +224,7 @@ static HRESULT WINAPI domtext_get_attributes(
IXMLDOMNamedNodeMap** attributeMap) IXMLDOMNamedNodeMap** attributeMap)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_attributes( This->node, attributeMap ); return IXMLDOMNode_get_attributes( This->element, attributeMap );
} }
static HRESULT WINAPI domtext_insertBefore( static HRESULT WINAPI domtext_insertBefore(
@ -237,7 +233,7 @@ static HRESULT WINAPI domtext_insertBefore(
IXMLDOMNode** outOldNode) IXMLDOMNode** outOldNode)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_insertBefore( This->node, newNode, var1, outOldNode ); return IXMLDOMNode_insertBefore( This->element, newNode, var1, outOldNode );
} }
static HRESULT WINAPI domtext_replaceChild( static HRESULT WINAPI domtext_replaceChild(
@ -247,7 +243,7 @@ static HRESULT WINAPI domtext_replaceChild(
IXMLDOMNode** outOldNode) IXMLDOMNode** outOldNode)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_replaceChild( This->node, newNode, oldNode, outOldNode ); return IXMLDOMNode_replaceChild( This->element, newNode, oldNode, outOldNode );
} }
static HRESULT WINAPI domtext_removeChild( static HRESULT WINAPI domtext_removeChild(
@ -255,7 +251,7 @@ static HRESULT WINAPI domtext_removeChild(
IXMLDOMNode* domNode, IXMLDOMNode** oldNode) IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_removeChild( This->node, domNode, oldNode ); return IXMLDOMNode_removeChild( This->element, domNode, oldNode );
} }
static HRESULT WINAPI domtext_appendChild( static HRESULT WINAPI domtext_appendChild(
@ -263,7 +259,7 @@ static HRESULT WINAPI domtext_appendChild(
IXMLDOMNode* newNode, IXMLDOMNode** outNewNode) IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_appendChild( This->node, newNode, outNewNode ); return IXMLDOMNode_appendChild( This->element, newNode, outNewNode );
} }
static HRESULT WINAPI domtext_hasChildNodes( static HRESULT WINAPI domtext_hasChildNodes(
@ -271,7 +267,7 @@ static HRESULT WINAPI domtext_hasChildNodes(
VARIANT_BOOL* pbool) VARIANT_BOOL* pbool)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_hasChildNodes( This->node, pbool ); return IXMLDOMNode_hasChildNodes( This->element, pbool );
} }
static HRESULT WINAPI domtext_get_ownerDocument( static HRESULT WINAPI domtext_get_ownerDocument(
@ -279,7 +275,7 @@ static HRESULT WINAPI domtext_get_ownerDocument(
IXMLDOMDocument** domDocument) IXMLDOMDocument** domDocument)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_ownerDocument( This->node, domDocument ); return IXMLDOMNode_get_ownerDocument( This->element, domDocument );
} }
static HRESULT WINAPI domtext_cloneNode( static HRESULT WINAPI domtext_cloneNode(
@ -287,7 +283,7 @@ static HRESULT WINAPI domtext_cloneNode(
VARIANT_BOOL pbool, IXMLDOMNode** outNode) VARIANT_BOOL pbool, IXMLDOMNode** outNode)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_cloneNode( This->node, pbool, outNode ); return IXMLDOMNode_cloneNode( This->element, pbool, outNode );
} }
static HRESULT WINAPI domtext_get_nodeTypeString( static HRESULT WINAPI domtext_get_nodeTypeString(
@ -295,7 +291,7 @@ static HRESULT WINAPI domtext_get_nodeTypeString(
BSTR* p) BSTR* p)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_nodeTypeString( This->node, p ); return IXMLDOMNode_get_nodeTypeString( This->element, p );
} }
static HRESULT WINAPI domtext_get_text( static HRESULT WINAPI domtext_get_text(
@ -303,7 +299,7 @@ static HRESULT WINAPI domtext_get_text(
BSTR* p) BSTR* p)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_text( This->node, p ); return IXMLDOMNode_get_text( This->element, p );
} }
static HRESULT WINAPI domtext_put_text( static HRESULT WINAPI domtext_put_text(
@ -311,7 +307,7 @@ static HRESULT WINAPI domtext_put_text(
BSTR p) BSTR p)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_put_text( This->node, p ); return IXMLDOMNode_put_text( This->element, p );
} }
static HRESULT WINAPI domtext_get_specified( static HRESULT WINAPI domtext_get_specified(
@ -319,7 +315,7 @@ static HRESULT WINAPI domtext_get_specified(
VARIANT_BOOL* pbool) VARIANT_BOOL* pbool)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_specified( This->node, pbool ); return IXMLDOMNode_get_specified( This->element, pbool );
} }
static HRESULT WINAPI domtext_get_definition( static HRESULT WINAPI domtext_get_definition(
@ -327,7 +323,7 @@ static HRESULT WINAPI domtext_get_definition(
IXMLDOMNode** domNode) IXMLDOMNode** domNode)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_definition( This->node, domNode ); return IXMLDOMNode_get_definition( This->element, domNode );
} }
static HRESULT WINAPI domtext_get_nodeTypedValue( static HRESULT WINAPI domtext_get_nodeTypedValue(
@ -335,7 +331,7 @@ static HRESULT WINAPI domtext_get_nodeTypedValue(
VARIANT* var1) VARIANT* var1)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_nodeTypedValue( This->node, var1 ); return IXMLDOMNode_get_nodeTypedValue( This->element, var1 );
} }
static HRESULT WINAPI domtext_put_nodeTypedValue( static HRESULT WINAPI domtext_put_nodeTypedValue(
@ -343,7 +339,7 @@ static HRESULT WINAPI domtext_put_nodeTypedValue(
VARIANT var1) VARIANT var1)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_put_nodeTypedValue( This->node, var1 ); return IXMLDOMNode_put_nodeTypedValue( This->element, var1 );
} }
static HRESULT WINAPI domtext_get_dataType( static HRESULT WINAPI domtext_get_dataType(
@ -351,7 +347,7 @@ static HRESULT WINAPI domtext_get_dataType(
VARIANT* var1) VARIANT* var1)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_dataType( This->node, var1 ); return IXMLDOMNode_get_dataType( This->element, var1 );
} }
static HRESULT WINAPI domtext_put_dataType( static HRESULT WINAPI domtext_put_dataType(
@ -359,7 +355,7 @@ static HRESULT WINAPI domtext_put_dataType(
BSTR p) BSTR p)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_put_dataType( This->node, p ); return IXMLDOMNode_put_dataType( This->element, p );
} }
static HRESULT WINAPI domtext_get_xml( static HRESULT WINAPI domtext_get_xml(
@ -367,7 +363,7 @@ 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( This->node, p ); return IXMLDOMNode_get_xml( This->element, p );
} }
static HRESULT WINAPI domtext_transformNode( static HRESULT WINAPI domtext_transformNode(
@ -375,7 +371,7 @@ static HRESULT WINAPI domtext_transformNode(
IXMLDOMNode* domNode, BSTR* p) IXMLDOMNode* domNode, BSTR* p)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_transformNode( This->node, domNode, p ); return IXMLDOMNode_transformNode( This->element, domNode, p );
} }
static HRESULT WINAPI domtext_selectNodes( static HRESULT WINAPI domtext_selectNodes(
@ -383,7 +379,7 @@ static HRESULT WINAPI domtext_selectNodes(
BSTR p, IXMLDOMNodeList** outList) BSTR p, IXMLDOMNodeList** outList)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_selectNodes( This->node, p, outList ); return IXMLDOMNode_selectNodes( This->element, p, outList );
} }
static HRESULT WINAPI domtext_selectSingleNode( static HRESULT WINAPI domtext_selectSingleNode(
@ -391,7 +387,7 @@ static HRESULT WINAPI domtext_selectSingleNode(
BSTR p, IXMLDOMNode** outNode) BSTR p, IXMLDOMNode** outNode)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_selectSingleNode( This->node, p, outNode ); return IXMLDOMNode_selectSingleNode( This->element, p, outNode );
} }
static HRESULT WINAPI domtext_get_parsed( static HRESULT WINAPI domtext_get_parsed(
@ -399,7 +395,7 @@ static HRESULT WINAPI domtext_get_parsed(
VARIANT_BOOL* pbool) VARIANT_BOOL* pbool)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_parsed( This->node, pbool ); return IXMLDOMNode_get_parsed( This->element, pbool );
} }
static HRESULT WINAPI domtext_get_namespaceURI( static HRESULT WINAPI domtext_get_namespaceURI(
@ -407,7 +403,7 @@ static HRESULT WINAPI domtext_get_namespaceURI(
BSTR* p) BSTR* p)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_namespaceURI( This->node, p ); return IXMLDOMNode_get_namespaceURI( This->element, p );
} }
static HRESULT WINAPI domtext_get_prefix( static HRESULT WINAPI domtext_get_prefix(
@ -415,7 +411,7 @@ static HRESULT WINAPI domtext_get_prefix(
BSTR* p) BSTR* p)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_prefix( This->node, p ); return IXMLDOMNode_get_prefix( This->element, p );
} }
static HRESULT WINAPI domtext_get_baseName( static HRESULT WINAPI domtext_get_baseName(
@ -423,7 +419,7 @@ static HRESULT WINAPI domtext_get_baseName(
BSTR* p) BSTR* p)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_get_baseName( This->node, p ); return IXMLDOMNode_get_baseName( This->element, p );
} }
static HRESULT WINAPI domtext_transformNodeToObject( static HRESULT WINAPI domtext_transformNodeToObject(
@ -431,7 +427,7 @@ static HRESULT WINAPI domtext_transformNodeToObject(
IXMLDOMNode* domNode, VARIANT var1) IXMLDOMNode* domNode, VARIANT var1)
{ {
domtext *This = impl_from_IXMLDOMText( iface ); domtext *This = impl_from_IXMLDOMText( iface );
return IXMLDOMNode_transformNodeToObject( This->node, domNode, var1 ); return IXMLDOMNode_transformNodeToObject( This->element, domNode, var1 );
} }
static HRESULT WINAPI domtext_get_data( static HRESULT WINAPI domtext_get_data(
@ -575,22 +571,22 @@ IUnknown* create_text( xmlNodePtr text )
This->lpVtbl = &domtext_vtbl; This->lpVtbl = &domtext_vtbl;
This->ref = 1; This->ref = 1;
This->node_unk = create_basic_node( text, (IUnknown*)&This->lpVtbl ); This->element_unk = create_element( text, (IUnknown*)&This->lpVtbl );
if(!This->node_unk) if(!This->element_unk)
{ {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return NULL; return NULL;
} }
hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node); hr = IUnknown_QueryInterface(This->element_unk, &IID_IXMLDOMNode, (LPVOID*)&This->element);
if(FAILED(hr)) if(FAILED(hr))
{ {
IUnknown_Release(This->node_unk); IUnknown_Release(This->element_unk);
HeapFree( GetProcessHeap(), 0, This ); HeapFree( GetProcessHeap(), 0, This );
return NULL; return NULL;
} }
/* The ref on This->node is actually looped back into this object, so release it */ /* The ref on This->element is actually looped back into this object, so release it */
IXMLDOMNode_Release(This->node); IXMLDOMNode_Release(This->element);
return (IUnknown*) &This->lpVtbl; return (IUnknown*) &This->lpVtbl;
} }