2 * DOM CDATA node 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 _domcdata
42 const struct IXMLDOMCDATASectionVtbl *lpVtbl;
44 IUnknown *element_unk;
45 IXMLDOMCDATASection *element;
48 static inline domcdata *impl_from_IXMLDOMCDATASection( IXMLDOMCDATASection *iface )
50 return (domcdata *)((char*)iface - FIELD_OFFSET(domcdata, lpVtbl));
53 static HRESULT WINAPI domcdata_QueryInterface(
54 IXMLDOMCDATASection *iface,
58 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
59 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
61 if ( IsEqualGUID( riid, &IID_IXMLDOMCDATASection ) ||
62 IsEqualGUID( riid, &IID_IDispatch ) ||
63 IsEqualGUID( riid, &IID_IUnknown ) )
67 else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
68 IsEqualGUID( riid, &IID_IXMLDOMElement ) )
70 return IUnknown_QueryInterface(This->element_unk, riid, ppvObject);
74 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
78 IXMLDOMCDATASection_AddRef( iface );
83 static ULONG WINAPI domcdata_AddRef(
84 IXMLDOMCDATASection *iface )
86 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
87 return InterlockedIncrement( &This->ref );
90 static ULONG WINAPI domcdata_Release(
91 IXMLDOMCDATASection *iface )
93 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
96 ref = InterlockedDecrement( &This->ref );
99 IUnknown_Release( This->element_unk );
100 HeapFree( GetProcessHeap(), 0, This );
106 static HRESULT WINAPI domcdata_GetTypeInfoCount(
107 IXMLDOMCDATASection *iface,
110 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
112 TRACE("(%p)->(%p)\n", This, pctinfo);
119 static HRESULT WINAPI domcdata_GetTypeInfo(
120 IXMLDOMCDATASection *iface,
121 UINT iTInfo, LCID lcid,
122 ITypeInfo** ppTInfo )
124 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
127 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
129 hr = get_typeinfo(IXMLDOMCDATASection_tid, ppTInfo);
134 static HRESULT WINAPI domcdata_GetIDsOfNames(
135 IXMLDOMCDATASection *iface,
136 REFIID riid, LPOLESTR* rgszNames,
137 UINT cNames, LCID lcid, DISPID* rgDispId )
139 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
143 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
146 if(!rgszNames || cNames == 0 || !rgDispId)
149 hr = get_typeinfo(IXMLDOMCDATASection_tid, &typeinfo);
152 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
153 ITypeInfo_Release(typeinfo);
159 static HRESULT WINAPI domcdata_Invoke(
160 IXMLDOMCDATASection *iface,
161 DISPID dispIdMember, REFIID riid, LCID lcid,
162 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
163 EXCEPINFO* pExcepInfo, UINT* puArgErr )
165 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
169 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
170 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
172 hr = get_typeinfo(IXMLDOMCDATASection_tid, &typeinfo);
175 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
176 pVarResult, pExcepInfo, puArgErr);
177 ITypeInfo_Release(typeinfo);
183 static HRESULT WINAPI domcdata_get_nodeName(
184 IXMLDOMCDATASection *iface,
187 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
188 return IXMLDOMNode_get_nodeName( This->element, p );
191 static HRESULT WINAPI domcdata_get_nodeValue(
192 IXMLDOMCDATASection *iface,
195 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
196 return IXMLDOMNode_get_nodeValue( This->element, var1 );
199 static HRESULT WINAPI domcdata_put_nodeValue(
200 IXMLDOMCDATASection *iface,
203 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
204 return IXMLDOMNode_put_nodeValue( This->element, var1 );
207 static HRESULT WINAPI domcdata_get_nodeType(
208 IXMLDOMCDATASection *iface,
209 DOMNodeType* domNodeType )
211 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
212 return IXMLDOMNode_get_nodeType( This->element, domNodeType );
215 static HRESULT WINAPI domcdata_get_parentNode(
216 IXMLDOMCDATASection *iface,
217 IXMLDOMNode** parent )
219 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
220 return IXMLDOMNode_get_parentNode( This->element, parent );
223 static HRESULT WINAPI domcdata_get_childNodes(
224 IXMLDOMCDATASection *iface,
225 IXMLDOMNodeList** outList)
227 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
228 return IXMLDOMNode_get_childNodes( This->element, outList );
231 static HRESULT WINAPI domcdata_get_firstChild(
232 IXMLDOMCDATASection *iface,
233 IXMLDOMNode** domNode)
235 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
236 return IXMLDOMNode_get_firstChild( This->element, domNode );
239 static HRESULT WINAPI domcdata_get_lastChild(
240 IXMLDOMCDATASection *iface,
241 IXMLDOMNode** domNode)
243 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
244 return IXMLDOMNode_get_lastChild( This->element, domNode );
247 static HRESULT WINAPI domcdata_get_previousSibling(
248 IXMLDOMCDATASection *iface,
249 IXMLDOMNode** domNode)
251 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
252 return IXMLDOMNode_get_previousSibling( This->element, domNode );
255 static HRESULT WINAPI domcdata_get_nextSibling(
256 IXMLDOMCDATASection *iface,
257 IXMLDOMNode** domNode)
259 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
260 return IXMLDOMNode_get_nextSibling( This->element, domNode );
263 static HRESULT WINAPI domcdata_get_attributes(
264 IXMLDOMCDATASection *iface,
265 IXMLDOMNamedNodeMap** attributeMap)
267 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
268 return IXMLDOMNode_get_attributes( This->element, attributeMap );
271 static HRESULT WINAPI domcdata_insertBefore(
272 IXMLDOMCDATASection *iface,
273 IXMLDOMNode* newNode, VARIANT var1,
274 IXMLDOMNode** outOldNode)
276 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
277 return IXMLDOMNode_insertBefore( This->element, newNode, var1, outOldNode );
280 static HRESULT WINAPI domcdata_replaceChild(
281 IXMLDOMCDATASection *iface,
282 IXMLDOMNode* newNode,
283 IXMLDOMNode* oldNode,
284 IXMLDOMNode** outOldNode)
286 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
287 return IXMLDOMNode_replaceChild( This->element, newNode, oldNode, outOldNode );
290 static HRESULT WINAPI domcdata_removeChild(
291 IXMLDOMCDATASection *iface,
292 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
294 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
295 return IXMLDOMNode_removeChild( This->element, domNode, oldNode );
298 static HRESULT WINAPI domcdata_appendChild(
299 IXMLDOMCDATASection *iface,
300 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
302 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
303 return IXMLDOMNode_appendChild( This->element, newNode, outNewNode );
306 static HRESULT WINAPI domcdata_hasChildNodes(
307 IXMLDOMCDATASection *iface,
310 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
311 return IXMLDOMNode_hasChildNodes( This->element, pbool );
314 static HRESULT WINAPI domcdata_get_ownerDocument(
315 IXMLDOMCDATASection *iface,
316 IXMLDOMDocument** domDocument)
318 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
319 return IXMLDOMNode_get_ownerDocument( This->element, domDocument );
322 static HRESULT WINAPI domcdata_cloneNode(
323 IXMLDOMCDATASection *iface,
324 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
326 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
327 return IXMLDOMNode_cloneNode( This->element, pbool, outNode );
330 static HRESULT WINAPI domcdata_get_nodeTypeString(
331 IXMLDOMCDATASection *iface,
334 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
335 return IXMLDOMNode_get_nodeTypeString( This->element, p );
338 static HRESULT WINAPI domcdata_get_text(
339 IXMLDOMCDATASection *iface,
342 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
343 return IXMLDOMNode_get_text( This->element, p );
346 static HRESULT WINAPI domcdata_put_text(
347 IXMLDOMCDATASection *iface,
350 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
351 return IXMLDOMNode_put_text( This->element, p );
354 static HRESULT WINAPI domcdata_get_specified(
355 IXMLDOMCDATASection *iface,
358 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
359 return IXMLDOMNode_get_specified( This->element, pbool );
362 static HRESULT WINAPI domcdata_get_definition(
363 IXMLDOMCDATASection *iface,
364 IXMLDOMNode** domNode)
366 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
367 return IXMLDOMNode_get_definition( This->element, domNode );
370 static HRESULT WINAPI domcdata_get_nodeTypedValue(
371 IXMLDOMCDATASection *iface,
374 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
375 return IXMLDOMNode_get_nodeTypedValue( This->element, var1 );
378 static HRESULT WINAPI domcdata_put_nodeTypedValue(
379 IXMLDOMCDATASection *iface,
382 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
383 return IXMLDOMNode_put_nodeTypedValue( This->element, var1 );
386 static HRESULT WINAPI domcdata_get_dataType(
387 IXMLDOMCDATASection *iface,
390 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
391 return IXMLDOMNode_get_dataType( This->element, var1 );
394 static HRESULT WINAPI domcdata_put_dataType(
395 IXMLDOMCDATASection *iface,
398 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
399 return IXMLDOMNode_put_dataType( This->element, p );
402 static HRESULT WINAPI domcdata_get_xml(
403 IXMLDOMCDATASection *iface,
406 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
407 return IXMLDOMNode_get_xml( This->element, p );
410 static HRESULT WINAPI domcdata_transformNode(
411 IXMLDOMCDATASection *iface,
412 IXMLDOMNode* domNode, BSTR* p)
414 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
415 return IXMLDOMNode_transformNode( This->element, domNode, p );
418 static HRESULT WINAPI domcdata_selectNodes(
419 IXMLDOMCDATASection *iface,
420 BSTR p, IXMLDOMNodeList** outList)
422 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
423 return IXMLDOMNode_selectNodes( This->element, p, outList );
426 static HRESULT WINAPI domcdata_selectSingleNode(
427 IXMLDOMCDATASection *iface,
428 BSTR p, IXMLDOMNode** outNode)
430 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
431 return IXMLDOMNode_selectSingleNode( This->element, p, outNode );
434 static HRESULT WINAPI domcdata_get_parsed(
435 IXMLDOMCDATASection *iface,
438 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
439 return IXMLDOMNode_get_parsed( This->element, pbool );
442 static HRESULT WINAPI domcdata_get_namespaceURI(
443 IXMLDOMCDATASection *iface,
446 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
447 return IXMLDOMNode_get_namespaceURI( This->element, p );
450 static HRESULT WINAPI domcdata_get_prefix(
451 IXMLDOMCDATASection *iface,
454 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
455 return IXMLDOMNode_get_prefix( This->element, p );
458 static HRESULT WINAPI domcdata_get_baseName(
459 IXMLDOMCDATASection *iface,
462 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
463 return IXMLDOMNode_get_baseName( This->element, p );
466 static HRESULT WINAPI domcdata_transformNodeToObject(
467 IXMLDOMCDATASection *iface,
468 IXMLDOMNode* domNode, VARIANT var1)
470 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
471 return IXMLDOMNode_transformNodeToObject( This->element, domNode, var1 );
474 static HRESULT WINAPI domcdata_get_data(
475 IXMLDOMCDATASection *iface,
482 static HRESULT WINAPI domcdata_put_data(
483 IXMLDOMCDATASection *iface,
490 static HRESULT WINAPI domcdata_get_length(
491 IXMLDOMCDATASection *iface,
498 static HRESULT WINAPI domcdata_substringData(
499 IXMLDOMCDATASection *iface,
500 long offset, long count, BSTR *p)
506 static HRESULT WINAPI domcdata_appendData(
507 IXMLDOMCDATASection *iface,
514 static HRESULT WINAPI domcdata_insertData(
515 IXMLDOMCDATASection *iface,
522 static HRESULT WINAPI domcdata_deleteData(
523 IXMLDOMCDATASection *iface,
524 long offset, long count)
530 static HRESULT WINAPI domcdata_replaceData(
531 IXMLDOMCDATASection *iface,
532 long offset, long count, BSTR p)
538 static HRESULT WINAPI domcdata_splitText(
539 IXMLDOMCDATASection *iface,
540 long offset, IXMLDOMText **txtNode)
547 static const struct IXMLDOMCDATASectionVtbl domcdata_vtbl =
549 domcdata_QueryInterface,
552 domcdata_GetTypeInfoCount,
553 domcdata_GetTypeInfo,
554 domcdata_GetIDsOfNames,
556 domcdata_get_nodeName,
557 domcdata_get_nodeValue,
558 domcdata_put_nodeValue,
559 domcdata_get_nodeType,
560 domcdata_get_parentNode,
561 domcdata_get_childNodes,
562 domcdata_get_firstChild,
563 domcdata_get_lastChild,
564 domcdata_get_previousSibling,
565 domcdata_get_nextSibling,
566 domcdata_get_attributes,
567 domcdata_insertBefore,
568 domcdata_replaceChild,
569 domcdata_removeChild,
570 domcdata_appendChild,
571 domcdata_hasChildNodes,
572 domcdata_get_ownerDocument,
574 domcdata_get_nodeTypeString,
577 domcdata_get_specified,
578 domcdata_get_definition,
579 domcdata_get_nodeTypedValue,
580 domcdata_put_nodeTypedValue,
581 domcdata_get_dataType,
582 domcdata_put_dataType,
584 domcdata_transformNode,
585 domcdata_selectNodes,
586 domcdata_selectSingleNode,
588 domcdata_get_namespaceURI,
590 domcdata_get_baseName,
591 domcdata_transformNodeToObject,
595 domcdata_substringData,
599 domcdata_replaceData,
603 IUnknown* create_cdata( xmlNodePtr text )
608 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
612 This->lpVtbl = &domcdata_vtbl;
615 This->element_unk = create_element( text, (IUnknown*)&This->lpVtbl );
616 if(!This->element_unk)
618 HeapFree(GetProcessHeap(), 0, This);
622 hr = IUnknown_QueryInterface(This->element_unk, &IID_IXMLDOMNode, (LPVOID*)&This->element);
625 IUnknown_Release(This->element_unk);
626 HeapFree( GetProcessHeap(), 0, This );
629 /* The ref on This->element is actually looped back into this object, so release it */
630 IXMLDOMNode_Release(This->element);
632 return (IUnknown*) &This->lpVtbl;