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 pbool, IXMLDOMNode** outNode)
365 entityref *This = impl_from_IXMLDOMEntityReference( iface );
366 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
369 static HRESULT WINAPI entityref_get_nodeTypeString(
370 IXMLDOMEntityReference *iface,
373 entityref *This = impl_from_IXMLDOMEntityReference( iface );
374 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
377 static HRESULT WINAPI entityref_get_text(
378 IXMLDOMEntityReference *iface,
381 entityref *This = impl_from_IXMLDOMEntityReference( iface );
382 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
385 static HRESULT WINAPI entityref_put_text(
386 IXMLDOMEntityReference *iface,
389 entityref *This = impl_from_IXMLDOMEntityReference( iface );
390 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
393 static HRESULT WINAPI entityref_get_specified(
394 IXMLDOMEntityReference *iface,
397 entityref *This = impl_from_IXMLDOMEntityReference( iface );
398 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
401 static HRESULT WINAPI entityref_get_definition(
402 IXMLDOMEntityReference *iface,
403 IXMLDOMNode** domNode)
405 entityref *This = impl_from_IXMLDOMEntityReference( iface );
406 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
409 static HRESULT WINAPI entityref_get_nodeTypedValue(
410 IXMLDOMEntityReference *iface,
413 entityref *This = impl_from_IXMLDOMEntityReference( iface );
414 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
417 static HRESULT WINAPI entityref_put_nodeTypedValue(
418 IXMLDOMEntityReference *iface,
421 entityref *This = impl_from_IXMLDOMEntityReference( iface );
422 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
425 static HRESULT WINAPI entityref_get_dataType(
426 IXMLDOMEntityReference *iface,
429 entityref *This = impl_from_IXMLDOMEntityReference( iface );
430 FIXME("(%p)->(%p): should return a valid value\n", This, typename);
431 return return_null_var( typename );
434 static HRESULT WINAPI entityref_put_dataType(
435 IXMLDOMEntityReference *iface,
438 entityref *This = impl_from_IXMLDOMEntityReference( iface );
439 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
442 static HRESULT WINAPI entityref_get_xml(
443 IXMLDOMEntityReference *iface,
446 entityref *This = impl_from_IXMLDOMEntityReference( iface );
447 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
450 static HRESULT WINAPI entityref_transformNode(
451 IXMLDOMEntityReference *iface,
452 IXMLDOMNode* domNode, BSTR* p)
454 entityref *This = impl_from_IXMLDOMEntityReference( iface );
455 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
458 static HRESULT WINAPI entityref_selectNodes(
459 IXMLDOMEntityReference *iface,
460 BSTR p, IXMLDOMNodeList** outList)
462 entityref *This = impl_from_IXMLDOMEntityReference( iface );
463 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
466 static HRESULT WINAPI entityref_selectSingleNode(
467 IXMLDOMEntityReference *iface,
468 BSTR p, IXMLDOMNode** outNode)
470 entityref *This = impl_from_IXMLDOMEntityReference( iface );
471 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
474 static HRESULT WINAPI entityref_get_parsed(
475 IXMLDOMEntityReference *iface,
478 entityref *This = impl_from_IXMLDOMEntityReference( iface );
479 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
482 static HRESULT WINAPI entityref_get_namespaceURI(
483 IXMLDOMEntityReference *iface,
486 entityref *This = impl_from_IXMLDOMEntityReference( iface );
487 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
490 static HRESULT WINAPI entityref_get_prefix(
491 IXMLDOMEntityReference *iface,
494 entityref *This = impl_from_IXMLDOMEntityReference( iface );
495 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
498 static HRESULT WINAPI entityref_get_baseName(
499 IXMLDOMEntityReference *iface,
502 entityref *This = impl_from_IXMLDOMEntityReference( iface );
503 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
506 static HRESULT WINAPI entityref_transformNodeToObject(
507 IXMLDOMEntityReference *iface,
508 IXMLDOMNode* domNode, VARIANT var1)
510 entityref *This = impl_from_IXMLDOMEntityReference( iface );
511 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
514 static const struct IXMLDOMEntityReferenceVtbl entityref_vtbl =
516 entityref_QueryInterface,
519 entityref_GetTypeInfoCount,
520 entityref_GetTypeInfo,
521 entityref_GetIDsOfNames,
523 entityref_get_nodeName,
524 entityref_get_nodeValue,
525 entityref_put_nodeValue,
526 entityref_get_nodeType,
527 entityref_get_parentNode,
528 entityref_get_childNodes,
529 entityref_get_firstChild,
530 entityref_get_lastChild,
531 entityref_get_previousSibling,
532 entityref_get_nextSibling,
533 entityref_get_attributes,
534 entityref_insertBefore,
535 entityref_replaceChild,
536 entityref_removeChild,
537 entityref_appendChild,
538 entityref_hasChildNodes,
539 entityref_get_ownerDocument,
541 entityref_get_nodeTypeString,
544 entityref_get_specified,
545 entityref_get_definition,
546 entityref_get_nodeTypedValue,
547 entityref_put_nodeTypedValue,
548 entityref_get_dataType,
549 entityref_put_dataType,
551 entityref_transformNode,
552 entityref_selectNodes,
553 entityref_selectSingleNode,
554 entityref_get_parsed,
555 entityref_get_namespaceURI,
556 entityref_get_prefix,
557 entityref_get_baseName,
558 entityref_transformNodeToObject,
561 IUnknown* create_doc_entity_ref( xmlNodePtr entity )
565 This = heap_alloc( sizeof *This );
569 This->lpVtbl = &entityref_vtbl;
572 init_xmlnode(&This->node, entity, (IXMLDOMNode*)&This->lpVtbl, NULL);
574 return (IUnknown*) &This->lpVtbl;