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
43 IXMLDOMProcessingInstruction IXMLDOMProcessingInstruction_iface;
47 static inline dom_pi *impl_from_IXMLDOMProcessingInstruction( IXMLDOMProcessingInstruction *iface )
49 return CONTAINING_RECORD(iface, dom_pi, IXMLDOMProcessingInstruction_iface);
52 static HRESULT WINAPI dom_pi_QueryInterface(
53 IXMLDOMProcessingInstruction *iface,
57 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
58 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
60 if ( IsEqualGUID( riid, &IID_IXMLDOMProcessingInstruction ) ||
61 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
62 IsEqualGUID( riid, &IID_IDispatch ) ||
63 IsEqualGUID( riid, &IID_IUnknown ) )
67 else if(node_query_interface(&This->node, riid, ppvObject))
69 return *ppvObject ? S_OK : E_NOINTERFACE;
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
77 IUnknown_AddRef((IUnknown*)*ppvObject);
81 static ULONG WINAPI dom_pi_AddRef(
82 IXMLDOMProcessingInstruction *iface )
84 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
85 return InterlockedIncrement( &This->ref );
88 static ULONG WINAPI dom_pi_Release(
89 IXMLDOMProcessingInstruction *iface )
91 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
94 ref = InterlockedDecrement( &This->ref );
97 destroy_xmlnode(&This->node);
104 static HRESULT WINAPI dom_pi_GetTypeInfoCount(
105 IXMLDOMProcessingInstruction *iface,
108 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
110 TRACE("(%p)->(%p)\n", This, pctinfo);
117 static HRESULT WINAPI dom_pi_GetTypeInfo(
118 IXMLDOMProcessingInstruction *iface,
119 UINT iTInfo, LCID lcid,
120 ITypeInfo** ppTInfo )
122 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
125 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
127 hr = get_typeinfo(IXMLDOMProcessingInstruction_tid, ppTInfo);
132 static HRESULT WINAPI dom_pi_GetIDsOfNames(
133 IXMLDOMProcessingInstruction *iface,
134 REFIID riid, LPOLESTR* rgszNames,
135 UINT cNames, LCID lcid, DISPID* rgDispId )
137 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
141 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
144 if(!rgszNames || cNames == 0 || !rgDispId)
147 hr = get_typeinfo(IXMLDOMProcessingInstruction_tid, &typeinfo);
150 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
151 ITypeInfo_Release(typeinfo);
157 static HRESULT WINAPI dom_pi_Invoke(
158 IXMLDOMProcessingInstruction *iface,
159 DISPID dispIdMember, REFIID riid, LCID lcid,
160 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
161 EXCEPINFO* pExcepInfo, UINT* puArgErr )
163 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
167 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
168 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
170 hr = get_typeinfo(IXMLDOMProcessingInstruction_tid, &typeinfo);
173 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMProcessingInstruction_iface, dispIdMember,
174 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
175 ITypeInfo_Release(typeinfo);
181 static HRESULT WINAPI dom_pi_get_nodeName(
182 IXMLDOMProcessingInstruction *iface,
185 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
187 TRACE("(%p)->(%p)\n", This, p);
189 return node_get_nodeName(&This->node, p);
192 static HRESULT WINAPI dom_pi_get_nodeValue(
193 IXMLDOMProcessingInstruction *iface,
196 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
198 TRACE("(%p)->(%p)\n", This, value);
200 return node_get_content(&This->node, value);
203 static HRESULT WINAPI dom_pi_put_nodeValue(
204 IXMLDOMProcessingInstruction *iface,
207 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
211 TRACE("(%p)->(v%d)\n", This, V_VT(&value));
213 /* Cannot set data to a PI node whose target is 'xml' */
214 hr = dom_pi_get_nodeName(iface, &sTarget);
217 static const WCHAR xmlW[] = {'x','m','l',0};
218 if(lstrcmpW( sTarget, xmlW) == 0)
220 SysFreeString(sTarget);
224 SysFreeString(sTarget);
227 return node_put_value(&This->node, &value);
230 static HRESULT WINAPI dom_pi_get_nodeType(
231 IXMLDOMProcessingInstruction *iface,
232 DOMNodeType* domNodeType )
234 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
236 TRACE("(%p)->(%p)\n", This, domNodeType);
238 *domNodeType = NODE_PROCESSING_INSTRUCTION;
242 static HRESULT WINAPI dom_pi_get_parentNode(
243 IXMLDOMProcessingInstruction *iface,
244 IXMLDOMNode** parent )
246 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
248 TRACE("(%p)->(%p)\n", This, parent);
250 return node_get_parent(&This->node, parent);
253 static HRESULT WINAPI dom_pi_get_childNodes(
254 IXMLDOMProcessingInstruction *iface,
255 IXMLDOMNodeList** outList)
257 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
259 TRACE("(%p)->(%p)\n", This, outList);
261 return node_get_child_nodes(&This->node, outList);
264 static HRESULT WINAPI dom_pi_get_firstChild(
265 IXMLDOMProcessingInstruction *iface,
266 IXMLDOMNode** domNode)
268 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
270 TRACE("(%p)->(%p)\n", This, domNode);
272 return return_null_node(domNode);
275 static HRESULT WINAPI dom_pi_get_lastChild(
276 IXMLDOMProcessingInstruction *iface,
277 IXMLDOMNode** domNode)
279 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
281 TRACE("(%p)->(%p)\n", This, domNode);
283 return return_null_node(domNode);
286 static HRESULT WINAPI dom_pi_get_previousSibling(
287 IXMLDOMProcessingInstruction *iface,
288 IXMLDOMNode** domNode)
290 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
292 TRACE("(%p)->(%p)\n", This, domNode);
294 return node_get_previous_sibling(&This->node, domNode);
297 static HRESULT WINAPI dom_pi_get_nextSibling(
298 IXMLDOMProcessingInstruction *iface,
299 IXMLDOMNode** domNode)
301 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
303 TRACE("(%p)->(%p)\n", This, domNode);
305 return node_get_next_sibling(&This->node, domNode);
308 static HRESULT WINAPI dom_pi_get_attributes(
309 IXMLDOMProcessingInstruction *iface,
310 IXMLDOMNamedNodeMap** attributeMap)
312 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
314 TRACE("(%p)->(%p)\n", This, attributeMap);
316 *attributeMap = create_nodemap((IXMLDOMNode*)&This->IXMLDOMProcessingInstruction_iface);
320 static HRESULT WINAPI dom_pi_insertBefore(
321 IXMLDOMProcessingInstruction *iface,
322 IXMLDOMNode* newNode, VARIANT refChild,
323 IXMLDOMNode** outOldNode)
325 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
327 FIXME("(%p)->(%p x%d %p) needs test\n", This, newNode, V_VT(&refChild), outOldNode);
329 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
332 static HRESULT WINAPI dom_pi_replaceChild(
333 IXMLDOMProcessingInstruction *iface,
334 IXMLDOMNode* newNode,
335 IXMLDOMNode* oldNode,
336 IXMLDOMNode** outOldNode)
338 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
340 FIXME("(%p)->(%p %p %p) needs test\n", This, newNode, oldNode, outOldNode);
342 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
345 static HRESULT WINAPI dom_pi_removeChild(
346 IXMLDOMProcessingInstruction *iface,
347 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
349 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
350 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
353 static HRESULT WINAPI dom_pi_appendChild(
354 IXMLDOMProcessingInstruction *iface,
355 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
357 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
358 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
361 static HRESULT WINAPI dom_pi_hasChildNodes(
362 IXMLDOMProcessingInstruction *iface,
365 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
366 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
369 static HRESULT WINAPI dom_pi_get_ownerDocument(
370 IXMLDOMProcessingInstruction *iface,
371 IXMLDOMDocument** domDocument)
373 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
374 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
377 static HRESULT WINAPI dom_pi_cloneNode(
378 IXMLDOMProcessingInstruction *iface,
379 VARIANT_BOOL deep, IXMLDOMNode** outNode)
381 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
382 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
383 return node_clone( &This->node, deep, outNode );
386 static HRESULT WINAPI dom_pi_get_nodeTypeString(
387 IXMLDOMProcessingInstruction *iface,
390 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
391 static const WCHAR processinginstructionW[] =
392 {'p','r','o','c','e','s','s','i','n','g','i','n','s','t','r','u','c','t','i','o','n',0};
394 TRACE("(%p)->(%p)\n", This, p);
396 return return_bstr(processinginstructionW, p);
399 static HRESULT WINAPI dom_pi_get_text(
400 IXMLDOMProcessingInstruction *iface,
403 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
404 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
407 static HRESULT WINAPI dom_pi_put_text(
408 IXMLDOMProcessingInstruction *iface,
411 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
412 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
413 return node_put_text( &This->node, p );
416 static HRESULT WINAPI dom_pi_get_specified(
417 IXMLDOMProcessingInstruction *iface,
418 VARIANT_BOOL* isSpecified)
420 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
421 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
422 *isSpecified = VARIANT_TRUE;
426 static HRESULT WINAPI dom_pi_get_definition(
427 IXMLDOMProcessingInstruction *iface,
428 IXMLDOMNode** definitionNode)
430 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
431 FIXME("(%p)->(%p)\n", This, definitionNode);
435 static HRESULT WINAPI dom_pi_get_nodeTypedValue(
436 IXMLDOMProcessingInstruction *iface,
439 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
440 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
443 static HRESULT WINAPI dom_pi_put_nodeTypedValue(
444 IXMLDOMProcessingInstruction *iface,
447 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
448 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
452 static HRESULT WINAPI dom_pi_get_dataType(
453 IXMLDOMProcessingInstruction *iface,
456 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
457 TRACE("(%p)->(%p)\n", This, typename);
458 return return_null_var( typename );
461 static HRESULT WINAPI dom_pi_put_dataType(
462 IXMLDOMProcessingInstruction *iface,
465 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
467 FIXME("(%p)->(%s)\n", This, debugstr_w(p));
475 static HRESULT WINAPI dom_pi_get_xml(
476 IXMLDOMProcessingInstruction *iface,
479 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
481 TRACE("(%p)->(%p)\n", This, p);
483 return node_get_xml(&This->node, FALSE, FALSE, p);
486 static HRESULT WINAPI dom_pi_transformNode(
487 IXMLDOMProcessingInstruction *iface,
488 IXMLDOMNode* domNode, BSTR* p)
490 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
491 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
494 static HRESULT WINAPI dom_pi_selectNodes(
495 IXMLDOMProcessingInstruction *iface,
496 BSTR p, IXMLDOMNodeList** outList)
498 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
499 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
502 static HRESULT WINAPI dom_pi_selectSingleNode(
503 IXMLDOMProcessingInstruction *iface,
504 BSTR p, IXMLDOMNode** outNode)
506 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
507 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
510 static HRESULT WINAPI dom_pi_get_parsed(
511 IXMLDOMProcessingInstruction *iface,
512 VARIANT_BOOL* isParsed)
514 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
515 FIXME("(%p)->(%p) stub!\n", This, isParsed);
516 *isParsed = VARIANT_TRUE;
520 static HRESULT WINAPI dom_pi_get_namespaceURI(
521 IXMLDOMProcessingInstruction *iface,
524 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
525 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
528 static HRESULT WINAPI dom_pi_get_prefix(
529 IXMLDOMProcessingInstruction *iface,
532 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
533 TRACE("(%p)->(%p)\n", This, prefix);
534 return return_null_bstr( prefix );
537 static HRESULT WINAPI dom_pi_get_baseName(
538 IXMLDOMProcessingInstruction *iface,
541 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
542 TRACE("(%p)->(%p)\n", This, name);
543 return node_get_base_name( &This->node, name );
546 static HRESULT WINAPI dom_pi_transformNodeToObject(
547 IXMLDOMProcessingInstruction *iface,
548 IXMLDOMNode* domNode, VARIANT var1)
550 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
551 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
554 static HRESULT WINAPI dom_pi_get_target(
555 IXMLDOMProcessingInstruction *iface,
558 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
560 TRACE("(%p)->(%p)\n", This, p);
562 /* target returns the same value as nodeName property */
563 return node_get_nodeName(&This->node, p);
566 static HRESULT WINAPI dom_pi_get_data(
567 IXMLDOMProcessingInstruction *iface,
570 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
574 TRACE("(%p)->(%p)\n", This, p);
579 hr = IXMLDOMProcessingInstruction_get_nodeValue( iface, &ret );
588 static HRESULT WINAPI dom_pi_put_data(
589 IXMLDOMProcessingInstruction *iface,
592 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
597 TRACE("(%p)->(%s)\n", This, debugstr_w(data) );
599 /* Cannot set data to a PI node whose target is 'xml' */
600 hr = dom_pi_get_nodeName(iface, &sTarget);
603 static const WCHAR xmlW[] = {'x','m','l',0};
604 if(lstrcmpW( sTarget, xmlW) == 0)
606 SysFreeString(sTarget);
610 SysFreeString(sTarget);
613 V_VT(&val) = VT_BSTR;
616 return IXMLDOMProcessingInstruction_put_nodeValue( iface, val );
619 static const struct IXMLDOMProcessingInstructionVtbl dom_pi_vtbl =
621 dom_pi_QueryInterface,
624 dom_pi_GetTypeInfoCount,
626 dom_pi_GetIDsOfNames,
629 dom_pi_get_nodeValue,
630 dom_pi_put_nodeValue,
632 dom_pi_get_parentNode,
633 dom_pi_get_childNodes,
634 dom_pi_get_firstChild,
635 dom_pi_get_lastChild,
636 dom_pi_get_previousSibling,
637 dom_pi_get_nextSibling,
638 dom_pi_get_attributes,
643 dom_pi_hasChildNodes,
644 dom_pi_get_ownerDocument,
646 dom_pi_get_nodeTypeString,
649 dom_pi_get_specified,
650 dom_pi_get_definition,
651 dom_pi_get_nodeTypedValue,
652 dom_pi_put_nodeTypedValue,
656 dom_pi_transformNode,
658 dom_pi_selectSingleNode,
660 dom_pi_get_namespaceURI,
663 dom_pi_transformNodeToObject,
670 IUnknown* create_pi( xmlNodePtr pi )
674 This = heap_alloc( sizeof *This );
678 This->IXMLDOMProcessingInstruction_iface.lpVtbl = &dom_pi_vtbl;
681 init_xmlnode(&This->node, pi, (IXMLDOMNode*)&This->IXMLDOMProcessingInstruction_iface, NULL);
683 return (IUnknown*)&This->IXMLDOMProcessingInstruction_iface;