wined3d: Spawn a separate thread to adjust the window state of windows belonging...
[wine.git] / dlls / msxml3 / cdata.c
blob9994a508c54caaa23cf176466b851c973f5231ff
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 <stdarg.h>
24 #include <libxml/parser.h>
25 #include <libxml/xmlerror.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "ole2.h"
31 #include "msxml6.h"
33 #include "msxml_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
39 typedef struct
41 xmlnode node;
42 IXMLDOMCDATASection IXMLDOMCDATASection_iface;
43 LONG ref;
44 } domcdata;
46 static const tid_t domcdata_se_tids[] = {
47 IXMLDOMNode_tid,
48 IXMLDOMCDATASection_tid,
49 NULL_tid
52 static inline domcdata *impl_from_IXMLDOMCDATASection( IXMLDOMCDATASection *iface )
54 return CONTAINING_RECORD(iface, domcdata, IXMLDOMCDATASection_iface);
57 static HRESULT WINAPI domcdata_QueryInterface(
58 IXMLDOMCDATASection *iface,
59 REFIID riid,
60 void** ppvObject )
62 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
63 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
65 if ( IsEqualGUID( riid, &IID_IXMLDOMCDATASection ) ||
66 IsEqualGUID( riid, &IID_IXMLDOMCharacterData) ||
67 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
68 IsEqualGUID( riid, &IID_IDispatch ) ||
69 IsEqualGUID( riid, &IID_IUnknown ) )
71 *ppvObject = iface;
73 else if(node_query_interface(&This->node, riid, ppvObject))
75 return *ppvObject ? S_OK : E_NOINTERFACE;
77 else if(IsEqualGUID( riid, &IID_ISupportErrorInfo ))
79 return node_create_supporterrorinfo(domcdata_se_tids, ppvObject);
81 else
83 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
84 *ppvObject = NULL;
85 return E_NOINTERFACE;
88 IXMLDOMCDATASection_AddRef(iface);
89 return S_OK;
92 static ULONG WINAPI domcdata_AddRef(IXMLDOMCDATASection *iface)
94 domcdata *cdata = impl_from_IXMLDOMCDATASection(iface);
95 ULONG ref = InterlockedIncrement(&cdata->ref);
96 TRACE("%p, refcount %lu.\n", iface, ref);
97 return ref;
100 static ULONG WINAPI domcdata_Release(IXMLDOMCDATASection *iface)
102 domcdata *cdata = impl_from_IXMLDOMCDATASection(iface);
103 ULONG ref = InterlockedDecrement(&cdata->ref);
105 TRACE("%p, refcount %lu.\n", iface, ref);
107 if (!ref)
109 destroy_xmlnode(&cdata->node);
110 heap_free(cdata);
113 return ref;
116 static HRESULT WINAPI domcdata_GetTypeInfoCount(
117 IXMLDOMCDATASection *iface,
118 UINT* pctinfo )
120 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
121 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
124 static HRESULT WINAPI domcdata_GetTypeInfo(
125 IXMLDOMCDATASection *iface,
126 UINT iTInfo, LCID lcid,
127 ITypeInfo** ppTInfo )
129 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
130 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface,
131 iTInfo, lcid, 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 );
140 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface,
141 riid, rgszNames, cNames, lcid, rgDispId);
144 static HRESULT WINAPI domcdata_Invoke(
145 IXMLDOMCDATASection *iface,
146 DISPID dispIdMember, REFIID riid, LCID lcid,
147 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
148 EXCEPINFO* pExcepInfo, UINT* puArgErr )
150 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
151 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface,
152 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
155 static HRESULT WINAPI domcdata_get_nodeName(
156 IXMLDOMCDATASection *iface,
157 BSTR* p )
159 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
161 static const WCHAR cdata_sectionW[] =
162 {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0};
164 TRACE("(%p)->(%p)\n", This, p);
166 return return_bstr(cdata_sectionW, p);
169 static HRESULT WINAPI domcdata_get_nodeValue(
170 IXMLDOMCDATASection *iface,
171 VARIANT* value)
173 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
175 TRACE("(%p)->(%p)\n", This, value);
177 return node_get_content(&This->node, value);
180 static HRESULT WINAPI domcdata_put_nodeValue(
181 IXMLDOMCDATASection *iface,
182 VARIANT value)
184 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
186 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
188 return node_put_value(&This->node, &value);
191 static HRESULT WINAPI domcdata_get_nodeType(
192 IXMLDOMCDATASection *iface,
193 DOMNodeType* domNodeType )
195 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
197 TRACE("(%p)->(%p)\n", This, domNodeType);
199 *domNodeType = NODE_CDATA_SECTION;
200 return S_OK;
203 static HRESULT WINAPI domcdata_get_parentNode(
204 IXMLDOMCDATASection *iface,
205 IXMLDOMNode** parent )
207 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
209 TRACE("(%p)->(%p)\n", This, parent);
211 return node_get_parent(&This->node, parent);
214 static HRESULT WINAPI domcdata_get_childNodes(
215 IXMLDOMCDATASection *iface,
216 IXMLDOMNodeList** outList)
218 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
220 TRACE("(%p)->(%p)\n", This, outList);
222 return node_get_child_nodes(&This->node, outList);
225 static HRESULT WINAPI domcdata_get_firstChild(
226 IXMLDOMCDATASection *iface,
227 IXMLDOMNode** domNode)
229 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
231 TRACE("(%p)->(%p)\n", This, domNode);
233 return return_null_node(domNode);
236 static HRESULT WINAPI domcdata_get_lastChild(
237 IXMLDOMCDATASection *iface,
238 IXMLDOMNode** domNode)
240 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
242 TRACE("(%p)->(%p)\n", This, domNode);
244 return return_null_node(domNode);
247 static HRESULT WINAPI domcdata_get_previousSibling(
248 IXMLDOMCDATASection *iface,
249 IXMLDOMNode** domNode)
251 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
253 TRACE("(%p)->(%p)\n", This, domNode);
255 return node_get_previous_sibling(&This->node, domNode);
258 static HRESULT WINAPI domcdata_get_nextSibling(
259 IXMLDOMCDATASection *iface,
260 IXMLDOMNode** domNode)
262 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
264 TRACE("(%p)->(%p)\n", This, domNode);
266 return node_get_next_sibling(&This->node, domNode);
269 static HRESULT WINAPI domcdata_get_attributes(
270 IXMLDOMCDATASection *iface,
271 IXMLDOMNamedNodeMap** attributeMap)
273 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
275 TRACE("(%p)->(%p)\n", This, attributeMap);
277 return return_null_ptr((void**)attributeMap);
280 static HRESULT WINAPI domcdata_insertBefore(
281 IXMLDOMCDATASection *iface,
282 IXMLDOMNode* newNode, VARIANT refChild,
283 IXMLDOMNode** outOldNode)
285 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
286 TRACE("(%p)->(%p %s %p)\n", This, newNode, debugstr_variant(&refChild), outOldNode);
287 if (outOldNode) *outOldNode = NULL;
288 return E_FAIL;
291 static HRESULT WINAPI domcdata_replaceChild(
292 IXMLDOMCDATASection *iface,
293 IXMLDOMNode* newNode,
294 IXMLDOMNode* oldNode,
295 IXMLDOMNode** outOldNode)
297 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
298 TRACE("(%p)->(%p %p %p)\n", This, newNode, oldNode, outOldNode);
299 if (outOldNode) *outOldNode = NULL;
300 return E_FAIL;
303 static HRESULT WINAPI domcdata_removeChild(
304 IXMLDOMCDATASection *iface,
305 IXMLDOMNode *child, IXMLDOMNode **oldChild)
307 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
308 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
309 if (oldChild) *oldChild = NULL;
310 return E_FAIL;
313 static HRESULT WINAPI domcdata_appendChild(
314 IXMLDOMCDATASection *iface,
315 IXMLDOMNode *child, IXMLDOMNode **outChild)
317 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
318 TRACE("(%p)->(%p %p)\n", This, child, outChild);
319 if (outChild) *outChild = NULL;
320 return E_FAIL;
323 static HRESULT WINAPI domcdata_hasChildNodes(
324 IXMLDOMCDATASection *iface,
325 VARIANT_BOOL *ret)
327 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
328 TRACE("(%p)->(%p)\n", This, ret);
329 return return_var_false(ret);
332 static HRESULT WINAPI domcdata_get_ownerDocument(
333 IXMLDOMCDATASection *iface,
334 IXMLDOMDocument **doc)
336 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
337 TRACE("(%p)->(%p)\n", This, doc);
338 return node_get_owner_doc(&This->node, doc);
341 static HRESULT WINAPI domcdata_cloneNode(
342 IXMLDOMCDATASection *iface,
343 VARIANT_BOOL deep, IXMLDOMNode** outNode)
345 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
346 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
347 return node_clone( &This->node, deep, outNode );
350 static HRESULT WINAPI domcdata_get_nodeTypeString(
351 IXMLDOMCDATASection *iface,
352 BSTR* p)
354 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
355 static const WCHAR cdatasectionW[] = {'c','d','a','t','a','s','e','c','t','i','o','n',0};
357 TRACE("(%p)->(%p)\n", This, p);
359 return return_bstr(cdatasectionW, p);
362 static HRESULT WINAPI domcdata_get_text(
363 IXMLDOMCDATASection *iface,
364 BSTR* p)
366 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
367 TRACE("(%p)->(%p)\n", This, p);
368 return node_get_text(&This->node, p);
371 static HRESULT WINAPI domcdata_put_text(
372 IXMLDOMCDATASection *iface,
373 BSTR p)
375 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
376 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
377 return node_put_text( &This->node, p );
380 static HRESULT WINAPI domcdata_get_specified(
381 IXMLDOMCDATASection *iface,
382 VARIANT_BOOL* isSpecified)
384 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
385 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
386 *isSpecified = VARIANT_TRUE;
387 return S_OK;
390 static HRESULT WINAPI domcdata_get_definition(
391 IXMLDOMCDATASection *iface,
392 IXMLDOMNode** definitionNode)
394 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
395 FIXME("(%p)->(%p)\n", This, definitionNode);
396 return E_NOTIMPL;
399 static HRESULT WINAPI domcdata_get_nodeTypedValue(
400 IXMLDOMCDATASection *iface,
401 VARIANT* v)
403 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
404 TRACE("(%p)->(%p)\n", This, v);
405 return node_get_content(&This->node, v);
408 static HRESULT WINAPI domcdata_put_nodeTypedValue(
409 IXMLDOMCDATASection *iface,
410 VARIANT typedValue)
412 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
413 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
414 return E_NOTIMPL;
417 static HRESULT WINAPI domcdata_get_dataType(
418 IXMLDOMCDATASection *iface,
419 VARIANT* typename)
421 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
422 TRACE("(%p)->(%p)\n", This, typename);
423 return return_null_var( typename );
426 static HRESULT WINAPI domcdata_put_dataType(
427 IXMLDOMCDATASection *iface,
428 BSTR p)
430 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
432 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
434 if(!p)
435 return E_INVALIDARG;
437 return E_FAIL;
440 static HRESULT WINAPI domcdata_get_xml(
441 IXMLDOMCDATASection *iface,
442 BSTR* p)
444 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
446 TRACE("(%p)->(%p)\n", This, p);
448 return node_get_xml(&This->node, FALSE, p);
451 static HRESULT WINAPI domcdata_transformNode(
452 IXMLDOMCDATASection *iface,
453 IXMLDOMNode *node, BSTR *p)
455 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
456 TRACE("(%p)->(%p %p)\n", This, node, p);
457 return node_transform_node(&This->node, node, p);
460 static HRESULT WINAPI domcdata_selectNodes(
461 IXMLDOMCDATASection *iface,
462 BSTR p, IXMLDOMNodeList** outList)
464 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
465 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
466 return node_select_nodes(&This->node, p, outList);
469 static HRESULT WINAPI domcdata_selectSingleNode(
470 IXMLDOMCDATASection *iface,
471 BSTR p, IXMLDOMNode** outNode)
473 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
474 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
475 return node_select_singlenode(&This->node, p, outNode);
478 static HRESULT WINAPI domcdata_get_parsed(
479 IXMLDOMCDATASection *iface,
480 VARIANT_BOOL* isParsed)
482 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
483 FIXME("(%p)->(%p) stub!\n", This, isParsed);
484 *isParsed = VARIANT_TRUE;
485 return S_OK;
488 static HRESULT WINAPI domcdata_get_namespaceURI(
489 IXMLDOMCDATASection *iface,
490 BSTR* p)
492 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
493 TRACE("(%p)->(%p)\n", This, p);
494 return node_get_namespaceURI(&This->node, p);
497 static HRESULT WINAPI domcdata_get_prefix(
498 IXMLDOMCDATASection *iface,
499 BSTR* prefix)
501 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
502 TRACE("(%p)->(%p)\n", This, prefix);
503 return return_null_bstr( prefix );
506 static HRESULT WINAPI domcdata_get_baseName(
507 IXMLDOMCDATASection *iface,
508 BSTR* name)
510 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
511 FIXME("(%p)->(%p): needs test\n", This, name);
512 return return_null_bstr( name );
515 static HRESULT WINAPI domcdata_transformNodeToObject(
516 IXMLDOMCDATASection *iface,
517 IXMLDOMNode* domNode, VARIANT var1)
519 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
520 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
521 return E_NOTIMPL;
524 static HRESULT WINAPI domcdata_get_data(
525 IXMLDOMCDATASection *iface,
526 BSTR *p)
528 HRESULT hr;
529 VARIANT vRet;
531 if(!p)
532 return E_INVALIDARG;
534 hr = IXMLDOMCDATASection_get_nodeValue( iface, &vRet );
535 if(hr == S_OK)
537 *p = V_BSTR(&vRet);
540 return hr;
543 static HRESULT WINAPI domcdata_put_data(
544 IXMLDOMCDATASection *iface,
545 BSTR data)
547 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
548 TRACE("(%p)->(%s)\n", This, debugstr_w(data));
549 return node_set_content(&This->node, data);
552 static HRESULT WINAPI domcdata_get_length(
553 IXMLDOMCDATASection *iface,
554 LONG *len)
556 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
557 HRESULT hr;
558 BSTR data;
560 TRACE("(%p)->(%p)\n", This, len);
562 if(!len)
563 return E_INVALIDARG;
565 hr = IXMLDOMCDATASection_get_data(iface, &data);
566 if(hr == S_OK)
568 *len = SysStringLen(data);
569 SysFreeString(data);
572 return S_OK;
575 static HRESULT WINAPI domcdata_substringData(
576 IXMLDOMCDATASection *iface,
577 LONG offset, LONG count, BSTR *p)
579 HRESULT hr;
580 BSTR data;
582 TRACE("%p, %ld, %ld, %p.\n", iface, offset, count, p);
584 if(!p)
585 return E_INVALIDARG;
587 *p = NULL;
588 if(offset < 0 || count < 0)
589 return E_INVALIDARG;
591 if(count == 0)
592 return S_FALSE;
594 hr = IXMLDOMCDATASection_get_data(iface, &data);
595 if(hr == S_OK)
597 LONG len = SysStringLen(data);
599 if(offset < len)
601 if(offset + count > len)
602 *p = SysAllocString(&data[offset]);
603 else
604 *p = SysAllocStringLen(&data[offset], count);
606 else
607 hr = S_FALSE;
609 SysFreeString(data);
612 return hr;
615 static HRESULT WINAPI domcdata_appendData(
616 IXMLDOMCDATASection *iface,
617 BSTR p)
619 domcdata *This = impl_from_IXMLDOMCDATASection( iface );
620 HRESULT hr;
621 BSTR data;
622 LONG p_len;
624 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
626 /* Nothing to do if NULL or an Empty string passed in. */
627 if((p_len = SysStringLen(p)) == 0) return S_OK;
629 hr = IXMLDOMCDATASection_get_data(iface, &data);
630 if(hr == S_OK)
632 LONG len = SysStringLen(data);
633 BSTR str = SysAllocStringLen(NULL, p_len + len);
635 memcpy(str, data, len*sizeof(WCHAR));
636 memcpy(&str[len], p, p_len*sizeof(WCHAR));
637 str[len+p_len] = 0;
639 hr = IXMLDOMCDATASection_put_data(iface, str);
641 SysFreeString(str);
642 SysFreeString(data);
645 return hr;
648 static HRESULT WINAPI domcdata_insertData(
649 IXMLDOMCDATASection *iface,
650 LONG offset, BSTR p)
652 HRESULT hr;
653 BSTR data;
654 LONG p_len;
656 TRACE("%p, %ld, %s.\n", iface, offset, debugstr_w(p));
658 /* If have a NULL or empty string, don't do anything. */
659 if((p_len = SysStringLen(p)) == 0)
660 return S_OK;
662 if(offset < 0)
664 return E_INVALIDARG;
667 hr = IXMLDOMCDATASection_get_data(iface, &data);
668 if(hr == S_OK)
670 LONG len = SysStringLen(data);
671 BSTR str;
673 if(len < offset)
675 SysFreeString(data);
676 return E_INVALIDARG;
679 str = SysAllocStringLen(NULL, len + p_len);
680 /* start part, supplied string and end part */
681 memcpy(str, data, offset*sizeof(WCHAR));
682 memcpy(&str[offset], p, p_len*sizeof(WCHAR));
683 memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR));
684 str[len+p_len] = 0;
686 hr = IXMLDOMCDATASection_put_data(iface, str);
688 SysFreeString(str);
689 SysFreeString(data);
692 return hr;
695 static HRESULT WINAPI domcdata_deleteData(
696 IXMLDOMCDATASection *iface,
697 LONG offset, LONG count)
699 HRESULT hr;
700 LONG len = -1;
701 BSTR str;
703 TRACE("%p, %ld, %ld.\n", iface, offset, count);
705 hr = IXMLDOMCDATASection_get_length(iface, &len);
706 if(hr != S_OK) return hr;
708 if((offset < 0) || (offset > len) || (count < 0))
709 return E_INVALIDARG;
711 if(len == 0) return S_OK;
713 /* cutting start or end */
714 if((offset == 0) || ((count + offset) >= len))
716 if(offset == 0)
717 IXMLDOMCDATASection_substringData(iface, count, len - count, &str);
718 else
719 IXMLDOMCDATASection_substringData(iface, 0, offset, &str);
720 hr = IXMLDOMCDATASection_put_data(iface, str);
722 else
723 /* cutting from the inside */
725 BSTR str_end;
727 IXMLDOMCDATASection_substringData(iface, 0, offset, &str);
728 IXMLDOMCDATASection_substringData(iface, offset + count, len - count, &str_end);
730 hr = IXMLDOMCDATASection_put_data(iface, str);
731 if(hr == S_OK)
732 hr = IXMLDOMCDATASection_appendData(iface, str_end);
734 SysFreeString(str_end);
737 SysFreeString(str);
739 return hr;
742 static HRESULT WINAPI domcdata_replaceData(
743 IXMLDOMCDATASection *iface,
744 LONG offset, LONG count, BSTR p)
746 HRESULT hr;
748 TRACE("%p, %ld, %ld, %s.\n", iface, offset, count, debugstr_w(p));
750 hr = IXMLDOMCDATASection_deleteData(iface, offset, count);
752 if (hr == S_OK)
753 hr = IXMLDOMCDATASection_insertData(iface, offset, p);
755 return hr;
758 static HRESULT WINAPI domcdata_splitText(
759 IXMLDOMCDATASection *iface,
760 LONG offset, IXMLDOMText **txtNode)
762 IXMLDOMDocument *doc;
763 LONG length = 0;
764 HRESULT hr;
766 TRACE("%p, %ld, %p.\n", iface, offset, txtNode);
768 if (!txtNode || offset < 0) return E_INVALIDARG;
770 *txtNode = NULL;
772 IXMLDOMCDATASection_get_length(iface, &length);
774 if (offset > length) return E_INVALIDARG;
775 if (offset == length) return S_FALSE;
777 hr = IXMLDOMCDATASection_get_ownerDocument(iface, &doc);
778 if (hr == S_OK)
780 BSTR data;
782 hr = IXMLDOMCDATASection_substringData(iface, offset, length - offset, &data);
783 if (hr == S_OK)
785 hr = IXMLDOMDocument_createTextNode(doc, data, txtNode);
786 if (hr == S_OK)
788 IXMLDOMNode *parent;
790 hr = IXMLDOMCDATASection_get_parentNode(iface, &parent);
791 if (hr == S_OK)
793 IXMLDOMCDATASection_deleteData(iface, 0, offset);
794 hr = IXMLDOMNode_appendChild(parent, (IXMLDOMNode*)*txtNode, NULL);
795 IXMLDOMNode_Release(parent);
798 SysFreeString(data);
800 IXMLDOMDocument_Release(doc);
803 return hr;
806 static const struct IXMLDOMCDATASectionVtbl domcdata_vtbl =
808 domcdata_QueryInterface,
809 domcdata_AddRef,
810 domcdata_Release,
811 domcdata_GetTypeInfoCount,
812 domcdata_GetTypeInfo,
813 domcdata_GetIDsOfNames,
814 domcdata_Invoke,
815 domcdata_get_nodeName,
816 domcdata_get_nodeValue,
817 domcdata_put_nodeValue,
818 domcdata_get_nodeType,
819 domcdata_get_parentNode,
820 domcdata_get_childNodes,
821 domcdata_get_firstChild,
822 domcdata_get_lastChild,
823 domcdata_get_previousSibling,
824 domcdata_get_nextSibling,
825 domcdata_get_attributes,
826 domcdata_insertBefore,
827 domcdata_replaceChild,
828 domcdata_removeChild,
829 domcdata_appendChild,
830 domcdata_hasChildNodes,
831 domcdata_get_ownerDocument,
832 domcdata_cloneNode,
833 domcdata_get_nodeTypeString,
834 domcdata_get_text,
835 domcdata_put_text,
836 domcdata_get_specified,
837 domcdata_get_definition,
838 domcdata_get_nodeTypedValue,
839 domcdata_put_nodeTypedValue,
840 domcdata_get_dataType,
841 domcdata_put_dataType,
842 domcdata_get_xml,
843 domcdata_transformNode,
844 domcdata_selectNodes,
845 domcdata_selectSingleNode,
846 domcdata_get_parsed,
847 domcdata_get_namespaceURI,
848 domcdata_get_prefix,
849 domcdata_get_baseName,
850 domcdata_transformNodeToObject,
851 domcdata_get_data,
852 domcdata_put_data,
853 domcdata_get_length,
854 domcdata_substringData,
855 domcdata_appendData,
856 domcdata_insertData,
857 domcdata_deleteData,
858 domcdata_replaceData,
859 domcdata_splitText
862 static const tid_t domcdata_iface_tids[] = {
863 IXMLDOMCDATASection_tid,
867 static dispex_static_data_t domcdata_dispex = {
868 NULL,
869 IXMLDOMCDATASection_tid,
870 NULL,
871 domcdata_iface_tids
874 IUnknown* create_cdata( xmlNodePtr text )
876 domcdata *This;
878 This = heap_alloc( sizeof *This );
879 if ( !This )
880 return NULL;
882 This->IXMLDOMCDATASection_iface.lpVtbl = &domcdata_vtbl;
883 This->ref = 1;
885 init_xmlnode(&This->node, text, (IXMLDOMNode*)&This->IXMLDOMCDATASection_iface, &domcdata_dispex);
887 return (IUnknown*)&This->IXMLDOMCDATASection_iface;