gdiplus: Stubs for GdipIsVisiblePathPoint[I].
[wine/multimedia.git] / dlls / msxml3 / pi.c
bloba38f355ce04dd0fa4b8a158e7b61a8a0ff6d0f38
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 "msxml2.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 const struct IXMLDOMProcessingInstructionVtbl *lpVtbl;
43 LONG ref;
44 IUnknown *node_unk;
45 IXMLDOMNode *node;
46 } dom_pi;
48 static inline dom_pi *impl_from_IXMLDOMProcessingInstruction( IXMLDOMProcessingInstruction *iface )
50 return (dom_pi *)((char*)iface - FIELD_OFFSET(dom_pi, lpVtbl));
53 static HRESULT WINAPI dom_pi_QueryInterface(
54 IXMLDOMProcessingInstruction *iface,
55 REFIID riid,
56 void** ppvObject )
58 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
59 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
61 if ( IsEqualGUID( riid, &IID_IXMLDOMProcessingInstruction ) ||
62 IsEqualGUID( riid, &IID_IDispatch ) ||
63 IsEqualGUID( riid, &IID_IUnknown ) )
65 *ppvObject = iface;
67 else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) )
69 return IUnknown_QueryInterface(This->node_unk, riid, ppvObject);
71 else
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
74 return E_NOINTERFACE;
77 IXMLDOMProcessingInstruction_AddRef( iface );
79 return S_OK;
82 static ULONG WINAPI dom_pi_AddRef(
83 IXMLDOMProcessingInstruction *iface )
85 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
86 return InterlockedIncrement( &This->ref );
89 static ULONG WINAPI dom_pi_Release(
90 IXMLDOMProcessingInstruction *iface )
92 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
93 ULONG ref;
95 ref = InterlockedDecrement( &This->ref );
96 if ( ref == 0 )
98 IUnknown_Release( This->node_unk );
99 HeapFree( GetProcessHeap(), 0, This );
102 return ref;
105 static HRESULT WINAPI dom_pi_GetTypeInfoCount(
106 IXMLDOMProcessingInstruction *iface,
107 UINT* pctinfo )
109 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
111 TRACE("(%p)->(%p)\n", This, pctinfo);
113 *pctinfo = 1;
115 return S_OK;
118 static HRESULT WINAPI dom_pi_GetTypeInfo(
119 IXMLDOMProcessingInstruction *iface,
120 UINT iTInfo, LCID lcid,
121 ITypeInfo** ppTInfo )
123 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
124 HRESULT hr;
126 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
128 hr = get_typeinfo(IXMLDOMProcessingInstruction_tid, ppTInfo);
130 return hr;
133 static HRESULT WINAPI dom_pi_GetIDsOfNames(
134 IXMLDOMProcessingInstruction *iface,
135 REFIID riid, LPOLESTR* rgszNames,
136 UINT cNames, LCID lcid, DISPID* rgDispId )
138 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
139 ITypeInfo *typeinfo;
140 HRESULT hr;
142 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
143 lcid, rgDispId);
145 if(!rgszNames || cNames == 0 || !rgDispId)
146 return E_INVALIDARG;
148 hr = get_typeinfo(IXMLDOMProcessingInstruction_tid, &typeinfo);
149 if(SUCCEEDED(hr))
151 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
152 ITypeInfo_Release(typeinfo);
155 return hr;
158 static HRESULT WINAPI dom_pi_Invoke(
159 IXMLDOMProcessingInstruction *iface,
160 DISPID dispIdMember, REFIID riid, LCID lcid,
161 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
162 EXCEPINFO* pExcepInfo, UINT* puArgErr )
164 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
165 ITypeInfo *typeinfo;
166 HRESULT hr;
168 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
169 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
171 hr = get_typeinfo(IXMLDOMProcessingInstruction_tid, &typeinfo);
172 if(SUCCEEDED(hr))
174 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
175 pVarResult, pExcepInfo, puArgErr);
176 ITypeInfo_Release(typeinfo);
179 return hr;
182 static HRESULT WINAPI dom_pi_get_nodeName(
183 IXMLDOMProcessingInstruction *iface,
184 BSTR* p )
186 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
187 return IXMLDOMNode_get_nodeName( This->node, p );
190 static HRESULT WINAPI dom_pi_get_nodeValue(
191 IXMLDOMProcessingInstruction *iface,
192 VARIANT* var1 )
194 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
195 return IXMLDOMNode_get_nodeValue( This->node, var1 );
198 static HRESULT WINAPI dom_pi_put_nodeValue(
199 IXMLDOMProcessingInstruction *iface,
200 VARIANT var1 )
202 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
203 BSTR sTarget;
204 static const WCHAR szXML[] = {'x','m','l',0};
205 HRESULT hr;
207 TRACE("%p\n", This );
209 /* Cannot set data to a PI node whose target is 'xml' */
210 hr = dom_pi_get_nodeName(iface, &sTarget);
211 if(hr == S_OK)
213 if(lstrcmpW( sTarget, szXML) == 0)
215 SysFreeString(sTarget);
216 return E_FAIL;
219 SysFreeString(sTarget);
222 return IXMLDOMNode_put_nodeValue( This->node, var1 );
225 static HRESULT WINAPI dom_pi_get_nodeType(
226 IXMLDOMProcessingInstruction *iface,
227 DOMNodeType* domNodeType )
229 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
230 return IXMLDOMNode_get_nodeType( This->node, domNodeType );
233 static HRESULT WINAPI dom_pi_get_parentNode(
234 IXMLDOMProcessingInstruction *iface,
235 IXMLDOMNode** parent )
237 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
238 return IXMLDOMNode_get_parentNode( This->node, parent );
241 static HRESULT WINAPI dom_pi_get_childNodes(
242 IXMLDOMProcessingInstruction *iface,
243 IXMLDOMNodeList** outList)
245 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
246 return IXMLDOMNode_get_childNodes( This->node, outList );
249 static HRESULT WINAPI dom_pi_get_firstChild(
250 IXMLDOMProcessingInstruction *iface,
251 IXMLDOMNode** domNode)
253 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
254 return IXMLDOMNode_get_firstChild( This->node, domNode );
257 static HRESULT WINAPI dom_pi_get_lastChild(
258 IXMLDOMProcessingInstruction *iface,
259 IXMLDOMNode** domNode)
261 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
262 return IXMLDOMNode_get_lastChild( This->node, domNode );
265 static HRESULT WINAPI dom_pi_get_previousSibling(
266 IXMLDOMProcessingInstruction *iface,
267 IXMLDOMNode** domNode)
269 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
270 return IXMLDOMNode_get_previousSibling( This->node, domNode );
273 static HRESULT WINAPI dom_pi_get_nextSibling(
274 IXMLDOMProcessingInstruction *iface,
275 IXMLDOMNode** domNode)
277 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
278 return IXMLDOMNode_get_nextSibling( This->node, domNode );
281 static HRESULT WINAPI dom_pi_get_attributes(
282 IXMLDOMProcessingInstruction *iface,
283 IXMLDOMNamedNodeMap** attributeMap)
285 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
286 return IXMLDOMNode_get_attributes( This->node, attributeMap );
289 static HRESULT WINAPI dom_pi_insertBefore(
290 IXMLDOMProcessingInstruction *iface,
291 IXMLDOMNode* newNode, VARIANT var1,
292 IXMLDOMNode** outOldNode)
294 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
295 return IXMLDOMNode_insertBefore( This->node, newNode, var1, outOldNode );
298 static HRESULT WINAPI dom_pi_replaceChild(
299 IXMLDOMProcessingInstruction *iface,
300 IXMLDOMNode* newNode,
301 IXMLDOMNode* oldNode,
302 IXMLDOMNode** outOldNode)
304 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
305 return IXMLDOMNode_replaceChild( This->node, newNode, oldNode, outOldNode );
308 static HRESULT WINAPI dom_pi_removeChild(
309 IXMLDOMProcessingInstruction *iface,
310 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
312 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
313 return IXMLDOMNode_removeChild( This->node, domNode, oldNode );
316 static HRESULT WINAPI dom_pi_appendChild(
317 IXMLDOMProcessingInstruction *iface,
318 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
320 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
321 return IXMLDOMNode_appendChild( This->node, newNode, outNewNode );
324 static HRESULT WINAPI dom_pi_hasChildNodes(
325 IXMLDOMProcessingInstruction *iface,
326 VARIANT_BOOL* pbool)
328 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
329 return IXMLDOMNode_hasChildNodes( This->node, pbool );
332 static HRESULT WINAPI dom_pi_get_ownerDocument(
333 IXMLDOMProcessingInstruction *iface,
334 IXMLDOMDocument** domDocument)
336 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
337 return IXMLDOMNode_get_ownerDocument( This->node, domDocument );
340 static HRESULT WINAPI dom_pi_cloneNode(
341 IXMLDOMProcessingInstruction *iface,
342 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
344 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
345 return IXMLDOMNode_cloneNode( This->node, pbool, outNode );
348 static HRESULT WINAPI dom_pi_get_nodeTypeString(
349 IXMLDOMProcessingInstruction *iface,
350 BSTR* p)
352 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
353 return IXMLDOMNode_get_nodeTypeString( This->node, p );
356 static HRESULT WINAPI dom_pi_get_text(
357 IXMLDOMProcessingInstruction *iface,
358 BSTR* p)
360 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
361 return IXMLDOMNode_get_text( This->node, p );
364 static HRESULT WINAPI dom_pi_put_text(
365 IXMLDOMProcessingInstruction *iface,
366 BSTR p)
368 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
369 return IXMLDOMNode_put_text( This->node, p );
372 static HRESULT WINAPI dom_pi_get_specified(
373 IXMLDOMProcessingInstruction *iface,
374 VARIANT_BOOL* pbool)
376 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
377 return IXMLDOMNode_get_specified( This->node, pbool );
380 static HRESULT WINAPI dom_pi_get_definition(
381 IXMLDOMProcessingInstruction *iface,
382 IXMLDOMNode** domNode)
384 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
385 return IXMLDOMNode_get_definition( This->node, domNode );
388 static HRESULT WINAPI dom_pi_get_nodeTypedValue(
389 IXMLDOMProcessingInstruction *iface,
390 VARIANT* var1)
392 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
393 return IXMLDOMNode_get_nodeTypedValue( This->node, var1 );
396 static HRESULT WINAPI dom_pi_put_nodeTypedValue(
397 IXMLDOMProcessingInstruction *iface,
398 VARIANT var1)
400 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
401 return IXMLDOMNode_put_nodeTypedValue( This->node, var1 );
404 static HRESULT WINAPI dom_pi_get_dataType(
405 IXMLDOMProcessingInstruction *iface,
406 VARIANT* var1)
408 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
409 return IXMLDOMNode_get_dataType( This->node, var1 );
412 static HRESULT WINAPI dom_pi_put_dataType(
413 IXMLDOMProcessingInstruction *iface,
414 BSTR p)
416 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
417 return IXMLDOMNode_put_dataType( This->node, p );
420 static HRESULT WINAPI dom_pi_get_xml(
421 IXMLDOMProcessingInstruction *iface,
422 BSTR* p)
424 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
425 return IXMLDOMNode_get_xml( This->node, p );
428 static HRESULT WINAPI dom_pi_transformNode(
429 IXMLDOMProcessingInstruction *iface,
430 IXMLDOMNode* domNode, BSTR* p)
432 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
433 return IXMLDOMNode_transformNode( This->node, domNode, p );
436 static HRESULT WINAPI dom_pi_selectNodes(
437 IXMLDOMProcessingInstruction *iface,
438 BSTR p, IXMLDOMNodeList** outList)
440 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
441 return IXMLDOMNode_selectNodes( This->node, p, outList );
444 static HRESULT WINAPI dom_pi_selectSingleNode(
445 IXMLDOMProcessingInstruction *iface,
446 BSTR p, IXMLDOMNode** outNode)
448 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
449 return IXMLDOMNode_selectSingleNode( This->node, p, outNode );
452 static HRESULT WINAPI dom_pi_get_parsed(
453 IXMLDOMProcessingInstruction *iface,
454 VARIANT_BOOL* pbool)
456 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
457 return IXMLDOMNode_get_parsed( This->node, pbool );
460 static HRESULT WINAPI dom_pi_get_namespaceURI(
461 IXMLDOMProcessingInstruction *iface,
462 BSTR* p)
464 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
465 return IXMLDOMNode_get_namespaceURI( This->node, p );
468 static HRESULT WINAPI dom_pi_get_prefix(
469 IXMLDOMProcessingInstruction *iface,
470 BSTR* p)
472 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
473 return IXMLDOMNode_get_prefix( This->node, p );
476 static HRESULT WINAPI dom_pi_get_baseName(
477 IXMLDOMProcessingInstruction *iface,
478 BSTR* p)
480 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
481 return IXMLDOMNode_get_baseName( This->node, p );
484 static HRESULT WINAPI dom_pi_transformNodeToObject(
485 IXMLDOMProcessingInstruction *iface,
486 IXMLDOMNode* domNode, VARIANT var1)
488 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
489 return IXMLDOMNode_transformNodeToObject( This->node, domNode, var1 );
492 static HRESULT WINAPI dom_pi_get_target(
493 IXMLDOMProcessingInstruction *iface,
494 BSTR *p)
496 /* target returns the same value as nodeName property */
497 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
498 return IXMLDOMNode_get_nodeName( This->node, p );
501 static HRESULT WINAPI dom_pi_get_data(
502 IXMLDOMProcessingInstruction *iface,
503 BSTR *p)
505 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
506 HRESULT hr = E_FAIL;
507 VARIANT vRet;
509 if(!p)
510 return E_INVALIDARG;
512 hr = IXMLDOMNode_get_nodeValue( This->node, &vRet );
513 if(hr == S_OK)
515 *p = V_BSTR(&vRet);
518 return hr;
521 static HRESULT WINAPI dom_pi_put_data(
522 IXMLDOMProcessingInstruction *iface,
523 BSTR data)
525 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
526 HRESULT hr = E_FAIL;
527 VARIANT val;
528 BSTR sTarget;
529 static const WCHAR szXML[] = {'x','m','l',0};
531 TRACE("%p %s\n", This, debugstr_w(data) );
533 /* Cannot set data to a PI node whose target is 'xml' */
534 hr = dom_pi_get_nodeName(iface, &sTarget);
535 if(hr == S_OK)
537 if(lstrcmpW( sTarget, szXML) == 0)
539 SysFreeString(sTarget);
540 return E_FAIL;
543 SysFreeString(sTarget);
546 V_VT(&val) = VT_BSTR;
547 V_BSTR(&val) = data;
549 hr = IXMLDOMNode_put_nodeValue( This->node, val );
551 return hr;
554 static const struct IXMLDOMProcessingInstructionVtbl dom_pi_vtbl =
556 dom_pi_QueryInterface,
557 dom_pi_AddRef,
558 dom_pi_Release,
559 dom_pi_GetTypeInfoCount,
560 dom_pi_GetTypeInfo,
561 dom_pi_GetIDsOfNames,
562 dom_pi_Invoke,
563 dom_pi_get_nodeName,
564 dom_pi_get_nodeValue,
565 dom_pi_put_nodeValue,
566 dom_pi_get_nodeType,
567 dom_pi_get_parentNode,
568 dom_pi_get_childNodes,
569 dom_pi_get_firstChild,
570 dom_pi_get_lastChild,
571 dom_pi_get_previousSibling,
572 dom_pi_get_nextSibling,
573 dom_pi_get_attributes,
574 dom_pi_insertBefore,
575 dom_pi_replaceChild,
576 dom_pi_removeChild,
577 dom_pi_appendChild,
578 dom_pi_hasChildNodes,
579 dom_pi_get_ownerDocument,
580 dom_pi_cloneNode,
581 dom_pi_get_nodeTypeString,
582 dom_pi_get_text,
583 dom_pi_put_text,
584 dom_pi_get_specified,
585 dom_pi_get_definition,
586 dom_pi_get_nodeTypedValue,
587 dom_pi_put_nodeTypedValue,
588 dom_pi_get_dataType,
589 dom_pi_put_dataType,
590 dom_pi_get_xml,
591 dom_pi_transformNode,
592 dom_pi_selectNodes,
593 dom_pi_selectSingleNode,
594 dom_pi_get_parsed,
595 dom_pi_get_namespaceURI,
596 dom_pi_get_prefix,
597 dom_pi_get_baseName,
598 dom_pi_transformNodeToObject,
600 dom_pi_get_target,
601 dom_pi_get_data,
602 dom_pi_put_data
605 IUnknown* create_pi( xmlNodePtr pi )
607 dom_pi *This;
608 HRESULT hr;
610 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
611 if ( !This )
612 return NULL;
614 This->lpVtbl = &dom_pi_vtbl;
615 This->ref = 1;
617 This->node_unk = create_basic_node( pi, (IUnknown*)&This->lpVtbl );
618 if(!This->node_unk)
620 HeapFree(GetProcessHeap(), 0, This);
621 return NULL;
624 hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
625 if(FAILED(hr))
627 IUnknown_Release(This->node_unk);
628 HeapFree( GetProcessHeap(), 0, This );
629 return NULL;
631 /* The ref on This->node is actually looped back into this object, so release it */
632 IXMLDOMNode_Release(This->node);
634 return (IUnknown*) &This->lpVtbl;
637 #endif