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
42 const struct IXMLDOMEntityReferenceVtbl *lpVtbl;
48 static inline entityref *impl_from_IXMLDOMEntityReference( IXMLDOMEntityReference *iface )
50 return (entityref *)((char*)iface - FIELD_OFFSET(entityref, lpVtbl));
53 static HRESULT WINAPI entityref_QueryInterface(
54 IXMLDOMEntityReference *iface,
58 entityref *This = impl_from_IXMLDOMEntityReference( iface );
59 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
61 if ( IsEqualGUID( riid, &IID_IXMLDOMEntityReference ) ||
62 IsEqualGUID( riid, &IID_IDispatch ) ||
63 IsEqualGUID( riid, &IID_IUnknown ) )
67 else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) )
69 return IUnknown_QueryInterface(This->node_unk, riid, ppvObject);
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
77 IXMLDOMEntityReference_AddRef( iface );
82 static ULONG WINAPI entityref_AddRef(
83 IXMLDOMEntityReference *iface )
85 entityref *This = impl_from_IXMLDOMEntityReference( iface );
86 return InterlockedIncrement( &This->ref );
89 static ULONG WINAPI entityref_Release(
90 IXMLDOMEntityReference *iface )
92 entityref *This = impl_from_IXMLDOMEntityReference( iface );
95 ref = InterlockedDecrement( &This->ref );
98 IUnknown_Release( This->node_unk );
99 HeapFree( GetProcessHeap(), 0, This );
105 static HRESULT WINAPI entityref_GetTypeInfoCount(
106 IXMLDOMEntityReference *iface,
109 entityref *This = impl_from_IXMLDOMEntityReference( iface );
110 TRACE("(%p)->(%p)\n", This, pctinfo);
117 static HRESULT WINAPI entityref_GetTypeInfo(
118 IXMLDOMEntityReference *iface,
119 UINT iTInfo, LCID lcid,
120 ITypeInfo** ppTInfo )
122 entityref *This = impl_from_IXMLDOMEntityReference( iface );
125 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
127 hr = get_typeinfo(IXMLDOMEntityReference_tid, ppTInfo);
132 static HRESULT WINAPI entityref_GetIDsOfNames(
133 IXMLDOMEntityReference *iface,
134 REFIID riid, LPOLESTR* rgszNames,
135 UINT cNames, LCID lcid, DISPID* rgDispId )
137 entityref *This = impl_from_IXMLDOMEntityReference( iface );
141 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
144 if(!rgszNames || cNames == 0 || !rgDispId)
147 hr = get_typeinfo(IXMLDOMEntityReference_tid, &typeinfo);
150 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
151 ITypeInfo_Release(typeinfo);
157 static HRESULT WINAPI entityref_Invoke(
158 IXMLDOMEntityReference *iface,
159 DISPID dispIdMember, REFIID riid, LCID lcid,
160 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
161 EXCEPINFO* pExcepInfo, UINT* puArgErr )
163 entityref *This = impl_from_IXMLDOMEntityReference( iface );
167 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
168 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
170 hr = get_typeinfo(IXMLDOMEntityReference_tid, &typeinfo);
173 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
174 pVarResult, pExcepInfo, puArgErr);
175 ITypeInfo_Release(typeinfo);
181 static HRESULT WINAPI entityref_get_nodeName(
182 IXMLDOMEntityReference *iface,
185 entityref *This = impl_from_IXMLDOMEntityReference( iface );
186 return IXMLDOMNode_get_nodeName( This->node, p );
189 static HRESULT WINAPI entityref_get_nodeValue(
190 IXMLDOMEntityReference *iface,
193 entityref *This = impl_from_IXMLDOMEntityReference( iface );
194 return IXMLDOMNode_get_nodeValue( This->node, var1 );
197 static HRESULT WINAPI entityref_put_nodeValue(
198 IXMLDOMEntityReference *iface,
201 entityref *This = impl_from_IXMLDOMEntityReference( iface );
202 return IXMLDOMNode_put_nodeValue( This->node, var1 );
205 static HRESULT WINAPI entityref_get_nodeType(
206 IXMLDOMEntityReference *iface,
207 DOMNodeType* domNodeType )
209 entityref *This = impl_from_IXMLDOMEntityReference( iface );
210 return IXMLDOMNode_get_nodeType( This->node, domNodeType );
213 static HRESULT WINAPI entityref_get_parentNode(
214 IXMLDOMEntityReference *iface,
215 IXMLDOMNode** parent )
217 entityref *This = impl_from_IXMLDOMEntityReference( iface );
218 return IXMLDOMNode_get_parentNode( This->node, parent );
221 static HRESULT WINAPI entityref_get_childNodes(
222 IXMLDOMEntityReference *iface,
223 IXMLDOMNodeList** outList)
225 entityref *This = impl_from_IXMLDOMEntityReference( iface );
226 return IXMLDOMNode_get_childNodes( This->node, outList );
229 static HRESULT WINAPI entityref_get_firstChild(
230 IXMLDOMEntityReference *iface,
231 IXMLDOMNode** domNode)
233 entityref *This = impl_from_IXMLDOMEntityReference( iface );
234 return IXMLDOMNode_get_firstChild( This->node, domNode );
237 static HRESULT WINAPI entityref_get_lastChild(
238 IXMLDOMEntityReference *iface,
239 IXMLDOMNode** domNode)
241 entityref *This = impl_from_IXMLDOMEntityReference( iface );
242 return IXMLDOMNode_get_lastChild( This->node, domNode );
245 static HRESULT WINAPI entityref_get_previousSibling(
246 IXMLDOMEntityReference *iface,
247 IXMLDOMNode** domNode)
249 entityref *This = impl_from_IXMLDOMEntityReference( iface );
250 return IXMLDOMNode_get_previousSibling( This->node, domNode );
253 static HRESULT WINAPI entityref_get_nextSibling(
254 IXMLDOMEntityReference *iface,
255 IXMLDOMNode** domNode)
257 entityref *This = impl_from_IXMLDOMEntityReference( iface );
258 return IXMLDOMNode_get_nextSibling( This->node, domNode );
261 static HRESULT WINAPI entityref_get_attributes(
262 IXMLDOMEntityReference *iface,
263 IXMLDOMNamedNodeMap** attributeMap)
265 entityref *This = impl_from_IXMLDOMEntityReference( iface );
266 return IXMLDOMNode_get_attributes( This->node, attributeMap );
269 static HRESULT WINAPI entityref_insertBefore(
270 IXMLDOMEntityReference *iface,
271 IXMLDOMNode* newNode, VARIANT var1,
272 IXMLDOMNode** outOldNode)
274 entityref *This = impl_from_IXMLDOMEntityReference( iface );
275 return IXMLDOMNode_insertBefore( This->node, newNode, var1, outOldNode );
278 static HRESULT WINAPI entityref_replaceChild(
279 IXMLDOMEntityReference *iface,
280 IXMLDOMNode* newNode,
281 IXMLDOMNode* oldNode,
282 IXMLDOMNode** outOldNode)
284 entityref *This = impl_from_IXMLDOMEntityReference( iface );
285 return IXMLDOMNode_replaceChild( This->node, newNode, oldNode, outOldNode );
288 static HRESULT WINAPI entityref_removeChild(
289 IXMLDOMEntityReference *iface,
290 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
292 entityref *This = impl_from_IXMLDOMEntityReference( iface );
293 return IXMLDOMNode_removeChild( This->node, domNode, oldNode );
296 static HRESULT WINAPI entityref_appendChild(
297 IXMLDOMEntityReference *iface,
298 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
300 entityref *This = impl_from_IXMLDOMEntityReference( iface );
301 return IXMLDOMNode_appendChild( This->node, newNode, outNewNode );
304 static HRESULT WINAPI entityref_hasChildNodes(
305 IXMLDOMEntityReference *iface,
308 entityref *This = impl_from_IXMLDOMEntityReference( iface );
309 return IXMLDOMNode_hasChildNodes( This->node, pbool );
312 static HRESULT WINAPI entityref_get_ownerDocument(
313 IXMLDOMEntityReference *iface,
314 IXMLDOMDocument** domDocument)
316 entityref *This = impl_from_IXMLDOMEntityReference( iface );
317 return IXMLDOMNode_get_ownerDocument( This->node, domDocument );
320 static HRESULT WINAPI entityref_cloneNode(
321 IXMLDOMEntityReference *iface,
322 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
324 entityref *This = impl_from_IXMLDOMEntityReference( iface );
325 return IXMLDOMNode_cloneNode( This->node, pbool, outNode );
328 static HRESULT WINAPI entityref_get_nodeTypeString(
329 IXMLDOMEntityReference *iface,
332 entityref *This = impl_from_IXMLDOMEntityReference( iface );
333 return IXMLDOMNode_get_nodeTypeString( This->node, p );
336 static HRESULT WINAPI entityref_get_text(
337 IXMLDOMEntityReference *iface,
340 entityref *This = impl_from_IXMLDOMEntityReference( iface );
341 return IXMLDOMNode_get_text( This->node, p );
344 static HRESULT WINAPI entityref_put_text(
345 IXMLDOMEntityReference *iface,
348 entityref *This = impl_from_IXMLDOMEntityReference( iface );
349 return IXMLDOMNode_put_text( This->node, p );
352 static HRESULT WINAPI entityref_get_specified(
353 IXMLDOMEntityReference *iface,
356 entityref *This = impl_from_IXMLDOMEntityReference( iface );
357 return IXMLDOMNode_get_specified( This->node, pbool );
360 static HRESULT WINAPI entityref_get_definition(
361 IXMLDOMEntityReference *iface,
362 IXMLDOMNode** domNode)
364 entityref *This = impl_from_IXMLDOMEntityReference( iface );
365 return IXMLDOMNode_get_definition( This->node, domNode );
368 static HRESULT WINAPI entityref_get_nodeTypedValue(
369 IXMLDOMEntityReference *iface,
372 entityref *This = impl_from_IXMLDOMEntityReference( iface );
373 return IXMLDOMNode_get_nodeTypedValue( This->node, var1 );
376 static HRESULT WINAPI entityref_put_nodeTypedValue(
377 IXMLDOMEntityReference *iface,
380 entityref *This = impl_from_IXMLDOMEntityReference( iface );
381 return IXMLDOMNode_put_nodeTypedValue( This->node, var1 );
384 static HRESULT WINAPI entityref_get_dataType(
385 IXMLDOMEntityReference *iface,
388 entityref *This = impl_from_IXMLDOMEntityReference( iface );
389 return IXMLDOMNode_get_dataType( This->node, var1 );
392 static HRESULT WINAPI entityref_put_dataType(
393 IXMLDOMEntityReference *iface,
396 entityref *This = impl_from_IXMLDOMEntityReference( iface );
397 return IXMLDOMNode_put_dataType( This->node, p );
400 static HRESULT WINAPI entityref_get_xml(
401 IXMLDOMEntityReference *iface,
404 entityref *This = impl_from_IXMLDOMEntityReference( iface );
405 return IXMLDOMNode_get_xml( This->node, p );
408 static HRESULT WINAPI entityref_transformNode(
409 IXMLDOMEntityReference *iface,
410 IXMLDOMNode* domNode, BSTR* p)
412 entityref *This = impl_from_IXMLDOMEntityReference( iface );
413 return IXMLDOMNode_transformNode( This->node, domNode, p );
416 static HRESULT WINAPI entityref_selectNodes(
417 IXMLDOMEntityReference *iface,
418 BSTR p, IXMLDOMNodeList** outList)
420 entityref *This = impl_from_IXMLDOMEntityReference( iface );
421 return IXMLDOMNode_selectNodes( This->node, p, outList );
424 static HRESULT WINAPI entityref_selectSingleNode(
425 IXMLDOMEntityReference *iface,
426 BSTR p, IXMLDOMNode** outNode)
428 entityref *This = impl_from_IXMLDOMEntityReference( iface );
429 return IXMLDOMNode_selectSingleNode( This->node, p, outNode );
432 static HRESULT WINAPI entityref_get_parsed(
433 IXMLDOMEntityReference *iface,
436 entityref *This = impl_from_IXMLDOMEntityReference( iface );
437 return IXMLDOMNode_get_parsed( This->node, pbool );
440 static HRESULT WINAPI entityref_get_namespaceURI(
441 IXMLDOMEntityReference *iface,
444 entityref *This = impl_from_IXMLDOMEntityReference( iface );
445 return IXMLDOMNode_get_namespaceURI( This->node, p );
448 static HRESULT WINAPI entityref_get_prefix(
449 IXMLDOMEntityReference *iface,
452 entityref *This = impl_from_IXMLDOMEntityReference( iface );
453 return IXMLDOMNode_get_prefix( This->node, p );
456 static HRESULT WINAPI entityref_get_baseName(
457 IXMLDOMEntityReference *iface,
460 entityref *This = impl_from_IXMLDOMEntityReference( iface );
461 return IXMLDOMNode_get_baseName( This->node, p );
464 static HRESULT WINAPI entityref_transformNodeToObject(
465 IXMLDOMEntityReference *iface,
466 IXMLDOMNode* domNode, VARIANT var1)
468 entityref *This = impl_from_IXMLDOMEntityReference( iface );
469 return IXMLDOMNode_transformNodeToObject( This->node, domNode, var1 );
472 static const struct IXMLDOMEntityReferenceVtbl entityref_vtbl =
474 entityref_QueryInterface,
477 entityref_GetTypeInfoCount,
478 entityref_GetTypeInfo,
479 entityref_GetIDsOfNames,
481 entityref_get_nodeName,
482 entityref_get_nodeValue,
483 entityref_put_nodeValue,
484 entityref_get_nodeType,
485 entityref_get_parentNode,
486 entityref_get_childNodes,
487 entityref_get_firstChild,
488 entityref_get_lastChild,
489 entityref_get_previousSibling,
490 entityref_get_nextSibling,
491 entityref_get_attributes,
492 entityref_insertBefore,
493 entityref_replaceChild,
494 entityref_removeChild,
495 entityref_appendChild,
496 entityref_hasChildNodes,
497 entityref_get_ownerDocument,
499 entityref_get_nodeTypeString,
502 entityref_get_specified,
503 entityref_get_definition,
504 entityref_get_nodeTypedValue,
505 entityref_put_nodeTypedValue,
506 entityref_get_dataType,
507 entityref_put_dataType,
509 entityref_transformNode,
510 entityref_selectNodes,
511 entityref_selectSingleNode,
512 entityref_get_parsed,
513 entityref_get_namespaceURI,
514 entityref_get_prefix,
515 entityref_get_baseName,
516 entityref_transformNodeToObject,
519 IUnknown* create_doc_entity_ref( xmlNodePtr entity )
524 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
528 This->lpVtbl = &entityref_vtbl;
531 This->node_unk = create_basic_node( entity, (IUnknown*)&This->lpVtbl );
534 HeapFree(GetProcessHeap(), 0, This);
538 hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
541 IUnknown_Release(This->node_unk);
542 HeapFree( GetProcessHeap(), 0, This );
545 /* The ref on This->node is actually looped back into this object, so release it */
546 IXMLDOMNode_Release(This->node);
548 return (IUnknown*) &This->lpVtbl;