2 * DOM Document implementation
4 * Copyright 2005 Mike McCormack
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
40 typedef struct _domelem
42 const struct IXMLDOMElementVtbl *lpVtbl;
48 static inline domelem *impl_from_IXMLDOMElement( IXMLDOMElement *iface )
50 return (domelem *)((char*)iface - FIELD_OFFSET(domelem, lpVtbl));
53 static inline xmlNodePtr get_element( domelem *This )
55 return xmlNodePtr_from_domnode( This->node, XML_ELEMENT_NODE );
58 static HRESULT WINAPI domelem_QueryInterface(
59 IXMLDOMElement *iface,
63 domelem *This = impl_from_IXMLDOMElement( iface );
64 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
66 if ( IsEqualGUID( riid, &IID_IXMLDOMElement ) ||
67 IsEqualGUID( riid, &IID_IUnknown ) )
71 else if ( IsEqualGUID( riid, &IID_IDispatch ) ||
72 IsEqualGUID( riid, &IID_IXMLDOMNode ) )
74 return IUnknown_QueryInterface(This->node_unk, riid, ppvObject);
79 IXMLDOMElement_AddRef( iface );
84 static ULONG WINAPI domelem_AddRef(
85 IXMLDOMElement *iface )
87 domelem *This = impl_from_IXMLDOMElement( iface );
88 return InterlockedIncrement( &This->ref );
91 static ULONG WINAPI domelem_Release(
92 IXMLDOMElement *iface )
94 domelem *This = impl_from_IXMLDOMElement( iface );
97 ref = InterlockedDecrement( &This->ref );
100 IUnknown_Release( This->node_unk );
101 HeapFree( GetProcessHeap(), 0, This );
107 static HRESULT WINAPI domelem_GetTypeInfoCount(
108 IXMLDOMElement *iface,
115 static HRESULT WINAPI domelem_GetTypeInfo(
116 IXMLDOMElement *iface,
117 UINT iTInfo, LCID lcid,
118 ITypeInfo** ppTInfo )
124 static HRESULT WINAPI domelem_GetIDsOfNames(
125 IXMLDOMElement *iface,
126 REFIID riid, LPOLESTR* rgszNames,
127 UINT cNames, LCID lcid, DISPID* rgDispId )
133 static HRESULT WINAPI domelem_Invoke(
134 IXMLDOMElement *iface,
135 DISPID dispIdMember, REFIID riid, LCID lcid,
136 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
137 EXCEPINFO* pExcepInfo, UINT* puArgErr )
143 static HRESULT WINAPI domelem_get_nodeName(
144 IXMLDOMElement *iface,
147 domelem *This = impl_from_IXMLDOMElement( iface );
148 return IXMLDOMNode_get_nodeName( This->node, p );
151 static HRESULT WINAPI domelem_get_nodeValue(
152 IXMLDOMElement *iface,
155 domelem *This = impl_from_IXMLDOMElement( iface );
156 return IXMLDOMNode_get_nodeValue( This->node, var1 );
159 static HRESULT WINAPI domelem_put_nodeValue(
160 IXMLDOMElement *iface,
163 domelem *This = impl_from_IXMLDOMElement( iface );
164 return IXMLDOMNode_put_nodeValue( This->node, var1 );
167 static HRESULT WINAPI domelem_get_nodeType(
168 IXMLDOMElement *iface,
169 DOMNodeType* domNodeType )
171 domelem *This = impl_from_IXMLDOMElement( iface );
172 return IXMLDOMNode_get_nodeType( This->node, domNodeType );
175 static HRESULT WINAPI domelem_get_parentNode(
176 IXMLDOMElement *iface,
177 IXMLDOMNode** parent )
179 domelem *This = impl_from_IXMLDOMElement( iface );
180 return IXMLDOMNode_get_parentNode( This->node, parent );
183 static HRESULT WINAPI domelem_get_childNodes(
184 IXMLDOMElement *iface,
185 IXMLDOMNodeList** outList)
187 domelem *This = impl_from_IXMLDOMElement( iface );
188 return IXMLDOMNode_get_childNodes( This->node, outList );
191 static HRESULT WINAPI domelem_get_firstChild(
192 IXMLDOMElement *iface,
193 IXMLDOMNode** domNode)
195 domelem *This = impl_from_IXMLDOMElement( iface );
196 return IXMLDOMNode_get_firstChild( This->node, domNode );
199 static HRESULT WINAPI domelem_get_lastChild(
200 IXMLDOMElement *iface,
201 IXMLDOMNode** domNode)
203 domelem *This = impl_from_IXMLDOMElement( iface );
204 return IXMLDOMNode_get_lastChild( This->node, domNode );
207 static HRESULT WINAPI domelem_get_previousSibling(
208 IXMLDOMElement *iface,
209 IXMLDOMNode** domNode)
211 domelem *This = impl_from_IXMLDOMElement( iface );
212 return IXMLDOMNode_get_previousSibling( This->node, domNode );
215 static HRESULT WINAPI domelem_get_nextSibling(
216 IXMLDOMElement *iface,
217 IXMLDOMNode** domNode)
219 domelem *This = impl_from_IXMLDOMElement( iface );
220 return IXMLDOMNode_get_nextSibling( This->node, domNode );
223 static HRESULT WINAPI domelem_get_attributes(
224 IXMLDOMElement *iface,
225 IXMLDOMNamedNodeMap** attributeMap)
227 domelem *This = impl_from_IXMLDOMElement( iface );
228 return IXMLDOMNode_get_attributes( This->node, attributeMap );
231 static HRESULT WINAPI domelem_insertBefore(
232 IXMLDOMElement *iface,
233 IXMLDOMNode* newNode, VARIANT var1,
234 IXMLDOMNode** outOldNode)
236 domelem *This = impl_from_IXMLDOMElement( iface );
237 return IXMLDOMNode_insertBefore( This->node, newNode, var1, outOldNode );
240 static HRESULT WINAPI domelem_replaceChild(
241 IXMLDOMElement *iface,
242 IXMLDOMNode* newNode,
243 IXMLDOMNode* oldNode,
244 IXMLDOMNode** outOldNode)
246 domelem *This = impl_from_IXMLDOMElement( iface );
247 return IXMLDOMNode_replaceChild( This->node, newNode, oldNode, outOldNode );
250 static HRESULT WINAPI domelem_removeChild(
251 IXMLDOMElement *iface,
252 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
254 domelem *This = impl_from_IXMLDOMElement( iface );
255 return IXMLDOMNode_removeChild( This->node, domNode, oldNode );
258 static HRESULT WINAPI domelem_appendChild(
259 IXMLDOMElement *iface,
260 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
262 domelem *This = impl_from_IXMLDOMElement( iface );
263 return IXMLDOMNode_appendChild( This->node, newNode, outNewNode );
266 static HRESULT WINAPI domelem_hasChildNodes(
267 IXMLDOMElement *iface,
270 domelem *This = impl_from_IXMLDOMElement( iface );
271 return IXMLDOMNode_hasChildNodes( This->node, pbool );
274 static HRESULT WINAPI domelem_get_ownerDocument(
275 IXMLDOMElement *iface,
276 IXMLDOMDocument** domDocument)
278 domelem *This = impl_from_IXMLDOMElement( iface );
279 return IXMLDOMNode_get_ownerDocument( This->node, domDocument );
282 static HRESULT WINAPI domelem_cloneNode(
283 IXMLDOMElement *iface,
284 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
286 domelem *This = impl_from_IXMLDOMElement( iface );
287 return IXMLDOMNode_cloneNode( This->node, pbool, outNode );
290 static HRESULT WINAPI domelem_get_nodeTypeString(
291 IXMLDOMElement *iface,
294 domelem *This = impl_from_IXMLDOMElement( iface );
295 return IXMLDOMNode_get_nodeTypeString( This->node, p );
298 static HRESULT WINAPI domelem_get_text(
299 IXMLDOMElement *iface,
302 domelem *This = impl_from_IXMLDOMElement( iface );
303 return IXMLDOMNode_get_text( This->node, p );
306 static HRESULT WINAPI domelem_put_text(
307 IXMLDOMElement *iface,
310 domelem *This = impl_from_IXMLDOMElement( iface );
311 return IXMLDOMNode_put_text( This->node, p );
314 static HRESULT WINAPI domelem_get_specified(
315 IXMLDOMElement *iface,
318 domelem *This = impl_from_IXMLDOMElement( iface );
319 return IXMLDOMNode_get_specified( This->node, pbool );
322 static HRESULT WINAPI domelem_get_definition(
323 IXMLDOMElement *iface,
324 IXMLDOMNode** domNode)
326 domelem *This = impl_from_IXMLDOMElement( iface );
327 return IXMLDOMNode_get_definition( This->node, domNode );
330 static HRESULT WINAPI domelem_get_nodeTypedValue(
331 IXMLDOMElement *iface,
334 domelem *This = impl_from_IXMLDOMElement( iface );
335 return IXMLDOMNode_get_nodeTypedValue( This->node, var1 );
338 static HRESULT WINAPI domelem_put_nodeTypedValue(
339 IXMLDOMElement *iface,
342 domelem *This = impl_from_IXMLDOMElement( iface );
343 return IXMLDOMNode_put_nodeTypedValue( This->node, var1 );
346 static HRESULT WINAPI domelem_get_dataType(
347 IXMLDOMElement *iface,
350 domelem *This = impl_from_IXMLDOMElement( iface );
351 return IXMLDOMNode_get_dataType( This->node, var1 );
354 static HRESULT WINAPI domelem_put_dataType(
355 IXMLDOMElement *iface,
358 domelem *This = impl_from_IXMLDOMElement( iface );
359 return IXMLDOMNode_put_dataType( This->node, p );
362 static HRESULT WINAPI domelem_get_xml(
363 IXMLDOMElement *iface,
366 domelem *This = impl_from_IXMLDOMElement( iface );
367 return IXMLDOMNode_get_xml( This->node, p );
370 static HRESULT WINAPI domelem_transformNode(
371 IXMLDOMElement *iface,
372 IXMLDOMNode* domNode, BSTR* p)
374 domelem *This = impl_from_IXMLDOMElement( iface );
375 return IXMLDOMNode_transformNode( This->node, domNode, p );
378 static HRESULT WINAPI domelem_selectNodes(
379 IXMLDOMElement *iface,
380 BSTR p, IXMLDOMNodeList** outList)
382 domelem *This = impl_from_IXMLDOMElement( iface );
383 return IXMLDOMNode_selectNodes( This->node, p, outList );
386 static HRESULT WINAPI domelem_selectSingleNode(
387 IXMLDOMElement *iface,
388 BSTR p, IXMLDOMNode** outNode)
390 domelem *This = impl_from_IXMLDOMElement( iface );
391 return IXMLDOMNode_selectSingleNode( This->node, p, outNode );
394 static HRESULT WINAPI domelem_get_parsed(
395 IXMLDOMElement *iface,
398 domelem *This = impl_from_IXMLDOMElement( iface );
399 return IXMLDOMNode_get_parsed( This->node, pbool );
402 static HRESULT WINAPI domelem_get_namespaceURI(
403 IXMLDOMElement *iface,
406 domelem *This = impl_from_IXMLDOMElement( iface );
407 return IXMLDOMNode_get_namespaceURI( This->node, p );
410 static HRESULT WINAPI domelem_get_prefix(
411 IXMLDOMElement *iface,
414 domelem *This = impl_from_IXMLDOMElement( iface );
415 return IXMLDOMNode_get_prefix( This->node, p );
418 static HRESULT WINAPI domelem_get_baseName(
419 IXMLDOMElement *iface,
422 domelem *This = impl_from_IXMLDOMElement( iface );
423 return IXMLDOMNode_get_baseName( This->node, p );
426 static HRESULT WINAPI domelem_transformNodeToObject(
427 IXMLDOMElement *iface,
428 IXMLDOMNode* domNode, VARIANT var1)
430 domelem *This = impl_from_IXMLDOMElement( iface );
431 return IXMLDOMNode_transformNodeToObject( This->node, domNode, var1 );
434 static HRESULT WINAPI domelem_get_tagName(
435 IXMLDOMElement *iface,
438 domelem *This = impl_from_IXMLDOMElement( iface );
441 TRACE("%p\n", This );
446 element = get_element( This );
450 *p = bstr_from_xmlChar( element->name );
455 static HRESULT WINAPI domelem_getAttribute(
456 IXMLDOMElement *iface,
457 BSTR p, VARIANT* var)
463 static HRESULT WINAPI domelem_setAttribute(
464 IXMLDOMElement *iface,
471 static HRESULT WINAPI domelem_removeAttribute(
472 IXMLDOMElement *iface,
479 static HRESULT WINAPI domelem_getAttributeNode(
480 IXMLDOMElement *iface,
481 BSTR p, IXMLDOMAttribute** attributeNode )
487 static HRESULT WINAPI domelem_setAttributeNode(
488 IXMLDOMElement *iface,
489 IXMLDOMAttribute* domAttribute,
490 IXMLDOMAttribute** attributeNode)
496 static HRESULT WINAPI domelem_removeAttributeNode(
497 IXMLDOMElement *iface,
498 IXMLDOMAttribute* domAttribute,
499 IXMLDOMAttribute** attributeNode)
505 static HRESULT WINAPI domelem_getElementsByTagName(
506 IXMLDOMElement *iface,
507 BSTR p, IXMLDOMNodeList** resultList)
513 static HRESULT WINAPI domelem_normalize(
514 IXMLDOMElement *iface )
520 static const struct IXMLDOMElementVtbl domelem_vtbl =
522 domelem_QueryInterface,
525 domelem_GetTypeInfoCount,
527 domelem_GetIDsOfNames,
529 domelem_get_nodeName,
530 domelem_get_nodeValue,
531 domelem_put_nodeValue,
532 domelem_get_nodeType,
533 domelem_get_parentNode,
534 domelem_get_childNodes,
535 domelem_get_firstChild,
536 domelem_get_lastChild,
537 domelem_get_previousSibling,
538 domelem_get_nextSibling,
539 domelem_get_attributes,
540 domelem_insertBefore,
541 domelem_replaceChild,
544 domelem_hasChildNodes,
545 domelem_get_ownerDocument,
547 domelem_get_nodeTypeString,
550 domelem_get_specified,
551 domelem_get_definition,
552 domelem_get_nodeTypedValue,
553 domelem_put_nodeTypedValue,
554 domelem_get_dataType,
555 domelem_put_dataType,
557 domelem_transformNode,
559 domelem_selectSingleNode,
561 domelem_get_namespaceURI,
563 domelem_get_baseName,
564 domelem_transformNodeToObject,
566 domelem_getAttribute,
567 domelem_setAttribute,
568 domelem_removeAttribute,
569 domelem_getAttributeNode,
570 domelem_setAttributeNode,
571 domelem_removeAttributeNode,
572 domelem_getElementsByTagName,
576 IUnknown* create_element( xmlNodePtr element )
581 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
585 This->lpVtbl = &domelem_vtbl;
588 This->node_unk = create_basic_node( element, (IUnknown*)&This->lpVtbl );
591 HeapFree(GetProcessHeap(), 0, This);
595 hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
598 IUnknown_Release(This->node_unk);
599 HeapFree( GetProcessHeap(), 0, This );
602 /* The ref on This->node is actually looped back into this object, so release it */
603 IXMLDOMNode_Release(This->node);
605 return (IUnknown*) &This->lpVtbl;