2 * DOM Entity Reference implementation
4 * Copyright 2007 Alistair Leslie-Hughes
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
40 typedef struct _entityref
43 const struct IXMLDOMEntityReferenceVtbl
*lpVtbl
;
47 static inline entityref
*impl_from_IXMLDOMEntityReference( IXMLDOMEntityReference
*iface
)
49 return (entityref
*)((char*)iface
- FIELD_OFFSET(entityref
, lpVtbl
));
52 static HRESULT WINAPI
entityref_QueryInterface(
53 IXMLDOMEntityReference
*iface
,
57 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
58 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
60 if ( IsEqualGUID( riid
, &IID_IXMLDOMEntityReference
) ||
61 IsEqualGUID( riid
, &IID_IXMLDOMNode
) ||
62 IsEqualGUID( riid
, &IID_IDispatch
) ||
63 IsEqualGUID( riid
, &IID_IUnknown
) )
67 else if(node_query_interface(&This
->node
, riid
, ppvObject
))
69 return *ppvObject
? S_OK
: E_NOINTERFACE
;
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid
));
77 IUnknown_AddRef((IUnknown
*)*ppvObject
);
81 static ULONG WINAPI
entityref_AddRef(
82 IXMLDOMEntityReference
*iface
)
84 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
85 return InterlockedIncrement( &This
->ref
);
88 static ULONG WINAPI
entityref_Release(
89 IXMLDOMEntityReference
*iface
)
91 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
94 ref
= InterlockedDecrement( &This
->ref
);
97 destroy_xmlnode(&This
->node
);
104 static HRESULT WINAPI
entityref_GetTypeInfoCount(
105 IXMLDOMEntityReference
*iface
,
108 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
109 TRACE("(%p)->(%p)\n", This
, pctinfo
);
116 static HRESULT WINAPI
entityref_GetTypeInfo(
117 IXMLDOMEntityReference
*iface
,
118 UINT iTInfo
, LCID lcid
,
119 ITypeInfo
** ppTInfo
)
121 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
124 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
126 hr
= get_typeinfo(IXMLDOMEntityReference_tid
, ppTInfo
);
131 static HRESULT WINAPI
entityref_GetIDsOfNames(
132 IXMLDOMEntityReference
*iface
,
133 REFIID riid
, LPOLESTR
* rgszNames
,
134 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
136 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
140 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
143 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
146 hr
= get_typeinfo(IXMLDOMEntityReference_tid
, &typeinfo
);
149 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
150 ITypeInfo_Release(typeinfo
);
156 static HRESULT WINAPI
entityref_Invoke(
157 IXMLDOMEntityReference
*iface
,
158 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
159 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
160 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
162 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
166 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
167 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
169 hr
= get_typeinfo(IXMLDOMEntityReference_tid
, &typeinfo
);
172 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVtbl
), dispIdMember
, wFlags
, pDispParams
,
173 pVarResult
, pExcepInfo
, puArgErr
);
174 ITypeInfo_Release(typeinfo
);
180 static HRESULT WINAPI
entityref_get_nodeName(
181 IXMLDOMEntityReference
*iface
,
184 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
186 FIXME("(%p)->(%p)\n", This
, p
);
188 return node_get_nodeName(&This
->node
, p
);
191 static HRESULT WINAPI
entityref_get_nodeValue(
192 IXMLDOMEntityReference
*iface
,
195 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
197 FIXME("(%p)->(%p)\n", This
, value
);
202 V_VT(value
) = VT_NULL
;
206 static HRESULT WINAPI
entityref_put_nodeValue(
207 IXMLDOMEntityReference
*iface
,
210 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
211 FIXME("(%p)->(v%d)\n", This
, V_VT(&value
));
215 static HRESULT WINAPI
entityref_get_nodeType(
216 IXMLDOMEntityReference
*iface
,
217 DOMNodeType
* domNodeType
)
219 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
221 TRACE("(%p)->(%p)\n", This
, domNodeType
);
223 *domNodeType
= NODE_ENTITY_REFERENCE
;
227 static HRESULT WINAPI
entityref_get_parentNode(
228 IXMLDOMEntityReference
*iface
,
229 IXMLDOMNode
** parent
)
231 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
233 TRACE("(%p)->(%p)\n", This
, parent
);
235 return node_get_parent(&This
->node
, parent
);
238 static HRESULT WINAPI
entityref_get_childNodes(
239 IXMLDOMEntityReference
*iface
,
240 IXMLDOMNodeList
** outList
)
242 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
244 TRACE("(%p)->(%p)\n", This
, outList
);
246 return node_get_child_nodes(&This
->node
, outList
);
249 static HRESULT WINAPI
entityref_get_firstChild(
250 IXMLDOMEntityReference
*iface
,
251 IXMLDOMNode
** domNode
)
253 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
255 TRACE("(%p)->(%p)\n", This
, domNode
);
257 return node_get_first_child(&This
->node
, domNode
);
260 static HRESULT WINAPI
entityref_get_lastChild(
261 IXMLDOMEntityReference
*iface
,
262 IXMLDOMNode
** domNode
)
264 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
266 TRACE("(%p)->(%p)\n", This
, domNode
);
268 return node_get_last_child(&This
->node
, domNode
);
271 static HRESULT WINAPI
entityref_get_previousSibling(
272 IXMLDOMEntityReference
*iface
,
273 IXMLDOMNode
** domNode
)
275 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
277 TRACE("(%p)->(%p)\n", This
, domNode
);
279 return node_get_previous_sibling(&This
->node
, domNode
);
282 static HRESULT WINAPI
entityref_get_nextSibling(
283 IXMLDOMEntityReference
*iface
,
284 IXMLDOMNode
** domNode
)
286 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
288 TRACE("(%p)->(%p)\n", This
, domNode
);
290 return node_get_next_sibling(&This
->node
, domNode
);
293 static HRESULT WINAPI
entityref_get_attributes(
294 IXMLDOMEntityReference
*iface
,
295 IXMLDOMNamedNodeMap
** attributeMap
)
297 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
299 TRACE("(%p)->(%p)\n", This
, attributeMap
);
301 return return_null_ptr((void**)attributeMap
);
304 static HRESULT WINAPI
entityref_insertBefore(
305 IXMLDOMEntityReference
*iface
,
306 IXMLDOMNode
* newNode
, VARIANT refChild
,
307 IXMLDOMNode
** outOldNode
)
309 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
311 FIXME("(%p)->(%p x%d %p) needs test\n", This
, newNode
, V_VT(&refChild
), outOldNode
);
313 return node_insert_before(&This
->node
, newNode
, &refChild
, outOldNode
);
316 static HRESULT WINAPI
entityref_replaceChild(
317 IXMLDOMEntityReference
*iface
,
318 IXMLDOMNode
* newNode
,
319 IXMLDOMNode
* oldNode
,
320 IXMLDOMNode
** outOldNode
)
322 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
324 FIXME("(%p)->(%p %p %p) needs test\n", This
, newNode
, oldNode
, outOldNode
);
326 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
329 static HRESULT WINAPI
entityref_removeChild(
330 IXMLDOMEntityReference
*iface
,
331 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
333 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
334 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This
->node
), domNode
, oldNode
);
337 static HRESULT WINAPI
entityref_appendChild(
338 IXMLDOMEntityReference
*iface
,
339 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
341 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
342 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This
->node
), newNode
, outNewNode
);
345 static HRESULT WINAPI
entityref_hasChildNodes(
346 IXMLDOMEntityReference
*iface
,
349 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
350 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This
->node
), pbool
);
353 static HRESULT WINAPI
entityref_get_ownerDocument(
354 IXMLDOMEntityReference
*iface
,
355 IXMLDOMDocument
** domDocument
)
357 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
358 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This
->node
), domDocument
);
361 static HRESULT WINAPI
entityref_cloneNode(
362 IXMLDOMEntityReference
*iface
,
363 VARIANT_BOOL deep
, IXMLDOMNode
** outNode
)
365 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
366 TRACE("(%p)->(%d %p)\n", This
, deep
, outNode
);
367 return node_clone( &This
->node
, deep
, outNode
);
370 static HRESULT WINAPI
entityref_get_nodeTypeString(
371 IXMLDOMEntityReference
*iface
,
374 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
375 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This
->node
), p
);
378 static HRESULT WINAPI
entityref_get_text(
379 IXMLDOMEntityReference
*iface
,
382 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
383 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This
->node
), p
);
386 static HRESULT WINAPI
entityref_put_text(
387 IXMLDOMEntityReference
*iface
,
390 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
391 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
392 return node_put_text( &This
->node
, p
);
395 static HRESULT WINAPI
entityref_get_specified(
396 IXMLDOMEntityReference
*iface
,
397 VARIANT_BOOL
* isSpecified
)
399 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
400 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
401 *isSpecified
= VARIANT_TRUE
;
405 static HRESULT WINAPI
entityref_get_definition(
406 IXMLDOMEntityReference
*iface
,
407 IXMLDOMNode
** definitionNode
)
409 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
410 FIXME("(%p)->(%p)\n", This
, definitionNode
);
414 static HRESULT WINAPI
entityref_get_nodeTypedValue(
415 IXMLDOMEntityReference
*iface
,
418 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
419 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
422 static HRESULT WINAPI
entityref_put_nodeTypedValue(
423 IXMLDOMEntityReference
*iface
,
426 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
427 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
430 static HRESULT WINAPI
entityref_get_dataType(
431 IXMLDOMEntityReference
*iface
,
434 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
435 FIXME("(%p)->(%p): should return a valid value\n", This
, typename
);
436 return return_null_var( typename
);
439 static HRESULT WINAPI
entityref_put_dataType(
440 IXMLDOMEntityReference
*iface
,
443 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
444 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This
->node
), p
);
447 static HRESULT WINAPI
entityref_get_xml(
448 IXMLDOMEntityReference
*iface
,
451 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
453 TRACE("(%p)->(%p)\n", This
, p
);
455 return node_get_xml(&This
->node
, FALSE
, FALSE
, p
);
458 static HRESULT WINAPI
entityref_transformNode(
459 IXMLDOMEntityReference
*iface
,
460 IXMLDOMNode
* domNode
, BSTR
* p
)
462 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
463 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This
->node
), domNode
, p
);
466 static HRESULT WINAPI
entityref_selectNodes(
467 IXMLDOMEntityReference
*iface
,
468 BSTR p
, IXMLDOMNodeList
** outList
)
470 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
471 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This
->node
), p
, outList
);
474 static HRESULT WINAPI
entityref_selectSingleNode(
475 IXMLDOMEntityReference
*iface
,
476 BSTR p
, IXMLDOMNode
** outNode
)
478 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
479 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This
->node
), p
, outNode
);
482 static HRESULT WINAPI
entityref_get_parsed(
483 IXMLDOMEntityReference
*iface
,
484 VARIANT_BOOL
* isParsed
)
486 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
487 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
488 *isParsed
= VARIANT_TRUE
;
492 static HRESULT WINAPI
entityref_get_namespaceURI(
493 IXMLDOMEntityReference
*iface
,
496 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
497 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This
->node
), p
);
500 static HRESULT WINAPI
entityref_get_prefix(
501 IXMLDOMEntityReference
*iface
,
504 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
505 TRACE("(%p)->(%p)\n", This
, prefix
);
506 return node_get_prefix( &This
->node
, prefix
);
509 static HRESULT WINAPI
entityref_get_baseName(
510 IXMLDOMEntityReference
*iface
,
513 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
514 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This
->node
), p
);
517 static HRESULT WINAPI
entityref_transformNodeToObject(
518 IXMLDOMEntityReference
*iface
,
519 IXMLDOMNode
* domNode
, VARIANT var1
)
521 entityref
*This
= impl_from_IXMLDOMEntityReference( iface
);
522 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This
->node
), domNode
, var1
);
525 static const struct IXMLDOMEntityReferenceVtbl entityref_vtbl
=
527 entityref_QueryInterface
,
530 entityref_GetTypeInfoCount
,
531 entityref_GetTypeInfo
,
532 entityref_GetIDsOfNames
,
534 entityref_get_nodeName
,
535 entityref_get_nodeValue
,
536 entityref_put_nodeValue
,
537 entityref_get_nodeType
,
538 entityref_get_parentNode
,
539 entityref_get_childNodes
,
540 entityref_get_firstChild
,
541 entityref_get_lastChild
,
542 entityref_get_previousSibling
,
543 entityref_get_nextSibling
,
544 entityref_get_attributes
,
545 entityref_insertBefore
,
546 entityref_replaceChild
,
547 entityref_removeChild
,
548 entityref_appendChild
,
549 entityref_hasChildNodes
,
550 entityref_get_ownerDocument
,
552 entityref_get_nodeTypeString
,
555 entityref_get_specified
,
556 entityref_get_definition
,
557 entityref_get_nodeTypedValue
,
558 entityref_put_nodeTypedValue
,
559 entityref_get_dataType
,
560 entityref_put_dataType
,
562 entityref_transformNode
,
563 entityref_selectNodes
,
564 entityref_selectSingleNode
,
565 entityref_get_parsed
,
566 entityref_get_namespaceURI
,
567 entityref_get_prefix
,
568 entityref_get_baseName
,
569 entityref_transformNodeToObject
,
572 IUnknown
* create_doc_entity_ref( xmlNodePtr entity
)
576 This
= heap_alloc( sizeof *This
);
580 This
->lpVtbl
= &entityref_vtbl
;
583 init_xmlnode(&This
->node
, entity
, (IXMLDOMNode
*)&This
->lpVtbl
, NULL
);
585 return (IUnknown
*) &This
->lpVtbl
;