nsiproxy.sys: Implement change notifications for NSI_IP_UNICAST_TABLE.
[wine.git] / dlls / msxml3 / text.c
blob7631c8595aae1625b1f6ef6e0191c49bcfc15347
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 <stdarg.h>
25 #include <libxml/parser.h>
26 #include <libxml/parserInternals.h>
27 #include <libxml/xmlerror.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "ole2.h"
33 #include "msxml6.h"
35 #include "msxml_private.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
41 typedef struct _domtext
43 xmlnode node;
44 IXMLDOMText IXMLDOMText_iface;
45 LONG ref;
46 } domtext;
48 static inline domtext *impl_from_IXMLDOMText( IXMLDOMText *iface )
50 return CONTAINING_RECORD(iface, domtext, IXMLDOMText_iface);
53 static void domtext_reset_noenc(domtext *This)
55 This->node.node->name = NULL;
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(iface);
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, refcount %lu.\n", iface, 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, refcount %lu.\n", iface, 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 return node_get_content(&This->node, value);
177 static HRESULT WINAPI domtext_put_nodeValue(
178 IXMLDOMText *iface,
179 VARIANT value)
181 domtext *This = impl_from_IXMLDOMText( iface );
183 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
185 domtext_reset_noenc(This);
186 return node_put_value(&This->node, &value);
189 static HRESULT WINAPI domtext_get_nodeType(
190 IXMLDOMText *iface,
191 DOMNodeType* domNodeType )
193 domtext *This = impl_from_IXMLDOMText( iface );
195 TRACE("(%p)->(%p)\n", This, domNodeType);
197 *domNodeType = NODE_TEXT;
198 return S_OK;
201 static HRESULT WINAPI domtext_get_parentNode(
202 IXMLDOMText *iface,
203 IXMLDOMNode** parent )
205 domtext *This = impl_from_IXMLDOMText( iface );
207 TRACE("(%p)->(%p)\n", This, parent);
209 return node_get_parent(&This->node, parent);
212 static HRESULT WINAPI domtext_get_childNodes(
213 IXMLDOMText *iface,
214 IXMLDOMNodeList** outList)
216 domtext *This = impl_from_IXMLDOMText( iface );
218 TRACE("(%p)->(%p)\n", This, outList);
220 return node_get_child_nodes(&This->node, outList);
223 static HRESULT WINAPI domtext_get_firstChild(
224 IXMLDOMText *iface,
225 IXMLDOMNode** domNode)
227 domtext *This = impl_from_IXMLDOMText( iface );
229 TRACE("(%p)->(%p)\n", This, domNode);
231 return return_null_node(domNode);
234 static HRESULT WINAPI domtext_get_lastChild(
235 IXMLDOMText *iface,
236 IXMLDOMNode** domNode)
238 domtext *This = impl_from_IXMLDOMText( iface );
240 TRACE("(%p)->(%p)\n", This, domNode);
242 return return_null_node(domNode);
245 static HRESULT WINAPI domtext_get_previousSibling(
246 IXMLDOMText *iface,
247 IXMLDOMNode** domNode)
249 domtext *This = impl_from_IXMLDOMText( iface );
251 TRACE("(%p)->(%p)\n", This, domNode);
253 return node_get_previous_sibling(&This->node, domNode);
256 static HRESULT WINAPI domtext_get_nextSibling(
257 IXMLDOMText *iface,
258 IXMLDOMNode** domNode)
260 domtext *This = impl_from_IXMLDOMText( iface );
262 TRACE("(%p)->(%p)\n", This, domNode);
264 return node_get_next_sibling(&This->node, domNode);
267 static HRESULT WINAPI domtext_get_attributes(
268 IXMLDOMText *iface,
269 IXMLDOMNamedNodeMap** attributeMap)
271 domtext *This = impl_from_IXMLDOMText( iface );
273 TRACE("(%p)->(%p)\n", This, attributeMap);
275 return return_null_ptr((void**)attributeMap);
278 static HRESULT WINAPI domtext_insertBefore(
279 IXMLDOMText *iface,
280 IXMLDOMNode* newNode, VARIANT refChild,
281 IXMLDOMNode** outOldNode)
283 domtext *This = impl_from_IXMLDOMText( iface );
285 FIXME("(%p)->(%p %s %p) needs test\n", This, newNode, debugstr_variant(&refChild), outOldNode);
287 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
290 static HRESULT WINAPI domtext_replaceChild(
291 IXMLDOMText *iface,
292 IXMLDOMNode* newNode,
293 IXMLDOMNode* oldNode,
294 IXMLDOMNode** outOldNode)
296 domtext *This = impl_from_IXMLDOMText( iface );
298 FIXME("(%p)->(%p %p %p) needs test\n", This, newNode, oldNode, outOldNode);
300 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
303 static HRESULT WINAPI domtext_removeChild(
304 IXMLDOMText *iface,
305 IXMLDOMNode *child, IXMLDOMNode **oldChild)
307 domtext *This = impl_from_IXMLDOMText( iface );
308 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
309 return node_remove_child(&This->node, child, oldChild);
312 static HRESULT WINAPI domtext_appendChild(
313 IXMLDOMText *iface,
314 IXMLDOMNode *child, IXMLDOMNode **outChild)
316 domtext *This = impl_from_IXMLDOMText( iface );
317 TRACE("(%p)->(%p %p)\n", This, child, outChild);
318 return node_append_child(&This->node, child, outChild);
321 static HRESULT WINAPI domtext_hasChildNodes(
322 IXMLDOMText *iface,
323 VARIANT_BOOL *ret)
325 domtext *This = impl_from_IXMLDOMText( iface );
326 TRACE("(%p)->(%p)\n", This, ret);
327 return return_var_false(ret);
330 static HRESULT WINAPI domtext_get_ownerDocument(
331 IXMLDOMText *iface,
332 IXMLDOMDocument **doc)
334 domtext *This = impl_from_IXMLDOMText( iface );
335 TRACE("(%p)->(%p)\n", This, doc);
336 return node_get_owner_doc(&This->node, doc);
339 static HRESULT WINAPI domtext_cloneNode(
340 IXMLDOMText *iface,
341 VARIANT_BOOL deep, IXMLDOMNode** outNode)
343 domtext *This = impl_from_IXMLDOMText( iface );
344 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
345 return node_clone( &This->node, deep, outNode );
348 static HRESULT WINAPI domtext_get_nodeTypeString(
349 IXMLDOMText *iface,
350 BSTR* p)
352 domtext *This = impl_from_IXMLDOMText( iface );
353 static const WCHAR textW[] = {'t','e','x','t',0};
355 TRACE("(%p)->(%p)\n", This, p);
357 return return_bstr(textW, p);
360 static HRESULT WINAPI domtext_get_text(
361 IXMLDOMText *iface,
362 BSTR* p)
364 domtext *This = impl_from_IXMLDOMText( iface );
365 TRACE("(%p)->(%p)\n", This, p);
366 return node_get_text(&This->node, p);
369 static HRESULT WINAPI domtext_put_text(
370 IXMLDOMText *iface,
371 BSTR p)
373 domtext *This = impl_from_IXMLDOMText( iface );
374 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
375 domtext_reset_noenc(This);
376 return node_put_text( &This->node, p );
379 static HRESULT WINAPI domtext_get_specified(
380 IXMLDOMText *iface,
381 VARIANT_BOOL* isSpecified)
383 domtext *This = impl_from_IXMLDOMText( iface );
384 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
385 *isSpecified = VARIANT_TRUE;
386 return S_OK;
389 static HRESULT WINAPI domtext_get_definition(
390 IXMLDOMText *iface,
391 IXMLDOMNode** definitionNode)
393 domtext *This = impl_from_IXMLDOMText( iface );
394 FIXME("(%p)->(%p)\n", This, definitionNode);
395 return E_NOTIMPL;
398 static HRESULT WINAPI domtext_get_nodeTypedValue(
399 IXMLDOMText *iface,
400 VARIANT* var1)
402 domtext *This = impl_from_IXMLDOMText( iface );
403 IXMLDOMNode* parent = NULL;
404 HRESULT hr;
406 TRACE("(%p)->(%p)\n", This, var1);
408 if (!var1)
409 return E_INVALIDARG;
411 hr = IXMLDOMText_get_parentNode(iface, &parent);
413 if (hr == S_OK)
415 hr = IXMLDOMNode_get_nodeTypedValue(parent, var1);
416 IXMLDOMNode_Release(parent);
418 else
420 V_VT(var1) = VT_NULL;
421 V_BSTR(var1) = NULL;
422 hr = S_FALSE;
425 return hr;
428 static HRESULT WINAPI domtext_put_nodeTypedValue(
429 IXMLDOMText *iface,
430 VARIANT value)
432 domtext *This = impl_from_IXMLDOMText( iface );
433 IXMLDOMNode* parent = NULL;
434 HRESULT hr;
436 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
438 hr = IXMLDOMText_get_parentNode(iface, &parent);
440 if (hr == S_OK)
442 hr = IXMLDOMNode_put_nodeTypedValue(parent, value);
443 IXMLDOMNode_Release(parent);
445 else
447 hr = S_FALSE;
450 return hr;
453 static HRESULT WINAPI domtext_get_dataType(
454 IXMLDOMText *iface,
455 VARIANT* dtName)
457 domtext *This = impl_from_IXMLDOMText( iface );
458 IXMLDOMNode* parent = NULL;
459 HRESULT hr;
461 TRACE("(%p)->(%p)\n", This, dtName);
463 if (!dtName)
464 return E_INVALIDARG;
466 hr = IXMLDOMText_get_parentNode(iface, &parent);
468 if (hr == S_OK)
470 hr = IXMLDOMNode_get_dataType(parent, dtName);
471 IXMLDOMNode_Release(parent);
473 else
475 V_VT(dtName) = VT_NULL;
476 V_BSTR(dtName) = NULL;
477 hr = S_FALSE;
480 return hr;
483 static HRESULT WINAPI domtext_put_dataType(
484 IXMLDOMText *iface,
485 BSTR dtName)
487 domtext *This = impl_from_IXMLDOMText( iface );
488 IXMLDOMNode* parent = NULL;
489 HRESULT hr;
491 TRACE("(%p)->(%p)\n", This, dtName);
493 if (!dtName)
494 return E_INVALIDARG;
496 hr = IXMLDOMText_get_parentNode(iface, &parent);
498 if (hr == S_OK)
500 hr = IXMLDOMNode_put_dataType(parent, dtName);
501 IXMLDOMNode_Release(parent);
503 else
505 hr = S_FALSE;
508 return hr;
511 static HRESULT WINAPI domtext_get_xml(
512 IXMLDOMText *iface,
513 BSTR* p)
515 domtext *This = impl_from_IXMLDOMText( iface );
517 TRACE("(%p)->(%p)\n", This, p);
519 return node_get_xml(&This->node, TRUE, p);
522 static HRESULT WINAPI domtext_transformNode(
523 IXMLDOMText *iface,
524 IXMLDOMNode *node, BSTR *p)
526 domtext *This = impl_from_IXMLDOMText( iface );
527 TRACE("(%p)->(%p %p)\n", This, node, p);
528 return node_transform_node(&This->node, node, p);
531 static HRESULT WINAPI domtext_selectNodes(
532 IXMLDOMText *iface,
533 BSTR p, IXMLDOMNodeList** outList)
535 domtext *This = impl_from_IXMLDOMText( iface );
536 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
537 return node_select_nodes(&This->node, p, outList);
540 static HRESULT WINAPI domtext_selectSingleNode(
541 IXMLDOMText *iface,
542 BSTR p, IXMLDOMNode** outNode)
544 domtext *This = impl_from_IXMLDOMText( iface );
545 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
546 return node_select_singlenode(&This->node, p, outNode);
549 static HRESULT WINAPI domtext_get_parsed(
550 IXMLDOMText *iface,
551 VARIANT_BOOL* isParsed)
553 domtext *This = impl_from_IXMLDOMText( iface );
554 FIXME("(%p)->(%p) stub!\n", This, isParsed);
555 *isParsed = VARIANT_TRUE;
556 return S_OK;
559 static HRESULT WINAPI domtext_get_namespaceURI(
560 IXMLDOMText *iface,
561 BSTR* p)
563 domtext *This = impl_from_IXMLDOMText( iface );
564 TRACE("(%p)->(%p)\n", This, p);
565 return node_get_namespaceURI(&This->node, p);
568 static HRESULT WINAPI domtext_get_prefix(
569 IXMLDOMText *iface,
570 BSTR* prefix)
572 domtext *This = impl_from_IXMLDOMText( iface );
573 TRACE("(%p)->(%p)\n", This, prefix);
574 return return_null_bstr( prefix );
577 static HRESULT WINAPI domtext_get_baseName(
578 IXMLDOMText *iface,
579 BSTR* name)
581 domtext *This = impl_from_IXMLDOMText( iface );
582 TRACE("(%p)->(%p)\n", This, name);
583 return return_null_bstr( name );
586 static HRESULT WINAPI domtext_transformNodeToObject(
587 IXMLDOMText *iface,
588 IXMLDOMNode* domNode, VARIANT var1)
590 domtext *This = impl_from_IXMLDOMText( iface );
591 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
592 return E_NOTIMPL;
595 static HRESULT WINAPI domtext_get_data(
596 IXMLDOMText *iface,
597 BSTR *p)
599 domtext *This = impl_from_IXMLDOMText( iface );
601 if(!p)
602 return E_INVALIDARG;
604 *p = bstr_from_xmlChar(This->node.node->content);
605 return S_OK;
608 static HRESULT WINAPI domtext_put_data(
609 IXMLDOMText *iface,
610 BSTR data)
612 domtext *This = impl_from_IXMLDOMText( iface );
613 BSTR normalized_data = NULL;
614 HRESULT hr;
615 size_t i, j;
617 TRACE("(%p)->(%s)\n", This, debugstr_w(data));
619 if (data)
621 /* normalize line endings */
622 normalized_data = SysAllocStringLen(NULL, SysStringLen(data));
623 if (!normalized_data) return E_OUTOFMEMORY;
624 for (i = 0, j = 0; data[i]; i++)
626 if (data[i] == '\r')
628 if (data[i + 1] == '\n') i++; /* change \r\n to just \n */
629 normalized_data[j++] = '\n'; /* change \r by itself to \n */
631 else
632 normalized_data[j++] = data[i];
634 normalized_data[j] = 0;
637 domtext_reset_noenc(This);
638 hr = node_set_content(&This->node, normalized_data);
640 SysFreeString(normalized_data);
641 return hr;
644 static HRESULT WINAPI domtext_get_length(
645 IXMLDOMText *iface,
646 LONG *len)
648 domtext *This = impl_from_IXMLDOMText( iface );
649 HRESULT hr;
650 BSTR data;
652 TRACE("(%p)->(%p)\n", This, len);
654 if(!len)
655 return E_INVALIDARG;
657 hr = IXMLDOMText_get_data(iface, &data);
658 if(hr == S_OK)
660 *len = SysStringLen(data);
661 SysFreeString(data);
664 return hr;
667 static HRESULT WINAPI domtext_substringData(
668 IXMLDOMText *iface,
669 LONG offset, LONG count, BSTR *p)
671 HRESULT hr;
672 BSTR data;
674 TRACE("%p, %ld, %ld, %p.\n", iface, offset, count, p);
676 if(!p)
677 return E_INVALIDARG;
679 *p = NULL;
680 if(offset < 0 || count < 0)
681 return E_INVALIDARG;
683 if(count == 0)
684 return S_FALSE;
686 hr = IXMLDOMText_get_data(iface, &data);
687 if(hr == S_OK)
689 LONG len = SysStringLen(data);
691 if(offset < len)
693 if(offset + count > len)
694 *p = SysAllocString(&data[offset]);
695 else
696 *p = SysAllocStringLen(&data[offset], count);
698 else
699 hr = S_FALSE;
701 SysFreeString(data);
704 return hr;
707 static HRESULT WINAPI domtext_appendData(
708 IXMLDOMText *iface,
709 BSTR p)
711 domtext *This = impl_from_IXMLDOMText( iface );
712 HRESULT hr;
713 BSTR data;
714 LONG p_len;
716 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
718 /* Nothing to do if NULL or an Empty string passed in. */
719 if((p_len = SysStringLen(p)) == 0) return S_OK;
721 hr = IXMLDOMText_get_data(iface, &data);
722 if(hr == S_OK)
724 LONG len = SysStringLen(data);
725 BSTR str = SysAllocStringLen(NULL, p_len + len);
727 memcpy(str, data, len*sizeof(WCHAR));
728 memcpy(&str[len], p, p_len*sizeof(WCHAR));
729 str[len+p_len] = 0;
731 hr = IXMLDOMText_put_data(iface, str);
733 SysFreeString(str);
734 SysFreeString(data);
737 return hr;
740 static HRESULT WINAPI domtext_insertData(
741 IXMLDOMText *iface,
742 LONG offset, BSTR p)
744 HRESULT hr;
745 BSTR data;
746 LONG p_len;
748 TRACE("%p, %ld, %s.\n", iface, offset, debugstr_w(p));
750 /* If have a NULL or empty string, don't do anything. */
751 if((p_len = SysStringLen(p)) == 0)
752 return S_OK;
754 if(offset < 0)
756 return E_INVALIDARG;
759 hr = IXMLDOMText_get_data(iface, &data);
760 if(hr == S_OK)
762 LONG len = SysStringLen(data);
763 BSTR str;
765 if(len < offset)
767 SysFreeString(data);
768 return E_INVALIDARG;
771 str = SysAllocStringLen(NULL, len + p_len);
772 /* start part, supplied string and end part */
773 memcpy(str, data, offset*sizeof(WCHAR));
774 memcpy(&str[offset], p, p_len*sizeof(WCHAR));
775 memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR));
776 str[len+p_len] = 0;
778 hr = IXMLDOMText_put_data(iface, str);
780 SysFreeString(str);
781 SysFreeString(data);
784 return hr;
787 static HRESULT WINAPI domtext_deleteData(
788 IXMLDOMText *iface,
789 LONG offset, LONG count)
791 HRESULT hr;
792 LONG len = -1;
793 BSTR str;
795 TRACE("%p, %ld, %ld.\n", iface, offset, count);
797 hr = IXMLDOMText_get_length(iface, &len);
798 if(hr != S_OK) return hr;
800 if((offset < 0) || (offset > len) || (count < 0))
801 return E_INVALIDARG;
803 if(len == 0) return S_OK;
805 /* cutting start or end */
806 if((offset == 0) || ((count + offset) >= len))
808 if(offset == 0)
809 IXMLDOMText_substringData(iface, count, len - count, &str);
810 else
811 IXMLDOMText_substringData(iface, 0, offset, &str);
812 hr = IXMLDOMText_put_data(iface, str);
814 else
815 /* cutting from the inside */
817 BSTR str_end;
819 IXMLDOMText_substringData(iface, 0, offset, &str);
820 IXMLDOMText_substringData(iface, offset + count, len - count, &str_end);
822 hr = IXMLDOMText_put_data(iface, str);
823 if(hr == S_OK)
824 hr = IXMLDOMText_appendData(iface, str_end);
826 SysFreeString(str_end);
829 SysFreeString(str);
831 return hr;
834 static HRESULT WINAPI domtext_replaceData(
835 IXMLDOMText *iface,
836 LONG offset, LONG count, BSTR p)
838 HRESULT hr;
840 TRACE("%p, %ld, %ld, %s.\n", iface, offset, count, debugstr_w(p));
842 hr = IXMLDOMText_deleteData(iface, offset, count);
844 if (hr == S_OK)
845 hr = IXMLDOMText_insertData(iface, offset, p);
847 return hr;
850 static HRESULT WINAPI domtext_splitText(
851 IXMLDOMText *iface,
852 LONG offset, IXMLDOMText **txtNode)
854 LONG length = 0;
856 TRACE("%p, %ld, %p.\n", iface, offset, txtNode);
858 if (!txtNode || offset < 0) return E_INVALIDARG;
860 *txtNode = NULL;
862 IXMLDOMText_get_length(iface, &length);
864 if (offset > length) return E_INVALIDARG;
865 if (offset == length) return S_FALSE;
867 FIXME("adjacent text nodes are not supported\n");
869 return E_NOTIMPL;
872 static const struct IXMLDOMTextVtbl domtext_vtbl =
874 domtext_QueryInterface,
875 domtext_AddRef,
876 domtext_Release,
877 domtext_GetTypeInfoCount,
878 domtext_GetTypeInfo,
879 domtext_GetIDsOfNames,
880 domtext_Invoke,
881 domtext_get_nodeName,
882 domtext_get_nodeValue,
883 domtext_put_nodeValue,
884 domtext_get_nodeType,
885 domtext_get_parentNode,
886 domtext_get_childNodes,
887 domtext_get_firstChild,
888 domtext_get_lastChild,
889 domtext_get_previousSibling,
890 domtext_get_nextSibling,
891 domtext_get_attributes,
892 domtext_insertBefore,
893 domtext_replaceChild,
894 domtext_removeChild,
895 domtext_appendChild,
896 domtext_hasChildNodes,
897 domtext_get_ownerDocument,
898 domtext_cloneNode,
899 domtext_get_nodeTypeString,
900 domtext_get_text,
901 domtext_put_text,
902 domtext_get_specified,
903 domtext_get_definition,
904 domtext_get_nodeTypedValue,
905 domtext_put_nodeTypedValue,
906 domtext_get_dataType,
907 domtext_put_dataType,
908 domtext_get_xml,
909 domtext_transformNode,
910 domtext_selectNodes,
911 domtext_selectSingleNode,
912 domtext_get_parsed,
913 domtext_get_namespaceURI,
914 domtext_get_prefix,
915 domtext_get_baseName,
916 domtext_transformNodeToObject,
917 domtext_get_data,
918 domtext_put_data,
919 domtext_get_length,
920 domtext_substringData,
921 domtext_appendData,
922 domtext_insertData,
923 domtext_deleteData,
924 domtext_replaceData,
925 domtext_splitText
928 static const tid_t domtext_iface_tids[] = {
929 IXMLDOMText_tid,
933 static dispex_static_data_t domtext_dispex = {
934 NULL,
935 IXMLDOMText_tid,
936 NULL,
937 domtext_iface_tids
940 IUnknown* create_text( xmlNodePtr text )
942 domtext *This;
944 This = heap_alloc( sizeof *This );
945 if ( !This )
946 return NULL;
948 This->IXMLDOMText_iface.lpVtbl = &domtext_vtbl;
949 This->ref = 1;
951 init_xmlnode(&This->node, text, (IXMLDOMNode*)&This->IXMLDOMText_iface, &domtext_dispex);
953 return (IUnknown*)&This->IXMLDOMText_iface;