d3d9: Don't return a pointer to the implementation in IDirect3DSwapChain9Impl_QueryIn...
[wine.git] / dlls / msxml3 / cdata.c
blob63265bf2221204a37563e0a0a76de68fa72bec0e
1 /*
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
21 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #ifdef HAVE_LIBXML2
27 # include <libxml/parser.h>
28 # include <libxml/xmlerror.h>
29 #endif
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "ole2.h"
35 #include "msxml6.h"
37 #include "msxml_private.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
43 #ifdef HAVE_LIBXML2
45 typedef struct
47 xmlnode node;
48 IXMLDOMCDATASection IXMLDOMCDATASection_iface;
49 LONG ref;
50 } domcdata;
52 static const tid_t domcdata_se_tids[] = {
53 IXMLDOMNode_tid,
54 IXMLDOMCDATASection_tid,
58 static inline domcdata *impl_from_IXMLDOMCDATASection( IXMLDOMCDATASection *iface )
60 return CONTAINING_RECORD(iface, domcdata, IXMLDOMCDATASection_iface);
63 static HRESULT WINAPI domcdata_QueryInterface(
64 IXMLDOMCDATASection *iface,
65 REFIID riid,
66 void** ppvObject )
68 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
69 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
71 if ( IsEqualGUID( riid, &IID_IXMLDOMCDATASection ) ||
72 IsEqualGUID( riid, &IID_IXMLDOMCharacterData) ||
73 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
74 IsEqualGUID( riid, &IID_IDispatch ) ||
75 IsEqualGUID( riid, &IID_IUnknown ) )
77 *ppvObject = iface;
79 else if(node_query_interface(&This->node, riid, ppvObject))
81 return *ppvObject ? S_OK : E_NOINTERFACE;
83 else if(IsEqualGUID( riid, &IID_ISupportErrorInfo ))
85 return node_create_supporterrorinfo(domcdata_se_tids, ppvObject);
87 else
89 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
90 *ppvObject = NULL;
91 return E_NOINTERFACE;
94 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
95 return S_OK;
98 static ULONG WINAPI domcdata_AddRef(
99 IXMLDOMCDATASection *iface )
101 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
102 ULONG ref = InterlockedIncrement( &This->ref );
103 TRACE("(%p)->(%d)\n", This, ref);
104 return ref;
107 static ULONG WINAPI domcdata_Release(
108 IXMLDOMCDATASection *iface )
110 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
111 ULONG ref = InterlockedDecrement( &This->ref );
113 TRACE("(%p)->(%d)\n", This, ref);
114 if ( ref == 0 )
116 destroy_xmlnode(&This->node);
117 heap_free( This );
120 return ref;
123 static HRESULT WINAPI domcdata_GetTypeInfoCount(
124 IXMLDOMCDATASection *iface,
125 UINT* pctinfo )
127 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
128 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
131 static HRESULT WINAPI domcdata_GetTypeInfo(
132 IXMLDOMCDATASection *iface,
133 UINT iTInfo, LCID lcid,
134 ITypeInfo** ppTInfo )
136 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
137 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface,
138 iTInfo, lcid, ppTInfo);
141 static HRESULT WINAPI domcdata_GetIDsOfNames(
142 IXMLDOMCDATASection *iface,
143 REFIID riid, LPOLESTR* rgszNames,
144 UINT cNames, LCID lcid, DISPID* rgDispId )
146 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
147 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface,
148 riid, rgszNames, cNames, lcid, rgDispId);
151 static HRESULT WINAPI domcdata_Invoke(
152 IXMLDOMCDATASection *iface,
153 DISPID dispIdMember, REFIID riid, LCID lcid,
154 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
155 EXCEPINFO* pExcepInfo, UINT* puArgErr )
157 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
158 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface,
159 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
162 static HRESULT WINAPI domcdata_get_nodeName(
163 IXMLDOMCDATASection *iface,
164 BSTR* p )
166 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
168 static const WCHAR cdata_sectionW[] =
169 {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0};
171 TRACE("(%p)->(%p)\n", This, p);
173 return return_bstr(cdata_sectionW, p);
176 static HRESULT WINAPI domcdata_get_nodeValue(
177 IXMLDOMCDATASection *iface,
178 VARIANT* value)
180 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
182 TRACE("(%p)->(%p)\n", This, value);
184 return node_get_content(&This->node, value);
187 static HRESULT WINAPI domcdata_put_nodeValue(
188 IXMLDOMCDATASection *iface,
189 VARIANT value)
191 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
193 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
195 return node_put_value(&This->node, &value);
198 static HRESULT WINAPI domcdata_get_nodeType(
199 IXMLDOMCDATASection *iface,
200 DOMNodeType* domNodeType )
202 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
204 TRACE("(%p)->(%p)\n", This, domNodeType);
206 *domNodeType = NODE_CDATA_SECTION;
207 return S_OK;
210 static HRESULT WINAPI domcdata_get_parentNode(
211 IXMLDOMCDATASection *iface,
212 IXMLDOMNode** parent )
214 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
216 TRACE("(%p)->(%p)\n", This, parent);
218 return node_get_parent(&This->node, parent);
221 static HRESULT WINAPI domcdata_get_childNodes(
222 IXMLDOMCDATASection *iface,
223 IXMLDOMNodeList** outList)
225 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
227 TRACE("(%p)->(%p)\n", This, outList);
229 return node_get_child_nodes(&This->node, outList);
232 static HRESULT WINAPI domcdata_get_firstChild(
233 IXMLDOMCDATASection *iface,
234 IXMLDOMNode** domNode)
236 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
238 TRACE("(%p)->(%p)\n", This, domNode);
240 return return_null_node(domNode);
243 static HRESULT WINAPI domcdata_get_lastChild(
244 IXMLDOMCDATASection *iface,
245 IXMLDOMNode** domNode)
247 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
249 TRACE("(%p)->(%p)\n", This, domNode);
251 return return_null_node(domNode);
254 static HRESULT WINAPI domcdata_get_previousSibling(
255 IXMLDOMCDATASection *iface,
256 IXMLDOMNode** domNode)
258 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
260 TRACE("(%p)->(%p)\n", This, domNode);
262 return node_get_previous_sibling(&This->node, domNode);
265 static HRESULT WINAPI domcdata_get_nextSibling(
266 IXMLDOMCDATASection *iface,
267 IXMLDOMNode** domNode)
269 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
271 TRACE("(%p)->(%p)\n", This, domNode);
273 return node_get_next_sibling(&This->node, domNode);
276 static HRESULT WINAPI domcdata_get_attributes(
277 IXMLDOMCDATASection *iface,
278 IXMLDOMNamedNodeMap** attributeMap)
280 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
282 TRACE("(%p)->(%p)\n", This, attributeMap);
284 return return_null_ptr((void**)attributeMap);
287 static HRESULT WINAPI domcdata_insertBefore(
288 IXMLDOMCDATASection *iface,
289 IXMLDOMNode* newNode, VARIANT refChild,
290 IXMLDOMNode** outOldNode)
292 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
294 FIXME("(%p)->(%p %s %p) needs test\n", This, newNode, debugstr_variant(&refChild), outOldNode);
296 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
299 static HRESULT WINAPI domcdata_replaceChild(
300 IXMLDOMCDATASection *iface,
301 IXMLDOMNode* newNode,
302 IXMLDOMNode* oldNode,
303 IXMLDOMNode** outOldNode)
305 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
307 FIXME("(%p)->(%p %p %p) needs tests\n", This, newNode, oldNode, outOldNode);
309 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
312 static HRESULT WINAPI domcdata_removeChild(
313 IXMLDOMCDATASection *iface,
314 IXMLDOMNode *child, IXMLDOMNode **oldChild)
316 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
317 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
318 return node_remove_child(&This->node, child, oldChild);
321 static HRESULT WINAPI domcdata_appendChild(
322 IXMLDOMCDATASection *iface,
323 IXMLDOMNode *child, IXMLDOMNode **outChild)
325 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
326 TRACE("(%p)->(%p %p)\n", This, child, outChild);
327 return node_append_child(&This->node, child, outChild);
330 static HRESULT WINAPI domcdata_hasChildNodes(
331 IXMLDOMCDATASection *iface,
332 VARIANT_BOOL *ret)
334 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
335 TRACE("(%p)->(%p)\n", This, ret);
336 return node_has_childnodes(&This->node, ret);
339 static HRESULT WINAPI domcdata_get_ownerDocument(
340 IXMLDOMCDATASection *iface,
341 IXMLDOMDocument **doc)
343 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
344 TRACE("(%p)->(%p)\n", This, doc);
345 return node_get_owner_doc(&This->node, doc);
348 static HRESULT WINAPI domcdata_cloneNode(
349 IXMLDOMCDATASection *iface,
350 VARIANT_BOOL deep, IXMLDOMNode** outNode)
352 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
353 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
354 return node_clone( &This->node, deep, outNode );
357 static HRESULT WINAPI domcdata_get_nodeTypeString(
358 IXMLDOMCDATASection *iface,
359 BSTR* p)
361 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
362 static const WCHAR cdatasectionW[] = {'c','d','a','t','a','s','e','c','t','i','o','n',0};
364 TRACE("(%p)->(%p)\n", This, p);
366 return return_bstr(cdatasectionW, p);
369 static HRESULT WINAPI domcdata_get_text(
370 IXMLDOMCDATASection *iface,
371 BSTR* p)
373 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
374 TRACE("(%p)->(%p)\n", This, p);
375 return node_get_text(&This->node, p);
378 static HRESULT WINAPI domcdata_put_text(
379 IXMLDOMCDATASection *iface,
380 BSTR p)
382 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
383 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
384 return node_put_text( &This->node, p );
387 static HRESULT WINAPI domcdata_get_specified(
388 IXMLDOMCDATASection *iface,
389 VARIANT_BOOL* isSpecified)
391 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
392 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
393 *isSpecified = VARIANT_TRUE;
394 return S_OK;
397 static HRESULT WINAPI domcdata_get_definition(
398 IXMLDOMCDATASection *iface,
399 IXMLDOMNode** definitionNode)
401 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
402 FIXME("(%p)->(%p)\n", This, definitionNode);
403 return E_NOTIMPL;
406 static HRESULT WINAPI domcdata_get_nodeTypedValue(
407 IXMLDOMCDATASection *iface,
408 VARIANT* v)
410 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
411 TRACE("(%p)->(%p)\n", This, v);
412 return node_get_content(&This->node, v);
415 static HRESULT WINAPI domcdata_put_nodeTypedValue(
416 IXMLDOMCDATASection *iface,
417 VARIANT typedValue)
419 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
420 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
421 return E_NOTIMPL;
424 static HRESULT WINAPI domcdata_get_dataType(
425 IXMLDOMCDATASection *iface,
426 VARIANT* typename)
428 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
429 TRACE("(%p)->(%p)\n", This, typename);
430 return return_null_var( typename );
433 static HRESULT WINAPI domcdata_put_dataType(
434 IXMLDOMCDATASection *iface,
435 BSTR p)
437 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
439 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
441 if(!p)
442 return E_INVALIDARG;
444 return E_FAIL;
447 static HRESULT WINAPI domcdata_get_xml(
448 IXMLDOMCDATASection *iface,
449 BSTR* p)
451 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
453 TRACE("(%p)->(%p)\n", This, p);
455 return node_get_xml(&This->node, FALSE, FALSE, p);
458 static HRESULT WINAPI domcdata_transformNode(
459 IXMLDOMCDATASection *iface,
460 IXMLDOMNode *node, BSTR *p)
462 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
463 TRACE("(%p)->(%p %p)\n", This, node, p);
464 return node_transform_node(&This->node, node, p);
467 static HRESULT WINAPI domcdata_selectNodes(
468 IXMLDOMCDATASection *iface,
469 BSTR p, IXMLDOMNodeList** outList)
471 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
472 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
473 return node_select_nodes(&This->node, p, outList);
476 static HRESULT WINAPI domcdata_selectSingleNode(
477 IXMLDOMCDATASection *iface,
478 BSTR p, IXMLDOMNode** outNode)
480 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
481 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
482 return node_select_singlenode(&This->node, p, outNode);
485 static HRESULT WINAPI domcdata_get_parsed(
486 IXMLDOMCDATASection *iface,
487 VARIANT_BOOL* isParsed)
489 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
490 FIXME("(%p)->(%p) stub!\n", This, isParsed);
491 *isParsed = VARIANT_TRUE;
492 return S_OK;
495 static HRESULT WINAPI domcdata_get_namespaceURI(
496 IXMLDOMCDATASection *iface,
497 BSTR* p)
499 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
500 TRACE("(%p)->(%p)\n", This, p);
501 return node_get_namespaceURI(&This->node, p);
504 static HRESULT WINAPI domcdata_get_prefix(
505 IXMLDOMCDATASection *iface,
506 BSTR* prefix)
508 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
509 TRACE("(%p)->(%p)\n", This, prefix);
510 return return_null_bstr( prefix );
513 static HRESULT WINAPI domcdata_get_baseName(
514 IXMLDOMCDATASection *iface,
515 BSTR* name)
517 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
518 FIXME("(%p)->(%p): needs test\n", This, name);
519 return return_null_bstr( name );
522 static HRESULT WINAPI domcdata_transformNodeToObject(
523 IXMLDOMCDATASection *iface,
524 IXMLDOMNode* domNode, VARIANT var1)
526 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
527 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
528 return E_NOTIMPL;
531 static HRESULT WINAPI domcdata_get_data(
532 IXMLDOMCDATASection *iface,
533 BSTR *p)
535 HRESULT hr;
536 VARIANT vRet;
538 if(!p)
539 return E_INVALIDARG;
541 hr = IXMLDOMCDATASection_get_nodeValue( iface, &vRet );
542 if(hr == S_OK)
544 *p = V_BSTR(&vRet);
547 return hr;
550 static HRESULT WINAPI domcdata_put_data(
551 IXMLDOMCDATASection *iface,
552 BSTR data)
554 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
555 VARIANT val;
557 TRACE("(%p)->(%s)\n", This, debugstr_w(data) );
559 V_VT(&val) = VT_BSTR;
560 V_BSTR(&val) = data;
562 return IXMLDOMCDATASection_put_nodeValue( iface, val );
565 static HRESULT WINAPI domcdata_get_length(
566 IXMLDOMCDATASection *iface,
567 LONG *len)
569 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
570 HRESULT hr;
571 BSTR data;
573 TRACE("(%p)->(%p)\n", This, len);
575 if(!len)
576 return E_INVALIDARG;
578 hr = IXMLDOMCDATASection_get_data(iface, &data);
579 if(hr == S_OK)
581 *len = SysStringLen(data);
582 SysFreeString(data);
585 return S_OK;
588 static HRESULT WINAPI domcdata_substringData(
589 IXMLDOMCDATASection *iface,
590 LONG offset, LONG count, BSTR *p)
592 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
593 HRESULT hr;
594 BSTR data;
596 TRACE("(%p)->(%d %d %p)\n", This, offset, count, p);
598 if(!p)
599 return E_INVALIDARG;
601 *p = NULL;
602 if(offset < 0 || count < 0)
603 return E_INVALIDARG;
605 if(count == 0)
606 return S_FALSE;
608 hr = IXMLDOMCDATASection_get_data(iface, &data);
609 if(hr == S_OK)
611 LONG len = SysStringLen(data);
613 if(offset < len)
615 if(offset + count > len)
616 *p = SysAllocString(&data[offset]);
617 else
618 *p = SysAllocStringLen(&data[offset], count);
620 else
621 hr = S_FALSE;
623 SysFreeString(data);
626 return hr;
629 static HRESULT WINAPI domcdata_appendData(
630 IXMLDOMCDATASection *iface,
631 BSTR p)
633 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
634 HRESULT hr;
635 BSTR data;
636 LONG p_len;
638 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
640 /* Nothing to do if NULL or an Empty string passed in. */
641 if((p_len = SysStringLen(p)) == 0) return S_OK;
643 hr = IXMLDOMCDATASection_get_data(iface, &data);
644 if(hr == S_OK)
646 LONG len = SysStringLen(data);
647 BSTR str = SysAllocStringLen(NULL, p_len + len);
649 memcpy(str, data, len*sizeof(WCHAR));
650 memcpy(&str[len], p, p_len*sizeof(WCHAR));
651 str[len+p_len] = 0;
653 hr = IXMLDOMCDATASection_put_data(iface, str);
655 SysFreeString(str);
656 SysFreeString(data);
659 return hr;
662 static HRESULT WINAPI domcdata_insertData(
663 IXMLDOMCDATASection *iface,
664 LONG offset, BSTR p)
666 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
667 HRESULT hr;
668 BSTR data;
669 LONG p_len;
671 TRACE("(%p)->(%d %s)\n", This, offset, debugstr_w(p));
673 /* If have a NULL or empty string, don't do anything. */
674 if((p_len = SysStringLen(p)) == 0)
675 return S_OK;
677 if(offset < 0)
679 return E_INVALIDARG;
682 hr = IXMLDOMCDATASection_get_data(iface, &data);
683 if(hr == S_OK)
685 LONG len = SysStringLen(data);
686 BSTR str;
688 if(len < offset)
690 SysFreeString(data);
691 return E_INVALIDARG;
694 str = SysAllocStringLen(NULL, len + p_len);
695 /* start part, supplied string and end part */
696 memcpy(str, data, offset*sizeof(WCHAR));
697 memcpy(&str[offset], p, p_len*sizeof(WCHAR));
698 memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR));
699 str[len+p_len] = 0;
701 hr = IXMLDOMCDATASection_put_data(iface, str);
703 SysFreeString(str);
704 SysFreeString(data);
707 return hr;
710 static HRESULT WINAPI domcdata_deleteData(
711 IXMLDOMCDATASection *iface,
712 LONG offset, LONG count)
714 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
715 HRESULT hr;
716 LONG len = -1;
717 BSTR str;
719 TRACE("(%p)->(%d %d)\n", This, offset, count);
721 hr = IXMLDOMCDATASection_get_length(iface, &len);
722 if(hr != S_OK) return hr;
724 if((offset < 0) || (offset > len) || (count < 0))
725 return E_INVALIDARG;
727 if(len == 0) return S_OK;
729 /* cutting start or end */
730 if((offset == 0) || ((count + offset) >= len))
732 if(offset == 0)
733 IXMLDOMCDATASection_substringData(iface, count, len - count, &str);
734 else
735 IXMLDOMCDATASection_substringData(iface, 0, offset, &str);
736 hr = IXMLDOMCDATASection_put_data(iface, str);
738 else
739 /* cutting from the inside */
741 BSTR str_end;
743 IXMLDOMCDATASection_substringData(iface, 0, offset, &str);
744 IXMLDOMCDATASection_substringData(iface, offset + count, len - count, &str_end);
746 hr = IXMLDOMCDATASection_put_data(iface, str);
747 if(hr == S_OK)
748 hr = IXMLDOMCDATASection_appendData(iface, str_end);
750 SysFreeString(str_end);
753 SysFreeString(str);
755 return hr;
758 static HRESULT WINAPI domcdata_replaceData(
759 IXMLDOMCDATASection *iface,
760 LONG offset, LONG count, BSTR p)
762 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
763 HRESULT hr;
765 TRACE("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(p));
767 hr = IXMLDOMCDATASection_deleteData(iface, offset, count);
769 if (hr == S_OK)
770 hr = IXMLDOMCDATASection_insertData(iface, offset, p);
772 return hr;
775 static HRESULT WINAPI domcdata_splitText(
776 IXMLDOMCDATASection *iface,
777 LONG offset, IXMLDOMText **txtNode)
779 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
780 IXMLDOMDocument *doc;
781 LONG length = 0;
782 HRESULT hr;
784 TRACE("(%p)->(%d %p)\n", This, offset, txtNode);
786 if (!txtNode || offset < 0) return E_INVALIDARG;
788 *txtNode = NULL;
790 IXMLDOMCDATASection_get_length(iface, &length);
792 if (offset > length) return E_INVALIDARG;
793 if (offset == length) return S_FALSE;
795 hr = IXMLDOMCDATASection_get_ownerDocument(iface, &doc);
796 if (hr == S_OK)
798 BSTR data;
800 hr = IXMLDOMCDATASection_substringData(iface, offset, length - offset, &data);
801 if (hr == S_OK)
803 hr = IXMLDOMDocument_createTextNode(doc, data, txtNode);
804 if (hr == S_OK)
806 IXMLDOMNode *parent;
808 hr = IXMLDOMCDATASection_get_parentNode(iface, &parent);
809 if (hr == S_OK)
811 IXMLDOMCDATASection_deleteData(iface, 0, offset);
812 hr = IXMLDOMNode_appendChild(parent, (IXMLDOMNode*)*txtNode, NULL);
813 IXMLDOMNode_Release(parent);
816 SysFreeString(data);
818 IXMLDOMDocument_Release(doc);
821 return hr;
824 static const struct IXMLDOMCDATASectionVtbl domcdata_vtbl =
826 domcdata_QueryInterface,
827 domcdata_AddRef,
828 domcdata_Release,
829 domcdata_GetTypeInfoCount,
830 domcdata_GetTypeInfo,
831 domcdata_GetIDsOfNames,
832 domcdata_Invoke,
833 domcdata_get_nodeName,
834 domcdata_get_nodeValue,
835 domcdata_put_nodeValue,
836 domcdata_get_nodeType,
837 domcdata_get_parentNode,
838 domcdata_get_childNodes,
839 domcdata_get_firstChild,
840 domcdata_get_lastChild,
841 domcdata_get_previousSibling,
842 domcdata_get_nextSibling,
843 domcdata_get_attributes,
844 domcdata_insertBefore,
845 domcdata_replaceChild,
846 domcdata_removeChild,
847 domcdata_appendChild,
848 domcdata_hasChildNodes,
849 domcdata_get_ownerDocument,
850 domcdata_cloneNode,
851 domcdata_get_nodeTypeString,
852 domcdata_get_text,
853 domcdata_put_text,
854 domcdata_get_specified,
855 domcdata_get_definition,
856 domcdata_get_nodeTypedValue,
857 domcdata_put_nodeTypedValue,
858 domcdata_get_dataType,
859 domcdata_put_dataType,
860 domcdata_get_xml,
861 domcdata_transformNode,
862 domcdata_selectNodes,
863 domcdata_selectSingleNode,
864 domcdata_get_parsed,
865 domcdata_get_namespaceURI,
866 domcdata_get_prefix,
867 domcdata_get_baseName,
868 domcdata_transformNodeToObject,
869 domcdata_get_data,
870 domcdata_put_data,
871 domcdata_get_length,
872 domcdata_substringData,
873 domcdata_appendData,
874 domcdata_insertData,
875 domcdata_deleteData,
876 domcdata_replaceData,
877 domcdata_splitText
880 static const tid_t domcdata_iface_tids[] = {
881 IXMLDOMCDATASection_tid,
885 static dispex_static_data_t domcdata_dispex = {
886 NULL,
887 IXMLDOMCDATASection_tid,
888 NULL,
889 domcdata_iface_tids
892 IUnknown* create_cdata( xmlNodePtr text )
894 domcdata *This;
896 This = heap_alloc( sizeof *This );
897 if ( !This )
898 return NULL;
900 This->IXMLDOMCDATASection_iface.lpVtbl = &domcdata_vtbl;
901 This->ref = 1;
903 init_xmlnode(&This->node, text, (IXMLDOMNode*)&This->IXMLDOMCDATASection_iface, &domcdata_dispex);
905 return (IUnknown*)&This->IXMLDOMCDATASection_iface;
908 #endif