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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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;
44 IUnknown *element_unk;
45 IXMLDOMElement *element;
48 static inline domtext *impl_from_IXMLDOMText( IXMLDOMText *iface )
50 return (domtext *)((char*)iface - FIELD_OFFSET(domtext, lpVtbl));
53 static HRESULT WINAPI domtext_QueryInterface(
58 domtext *This = impl_from_IXMLDOMText( iface );
59 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
61 if ( IsEqualGUID( riid, &IID_IXMLDOMText ) ||
62 IsEqualGUID( riid, &IID_IUnknown ) )
66 else if ( IsEqualGUID( riid, &IID_IDispatch ) ||
67 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
68 IsEqualGUID( riid, &IID_IXMLDOMElement ) )
70 return IUnknown_QueryInterface(This->element_unk, riid, ppvObject);
74 FIXME("Unsupported inteferace %s\n", debugstr_guid(riid));
78 IXMLDOMText_AddRef( iface );
83 static ULONG WINAPI domtext_AddRef(
86 domtext *This = impl_from_IXMLDOMText( iface );
87 return InterlockedIncrement( &This->ref );
90 static ULONG WINAPI domtext_Release(
93 domtext *This = impl_from_IXMLDOMText( iface );
96 ref = InterlockedDecrement( &This->ref );
99 IUnknown_Release( This->element_unk );
100 HeapFree( GetProcessHeap(), 0, This );
106 static HRESULT WINAPI domtext_GetTypeInfoCount(
114 static HRESULT WINAPI domtext_GetTypeInfo(
116 UINT iTInfo, LCID lcid,
117 ITypeInfo** ppTInfo )
123 static HRESULT WINAPI domtext_GetIDsOfNames(
125 REFIID riid, LPOLESTR* rgszNames,
126 UINT cNames, LCID lcid, DISPID* rgDispId )
132 static HRESULT WINAPI domtext_Invoke(
134 DISPID dispIdMember, REFIID riid, LCID lcid,
135 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
136 EXCEPINFO* pExcepInfo, UINT* puArgErr )
142 static HRESULT WINAPI domtext_get_nodeName(
146 domtext *This = impl_from_IXMLDOMText( iface );
147 return IXMLDOMNode_get_nodeName( This->element, p );
150 static HRESULT WINAPI domtext_get_nodeValue(
154 domtext *This = impl_from_IXMLDOMText( iface );
155 return IXMLDOMNode_get_nodeValue( This->element, var1 );
158 static HRESULT WINAPI domtext_put_nodeValue(
162 domtext *This = impl_from_IXMLDOMText( iface );
163 return IXMLDOMNode_put_nodeValue( This->element, var1 );
166 static HRESULT WINAPI domtext_get_nodeType(
168 DOMNodeType* domNodeType )
170 domtext *This = impl_from_IXMLDOMText( iface );
171 return IXMLDOMNode_get_nodeType( This->element, domNodeType );
174 static HRESULT WINAPI domtext_get_parentNode(
176 IXMLDOMNode** parent )
178 domtext *This = impl_from_IXMLDOMText( iface );
179 return IXMLDOMNode_get_parentNode( This->element, parent );
182 static HRESULT WINAPI domtext_get_childNodes(
184 IXMLDOMNodeList** outList)
186 domtext *This = impl_from_IXMLDOMText( iface );
187 return IXMLDOMNode_get_childNodes( This->element, outList );
190 static HRESULT WINAPI domtext_get_firstChild(
192 IXMLDOMNode** domNode)
194 domtext *This = impl_from_IXMLDOMText( iface );
195 return IXMLDOMNode_get_firstChild( This->element, domNode );
198 static HRESULT WINAPI domtext_get_lastChild(
200 IXMLDOMNode** domNode)
202 domtext *This = impl_from_IXMLDOMText( iface );
203 return IXMLDOMNode_get_lastChild( This->element, domNode );
206 static HRESULT WINAPI domtext_get_previousSibling(
208 IXMLDOMNode** domNode)
210 domtext *This = impl_from_IXMLDOMText( iface );
211 return IXMLDOMNode_get_previousSibling( This->element, domNode );
214 static HRESULT WINAPI domtext_get_nextSibling(
216 IXMLDOMNode** domNode)
218 domtext *This = impl_from_IXMLDOMText( iface );
219 return IXMLDOMNode_get_nextSibling( This->element, domNode );
222 static HRESULT WINAPI domtext_get_attributes(
224 IXMLDOMNamedNodeMap** attributeMap)
226 domtext *This = impl_from_IXMLDOMText( iface );
227 return IXMLDOMNode_get_attributes( This->element, attributeMap );
230 static HRESULT WINAPI domtext_insertBefore(
232 IXMLDOMNode* newNode, VARIANT var1,
233 IXMLDOMNode** outOldNode)
235 domtext *This = impl_from_IXMLDOMText( iface );
236 return IXMLDOMNode_insertBefore( This->element, newNode, var1, outOldNode );
239 static HRESULT WINAPI domtext_replaceChild(
241 IXMLDOMNode* newNode,
242 IXMLDOMNode* oldNode,
243 IXMLDOMNode** outOldNode)
245 domtext *This = impl_from_IXMLDOMText( iface );
246 return IXMLDOMNode_replaceChild( This->element, newNode, oldNode, outOldNode );
249 static HRESULT WINAPI domtext_removeChild(
251 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
253 domtext *This = impl_from_IXMLDOMText( iface );
254 return IXMLDOMNode_removeChild( This->element, domNode, oldNode );
257 static HRESULT WINAPI domtext_appendChild(
259 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
261 domtext *This = impl_from_IXMLDOMText( iface );
262 return IXMLDOMNode_appendChild( This->element, newNode, outNewNode );
265 static HRESULT WINAPI domtext_hasChildNodes(
269 domtext *This = impl_from_IXMLDOMText( iface );
270 return IXMLDOMNode_hasChildNodes( This->element, pbool );
273 static HRESULT WINAPI domtext_get_ownerDocument(
275 IXMLDOMDocument** domDocument)
277 domtext *This = impl_from_IXMLDOMText( iface );
278 return IXMLDOMNode_get_ownerDocument( This->element, domDocument );
281 static HRESULT WINAPI domtext_cloneNode(
283 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
285 domtext *This = impl_from_IXMLDOMText( iface );
286 return IXMLDOMNode_cloneNode( This->element, pbool, outNode );
289 static HRESULT WINAPI domtext_get_nodeTypeString(
293 domtext *This = impl_from_IXMLDOMText( iface );
294 return IXMLDOMNode_get_nodeTypeString( This->element, p );
297 static HRESULT WINAPI domtext_get_text(
301 domtext *This = impl_from_IXMLDOMText( iface );
302 return IXMLDOMNode_get_text( This->element, p );
305 static HRESULT WINAPI domtext_put_text(
309 domtext *This = impl_from_IXMLDOMText( iface );
310 return IXMLDOMNode_put_text( This->element, p );
313 static HRESULT WINAPI domtext_get_specified(
317 domtext *This = impl_from_IXMLDOMText( iface );
318 return IXMLDOMNode_get_specified( This->element, pbool );
321 static HRESULT WINAPI domtext_get_definition(
323 IXMLDOMNode** domNode)
325 domtext *This = impl_from_IXMLDOMText( iface );
326 return IXMLDOMNode_get_definition( This->element, domNode );
329 static HRESULT WINAPI domtext_get_nodeTypedValue(
333 domtext *This = impl_from_IXMLDOMText( iface );
334 return IXMLDOMNode_get_nodeTypedValue( This->element, var1 );
337 static HRESULT WINAPI domtext_put_nodeTypedValue(
341 domtext *This = impl_from_IXMLDOMText( iface );
342 return IXMLDOMNode_put_nodeTypedValue( This->element, var1 );
345 static HRESULT WINAPI domtext_get_dataType(
349 domtext *This = impl_from_IXMLDOMText( iface );
350 return IXMLDOMNode_get_dataType( This->element, var1 );
353 static HRESULT WINAPI domtext_put_dataType(
357 domtext *This = impl_from_IXMLDOMText( iface );
358 return IXMLDOMNode_put_dataType( This->element, p );
361 static HRESULT WINAPI domtext_get_xml(
365 domtext *This = impl_from_IXMLDOMText( iface );
366 return IXMLDOMNode_get_xml( This->element, p );
369 static HRESULT WINAPI domtext_transformNode(
371 IXMLDOMNode* domNode, BSTR* p)
373 domtext *This = impl_from_IXMLDOMText( iface );
374 return IXMLDOMNode_transformNode( This->element, domNode, p );
377 static HRESULT WINAPI domtext_selectNodes(
379 BSTR p, IXMLDOMNodeList** outList)
381 domtext *This = impl_from_IXMLDOMText( iface );
382 return IXMLDOMNode_selectNodes( This->element, p, outList );
385 static HRESULT WINAPI domtext_selectSingleNode(
387 BSTR p, IXMLDOMNode** outNode)
389 domtext *This = impl_from_IXMLDOMText( iface );
390 return IXMLDOMNode_selectSingleNode( This->element, p, outNode );
393 static HRESULT WINAPI domtext_get_parsed(
397 domtext *This = impl_from_IXMLDOMText( iface );
398 return IXMLDOMNode_get_parsed( This->element, pbool );
401 static HRESULT WINAPI domtext_get_namespaceURI(
405 domtext *This = impl_from_IXMLDOMText( iface );
406 return IXMLDOMNode_get_namespaceURI( This->element, p );
409 static HRESULT WINAPI domtext_get_prefix(
413 domtext *This = impl_from_IXMLDOMText( iface );
414 return IXMLDOMNode_get_prefix( This->element, p );
417 static HRESULT WINAPI domtext_get_baseName(
421 domtext *This = impl_from_IXMLDOMText( iface );
422 return IXMLDOMNode_get_baseName( This->element, p );
425 static HRESULT WINAPI domtext_transformNodeToObject(
427 IXMLDOMNode* domNode, VARIANT var1)
429 domtext *This = impl_from_IXMLDOMText( iface );
430 return IXMLDOMNode_transformNodeToObject( This->element, domNode, var1 );
433 static HRESULT WINAPI domtext_get_data(
441 static HRESULT WINAPI domtext_put_data(
449 static HRESULT WINAPI domtext_get_length(
457 static HRESULT WINAPI domtext_substringData(
459 long offset, long count, BSTR *p)
465 static HRESULT WINAPI domtext_appendData(
473 static HRESULT WINAPI domtext_insertData(
481 static HRESULT WINAPI domtext_deleteData(
483 long offset, long count)
489 static HRESULT WINAPI domtext_replaceData(
491 long offset, long count, BSTR p)
497 static HRESULT WINAPI domtext_splitText(
499 long offset, IXMLDOMText **txtNode)
506 static const struct IXMLDOMTextVtbl domtext_vtbl =
508 domtext_QueryInterface,
511 domtext_GetTypeInfoCount,
513 domtext_GetIDsOfNames,
515 domtext_get_nodeName,
516 domtext_get_nodeValue,
517 domtext_put_nodeValue,
518 domtext_get_nodeType,
519 domtext_get_parentNode,
520 domtext_get_childNodes,
521 domtext_get_firstChild,
522 domtext_get_lastChild,
523 domtext_get_previousSibling,
524 domtext_get_nextSibling,
525 domtext_get_attributes,
526 domtext_insertBefore,
527 domtext_replaceChild,
530 domtext_hasChildNodes,
531 domtext_get_ownerDocument,
533 domtext_get_nodeTypeString,
536 domtext_get_specified,
537 domtext_get_definition,
538 domtext_get_nodeTypedValue,
539 domtext_put_nodeTypedValue,
540 domtext_get_dataType,
541 domtext_put_dataType,
543 domtext_transformNode,
545 domtext_selectSingleNode,
547 domtext_get_namespaceURI,
549 domtext_get_baseName,
550 domtext_transformNodeToObject,
554 domtext_substringData,
562 IUnknown* create_text( xmlNodePtr text )
567 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
571 This->lpVtbl = &domtext_vtbl;
574 This->element_unk = create_element( text, (IUnknown*)&This->lpVtbl );
575 if(!This->element_unk)
577 HeapFree(GetProcessHeap(), 0, This);
581 hr = IUnknown_QueryInterface(This->element_unk, &IID_IXMLDOMNode, (LPVOID*)&This->element);
584 IUnknown_Release(This->element_unk);
585 HeapFree( GetProcessHeap(), 0, This );
588 /* The ref on This->element is actually looped back into this object, so release it */
589 IXMLDOMNode_Release(This->element);
591 return (IUnknown*) &This->lpVtbl;