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
;
47 static inline domelem
*impl_from_IXMLDOMElement( IXMLDOMElement
*iface
)
49 return (domelem
*)((char*)iface
- FIELD_OFFSET(domelem
, lpVtbl
));
52 static inline xmlNodePtr
get_element( domelem
*This
)
54 return xmlNodePtr_from_domnode( This
->node
, XML_ELEMENT_NODE
);
57 static HRESULT WINAPI
domelem_QueryInterface(
58 IXMLDOMElement
*iface
,
62 TRACE("%p %s %p\n", iface
, debugstr_guid(riid
), ppvObject
);
64 if ( IsEqualGUID( riid
, &IID_IXMLDOMElement
) ||
65 IsEqualGUID( riid
, &IID_IUnknown
) ||
66 IsEqualGUID( riid
, &IID_IDispatch
) ||
67 IsEqualGUID( riid
, &IID_IXMLDOMNode
) )
74 IXMLDOMElement_AddRef( iface
);
79 static ULONG WINAPI
domelem_AddRef(
80 IXMLDOMElement
*iface
)
82 domelem
*This
= impl_from_IXMLDOMElement( iface
);
83 return InterlockedIncrement( &This
->ref
);
86 static ULONG WINAPI
domelem_Release(
87 IXMLDOMElement
*iface
)
89 domelem
*This
= impl_from_IXMLDOMElement( iface
);
92 ref
= InterlockedDecrement( &This
->ref
);
95 IXMLDOMNode_Release( This
->node
);
96 HeapFree( GetProcessHeap(), 0, This
);
102 static HRESULT WINAPI
domelem_GetTypeInfoCount(
103 IXMLDOMElement
*iface
,
110 static HRESULT WINAPI
domelem_GetTypeInfo(
111 IXMLDOMElement
*iface
,
112 UINT iTInfo
, LCID lcid
,
113 ITypeInfo
** ppTInfo
)
119 static HRESULT WINAPI
domelem_GetIDsOfNames(
120 IXMLDOMElement
*iface
,
121 REFIID riid
, LPOLESTR
* rgszNames
,
122 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
128 static HRESULT WINAPI
domelem_Invoke(
129 IXMLDOMElement
*iface
,
130 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
131 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
132 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
138 static HRESULT WINAPI
domelem_get_nodeName(
139 IXMLDOMElement
*iface
,
142 domelem
*This
= impl_from_IXMLDOMElement( iface
);
143 return IXMLDOMNode_get_nodeName( This
->node
, p
);
146 static HRESULT WINAPI
domelem_get_nodeValue(
147 IXMLDOMElement
*iface
,
150 domelem
*This
= impl_from_IXMLDOMElement( iface
);
151 return IXMLDOMNode_get_nodeValue( This
->node
, var1
);
154 static HRESULT WINAPI
domelem_put_nodeValue(
155 IXMLDOMElement
*iface
,
158 domelem
*This
= impl_from_IXMLDOMElement( iface
);
159 return IXMLDOMNode_put_nodeValue( This
->node
, var1
);
162 static HRESULT WINAPI
domelem_get_nodeType(
163 IXMLDOMElement
*iface
,
164 DOMNodeType
* domNodeType
)
166 domelem
*This
= impl_from_IXMLDOMElement( iface
);
167 return IXMLDOMNode_get_nodeType( This
->node
, domNodeType
);
170 static HRESULT WINAPI
domelem_get_parentNode(
171 IXMLDOMElement
*iface
,
172 IXMLDOMNode
** parent
)
174 domelem
*This
= impl_from_IXMLDOMElement( iface
);
175 return IXMLDOMNode_get_parentNode( This
->node
, parent
);
178 static HRESULT WINAPI
domelem_get_childNodes(
179 IXMLDOMElement
*iface
,
180 IXMLDOMNodeList
** outList
)
182 domelem
*This
= impl_from_IXMLDOMElement( iface
);
183 return IXMLDOMNode_get_childNodes( This
->node
, outList
);
186 static HRESULT WINAPI
domelem_get_firstChild(
187 IXMLDOMElement
*iface
,
188 IXMLDOMNode
** domNode
)
190 domelem
*This
= impl_from_IXMLDOMElement( iface
);
191 return IXMLDOMNode_get_firstChild( This
->node
, domNode
);
194 static HRESULT WINAPI
domelem_get_lastChild(
195 IXMLDOMElement
*iface
,
196 IXMLDOMNode
** domNode
)
198 domelem
*This
= impl_from_IXMLDOMElement( iface
);
199 return IXMLDOMNode_get_lastChild( This
->node
, domNode
);
202 static HRESULT WINAPI
domelem_get_previousSibling(
203 IXMLDOMElement
*iface
,
204 IXMLDOMNode
** domNode
)
206 domelem
*This
= impl_from_IXMLDOMElement( iface
);
207 return IXMLDOMNode_get_previousSibling( This
->node
, domNode
);
210 static HRESULT WINAPI
domelem_get_nextSibling(
211 IXMLDOMElement
*iface
,
212 IXMLDOMNode
** domNode
)
214 domelem
*This
= impl_from_IXMLDOMElement( iface
);
215 return IXMLDOMNode_get_nextSibling( This
->node
, domNode
);
218 static HRESULT WINAPI
domelem_get_attributes(
219 IXMLDOMElement
*iface
,
220 IXMLDOMNamedNodeMap
** attributeMap
)
222 domelem
*This
= impl_from_IXMLDOMElement( iface
);
223 return IXMLDOMNode_get_attributes( This
->node
, attributeMap
);
226 static HRESULT WINAPI
domelem_insertBefore(
227 IXMLDOMElement
*iface
,
228 IXMLDOMNode
* newNode
, VARIANT var1
,
229 IXMLDOMNode
** outOldNode
)
231 domelem
*This
= impl_from_IXMLDOMElement( iface
);
232 return IXMLDOMNode_insertBefore( This
->node
, newNode
, var1
, outOldNode
);
235 static HRESULT WINAPI
domelem_replaceChild(
236 IXMLDOMElement
*iface
,
237 IXMLDOMNode
* newNode
,
238 IXMLDOMNode
* oldNode
,
239 IXMLDOMNode
** outOldNode
)
241 domelem
*This
= impl_from_IXMLDOMElement( iface
);
242 return IXMLDOMNode_replaceChild( This
->node
, newNode
, oldNode
, outOldNode
);
245 static HRESULT WINAPI
domelem_removeChild(
246 IXMLDOMElement
*iface
,
247 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
249 domelem
*This
= impl_from_IXMLDOMElement( iface
);
250 return IXMLDOMNode_removeChild( This
->node
, domNode
, oldNode
);
253 static HRESULT WINAPI
domelem_appendChild(
254 IXMLDOMElement
*iface
,
255 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
257 domelem
*This
= impl_from_IXMLDOMElement( iface
);
258 return IXMLDOMNode_appendChild( This
->node
, newNode
, outNewNode
);
261 static HRESULT WINAPI
domelem_hasChildNodes(
262 IXMLDOMElement
*iface
,
265 domelem
*This
= impl_from_IXMLDOMElement( iface
);
266 return IXMLDOMNode_hasChildNodes( This
->node
, pbool
);
269 static HRESULT WINAPI
domelem_get_ownerDocument(
270 IXMLDOMElement
*iface
,
271 IXMLDOMDocument
** domDocument
)
273 domelem
*This
= impl_from_IXMLDOMElement( iface
);
274 return IXMLDOMNode_get_ownerDocument( This
->node
, domDocument
);
277 static HRESULT WINAPI
domelem_cloneNode(
278 IXMLDOMElement
*iface
,
279 VARIANT_BOOL pbool
, IXMLDOMNode
** outNode
)
281 domelem
*This
= impl_from_IXMLDOMElement( iface
);
282 return IXMLDOMNode_cloneNode( This
->node
, pbool
, outNode
);
285 static HRESULT WINAPI
domelem_get_nodeTypeString(
286 IXMLDOMElement
*iface
,
289 domelem
*This
= impl_from_IXMLDOMElement( iface
);
290 return IXMLDOMNode_get_nodeTypeString( This
->node
, p
);
293 static HRESULT WINAPI
domelem_get_text(
294 IXMLDOMElement
*iface
,
297 domelem
*This
= impl_from_IXMLDOMElement( iface
);
298 return IXMLDOMNode_get_text( This
->node
, p
);
301 static HRESULT WINAPI
domelem_put_text(
302 IXMLDOMElement
*iface
,
305 domelem
*This
= impl_from_IXMLDOMElement( iface
);
306 return IXMLDOMNode_put_text( This
->node
, p
);
309 static HRESULT WINAPI
domelem_get_specified(
310 IXMLDOMElement
*iface
,
313 domelem
*This
= impl_from_IXMLDOMElement( iface
);
314 return IXMLDOMNode_get_specified( This
->node
, pbool
);
317 static HRESULT WINAPI
domelem_get_definition(
318 IXMLDOMElement
*iface
,
319 IXMLDOMNode
** domNode
)
321 domelem
*This
= impl_from_IXMLDOMElement( iface
);
322 return IXMLDOMNode_get_definition( This
->node
, domNode
);
325 static HRESULT WINAPI
domelem_get_nodeTypedValue(
326 IXMLDOMElement
*iface
,
329 domelem
*This
= impl_from_IXMLDOMElement( iface
);
330 return IXMLDOMNode_get_nodeTypedValue( This
->node
, var1
);
333 static HRESULT WINAPI
domelem_put_nodeTypedValue(
334 IXMLDOMElement
*iface
,
337 domelem
*This
= impl_from_IXMLDOMElement( iface
);
338 return IXMLDOMNode_put_nodeTypedValue( This
->node
, var1
);
341 static HRESULT WINAPI
domelem_get_dataType(
342 IXMLDOMElement
*iface
,
345 domelem
*This
= impl_from_IXMLDOMElement( iface
);
346 return IXMLDOMNode_get_dataType( This
->node
, var1
);
349 static HRESULT WINAPI
domelem_put_dataType(
350 IXMLDOMElement
*iface
,
353 domelem
*This
= impl_from_IXMLDOMElement( iface
);
354 return IXMLDOMNode_put_dataType( This
->node
, p
);
357 static HRESULT WINAPI
domelem_get_xml(
358 IXMLDOMElement
*iface
,
361 domelem
*This
= impl_from_IXMLDOMElement( iface
);
362 return IXMLDOMNode_get_xml( This
->node
, p
);
365 static HRESULT WINAPI
domelem_transformNode(
366 IXMLDOMElement
*iface
,
367 IXMLDOMNode
* domNode
, BSTR
* p
)
369 domelem
*This
= impl_from_IXMLDOMElement( iface
);
370 return IXMLDOMNode_transformNode( This
->node
, domNode
, p
);
373 static HRESULT WINAPI
domelem_selectNodes(
374 IXMLDOMElement
*iface
,
375 BSTR p
, IXMLDOMNodeList
** outList
)
377 domelem
*This
= impl_from_IXMLDOMElement( iface
);
378 return IXMLDOMNode_selectNodes( This
->node
, p
, outList
);
381 static HRESULT WINAPI
domelem_selectSingleNode(
382 IXMLDOMElement
*iface
,
383 BSTR p
, IXMLDOMNode
** outNode
)
385 domelem
*This
= impl_from_IXMLDOMElement( iface
);
386 return IXMLDOMNode_selectSingleNode( This
->node
, p
, outNode
);
389 static HRESULT WINAPI
domelem_get_parsed(
390 IXMLDOMElement
*iface
,
393 domelem
*This
= impl_from_IXMLDOMElement( iface
);
394 return IXMLDOMNode_get_parsed( This
->node
, pbool
);
397 static HRESULT WINAPI
domelem_get_namespaceURI(
398 IXMLDOMElement
*iface
,
401 domelem
*This
= impl_from_IXMLDOMElement( iface
);
402 return IXMLDOMNode_get_namespaceURI( This
->node
, p
);
405 static HRESULT WINAPI
domelem_get_prefix(
406 IXMLDOMElement
*iface
,
409 domelem
*This
= impl_from_IXMLDOMElement( iface
);
410 return IXMLDOMNode_get_prefix( This
->node
, p
);
413 static HRESULT WINAPI
domelem_get_baseName(
414 IXMLDOMElement
*iface
,
417 domelem
*This
= impl_from_IXMLDOMElement( iface
);
418 return IXMLDOMNode_get_baseName( This
->node
, p
);
421 static HRESULT WINAPI
domelem_transformNodeToObject(
422 IXMLDOMElement
*iface
,
423 IXMLDOMNode
* domNode
, VARIANT var1
)
425 domelem
*This
= impl_from_IXMLDOMElement( iface
);
426 return IXMLDOMNode_transformNodeToObject( This
->node
, domNode
, var1
);
429 static HRESULT WINAPI
domelem_get_tagName(
430 IXMLDOMElement
*iface
,
433 domelem
*This
= impl_from_IXMLDOMElement( iface
);
436 TRACE("%p\n", This
);
441 element
= get_element( This
);
445 *p
= bstr_from_xmlChar( element
->name
);
450 static HRESULT WINAPI
domelem_getAttribute(
451 IXMLDOMElement
*iface
,
452 BSTR p
, VARIANT
* var
)
458 static HRESULT WINAPI
domelem_setAttribute(
459 IXMLDOMElement
*iface
,
466 static HRESULT WINAPI
domelem_removeAttribute(
467 IXMLDOMElement
*iface
,
474 static HRESULT WINAPI
domelem_getAttributeNode(
475 IXMLDOMElement
*iface
,
476 BSTR p
, IXMLDOMAttribute
** attributeNode
)
482 static HRESULT WINAPI
domelem_setAttributeNode(
483 IXMLDOMElement
*iface
,
484 IXMLDOMAttribute
* domAttribute
,
485 IXMLDOMAttribute
** attributeNode
)
491 static HRESULT WINAPI
domelem_removeAttributeNode(
492 IXMLDOMElement
*iface
,
493 IXMLDOMAttribute
* domAttribute
,
494 IXMLDOMAttribute
** attributeNode
)
500 static HRESULT WINAPI
domelem_getElementsByTagName(
501 IXMLDOMElement
*iface
,
502 BSTR p
, IXMLDOMNodeList
** resultList
)
508 static HRESULT WINAPI
domelem_normalize(
509 IXMLDOMElement
*iface
)
515 static const struct IXMLDOMElementVtbl domelem_vtbl
=
517 domelem_QueryInterface
,
520 domelem_GetTypeInfoCount
,
522 domelem_GetIDsOfNames
,
524 domelem_get_nodeName
,
525 domelem_get_nodeValue
,
526 domelem_put_nodeValue
,
527 domelem_get_nodeType
,
528 domelem_get_parentNode
,
529 domelem_get_childNodes
,
530 domelem_get_firstChild
,
531 domelem_get_lastChild
,
532 domelem_get_previousSibling
,
533 domelem_get_nextSibling
,
534 domelem_get_attributes
,
535 domelem_insertBefore
,
536 domelem_replaceChild
,
539 domelem_hasChildNodes
,
540 domelem_get_ownerDocument
,
542 domelem_get_nodeTypeString
,
545 domelem_get_specified
,
546 domelem_get_definition
,
547 domelem_get_nodeTypedValue
,
548 domelem_put_nodeTypedValue
,
549 domelem_get_dataType
,
550 domelem_put_dataType
,
552 domelem_transformNode
,
554 domelem_selectSingleNode
,
556 domelem_get_namespaceURI
,
558 domelem_get_baseName
,
559 domelem_transformNodeToObject
,
561 domelem_getAttribute
,
562 domelem_setAttribute
,
563 domelem_removeAttribute
,
564 domelem_getAttributeNode
,
565 domelem_setAttributeNode
,
566 domelem_removeAttributeNode
,
567 domelem_getElementsByTagName
,
571 IXMLDOMElement
* create_element( xmlNodePtr element
)
575 This
= HeapAlloc( GetProcessHeap(), 0, sizeof *This
);
579 This
->lpVtbl
= &domelem_vtbl
;
580 This
->node
= create_node( element
);
585 HeapFree( GetProcessHeap(), 0, This
);
589 return (IXMLDOMElement
*) &This
->lpVtbl
;