2 * DOM comment node implementation
4 * Copyright 2006 Huw Davies
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 _domcomment
42 const struct IXMLDOMCommentVtbl *lpVtbl;
48 static inline domcomment *impl_from_IXMLDOMComment( IXMLDOMComment *iface )
50 return (domcomment *)((char*)iface - FIELD_OFFSET(domcomment, lpVtbl));
53 static inline xmlNodePtr get_comment( domcomment *This )
55 return xmlNodePtr_from_domnode( This->node, XML_COMMENT_NODE );
58 static HRESULT WINAPI domcomment_QueryInterface(
59 IXMLDOMComment *iface,
63 domcomment *This = impl_from_IXMLDOMComment( iface );
64 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
66 if ( IsEqualGUID( riid, &IID_IXMLDOMComment ) ||
67 IsEqualGUID( riid, &IID_IUnknown ) )
71 else if ( IsEqualGUID( riid, &IID_IDispatch ) ||
72 IsEqualGUID( riid, &IID_IXMLDOMNode ) )
74 return IUnknown_QueryInterface(This->node_unk, riid, ppvObject);
78 FIXME("Unsupported inteferace %s\n", debugstr_guid(riid));
82 IXMLDOMComment_AddRef( iface );
87 static ULONG WINAPI domcomment_AddRef(
88 IXMLDOMComment *iface )
90 domcomment *This = impl_from_IXMLDOMComment( iface );
91 return InterlockedIncrement( &This->ref );
94 static ULONG WINAPI domcomment_Release(
95 IXMLDOMComment *iface )
97 domcomment *This = impl_from_IXMLDOMComment( iface );
100 ref = InterlockedDecrement( &This->ref );
103 IUnknown_Release( This->node_unk );
104 HeapFree( GetProcessHeap(), 0, This );
110 static HRESULT WINAPI domcomment_GetTypeInfoCount(
111 IXMLDOMComment *iface,
118 static HRESULT WINAPI domcomment_GetTypeInfo(
119 IXMLDOMComment *iface,
120 UINT iTInfo, LCID lcid,
121 ITypeInfo** ppTInfo )
127 static HRESULT WINAPI domcomment_GetIDsOfNames(
128 IXMLDOMComment *iface,
129 REFIID riid, LPOLESTR* rgszNames,
130 UINT cNames, LCID lcid, DISPID* rgDispId )
136 static HRESULT WINAPI domcomment_Invoke(
137 IXMLDOMComment *iface,
138 DISPID dispIdMember, REFIID riid, LCID lcid,
139 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
140 EXCEPINFO* pExcepInfo, UINT* puArgErr )
146 static HRESULT WINAPI domcomment_get_nodeName(
147 IXMLDOMComment *iface,
150 domcomment *This = impl_from_IXMLDOMComment( iface );
151 return IXMLDOMNode_get_nodeName( This->node, p );
154 static HRESULT WINAPI domcomment_get_nodeValue(
155 IXMLDOMComment *iface,
158 domcomment *This = impl_from_IXMLDOMComment( iface );
159 return IXMLDOMNode_get_nodeValue( This->node, var1 );
162 static HRESULT WINAPI domcomment_put_nodeValue(
163 IXMLDOMComment *iface,
166 domcomment *This = impl_from_IXMLDOMComment( iface );
167 return IXMLDOMNode_put_nodeValue( This->node, var1 );
170 static HRESULT WINAPI domcomment_get_nodeType(
171 IXMLDOMComment *iface,
172 DOMNodeType* domNodeType )
174 domcomment *This = impl_from_IXMLDOMComment( iface );
175 return IXMLDOMNode_get_nodeType( This->node, domNodeType );
178 static HRESULT WINAPI domcomment_get_parentNode(
179 IXMLDOMComment *iface,
180 IXMLDOMNode** parent )
182 domcomment *This = impl_from_IXMLDOMComment( iface );
183 return IXMLDOMNode_get_parentNode( This->node, parent );
186 static HRESULT WINAPI domcomment_get_childNodes(
187 IXMLDOMComment *iface,
188 IXMLDOMNodeList** outList)
190 domcomment *This = impl_from_IXMLDOMComment( iface );
191 return IXMLDOMNode_get_childNodes( This->node, outList );
194 static HRESULT WINAPI domcomment_get_firstChild(
195 IXMLDOMComment *iface,
196 IXMLDOMNode** domNode)
198 domcomment *This = impl_from_IXMLDOMComment( iface );
199 return IXMLDOMNode_get_firstChild( This->node, domNode );
202 static HRESULT WINAPI domcomment_get_lastChild(
203 IXMLDOMComment *iface,
204 IXMLDOMNode** domNode)
206 domcomment *This = impl_from_IXMLDOMComment( iface );
207 return IXMLDOMNode_get_lastChild( This->node, domNode );
210 static HRESULT WINAPI domcomment_get_previousSibling(
211 IXMLDOMComment *iface,
212 IXMLDOMNode** domNode)
214 domcomment *This = impl_from_IXMLDOMComment( iface );
215 return IXMLDOMNode_get_previousSibling( This->node, domNode );
218 static HRESULT WINAPI domcomment_get_nextSibling(
219 IXMLDOMComment *iface,
220 IXMLDOMNode** domNode)
222 domcomment *This = impl_from_IXMLDOMComment( iface );
223 return IXMLDOMNode_get_nextSibling( This->node, domNode );
226 static HRESULT WINAPI domcomment_get_attributes(
227 IXMLDOMComment *iface,
228 IXMLDOMNamedNodeMap** attributeMap)
230 domcomment *This = impl_from_IXMLDOMComment( iface );
231 return IXMLDOMNode_get_attributes( This->node, attributeMap );
234 static HRESULT WINAPI domcomment_insertBefore(
235 IXMLDOMComment *iface,
236 IXMLDOMNode* newNode, VARIANT var1,
237 IXMLDOMNode** outOldNode)
239 domcomment *This = impl_from_IXMLDOMComment( iface );
240 return IXMLDOMNode_insertBefore( This->node, newNode, var1, outOldNode );
243 static HRESULT WINAPI domcomment_replaceChild(
244 IXMLDOMComment *iface,
245 IXMLDOMNode* newNode,
246 IXMLDOMNode* oldNode,
247 IXMLDOMNode** outOldNode)
249 domcomment *This = impl_from_IXMLDOMComment( iface );
250 return IXMLDOMNode_replaceChild( This->node, newNode, oldNode, outOldNode );
253 static HRESULT WINAPI domcomment_removeChild(
254 IXMLDOMComment *iface,
255 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
257 domcomment *This = impl_from_IXMLDOMComment( iface );
258 return IXMLDOMNode_removeChild( This->node, domNode, oldNode );
261 static HRESULT WINAPI domcomment_appendChild(
262 IXMLDOMComment *iface,
263 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
265 domcomment *This = impl_from_IXMLDOMComment( iface );
266 return IXMLDOMNode_appendChild( This->node, newNode, outNewNode );
269 static HRESULT WINAPI domcomment_hasChildNodes(
270 IXMLDOMComment *iface,
273 domcomment *This = impl_from_IXMLDOMComment( iface );
274 return IXMLDOMNode_hasChildNodes( This->node, pbool );
277 static HRESULT WINAPI domcomment_get_ownerDocument(
278 IXMLDOMComment *iface,
279 IXMLDOMDocument** domDocument)
281 domcomment *This = impl_from_IXMLDOMComment( iface );
282 return IXMLDOMNode_get_ownerDocument( This->node, domDocument );
285 static HRESULT WINAPI domcomment_cloneNode(
286 IXMLDOMComment *iface,
287 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
289 domcomment *This = impl_from_IXMLDOMComment( iface );
290 return IXMLDOMNode_cloneNode( This->node, pbool, outNode );
293 static HRESULT WINAPI domcomment_get_nodeTypeString(
294 IXMLDOMComment *iface,
297 domcomment *This = impl_from_IXMLDOMComment( iface );
298 return IXMLDOMNode_get_nodeTypeString( This->node, p );
301 static HRESULT WINAPI domcomment_get_text(
302 IXMLDOMComment *iface,
305 domcomment *This = impl_from_IXMLDOMComment( iface );
306 return IXMLDOMNode_get_text( This->node, p );
309 static HRESULT WINAPI domcomment_put_text(
310 IXMLDOMComment *iface,
313 domcomment *This = impl_from_IXMLDOMComment( iface );
314 return IXMLDOMNode_put_text( This->node, p );
317 static HRESULT WINAPI domcomment_get_specified(
318 IXMLDOMComment *iface,
321 domcomment *This = impl_from_IXMLDOMComment( iface );
322 return IXMLDOMNode_get_specified( This->node, pbool );
325 static HRESULT WINAPI domcomment_get_definition(
326 IXMLDOMComment *iface,
327 IXMLDOMNode** domNode)
329 domcomment *This = impl_from_IXMLDOMComment( iface );
330 return IXMLDOMNode_get_definition( This->node, domNode );
333 static HRESULT WINAPI domcomment_get_nodeTypedValue(
334 IXMLDOMComment *iface,
337 domcomment *This = impl_from_IXMLDOMComment( iface );
338 return IXMLDOMNode_get_nodeTypedValue( This->node, var1 );
341 static HRESULT WINAPI domcomment_put_nodeTypedValue(
342 IXMLDOMComment *iface,
345 domcomment *This = impl_from_IXMLDOMComment( iface );
346 return IXMLDOMNode_put_nodeTypedValue( This->node, var1 );
349 static HRESULT WINAPI domcomment_get_dataType(
350 IXMLDOMComment *iface,
353 domcomment *This = impl_from_IXMLDOMComment( iface );
354 return IXMLDOMNode_get_dataType( This->node, var1 );
357 static HRESULT WINAPI domcomment_put_dataType(
358 IXMLDOMComment *iface,
361 domcomment *This = impl_from_IXMLDOMComment( iface );
362 return IXMLDOMNode_put_dataType( This->node, p );
365 static HRESULT WINAPI domcomment_get_xml(
366 IXMLDOMComment *iface,
369 domcomment *This = impl_from_IXMLDOMComment( iface );
370 return IXMLDOMNode_get_xml( This->node, p );
373 static HRESULT WINAPI domcomment_transformNode(
374 IXMLDOMComment *iface,
375 IXMLDOMNode* domNode, BSTR* p)
377 domcomment *This = impl_from_IXMLDOMComment( iface );
378 return IXMLDOMNode_transformNode( This->node, domNode, p );
381 static HRESULT WINAPI domcomment_selectNodes(
382 IXMLDOMComment *iface,
383 BSTR p, IXMLDOMNodeList** outList)
385 domcomment *This = impl_from_IXMLDOMComment( iface );
386 return IXMLDOMNode_selectNodes( This->node, p, outList );
389 static HRESULT WINAPI domcomment_selectSingleNode(
390 IXMLDOMComment *iface,
391 BSTR p, IXMLDOMNode** outNode)
393 domcomment *This = impl_from_IXMLDOMComment( iface );
394 return IXMLDOMNode_selectSingleNode( This->node, p, outNode );
397 static HRESULT WINAPI domcomment_get_parsed(
398 IXMLDOMComment *iface,
401 domcomment *This = impl_from_IXMLDOMComment( iface );
402 return IXMLDOMNode_get_parsed( This->node, pbool );
405 static HRESULT WINAPI domcomment_get_namespaceURI(
406 IXMLDOMComment *iface,
409 domcomment *This = impl_from_IXMLDOMComment( iface );
410 return IXMLDOMNode_get_namespaceURI( This->node, p );
413 static HRESULT WINAPI domcomment_get_prefix(
414 IXMLDOMComment *iface,
417 domcomment *This = impl_from_IXMLDOMComment( iface );
418 return IXMLDOMNode_get_prefix( This->node, p );
421 static HRESULT WINAPI domcomment_get_baseName(
422 IXMLDOMComment *iface,
425 domcomment *This = impl_from_IXMLDOMComment( iface );
426 return IXMLDOMNode_get_baseName( This->node, p );
429 static HRESULT WINAPI domcomment_transformNodeToObject(
430 IXMLDOMComment *iface,
431 IXMLDOMNode* domNode, VARIANT var1)
433 domcomment *This = impl_from_IXMLDOMComment( iface );
434 return IXMLDOMNode_transformNodeToObject( This->node, domNode, var1 );
437 static HRESULT WINAPI domcomment_get_data(
438 IXMLDOMComment *iface,
445 static HRESULT WINAPI domcomment_put_data(
446 IXMLDOMComment *iface,
453 static HRESULT WINAPI domcomment_get_length(
454 IXMLDOMComment *iface,
461 static HRESULT WINAPI domcomment_substringData(
462 IXMLDOMComment *iface,
463 long offset, long count, BSTR *p)
469 static HRESULT WINAPI domcomment_appendData(
470 IXMLDOMComment *iface,
477 static HRESULT WINAPI domcomment_insertData(
478 IXMLDOMComment *iface,
485 static HRESULT WINAPI domcomment_deleteData(
486 IXMLDOMComment *iface,
487 long offset, long count)
493 static HRESULT WINAPI domcomment_replaceData(
494 IXMLDOMComment *iface,
495 long offset, long count, BSTR p)
501 static const struct IXMLDOMCommentVtbl domcomment_vtbl =
503 domcomment_QueryInterface,
506 domcomment_GetTypeInfoCount,
507 domcomment_GetTypeInfo,
508 domcomment_GetIDsOfNames,
510 domcomment_get_nodeName,
511 domcomment_get_nodeValue,
512 domcomment_put_nodeValue,
513 domcomment_get_nodeType,
514 domcomment_get_parentNode,
515 domcomment_get_childNodes,
516 domcomment_get_firstChild,
517 domcomment_get_lastChild,
518 domcomment_get_previousSibling,
519 domcomment_get_nextSibling,
520 domcomment_get_attributes,
521 domcomment_insertBefore,
522 domcomment_replaceChild,
523 domcomment_removeChild,
524 domcomment_appendChild,
525 domcomment_hasChildNodes,
526 domcomment_get_ownerDocument,
527 domcomment_cloneNode,
528 domcomment_get_nodeTypeString,
531 domcomment_get_specified,
532 domcomment_get_definition,
533 domcomment_get_nodeTypedValue,
534 domcomment_put_nodeTypedValue,
535 domcomment_get_dataType,
536 domcomment_put_dataType,
538 domcomment_transformNode,
539 domcomment_selectNodes,
540 domcomment_selectSingleNode,
541 domcomment_get_parsed,
542 domcomment_get_namespaceURI,
543 domcomment_get_prefix,
544 domcomment_get_baseName,
545 domcomment_transformNodeToObject,
548 domcomment_get_length,
549 domcomment_substringData,
550 domcomment_appendData,
551 domcomment_insertData,
552 domcomment_deleteData,
553 domcomment_replaceData
556 IUnknown* create_comment( xmlNodePtr comment )
561 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
565 This->lpVtbl = &domcomment_vtbl;
568 This->node_unk = create_basic_node( comment, (IUnknown*)&This->lpVtbl );
571 HeapFree(GetProcessHeap(), 0, This);
575 hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
578 IUnknown_Release(This->node_unk);
579 HeapFree( GetProcessHeap(), 0, This );
582 /* The ref on This->node is actually looped back into this object, so release it */
583 IXMLDOMNode_Release(This->node);
585 return (IUnknown*) &This->lpVtbl;