urlmon: Fixed some tests on IE11.
[wine/wine-gecko.git] / dlls / msxml3 / text.c
blob411f6eb14545ca083727da4c49cc09c611ba485b
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/parserInternals.h>
30 # include <libxml/xmlerror.h>
31 #endif
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winuser.h"
36 #include "ole2.h"
37 #include "msxml6.h"
39 #include "msxml_private.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
45 #ifdef HAVE_LIBXML2
47 typedef struct _domtext
49 xmlnode node;
50 IXMLDOMText IXMLDOMText_iface;
51 LONG ref;
52 } domtext;
54 static inline domtext *impl_from_IXMLDOMText( IXMLDOMText *iface )
56 return CONTAINING_RECORD(iface, domtext, IXMLDOMText_iface);
59 static void domtext_reset_noenc(domtext *This)
61 This->node.node->name = NULL;
64 static HRESULT WINAPI domtext_QueryInterface(
65 IXMLDOMText *iface,
66 REFIID riid,
67 void** ppvObject )
69 domtext *This = impl_from_IXMLDOMText( iface );
70 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
72 if ( IsEqualGUID( riid, &IID_IXMLDOMText ) ||
73 IsEqualGUID( riid, &IID_IXMLDOMCharacterData) ||
74 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
75 IsEqualGUID( riid, &IID_IDispatch ) ||
76 IsEqualGUID( riid, &IID_IUnknown ) )
78 *ppvObject = iface;
80 else if(node_query_interface(&This->node, riid, ppvObject))
82 return *ppvObject ? S_OK : E_NOINTERFACE;
84 else
86 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
87 *ppvObject = NULL;
88 return E_NOINTERFACE;
91 IXMLDOMText_AddRef(iface);
92 return S_OK;
95 static ULONG WINAPI domtext_AddRef(
96 IXMLDOMText *iface )
98 domtext *This = impl_from_IXMLDOMText( iface );
99 ULONG ref = InterlockedIncrement( &This->ref );
100 TRACE("(%p)->(%d)\n", This, ref);
101 return ref;
104 static ULONG WINAPI domtext_Release(
105 IXMLDOMText *iface )
107 domtext *This = impl_from_IXMLDOMText( iface );
108 ULONG ref = InterlockedDecrement( &This->ref );
110 TRACE("(%p)->(%d)\n", This, ref);
111 if ( ref == 0 )
113 destroy_xmlnode(&This->node);
114 heap_free( This );
117 return ref;
120 static HRESULT WINAPI domtext_GetTypeInfoCount(
121 IXMLDOMText *iface,
122 UINT* pctinfo )
124 domtext *This = impl_from_IXMLDOMText( iface );
125 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
128 static HRESULT WINAPI domtext_GetTypeInfo(
129 IXMLDOMText *iface,
130 UINT iTInfo, LCID lcid,
131 ITypeInfo** ppTInfo )
133 domtext *This = impl_from_IXMLDOMText( iface );
134 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface,
135 iTInfo, lcid, ppTInfo);
138 static HRESULT WINAPI domtext_GetIDsOfNames(
139 IXMLDOMText *iface,
140 REFIID riid, LPOLESTR* rgszNames,
141 UINT cNames, LCID lcid, DISPID* rgDispId )
143 domtext *This = impl_from_IXMLDOMText( iface );
144 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface,
145 riid, rgszNames, cNames, lcid, rgDispId);
148 static HRESULT WINAPI domtext_Invoke(
149 IXMLDOMText *iface,
150 DISPID dispIdMember, REFIID riid, LCID lcid,
151 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
152 EXCEPINFO* pExcepInfo, UINT* puArgErr )
154 domtext *This = impl_from_IXMLDOMText( iface );
155 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface,
156 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
159 static HRESULT WINAPI domtext_get_nodeName(
160 IXMLDOMText *iface,
161 BSTR* p )
163 domtext *This = impl_from_IXMLDOMText( iface );
165 static const WCHAR textW[] = {'#','t','e','x','t',0};
167 TRACE("(%p)->(%p)\n", This, p);
169 return return_bstr(textW, p);
172 static HRESULT WINAPI domtext_get_nodeValue(
173 IXMLDOMText *iface,
174 VARIANT* value )
176 domtext *This = impl_from_IXMLDOMText( iface );
178 TRACE("(%p)->(%p)\n", This, value);
180 return node_get_content(&This->node, value);
183 static HRESULT WINAPI domtext_put_nodeValue(
184 IXMLDOMText *iface,
185 VARIANT value)
187 domtext *This = impl_from_IXMLDOMText( iface );
189 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
191 domtext_reset_noenc(This);
192 return node_put_value(&This->node, &value);
195 static HRESULT WINAPI domtext_get_nodeType(
196 IXMLDOMText *iface,
197 DOMNodeType* domNodeType )
199 domtext *This = impl_from_IXMLDOMText( iface );
201 TRACE("(%p)->(%p)\n", This, domNodeType);
203 *domNodeType = NODE_TEXT;
204 return S_OK;
207 static HRESULT WINAPI domtext_get_parentNode(
208 IXMLDOMText *iface,
209 IXMLDOMNode** parent )
211 domtext *This = impl_from_IXMLDOMText( iface );
213 TRACE("(%p)->(%p)\n", This, parent);
215 return node_get_parent(&This->node, parent);
218 static HRESULT WINAPI domtext_get_childNodes(
219 IXMLDOMText *iface,
220 IXMLDOMNodeList** outList)
222 domtext *This = impl_from_IXMLDOMText( iface );
224 TRACE("(%p)->(%p)\n", This, outList);
226 return node_get_child_nodes(&This->node, outList);
229 static HRESULT WINAPI domtext_get_firstChild(
230 IXMLDOMText *iface,
231 IXMLDOMNode** domNode)
233 domtext *This = impl_from_IXMLDOMText( iface );
235 TRACE("(%p)->(%p)\n", This, domNode);
237 return return_null_node(domNode);
240 static HRESULT WINAPI domtext_get_lastChild(
241 IXMLDOMText *iface,
242 IXMLDOMNode** domNode)
244 domtext *This = impl_from_IXMLDOMText( iface );
246 TRACE("(%p)->(%p)\n", This, domNode);
248 return return_null_node(domNode);
251 static HRESULT WINAPI domtext_get_previousSibling(
252 IXMLDOMText *iface,
253 IXMLDOMNode** domNode)
255 domtext *This = impl_from_IXMLDOMText( iface );
257 TRACE("(%p)->(%p)\n", This, domNode);
259 return node_get_previous_sibling(&This->node, domNode);
262 static HRESULT WINAPI domtext_get_nextSibling(
263 IXMLDOMText *iface,
264 IXMLDOMNode** domNode)
266 domtext *This = impl_from_IXMLDOMText( iface );
268 TRACE("(%p)->(%p)\n", This, domNode);
270 return node_get_next_sibling(&This->node, domNode);
273 static HRESULT WINAPI domtext_get_attributes(
274 IXMLDOMText *iface,
275 IXMLDOMNamedNodeMap** attributeMap)
277 domtext *This = impl_from_IXMLDOMText( iface );
279 TRACE("(%p)->(%p)\n", This, attributeMap);
281 return return_null_ptr((void**)attributeMap);
284 static HRESULT WINAPI domtext_insertBefore(
285 IXMLDOMText *iface,
286 IXMLDOMNode* newNode, VARIANT refChild,
287 IXMLDOMNode** outOldNode)
289 domtext *This = impl_from_IXMLDOMText( iface );
291 FIXME("(%p)->(%p %s %p) needs test\n", This, newNode, debugstr_variant(&refChild), outOldNode);
293 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
296 static HRESULT WINAPI domtext_replaceChild(
297 IXMLDOMText *iface,
298 IXMLDOMNode* newNode,
299 IXMLDOMNode* oldNode,
300 IXMLDOMNode** outOldNode)
302 domtext *This = impl_from_IXMLDOMText( iface );
304 FIXME("(%p)->(%p %p %p) needs test\n", This, newNode, oldNode, outOldNode);
306 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
309 static HRESULT WINAPI domtext_removeChild(
310 IXMLDOMText *iface,
311 IXMLDOMNode *child, IXMLDOMNode **oldChild)
313 domtext *This = impl_from_IXMLDOMText( iface );
314 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
315 return node_remove_child(&This->node, child, oldChild);
318 static HRESULT WINAPI domtext_appendChild(
319 IXMLDOMText *iface,
320 IXMLDOMNode *child, IXMLDOMNode **outChild)
322 domtext *This = impl_from_IXMLDOMText( iface );
323 TRACE("(%p)->(%p %p)\n", This, child, outChild);
324 return node_append_child(&This->node, child, outChild);
327 static HRESULT WINAPI domtext_hasChildNodes(
328 IXMLDOMText *iface,
329 VARIANT_BOOL *ret)
331 domtext *This = impl_from_IXMLDOMText( iface );
332 TRACE("(%p)->(%p)\n", This, ret);
333 return return_var_false(ret);
336 static HRESULT WINAPI domtext_get_ownerDocument(
337 IXMLDOMText *iface,
338 IXMLDOMDocument **doc)
340 domtext *This = impl_from_IXMLDOMText( iface );
341 TRACE("(%p)->(%p)\n", This, doc);
342 return node_get_owner_doc(&This->node, doc);
345 static HRESULT WINAPI domtext_cloneNode(
346 IXMLDOMText *iface,
347 VARIANT_BOOL deep, IXMLDOMNode** outNode)
349 domtext *This = impl_from_IXMLDOMText( iface );
350 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
351 return node_clone( &This->node, deep, outNode );
354 static HRESULT WINAPI domtext_get_nodeTypeString(
355 IXMLDOMText *iface,
356 BSTR* p)
358 domtext *This = impl_from_IXMLDOMText( iface );
359 static const WCHAR textW[] = {'t','e','x','t',0};
361 TRACE("(%p)->(%p)\n", This, p);
363 return return_bstr(textW, p);
366 static HRESULT WINAPI domtext_get_text(
367 IXMLDOMText *iface,
368 BSTR* p)
370 domtext *This = impl_from_IXMLDOMText( iface );
371 TRACE("(%p)->(%p)\n", This, p);
372 return node_get_text(&This->node, p);
375 static HRESULT WINAPI domtext_put_text(
376 IXMLDOMText *iface,
377 BSTR p)
379 domtext *This = impl_from_IXMLDOMText( iface );
380 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
381 domtext_reset_noenc(This);
382 return node_put_text( &This->node, p );
385 static HRESULT WINAPI domtext_get_specified(
386 IXMLDOMText *iface,
387 VARIANT_BOOL* isSpecified)
389 domtext *This = impl_from_IXMLDOMText( iface );
390 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
391 *isSpecified = VARIANT_TRUE;
392 return S_OK;
395 static HRESULT WINAPI domtext_get_definition(
396 IXMLDOMText *iface,
397 IXMLDOMNode** definitionNode)
399 domtext *This = impl_from_IXMLDOMText( iface );
400 FIXME("(%p)->(%p)\n", This, definitionNode);
401 return E_NOTIMPL;
404 static HRESULT WINAPI domtext_get_nodeTypedValue(
405 IXMLDOMText *iface,
406 VARIANT* var1)
408 domtext *This = impl_from_IXMLDOMText( iface );
409 IXMLDOMNode* parent = NULL;
410 HRESULT hr;
412 TRACE("(%p)->(%p)\n", This, var1);
414 if (!var1)
415 return E_INVALIDARG;
417 hr = IXMLDOMText_get_parentNode(iface, &parent);
419 if (hr == S_OK)
421 hr = IXMLDOMNode_get_nodeTypedValue(parent, var1);
422 IXMLDOMNode_Release(parent);
424 else
426 V_VT(var1) = VT_NULL;
427 V_BSTR(var1) = NULL;
428 hr = S_FALSE;
431 return hr;
434 static HRESULT WINAPI domtext_put_nodeTypedValue(
435 IXMLDOMText *iface,
436 VARIANT value)
438 domtext *This = impl_from_IXMLDOMText( iface );
439 IXMLDOMNode* parent = NULL;
440 HRESULT hr;
442 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
444 hr = IXMLDOMText_get_parentNode(iface, &parent);
446 if (hr == S_OK)
448 hr = IXMLDOMNode_put_nodeTypedValue(parent, value);
449 IXMLDOMNode_Release(parent);
451 else
453 hr = S_FALSE;
456 return hr;
459 static HRESULT WINAPI domtext_get_dataType(
460 IXMLDOMText *iface,
461 VARIANT* dtName)
463 domtext *This = impl_from_IXMLDOMText( iface );
464 IXMLDOMNode* parent = NULL;
465 HRESULT hr;
467 TRACE("(%p)->(%p)\n", This, dtName);
469 if (!dtName)
470 return E_INVALIDARG;
472 hr = IXMLDOMText_get_parentNode(iface, &parent);
474 if (hr == S_OK)
476 hr = IXMLDOMNode_get_dataType(parent, dtName);
477 IXMLDOMNode_Release(parent);
479 else
481 V_VT(dtName) = VT_NULL;
482 V_BSTR(dtName) = NULL;
483 hr = S_FALSE;
486 return hr;
489 static HRESULT WINAPI domtext_put_dataType(
490 IXMLDOMText *iface,
491 BSTR dtName)
493 domtext *This = impl_from_IXMLDOMText( iface );
494 IXMLDOMNode* parent = NULL;
495 HRESULT hr;
497 TRACE("(%p)->(%p)\n", This, dtName);
499 if (!dtName)
500 return E_INVALIDARG;
502 hr = IXMLDOMText_get_parentNode(iface, &parent);
504 if (hr == S_OK)
506 hr = IXMLDOMNode_put_dataType(parent, dtName);
507 IXMLDOMNode_Release(parent);
509 else
511 hr = S_FALSE;
514 return hr;
517 static HRESULT WINAPI domtext_get_xml(
518 IXMLDOMText *iface,
519 BSTR* p)
521 domtext *This = impl_from_IXMLDOMText( iface );
523 TRACE("(%p)->(%p)\n", This, p);
525 return node_get_xml(&This->node, FALSE, p);
528 static HRESULT WINAPI domtext_transformNode(
529 IXMLDOMText *iface,
530 IXMLDOMNode *node, BSTR *p)
532 domtext *This = impl_from_IXMLDOMText( iface );
533 TRACE("(%p)->(%p %p)\n", This, node, p);
534 return node_transform_node(&This->node, node, p);
537 static HRESULT WINAPI domtext_selectNodes(
538 IXMLDOMText *iface,
539 BSTR p, IXMLDOMNodeList** outList)
541 domtext *This = impl_from_IXMLDOMText( iface );
542 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
543 return node_select_nodes(&This->node, p, outList);
546 static HRESULT WINAPI domtext_selectSingleNode(
547 IXMLDOMText *iface,
548 BSTR p, IXMLDOMNode** outNode)
550 domtext *This = impl_from_IXMLDOMText( iface );
551 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
552 return node_select_singlenode(&This->node, p, outNode);
555 static HRESULT WINAPI domtext_get_parsed(
556 IXMLDOMText *iface,
557 VARIANT_BOOL* isParsed)
559 domtext *This = impl_from_IXMLDOMText( iface );
560 FIXME("(%p)->(%p) stub!\n", This, isParsed);
561 *isParsed = VARIANT_TRUE;
562 return S_OK;
565 static HRESULT WINAPI domtext_get_namespaceURI(
566 IXMLDOMText *iface,
567 BSTR* p)
569 domtext *This = impl_from_IXMLDOMText( iface );
570 TRACE("(%p)->(%p)\n", This, p);
571 return node_get_namespaceURI(&This->node, p);
574 static HRESULT WINAPI domtext_get_prefix(
575 IXMLDOMText *iface,
576 BSTR* prefix)
578 domtext *This = impl_from_IXMLDOMText( iface );
579 TRACE("(%p)->(%p)\n", This, prefix);
580 return return_null_bstr( prefix );
583 static HRESULT WINAPI domtext_get_baseName(
584 IXMLDOMText *iface,
585 BSTR* name)
587 domtext *This = impl_from_IXMLDOMText( iface );
588 TRACE("(%p)->(%p)\n", This, name);
589 return return_null_bstr( name );
592 static HRESULT WINAPI domtext_transformNodeToObject(
593 IXMLDOMText *iface,
594 IXMLDOMNode* domNode, VARIANT var1)
596 domtext *This = impl_from_IXMLDOMText( iface );
597 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
598 return E_NOTIMPL;
601 static HRESULT WINAPI domtext_get_data(
602 IXMLDOMText *iface,
603 BSTR *p)
605 domtext *This = impl_from_IXMLDOMText( iface );
607 if(!p)
608 return E_INVALIDARG;
610 *p = bstr_from_xmlChar(This->node.node->content);
611 return S_OK;
614 static HRESULT WINAPI domtext_put_data(
615 IXMLDOMText *iface,
616 BSTR data)
618 domtext *This = impl_from_IXMLDOMText( iface );
619 static const WCHAR rnW[] = {'\r','\n',0};
621 TRACE("(%p)->(%s)\n", This, debugstr_w(data));
623 if (data && !strcmpW(rnW, data))
624 This->node.node->name = xmlStringTextNoenc;
625 else
626 domtext_reset_noenc(This);
627 return node_set_content(&This->node, data);
630 static HRESULT WINAPI domtext_get_length(
631 IXMLDOMText *iface,
632 LONG *len)
634 domtext *This = impl_from_IXMLDOMText( iface );
635 HRESULT hr;
636 BSTR data;
638 TRACE("(%p)->(%p)\n", This, len);
640 if(!len)
641 return E_INVALIDARG;
643 hr = IXMLDOMText_get_data(iface, &data);
644 if(hr == S_OK)
646 *len = SysStringLen(data);
647 SysFreeString(data);
650 return hr;
653 static HRESULT WINAPI domtext_substringData(
654 IXMLDOMText *iface,
655 LONG offset, LONG count, BSTR *p)
657 domtext *This = impl_from_IXMLDOMText( iface );
658 HRESULT hr;
659 BSTR data;
661 TRACE("(%p)->(%d %d %p)\n", This, offset, count, p);
663 if(!p)
664 return E_INVALIDARG;
666 *p = NULL;
667 if(offset < 0 || count < 0)
668 return E_INVALIDARG;
670 if(count == 0)
671 return S_FALSE;
673 hr = IXMLDOMText_get_data(iface, &data);
674 if(hr == S_OK)
676 LONG len = SysStringLen(data);
678 if(offset < len)
680 if(offset + count > len)
681 *p = SysAllocString(&data[offset]);
682 else
683 *p = SysAllocStringLen(&data[offset], count);
685 else
686 hr = S_FALSE;
688 SysFreeString(data);
691 return hr;
694 static HRESULT WINAPI domtext_appendData(
695 IXMLDOMText *iface,
696 BSTR p)
698 domtext *This = impl_from_IXMLDOMText( iface );
699 HRESULT hr;
700 BSTR data;
701 LONG p_len;
703 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
705 /* Nothing to do if NULL or an Empty string passed in. */
706 if((p_len = SysStringLen(p)) == 0) return S_OK;
708 hr = IXMLDOMText_get_data(iface, &data);
709 if(hr == S_OK)
711 LONG len = SysStringLen(data);
712 BSTR str = SysAllocStringLen(NULL, p_len + len);
714 memcpy(str, data, len*sizeof(WCHAR));
715 memcpy(&str[len], p, p_len*sizeof(WCHAR));
716 str[len+p_len] = 0;
718 hr = IXMLDOMText_put_data(iface, str);
720 SysFreeString(str);
721 SysFreeString(data);
724 return hr;
727 static HRESULT WINAPI domtext_insertData(
728 IXMLDOMText *iface,
729 LONG offset, BSTR p)
731 domtext *This = impl_from_IXMLDOMText( iface );
732 HRESULT hr;
733 BSTR data;
734 LONG p_len;
736 TRACE("(%p)->(%d %s)\n", This, offset, debugstr_w(p));
738 /* If have a NULL or empty string, don't do anything. */
739 if((p_len = SysStringLen(p)) == 0)
740 return S_OK;
742 if(offset < 0)
744 return E_INVALIDARG;
747 hr = IXMLDOMText_get_data(iface, &data);
748 if(hr == S_OK)
750 LONG len = SysStringLen(data);
751 BSTR str;
753 if(len < offset)
755 SysFreeString(data);
756 return E_INVALIDARG;
759 str = SysAllocStringLen(NULL, len + p_len);
760 /* start part, supplied string and end part */
761 memcpy(str, data, offset*sizeof(WCHAR));
762 memcpy(&str[offset], p, p_len*sizeof(WCHAR));
763 memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR));
764 str[len+p_len] = 0;
766 hr = IXMLDOMText_put_data(iface, str);
768 SysFreeString(str);
769 SysFreeString(data);
772 return hr;
775 static HRESULT WINAPI domtext_deleteData(
776 IXMLDOMText *iface,
777 LONG offset, LONG count)
779 HRESULT hr;
780 LONG len = -1;
781 BSTR str;
783 TRACE("(%p)->(%d %d)\n", iface, offset, count);
785 hr = IXMLDOMText_get_length(iface, &len);
786 if(hr != S_OK) return hr;
788 if((offset < 0) || (offset > len) || (count < 0))
789 return E_INVALIDARG;
791 if(len == 0) return S_OK;
793 /* cutting start or end */
794 if((offset == 0) || ((count + offset) >= len))
796 if(offset == 0)
797 IXMLDOMText_substringData(iface, count, len - count, &str);
798 else
799 IXMLDOMText_substringData(iface, 0, offset, &str);
800 hr = IXMLDOMText_put_data(iface, str);
802 else
803 /* cutting from the inside */
805 BSTR str_end;
807 IXMLDOMText_substringData(iface, 0, offset, &str);
808 IXMLDOMText_substringData(iface, offset + count, len - count, &str_end);
810 hr = IXMLDOMText_put_data(iface, str);
811 if(hr == S_OK)
812 hr = IXMLDOMText_appendData(iface, str_end);
814 SysFreeString(str_end);
817 SysFreeString(str);
819 return hr;
822 static HRESULT WINAPI domtext_replaceData(
823 IXMLDOMText *iface,
824 LONG offset, LONG count, BSTR p)
826 domtext *This = impl_from_IXMLDOMText( iface );
827 HRESULT hr;
829 TRACE("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(p));
831 hr = IXMLDOMText_deleteData(iface, offset, count);
833 if (hr == S_OK)
834 hr = IXMLDOMText_insertData(iface, offset, p);
836 return hr;
839 static HRESULT WINAPI domtext_splitText(
840 IXMLDOMText *iface,
841 LONG offset, IXMLDOMText **txtNode)
843 domtext *This = impl_from_IXMLDOMText( iface );
844 LONG length = 0;
846 TRACE("(%p)->(%d %p)\n", This, offset, txtNode);
848 if (!txtNode || offset < 0) return E_INVALIDARG;
850 *txtNode = NULL;
852 IXMLDOMText_get_length(iface, &length);
854 if (offset > length) return E_INVALIDARG;
855 if (offset == length) return S_FALSE;
857 FIXME("adjacent text nodes are not supported\n");
859 return E_NOTIMPL;
862 static const struct IXMLDOMTextVtbl domtext_vtbl =
864 domtext_QueryInterface,
865 domtext_AddRef,
866 domtext_Release,
867 domtext_GetTypeInfoCount,
868 domtext_GetTypeInfo,
869 domtext_GetIDsOfNames,
870 domtext_Invoke,
871 domtext_get_nodeName,
872 domtext_get_nodeValue,
873 domtext_put_nodeValue,
874 domtext_get_nodeType,
875 domtext_get_parentNode,
876 domtext_get_childNodes,
877 domtext_get_firstChild,
878 domtext_get_lastChild,
879 domtext_get_previousSibling,
880 domtext_get_nextSibling,
881 domtext_get_attributes,
882 domtext_insertBefore,
883 domtext_replaceChild,
884 domtext_removeChild,
885 domtext_appendChild,
886 domtext_hasChildNodes,
887 domtext_get_ownerDocument,
888 domtext_cloneNode,
889 domtext_get_nodeTypeString,
890 domtext_get_text,
891 domtext_put_text,
892 domtext_get_specified,
893 domtext_get_definition,
894 domtext_get_nodeTypedValue,
895 domtext_put_nodeTypedValue,
896 domtext_get_dataType,
897 domtext_put_dataType,
898 domtext_get_xml,
899 domtext_transformNode,
900 domtext_selectNodes,
901 domtext_selectSingleNode,
902 domtext_get_parsed,
903 domtext_get_namespaceURI,
904 domtext_get_prefix,
905 domtext_get_baseName,
906 domtext_transformNodeToObject,
907 domtext_get_data,
908 domtext_put_data,
909 domtext_get_length,
910 domtext_substringData,
911 domtext_appendData,
912 domtext_insertData,
913 domtext_deleteData,
914 domtext_replaceData,
915 domtext_splitText
918 static const tid_t domtext_iface_tids[] = {
919 IXMLDOMText_tid,
923 static dispex_static_data_t domtext_dispex = {
924 NULL,
925 IXMLDOMText_tid,
926 NULL,
927 domtext_iface_tids
930 IUnknown* create_text( xmlNodePtr text )
932 domtext *This;
934 This = heap_alloc( sizeof *This );
935 if ( !This )
936 return NULL;
938 This->IXMLDOMText_iface.lpVtbl = &domtext_vtbl;
939 This->ref = 1;
941 init_xmlnode(&This->node, text, (IXMLDOMNode*)&This->IXMLDOMText_iface, &domtext_dispex);
943 return (IUnknown*)&This->IXMLDOMText_iface;
946 #endif