crypt32/tests: CertAddCertificateLinkToStore is not present on W98.
[wine/multimedia.git] / dlls / msxml3 / pi.c
blob44ccb965e87aa0e4a3e761a52eaff42ed93d4635
1 /*
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
21 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "msxml6.h"
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
38 #ifdef HAVE_LIBXML2
40 typedef struct _dom_pi
42 xmlnode node;
43 const struct IXMLDOMProcessingInstructionVtbl *lpVtbl;
44 LONG ref;
45 } dom_pi;
47 static inline dom_pi *impl_from_IXMLDOMProcessingInstruction( IXMLDOMProcessingInstruction *iface )
49 return (dom_pi *)((char*)iface - FIELD_OFFSET(dom_pi, lpVtbl));
52 static HRESULT WINAPI dom_pi_QueryInterface(
53 IXMLDOMProcessingInstruction *iface,
54 REFIID riid,
55 void** ppvObject )
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 ) )
65 *ppvObject = iface;
67 else if(node_query_interface(&This->node, riid, ppvObject))
69 return *ppvObject ? S_OK : E_NOINTERFACE;
71 else
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
74 return E_NOINTERFACE;
77 IUnknown_AddRef((IUnknown*)*ppvObject);
78 return S_OK;
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 );
92 ULONG ref;
94 ref = InterlockedDecrement( &This->ref );
95 if ( ref == 0 )
97 destroy_xmlnode(&This->node);
98 heap_free( This );
101 return ref;
104 static HRESULT WINAPI dom_pi_GetTypeInfoCount(
105 IXMLDOMProcessingInstruction *iface,
106 UINT* pctinfo )
108 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
110 TRACE("(%p)->(%p)\n", This, pctinfo);
112 *pctinfo = 1;
114 return S_OK;
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 );
123 HRESULT hr;
125 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
127 hr = get_typeinfo(IXMLDOMProcessingInstruction_tid, ppTInfo);
129 return hr;
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 );
138 ITypeInfo *typeinfo;
139 HRESULT hr;
141 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
142 lcid, rgDispId);
144 if(!rgszNames || cNames == 0 || !rgDispId)
145 return E_INVALIDARG;
147 hr = get_typeinfo(IXMLDOMProcessingInstruction_tid, &typeinfo);
148 if(SUCCEEDED(hr))
150 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
151 ITypeInfo_Release(typeinfo);
154 return hr;
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 );
164 ITypeInfo *typeinfo;
165 HRESULT hr;
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);
171 if(SUCCEEDED(hr))
173 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
174 pVarResult, pExcepInfo, puArgErr);
175 ITypeInfo_Release(typeinfo);
178 return hr;
181 static HRESULT WINAPI dom_pi_get_nodeName(
182 IXMLDOMProcessingInstruction *iface,
183 BSTR* p )
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,
194 VARIANT* value)
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,
205 VARIANT value)
207 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
208 BSTR sTarget;
209 HRESULT hr;
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);
215 if(hr == S_OK)
217 static const WCHAR xmlW[] = {'x','m','l',0};
218 if(lstrcmpW( sTarget, xmlW) == 0)
220 SysFreeString(sTarget);
221 return E_FAIL;
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;
239 return S_OK;
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->lpVtbl);
317 return S_OK;
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,
363 VARIANT_BOOL* pbool)
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,
388 BSTR* p)
390 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
391 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
394 static HRESULT WINAPI dom_pi_get_text(
395 IXMLDOMProcessingInstruction *iface,
396 BSTR* p)
398 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
399 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
402 static HRESULT WINAPI dom_pi_put_text(
403 IXMLDOMProcessingInstruction *iface,
404 BSTR p)
406 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
407 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
408 return node_put_text( &This->node, p );
411 static HRESULT WINAPI dom_pi_get_specified(
412 IXMLDOMProcessingInstruction *iface,
413 VARIANT_BOOL* isSpecified)
415 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
416 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
417 *isSpecified = VARIANT_TRUE;
418 return S_OK;
421 static HRESULT WINAPI dom_pi_get_definition(
422 IXMLDOMProcessingInstruction *iface,
423 IXMLDOMNode** definitionNode)
425 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
426 FIXME("(%p)->(%p)\n", This, definitionNode);
427 return E_NOTIMPL;
430 static HRESULT WINAPI dom_pi_get_nodeTypedValue(
431 IXMLDOMProcessingInstruction *iface,
432 VARIANT* var1)
434 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
435 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
438 static HRESULT WINAPI dom_pi_put_nodeTypedValue(
439 IXMLDOMProcessingInstruction *iface,
440 VARIANT var1)
442 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
443 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
446 static HRESULT WINAPI dom_pi_get_dataType(
447 IXMLDOMProcessingInstruction *iface,
448 VARIANT* typename)
450 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
451 TRACE("(%p)->(%p)\n", This, typename);
452 return return_null_var( typename );
455 static HRESULT WINAPI dom_pi_put_dataType(
456 IXMLDOMProcessingInstruction *iface,
457 BSTR p)
459 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
460 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
463 static HRESULT WINAPI dom_pi_get_xml(
464 IXMLDOMProcessingInstruction *iface,
465 BSTR* p)
467 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
469 TRACE("(%p)->(%p)\n", This, p);
471 return node_get_xml(&This->node, FALSE, FALSE, p);
474 static HRESULT WINAPI dom_pi_transformNode(
475 IXMLDOMProcessingInstruction *iface,
476 IXMLDOMNode* domNode, BSTR* p)
478 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
479 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
482 static HRESULT WINAPI dom_pi_selectNodes(
483 IXMLDOMProcessingInstruction *iface,
484 BSTR p, IXMLDOMNodeList** outList)
486 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
487 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
490 static HRESULT WINAPI dom_pi_selectSingleNode(
491 IXMLDOMProcessingInstruction *iface,
492 BSTR p, IXMLDOMNode** outNode)
494 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
495 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
498 static HRESULT WINAPI dom_pi_get_parsed(
499 IXMLDOMProcessingInstruction *iface,
500 VARIANT_BOOL* isParsed)
502 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
503 FIXME("(%p)->(%p) stub!\n", This, isParsed);
504 *isParsed = VARIANT_TRUE;
505 return S_OK;
508 static HRESULT WINAPI dom_pi_get_namespaceURI(
509 IXMLDOMProcessingInstruction *iface,
510 BSTR* p)
512 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
513 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
516 static HRESULT WINAPI dom_pi_get_prefix(
517 IXMLDOMProcessingInstruction *iface,
518 BSTR* prefix)
520 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
521 TRACE("(%p)->(%p)\n", This, prefix);
522 return return_null_bstr( prefix );
525 static HRESULT WINAPI dom_pi_get_baseName(
526 IXMLDOMProcessingInstruction *iface,
527 BSTR* name)
529 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
530 TRACE("(%p)->(%p)\n", This, name);
531 return node_get_base_name( &This->node, name );
534 static HRESULT WINAPI dom_pi_transformNodeToObject(
535 IXMLDOMProcessingInstruction *iface,
536 IXMLDOMNode* domNode, VARIANT var1)
538 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
539 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
542 static HRESULT WINAPI dom_pi_get_target(
543 IXMLDOMProcessingInstruction *iface,
544 BSTR *p)
546 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
548 TRACE("(%p)->(%p)\n", This, p);
550 /* target returns the same value as nodeName property */
551 return node_get_nodeName(&This->node, p);
554 static HRESULT WINAPI dom_pi_get_data(
555 IXMLDOMProcessingInstruction *iface,
556 BSTR *p)
558 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
559 HRESULT hr;
560 VARIANT ret;
562 TRACE("(%p)->(%p)\n", This, p);
564 if(!p)
565 return E_INVALIDARG;
567 hr = IXMLDOMProcessingInstruction_get_nodeValue( iface, &ret );
568 if(hr == S_OK)
570 *p = V_BSTR(&ret);
573 return hr;
576 static HRESULT WINAPI dom_pi_put_data(
577 IXMLDOMProcessingInstruction *iface,
578 BSTR data)
580 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
581 HRESULT hr;
582 VARIANT val;
583 BSTR sTarget;
585 TRACE("(%p)->(%s)\n", This, debugstr_w(data) );
587 /* Cannot set data to a PI node whose target is 'xml' */
588 hr = dom_pi_get_nodeName(iface, &sTarget);
589 if(hr == S_OK)
591 static const WCHAR xmlW[] = {'x','m','l',0};
592 if(lstrcmpW( sTarget, xmlW) == 0)
594 SysFreeString(sTarget);
595 return E_FAIL;
598 SysFreeString(sTarget);
601 V_VT(&val) = VT_BSTR;
602 V_BSTR(&val) = data;
604 return IXMLDOMProcessingInstruction_put_nodeValue( iface, val );
607 static const struct IXMLDOMProcessingInstructionVtbl dom_pi_vtbl =
609 dom_pi_QueryInterface,
610 dom_pi_AddRef,
611 dom_pi_Release,
612 dom_pi_GetTypeInfoCount,
613 dom_pi_GetTypeInfo,
614 dom_pi_GetIDsOfNames,
615 dom_pi_Invoke,
616 dom_pi_get_nodeName,
617 dom_pi_get_nodeValue,
618 dom_pi_put_nodeValue,
619 dom_pi_get_nodeType,
620 dom_pi_get_parentNode,
621 dom_pi_get_childNodes,
622 dom_pi_get_firstChild,
623 dom_pi_get_lastChild,
624 dom_pi_get_previousSibling,
625 dom_pi_get_nextSibling,
626 dom_pi_get_attributes,
627 dom_pi_insertBefore,
628 dom_pi_replaceChild,
629 dom_pi_removeChild,
630 dom_pi_appendChild,
631 dom_pi_hasChildNodes,
632 dom_pi_get_ownerDocument,
633 dom_pi_cloneNode,
634 dom_pi_get_nodeTypeString,
635 dom_pi_get_text,
636 dom_pi_put_text,
637 dom_pi_get_specified,
638 dom_pi_get_definition,
639 dom_pi_get_nodeTypedValue,
640 dom_pi_put_nodeTypedValue,
641 dom_pi_get_dataType,
642 dom_pi_put_dataType,
643 dom_pi_get_xml,
644 dom_pi_transformNode,
645 dom_pi_selectNodes,
646 dom_pi_selectSingleNode,
647 dom_pi_get_parsed,
648 dom_pi_get_namespaceURI,
649 dom_pi_get_prefix,
650 dom_pi_get_baseName,
651 dom_pi_transformNodeToObject,
653 dom_pi_get_target,
654 dom_pi_get_data,
655 dom_pi_put_data
658 IUnknown* create_pi( xmlNodePtr pi )
660 dom_pi *This;
662 This = heap_alloc( sizeof *This );
663 if ( !This )
664 return NULL;
666 This->lpVtbl = &dom_pi_vtbl;
667 This->ref = 1;
669 init_xmlnode(&This->node, pi, (IXMLDOMNode*)&This->lpVtbl, NULL);
671 return (IUnknown*) &This->lpVtbl;
674 #endif