d3d9: Don't return a pointer to the implementation in IDirect3DSwapChain9Impl_QueryIn...
[wine.git] / dlls / msxml3 / text.c
blob74de8e54a36f3cdf0593bb3d973d24d755ca40d5
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 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 return node_put_value(&This->node, &value);
188 static HRESULT WINAPI domtext_get_nodeType(
189 IXMLDOMText *iface,
190 DOMNodeType* domNodeType )
192 domtext *This = impl_from_IXMLDOMText( iface );
194 TRACE("(%p)->(%p)\n", This, domNodeType);
196 *domNodeType = NODE_TEXT;
197 return S_OK;
200 static HRESULT WINAPI domtext_get_parentNode(
201 IXMLDOMText *iface,
202 IXMLDOMNode** parent )
204 domtext *This = impl_from_IXMLDOMText( iface );
206 TRACE("(%p)->(%p)\n", This, parent);
208 return node_get_parent(&This->node, parent);
211 static HRESULT WINAPI domtext_get_childNodes(
212 IXMLDOMText *iface,
213 IXMLDOMNodeList** outList)
215 domtext *This = impl_from_IXMLDOMText( iface );
217 TRACE("(%p)->(%p)\n", This, outList);
219 return node_get_child_nodes(&This->node, outList);
222 static HRESULT WINAPI domtext_get_firstChild(
223 IXMLDOMText *iface,
224 IXMLDOMNode** domNode)
226 domtext *This = impl_from_IXMLDOMText( iface );
228 TRACE("(%p)->(%p)\n", This, domNode);
230 return return_null_node(domNode);
233 static HRESULT WINAPI domtext_get_lastChild(
234 IXMLDOMText *iface,
235 IXMLDOMNode** domNode)
237 domtext *This = impl_from_IXMLDOMText( iface );
239 TRACE("(%p)->(%p)\n", This, domNode);
241 return return_null_node(domNode);
244 static HRESULT WINAPI domtext_get_previousSibling(
245 IXMLDOMText *iface,
246 IXMLDOMNode** domNode)
248 domtext *This = impl_from_IXMLDOMText( iface );
250 TRACE("(%p)->(%p)\n", This, domNode);
252 return node_get_previous_sibling(&This->node, domNode);
255 static HRESULT WINAPI domtext_get_nextSibling(
256 IXMLDOMText *iface,
257 IXMLDOMNode** domNode)
259 domtext *This = impl_from_IXMLDOMText( iface );
261 TRACE("(%p)->(%p)\n", This, domNode);
263 return node_get_next_sibling(&This->node, domNode);
266 static HRESULT WINAPI domtext_get_attributes(
267 IXMLDOMText *iface,
268 IXMLDOMNamedNodeMap** attributeMap)
270 domtext *This = impl_from_IXMLDOMText( iface );
272 TRACE("(%p)->(%p)\n", This, attributeMap);
274 return return_null_ptr((void**)attributeMap);
277 static HRESULT WINAPI domtext_insertBefore(
278 IXMLDOMText *iface,
279 IXMLDOMNode* newNode, VARIANT refChild,
280 IXMLDOMNode** outOldNode)
282 domtext *This = impl_from_IXMLDOMText( iface );
284 FIXME("(%p)->(%p %s %p) needs test\n", This, newNode, debugstr_variant(&refChild), outOldNode);
286 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
289 static HRESULT WINAPI domtext_replaceChild(
290 IXMLDOMText *iface,
291 IXMLDOMNode* newNode,
292 IXMLDOMNode* oldNode,
293 IXMLDOMNode** outOldNode)
295 domtext *This = impl_from_IXMLDOMText( iface );
297 FIXME("(%p)->(%p %p %p) needs test\n", This, newNode, oldNode, outOldNode);
299 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
302 static HRESULT WINAPI domtext_removeChild(
303 IXMLDOMText *iface,
304 IXMLDOMNode *child, IXMLDOMNode **oldChild)
306 domtext *This = impl_from_IXMLDOMText( iface );
307 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
308 return node_remove_child(&This->node, child, oldChild);
311 static HRESULT WINAPI domtext_appendChild(
312 IXMLDOMText *iface,
313 IXMLDOMNode *child, IXMLDOMNode **outChild)
315 domtext *This = impl_from_IXMLDOMText( iface );
316 TRACE("(%p)->(%p %p)\n", This, child, outChild);
317 return node_append_child(&This->node, child, outChild);
320 static HRESULT WINAPI domtext_hasChildNodes(
321 IXMLDOMText *iface,
322 VARIANT_BOOL *ret)
324 domtext *This = impl_from_IXMLDOMText( iface );
325 TRACE("(%p)->(%p)\n", This, ret);
326 return node_has_childnodes(&This->node, ret);
329 static HRESULT WINAPI domtext_get_ownerDocument(
330 IXMLDOMText *iface,
331 IXMLDOMDocument **doc)
333 domtext *This = impl_from_IXMLDOMText( iface );
334 TRACE("(%p)->(%p)\n", This, doc);
335 return node_get_owner_doc(&This->node, doc);
338 static HRESULT WINAPI domtext_cloneNode(
339 IXMLDOMText *iface,
340 VARIANT_BOOL deep, IXMLDOMNode** outNode)
342 domtext *This = impl_from_IXMLDOMText( iface );
343 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
344 return node_clone( &This->node, deep, outNode );
347 static HRESULT WINAPI domtext_get_nodeTypeString(
348 IXMLDOMText *iface,
349 BSTR* p)
351 domtext *This = impl_from_IXMLDOMText( iface );
352 static const WCHAR textW[] = {'t','e','x','t',0};
354 TRACE("(%p)->(%p)\n", This, p);
356 return return_bstr(textW, p);
359 static HRESULT WINAPI domtext_get_text(
360 IXMLDOMText *iface,
361 BSTR* p)
363 domtext *This = impl_from_IXMLDOMText( iface );
364 TRACE("(%p)->(%p)\n", This, p);
365 return node_get_text(&This->node, p);
368 static HRESULT WINAPI domtext_put_text(
369 IXMLDOMText *iface,
370 BSTR p)
372 domtext *This = impl_from_IXMLDOMText( iface );
373 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
374 return node_put_text( &This->node, p );
377 static HRESULT WINAPI domtext_get_specified(
378 IXMLDOMText *iface,
379 VARIANT_BOOL* isSpecified)
381 domtext *This = impl_from_IXMLDOMText( iface );
382 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
383 *isSpecified = VARIANT_TRUE;
384 return S_OK;
387 static HRESULT WINAPI domtext_get_definition(
388 IXMLDOMText *iface,
389 IXMLDOMNode** definitionNode)
391 domtext *This = impl_from_IXMLDOMText( iface );
392 FIXME("(%p)->(%p)\n", This, definitionNode);
393 return E_NOTIMPL;
396 static HRESULT WINAPI domtext_get_nodeTypedValue(
397 IXMLDOMText *iface,
398 VARIANT* var1)
400 domtext *This = impl_from_IXMLDOMText( iface );
401 IXMLDOMNode* parent = NULL;
402 HRESULT hr;
404 TRACE("(%p)->(%p)\n", This, var1);
406 if (!var1)
407 return E_INVALIDARG;
409 hr = IXMLDOMText_get_parentNode(iface, &parent);
411 if (hr == S_OK)
413 hr = IXMLDOMNode_get_nodeTypedValue(parent, var1);
414 IXMLDOMNode_Release(parent);
416 else
418 V_VT(var1) = VT_NULL;
419 V_BSTR(var1) = NULL;
420 hr = S_FALSE;
423 return hr;
426 static HRESULT WINAPI domtext_put_nodeTypedValue(
427 IXMLDOMText *iface,
428 VARIANT value)
430 domtext *This = impl_from_IXMLDOMText( iface );
431 IXMLDOMNode* parent = NULL;
432 HRESULT hr;
434 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
436 hr = IXMLDOMText_get_parentNode(iface, &parent);
438 if (hr == S_OK)
440 hr = IXMLDOMNode_put_nodeTypedValue(parent, value);
441 IXMLDOMNode_Release(parent);
443 else
445 hr = S_FALSE;
448 return hr;
451 static HRESULT WINAPI domtext_get_dataType(
452 IXMLDOMText *iface,
453 VARIANT* dtName)
455 domtext *This = impl_from_IXMLDOMText( iface );
456 IXMLDOMNode* parent = NULL;
457 HRESULT hr;
459 TRACE("(%p)->(%p)\n", This, dtName);
461 if (!dtName)
462 return E_INVALIDARG;
464 hr = IXMLDOMText_get_parentNode(iface, &parent);
466 if (hr == S_OK)
468 hr = IXMLDOMNode_get_dataType(parent, dtName);
469 IXMLDOMNode_Release(parent);
471 else
473 V_VT(dtName) = VT_NULL;
474 V_BSTR(dtName) = NULL;
475 hr = S_FALSE;
478 return hr;
481 static HRESULT WINAPI domtext_put_dataType(
482 IXMLDOMText *iface,
483 BSTR dtName)
485 domtext *This = impl_from_IXMLDOMText( iface );
486 IXMLDOMNode* parent = NULL;
487 HRESULT hr;
489 TRACE("(%p)->(%p)\n", This, dtName);
491 if (!dtName)
492 return E_INVALIDARG;
494 hr = IXMLDOMText_get_parentNode(iface, &parent);
496 if (hr == S_OK)
498 hr = IXMLDOMNode_put_dataType(parent, dtName);
499 IXMLDOMNode_Release(parent);
501 else
503 hr = S_FALSE;
506 return hr;
509 static HRESULT WINAPI domtext_get_xml(
510 IXMLDOMText *iface,
511 BSTR* p)
513 domtext *This = impl_from_IXMLDOMText( iface );
515 TRACE("(%p)->(%p)\n", This, p);
517 return node_get_xml(&This->node, FALSE, FALSE, p);
520 static HRESULT WINAPI domtext_transformNode(
521 IXMLDOMText *iface,
522 IXMLDOMNode *node, BSTR *p)
524 domtext *This = impl_from_IXMLDOMText( iface );
525 TRACE("(%p)->(%p %p)\n", This, node, p);
526 return node_transform_node(&This->node, node, p);
529 static HRESULT WINAPI domtext_selectNodes(
530 IXMLDOMText *iface,
531 BSTR p, IXMLDOMNodeList** outList)
533 domtext *This = impl_from_IXMLDOMText( iface );
534 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
535 return node_select_nodes(&This->node, p, outList);
538 static HRESULT WINAPI domtext_selectSingleNode(
539 IXMLDOMText *iface,
540 BSTR p, IXMLDOMNode** outNode)
542 domtext *This = impl_from_IXMLDOMText( iface );
543 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
544 return node_select_singlenode(&This->node, p, outNode);
547 static HRESULT WINAPI domtext_get_parsed(
548 IXMLDOMText *iface,
549 VARIANT_BOOL* isParsed)
551 domtext *This = impl_from_IXMLDOMText( iface );
552 FIXME("(%p)->(%p) stub!\n", This, isParsed);
553 *isParsed = VARIANT_TRUE;
554 return S_OK;
557 static HRESULT WINAPI domtext_get_namespaceURI(
558 IXMLDOMText *iface,
559 BSTR* p)
561 domtext *This = impl_from_IXMLDOMText( iface );
562 TRACE("(%p)->(%p)\n", This, p);
563 return node_get_namespaceURI(&This->node, p);
566 static HRESULT WINAPI domtext_get_prefix(
567 IXMLDOMText *iface,
568 BSTR* prefix)
570 domtext *This = impl_from_IXMLDOMText( iface );
571 TRACE("(%p)->(%p)\n", This, prefix);
572 return return_null_bstr( prefix );
575 static HRESULT WINAPI domtext_get_baseName(
576 IXMLDOMText *iface,
577 BSTR* name)
579 domtext *This = impl_from_IXMLDOMText( iface );
580 TRACE("(%p)->(%p)\n", This, name);
581 return return_null_bstr( name );
584 static HRESULT WINAPI domtext_transformNodeToObject(
585 IXMLDOMText *iface,
586 IXMLDOMNode* domNode, VARIANT var1)
588 domtext *This = impl_from_IXMLDOMText( iface );
589 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
590 return E_NOTIMPL;
593 static HRESULT WINAPI domtext_get_data(
594 IXMLDOMText *iface,
595 BSTR *p)
597 domtext *This = impl_from_IXMLDOMText( iface );
599 if(!p)
600 return E_INVALIDARG;
602 *p = bstr_from_xmlChar(This->node.node->content);
603 return S_OK;
606 static HRESULT WINAPI domtext_put_data(
607 IXMLDOMText *iface,
608 BSTR data)
610 domtext *This = impl_from_IXMLDOMText( iface );
611 VARIANT val;
613 TRACE("(%p)->(%s)\n", This, debugstr_w(data) );
615 V_VT(&val) = VT_BSTR;
616 V_BSTR(&val) = data;
617 return node_put_value(&This->node, &val);
620 static HRESULT WINAPI domtext_get_length(
621 IXMLDOMText *iface,
622 LONG *len)
624 domtext *This = impl_from_IXMLDOMText( iface );
625 HRESULT hr;
626 BSTR data;
628 TRACE("(%p)->(%p)\n", This, len);
630 if(!len)
631 return E_INVALIDARG;
633 hr = IXMLDOMText_get_data(iface, &data);
634 if(hr == S_OK)
636 *len = SysStringLen(data);
637 SysFreeString(data);
640 return hr;
643 static HRESULT WINAPI domtext_substringData(
644 IXMLDOMText *iface,
645 LONG offset, LONG count, BSTR *p)
647 domtext *This = impl_from_IXMLDOMText( iface );
648 HRESULT hr;
649 BSTR data;
651 TRACE("(%p)->(%d %d %p)\n", This, offset, count, p);
653 if(!p)
654 return E_INVALIDARG;
656 *p = NULL;
657 if(offset < 0 || count < 0)
658 return E_INVALIDARG;
660 if(count == 0)
661 return S_FALSE;
663 hr = IXMLDOMText_get_data(iface, &data);
664 if(hr == S_OK)
666 LONG len = SysStringLen(data);
668 if(offset < len)
670 if(offset + count > len)
671 *p = SysAllocString(&data[offset]);
672 else
673 *p = SysAllocStringLen(&data[offset], count);
675 else
676 hr = S_FALSE;
678 SysFreeString(data);
681 return hr;
684 static HRESULT WINAPI domtext_appendData(
685 IXMLDOMText *iface,
686 BSTR p)
688 domtext *This = impl_from_IXMLDOMText( iface );
689 HRESULT hr;
690 BSTR data;
691 LONG p_len;
693 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
695 /* Nothing to do if NULL or an Empty string passed in. */
696 if((p_len = SysStringLen(p)) == 0) return S_OK;
698 hr = IXMLDOMText_get_data(iface, &data);
699 if(hr == S_OK)
701 LONG len = SysStringLen(data);
702 BSTR str = SysAllocStringLen(NULL, p_len + len);
704 memcpy(str, data, len*sizeof(WCHAR));
705 memcpy(&str[len], p, p_len*sizeof(WCHAR));
706 str[len+p_len] = 0;
708 hr = IXMLDOMText_put_data(iface, str);
710 SysFreeString(str);
711 SysFreeString(data);
714 return hr;
717 static HRESULT WINAPI domtext_insertData(
718 IXMLDOMText *iface,
719 LONG offset, BSTR p)
721 domtext *This = impl_from_IXMLDOMText( iface );
722 HRESULT hr;
723 BSTR data;
724 LONG p_len;
726 TRACE("(%p)->(%d %s)\n", This, offset, debugstr_w(p));
728 /* If have a NULL or empty string, don't do anything. */
729 if((p_len = SysStringLen(p)) == 0)
730 return S_OK;
732 if(offset < 0)
734 return E_INVALIDARG;
737 hr = IXMLDOMText_get_data(iface, &data);
738 if(hr == S_OK)
740 LONG len = SysStringLen(data);
741 BSTR str;
743 if(len < offset)
745 SysFreeString(data);
746 return E_INVALIDARG;
749 str = SysAllocStringLen(NULL, len + p_len);
750 /* start part, supplied string and end part */
751 memcpy(str, data, offset*sizeof(WCHAR));
752 memcpy(&str[offset], p, p_len*sizeof(WCHAR));
753 memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR));
754 str[len+p_len] = 0;
756 hr = IXMLDOMText_put_data(iface, str);
758 SysFreeString(str);
759 SysFreeString(data);
762 return hr;
765 static HRESULT WINAPI domtext_deleteData(
766 IXMLDOMText *iface,
767 LONG offset, LONG count)
769 HRESULT hr;
770 LONG len = -1;
771 BSTR str;
773 TRACE("(%p)->(%d %d)\n", iface, offset, count);
775 hr = IXMLDOMText_get_length(iface, &len);
776 if(hr != S_OK) return hr;
778 if((offset < 0) || (offset > len) || (count < 0))
779 return E_INVALIDARG;
781 if(len == 0) return S_OK;
783 /* cutting start or end */
784 if((offset == 0) || ((count + offset) >= len))
786 if(offset == 0)
787 IXMLDOMText_substringData(iface, count, len - count, &str);
788 else
789 IXMLDOMText_substringData(iface, 0, offset, &str);
790 hr = IXMLDOMText_put_data(iface, str);
792 else
793 /* cutting from the inside */
795 BSTR str_end;
797 IXMLDOMText_substringData(iface, 0, offset, &str);
798 IXMLDOMText_substringData(iface, offset + count, len - count, &str_end);
800 hr = IXMLDOMText_put_data(iface, str);
801 if(hr == S_OK)
802 hr = IXMLDOMText_appendData(iface, str_end);
804 SysFreeString(str_end);
807 SysFreeString(str);
809 return hr;
812 static HRESULT WINAPI domtext_replaceData(
813 IXMLDOMText *iface,
814 LONG offset, LONG count, BSTR p)
816 domtext *This = impl_from_IXMLDOMText( iface );
817 HRESULT hr;
819 TRACE("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(p));
821 hr = IXMLDOMText_deleteData(iface, offset, count);
823 if (hr == S_OK)
824 hr = IXMLDOMText_insertData(iface, offset, p);
826 return hr;
829 static HRESULT WINAPI domtext_splitText(
830 IXMLDOMText *iface,
831 LONG offset, IXMLDOMText **txtNode)
833 domtext *This = impl_from_IXMLDOMText( iface );
834 LONG length = 0;
836 TRACE("(%p)->(%d %p)\n", This, offset, txtNode);
838 if (!txtNode || offset < 0) return E_INVALIDARG;
840 *txtNode = NULL;
842 IXMLDOMText_get_length(iface, &length);
844 if (offset > length) return E_INVALIDARG;
845 if (offset == length) return S_FALSE;
847 FIXME("adjacent text nodes are not supported\n");
849 return E_NOTIMPL;
852 static const struct IXMLDOMTextVtbl domtext_vtbl =
854 domtext_QueryInterface,
855 domtext_AddRef,
856 domtext_Release,
857 domtext_GetTypeInfoCount,
858 domtext_GetTypeInfo,
859 domtext_GetIDsOfNames,
860 domtext_Invoke,
861 domtext_get_nodeName,
862 domtext_get_nodeValue,
863 domtext_put_nodeValue,
864 domtext_get_nodeType,
865 domtext_get_parentNode,
866 domtext_get_childNodes,
867 domtext_get_firstChild,
868 domtext_get_lastChild,
869 domtext_get_previousSibling,
870 domtext_get_nextSibling,
871 domtext_get_attributes,
872 domtext_insertBefore,
873 domtext_replaceChild,
874 domtext_removeChild,
875 domtext_appendChild,
876 domtext_hasChildNodes,
877 domtext_get_ownerDocument,
878 domtext_cloneNode,
879 domtext_get_nodeTypeString,
880 domtext_get_text,
881 domtext_put_text,
882 domtext_get_specified,
883 domtext_get_definition,
884 domtext_get_nodeTypedValue,
885 domtext_put_nodeTypedValue,
886 domtext_get_dataType,
887 domtext_put_dataType,
888 domtext_get_xml,
889 domtext_transformNode,
890 domtext_selectNodes,
891 domtext_selectSingleNode,
892 domtext_get_parsed,
893 domtext_get_namespaceURI,
894 domtext_get_prefix,
895 domtext_get_baseName,
896 domtext_transformNodeToObject,
897 domtext_get_data,
898 domtext_put_data,
899 domtext_get_length,
900 domtext_substringData,
901 domtext_appendData,
902 domtext_insertData,
903 domtext_deleteData,
904 domtext_replaceData,
905 domtext_splitText
908 static const tid_t domtext_iface_tids[] = {
909 IXMLDOMText_tid,
913 static dispex_static_data_t domtext_dispex = {
914 NULL,
915 IXMLDOMText_tid,
916 NULL,
917 domtext_iface_tids
920 IUnknown* create_text( xmlNodePtr text )
922 domtext *This;
924 This = heap_alloc( sizeof *This );
925 if ( !This )
926 return NULL;
928 This->IXMLDOMText_iface.lpVtbl = &domtext_vtbl;
929 This->ref = 1;
931 init_xmlnode(&This->node, text, (IXMLDOMNode*)&This->IXMLDOMText_iface, &domtext_dispex);
933 return (IUnknown*)&This->IXMLDOMText_iface;
936 #endif