dbghelp: Implement SymEnumerateSymbols64.
[wine/hacks.git] / dlls / msxml3 / entityref.c
bloba72b11022e7f6eed5c90c3921af7006f731a101c
1 /*
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
21 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "msxml2.h"
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
38 #ifdef HAVE_LIBXML2
40 typedef struct _entityref
42 const struct IXMLDOMEntityReferenceVtbl *lpVtbl;
43 LONG ref;
44 IUnknown *node_unk;
45 IXMLDOMNode *node;
46 } entityref;
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,
55 REFIID riid,
56 void** ppvObject )
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 ) )
65 *ppvObject = iface;
67 else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) )
69 return IUnknown_QueryInterface(This->node_unk, riid, ppvObject);
71 else
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
74 return E_NOINTERFACE;
77 IXMLDOMEntityReference_AddRef( iface );
79 return S_OK;
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 );
93 ULONG ref;
95 ref = InterlockedDecrement( &This->ref );
96 if ( ref == 0 )
98 IUnknown_Release( This->node_unk );
99 HeapFree( GetProcessHeap(), 0, This );
102 return ref;
105 static HRESULT WINAPI entityref_GetTypeInfoCount(
106 IXMLDOMEntityReference *iface,
107 UINT* pctinfo )
109 entityref *This = impl_from_IXMLDOMEntityReference( iface );
110 TRACE("(%p)->(%p)\n", This, pctinfo);
112 *pctinfo = 1;
114 return S_OK;
117 static HRESULT WINAPI entityref_GetTypeInfo(
118 IXMLDOMEntityReference *iface,
119 UINT iTInfo, LCID lcid,
120 ITypeInfo** ppTInfo )
122 entityref *This = impl_from_IXMLDOMEntityReference( iface );
123 HRESULT hr;
125 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
127 hr = get_typeinfo(IXMLDOMEntityReference_tid, ppTInfo);
129 return hr;
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 );
138 ITypeInfo *typeinfo;
139 HRESULT hr;
141 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
142 lcid, rgDispId);
144 if(!rgszNames || cNames == 0 || !rgDispId)
145 return E_INVALIDARG;
147 hr = get_typeinfo(IXMLDOMEntityReference_tid, &typeinfo);
148 if(SUCCEEDED(hr))
150 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
151 ITypeInfo_Release(typeinfo);
154 return hr;
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 );
164 ITypeInfo *typeinfo;
165 HRESULT hr;
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);
171 if(SUCCEEDED(hr))
173 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
174 pVarResult, pExcepInfo, puArgErr);
175 ITypeInfo_Release(typeinfo);
178 return hr;
181 static HRESULT WINAPI entityref_get_nodeName(
182 IXMLDOMEntityReference *iface,
183 BSTR* p )
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,
191 VARIANT* var1 )
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,
199 VARIANT var1 )
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,
306 VARIANT_BOOL* pbool)
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,
330 BSTR* p)
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,
338 BSTR* p)
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,
346 BSTR p)
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,
354 VARIANT_BOOL* pbool)
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,
370 VARIANT* var1)
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,
378 VARIANT var1)
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,
386 VARIANT* var1)
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,
394 BSTR p)
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,
402 BSTR* p)
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,
434 VARIANT_BOOL* pbool)
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,
442 BSTR* p)
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,
450 BSTR* p)
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,
458 BSTR* p)
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,
475 entityref_AddRef,
476 entityref_Release,
477 entityref_GetTypeInfoCount,
478 entityref_GetTypeInfo,
479 entityref_GetIDsOfNames,
480 entityref_Invoke,
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,
498 entityref_cloneNode,
499 entityref_get_nodeTypeString,
500 entityref_get_text,
501 entityref_put_text,
502 entityref_get_specified,
503 entityref_get_definition,
504 entityref_get_nodeTypedValue,
505 entityref_put_nodeTypedValue,
506 entityref_get_dataType,
507 entityref_put_dataType,
508 entityref_get_xml,
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 )
521 entityref *This;
522 HRESULT hr;
524 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
525 if ( !This )
526 return NULL;
528 This->lpVtbl = &entityref_vtbl;
529 This->ref = 1;
531 This->node_unk = create_basic_node( entity, (IUnknown*)&This->lpVtbl );
532 if(!This->node_unk)
534 HeapFree(GetProcessHeap(), 0, This);
535 return NULL;
538 hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
539 if(FAILED(hr))
541 IUnknown_Release(This->node_unk);
542 HeapFree( GetProcessHeap(), 0, This );
543 return NULL;
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;
551 #endif