msxml3: Add support for standalone property.
[wine/multimedia.git] / dlls / msxml3 / mxwriter.c
blobfed2fda749498bcf33a28a948d460818c980da61
1 /*
2 * MXWriter implementation
4 * Copyright 2011 Nikolay Sivov for CodeWeaversы
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
22 #include "config.h"
24 #include <stdarg.h>
25 #ifdef HAVE_LIBXML2
26 # include <libxml/parser.h>
27 #endif
29 #include "windef.h"
30 #include "winbase.h"
31 #include "ole2.h"
33 #include "msxml6.h"
35 #include "wine/debug.h"
37 #include "msxml_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
41 typedef struct _mxwriter
43 IMXWriter IMXWriter_iface;
44 ISAXContentHandler ISAXContentHandler_iface;
46 LONG ref;
48 VARIANT_BOOL standalone;
49 } mxwriter;
51 static inline mxwriter *impl_from_IMXWriter(IMXWriter *iface)
53 return CONTAINING_RECORD(iface, mxwriter, IMXWriter_iface);
56 static inline mxwriter *impl_from_ISAXContentHandler(ISAXContentHandler *iface)
58 return CONTAINING_RECORD(iface, mxwriter, ISAXContentHandler_iface);
61 static HRESULT WINAPI mxwriter_QueryInterface(IMXWriter *iface, REFIID riid, void **obj)
63 mxwriter *This = impl_from_IMXWriter( iface );
65 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
67 if ( IsEqualGUID( riid, &IID_IMXWriter ) ||
68 IsEqualGUID( riid, &IID_IDispatch ) ||
69 IsEqualGUID( riid, &IID_IUnknown ) )
71 *obj = &This->IMXWriter_iface;
73 else if ( IsEqualGUID( riid, &IID_ISAXContentHandler ) )
75 *obj = &This->ISAXContentHandler_iface;
77 else
79 ERR("interface %s not implemented\n", debugstr_guid(riid));
80 *obj = NULL;
81 return E_NOINTERFACE;
84 IMXWriter_AddRef(iface);
85 return S_OK;
88 static ULONG WINAPI mxwriter_AddRef(IMXWriter *iface)
90 mxwriter *This = impl_from_IMXWriter( iface );
91 LONG ref = InterlockedIncrement(&This->ref);
93 TRACE("(%p)->(%d)\n", This, ref);
95 return ref;
98 static ULONG WINAPI mxwriter_Release(IMXWriter *iface)
100 mxwriter *This = impl_from_IMXWriter( iface );
101 ULONG ref = InterlockedDecrement(&This->ref);
103 TRACE("(%p)->(%d)\n", This, ref);
105 if(!ref)
106 heap_free(This);
108 return ref;
111 static HRESULT WINAPI mxwriter_GetTypeInfoCount(IMXWriter *iface, UINT* pctinfo)
113 mxwriter *This = impl_from_IMXWriter( iface );
115 TRACE("(%p)->(%p)\n", This, pctinfo);
117 *pctinfo = 1;
119 return S_OK;
122 static HRESULT WINAPI mxwriter_GetTypeInfo(
123 IMXWriter *iface,
124 UINT iTInfo, LCID lcid,
125 ITypeInfo** ppTInfo )
127 mxwriter *This = impl_from_IMXWriter( iface );
129 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
131 return get_typeinfo(IMXWriter_tid, ppTInfo);
134 static HRESULT WINAPI mxwriter_GetIDsOfNames(
135 IMXWriter *iface,
136 REFIID riid, LPOLESTR* rgszNames,
137 UINT cNames, LCID lcid, DISPID* rgDispId )
139 mxwriter *This = impl_from_IMXWriter( iface );
140 ITypeInfo *typeinfo;
141 HRESULT hr;
143 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
144 lcid, rgDispId);
146 if(!rgszNames || cNames == 0 || !rgDispId)
147 return E_INVALIDARG;
149 hr = get_typeinfo(IMXWriter_tid, &typeinfo);
150 if(SUCCEEDED(hr))
152 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
153 ITypeInfo_Release(typeinfo);
156 return hr;
159 static HRESULT WINAPI mxwriter_Invoke(
160 IMXWriter *iface,
161 DISPID dispIdMember, REFIID riid, LCID lcid,
162 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
163 EXCEPINFO* pExcepInfo, UINT* puArgErr )
165 mxwriter *This = impl_from_IMXWriter( iface );
166 ITypeInfo *typeinfo;
167 HRESULT hr;
169 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
170 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
172 hr = get_typeinfo(IMXWriter_tid, &typeinfo);
173 if(SUCCEEDED(hr))
175 hr = ITypeInfo_Invoke(typeinfo, &This->IMXWriter_iface, dispIdMember, wFlags,
176 pDispParams, pVarResult, pExcepInfo, puArgErr);
177 ITypeInfo_Release(typeinfo);
180 return hr;
183 static HRESULT WINAPI mxwriter_put_output(IMXWriter *iface, VARIANT dest)
185 mxwriter *This = impl_from_IMXWriter( iface );
186 FIXME("(%p)->(%s)\n", This, debugstr_variant(&dest));
187 return E_NOTIMPL;
190 static HRESULT WINAPI mxwriter_get_output(IMXWriter *iface, VARIANT *dest)
192 mxwriter *This = impl_from_IMXWriter( iface );
193 FIXME("(%p)->(%p)\n", This, dest);
194 return E_NOTIMPL;
197 static HRESULT WINAPI mxwriter_put_encoding(IMXWriter *iface, BSTR encoding)
199 mxwriter *This = impl_from_IMXWriter( iface );
200 FIXME("(%p)->(%s)\n", This, debugstr_w(encoding));
201 return E_NOTIMPL;
204 static HRESULT WINAPI mxwriter_get_encoding(IMXWriter *iface, BSTR *encoding)
206 mxwriter *This = impl_from_IMXWriter( iface );
207 FIXME("(%p)->(%p)\n", This, encoding);
208 return E_NOTIMPL;
211 static HRESULT WINAPI mxwriter_put_byteOrderMark(IMXWriter *iface, VARIANT_BOOL writeBOM)
213 mxwriter *This = impl_from_IMXWriter( iface );
214 FIXME("(%p)->(%d)\n", This, writeBOM);
215 return E_NOTIMPL;
218 static HRESULT WINAPI mxwriter_get_byteOrderMark(IMXWriter *iface, VARIANT_BOOL *writeBOM)
220 mxwriter *This = impl_from_IMXWriter( iface );
221 FIXME("(%p)->(%p)\n", This, writeBOM);
222 return E_NOTIMPL;
225 static HRESULT WINAPI mxwriter_put_indent(IMXWriter *iface, VARIANT_BOOL indent)
227 mxwriter *This = impl_from_IMXWriter( iface );
228 FIXME("(%p)->(%d)\n", This, indent);
229 return E_NOTIMPL;
232 static HRESULT WINAPI mxwriter_get_indent(IMXWriter *iface, VARIANT_BOOL *indent)
234 mxwriter *This = impl_from_IMXWriter( iface );
235 FIXME("(%p)->(%p)\n", This, indent);
236 return E_NOTIMPL;
239 static HRESULT WINAPI mxwriter_put_standalone(IMXWriter *iface, VARIANT_BOOL value)
241 mxwriter *This = impl_from_IMXWriter( iface );
243 TRACE("(%p)->(%d)\n", This, value);
244 This->standalone = value;
246 return S_OK;
249 static HRESULT WINAPI mxwriter_get_standalone(IMXWriter *iface, VARIANT_BOOL *value)
251 mxwriter *This = impl_from_IMXWriter( iface );
253 TRACE("(%p)->(%p)\n", This, value);
255 if (!value) return E_POINTER;
257 *value = This->standalone;
259 return S_OK;
262 static HRESULT WINAPI mxwriter_put_omitXMLDeclaration(IMXWriter *iface, VARIANT_BOOL value)
264 mxwriter *This = impl_from_IMXWriter( iface );
265 FIXME("(%p)->(%d)\n", This, value);
266 return E_NOTIMPL;
269 static HRESULT WINAPI mxwriter_get_omitXMLDeclaration(IMXWriter *iface, VARIANT_BOOL *value)
271 mxwriter *This = impl_from_IMXWriter( iface );
272 FIXME("(%p)->(%p)\n", This, value);
273 return E_NOTIMPL;
276 static HRESULT WINAPI mxwriter_put_version(IMXWriter *iface, BSTR version)
278 mxwriter *This = impl_from_IMXWriter( iface );
279 FIXME("(%p)->(%s)\n", This, debugstr_w(version));
280 return E_NOTIMPL;
283 static HRESULT WINAPI mxwriter_get_version(IMXWriter *iface, BSTR *version)
285 mxwriter *This = impl_from_IMXWriter( iface );
286 FIXME("(%p)->(%p)\n", This, version);
287 return E_NOTIMPL;
290 static HRESULT WINAPI mxwriter_put_disableOutputEscaping(IMXWriter *iface, VARIANT_BOOL value)
292 mxwriter *This = impl_from_IMXWriter( iface );
293 FIXME("(%p)->(%d)\n", This, value);
294 return E_NOTIMPL;
297 static HRESULT WINAPI mxwriter_get_disableOutputEscaping(IMXWriter *iface, VARIANT_BOOL *value)
299 mxwriter *This = impl_from_IMXWriter( iface );
300 FIXME("(%p)->(%p)\n", This, value);
301 return E_NOTIMPL;
304 static HRESULT WINAPI mxwriter_flush(IMXWriter *iface)
306 mxwriter *This = impl_from_IMXWriter( iface );
307 FIXME("(%p)\n", This);
308 return E_NOTIMPL;
311 static const struct IMXWriterVtbl mxwriter_vtbl =
313 mxwriter_QueryInterface,
314 mxwriter_AddRef,
315 mxwriter_Release,
316 mxwriter_GetTypeInfoCount,
317 mxwriter_GetTypeInfo,
318 mxwriter_GetIDsOfNames,
319 mxwriter_Invoke,
320 mxwriter_put_output,
321 mxwriter_get_output,
322 mxwriter_put_encoding,
323 mxwriter_get_encoding,
324 mxwriter_put_byteOrderMark,
325 mxwriter_get_byteOrderMark,
326 mxwriter_put_indent,
327 mxwriter_get_indent,
328 mxwriter_put_standalone,
329 mxwriter_get_standalone,
330 mxwriter_put_omitXMLDeclaration,
331 mxwriter_get_omitXMLDeclaration,
332 mxwriter_put_version,
333 mxwriter_get_version,
334 mxwriter_put_disableOutputEscaping,
335 mxwriter_get_disableOutputEscaping,
336 mxwriter_flush
339 /*** ISAXContentHandler ***/
340 static HRESULT WINAPI mxwriter_saxcontent_QueryInterface(
341 ISAXContentHandler *iface,
342 REFIID riid,
343 void **obj)
345 mxwriter *This = impl_from_ISAXContentHandler( iface );
346 return IMXWriter_QueryInterface(&This->IMXWriter_iface, riid, obj);
349 static ULONG WINAPI mxwriter_saxcontent_AddRef(ISAXContentHandler *iface)
351 mxwriter *This = impl_from_ISAXContentHandler( iface );
352 return IMXWriter_AddRef(&This->IMXWriter_iface);
355 static ULONG WINAPI mxwriter_saxcontent_Release(ISAXContentHandler *iface)
357 mxwriter *This = impl_from_ISAXContentHandler( iface );
358 return IMXWriter_Release(&This->IMXWriter_iface);
361 static HRESULT WINAPI mxwriter_saxcontent_putDocumentLocator(
362 ISAXContentHandler *iface,
363 ISAXLocator *locator)
365 mxwriter *This = impl_from_ISAXContentHandler( iface );
366 FIXME("(%p)->(%p)\n", This, locator);
367 return E_NOTIMPL;
370 static HRESULT WINAPI mxwriter_saxcontent_startDocument(ISAXContentHandler *iface)
372 mxwriter *This = impl_from_ISAXContentHandler( iface );
373 FIXME("(%p)\n", This);
374 return E_NOTIMPL;
377 static HRESULT WINAPI mxwriter_saxcontent_endDocument(ISAXContentHandler *iface)
379 mxwriter *This = impl_from_ISAXContentHandler( iface );
380 FIXME("(%p)\n", This);
381 return E_NOTIMPL;
384 static HRESULT WINAPI mxwriter_saxcontent_startPrefixMapping(
385 ISAXContentHandler *iface,
386 const WCHAR *prefix,
387 int nprefix,
388 const WCHAR *uri,
389 int nuri)
391 mxwriter *This = impl_from_ISAXContentHandler( iface );
392 FIXME("(%p)->(%s %s)\n", This, debugstr_wn(prefix, nprefix), debugstr_wn(uri, nuri));
393 return E_NOTIMPL;
396 static HRESULT WINAPI mxwriter_saxcontent_endPrefixMapping(
397 ISAXContentHandler *iface,
398 const WCHAR *prefix,
399 int nprefix)
401 mxwriter *This = impl_from_ISAXContentHandler( iface );
402 FIXME("(%p)->(%s)\n", This, debugstr_wn(prefix, nprefix));
403 return E_NOTIMPL;
406 static HRESULT WINAPI mxwriter_saxcontent_startElement(
407 ISAXContentHandler *iface,
408 const WCHAR *namespaceUri,
409 int nnamespaceUri,
410 const WCHAR *local_name,
411 int nlocal_name,
412 const WCHAR *QName,
413 int nQName,
414 ISAXAttributes *attr)
416 mxwriter *This = impl_from_ISAXContentHandler( iface );
417 FIXME("(%p)->(%s %s %s %p)\n", This, debugstr_wn(namespaceUri, nnamespaceUri),
418 debugstr_wn(local_name, nlocal_name), debugstr_wn(QName, nQName), attr);
419 return E_NOTIMPL;
422 static HRESULT WINAPI mxwriter_saxcontent_endElement(
423 ISAXContentHandler *iface,
424 const WCHAR *namespaceUri,
425 int nnamespaceUri,
426 const WCHAR * local_name,
427 int nlocal_name,
428 const WCHAR *QName,
429 int nQName)
431 mxwriter *This = impl_from_ISAXContentHandler( iface );
432 FIXME("(%p)->(%s %s %s)\n", This, debugstr_wn(namespaceUri, nnamespaceUri),
433 debugstr_wn(local_name, nlocal_name), debugstr_wn(QName, nQName));
434 return E_NOTIMPL;
437 static HRESULT WINAPI mxwriter_saxcontent_characters(
438 ISAXContentHandler *iface,
439 const WCHAR *chars,
440 int nchars)
442 mxwriter *This = impl_from_ISAXContentHandler( iface );
443 FIXME("(%p)->(%s)\n", This, debugstr_wn(chars, nchars));
444 return E_NOTIMPL;
447 static HRESULT WINAPI mxwriter_saxcontent_ignorableWhitespace(
448 ISAXContentHandler *iface,
449 const WCHAR *chars,
450 int nchars)
452 mxwriter *This = impl_from_ISAXContentHandler( iface );
453 FIXME("(%p)->(%s)\n", This, debugstr_wn(chars, nchars));
454 return E_NOTIMPL;
457 static HRESULT WINAPI mxwriter_saxcontent_processingInstruction(
458 ISAXContentHandler *iface,
459 const WCHAR *target,
460 int ntarget,
461 const WCHAR *data,
462 int ndata)
464 mxwriter *This = impl_from_ISAXContentHandler( iface );
465 FIXME("(%p)->(%s %s)\n", This, debugstr_wn(target, ntarget), debugstr_wn(data, ndata));
466 return E_NOTIMPL;
469 static HRESULT WINAPI mxwriter_saxcontent_skippedEntity(
470 ISAXContentHandler *iface,
471 const WCHAR *name,
472 int nname)
474 mxwriter *This = impl_from_ISAXContentHandler( iface );
475 FIXME("(%p)->(%s)\n", This, debugstr_wn(name, nname));
476 return E_NOTIMPL;
479 static const struct ISAXContentHandlerVtbl mxwriter_saxcontent_vtbl =
481 mxwriter_saxcontent_QueryInterface,
482 mxwriter_saxcontent_AddRef,
483 mxwriter_saxcontent_Release,
484 mxwriter_saxcontent_putDocumentLocator,
485 mxwriter_saxcontent_startDocument,
486 mxwriter_saxcontent_endDocument,
487 mxwriter_saxcontent_startPrefixMapping,
488 mxwriter_saxcontent_endPrefixMapping,
489 mxwriter_saxcontent_startElement,
490 mxwriter_saxcontent_endElement,
491 mxwriter_saxcontent_characters,
492 mxwriter_saxcontent_ignorableWhitespace,
493 mxwriter_saxcontent_processingInstruction,
494 mxwriter_saxcontent_skippedEntity
497 HRESULT MXWriter_create(IUnknown *pUnkOuter, void **ppObj)
499 mxwriter *This;
501 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
503 if (pUnkOuter) FIXME("support aggregation, outer\n");
505 This = heap_alloc( sizeof (*This) );
506 if(!This)
507 return E_OUTOFMEMORY;
509 This->IMXWriter_iface.lpVtbl = &mxwriter_vtbl;
510 This->ISAXContentHandler_iface.lpVtbl = &mxwriter_saxcontent_vtbl;
511 This->ref = 1;
513 This->standalone = VARIANT_FALSE;
515 *ppObj = &This->IMXWriter_iface;
517 TRACE("returning iface %p\n", *ppObj);
519 return S_OK;