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
26 # include <libxml/parser.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
;
48 VARIANT_BOOL standalone
;
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
;
79 ERR("interface %s not implemented\n", debugstr_guid(riid
));
84 IMXWriter_AddRef(iface
);
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
);
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
);
111 static HRESULT WINAPI
mxwriter_GetTypeInfoCount(IMXWriter
*iface
, UINT
* pctinfo
)
113 mxwriter
*This
= impl_from_IMXWriter( iface
);
115 TRACE("(%p)->(%p)\n", This
, pctinfo
);
122 static HRESULT WINAPI
mxwriter_GetTypeInfo(
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(
136 REFIID riid
, LPOLESTR
* rgszNames
,
137 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
139 mxwriter
*This
= impl_from_IMXWriter( iface
);
143 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
146 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
149 hr
= get_typeinfo(IMXWriter_tid
, &typeinfo
);
152 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
153 ITypeInfo_Release(typeinfo
);
159 static HRESULT WINAPI
mxwriter_Invoke(
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
);
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
);
175 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IMXWriter_iface
, dispIdMember
, wFlags
,
176 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
177 ITypeInfo_Release(typeinfo
);
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
));
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
);
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
));
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
);
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
);
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
);
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
);
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
);
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
;
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
;
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
);
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
);
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
));
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
);
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
);
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
);
304 static HRESULT WINAPI
mxwriter_flush(IMXWriter
*iface
)
306 mxwriter
*This
= impl_from_IMXWriter( iface
);
307 FIXME("(%p)\n", This
);
311 static const struct IMXWriterVtbl mxwriter_vtbl
=
313 mxwriter_QueryInterface
,
316 mxwriter_GetTypeInfoCount
,
317 mxwriter_GetTypeInfo
,
318 mxwriter_GetIDsOfNames
,
322 mxwriter_put_encoding
,
323 mxwriter_get_encoding
,
324 mxwriter_put_byteOrderMark
,
325 mxwriter_get_byteOrderMark
,
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
,
339 /*** ISAXContentHandler ***/
340 static HRESULT WINAPI
mxwriter_saxcontent_QueryInterface(
341 ISAXContentHandler
*iface
,
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
);
370 static HRESULT WINAPI
mxwriter_saxcontent_startDocument(ISAXContentHandler
*iface
)
372 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
373 FIXME("(%p)\n", This
);
377 static HRESULT WINAPI
mxwriter_saxcontent_endDocument(ISAXContentHandler
*iface
)
379 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
380 FIXME("(%p)\n", This
);
384 static HRESULT WINAPI
mxwriter_saxcontent_startPrefixMapping(
385 ISAXContentHandler
*iface
,
391 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
392 FIXME("(%p)->(%s %s)\n", This
, debugstr_wn(prefix
, nprefix
), debugstr_wn(uri
, nuri
));
396 static HRESULT WINAPI
mxwriter_saxcontent_endPrefixMapping(
397 ISAXContentHandler
*iface
,
401 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
402 FIXME("(%p)->(%s)\n", This
, debugstr_wn(prefix
, nprefix
));
406 static HRESULT WINAPI
mxwriter_saxcontent_startElement(
407 ISAXContentHandler
*iface
,
408 const WCHAR
*namespaceUri
,
410 const WCHAR
*local_name
,
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
);
422 static HRESULT WINAPI
mxwriter_saxcontent_endElement(
423 ISAXContentHandler
*iface
,
424 const WCHAR
*namespaceUri
,
426 const WCHAR
* local_name
,
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
));
437 static HRESULT WINAPI
mxwriter_saxcontent_characters(
438 ISAXContentHandler
*iface
,
442 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
443 FIXME("(%p)->(%s)\n", This
, debugstr_wn(chars
, nchars
));
447 static HRESULT WINAPI
mxwriter_saxcontent_ignorableWhitespace(
448 ISAXContentHandler
*iface
,
452 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
453 FIXME("(%p)->(%s)\n", This
, debugstr_wn(chars
, nchars
));
457 static HRESULT WINAPI
mxwriter_saxcontent_processingInstruction(
458 ISAXContentHandler
*iface
,
464 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
465 FIXME("(%p)->(%s %s)\n", This
, debugstr_wn(target
, ntarget
), debugstr_wn(data
, ndata
));
469 static HRESULT WINAPI
mxwriter_saxcontent_skippedEntity(
470 ISAXContentHandler
*iface
,
474 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
475 FIXME("(%p)->(%s)\n", This
, debugstr_wn(name
, nname
));
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
)
501 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
503 if (pUnkOuter
) FIXME("support aggregation, outer\n");
505 This
= heap_alloc( sizeof (*This
) );
507 return E_OUTOFMEMORY
;
509 This
->IMXWriter_iface
.lpVtbl
= &mxwriter_vtbl
;
510 This
->ISAXContentHandler_iface
.lpVtbl
= &mxwriter_saxcontent_vtbl
;
513 This
->standalone
= VARIANT_FALSE
;
515 *ppObj
= &This
->IMXWriter_iface
;
517 TRACE("returning iface %p\n", *ppObj
);