2 * DOM text node implementation
4 * Copyright 2006 Huw Davies
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
40 typedef struct _domtext
42 const struct IXMLDOMTextVtbl *lpVtbl;
48 static inline domtext *impl_from_IXMLDOMText( IXMLDOMText *iface )
50 return (domtext *)((char*)iface - FIELD_OFFSET(domtext, lpVtbl));
53 static inline xmlNodePtr get_text( domtext *This )
55 return xmlNodePtr_from_domnode( This->node, XML_TEXT_NODE );
58 static HRESULT WINAPI domtext_QueryInterface(
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_IUnknown ) )
71 else if ( IsEqualGUID( riid, &IID_IDispatch ) ||
72 IsEqualGUID( riid, &IID_IXMLDOMNode ) )
74 return IUnknown_QueryInterface(This->node_unk, riid, ppvObject);
78 FIXME("Unsupported inteferace %s\n", debugstr_guid(riid));
82 IXMLDOMText_AddRef( iface );
87 static ULONG WINAPI domtext_AddRef(
90 domtext *This = impl_from_IXMLDOMText( iface );
91 return InterlockedIncrement( &This->ref );
94 static ULONG WINAPI domtext_Release(
97 domtext *This = impl_from_IXMLDOMText( iface );
100 ref = InterlockedDecrement( &This->ref );
103 IUnknown_Release( This->node_unk );
104 HeapFree( GetProcessHeap(), 0, This );
110 static HRESULT WINAPI domtext_GetTypeInfoCount(
118 static HRESULT WINAPI domtext_GetTypeInfo(
120 UINT iTInfo, LCID lcid,
121 ITypeInfo** ppTInfo )
127 static HRESULT WINAPI domtext_GetIDsOfNames(
129 REFIID riid, LPOLESTR* rgszNames,
130 UINT cNames, LCID lcid, DISPID* rgDispId )
136 static HRESULT WINAPI domtext_Invoke(
138 DISPID dispIdMember, REFIID riid, LCID lcid,
139 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
140 EXCEPINFO* pExcepInfo, UINT* puArgErr )
146 static HRESULT WINAPI domtext_get_nodeName(
150 domtext *This = impl_from_IXMLDOMText( iface );
151 return IXMLDOMNode_get_nodeName( This->node, p );
154 static HRESULT WINAPI domtext_get_nodeValue(
158 domtext *This = impl_from_IXMLDOMText( iface );
159 return IXMLDOMNode_get_nodeValue( This->node, var1 );
162 static HRESULT WINAPI domtext_put_nodeValue(
166 domtext *This = impl_from_IXMLDOMText( iface );
167 return IXMLDOMNode_put_nodeValue( This->node, var1 );
170 static HRESULT WINAPI domtext_get_nodeType(
172 DOMNodeType* domNodeType )
174 domtext *This = impl_from_IXMLDOMText( iface );
175 return IXMLDOMNode_get_nodeType( This->node, domNodeType );
178 static HRESULT WINAPI domtext_get_parentNode(
180 IXMLDOMNode** parent )
182 domtext *This = impl_from_IXMLDOMText( iface );
183 return IXMLDOMNode_get_parentNode( This->node, parent );
186 static HRESULT WINAPI domtext_get_childNodes(
188 IXMLDOMNodeList** outList)
190 domtext *This = impl_from_IXMLDOMText( iface );
191 return IXMLDOMNode_get_childNodes( This->node, outList );
194 static HRESULT WINAPI domtext_get_firstChild(
196 IXMLDOMNode** domNode)
198 domtext *This = impl_from_IXMLDOMText( iface );
199 return IXMLDOMNode_get_firstChild( This->node, domNode );
202 static HRESULT WINAPI domtext_get_lastChild(
204 IXMLDOMNode** domNode)
206 domtext *This = impl_from_IXMLDOMText( iface );
207 return IXMLDOMNode_get_lastChild( This->node, domNode );
210 static HRESULT WINAPI domtext_get_previousSibling(
212 IXMLDOMNode** domNode)
214 domtext *This = impl_from_IXMLDOMText( iface );
215 return IXMLDOMNode_get_previousSibling( This->node, domNode );
218 static HRESULT WINAPI domtext_get_nextSibling(
220 IXMLDOMNode** domNode)
222 domtext *This = impl_from_IXMLDOMText( iface );
223 return IXMLDOMNode_get_nextSibling( This->node, domNode );
226 static HRESULT WINAPI domtext_get_attributes(
228 IXMLDOMNamedNodeMap** attributeMap)
230 domtext *This = impl_from_IXMLDOMText( iface );
231 return IXMLDOMNode_get_attributes( This->node, attributeMap );
234 static HRESULT WINAPI domtext_insertBefore(
236 IXMLDOMNode* newNode, VARIANT var1,
237 IXMLDOMNode** outOldNode)
239 domtext *This = impl_from_IXMLDOMText( iface );
240 return IXMLDOMNode_insertBefore( This->node, newNode, var1, outOldNode );
243 static HRESULT WINAPI domtext_replaceChild(
245 IXMLDOMNode* newNode,
246 IXMLDOMNode* oldNode,
247 IXMLDOMNode** outOldNode)
249 domtext *This = impl_from_IXMLDOMText( iface );
250 return IXMLDOMNode_replaceChild( This->node, newNode, oldNode, outOldNode );
253 static HRESULT WINAPI domtext_removeChild(
255 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
257 domtext *This = impl_from_IXMLDOMText( iface );
258 return IXMLDOMNode_removeChild( This->node, domNode, oldNode );
261 static HRESULT WINAPI domtext_appendChild(
263 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
265 domtext *This = impl_from_IXMLDOMText( iface );
266 return IXMLDOMNode_appendChild( This->node, newNode, outNewNode );
269 static HRESULT WINAPI domtext_hasChildNodes(
273 domtext *This = impl_from_IXMLDOMText( iface );
274 return IXMLDOMNode_hasChildNodes( This->node, pbool );
277 static HRESULT WINAPI domtext_get_ownerDocument(
279 IXMLDOMDocument** domDocument)
281 domtext *This = impl_from_IXMLDOMText( iface );
282 return IXMLDOMNode_get_ownerDocument( This->node, domDocument );
285 static HRESULT WINAPI domtext_cloneNode(
287 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
289 domtext *This = impl_from_IXMLDOMText( iface );
290 return IXMLDOMNode_cloneNode( This->node, pbool, outNode );
293 static HRESULT WINAPI domtext_get_nodeTypeString(
297 domtext *This = impl_from_IXMLDOMText( iface );
298 return IXMLDOMNode_get_nodeTypeString( This->node, p );
301 static HRESULT WINAPI domtext_get_text(
305 domtext *This = impl_from_IXMLDOMText( iface );
306 return IXMLDOMNode_get_text( This->node, p );
309 static HRESULT WINAPI domtext_put_text(
313 domtext *This = impl_from_IXMLDOMText( iface );
314 return IXMLDOMNode_put_text( This->node, p );
317 static HRESULT WINAPI domtext_get_specified(
321 domtext *This = impl_from_IXMLDOMText( iface );
322 return IXMLDOMNode_get_specified( This->node, pbool );
325 static HRESULT WINAPI domtext_get_definition(
327 IXMLDOMNode** domNode)
329 domtext *This = impl_from_IXMLDOMText( iface );
330 return IXMLDOMNode_get_definition( This->node, domNode );
333 static HRESULT WINAPI domtext_get_nodeTypedValue(
337 domtext *This = impl_from_IXMLDOMText( iface );
338 return IXMLDOMNode_get_nodeTypedValue( This->node, var1 );
341 static HRESULT WINAPI domtext_put_nodeTypedValue(
345 domtext *This = impl_from_IXMLDOMText( iface );
346 return IXMLDOMNode_put_nodeTypedValue( This->node, var1 );
349 static HRESULT WINAPI domtext_get_dataType(
353 domtext *This = impl_from_IXMLDOMText( iface );
354 return IXMLDOMNode_get_dataType( This->node, var1 );
357 static HRESULT WINAPI domtext_put_dataType(
361 domtext *This = impl_from_IXMLDOMText( iface );
362 return IXMLDOMNode_put_dataType( This->node, p );
365 static HRESULT WINAPI domtext_get_xml(
369 domtext *This = impl_from_IXMLDOMText( iface );
370 return IXMLDOMNode_get_xml( This->node, p );
373 static HRESULT WINAPI domtext_transformNode(
375 IXMLDOMNode* domNode, BSTR* p)
377 domtext *This = impl_from_IXMLDOMText( iface );
378 return IXMLDOMNode_transformNode( This->node, domNode, p );
381 static HRESULT WINAPI domtext_selectNodes(
383 BSTR p, IXMLDOMNodeList** outList)
385 domtext *This = impl_from_IXMLDOMText( iface );
386 return IXMLDOMNode_selectNodes( This->node, p, outList );
389 static HRESULT WINAPI domtext_selectSingleNode(
391 BSTR p, IXMLDOMNode** outNode)
393 domtext *This = impl_from_IXMLDOMText( iface );
394 return IXMLDOMNode_selectSingleNode( This->node, p, outNode );
397 static HRESULT WINAPI domtext_get_parsed(
401 domtext *This = impl_from_IXMLDOMText( iface );
402 return IXMLDOMNode_get_parsed( This->node, pbool );
405 static HRESULT WINAPI domtext_get_namespaceURI(
409 domtext *This = impl_from_IXMLDOMText( iface );
410 return IXMLDOMNode_get_namespaceURI( This->node, p );
413 static HRESULT WINAPI domtext_get_prefix(
417 domtext *This = impl_from_IXMLDOMText( iface );
418 return IXMLDOMNode_get_prefix( This->node, p );
421 static HRESULT WINAPI domtext_get_baseName(
425 domtext *This = impl_from_IXMLDOMText( iface );
426 return IXMLDOMNode_get_baseName( This->node, p );
429 static HRESULT WINAPI domtext_transformNodeToObject(
431 IXMLDOMNode* domNode, VARIANT var1)
433 domtext *This = impl_from_IXMLDOMText( iface );
434 return IXMLDOMNode_transformNodeToObject( This->node, domNode, var1 );
437 static HRESULT WINAPI domtext_get_data(
445 static HRESULT WINAPI domtext_put_data(
453 static HRESULT WINAPI domtext_get_length(
461 static HRESULT WINAPI domtext_substringData(
463 long offset, long count, BSTR *p)
469 static HRESULT WINAPI domtext_appendData(
477 static HRESULT WINAPI domtext_insertData(
485 static HRESULT WINAPI domtext_deleteData(
487 long offset, long count)
493 static HRESULT WINAPI domtext_replaceData(
495 long offset, long count, BSTR p)
501 static HRESULT WINAPI domtext_splitText(
503 long offset, IXMLDOMText **txtNode)
510 static const struct IXMLDOMTextVtbl domtext_vtbl =
512 domtext_QueryInterface,
515 domtext_GetTypeInfoCount,
517 domtext_GetIDsOfNames,
519 domtext_get_nodeName,
520 domtext_get_nodeValue,
521 domtext_put_nodeValue,
522 domtext_get_nodeType,
523 domtext_get_parentNode,
524 domtext_get_childNodes,
525 domtext_get_firstChild,
526 domtext_get_lastChild,
527 domtext_get_previousSibling,
528 domtext_get_nextSibling,
529 domtext_get_attributes,
530 domtext_insertBefore,
531 domtext_replaceChild,
534 domtext_hasChildNodes,
535 domtext_get_ownerDocument,
537 domtext_get_nodeTypeString,
540 domtext_get_specified,
541 domtext_get_definition,
542 domtext_get_nodeTypedValue,
543 domtext_put_nodeTypedValue,
544 domtext_get_dataType,
545 domtext_put_dataType,
547 domtext_transformNode,
549 domtext_selectSingleNode,
551 domtext_get_namespaceURI,
553 domtext_get_baseName,
554 domtext_transformNodeToObject,
558 domtext_substringData,
566 IUnknown* create_text( xmlNodePtr text )
571 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
575 This->lpVtbl = &domtext_vtbl;
578 This->node_unk = create_basic_node( text, (IUnknown*)&This->lpVtbl );
581 HeapFree(GetProcessHeap(), 0, This);
585 hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
588 IUnknown_Release(This->node_unk);
589 HeapFree( GetProcessHeap(), 0, This );
592 /* The ref on This->node is actually looped back into this object, so release it */
593 IXMLDOMNode_Release(This->node);
595 return (IUnknown*) &This->lpVtbl;