msxml3: Get rid of ::get_prefix() forward.
[wine/multimedia.git] / dlls / msxml3 / entityref.c
blobfae2a2c1802433f47b8dc3ad64f0500749ed6691
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 "msxml6.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 xmlnode node;
43 const struct IXMLDOMEntityReferenceVtbl *lpVtbl;
44 LONG ref;
45 } entityref;
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,
54 REFIID riid,
55 void** ppvObject )
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 ) )
65 *ppvObject = iface;
67 else if(node_query_interface(&This->node, riid, ppvObject))
69 return *ppvObject ? S_OK : E_NOINTERFACE;
71 else
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
74 return E_NOINTERFACE;
77 IUnknown_AddRef((IUnknown*)*ppvObject);
78 return S_OK;
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 );
92 ULONG ref;
94 ref = InterlockedDecrement( &This->ref );
95 if ( ref == 0 )
97 destroy_xmlnode(&This->node);
98 heap_free( This );
101 return ref;
104 static HRESULT WINAPI entityref_GetTypeInfoCount(
105 IXMLDOMEntityReference *iface,
106 UINT* pctinfo )
108 entityref *This = impl_from_IXMLDOMEntityReference( iface );
109 TRACE("(%p)->(%p)\n", This, pctinfo);
111 *pctinfo = 1;
113 return S_OK;
116 static HRESULT WINAPI entityref_GetTypeInfo(
117 IXMLDOMEntityReference *iface,
118 UINT iTInfo, LCID lcid,
119 ITypeInfo** ppTInfo )
121 entityref *This = impl_from_IXMLDOMEntityReference( iface );
122 HRESULT hr;
124 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
126 hr = get_typeinfo(IXMLDOMEntityReference_tid, ppTInfo);
128 return hr;
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 );
137 ITypeInfo *typeinfo;
138 HRESULT hr;
140 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
141 lcid, rgDispId);
143 if(!rgszNames || cNames == 0 || !rgDispId)
144 return E_INVALIDARG;
146 hr = get_typeinfo(IXMLDOMEntityReference_tid, &typeinfo);
147 if(SUCCEEDED(hr))
149 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
150 ITypeInfo_Release(typeinfo);
153 return hr;
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 );
163 ITypeInfo *typeinfo;
164 HRESULT hr;
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);
170 if(SUCCEEDED(hr))
172 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
173 pVarResult, pExcepInfo, puArgErr);
174 ITypeInfo_Release(typeinfo);
177 return hr;
180 static HRESULT WINAPI entityref_get_nodeName(
181 IXMLDOMEntityReference *iface,
182 BSTR* p )
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,
193 VARIANT* value)
195 entityref *This = impl_from_IXMLDOMEntityReference( iface );
197 FIXME("(%p)->(%p)\n", This, value);
199 if(!value)
200 return E_INVALIDARG;
202 V_VT(value) = VT_NULL;
203 return S_FALSE;
206 static HRESULT WINAPI entityref_put_nodeValue(
207 IXMLDOMEntityReference *iface,
208 VARIANT value)
210 entityref *This = impl_from_IXMLDOMEntityReference( iface );
211 FIXME("(%p)->(v%d)\n", This, V_VT(&value));
212 return E_FAIL;
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;
224 return S_OK;
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,
347 VARIANT_BOOL* pbool)
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,
372 BSTR* p)
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,
380 BSTR* p)
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,
388 BSTR p)
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;
402 return S_OK;
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);
411 return E_NOTIMPL;
414 static HRESULT WINAPI entityref_get_nodeTypedValue(
415 IXMLDOMEntityReference *iface,
416 VARIANT* var1)
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,
424 VARIANT var1)
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,
432 VARIANT* typename)
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,
441 BSTR p)
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,
449 BSTR* p)
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;
489 return S_OK;
492 static HRESULT WINAPI entityref_get_namespaceURI(
493 IXMLDOMEntityReference *iface,
494 BSTR* p)
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,
502 BSTR* prefix)
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,
511 BSTR* p)
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,
528 entityref_AddRef,
529 entityref_Release,
530 entityref_GetTypeInfoCount,
531 entityref_GetTypeInfo,
532 entityref_GetIDsOfNames,
533 entityref_Invoke,
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,
551 entityref_cloneNode,
552 entityref_get_nodeTypeString,
553 entityref_get_text,
554 entityref_put_text,
555 entityref_get_specified,
556 entityref_get_definition,
557 entityref_get_nodeTypedValue,
558 entityref_put_nodeTypedValue,
559 entityref_get_dataType,
560 entityref_put_dataType,
561 entityref_get_xml,
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 )
574 entityref *This;
576 This = heap_alloc( sizeof *This );
577 if ( !This )
578 return NULL;
580 This->lpVtbl = &entityref_vtbl;
581 This->ref = 1;
583 init_xmlnode(&This->node, entity, (IXMLDOMNode*)&This->lpVtbl, NULL);
585 return (IUnknown*) &This->lpVtbl;
588 #endif