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
27 # include <libxml/parser.h>
28 # include <libxml/xmlerror.h>
37 #include "msxml_private.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
45 typedef struct _domcdata
48 IXMLDOMCDATASection IXMLDOMCDATASection_iface
;
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
,
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
) )
73 else if(node_query_interface(&This
->node
, riid
, ppvObject
))
75 return *ppvObject
? S_OK
: E_NOINTERFACE
;
79 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
84 IXMLDOMText_AddRef((IUnknown
*)*ppvObject
);
88 static ULONG WINAPI
domcdata_AddRef(
89 IXMLDOMCDATASection
*iface
)
91 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
92 ULONG ref
= InterlockedIncrement( &This
->ref
);
93 TRACE("(%p)->(%d)\n", This
, ref
);
97 static ULONG WINAPI
domcdata_Release(
98 IXMLDOMCDATASection
*iface
)
100 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
101 ULONG ref
= InterlockedDecrement( &This
->ref
);
103 TRACE("(%p)->(%d)\n", This
, ref
);
106 destroy_xmlnode(&This
->node
);
113 static HRESULT WINAPI
domcdata_GetTypeInfoCount(
114 IXMLDOMCDATASection
*iface
,
117 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
119 TRACE("(%p)->(%p)\n", This
, pctinfo
);
126 static HRESULT WINAPI
domcdata_GetTypeInfo(
127 IXMLDOMCDATASection
*iface
,
128 UINT iTInfo
, LCID lcid
,
129 ITypeInfo
** ppTInfo
)
131 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
134 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
136 hr
= get_typeinfo(IXMLDOMCDATASection_tid
, 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
);
150 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
153 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
156 hr
= get_typeinfo(IXMLDOMCDATASection_tid
, &typeinfo
);
159 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
160 ITypeInfo_Release(typeinfo
);
166 static HRESULT WINAPI
domcdata_Invoke(
167 IXMLDOMCDATASection
*iface
,
168 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
169 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
170 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
172 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
176 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
177 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
179 hr
= get_typeinfo(IXMLDOMCDATASection_tid
, &typeinfo
);
182 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IXMLDOMCDATASection_iface
, dispIdMember
, wFlags
,
183 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
184 ITypeInfo_Release(typeinfo
);
190 static HRESULT WINAPI
domcdata_get_nodeName(
191 IXMLDOMCDATASection
*iface
,
194 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
196 static const WCHAR cdata_sectionW
[] =
197 {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0};
199 TRACE("(%p)->(%p)\n", This
, p
);
201 return return_bstr(cdata_sectionW
, p
);
204 static HRESULT WINAPI
domcdata_get_nodeValue(
205 IXMLDOMCDATASection
*iface
,
208 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
210 TRACE("(%p)->(%p)\n", This
, value
);
212 return node_get_content(&This
->node
, value
);
215 static HRESULT WINAPI
domcdata_put_nodeValue(
216 IXMLDOMCDATASection
*iface
,
219 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
221 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&value
));
223 return node_put_value(&This
->node
, &value
);
226 static HRESULT WINAPI
domcdata_get_nodeType(
227 IXMLDOMCDATASection
*iface
,
228 DOMNodeType
* domNodeType
)
230 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
232 TRACE("(%p)->(%p)\n", This
, domNodeType
);
234 *domNodeType
= NODE_CDATA_SECTION
;
238 static HRESULT WINAPI
domcdata_get_parentNode(
239 IXMLDOMCDATASection
*iface
,
240 IXMLDOMNode
** parent
)
242 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
244 TRACE("(%p)->(%p)\n", This
, parent
);
246 return node_get_parent(&This
->node
, parent
);
249 static HRESULT WINAPI
domcdata_get_childNodes(
250 IXMLDOMCDATASection
*iface
,
251 IXMLDOMNodeList
** outList
)
253 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
255 TRACE("(%p)->(%p)\n", This
, outList
);
257 return node_get_child_nodes(&This
->node
, outList
);
260 static HRESULT WINAPI
domcdata_get_firstChild(
261 IXMLDOMCDATASection
*iface
,
262 IXMLDOMNode
** domNode
)
264 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
266 TRACE("(%p)->(%p)\n", This
, domNode
);
268 return return_null_node(domNode
);
271 static HRESULT WINAPI
domcdata_get_lastChild(
272 IXMLDOMCDATASection
*iface
,
273 IXMLDOMNode
** domNode
)
275 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
277 TRACE("(%p)->(%p)\n", This
, domNode
);
279 return return_null_node(domNode
);
282 static HRESULT WINAPI
domcdata_get_previousSibling(
283 IXMLDOMCDATASection
*iface
,
284 IXMLDOMNode
** domNode
)
286 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
288 TRACE("(%p)->(%p)\n", This
, domNode
);
290 return node_get_previous_sibling(&This
->node
, domNode
);
293 static HRESULT WINAPI
domcdata_get_nextSibling(
294 IXMLDOMCDATASection
*iface
,
295 IXMLDOMNode
** domNode
)
297 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
299 TRACE("(%p)->(%p)\n", This
, domNode
);
301 return node_get_next_sibling(&This
->node
, domNode
);
304 static HRESULT WINAPI
domcdata_get_attributes(
305 IXMLDOMCDATASection
*iface
,
306 IXMLDOMNamedNodeMap
** attributeMap
)
308 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
310 TRACE("(%p)->(%p)\n", This
, attributeMap
);
312 return return_null_ptr((void**)attributeMap
);
315 static HRESULT WINAPI
domcdata_insertBefore(
316 IXMLDOMCDATASection
*iface
,
317 IXMLDOMNode
* newNode
, VARIANT refChild
,
318 IXMLDOMNode
** outOldNode
)
320 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
322 FIXME("(%p)->(%p %s %p) needs test\n", This
, newNode
, debugstr_variant(&refChild
), outOldNode
);
324 return node_insert_before(&This
->node
, newNode
, &refChild
, outOldNode
);
327 static HRESULT WINAPI
domcdata_replaceChild(
328 IXMLDOMCDATASection
*iface
,
329 IXMLDOMNode
* newNode
,
330 IXMLDOMNode
* oldNode
,
331 IXMLDOMNode
** outOldNode
)
333 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
335 FIXME("(%p)->(%p %p %p) needs tests\n", This
, newNode
, oldNode
, outOldNode
);
337 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
340 static HRESULT WINAPI
domcdata_removeChild(
341 IXMLDOMCDATASection
*iface
,
342 IXMLDOMNode
*child
, IXMLDOMNode
**oldChild
)
344 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
345 TRACE("(%p)->(%p %p)\n", This
, child
, oldChild
);
346 return node_remove_child(&This
->node
, child
, oldChild
);
349 static HRESULT WINAPI
domcdata_appendChild(
350 IXMLDOMCDATASection
*iface
,
351 IXMLDOMNode
*child
, IXMLDOMNode
**outChild
)
353 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
354 TRACE("(%p)->(%p %p)\n", This
, child
, outChild
);
355 return node_append_child(&This
->node
, child
, outChild
);
358 static HRESULT WINAPI
domcdata_hasChildNodes(
359 IXMLDOMCDATASection
*iface
,
362 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
363 TRACE("(%p)->(%p)\n", This
, ret
);
364 return node_has_childnodes(&This
->node
, ret
);
367 static HRESULT WINAPI
domcdata_get_ownerDocument(
368 IXMLDOMCDATASection
*iface
,
369 IXMLDOMDocument
**doc
)
371 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
372 TRACE("(%p)->(%p)\n", This
, doc
);
373 return node_get_owner_doc(&This
->node
, doc
);
376 static HRESULT WINAPI
domcdata_cloneNode(
377 IXMLDOMCDATASection
*iface
,
378 VARIANT_BOOL deep
, IXMLDOMNode
** outNode
)
380 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
381 TRACE("(%p)->(%d %p)\n", This
, deep
, outNode
);
382 return node_clone( &This
->node
, deep
, outNode
);
385 static HRESULT WINAPI
domcdata_get_nodeTypeString(
386 IXMLDOMCDATASection
*iface
,
389 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
390 static const WCHAR cdatasectionW
[] = {'c','d','a','t','a','s','e','c','t','i','o','n',0};
392 TRACE("(%p)->(%p)\n", This
, p
);
394 return return_bstr(cdatasectionW
, p
);
397 static HRESULT WINAPI
domcdata_get_text(
398 IXMLDOMCDATASection
*iface
,
401 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
402 TRACE("(%p)->(%p)\n", This
, p
);
403 return node_get_text(&This
->node
, p
);
406 static HRESULT WINAPI
domcdata_put_text(
407 IXMLDOMCDATASection
*iface
,
410 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
411 TRACE("(%p)->(%p)\n", This
, debugstr_w(p
));
412 return node_put_text( &This
->node
, p
);
415 static HRESULT WINAPI
domcdata_get_specified(
416 IXMLDOMCDATASection
*iface
,
417 VARIANT_BOOL
* isSpecified
)
419 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
420 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
421 *isSpecified
= VARIANT_TRUE
;
425 static HRESULT WINAPI
domcdata_get_definition(
426 IXMLDOMCDATASection
*iface
,
427 IXMLDOMNode
** definitionNode
)
429 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
430 FIXME("(%p)->(%p)\n", This
, definitionNode
);
434 static HRESULT WINAPI
domcdata_get_nodeTypedValue(
435 IXMLDOMCDATASection
*iface
,
438 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
439 TRACE("(%p)->(%p)\n", This
, v
);
440 return node_get_content(&This
->node
, v
);
443 static HRESULT WINAPI
domcdata_put_nodeTypedValue(
444 IXMLDOMCDATASection
*iface
,
447 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
448 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&typedValue
));
452 static HRESULT WINAPI
domcdata_get_dataType(
453 IXMLDOMCDATASection
*iface
,
456 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
457 TRACE("(%p)->(%p)\n", This
, typename
);
458 return return_null_var( typename
);
461 static HRESULT WINAPI
domcdata_put_dataType(
462 IXMLDOMCDATASection
*iface
,
465 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
467 FIXME("(%p)->(%s)\n", This
, debugstr_w(p
));
475 static HRESULT WINAPI
domcdata_get_xml(
476 IXMLDOMCDATASection
*iface
,
479 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
481 TRACE("(%p)->(%p)\n", This
, p
);
483 return node_get_xml(&This
->node
, FALSE
, FALSE
, p
);
486 static HRESULT WINAPI
domcdata_transformNode(
487 IXMLDOMCDATASection
*iface
,
488 IXMLDOMNode
*node
, BSTR
*p
)
490 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
491 TRACE("(%p)->(%p %p)\n", This
, node
, p
);
492 return node_transform_node(&This
->node
, node
, p
);
495 static HRESULT WINAPI
domcdata_selectNodes(
496 IXMLDOMCDATASection
*iface
,
497 BSTR p
, IXMLDOMNodeList
** outList
)
499 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
500 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outList
);
501 return node_select_nodes(&This
->node
, p
, outList
);
504 static HRESULT WINAPI
domcdata_selectSingleNode(
505 IXMLDOMCDATASection
*iface
,
506 BSTR p
, IXMLDOMNode
** outNode
)
508 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
509 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outNode
);
510 return node_select_singlenode(&This
->node
, p
, outNode
);
513 static HRESULT WINAPI
domcdata_get_parsed(
514 IXMLDOMCDATASection
*iface
,
515 VARIANT_BOOL
* isParsed
)
517 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
518 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
519 *isParsed
= VARIANT_TRUE
;
523 static HRESULT WINAPI
domcdata_get_namespaceURI(
524 IXMLDOMCDATASection
*iface
,
527 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
528 TRACE("(%p)->(%p)\n", This
, p
);
529 return node_get_namespaceURI(&This
->node
, p
);
532 static HRESULT WINAPI
domcdata_get_prefix(
533 IXMLDOMCDATASection
*iface
,
536 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
537 TRACE("(%p)->(%p)\n", This
, prefix
);
538 return return_null_bstr( prefix
);
541 static HRESULT WINAPI
domcdata_get_baseName(
542 IXMLDOMCDATASection
*iface
,
545 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
546 FIXME("(%p)->(%p): needs test\n", This
, name
);
547 return return_null_bstr( name
);
550 static HRESULT WINAPI
domcdata_transformNodeToObject(
551 IXMLDOMCDATASection
*iface
,
552 IXMLDOMNode
* domNode
, VARIANT var1
)
554 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
555 FIXME("(%p)->(%p %s)\n", This
, domNode
, debugstr_variant(&var1
));
559 static HRESULT WINAPI
domcdata_get_data(
560 IXMLDOMCDATASection
*iface
,
569 hr
= IXMLDOMCDATASection_get_nodeValue( iface
, &vRet
);
578 static HRESULT WINAPI
domcdata_put_data(
579 IXMLDOMCDATASection
*iface
,
582 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
585 TRACE("(%p)->(%s)\n", This
, debugstr_w(data
) );
587 V_VT(&val
) = VT_BSTR
;
590 return IXMLDOMCDATASection_put_nodeValue( iface
, val
);
593 static HRESULT WINAPI
domcdata_get_length(
594 IXMLDOMCDATASection
*iface
,
597 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
601 TRACE("(%p)->(%p)\n", This
, len
);
606 hr
= IXMLDOMCDATASection_get_data(iface
, &data
);
609 *len
= SysStringLen(data
);
616 static HRESULT WINAPI
domcdata_substringData(
617 IXMLDOMCDATASection
*iface
,
618 LONG offset
, LONG count
, BSTR
*p
)
620 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
624 TRACE("(%p)->(%d %d %p)\n", This
, offset
, count
, p
);
630 if(offset
< 0 || count
< 0)
636 hr
= IXMLDOMCDATASection_get_data(iface
, &data
);
639 LONG len
= SysStringLen(data
);
643 if(offset
+ count
> len
)
644 *p
= SysAllocString(&data
[offset
]);
646 *p
= SysAllocStringLen(&data
[offset
], count
);
657 static HRESULT WINAPI
domcdata_appendData(
658 IXMLDOMCDATASection
*iface
,
661 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
666 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
668 /* Nothing to do if NULL or an Empty string passed in. */
669 if((p_len
= SysStringLen(p
)) == 0) return S_OK
;
671 hr
= IXMLDOMCDATASection_get_data(iface
, &data
);
674 LONG len
= SysStringLen(data
);
675 BSTR str
= SysAllocStringLen(NULL
, p_len
+ len
);
677 memcpy(str
, data
, len
*sizeof(WCHAR
));
678 memcpy(&str
[len
], p
, p_len
*sizeof(WCHAR
));
681 hr
= IXMLDOMCDATASection_put_data(iface
, str
);
690 static HRESULT WINAPI
domcdata_insertData(
691 IXMLDOMCDATASection
*iface
,
694 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
699 TRACE("(%p)->(%d %s)\n", This
, offset
, debugstr_w(p
));
701 /* If have a NULL or empty string, don't do anything. */
702 if((p_len
= SysStringLen(p
)) == 0)
710 hr
= IXMLDOMCDATASection_get_data(iface
, &data
);
713 LONG len
= SysStringLen(data
);
722 str
= SysAllocStringLen(NULL
, len
+ p_len
);
723 /* start part, supplied string and end part */
724 memcpy(str
, data
, offset
*sizeof(WCHAR
));
725 memcpy(&str
[offset
], p
, p_len
*sizeof(WCHAR
));
726 memcpy(&str
[offset
+p_len
], &data
[offset
], (len
-offset
)*sizeof(WCHAR
));
729 hr
= IXMLDOMCDATASection_put_data(iface
, str
);
738 static HRESULT WINAPI
domcdata_deleteData(
739 IXMLDOMCDATASection
*iface
,
740 LONG offset
, LONG count
)
742 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
747 TRACE("(%p)->(%d %d)\n", This
, offset
, count
);
749 hr
= IXMLDOMCDATASection_get_length(iface
, &len
);
750 if(hr
!= S_OK
) return hr
;
752 if((offset
< 0) || (offset
> len
) || (count
< 0))
755 if(len
== 0) return S_OK
;
757 /* cutting start or end */
758 if((offset
== 0) || ((count
+ offset
) >= len
))
761 IXMLDOMCDATASection_substringData(iface
, count
, len
- count
, &str
);
763 IXMLDOMCDATASection_substringData(iface
, 0, offset
, &str
);
764 hr
= IXMLDOMCDATASection_put_data(iface
, str
);
767 /* cutting from the inside */
771 IXMLDOMCDATASection_substringData(iface
, 0, offset
, &str
);
772 IXMLDOMCDATASection_substringData(iface
, offset
+ count
, len
- count
, &str_end
);
774 hr
= IXMLDOMCDATASection_put_data(iface
, str
);
776 hr
= IXMLDOMCDATASection_appendData(iface
, str_end
);
778 SysFreeString(str_end
);
786 static HRESULT WINAPI
domcdata_replaceData(
787 IXMLDOMCDATASection
*iface
,
788 LONG offset
, LONG count
, BSTR p
)
790 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
793 TRACE("(%p)->(%d %d %s)\n", This
, offset
, count
, debugstr_w(p
));
795 hr
= IXMLDOMCDATASection_deleteData(iface
, offset
, count
);
798 hr
= IXMLDOMCDATASection_insertData(iface
, offset
, p
);
803 static HRESULT WINAPI
domcdata_splitText(
804 IXMLDOMCDATASection
*iface
,
805 LONG offset
, IXMLDOMText
**txtNode
)
807 domcdata
*This
= impl_from_IXMLDOMCDATASection( iface
);
808 IXMLDOMDocument
*doc
;
812 TRACE("(%p)->(%d %p)\n", This
, offset
, txtNode
);
814 if (!txtNode
|| offset
< 0) return E_INVALIDARG
;
818 IXMLDOMCDATASection_get_length(iface
, &length
);
820 if (offset
> length
) return E_INVALIDARG
;
821 if (offset
== length
) return S_FALSE
;
823 hr
= IXMLDOMCDATASection_get_ownerDocument(iface
, &doc
);
828 hr
= IXMLDOMCDATASection_substringData(iface
, offset
, length
- offset
, &data
);
831 hr
= IXMLDOMDocument_createTextNode(doc
, data
, txtNode
);
836 hr
= IXMLDOMCDATASection_get_parentNode(iface
, &parent
);
839 IXMLDOMCDATASection_deleteData(iface
, 0, offset
);
840 hr
= IXMLDOMNode_appendChild(parent
, (IXMLDOMNode
*)*txtNode
, NULL
);
841 IXMLDOMNode_Release(parent
);
846 IXMLDOMDocument_Release(doc
);
852 static const struct IXMLDOMCDATASectionVtbl domcdata_vtbl
=
854 domcdata_QueryInterface
,
857 domcdata_GetTypeInfoCount
,
858 domcdata_GetTypeInfo
,
859 domcdata_GetIDsOfNames
,
861 domcdata_get_nodeName
,
862 domcdata_get_nodeValue
,
863 domcdata_put_nodeValue
,
864 domcdata_get_nodeType
,
865 domcdata_get_parentNode
,
866 domcdata_get_childNodes
,
867 domcdata_get_firstChild
,
868 domcdata_get_lastChild
,
869 domcdata_get_previousSibling
,
870 domcdata_get_nextSibling
,
871 domcdata_get_attributes
,
872 domcdata_insertBefore
,
873 domcdata_replaceChild
,
874 domcdata_removeChild
,
875 domcdata_appendChild
,
876 domcdata_hasChildNodes
,
877 domcdata_get_ownerDocument
,
879 domcdata_get_nodeTypeString
,
882 domcdata_get_specified
,
883 domcdata_get_definition
,
884 domcdata_get_nodeTypedValue
,
885 domcdata_put_nodeTypedValue
,
886 domcdata_get_dataType
,
887 domcdata_put_dataType
,
889 domcdata_transformNode
,
890 domcdata_selectNodes
,
891 domcdata_selectSingleNode
,
893 domcdata_get_namespaceURI
,
895 domcdata_get_baseName
,
896 domcdata_transformNodeToObject
,
900 domcdata_substringData
,
904 domcdata_replaceData
,
908 static const tid_t domcdata_iface_tids
[] = {
909 IXMLDOMCDATASection_tid
,
913 static dispex_static_data_t domcdata_dispex
= {
915 IXMLDOMCDATASection_tid
,
920 IUnknown
* create_cdata( xmlNodePtr text
)
924 This
= heap_alloc( sizeof *This
);
928 This
->IXMLDOMCDATASection_iface
.lpVtbl
= &domcdata_vtbl
;
931 init_xmlnode(&This
->node
, text
, (IXMLDOMNode
*)&This
->IXMLDOMCDATASection_iface
, &domcdata_dispex
);
933 return (IUnknown
*)&This
->IXMLDOMCDATASection_iface
;