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 TRACE("(%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 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,
374 entityref *This = impl_from_IXMLDOMEntityReference( iface );
375 static const WCHAR entityreferenceW[] = {'e','n','t','i','t','y','r','e','f','e','r','e','n','c','e',0};
377 TRACE("(%p)->(%p)\n", This, p);
379 return return_bstr(entityreferenceW, p);
382 static HRESULT WINAPI entityref_get_text(
383 IXMLDOMEntityReference *iface,
386 entityref *This = impl_from_IXMLDOMEntityReference( iface );
387 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
390 static HRESULT WINAPI entityref_put_text(
391 IXMLDOMEntityReference *iface,
394 entityref *This = impl_from_IXMLDOMEntityReference( iface );
395 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
396 return node_put_text( &This->node, p );
399 static HRESULT WINAPI entityref_get_specified(
400 IXMLDOMEntityReference *iface,
401 VARIANT_BOOL* isSpecified)
403 entityref *This = impl_from_IXMLDOMEntityReference( iface );
404 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
405 *isSpecified = VARIANT_TRUE;
409 static HRESULT WINAPI entityref_get_definition(
410 IXMLDOMEntityReference *iface,
411 IXMLDOMNode** definitionNode)
413 entityref *This = impl_from_IXMLDOMEntityReference( iface );
414 FIXME("(%p)->(%p)\n", This, definitionNode);
418 static HRESULT WINAPI entityref_get_nodeTypedValue(
419 IXMLDOMEntityReference *iface,
422 entityref *This = impl_from_IXMLDOMEntityReference( iface );
423 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
426 static HRESULT WINAPI entityref_put_nodeTypedValue(
427 IXMLDOMEntityReference *iface,
430 entityref *This = impl_from_IXMLDOMEntityReference( iface );
431 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
434 static HRESULT WINAPI entityref_get_dataType(
435 IXMLDOMEntityReference *iface,
438 entityref *This = impl_from_IXMLDOMEntityReference( iface );
439 FIXME("(%p)->(%p): should return a valid value\n", This, typename);
440 return return_null_var( typename );
443 static HRESULT WINAPI entityref_put_dataType(
444 IXMLDOMEntityReference *iface,
447 entityref *This = impl_from_IXMLDOMEntityReference( iface );
448 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
451 static HRESULT WINAPI entityref_get_xml(
452 IXMLDOMEntityReference *iface,
455 entityref *This = impl_from_IXMLDOMEntityReference( iface );
457 TRACE("(%p)->(%p)\n", This, p);
459 return node_get_xml(&This->node, FALSE, FALSE, p);
462 static HRESULT WINAPI entityref_transformNode(
463 IXMLDOMEntityReference *iface,
464 IXMLDOMNode* domNode, BSTR* p)
466 entityref *This = impl_from_IXMLDOMEntityReference( iface );
467 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
470 static HRESULT WINAPI entityref_selectNodes(
471 IXMLDOMEntityReference *iface,
472 BSTR p, IXMLDOMNodeList** outList)
474 entityref *This = impl_from_IXMLDOMEntityReference( iface );
475 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
478 static HRESULT WINAPI entityref_selectSingleNode(
479 IXMLDOMEntityReference *iface,
480 BSTR p, IXMLDOMNode** outNode)
482 entityref *This = impl_from_IXMLDOMEntityReference( iface );
483 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
486 static HRESULT WINAPI entityref_get_parsed(
487 IXMLDOMEntityReference *iface,
488 VARIANT_BOOL* isParsed)
490 entityref *This = impl_from_IXMLDOMEntityReference( iface );
491 FIXME("(%p)->(%p) stub!\n", This, isParsed);
492 *isParsed = VARIANT_TRUE;
496 static HRESULT WINAPI entityref_get_namespaceURI(
497 IXMLDOMEntityReference *iface,
500 entityref *This = impl_from_IXMLDOMEntityReference( iface );
501 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
504 static HRESULT WINAPI entityref_get_prefix(
505 IXMLDOMEntityReference *iface,
508 entityref *This = impl_from_IXMLDOMEntityReference( iface );
509 TRACE("(%p)->(%p)\n", This, prefix);
510 return node_get_prefix( &This->node, prefix );
513 static HRESULT WINAPI entityref_get_baseName(
514 IXMLDOMEntityReference *iface,
517 entityref *This = impl_from_IXMLDOMEntityReference( iface );
518 FIXME("(%p)->(%p): needs test\n", This, name);
519 return return_null_bstr( name );
522 static HRESULT WINAPI entityref_transformNodeToObject(
523 IXMLDOMEntityReference *iface,
524 IXMLDOMNode* domNode, VARIANT var1)
526 entityref *This = impl_from_IXMLDOMEntityReference( iface );
527 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
530 static const struct IXMLDOMEntityReferenceVtbl entityref_vtbl =
532 entityref_QueryInterface,
535 entityref_GetTypeInfoCount,
536 entityref_GetTypeInfo,
537 entityref_GetIDsOfNames,
539 entityref_get_nodeName,
540 entityref_get_nodeValue,
541 entityref_put_nodeValue,
542 entityref_get_nodeType,
543 entityref_get_parentNode,
544 entityref_get_childNodes,
545 entityref_get_firstChild,
546 entityref_get_lastChild,
547 entityref_get_previousSibling,
548 entityref_get_nextSibling,
549 entityref_get_attributes,
550 entityref_insertBefore,
551 entityref_replaceChild,
552 entityref_removeChild,
553 entityref_appendChild,
554 entityref_hasChildNodes,
555 entityref_get_ownerDocument,
557 entityref_get_nodeTypeString,
560 entityref_get_specified,
561 entityref_get_definition,
562 entityref_get_nodeTypedValue,
563 entityref_put_nodeTypedValue,
564 entityref_get_dataType,
565 entityref_put_dataType,
567 entityref_transformNode,
568 entityref_selectNodes,
569 entityref_selectSingleNode,
570 entityref_get_parsed,
571 entityref_get_namespaceURI,
572 entityref_get_prefix,
573 entityref_get_baseName,
574 entityref_transformNodeToObject,
577 IUnknown* create_doc_entity_ref( xmlNodePtr entity )
581 This = heap_alloc( sizeof *This );
585 This->lpVtbl = &entityref_vtbl;
588 init_xmlnode(&This->node, entity, (IXMLDOMNode*)&This->lpVtbl, NULL);
590 return (IUnknown*) &This->lpVtbl;