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_IDispatch ) ||
62 IsEqualGUID( riid, &IID_IUnknown ) )
66 else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) )
68 *ppvObject = IXMLDOMNode_from_impl(&This->node);
72 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
76 IUnknown_AddRef((IUnknown*)*ppvObject);
80 static ULONG WINAPI entityref_AddRef(
81 IXMLDOMEntityReference *iface )
83 entityref *This = impl_from_IXMLDOMEntityReference( iface );
84 return InterlockedIncrement( &This->ref );
87 static ULONG WINAPI entityref_Release(
88 IXMLDOMEntityReference *iface )
90 entityref *This = impl_from_IXMLDOMEntityReference( iface );
93 ref = InterlockedDecrement( &This->ref );
96 destroy_xmlnode(&This->node);
97 HeapFree( GetProcessHeap(), 0, This );
103 static HRESULT WINAPI entityref_GetTypeInfoCount(
104 IXMLDOMEntityReference *iface,
107 entityref *This = impl_from_IXMLDOMEntityReference( iface );
108 TRACE("(%p)->(%p)\n", This, pctinfo);
115 static HRESULT WINAPI entityref_GetTypeInfo(
116 IXMLDOMEntityReference *iface,
117 UINT iTInfo, LCID lcid,
118 ITypeInfo** ppTInfo )
120 entityref *This = impl_from_IXMLDOMEntityReference( iface );
123 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
125 hr = get_typeinfo(IXMLDOMEntityReference_tid, ppTInfo);
130 static HRESULT WINAPI entityref_GetIDsOfNames(
131 IXMLDOMEntityReference *iface,
132 REFIID riid, LPOLESTR* rgszNames,
133 UINT cNames, LCID lcid, DISPID* rgDispId )
135 entityref *This = impl_from_IXMLDOMEntityReference( iface );
139 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
142 if(!rgszNames || cNames == 0 || !rgDispId)
145 hr = get_typeinfo(IXMLDOMEntityReference_tid, &typeinfo);
148 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
149 ITypeInfo_Release(typeinfo);
155 static HRESULT WINAPI entityref_Invoke(
156 IXMLDOMEntityReference *iface,
157 DISPID dispIdMember, REFIID riid, LCID lcid,
158 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
159 EXCEPINFO* pExcepInfo, UINT* puArgErr )
161 entityref *This = impl_from_IXMLDOMEntityReference( iface );
165 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
166 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
168 hr = get_typeinfo(IXMLDOMEntityReference_tid, &typeinfo);
171 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
172 pVarResult, pExcepInfo, puArgErr);
173 ITypeInfo_Release(typeinfo);
179 static HRESULT WINAPI entityref_get_nodeName(
180 IXMLDOMEntityReference *iface,
183 entityref *This = impl_from_IXMLDOMEntityReference( iface );
184 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p );
187 static HRESULT WINAPI entityref_get_nodeValue(
188 IXMLDOMEntityReference *iface,
191 entityref *This = impl_from_IXMLDOMEntityReference( iface );
192 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
195 static HRESULT WINAPI entityref_put_nodeValue(
196 IXMLDOMEntityReference *iface,
199 entityref *This = impl_from_IXMLDOMEntityReference( iface );
200 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
203 static HRESULT WINAPI entityref_get_nodeType(
204 IXMLDOMEntityReference *iface,
205 DOMNodeType* domNodeType )
207 entityref *This = impl_from_IXMLDOMEntityReference( iface );
208 return IXMLDOMNode_get_nodeType( IXMLDOMNode_from_impl(&This->node), domNodeType );
211 static HRESULT WINAPI entityref_get_parentNode(
212 IXMLDOMEntityReference *iface,
213 IXMLDOMNode** parent )
215 entityref *This = impl_from_IXMLDOMEntityReference( iface );
216 return IXMLDOMNode_get_parentNode( IXMLDOMNode_from_impl(&This->node), parent );
219 static HRESULT WINAPI entityref_get_childNodes(
220 IXMLDOMEntityReference *iface,
221 IXMLDOMNodeList** outList)
223 entityref *This = impl_from_IXMLDOMEntityReference( iface );
224 return IXMLDOMNode_get_childNodes( IXMLDOMNode_from_impl(&This->node), outList );
227 static HRESULT WINAPI entityref_get_firstChild(
228 IXMLDOMEntityReference *iface,
229 IXMLDOMNode** domNode)
231 entityref *This = impl_from_IXMLDOMEntityReference( iface );
232 return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode );
235 static HRESULT WINAPI entityref_get_lastChild(
236 IXMLDOMEntityReference *iface,
237 IXMLDOMNode** domNode)
239 entityref *This = impl_from_IXMLDOMEntityReference( iface );
240 return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode );
243 static HRESULT WINAPI entityref_get_previousSibling(
244 IXMLDOMEntityReference *iface,
245 IXMLDOMNode** domNode)
247 entityref *This = impl_from_IXMLDOMEntityReference( iface );
248 return IXMLDOMNode_get_previousSibling( IXMLDOMNode_from_impl(&This->node), domNode );
251 static HRESULT WINAPI entityref_get_nextSibling(
252 IXMLDOMEntityReference *iface,
253 IXMLDOMNode** domNode)
255 entityref *This = impl_from_IXMLDOMEntityReference( iface );
256 return IXMLDOMNode_get_nextSibling( IXMLDOMNode_from_impl(&This->node), domNode );
259 static HRESULT WINAPI entityref_get_attributes(
260 IXMLDOMEntityReference *iface,
261 IXMLDOMNamedNodeMap** attributeMap)
263 entityref *This = impl_from_IXMLDOMEntityReference( iface );
264 return IXMLDOMNode_get_attributes( IXMLDOMNode_from_impl(&This->node), attributeMap );
267 static HRESULT WINAPI entityref_insertBefore(
268 IXMLDOMEntityReference *iface,
269 IXMLDOMNode* newNode, VARIANT var1,
270 IXMLDOMNode** outOldNode)
272 entityref *This = impl_from_IXMLDOMEntityReference( iface );
273 return IXMLDOMNode_insertBefore( IXMLDOMNode_from_impl(&This->node), newNode, var1, outOldNode );
276 static HRESULT WINAPI entityref_replaceChild(
277 IXMLDOMEntityReference *iface,
278 IXMLDOMNode* newNode,
279 IXMLDOMNode* oldNode,
280 IXMLDOMNode** outOldNode)
282 entityref *This = impl_from_IXMLDOMEntityReference( iface );
283 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newNode, oldNode, outOldNode );
286 static HRESULT WINAPI entityref_removeChild(
287 IXMLDOMEntityReference *iface,
288 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
290 entityref *This = impl_from_IXMLDOMEntityReference( iface );
291 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
294 static HRESULT WINAPI entityref_appendChild(
295 IXMLDOMEntityReference *iface,
296 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
298 entityref *This = impl_from_IXMLDOMEntityReference( iface );
299 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
302 static HRESULT WINAPI entityref_hasChildNodes(
303 IXMLDOMEntityReference *iface,
306 entityref *This = impl_from_IXMLDOMEntityReference( iface );
307 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
310 static HRESULT WINAPI entityref_get_ownerDocument(
311 IXMLDOMEntityReference *iface,
312 IXMLDOMDocument** domDocument)
314 entityref *This = impl_from_IXMLDOMEntityReference( iface );
315 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
318 static HRESULT WINAPI entityref_cloneNode(
319 IXMLDOMEntityReference *iface,
320 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
322 entityref *This = impl_from_IXMLDOMEntityReference( iface );
323 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
326 static HRESULT WINAPI entityref_get_nodeTypeString(
327 IXMLDOMEntityReference *iface,
330 entityref *This = impl_from_IXMLDOMEntityReference( iface );
331 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
334 static HRESULT WINAPI entityref_get_text(
335 IXMLDOMEntityReference *iface,
338 entityref *This = impl_from_IXMLDOMEntityReference( iface );
339 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
342 static HRESULT WINAPI entityref_put_text(
343 IXMLDOMEntityReference *iface,
346 entityref *This = impl_from_IXMLDOMEntityReference( iface );
347 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
350 static HRESULT WINAPI entityref_get_specified(
351 IXMLDOMEntityReference *iface,
354 entityref *This = impl_from_IXMLDOMEntityReference( iface );
355 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
358 static HRESULT WINAPI entityref_get_definition(
359 IXMLDOMEntityReference *iface,
360 IXMLDOMNode** domNode)
362 entityref *This = impl_from_IXMLDOMEntityReference( iface );
363 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
366 static HRESULT WINAPI entityref_get_nodeTypedValue(
367 IXMLDOMEntityReference *iface,
370 entityref *This = impl_from_IXMLDOMEntityReference( iface );
371 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
374 static HRESULT WINAPI entityref_put_nodeTypedValue(
375 IXMLDOMEntityReference *iface,
378 entityref *This = impl_from_IXMLDOMEntityReference( iface );
379 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
382 static HRESULT WINAPI entityref_get_dataType(
383 IXMLDOMEntityReference *iface,
386 entityref *This = impl_from_IXMLDOMEntityReference( iface );
387 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
390 static HRESULT WINAPI entityref_put_dataType(
391 IXMLDOMEntityReference *iface,
394 entityref *This = impl_from_IXMLDOMEntityReference( iface );
395 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
398 static HRESULT WINAPI entityref_get_xml(
399 IXMLDOMEntityReference *iface,
402 entityref *This = impl_from_IXMLDOMEntityReference( iface );
403 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
406 static HRESULT WINAPI entityref_transformNode(
407 IXMLDOMEntityReference *iface,
408 IXMLDOMNode* domNode, BSTR* p)
410 entityref *This = impl_from_IXMLDOMEntityReference( iface );
411 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
414 static HRESULT WINAPI entityref_selectNodes(
415 IXMLDOMEntityReference *iface,
416 BSTR p, IXMLDOMNodeList** outList)
418 entityref *This = impl_from_IXMLDOMEntityReference( iface );
419 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
422 static HRESULT WINAPI entityref_selectSingleNode(
423 IXMLDOMEntityReference *iface,
424 BSTR p, IXMLDOMNode** outNode)
426 entityref *This = impl_from_IXMLDOMEntityReference( iface );
427 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
430 static HRESULT WINAPI entityref_get_parsed(
431 IXMLDOMEntityReference *iface,
434 entityref *This = impl_from_IXMLDOMEntityReference( iface );
435 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
438 static HRESULT WINAPI entityref_get_namespaceURI(
439 IXMLDOMEntityReference *iface,
442 entityref *This = impl_from_IXMLDOMEntityReference( iface );
443 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
446 static HRESULT WINAPI entityref_get_prefix(
447 IXMLDOMEntityReference *iface,
450 entityref *This = impl_from_IXMLDOMEntityReference( iface );
451 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
454 static HRESULT WINAPI entityref_get_baseName(
455 IXMLDOMEntityReference *iface,
458 entityref *This = impl_from_IXMLDOMEntityReference( iface );
459 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
462 static HRESULT WINAPI entityref_transformNodeToObject(
463 IXMLDOMEntityReference *iface,
464 IXMLDOMNode* domNode, VARIANT var1)
466 entityref *This = impl_from_IXMLDOMEntityReference( iface );
467 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
470 static const struct IXMLDOMEntityReferenceVtbl entityref_vtbl =
472 entityref_QueryInterface,
475 entityref_GetTypeInfoCount,
476 entityref_GetTypeInfo,
477 entityref_GetIDsOfNames,
479 entityref_get_nodeName,
480 entityref_get_nodeValue,
481 entityref_put_nodeValue,
482 entityref_get_nodeType,
483 entityref_get_parentNode,
484 entityref_get_childNodes,
485 entityref_get_firstChild,
486 entityref_get_lastChild,
487 entityref_get_previousSibling,
488 entityref_get_nextSibling,
489 entityref_get_attributes,
490 entityref_insertBefore,
491 entityref_replaceChild,
492 entityref_removeChild,
493 entityref_appendChild,
494 entityref_hasChildNodes,
495 entityref_get_ownerDocument,
497 entityref_get_nodeTypeString,
500 entityref_get_specified,
501 entityref_get_definition,
502 entityref_get_nodeTypedValue,
503 entityref_put_nodeTypedValue,
504 entityref_get_dataType,
505 entityref_put_dataType,
507 entityref_transformNode,
508 entityref_selectNodes,
509 entityref_selectSingleNode,
510 entityref_get_parsed,
511 entityref_get_namespaceURI,
512 entityref_get_prefix,
513 entityref_get_baseName,
514 entityref_transformNodeToObject,
517 IUnknown* create_doc_entity_ref( xmlNodePtr entity )
521 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
525 This->lpVtbl = &entityref_vtbl;
528 init_xmlnode(&This->node, entity, (IUnknown*)&This->lpVtbl, NULL);
530 return (IUnknown*) &This->lpVtbl;