2 * DOM processing instruction 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 _dom_pi
42 const struct IXMLDOMProcessingInstructionVtbl *lpVtbl;
48 static inline dom_pi *impl_from_IXMLDOMProcessingInstruction( IXMLDOMProcessingInstruction *iface )
50 return (dom_pi *)((char*)iface - FIELD_OFFSET(dom_pi, lpVtbl));
53 static inline xmlNodePtr get_pi( dom_pi *This )
55 return xmlNodePtr_from_domnode( This->node, XML_PI_NODE );
58 static HRESULT WINAPI dom_pi_QueryInterface(
59 IXMLDOMProcessingInstruction *iface,
63 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
64 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
66 if ( IsEqualGUID( riid, &IID_IXMLDOMProcessingInstruction ) ||
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 IXMLDOMProcessingInstruction_AddRef( iface );
87 static ULONG WINAPI dom_pi_AddRef(
88 IXMLDOMProcessingInstruction *iface )
90 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
91 return InterlockedIncrement( &This->ref );
94 static ULONG WINAPI dom_pi_Release(
95 IXMLDOMProcessingInstruction *iface )
97 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
100 ref = InterlockedDecrement( &This->ref );
103 IUnknown_Release( This->node_unk );
104 HeapFree( GetProcessHeap(), 0, This );
110 static HRESULT WINAPI dom_pi_GetTypeInfoCount(
111 IXMLDOMProcessingInstruction *iface,
118 static HRESULT WINAPI dom_pi_GetTypeInfo(
119 IXMLDOMProcessingInstruction *iface,
120 UINT iTInfo, LCID lcid,
121 ITypeInfo** ppTInfo )
127 static HRESULT WINAPI dom_pi_GetIDsOfNames(
128 IXMLDOMProcessingInstruction *iface,
129 REFIID riid, LPOLESTR* rgszNames,
130 UINT cNames, LCID lcid, DISPID* rgDispId )
136 static HRESULT WINAPI dom_pi_Invoke(
137 IXMLDOMProcessingInstruction *iface,
138 DISPID dispIdMember, REFIID riid, LCID lcid,
139 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
140 EXCEPINFO* pExcepInfo, UINT* puArgErr )
146 static HRESULT WINAPI dom_pi_get_nodeName(
147 IXMLDOMProcessingInstruction *iface,
150 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
151 return IXMLDOMNode_get_nodeName( This->node, p );
154 static HRESULT WINAPI dom_pi_get_nodeValue(
155 IXMLDOMProcessingInstruction *iface,
158 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
159 return IXMLDOMNode_get_nodeValue( This->node, var1 );
162 static HRESULT WINAPI dom_pi_put_nodeValue(
163 IXMLDOMProcessingInstruction *iface,
166 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
167 return IXMLDOMNode_put_nodeValue( This->node, var1 );
170 static HRESULT WINAPI dom_pi_get_nodeType(
171 IXMLDOMProcessingInstruction *iface,
172 DOMNodeType* domNodeType )
174 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
175 return IXMLDOMNode_get_nodeType( This->node, domNodeType );
178 static HRESULT WINAPI dom_pi_get_parentNode(
179 IXMLDOMProcessingInstruction *iface,
180 IXMLDOMNode** parent )
182 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
183 return IXMLDOMNode_get_parentNode( This->node, parent );
186 static HRESULT WINAPI dom_pi_get_childNodes(
187 IXMLDOMProcessingInstruction *iface,
188 IXMLDOMNodeList** outList)
190 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
191 return IXMLDOMNode_get_childNodes( This->node, outList );
194 static HRESULT WINAPI dom_pi_get_firstChild(
195 IXMLDOMProcessingInstruction *iface,
196 IXMLDOMNode** domNode)
198 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
199 return IXMLDOMNode_get_firstChild( This->node, domNode );
202 static HRESULT WINAPI dom_pi_get_lastChild(
203 IXMLDOMProcessingInstruction *iface,
204 IXMLDOMNode** domNode)
206 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
207 return IXMLDOMNode_get_lastChild( This->node, domNode );
210 static HRESULT WINAPI dom_pi_get_previousSibling(
211 IXMLDOMProcessingInstruction *iface,
212 IXMLDOMNode** domNode)
214 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
215 return IXMLDOMNode_get_previousSibling( This->node, domNode );
218 static HRESULT WINAPI dom_pi_get_nextSibling(
219 IXMLDOMProcessingInstruction *iface,
220 IXMLDOMNode** domNode)
222 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
223 return IXMLDOMNode_get_nextSibling( This->node, domNode );
226 static HRESULT WINAPI dom_pi_get_attributes(
227 IXMLDOMProcessingInstruction *iface,
228 IXMLDOMNamedNodeMap** attributeMap)
230 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
231 return IXMLDOMNode_get_attributes( This->node, attributeMap );
234 static HRESULT WINAPI dom_pi_insertBefore(
235 IXMLDOMProcessingInstruction *iface,
236 IXMLDOMNode* newNode, VARIANT var1,
237 IXMLDOMNode** outOldNode)
239 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
240 return IXMLDOMNode_insertBefore( This->node, newNode, var1, outOldNode );
243 static HRESULT WINAPI dom_pi_replaceChild(
244 IXMLDOMProcessingInstruction *iface,
245 IXMLDOMNode* newNode,
246 IXMLDOMNode* oldNode,
247 IXMLDOMNode** outOldNode)
249 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
250 return IXMLDOMNode_replaceChild( This->node, newNode, oldNode, outOldNode );
253 static HRESULT WINAPI dom_pi_removeChild(
254 IXMLDOMProcessingInstruction *iface,
255 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
257 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
258 return IXMLDOMNode_removeChild( This->node, domNode, oldNode );
261 static HRESULT WINAPI dom_pi_appendChild(
262 IXMLDOMProcessingInstruction *iface,
263 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
265 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
266 return IXMLDOMNode_appendChild( This->node, newNode, outNewNode );
269 static HRESULT WINAPI dom_pi_hasChildNodes(
270 IXMLDOMProcessingInstruction *iface,
273 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
274 return IXMLDOMNode_hasChildNodes( This->node, pbool );
277 static HRESULT WINAPI dom_pi_get_ownerDocument(
278 IXMLDOMProcessingInstruction *iface,
279 IXMLDOMDocument** domDocument)
281 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
282 return IXMLDOMNode_get_ownerDocument( This->node, domDocument );
285 static HRESULT WINAPI dom_pi_cloneNode(
286 IXMLDOMProcessingInstruction *iface,
287 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
289 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
290 return IXMLDOMNode_cloneNode( This->node, pbool, outNode );
293 static HRESULT WINAPI dom_pi_get_nodeTypeString(
294 IXMLDOMProcessingInstruction *iface,
297 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
298 return IXMLDOMNode_get_nodeTypeString( This->node, p );
301 static HRESULT WINAPI dom_pi_get_text(
302 IXMLDOMProcessingInstruction *iface,
305 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
306 return IXMLDOMNode_get_text( This->node, p );
309 static HRESULT WINAPI dom_pi_put_text(
310 IXMLDOMProcessingInstruction *iface,
313 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
314 return IXMLDOMNode_put_text( This->node, p );
317 static HRESULT WINAPI dom_pi_get_specified(
318 IXMLDOMProcessingInstruction *iface,
321 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
322 return IXMLDOMNode_get_specified( This->node, pbool );
325 static HRESULT WINAPI dom_pi_get_definition(
326 IXMLDOMProcessingInstruction *iface,
327 IXMLDOMNode** domNode)
329 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
330 return IXMLDOMNode_get_definition( This->node, domNode );
333 static HRESULT WINAPI dom_pi_get_nodeTypedValue(
334 IXMLDOMProcessingInstruction *iface,
337 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
338 return IXMLDOMNode_get_nodeTypedValue( This->node, var1 );
341 static HRESULT WINAPI dom_pi_put_nodeTypedValue(
342 IXMLDOMProcessingInstruction *iface,
345 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
346 return IXMLDOMNode_put_nodeTypedValue( This->node, var1 );
349 static HRESULT WINAPI dom_pi_get_dataType(
350 IXMLDOMProcessingInstruction *iface,
353 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
354 return IXMLDOMNode_get_dataType( This->node, var1 );
357 static HRESULT WINAPI dom_pi_put_dataType(
358 IXMLDOMProcessingInstruction *iface,
361 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
362 return IXMLDOMNode_put_dataType( This->node, p );
365 static HRESULT WINAPI dom_pi_get_xml(
366 IXMLDOMProcessingInstruction *iface,
369 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
370 return IXMLDOMNode_get_xml( This->node, p );
373 static HRESULT WINAPI dom_pi_transformNode(
374 IXMLDOMProcessingInstruction *iface,
375 IXMLDOMNode* domNode, BSTR* p)
377 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
378 return IXMLDOMNode_transformNode( This->node, domNode, p );
381 static HRESULT WINAPI dom_pi_selectNodes(
382 IXMLDOMProcessingInstruction *iface,
383 BSTR p, IXMLDOMNodeList** outList)
385 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
386 return IXMLDOMNode_selectNodes( This->node, p, outList );
389 static HRESULT WINAPI dom_pi_selectSingleNode(
390 IXMLDOMProcessingInstruction *iface,
391 BSTR p, IXMLDOMNode** outNode)
393 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
394 return IXMLDOMNode_selectSingleNode( This->node, p, outNode );
397 static HRESULT WINAPI dom_pi_get_parsed(
398 IXMLDOMProcessingInstruction *iface,
401 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
402 return IXMLDOMNode_get_parsed( This->node, pbool );
405 static HRESULT WINAPI dom_pi_get_namespaceURI(
406 IXMLDOMProcessingInstruction *iface,
409 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
410 return IXMLDOMNode_get_namespaceURI( This->node, p );
413 static HRESULT WINAPI dom_pi_get_prefix(
414 IXMLDOMProcessingInstruction *iface,
417 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
418 return IXMLDOMNode_get_prefix( This->node, p );
421 static HRESULT WINAPI dom_pi_get_baseName(
422 IXMLDOMProcessingInstruction *iface,
425 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
426 return IXMLDOMNode_get_baseName( This->node, p );
429 static HRESULT WINAPI dom_pi_transformNodeToObject(
430 IXMLDOMProcessingInstruction *iface,
431 IXMLDOMNode* domNode, VARIANT var1)
433 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
434 return IXMLDOMNode_transformNodeToObject( This->node, domNode, var1 );
437 static HRESULT WINAPI dom_pi_get_target(
438 IXMLDOMProcessingInstruction *iface,
445 static HRESULT WINAPI dom_pi_get_data(
446 IXMLDOMProcessingInstruction *iface,
453 static HRESULT WINAPI dom_pi_put_data(
454 IXMLDOMProcessingInstruction *iface,
461 static const struct IXMLDOMProcessingInstructionVtbl dom_pi_vtbl =
463 dom_pi_QueryInterface,
466 dom_pi_GetTypeInfoCount,
468 dom_pi_GetIDsOfNames,
471 dom_pi_get_nodeValue,
472 dom_pi_put_nodeValue,
474 dom_pi_get_parentNode,
475 dom_pi_get_childNodes,
476 dom_pi_get_firstChild,
477 dom_pi_get_lastChild,
478 dom_pi_get_previousSibling,
479 dom_pi_get_nextSibling,
480 dom_pi_get_attributes,
485 dom_pi_hasChildNodes,
486 dom_pi_get_ownerDocument,
488 dom_pi_get_nodeTypeString,
491 dom_pi_get_specified,
492 dom_pi_get_definition,
493 dom_pi_get_nodeTypedValue,
494 dom_pi_put_nodeTypedValue,
498 dom_pi_transformNode,
500 dom_pi_selectSingleNode,
502 dom_pi_get_namespaceURI,
505 dom_pi_transformNodeToObject,
512 IUnknown* create_pi( xmlNodePtr pi )
517 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
521 This->lpVtbl = &dom_pi_vtbl;
524 This->node_unk = create_basic_node( pi, (IUnknown*)&This->lpVtbl );
527 HeapFree(GetProcessHeap(), 0, This);
531 hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
534 IUnknown_Release(This->node_unk);
535 HeapFree( GetProcessHeap(), 0, This );
538 /* The ref on This->node is actually looped back into this object, so release it */
539 IXMLDOMNode_Release(This->node);
541 return (IUnknown*) &This->lpVtbl;