2 * DOM Document implementation
4 * Copyright 2005 Mike McCormack
6 * iface 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 * iface 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
35 #include "msxml_private.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
43 typedef struct _domelem
45 const struct IXMLDOMElementVtbl
*lpVtbl
;
50 static inline domelem
*impl_from_IXMLDOMElement( IXMLDOMElement
*iface
)
52 return (domelem
*)((char*)iface
- FIELD_OFFSET(domelem
, lpVtbl
));
55 static inline xmlNodePtr
get_element( domelem
*This
)
57 return xmlNodePtr_from_domnode( This
->node
, XML_ELEMENT_NODE
);
60 static HRESULT WINAPI
domelem_QueryInterface(
61 IXMLDOMElement
*iface
,
65 TRACE("%p %p %p\n", iface
, debugstr_guid(riid
), ppvObject
);
67 if ( IsEqualGUID( riid
, &IID_IXMLDOMElement
) ||
68 IsEqualGUID( riid
, &IID_IUnknown
) ||
69 IsEqualGUID( riid
, &IID_IDispatch
) ||
70 IsEqualGUID( riid
, &IID_IXMLDOMNode
) )
77 IXMLDOMElement_AddRef( iface
);
82 static ULONG WINAPI
domelem_AddRef(
83 IXMLDOMElement
*iface
)
85 domelem
*This
= impl_from_IXMLDOMElement( iface
);
86 return InterlockedIncrement( &This
->ref
);
89 static ULONG WINAPI
domelem_Release(
90 IXMLDOMElement
*iface
)
92 domelem
*This
= impl_from_IXMLDOMElement( iface
);
95 ref
= InterlockedDecrement( &This
->ref
);
98 IXMLDOMNode_Release( This
->node
);
99 HeapFree( GetProcessHeap(), 0, This
);
105 static HRESULT WINAPI
domelem_GetTypeInfoCount(
106 IXMLDOMElement
*iface
,
113 static HRESULT WINAPI
domelem_GetTypeInfo(
114 IXMLDOMElement
*iface
,
115 UINT iTInfo
, LCID lcid
,
116 ITypeInfo
** ppTInfo
)
122 static HRESULT WINAPI
domelem_GetIDsOfNames(
123 IXMLDOMElement
*iface
,
124 REFIID riid
, LPOLESTR
* rgszNames
,
125 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
131 static HRESULT WINAPI
domelem_Invoke(
132 IXMLDOMElement
*iface
,
133 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
134 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
135 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
141 static HRESULT WINAPI
domelem_get_nodeName(
142 IXMLDOMElement
*iface
,
145 domelem
*This
= impl_from_IXMLDOMElement( iface
);
146 return IXMLDOMNode_get_nodeName( This
->node
, p
);
149 static HRESULT WINAPI
domelem_get_nodeValue(
150 IXMLDOMElement
*iface
,
153 domelem
*This
= impl_from_IXMLDOMElement( iface
);
154 return IXMLDOMNode_get_nodeValue( This
->node
, var1
);
157 static HRESULT WINAPI
domelem_put_nodeValue(
158 IXMLDOMElement
*iface
,
161 domelem
*This
= impl_from_IXMLDOMElement( iface
);
162 return IXMLDOMNode_put_nodeValue( This
->node
, var1
);
165 static HRESULT WINAPI
domelem_get_nodeType(
166 IXMLDOMElement
*iface
,
167 DOMNodeType
* domNodeType
)
169 domelem
*This
= impl_from_IXMLDOMElement( iface
);
170 return IXMLDOMNode_get_nodeType( This
->node
, domNodeType
);
173 static HRESULT WINAPI
domelem_get_parentNode(
174 IXMLDOMElement
*iface
,
175 IXMLDOMNode
** parent
)
177 domelem
*This
= impl_from_IXMLDOMElement( iface
);
178 return IXMLDOMNode_get_parentNode( This
->node
, parent
);
181 static HRESULT WINAPI
domelem_get_childNodes(
182 IXMLDOMElement
*iface
,
183 IXMLDOMNodeList
** outList
)
185 domelem
*This
= impl_from_IXMLDOMElement( iface
);
186 return IXMLDOMNode_get_childNodes( This
->node
, outList
);
189 static HRESULT WINAPI
domelem_get_firstChild(
190 IXMLDOMElement
*iface
,
191 IXMLDOMNode
** domNode
)
193 domelem
*This
= impl_from_IXMLDOMElement( iface
);
194 return IXMLDOMNode_get_firstChild( This
->node
, domNode
);
197 static HRESULT WINAPI
domelem_get_lastChild(
198 IXMLDOMElement
*iface
,
199 IXMLDOMNode
** domNode
)
201 domelem
*This
= impl_from_IXMLDOMElement( iface
);
202 return IXMLDOMNode_get_lastChild( This
->node
, domNode
);
205 static HRESULT WINAPI
domelem_get_previousSibling(
206 IXMLDOMElement
*iface
,
207 IXMLDOMNode
** domNode
)
209 domelem
*This
= impl_from_IXMLDOMElement( iface
);
210 return IXMLDOMNode_get_previousSibling( This
->node
, domNode
);
213 static HRESULT WINAPI
domelem_get_nextSibling(
214 IXMLDOMElement
*iface
,
215 IXMLDOMNode
** domNode
)
217 domelem
*This
= impl_from_IXMLDOMElement( iface
);
218 return IXMLDOMNode_get_nextSibling( This
->node
, domNode
);
221 static HRESULT WINAPI
domelem_get_attributes(
222 IXMLDOMElement
*iface
,
223 IXMLDOMNamedNodeMap
** attributeMap
)
225 domelem
*This
= impl_from_IXMLDOMElement( iface
);
226 return IXMLDOMNode_get_attributes( This
->node
, attributeMap
);
229 static HRESULT WINAPI
domelem_insertBefore(
230 IXMLDOMElement
*iface
,
231 IXMLDOMNode
* newNode
, VARIANT var1
,
232 IXMLDOMNode
** outOldNode
)
234 domelem
*This
= impl_from_IXMLDOMElement( iface
);
235 return IXMLDOMNode_insertBefore( This
->node
, newNode
, var1
, outOldNode
);
238 static HRESULT WINAPI
domelem_replaceChild(
239 IXMLDOMElement
*iface
,
240 IXMLDOMNode
* newNode
,
241 IXMLDOMNode
* oldNode
,
242 IXMLDOMNode
** outOldNode
)
244 domelem
*This
= impl_from_IXMLDOMElement( iface
);
245 return IXMLDOMNode_replaceChild( This
->node
, newNode
, oldNode
, outOldNode
);
248 static HRESULT WINAPI
domelem_removeChild(
249 IXMLDOMElement
*iface
,
250 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
252 domelem
*This
= impl_from_IXMLDOMElement( iface
);
253 return IXMLDOMNode_removeChild( This
->node
, domNode
, oldNode
);
256 static HRESULT WINAPI
domelem_appendChild(
257 IXMLDOMElement
*iface
,
258 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
260 domelem
*This
= impl_from_IXMLDOMElement( iface
);
261 return IXMLDOMNode_appendChild( This
->node
, newNode
, outNewNode
);
264 static HRESULT WINAPI
domelem_hasChildNodes(
265 IXMLDOMElement
*iface
,
268 domelem
*This
= impl_from_IXMLDOMElement( iface
);
269 return IXMLDOMNode_hasChildNodes( This
->node
, pbool
);
272 static HRESULT WINAPI
domelem_get_ownerDocument(
273 IXMLDOMElement
*iface
,
274 IXMLDOMDocument
** domDocument
)
276 domelem
*This
= impl_from_IXMLDOMElement( iface
);
277 return IXMLDOMNode_get_ownerDocument( This
->node
, domDocument
);
280 static HRESULT WINAPI
domelem_cloneNode(
281 IXMLDOMElement
*iface
,
282 VARIANT_BOOL pbool
, IXMLDOMNode
** outNode
)
284 domelem
*This
= impl_from_IXMLDOMElement( iface
);
285 return IXMLDOMNode_cloneNode( This
->node
, pbool
, outNode
);
288 static HRESULT WINAPI
domelem_get_nodeTypeString(
289 IXMLDOMElement
*iface
,
292 domelem
*This
= impl_from_IXMLDOMElement( iface
);
293 return IXMLDOMNode_get_nodeTypeString( This
->node
, p
);
296 static HRESULT WINAPI
domelem_get_text(
297 IXMLDOMElement
*iface
,
300 domelem
*This
= impl_from_IXMLDOMElement( iface
);
301 return IXMLDOMNode_get_text( This
->node
, p
);
304 static HRESULT WINAPI
domelem_put_text(
305 IXMLDOMElement
*iface
,
308 domelem
*This
= impl_from_IXMLDOMElement( iface
);
309 return IXMLDOMNode_put_text( This
->node
, p
);
312 static HRESULT WINAPI
domelem_get_specified(
313 IXMLDOMElement
*iface
,
316 domelem
*This
= impl_from_IXMLDOMElement( iface
);
317 return IXMLDOMNode_get_specified( This
->node
, pbool
);
320 static HRESULT WINAPI
domelem_get_definition(
321 IXMLDOMElement
*iface
,
322 IXMLDOMNode
** domNode
)
324 domelem
*This
= impl_from_IXMLDOMElement( iface
);
325 return IXMLDOMNode_get_definition( This
->node
, domNode
);
328 static HRESULT WINAPI
domelem_get_nodeTypedValue(
329 IXMLDOMElement
*iface
,
332 domelem
*This
= impl_from_IXMLDOMElement( iface
);
333 return IXMLDOMNode_get_nodeTypedValue( This
->node
, var1
);
336 static HRESULT WINAPI
domelem_put_nodeTypedValue(
337 IXMLDOMElement
*iface
,
340 domelem
*This
= impl_from_IXMLDOMElement( iface
);
341 return IXMLDOMNode_put_nodeTypedValue( This
->node
, var1
);
344 static HRESULT WINAPI
domelem_get_dataType(
345 IXMLDOMElement
*iface
,
348 domelem
*This
= impl_from_IXMLDOMElement( iface
);
349 return IXMLDOMNode_get_dataType( This
->node
, var1
);
352 static HRESULT WINAPI
domelem_put_dataType(
353 IXMLDOMElement
*iface
,
356 domelem
*This
= impl_from_IXMLDOMElement( iface
);
357 return IXMLDOMNode_put_dataType( This
->node
, p
);
360 static HRESULT WINAPI
domelem_get_xml(
361 IXMLDOMElement
*iface
,
364 domelem
*This
= impl_from_IXMLDOMElement( iface
);
365 return IXMLDOMNode_get_xml( This
->node
, p
);
368 static HRESULT WINAPI
domelem_transformNode(
369 IXMLDOMElement
*iface
,
370 IXMLDOMNode
* domNode
, BSTR
* p
)
372 domelem
*This
= impl_from_IXMLDOMElement( iface
);
373 return IXMLDOMNode_transformNode( This
->node
, domNode
, p
);
376 static HRESULT WINAPI
domelem_selectNodes(
377 IXMLDOMElement
*iface
,
378 BSTR p
, IXMLDOMNodeList
** outList
)
380 domelem
*This
= impl_from_IXMLDOMElement( iface
);
381 return IXMLDOMNode_selectNodes( This
->node
, p
, outList
);
384 static HRESULT WINAPI
domelem_selectSingleNode(
385 IXMLDOMElement
*iface
,
386 BSTR p
, IXMLDOMNode
** outNode
)
388 domelem
*This
= impl_from_IXMLDOMElement( iface
);
389 return IXMLDOMNode_selectSingleNode( This
->node
, p
, outNode
);
392 static HRESULT WINAPI
domelem_get_parsed(
393 IXMLDOMElement
*iface
,
396 domelem
*This
= impl_from_IXMLDOMElement( iface
);
397 return IXMLDOMNode_get_parsed( This
->node
, pbool
);
400 static HRESULT WINAPI
domelem_get_namespaceURI(
401 IXMLDOMElement
*iface
,
404 domelem
*This
= impl_from_IXMLDOMElement( iface
);
405 return IXMLDOMNode_get_namespaceURI( This
->node
, p
);
408 static HRESULT WINAPI
domelem_get_prefix(
409 IXMLDOMElement
*iface
,
412 domelem
*This
= impl_from_IXMLDOMElement( iface
);
413 return IXMLDOMNode_get_prefix( This
->node
, p
);
416 static HRESULT WINAPI
domelem_get_baseName(
417 IXMLDOMElement
*iface
,
420 domelem
*This
= impl_from_IXMLDOMElement( iface
);
421 return IXMLDOMNode_get_baseName( This
->node
, p
);
424 static HRESULT WINAPI
domelem_transformNodeToObject(
425 IXMLDOMElement
*iface
,
426 IXMLDOMNode
* domNode
, VARIANT var1
)
428 domelem
*This
= impl_from_IXMLDOMElement( iface
);
429 return IXMLDOMNode_transformNodeToObject( This
->node
, domNode
, var1
);
432 static HRESULT WINAPI
domelem_get_tagName(
433 IXMLDOMElement
*iface
,
436 domelem
*This
= impl_from_IXMLDOMElement( iface
);
439 TRACE("%p\n", This
);
444 element
= get_element( This
);
448 *p
= bstr_from_xmlChar( element
->name
);
453 static HRESULT WINAPI
domelem_getAttribute(
454 IXMLDOMElement
*iface
,
455 BSTR p
, VARIANT
* var
)
461 static HRESULT WINAPI
domelem_setAttribute(
462 IXMLDOMElement
*iface
,
469 static HRESULT WINAPI
domelem_removeAttribute(
470 IXMLDOMElement
*iface
,
477 static HRESULT WINAPI
domelem_getAttributeNode(
478 IXMLDOMElement
*iface
,
479 BSTR p
, IXMLDOMAttribute
** attributeNode
)
485 static HRESULT WINAPI
domelem_setAttributeNode(
486 IXMLDOMElement
*iface
,
487 IXMLDOMAttribute
* domAttribute
,
488 IXMLDOMAttribute
** attributeNode
)
494 static HRESULT WINAPI
domelem_removeAttributeNode(
495 IXMLDOMElement
*iface
,
496 IXMLDOMAttribute
* domAttribute
,
497 IXMLDOMAttribute
** attributeNode
)
503 static HRESULT WINAPI
domelem_getElementsByTagName(
504 IXMLDOMElement
*iface
,
505 BSTR p
, IXMLDOMNodeList
** resultList
)
511 static HRESULT WINAPI
domelem_normalize(
512 IXMLDOMElement
*iface
)
518 static const struct IXMLDOMElementVtbl domelem_vtbl
=
520 domelem_QueryInterface
,
523 domelem_GetTypeInfoCount
,
525 domelem_GetIDsOfNames
,
527 domelem_get_nodeName
,
528 domelem_get_nodeValue
,
529 domelem_put_nodeValue
,
530 domelem_get_nodeType
,
531 domelem_get_parentNode
,
532 domelem_get_childNodes
,
533 domelem_get_firstChild
,
534 domelem_get_lastChild
,
535 domelem_get_previousSibling
,
536 domelem_get_nextSibling
,
537 domelem_get_attributes
,
538 domelem_insertBefore
,
539 domelem_replaceChild
,
542 domelem_hasChildNodes
,
543 domelem_get_ownerDocument
,
545 domelem_get_nodeTypeString
,
548 domelem_get_specified
,
549 domelem_get_definition
,
550 domelem_get_nodeTypedValue
,
551 domelem_put_nodeTypedValue
,
552 domelem_get_dataType
,
553 domelem_put_dataType
,
555 domelem_transformNode
,
557 domelem_selectSingleNode
,
559 domelem_get_namespaceURI
,
561 domelem_get_baseName
,
562 domelem_transformNodeToObject
,
564 domelem_getAttribute
,
565 domelem_setAttribute
,
566 domelem_removeAttribute
,
567 domelem_getAttributeNode
,
568 domelem_setAttributeNode
,
569 domelem_removeAttributeNode
,
570 domelem_getElementsByTagName
,
574 IXMLDOMElement
* create_element( xmlNodePtr element
)
578 This
= HeapAlloc( GetProcessHeap(), 0, sizeof *This
);
582 This
->lpVtbl
= &domelem_vtbl
;
583 This
->node
= create_node( element
);
588 HeapFree( GetProcessHeap(), 0, This
);
592 return (IXMLDOMElement
*) &This
->lpVtbl
;