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,
114 static HRESULT WINAPI domcdata_GetTypeInfo(
115 IXMLDOMCDATASection *iface,
116 UINT iTInfo, LCID lcid,
117 ITypeInfo** ppTInfo )
123 static HRESULT WINAPI domcdata_GetIDsOfNames(
124 IXMLDOMCDATASection *iface,
125 REFIID riid, LPOLESTR* rgszNames,
126 UINT cNames, LCID lcid, DISPID* rgDispId )
132 static HRESULT WINAPI domcdata_Invoke(
133 IXMLDOMCDATASection *iface,
134 DISPID dispIdMember, REFIID riid, LCID lcid,
135 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
136 EXCEPINFO* pExcepInfo, UINT* puArgErr )
142 static HRESULT WINAPI domcdata_get_nodeName(
143 IXMLDOMCDATASection *iface,
146 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
147 return IXMLDOMNode_get_nodeName( This->element, p );
150 static HRESULT WINAPI domcdata_get_nodeValue(
151 IXMLDOMCDATASection *iface,
154 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
155 return IXMLDOMNode_get_nodeValue( This->element, var1 );
158 static HRESULT WINAPI domcdata_put_nodeValue(
159 IXMLDOMCDATASection *iface,
162 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
163 return IXMLDOMNode_put_nodeValue( This->element, var1 );
166 static HRESULT WINAPI domcdata_get_nodeType(
167 IXMLDOMCDATASection *iface,
168 DOMNodeType* domNodeType )
170 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
171 return IXMLDOMNode_get_nodeType( This->element, domNodeType );
174 static HRESULT WINAPI domcdata_get_parentNode(
175 IXMLDOMCDATASection *iface,
176 IXMLDOMNode** parent )
178 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
179 return IXMLDOMNode_get_parentNode( This->element, parent );
182 static HRESULT WINAPI domcdata_get_childNodes(
183 IXMLDOMCDATASection *iface,
184 IXMLDOMNodeList** outList)
186 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
187 return IXMLDOMNode_get_childNodes( This->element, outList );
190 static HRESULT WINAPI domcdata_get_firstChild(
191 IXMLDOMCDATASection *iface,
192 IXMLDOMNode** domNode)
194 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
195 return IXMLDOMNode_get_firstChild( This->element, domNode );
198 static HRESULT WINAPI domcdata_get_lastChild(
199 IXMLDOMCDATASection *iface,
200 IXMLDOMNode** domNode)
202 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
203 return IXMLDOMNode_get_lastChild( This->element, domNode );
206 static HRESULT WINAPI domcdata_get_previousSibling(
207 IXMLDOMCDATASection *iface,
208 IXMLDOMNode** domNode)
210 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
211 return IXMLDOMNode_get_previousSibling( This->element, domNode );
214 static HRESULT WINAPI domcdata_get_nextSibling(
215 IXMLDOMCDATASection *iface,
216 IXMLDOMNode** domNode)
218 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
219 return IXMLDOMNode_get_nextSibling( This->element, domNode );
222 static HRESULT WINAPI domcdata_get_attributes(
223 IXMLDOMCDATASection *iface,
224 IXMLDOMNamedNodeMap** attributeMap)
226 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
227 return IXMLDOMNode_get_attributes( This->element, attributeMap );
230 static HRESULT WINAPI domcdata_insertBefore(
231 IXMLDOMCDATASection *iface,
232 IXMLDOMNode* newNode, VARIANT var1,
233 IXMLDOMNode** outOldNode)
235 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
236 return IXMLDOMNode_insertBefore( This->element, newNode, var1, outOldNode );
239 static HRESULT WINAPI domcdata_replaceChild(
240 IXMLDOMCDATASection *iface,
241 IXMLDOMNode* newNode,
242 IXMLDOMNode* oldNode,
243 IXMLDOMNode** outOldNode)
245 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
246 return IXMLDOMNode_replaceChild( This->element, newNode, oldNode, outOldNode );
249 static HRESULT WINAPI domcdata_removeChild(
250 IXMLDOMCDATASection *iface,
251 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
253 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
254 return IXMLDOMNode_removeChild( This->element, domNode, oldNode );
257 static HRESULT WINAPI domcdata_appendChild(
258 IXMLDOMCDATASection *iface,
259 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
261 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
262 return IXMLDOMNode_appendChild( This->element, newNode, outNewNode );
265 static HRESULT WINAPI domcdata_hasChildNodes(
266 IXMLDOMCDATASection *iface,
269 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
270 return IXMLDOMNode_hasChildNodes( This->element, pbool );
273 static HRESULT WINAPI domcdata_get_ownerDocument(
274 IXMLDOMCDATASection *iface,
275 IXMLDOMDocument** domDocument)
277 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
278 return IXMLDOMNode_get_ownerDocument( This->element, domDocument );
281 static HRESULT WINAPI domcdata_cloneNode(
282 IXMLDOMCDATASection *iface,
283 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
285 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
286 return IXMLDOMNode_cloneNode( This->element, pbool, outNode );
289 static HRESULT WINAPI domcdata_get_nodeTypeString(
290 IXMLDOMCDATASection *iface,
293 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
294 return IXMLDOMNode_get_nodeTypeString( This->element, p );
297 static HRESULT WINAPI domcdata_get_text(
298 IXMLDOMCDATASection *iface,
301 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
302 return IXMLDOMNode_get_text( This->element, p );
305 static HRESULT WINAPI domcdata_put_text(
306 IXMLDOMCDATASection *iface,
309 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
310 return IXMLDOMNode_put_text( This->element, p );
313 static HRESULT WINAPI domcdata_get_specified(
314 IXMLDOMCDATASection *iface,
317 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
318 return IXMLDOMNode_get_specified( This->element, pbool );
321 static HRESULT WINAPI domcdata_get_definition(
322 IXMLDOMCDATASection *iface,
323 IXMLDOMNode** domNode)
325 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
326 return IXMLDOMNode_get_definition( This->element, domNode );
329 static HRESULT WINAPI domcdata_get_nodeTypedValue(
330 IXMLDOMCDATASection *iface,
333 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
334 return IXMLDOMNode_get_nodeTypedValue( This->element, var1 );
337 static HRESULT WINAPI domcdata_put_nodeTypedValue(
338 IXMLDOMCDATASection *iface,
341 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
342 return IXMLDOMNode_put_nodeTypedValue( This->element, var1 );
345 static HRESULT WINAPI domcdata_get_dataType(
346 IXMLDOMCDATASection *iface,
349 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
350 return IXMLDOMNode_get_dataType( This->element, var1 );
353 static HRESULT WINAPI domcdata_put_dataType(
354 IXMLDOMCDATASection *iface,
357 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
358 return IXMLDOMNode_put_dataType( This->element, p );
361 static HRESULT WINAPI domcdata_get_xml(
362 IXMLDOMCDATASection *iface,
365 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
366 return IXMLDOMNode_get_xml( This->element, p );
369 static HRESULT WINAPI domcdata_transformNode(
370 IXMLDOMCDATASection *iface,
371 IXMLDOMNode* domNode, BSTR* p)
373 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
374 return IXMLDOMNode_transformNode( This->element, domNode, p );
377 static HRESULT WINAPI domcdata_selectNodes(
378 IXMLDOMCDATASection *iface,
379 BSTR p, IXMLDOMNodeList** outList)
381 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
382 return IXMLDOMNode_selectNodes( This->element, p, outList );
385 static HRESULT WINAPI domcdata_selectSingleNode(
386 IXMLDOMCDATASection *iface,
387 BSTR p, IXMLDOMNode** outNode)
389 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
390 return IXMLDOMNode_selectSingleNode( This->element, p, outNode );
393 static HRESULT WINAPI domcdata_get_parsed(
394 IXMLDOMCDATASection *iface,
397 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
398 return IXMLDOMNode_get_parsed( This->element, pbool );
401 static HRESULT WINAPI domcdata_get_namespaceURI(
402 IXMLDOMCDATASection *iface,
405 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
406 return IXMLDOMNode_get_namespaceURI( This->element, p );
409 static HRESULT WINAPI domcdata_get_prefix(
410 IXMLDOMCDATASection *iface,
413 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
414 return IXMLDOMNode_get_prefix( This->element, p );
417 static HRESULT WINAPI domcdata_get_baseName(
418 IXMLDOMCDATASection *iface,
421 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
422 return IXMLDOMNode_get_baseName( This->element, p );
425 static HRESULT WINAPI domcdata_transformNodeToObject(
426 IXMLDOMCDATASection *iface,
427 IXMLDOMNode* domNode, VARIANT var1)
429 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
430 return IXMLDOMNode_transformNodeToObject( This->element, domNode, var1 );
433 static HRESULT WINAPI domcdata_get_data(
434 IXMLDOMCDATASection *iface,
441 static HRESULT WINAPI domcdata_put_data(
442 IXMLDOMCDATASection *iface,
449 static HRESULT WINAPI domcdata_get_length(
450 IXMLDOMCDATASection *iface,
457 static HRESULT WINAPI domcdata_substringData(
458 IXMLDOMCDATASection *iface,
459 long offset, long count, BSTR *p)
465 static HRESULT WINAPI domcdata_appendData(
466 IXMLDOMCDATASection *iface,
473 static HRESULT WINAPI domcdata_insertData(
474 IXMLDOMCDATASection *iface,
481 static HRESULT WINAPI domcdata_deleteData(
482 IXMLDOMCDATASection *iface,
483 long offset, long count)
489 static HRESULT WINAPI domcdata_replaceData(
490 IXMLDOMCDATASection *iface,
491 long offset, long count, BSTR p)
497 static HRESULT WINAPI domcdata_splitText(
498 IXMLDOMCDATASection *iface,
499 long offset, IXMLDOMText **txtNode)
506 static const struct IXMLDOMCDATASectionVtbl domcdata_vtbl =
508 domcdata_QueryInterface,
511 domcdata_GetTypeInfoCount,
512 domcdata_GetTypeInfo,
513 domcdata_GetIDsOfNames,
515 domcdata_get_nodeName,
516 domcdata_get_nodeValue,
517 domcdata_put_nodeValue,
518 domcdata_get_nodeType,
519 domcdata_get_parentNode,
520 domcdata_get_childNodes,
521 domcdata_get_firstChild,
522 domcdata_get_lastChild,
523 domcdata_get_previousSibling,
524 domcdata_get_nextSibling,
525 domcdata_get_attributes,
526 domcdata_insertBefore,
527 domcdata_replaceChild,
528 domcdata_removeChild,
529 domcdata_appendChild,
530 domcdata_hasChildNodes,
531 domcdata_get_ownerDocument,
533 domcdata_get_nodeTypeString,
536 domcdata_get_specified,
537 domcdata_get_definition,
538 domcdata_get_nodeTypedValue,
539 domcdata_put_nodeTypedValue,
540 domcdata_get_dataType,
541 domcdata_put_dataType,
543 domcdata_transformNode,
544 domcdata_selectNodes,
545 domcdata_selectSingleNode,
547 domcdata_get_namespaceURI,
549 domcdata_get_baseName,
550 domcdata_transformNodeToObject,
554 domcdata_substringData,
558 domcdata_replaceData,
562 IUnknown* create_cdata( xmlNodePtr text )
567 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
571 This->lpVtbl = &domcdata_vtbl;
574 This->element_unk = create_element( text, (IUnknown*)&This->lpVtbl );
575 if(!This->element_unk)
577 HeapFree(GetProcessHeap(), 0, This);
581 hr = IUnknown_QueryInterface(This->element_unk, &IID_IXMLDOMNode, (LPVOID*)&This->element);
584 IUnknown_Release(This->element_unk);
585 HeapFree( GetProcessHeap(), 0, This );
588 /* The ref on This->element is actually looped back into this object, so release it */
589 IXMLDOMNode_Release(This->element);
591 return (IUnknown*) &This->lpVtbl;