wined3d: Get rid of the WINED3DADAPTER_IDENTIFIER typedef.
[wine/multimedia.git] / dlls / msxml3 / text.c
blob654077363b003ae5889e9139b3964c12ec80b91f
1 /*
2 * DOM text node implementation
4 * Copyright 2006 Huw Davies
5 * Copyright 2007-2008 Alistair Leslie-Hughes
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define COBJMACROS
24 #include "config.h"
26 #include <stdarg.h>
27 #ifdef HAVE_LIBXML2
28 # include <libxml/parser.h>
29 # include <libxml/xmlerror.h>
30 #endif
32 #include "windef.h"
33 #include "winbase.h"
34 #include "winuser.h"
35 #include "ole2.h"
36 #include "msxml6.h"
38 #include "msxml_private.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
44 #ifdef HAVE_LIBXML2
46 typedef struct _domtext
48 xmlnode node;
49 IXMLDOMText IXMLDOMText_iface;
50 LONG ref;
51 } domtext;
53 static inline domtext *impl_from_IXMLDOMText( IXMLDOMText *iface )
55 return CONTAINING_RECORD(iface, domtext, IXMLDOMText_iface);
58 static HRESULT WINAPI domtext_QueryInterface(
59 IXMLDOMText *iface,
60 REFIID riid,
61 void** ppvObject )
63 domtext *This = impl_from_IXMLDOMText( iface );
64 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
66 if ( IsEqualGUID( riid, &IID_IXMLDOMText ) ||
67 IsEqualGUID( riid, &IID_IXMLDOMCharacterData) ||
68 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
69 IsEqualGUID( riid, &IID_IDispatch ) ||
70 IsEqualGUID( riid, &IID_IUnknown ) )
72 *ppvObject = iface;
74 else if(node_query_interface(&This->node, riid, ppvObject))
76 return *ppvObject ? S_OK : E_NOINTERFACE;
78 else
80 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
81 *ppvObject = NULL;
82 return E_NOINTERFACE;
85 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
86 return S_OK;
89 static ULONG WINAPI domtext_AddRef(
90 IXMLDOMText *iface )
92 domtext *This = impl_from_IXMLDOMText( iface );
93 ULONG ref = InterlockedIncrement( &This->ref );
94 TRACE("(%p)->(%d)\n", This, ref);
95 return ref;
98 static ULONG WINAPI domtext_Release(
99 IXMLDOMText *iface )
101 domtext *This = impl_from_IXMLDOMText( iface );
102 ULONG ref = InterlockedDecrement( &This->ref );
104 TRACE("(%p)->(%d)\n", This, ref);
105 if ( ref == 0 )
107 destroy_xmlnode(&This->node);
108 heap_free( This );
111 return ref;
114 static HRESULT WINAPI domtext_GetTypeInfoCount(
115 IXMLDOMText *iface,
116 UINT* pctinfo )
118 domtext *This = impl_from_IXMLDOMText( iface );
119 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
122 static HRESULT WINAPI domtext_GetTypeInfo(
123 IXMLDOMText *iface,
124 UINT iTInfo, LCID lcid,
125 ITypeInfo** ppTInfo )
127 domtext *This = impl_from_IXMLDOMText( iface );
128 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface,
129 iTInfo, lcid, ppTInfo);
132 static HRESULT WINAPI domtext_GetIDsOfNames(
133 IXMLDOMText *iface,
134 REFIID riid, LPOLESTR* rgszNames,
135 UINT cNames, LCID lcid, DISPID* rgDispId )
137 domtext *This = impl_from_IXMLDOMText( iface );
138 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface,
139 riid, rgszNames, cNames, lcid, rgDispId);
142 static HRESULT WINAPI domtext_Invoke(
143 IXMLDOMText *iface,
144 DISPID dispIdMember, REFIID riid, LCID lcid,
145 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
146 EXCEPINFO* pExcepInfo, UINT* puArgErr )
148 domtext *This = impl_from_IXMLDOMText( iface );
149 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface,
150 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
153 static HRESULT WINAPI domtext_get_nodeName(
154 IXMLDOMText *iface,
155 BSTR* p )
157 domtext *This = impl_from_IXMLDOMText( iface );
159 static const WCHAR textW[] = {'#','t','e','x','t',0};
161 TRACE("(%p)->(%p)\n", This, p);
163 return return_bstr(textW, p);
166 static HRESULT WINAPI domtext_get_nodeValue(
167 IXMLDOMText *iface,
168 VARIANT* value )
170 domtext *This = impl_from_IXMLDOMText( iface );
172 TRACE("(%p)->(%p)\n", This, value);
174 if(!value)
175 return E_INVALIDARG;
177 V_VT(value) = VT_BSTR;
178 V_BSTR(value) = bstr_from_xmlChar(This->node.node->content);
179 return S_OK;
182 static HRESULT WINAPI domtext_put_nodeValue(
183 IXMLDOMText *iface,
184 VARIANT value)
186 domtext *This = impl_from_IXMLDOMText( iface );
188 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
190 return node_put_value(&This->node, &value);
193 static HRESULT WINAPI domtext_get_nodeType(
194 IXMLDOMText *iface,
195 DOMNodeType* domNodeType )
197 domtext *This = impl_from_IXMLDOMText( iface );
199 TRACE("(%p)->(%p)\n", This, domNodeType);
201 *domNodeType = NODE_TEXT;
202 return S_OK;
205 static HRESULT WINAPI domtext_get_parentNode(
206 IXMLDOMText *iface,
207 IXMLDOMNode** parent )
209 domtext *This = impl_from_IXMLDOMText( iface );
211 TRACE("(%p)->(%p)\n", This, parent);
213 return node_get_parent(&This->node, parent);
216 static HRESULT WINAPI domtext_get_childNodes(
217 IXMLDOMText *iface,
218 IXMLDOMNodeList** outList)
220 domtext *This = impl_from_IXMLDOMText( iface );
222 TRACE("(%p)->(%p)\n", This, outList);
224 return node_get_child_nodes(&This->node, outList);
227 static HRESULT WINAPI domtext_get_firstChild(
228 IXMLDOMText *iface,
229 IXMLDOMNode** domNode)
231 domtext *This = impl_from_IXMLDOMText( iface );
233 TRACE("(%p)->(%p)\n", This, domNode);
235 return return_null_node(domNode);
238 static HRESULT WINAPI domtext_get_lastChild(
239 IXMLDOMText *iface,
240 IXMLDOMNode** domNode)
242 domtext *This = impl_from_IXMLDOMText( iface );
244 TRACE("(%p)->(%p)\n", This, domNode);
246 return return_null_node(domNode);
249 static HRESULT WINAPI domtext_get_previousSibling(
250 IXMLDOMText *iface,
251 IXMLDOMNode** domNode)
253 domtext *This = impl_from_IXMLDOMText( iface );
255 TRACE("(%p)->(%p)\n", This, domNode);
257 return node_get_previous_sibling(&This->node, domNode);
260 static HRESULT WINAPI domtext_get_nextSibling(
261 IXMLDOMText *iface,
262 IXMLDOMNode** domNode)
264 domtext *This = impl_from_IXMLDOMText( iface );
266 TRACE("(%p)->(%p)\n", This, domNode);
268 return node_get_next_sibling(&This->node, domNode);
271 static HRESULT WINAPI domtext_get_attributes(
272 IXMLDOMText *iface,
273 IXMLDOMNamedNodeMap** attributeMap)
275 domtext *This = impl_from_IXMLDOMText( iface );
277 TRACE("(%p)->(%p)\n", This, attributeMap);
279 return return_null_ptr((void**)attributeMap);
282 static HRESULT WINAPI domtext_insertBefore(
283 IXMLDOMText *iface,
284 IXMLDOMNode* newNode, VARIANT refChild,
285 IXMLDOMNode** outOldNode)
287 domtext *This = impl_from_IXMLDOMText( iface );
289 FIXME("(%p)->(%p %s %p) needs test\n", This, newNode, debugstr_variant(&refChild), outOldNode);
291 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
294 static HRESULT WINAPI domtext_replaceChild(
295 IXMLDOMText *iface,
296 IXMLDOMNode* newNode,
297 IXMLDOMNode* oldNode,
298 IXMLDOMNode** outOldNode)
300 domtext *This = impl_from_IXMLDOMText( iface );
302 FIXME("(%p)->(%p %p %p) needs test\n", This, newNode, oldNode, outOldNode);
304 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
307 static HRESULT WINAPI domtext_removeChild(
308 IXMLDOMText *iface,
309 IXMLDOMNode *child, IXMLDOMNode **oldChild)
311 domtext *This = impl_from_IXMLDOMText( iface );
312 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
313 return node_remove_child(&This->node, child, oldChild);
316 static HRESULT WINAPI domtext_appendChild(
317 IXMLDOMText *iface,
318 IXMLDOMNode *child, IXMLDOMNode **outChild)
320 domtext *This = impl_from_IXMLDOMText( iface );
321 TRACE("(%p)->(%p %p)\n", This, child, outChild);
322 return node_append_child(&This->node, child, outChild);
325 static HRESULT WINAPI domtext_hasChildNodes(
326 IXMLDOMText *iface,
327 VARIANT_BOOL *ret)
329 domtext *This = impl_from_IXMLDOMText( iface );
330 TRACE("(%p)->(%p)\n", This, ret);
331 return node_has_childnodes(&This->node, ret);
334 static HRESULT WINAPI domtext_get_ownerDocument(
335 IXMLDOMText *iface,
336 IXMLDOMDocument **doc)
338 domtext *This = impl_from_IXMLDOMText( iface );
339 TRACE("(%p)->(%p)\n", This, doc);
340 return node_get_owner_doc(&This->node, doc);
343 static HRESULT WINAPI domtext_cloneNode(
344 IXMLDOMText *iface,
345 VARIANT_BOOL deep, IXMLDOMNode** outNode)
347 domtext *This = impl_from_IXMLDOMText( iface );
348 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
349 return node_clone( &This->node, deep, outNode );
352 static HRESULT WINAPI domtext_get_nodeTypeString(
353 IXMLDOMText *iface,
354 BSTR* p)
356 domtext *This = impl_from_IXMLDOMText( iface );
357 static const WCHAR textW[] = {'t','e','x','t',0};
359 TRACE("(%p)->(%p)\n", This, p);
361 return return_bstr(textW, p);
364 static HRESULT WINAPI domtext_get_text(
365 IXMLDOMText *iface,
366 BSTR* p)
368 domtext *This = impl_from_IXMLDOMText( iface );
369 TRACE("(%p)->(%p)\n", This, p);
370 return node_get_text(&This->node, p);
373 static HRESULT WINAPI domtext_put_text(
374 IXMLDOMText *iface,
375 BSTR p)
377 domtext *This = impl_from_IXMLDOMText( iface );
378 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
379 return node_put_text( &This->node, p );
382 static HRESULT WINAPI domtext_get_specified(
383 IXMLDOMText *iface,
384 VARIANT_BOOL* isSpecified)
386 domtext *This = impl_from_IXMLDOMText( iface );
387 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
388 *isSpecified = VARIANT_TRUE;
389 return S_OK;
392 static HRESULT WINAPI domtext_get_definition(
393 IXMLDOMText *iface,
394 IXMLDOMNode** definitionNode)
396 domtext *This = impl_from_IXMLDOMText( iface );
397 FIXME("(%p)->(%p)\n", This, definitionNode);
398 return E_NOTIMPL;
401 static HRESULT WINAPI domtext_get_nodeTypedValue(
402 IXMLDOMText *iface,
403 VARIANT* var1)
405 domtext *This = impl_from_IXMLDOMText( iface );
406 IXMLDOMNode* parent = NULL;
407 HRESULT hr;
409 TRACE("(%p)->(%p)\n", This, var1);
411 if (!var1)
412 return E_INVALIDARG;
414 hr = domtext_get_parentNode(iface, &parent);
416 if (hr == S_OK)
418 hr = IXMLDOMNode_get_nodeTypedValue(parent, var1);
419 IXMLDOMNode_Release(parent);
421 else
423 V_VT(var1) = VT_NULL;
424 V_BSTR(var1) = NULL;
425 hr = S_FALSE;
428 return hr;
431 static HRESULT WINAPI domtext_put_nodeTypedValue(
432 IXMLDOMText *iface,
433 VARIANT value)
435 domtext *This = impl_from_IXMLDOMText( iface );
436 IXMLDOMNode* parent = NULL;
437 HRESULT hr;
439 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
441 hr = domtext_get_parentNode(iface, &parent);
443 if (hr == S_OK)
445 hr = IXMLDOMNode_put_nodeTypedValue(parent, value);
446 IXMLDOMNode_Release(parent);
448 else
450 hr = S_FALSE;
453 return hr;
456 static HRESULT WINAPI domtext_get_dataType(
457 IXMLDOMText *iface,
458 VARIANT* dtName)
460 domtext *This = impl_from_IXMLDOMText( iface );
461 IXMLDOMNode* parent = NULL;
462 HRESULT hr;
464 TRACE("(%p)->(%p)\n", This, dtName);
466 if (!dtName)
467 return E_INVALIDARG;
469 hr = domtext_get_parentNode(iface, &parent);
471 if (hr == S_OK)
473 hr = IXMLDOMNode_get_dataType(parent, dtName);
474 IXMLDOMNode_Release(parent);
476 else
478 V_VT(dtName) = VT_NULL;
479 V_BSTR(dtName) = NULL;
480 hr = S_FALSE;
483 return hr;
486 static HRESULT WINAPI domtext_put_dataType(
487 IXMLDOMText *iface,
488 BSTR dtName)
490 domtext *This = impl_from_IXMLDOMText( iface );
491 IXMLDOMNode* parent = NULL;
492 HRESULT hr;
494 TRACE("(%p)->(%p)\n", This, dtName);
496 if (!dtName)
497 return E_INVALIDARG;
499 hr = domtext_get_parentNode(iface, &parent);
501 if (hr == S_OK)
503 hr = IXMLDOMNode_put_dataType(parent, dtName);
504 IXMLDOMNode_Release(parent);
506 else
508 hr = S_FALSE;
511 return hr;
514 static HRESULT WINAPI domtext_get_xml(
515 IXMLDOMText *iface,
516 BSTR* p)
518 domtext *This = impl_from_IXMLDOMText( iface );
520 TRACE("(%p)->(%p)\n", This, p);
522 return node_get_xml(&This->node, FALSE, FALSE, p);
525 static HRESULT WINAPI domtext_transformNode(
526 IXMLDOMText *iface,
527 IXMLDOMNode *node, BSTR *p)
529 domtext *This = impl_from_IXMLDOMText( iface );
530 TRACE("(%p)->(%p %p)\n", This, node, p);
531 return node_transform_node(&This->node, node, p);
534 static HRESULT WINAPI domtext_selectNodes(
535 IXMLDOMText *iface,
536 BSTR p, IXMLDOMNodeList** outList)
538 domtext *This = impl_from_IXMLDOMText( iface );
539 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
540 return node_select_nodes(&This->node, p, outList);
543 static HRESULT WINAPI domtext_selectSingleNode(
544 IXMLDOMText *iface,
545 BSTR p, IXMLDOMNode** outNode)
547 domtext *This = impl_from_IXMLDOMText( iface );
548 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
549 return node_select_singlenode(&This->node, p, outNode);
552 static HRESULT WINAPI domtext_get_parsed(
553 IXMLDOMText *iface,
554 VARIANT_BOOL* isParsed)
556 domtext *This = impl_from_IXMLDOMText( iface );
557 FIXME("(%p)->(%p) stub!\n", This, isParsed);
558 *isParsed = VARIANT_TRUE;
559 return S_OK;
562 static HRESULT WINAPI domtext_get_namespaceURI(
563 IXMLDOMText *iface,
564 BSTR* p)
566 domtext *This = impl_from_IXMLDOMText( iface );
567 TRACE("(%p)->(%p)\n", This, p);
568 return node_get_namespaceURI(&This->node, p);
571 static HRESULT WINAPI domtext_get_prefix(
572 IXMLDOMText *iface,
573 BSTR* prefix)
575 domtext *This = impl_from_IXMLDOMText( iface );
576 TRACE("(%p)->(%p)\n", This, prefix);
577 return return_null_bstr( prefix );
580 static HRESULT WINAPI domtext_get_baseName(
581 IXMLDOMText *iface,
582 BSTR* name)
584 domtext *This = impl_from_IXMLDOMText( iface );
585 TRACE("(%p)->(%p)\n", This, name);
586 return return_null_bstr( name );
589 static HRESULT WINAPI domtext_transformNodeToObject(
590 IXMLDOMText *iface,
591 IXMLDOMNode* domNode, VARIANT var1)
593 domtext *This = impl_from_IXMLDOMText( iface );
594 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
595 return E_NOTIMPL;
598 static HRESULT WINAPI domtext_get_data(
599 IXMLDOMText *iface,
600 BSTR *p)
602 domtext *This = impl_from_IXMLDOMText( iface );
604 if(!p)
605 return E_INVALIDARG;
607 *p = bstr_from_xmlChar(This->node.node->content);
608 return S_OK;
611 static HRESULT WINAPI domtext_put_data(
612 IXMLDOMText *iface,
613 BSTR data)
615 domtext *This = impl_from_IXMLDOMText( iface );
616 VARIANT val;
618 TRACE("(%p)->(%s)\n", This, debugstr_w(data) );
620 V_VT(&val) = VT_BSTR;
621 V_BSTR(&val) = data;
622 return node_put_value(&This->node, &val);
625 static HRESULT WINAPI domtext_get_length(
626 IXMLDOMText *iface,
627 LONG *len)
629 domtext *This = impl_from_IXMLDOMText( iface );
630 HRESULT hr;
631 BSTR data;
633 TRACE("(%p)->(%p)\n", This, len);
635 if(!len)
636 return E_INVALIDARG;
638 hr = IXMLDOMText_get_data(iface, &data);
639 if(hr == S_OK)
641 *len = SysStringLen(data);
642 SysFreeString(data);
645 return hr;
648 static HRESULT WINAPI domtext_substringData(
649 IXMLDOMText *iface,
650 LONG offset, LONG count, BSTR *p)
652 domtext *This = impl_from_IXMLDOMText( iface );
653 HRESULT hr;
654 BSTR data;
656 TRACE("(%p)->(%d %d %p)\n", This, offset, count, p);
658 if(!p)
659 return E_INVALIDARG;
661 *p = NULL;
662 if(offset < 0 || count < 0)
663 return E_INVALIDARG;
665 if(count == 0)
666 return S_FALSE;
668 hr = IXMLDOMText_get_data(iface, &data);
669 if(hr == S_OK)
671 LONG len = SysStringLen(data);
673 if(offset < len)
675 if(offset + count > len)
676 *p = SysAllocString(&data[offset]);
677 else
678 *p = SysAllocStringLen(&data[offset], count);
680 else
681 hr = S_FALSE;
683 SysFreeString(data);
686 return hr;
689 static HRESULT WINAPI domtext_appendData(
690 IXMLDOMText *iface,
691 BSTR p)
693 domtext *This = impl_from_IXMLDOMText( iface );
694 HRESULT hr;
695 BSTR data;
696 LONG p_len;
698 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
700 /* Nothing to do if NULL or an Empty string passed in. */
701 if((p_len = SysStringLen(p)) == 0) return S_OK;
703 hr = IXMLDOMText_get_data(iface, &data);
704 if(hr == S_OK)
706 LONG len = SysStringLen(data);
707 BSTR str = SysAllocStringLen(NULL, p_len + len);
709 memcpy(str, data, len*sizeof(WCHAR));
710 memcpy(&str[len], p, p_len*sizeof(WCHAR));
711 str[len+p_len] = 0;
713 hr = IXMLDOMText_put_data(iface, str);
715 SysFreeString(str);
716 SysFreeString(data);
719 return hr;
722 static HRESULT WINAPI domtext_insertData(
723 IXMLDOMText *iface,
724 LONG offset, BSTR p)
726 domtext *This = impl_from_IXMLDOMText( iface );
727 HRESULT hr;
728 BSTR data;
729 LONG p_len;
731 TRACE("(%p)->(%d %s)\n", This, offset, debugstr_w(p));
733 /* If have a NULL or empty string, don't do anything. */
734 if((p_len = SysStringLen(p)) == 0)
735 return S_OK;
737 if(offset < 0)
739 return E_INVALIDARG;
742 hr = IXMLDOMText_get_data(iface, &data);
743 if(hr == S_OK)
745 LONG len = SysStringLen(data);
746 BSTR str;
748 if(len < offset)
750 SysFreeString(data);
751 return E_INVALIDARG;
754 str = SysAllocStringLen(NULL, len + p_len);
755 /* start part, supplied string and end part */
756 memcpy(str, data, offset*sizeof(WCHAR));
757 memcpy(&str[offset], p, p_len*sizeof(WCHAR));
758 memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR));
759 str[len+p_len] = 0;
761 hr = IXMLDOMText_put_data(iface, str);
763 SysFreeString(str);
764 SysFreeString(data);
767 return hr;
770 static HRESULT WINAPI domtext_deleteData(
771 IXMLDOMText *iface,
772 LONG offset, LONG count)
774 HRESULT hr;
775 LONG len = -1;
776 BSTR str;
778 TRACE("(%p)->(%d %d)\n", iface, offset, count);
780 hr = IXMLDOMText_get_length(iface, &len);
781 if(hr != S_OK) return hr;
783 if((offset < 0) || (offset > len) || (count < 0))
784 return E_INVALIDARG;
786 if(len == 0) return S_OK;
788 /* cutting start or end */
789 if((offset == 0) || ((count + offset) >= len))
791 if(offset == 0)
792 IXMLDOMText_substringData(iface, count, len - count, &str);
793 else
794 IXMLDOMText_substringData(iface, 0, offset, &str);
795 hr = IXMLDOMText_put_data(iface, str);
797 else
798 /* cutting from the inside */
800 BSTR str_end;
802 IXMLDOMText_substringData(iface, 0, offset, &str);
803 IXMLDOMText_substringData(iface, offset + count, len - count, &str_end);
805 hr = IXMLDOMText_put_data(iface, str);
806 if(hr == S_OK)
807 hr = IXMLDOMText_appendData(iface, str_end);
809 SysFreeString(str_end);
812 SysFreeString(str);
814 return hr;
817 static HRESULT WINAPI domtext_replaceData(
818 IXMLDOMText *iface,
819 LONG offset, LONG count, BSTR p)
821 domtext *This = impl_from_IXMLDOMText( iface );
822 HRESULT hr;
824 TRACE("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(p));
826 hr = IXMLDOMText_deleteData(iface, offset, count);
828 if (hr == S_OK)
829 hr = IXMLDOMText_insertData(iface, offset, p);
831 return hr;
834 static HRESULT WINAPI domtext_splitText(
835 IXMLDOMText *iface,
836 LONG offset, IXMLDOMText **txtNode)
838 domtext *This = impl_from_IXMLDOMText( iface );
839 LONG length = 0;
841 TRACE("(%p)->(%d %p)\n", This, offset, txtNode);
843 if (!txtNode || offset < 0) return E_INVALIDARG;
845 *txtNode = NULL;
847 IXMLDOMText_get_length(iface, &length);
849 if (offset > length) return E_INVALIDARG;
850 if (offset == length) return S_FALSE;
852 FIXME("adjacent text nodes are not supported\n");
854 return E_NOTIMPL;
857 static const struct IXMLDOMTextVtbl domtext_vtbl =
859 domtext_QueryInterface,
860 domtext_AddRef,
861 domtext_Release,
862 domtext_GetTypeInfoCount,
863 domtext_GetTypeInfo,
864 domtext_GetIDsOfNames,
865 domtext_Invoke,
866 domtext_get_nodeName,
867 domtext_get_nodeValue,
868 domtext_put_nodeValue,
869 domtext_get_nodeType,
870 domtext_get_parentNode,
871 domtext_get_childNodes,
872 domtext_get_firstChild,
873 domtext_get_lastChild,
874 domtext_get_previousSibling,
875 domtext_get_nextSibling,
876 domtext_get_attributes,
877 domtext_insertBefore,
878 domtext_replaceChild,
879 domtext_removeChild,
880 domtext_appendChild,
881 domtext_hasChildNodes,
882 domtext_get_ownerDocument,
883 domtext_cloneNode,
884 domtext_get_nodeTypeString,
885 domtext_get_text,
886 domtext_put_text,
887 domtext_get_specified,
888 domtext_get_definition,
889 domtext_get_nodeTypedValue,
890 domtext_put_nodeTypedValue,
891 domtext_get_dataType,
892 domtext_put_dataType,
893 domtext_get_xml,
894 domtext_transformNode,
895 domtext_selectNodes,
896 domtext_selectSingleNode,
897 domtext_get_parsed,
898 domtext_get_namespaceURI,
899 domtext_get_prefix,
900 domtext_get_baseName,
901 domtext_transformNodeToObject,
902 domtext_get_data,
903 domtext_put_data,
904 domtext_get_length,
905 domtext_substringData,
906 domtext_appendData,
907 domtext_insertData,
908 domtext_deleteData,
909 domtext_replaceData,
910 domtext_splitText
913 static const tid_t domtext_iface_tids[] = {
914 IXMLDOMText_tid,
918 static dispex_static_data_t domtext_dispex = {
919 NULL,
920 IXMLDOMText_tid,
921 NULL,
922 domtext_iface_tids
925 IUnknown* create_text( xmlNodePtr text )
927 domtext *This;
929 This = heap_alloc( sizeof *This );
930 if ( !This )
931 return NULL;
933 This->IXMLDOMText_iface.lpVtbl = &domtext_vtbl;
934 This->ref = 1;
936 init_xmlnode(&This->node, text, (IXMLDOMNode*)&This->IXMLDOMText_iface, &domtext_dispex);
938 return (IUnknown*)&This->IXMLDOMText_iface;
941 #endif