2 * MXWriter implementation
4 * Copyright 2011-2012 Nikolay Sivov for CodeWeavers
5 * Copyright 2011 Thomas Mullaly
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 # include <libxml/parser.h>
36 #include "wine/debug.h"
38 #include "msxml_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
42 static const WCHAR utf16W[] = {'U','T','F','-','1','6',0};
43 static const WCHAR emptyW[] = {0};
44 static const WCHAR spaceW[] = {' '};
45 static const WCHAR quotW[] = {'\"'};
56 OutputBuffer_Native = 0x001,
57 OutputBuffer_Encoded = 0x010,
58 OutputBuffer_Both = 0x100
64 MXWriter_DisableEscaping,
80 unsigned int allocated;
87 encoded_buffer encoded;
94 IMXWriter IMXWriter_iface;
95 ISAXContentHandler ISAXContentHandler_iface;
96 ISAXLexicalHandler ISAXLexicalHandler_iface;
97 ISAXDeclHandler ISAXDeclHandler_iface;
100 MSXML_VERSION class_version;
102 VARIANT_BOOL props[MXWriter_LastProp];
108 BSTR encoding; /* exact property value */
109 xml_encoding xml_enc;
111 /* contains a pending (or not closed yet) element name or NULL if
112 we don't have to close */
118 output_buffer *buffer;
124 IMXAttributes IMXAttributes_iface;
128 static inline mxattributes *impl_from_IMXAttributes( IMXAttributes *iface )
130 return CONTAINING_RECORD(iface, mxattributes, IMXAttributes_iface);
133 static xml_encoding parse_encoding_name(const WCHAR *encoding)
135 static const WCHAR utf8W[] = {'U','T','F','-','8',0};
136 if (!strcmpiW(encoding, utf8W)) return XmlEncoding_UTF8;
137 if (!strcmpiW(encoding, utf16W)) return XmlEncoding_UTF16;
138 return XmlEncoding_Unknown;
141 static HRESULT init_encoded_buffer(encoded_buffer *buffer)
143 const int initial_len = 0x2000;
144 buffer->data = heap_alloc(initial_len);
145 if (!buffer->data) return E_OUTOFMEMORY;
147 memset(buffer->data, 0, 4);
148 buffer->allocated = initial_len;
154 static void free_encoded_buffer(encoded_buffer *buffer)
156 heap_free(buffer->data);
159 static HRESULT get_code_page(xml_encoding encoding, UINT *cp)
163 case XmlEncoding_UTF8:
166 case XmlEncoding_UTF16:
170 FIXME("unsupported encoding %d\n", encoding);
177 static HRESULT alloc_output_buffer(xml_encoding encoding, output_buffer **buffer)
182 ret = heap_alloc(sizeof(*ret));
183 if (!ret) return E_OUTOFMEMORY;
185 hr = get_code_page(encoding, &ret->code_page);
191 hr = init_encoded_buffer(&ret->utf16);
197 if (ret->code_page == CP_UTF8) {
198 hr = init_encoded_buffer(&ret->encoded);
200 free_encoded_buffer(&ret->utf16);
206 memset(&ret->encoded, 0, sizeof(ret->encoded));
213 static void free_output_buffer(output_buffer *buffer)
215 free_encoded_buffer(&buffer->encoded);
216 free_encoded_buffer(&buffer->utf16);
220 static void grow_buffer(encoded_buffer *buffer, int length)
222 /* grow if needed, plus 4 bytes to be sure null terminator will fit in */
223 if (buffer->allocated < buffer->written + length + 4)
225 int grown_size = max(2*buffer->allocated, buffer->allocated + length);
226 buffer->data = heap_realloc(buffer->data, grown_size);
227 buffer->allocated = grown_size;
231 static HRESULT write_output_buffer_mode(output_buffer *buffer, output_mode mode, const WCHAR *data, int len)
236 if (mode & (OutputBuffer_Encoded | OutputBuffer_Both)) {
237 if (buffer->code_page == CP_UTF8)
239 length = WideCharToMultiByte(buffer->code_page, 0, data, len, NULL, 0, NULL, NULL);
240 grow_buffer(&buffer->encoded, length);
241 ptr = buffer->encoded.data + buffer->encoded.written;
242 length = WideCharToMultiByte(buffer->code_page, 0, data, len, ptr, length, NULL, NULL);
243 buffer->encoded.written += len == -1 ? length-1 : length;
247 if (mode & (OutputBuffer_Native | OutputBuffer_Both)) {
248 /* WCHAR data just copied */
249 length = len == -1 ? strlenW(data) : len;
252 length *= sizeof(WCHAR);
254 grow_buffer(&buffer->utf16, length);
255 ptr = buffer->utf16.data + buffer->utf16.written;
257 memcpy(ptr, data, length);
258 buffer->utf16.written += length;
260 /* null termination */
261 memset(ptr, 0, sizeof(WCHAR));
268 static HRESULT write_output_buffer(output_buffer *buffer, const WCHAR *data, int len)
270 return write_output_buffer_mode(buffer, OutputBuffer_Both, data, len);
273 static HRESULT write_output_buffer_quoted(output_buffer *buffer, const WCHAR *data, int len)
275 write_output_buffer(buffer, quotW, 1);
276 write_output_buffer(buffer, data, len);
277 write_output_buffer(buffer, quotW, 1);
282 /* frees buffer data, reallocates with a default lengths */
283 static void close_output_buffer(mxwriter *This)
285 heap_free(This->buffer->utf16.data);
286 heap_free(This->buffer->encoded.data);
287 init_encoded_buffer(&This->buffer->utf16);
288 init_encoded_buffer(&This->buffer->encoded);
289 get_code_page(This->xml_enc, &This->buffer->code_page);
292 /* escapes special characters like:
298 static WCHAR *get_escaped_string(const WCHAR *str, escape_mode mode, int *len)
300 static const WCHAR ltW[] = {'&','l','t',';'};
301 static const WCHAR ampW[] = {'&','a','m','p',';'};
302 static const WCHAR equotW[] = {'&','q','u','o','t',';'};
303 static const WCHAR gtW[] = {'&','g','t',';'};
305 const int default_alloc = 100;
306 const int grow_thresh = 10;
307 int p = *len, conv_len;
310 /* default buffer size to something if length is unknown */
311 conv_len = *len == -1 ? default_alloc : max(2**len, default_alloc);
312 ptr = ret = heap_alloc(conv_len*sizeof(WCHAR));
316 if (ptr - ret > conv_len - grow_thresh)
318 int written = ptr - ret;
320 ptr = ret = heap_realloc(ret, conv_len*sizeof(WCHAR));
327 memcpy(ptr, ltW, sizeof(ltW));
328 ptr += sizeof(ltW)/sizeof(WCHAR);
331 memcpy(ptr, ampW, sizeof(ampW));
332 ptr += sizeof(ampW)/sizeof(WCHAR);
335 memcpy(ptr, gtW, sizeof(gtW));
336 ptr += sizeof(gtW)/sizeof(WCHAR);
339 if (mode == EscapeValue)
341 memcpy(ptr, equotW, sizeof(equotW));
342 ptr += sizeof(equotW)/sizeof(WCHAR);
345 /* fallthrough for text mode */
355 if (*len != -1) *len = ptr-ret;
361 static void write_prolog_buffer(const mxwriter *This)
363 static const WCHAR versionW[] = {'<','?','x','m','l',' ','v','e','r','s','i','o','n','='};
364 static const WCHAR encodingW[] = {' ','e','n','c','o','d','i','n','g','=','\"'};
365 static const WCHAR standaloneW[] = {' ','s','t','a','n','d','a','l','o','n','e','=','\"'};
366 static const WCHAR yesW[] = {'y','e','s','\"','?','>'};
367 static const WCHAR noW[] = {'n','o','\"','?','>'};
368 static const WCHAR crlfW[] = {'\r','\n'};
371 write_output_buffer(This->buffer, versionW, sizeof(versionW)/sizeof(WCHAR));
372 write_output_buffer_quoted(This->buffer, This->version, -1);
375 write_output_buffer(This->buffer, encodingW, sizeof(encodingW)/sizeof(WCHAR));
377 /* always write UTF-16 to WCHAR buffer */
378 write_output_buffer_mode(This->buffer, OutputBuffer_Native, utf16W, sizeof(utf16W)/sizeof(WCHAR) - 1);
379 write_output_buffer_mode(This->buffer, OutputBuffer_Encoded, This->encoding, -1);
380 write_output_buffer(This->buffer, quotW, 1);
383 write_output_buffer(This->buffer, standaloneW, sizeof(standaloneW)/sizeof(WCHAR));
384 if (This->props[MXWriter_Standalone] == VARIANT_TRUE)
385 write_output_buffer(This->buffer, yesW, sizeof(yesW)/sizeof(WCHAR));
387 write_output_buffer(This->buffer, noW, sizeof(noW)/sizeof(WCHAR));
389 write_output_buffer(This->buffer, crlfW, sizeof(crlfW)/sizeof(WCHAR));
392 /* Attempts to the write data from the mxwriter's buffer to
393 * the destination stream (if there is one).
395 static HRESULT write_data_to_stream(mxwriter *This)
397 encoded_buffer *buffer;
404 if (This->xml_enc != XmlEncoding_UTF16)
405 buffer = &This->buffer->encoded;
407 buffer = &This->buffer->utf16;
409 if (This->dest_written > buffer->written) {
410 ERR("Failed sanity check! Not sure what to do... (%d > %d)\n", This->dest_written, buffer->written);
412 } else if (This->dest_written == buffer->written && This->xml_enc != XmlEncoding_UTF8)
413 /* Windows seems to make an empty write call when the encoding is UTF-8 and
414 * all the data has been written to the stream. It doesn't seem make this call
415 * for any other encodings.
419 /* Write the current content from the output buffer into 'dest'.
420 * TODO: Check what Windows does if the IStream doesn't write all of
421 * the data we give it at once.
423 hr = IStream_Write(This->dest, buffer->data+This->dest_written,
424 buffer->written-This->dest_written, &written);
426 WARN("Failed to write data to IStream (0x%08x)\n", hr);
430 This->dest_written += written;
434 /* Newly added element start tag left unclosed cause for empty elements
435 we have to close it differently. */
436 static void close_element_starttag(const mxwriter *This)
438 static const WCHAR gtW[] = {'>'};
439 if (!This->element) return;
440 write_output_buffer(This->buffer, gtW, 1);
443 static void set_element_name(mxwriter *This, const WCHAR *name, int len)
445 SysFreeString(This->element);
446 This->element = name ? SysAllocStringLen(name, len) : NULL;
449 static inline HRESULT flush_output_buffer(mxwriter *This)
451 close_element_starttag(This);
452 set_element_name(This, NULL, 0);
454 return write_data_to_stream(This);
457 /* Resets the mxwriter's output buffer by closing it, then creating a new
458 * output buffer using the given encoding.
460 static inline void reset_output_buffer(mxwriter *This)
462 close_output_buffer(This);
463 This->dest_written = 0;
466 static HRESULT writer_set_property(mxwriter *writer, mxwriter_prop property, VARIANT_BOOL value)
468 writer->props[property] = value;
469 writer->prop_changed = TRUE;
473 static HRESULT writer_get_property(const mxwriter *writer, mxwriter_prop property, VARIANT_BOOL *value)
475 if (!value) return E_POINTER;
476 *value = writer->props[property];
480 static inline mxwriter *impl_from_IMXWriter(IMXWriter *iface)
482 return CONTAINING_RECORD(iface, mxwriter, IMXWriter_iface);
485 static inline mxwriter *impl_from_ISAXContentHandler(ISAXContentHandler *iface)
487 return CONTAINING_RECORD(iface, mxwriter, ISAXContentHandler_iface);
490 static inline mxwriter *impl_from_ISAXLexicalHandler(ISAXLexicalHandler *iface)
492 return CONTAINING_RECORD(iface, mxwriter, ISAXLexicalHandler_iface);
495 static inline mxwriter *impl_from_ISAXDeclHandler(ISAXDeclHandler *iface)
497 return CONTAINING_RECORD(iface, mxwriter, ISAXDeclHandler_iface);
500 static HRESULT WINAPI mxwriter_QueryInterface(IMXWriter *iface, REFIID riid, void **obj)
502 mxwriter *This = impl_from_IMXWriter( iface );
504 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
508 if ( IsEqualGUID( riid, &IID_IMXWriter ) ||
509 IsEqualGUID( riid, &IID_IDispatch ) ||
510 IsEqualGUID( riid, &IID_IUnknown ) )
512 *obj = &This->IMXWriter_iface;
514 else if ( IsEqualGUID( riid, &IID_ISAXContentHandler ) )
516 *obj = &This->ISAXContentHandler_iface;
518 else if ( IsEqualGUID( riid, &IID_ISAXLexicalHandler ) )
520 *obj = &This->ISAXLexicalHandler_iface;
522 else if ( IsEqualGUID( riid, &IID_ISAXDeclHandler ) )
524 *obj = &This->ISAXDeclHandler_iface;
526 else if (dispex_query_interface(&This->dispex, riid, obj))
528 return *obj ? S_OK : E_NOINTERFACE;
532 ERR("interface %s not implemented\n", debugstr_guid(riid));
534 return E_NOINTERFACE;
537 IMXWriter_AddRef(iface);
541 static ULONG WINAPI mxwriter_AddRef(IMXWriter *iface)
543 mxwriter *This = impl_from_IMXWriter( iface );
544 LONG ref = InterlockedIncrement(&This->ref);
546 TRACE("(%p)->(%d)\n", This, ref);
551 static ULONG WINAPI mxwriter_Release(IMXWriter *iface)
553 mxwriter *This = impl_from_IMXWriter( iface );
554 ULONG ref = InterlockedDecrement(&This->ref);
556 TRACE("(%p)->(%d)\n", This, ref);
560 /* Windows flushes the buffer when the interface is destroyed. */
561 flush_output_buffer(This);
562 free_output_buffer(This->buffer);
564 if (This->dest) IStream_Release(This->dest);
565 SysFreeString(This->version);
566 SysFreeString(This->encoding);
568 SysFreeString(This->element);
569 release_dispex(&This->dispex);
576 static HRESULT WINAPI mxwriter_GetTypeInfoCount(IMXWriter *iface, UINT* pctinfo)
578 mxwriter *This = impl_from_IMXWriter( iface );
579 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
582 static HRESULT WINAPI mxwriter_GetTypeInfo(
584 UINT iTInfo, LCID lcid,
585 ITypeInfo** ppTInfo )
587 mxwriter *This = impl_from_IMXWriter( iface );
588 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface,
589 iTInfo, lcid, ppTInfo);
592 static HRESULT WINAPI mxwriter_GetIDsOfNames(
594 REFIID riid, LPOLESTR* rgszNames,
595 UINT cNames, LCID lcid, DISPID* rgDispId )
597 mxwriter *This = impl_from_IMXWriter( iface );
598 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
599 riid, rgszNames, cNames, lcid, rgDispId);
602 static HRESULT WINAPI mxwriter_Invoke(
604 DISPID dispIdMember, REFIID riid, LCID lcid,
605 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
606 EXCEPINFO* pExcepInfo, UINT* puArgErr )
608 mxwriter *This = impl_from_IMXWriter( iface );
609 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
610 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
613 static HRESULT WINAPI mxwriter_put_output(IMXWriter *iface, VARIANT dest)
615 mxwriter *This = impl_from_IMXWriter( iface );
618 TRACE("(%p)->(%s)\n", This, debugstr_variant(&dest));
620 hr = flush_output_buffer(This);
628 if (This->dest) IStream_Release(This->dest);
630 reset_output_buffer(This);
637 hr = IUnknown_QueryInterface(V_UNKNOWN(&dest), &IID_IStream, (void**)&stream);
640 /* Recreate the output buffer to make sure it's using the correct encoding. */
641 reset_output_buffer(This);
643 if (This->dest) IStream_Release(This->dest);
648 FIXME("unhandled interface type for VT_UNKNOWN destination\n");
652 FIXME("unhandled destination type %s\n", debugstr_variant(&dest));
659 static HRESULT WINAPI mxwriter_get_output(IMXWriter *iface, VARIANT *dest)
661 mxwriter *This = impl_from_IMXWriter( iface );
663 TRACE("(%p)->(%p)\n", This, dest);
667 HRESULT hr = flush_output_buffer(This);
671 V_VT(dest) = VT_BSTR;
672 V_BSTR(dest) = SysAllocString((WCHAR*)This->buffer->utf16.data);
677 FIXME("not implemented when stream is set up\n");
682 static HRESULT WINAPI mxwriter_put_encoding(IMXWriter *iface, BSTR encoding)
684 mxwriter *This = impl_from_IMXWriter( iface );
688 TRACE("(%p)->(%s)\n", This, debugstr_w(encoding));
690 enc = parse_encoding_name(encoding);
691 if (enc == XmlEncoding_Unknown)
693 FIXME("unsupported encoding %s\n", debugstr_w(encoding));
697 hr = flush_output_buffer(This);
701 SysReAllocString(&This->encoding, encoding);
704 TRACE("got encoding %d\n", This->xml_enc);
705 reset_output_buffer(This);
709 static HRESULT WINAPI mxwriter_get_encoding(IMXWriter *iface, BSTR *encoding)
711 mxwriter *This = impl_from_IMXWriter( iface );
713 TRACE("(%p)->(%p)\n", This, encoding);
715 if (!encoding) return E_POINTER;
717 *encoding = SysAllocString(This->encoding);
718 if (!*encoding) return E_OUTOFMEMORY;
723 static HRESULT WINAPI mxwriter_put_byteOrderMark(IMXWriter *iface, VARIANT_BOOL value)
725 mxwriter *This = impl_from_IMXWriter( iface );
727 TRACE("(%p)->(%d)\n", This, value);
728 return writer_set_property(This, MXWriter_BOM, value);
731 static HRESULT WINAPI mxwriter_get_byteOrderMark(IMXWriter *iface, VARIANT_BOOL *value)
733 mxwriter *This = impl_from_IMXWriter( iface );
735 TRACE("(%p)->(%p)\n", This, value);
736 return writer_get_property(This, MXWriter_BOM, value);
739 static HRESULT WINAPI mxwriter_put_indent(IMXWriter *iface, VARIANT_BOOL value)
741 mxwriter *This = impl_from_IMXWriter( iface );
743 TRACE("(%p)->(%d)\n", This, value);
744 return writer_set_property(This, MXWriter_Indent, value);
747 static HRESULT WINAPI mxwriter_get_indent(IMXWriter *iface, VARIANT_BOOL *value)
749 mxwriter *This = impl_from_IMXWriter( iface );
751 TRACE("(%p)->(%p)\n", This, value);
752 return writer_get_property(This, MXWriter_Indent, value);
755 static HRESULT WINAPI mxwriter_put_standalone(IMXWriter *iface, VARIANT_BOOL value)
757 mxwriter *This = impl_from_IMXWriter( iface );
759 TRACE("(%p)->(%d)\n", This, value);
760 return writer_set_property(This, MXWriter_Standalone, value);
763 static HRESULT WINAPI mxwriter_get_standalone(IMXWriter *iface, VARIANT_BOOL *value)
765 mxwriter *This = impl_from_IMXWriter( iface );
767 TRACE("(%p)->(%p)\n", This, value);
768 return writer_get_property(This, MXWriter_Standalone, value);
771 static HRESULT WINAPI mxwriter_put_omitXMLDeclaration(IMXWriter *iface, VARIANT_BOOL value)
773 mxwriter *This = impl_from_IMXWriter( iface );
775 TRACE("(%p)->(%d)\n", This, value);
776 return writer_set_property(This, MXWriter_OmitXmlDecl, value);
779 static HRESULT WINAPI mxwriter_get_omitXMLDeclaration(IMXWriter *iface, VARIANT_BOOL *value)
781 mxwriter *This = impl_from_IMXWriter( iface );
783 TRACE("(%p)->(%p)\n", This, value);
784 return writer_get_property(This, MXWriter_OmitXmlDecl, value);
787 static HRESULT WINAPI mxwriter_put_version(IMXWriter *iface, BSTR version)
789 mxwriter *This = impl_from_IMXWriter( iface );
791 TRACE("(%p)->(%s)\n", This, debugstr_w(version));
793 if (!version) return E_INVALIDARG;
795 SysFreeString(This->version);
796 This->version = SysAllocString(version);
801 static HRESULT WINAPI mxwriter_get_version(IMXWriter *iface, BSTR *version)
803 mxwriter *This = impl_from_IMXWriter( iface );
805 TRACE("(%p)->(%p)\n", This, version);
807 if (!version) return E_POINTER;
809 return return_bstr(This->version, version);
812 static HRESULT WINAPI mxwriter_put_disableOutputEscaping(IMXWriter *iface, VARIANT_BOOL value)
814 mxwriter *This = impl_from_IMXWriter( iface );
816 TRACE("(%p)->(%d)\n", This, value);
817 return writer_set_property(This, MXWriter_DisableEscaping, value);
820 static HRESULT WINAPI mxwriter_get_disableOutputEscaping(IMXWriter *iface, VARIANT_BOOL *value)
822 mxwriter *This = impl_from_IMXWriter( iface );
824 TRACE("(%p)->(%p)\n", This, value);
825 return writer_get_property(This, MXWriter_DisableEscaping, value);
828 static HRESULT WINAPI mxwriter_flush(IMXWriter *iface)
830 mxwriter *This = impl_from_IMXWriter( iface );
831 TRACE("(%p)\n", This);
832 return flush_output_buffer(This);
835 static const struct IMXWriterVtbl MXWriterVtbl =
837 mxwriter_QueryInterface,
840 mxwriter_GetTypeInfoCount,
841 mxwriter_GetTypeInfo,
842 mxwriter_GetIDsOfNames,
846 mxwriter_put_encoding,
847 mxwriter_get_encoding,
848 mxwriter_put_byteOrderMark,
849 mxwriter_get_byteOrderMark,
852 mxwriter_put_standalone,
853 mxwriter_get_standalone,
854 mxwriter_put_omitXMLDeclaration,
855 mxwriter_get_omitXMLDeclaration,
856 mxwriter_put_version,
857 mxwriter_get_version,
858 mxwriter_put_disableOutputEscaping,
859 mxwriter_get_disableOutputEscaping,
863 /*** ISAXContentHandler ***/
864 static HRESULT WINAPI SAXContentHandler_QueryInterface(
865 ISAXContentHandler *iface,
869 mxwriter *This = impl_from_ISAXContentHandler( iface );
870 return IMXWriter_QueryInterface(&This->IMXWriter_iface, riid, obj);
873 static ULONG WINAPI SAXContentHandler_AddRef(ISAXContentHandler *iface)
875 mxwriter *This = impl_from_ISAXContentHandler( iface );
876 return IMXWriter_AddRef(&This->IMXWriter_iface);
879 static ULONG WINAPI SAXContentHandler_Release(ISAXContentHandler *iface)
881 mxwriter *This = impl_from_ISAXContentHandler( iface );
882 return IMXWriter_Release(&This->IMXWriter_iface);
885 static HRESULT WINAPI SAXContentHandler_putDocumentLocator(
886 ISAXContentHandler *iface,
887 ISAXLocator *locator)
889 mxwriter *This = impl_from_ISAXContentHandler( iface );
890 FIXME("(%p)->(%p)\n", This, locator);
894 static HRESULT WINAPI SAXContentHandler_startDocument(ISAXContentHandler *iface)
896 mxwriter *This = impl_from_ISAXContentHandler( iface );
898 TRACE("(%p)\n", This);
900 /* If properties have been changed since the last "endDocument" call
901 * we need to reset the output buffer. If we don't the output buffer
902 * could end up with multiple XML documents in it, plus this seems to
903 * be how Windows works.
905 if (This->prop_changed) {
906 reset_output_buffer(This);
907 This->prop_changed = FALSE;
910 if (This->props[MXWriter_OmitXmlDecl] == VARIANT_TRUE) return S_OK;
912 write_prolog_buffer(This);
914 if (This->dest && This->xml_enc == XmlEncoding_UTF16) {
915 static const char utf16BOM[] = {0xff,0xfe};
917 if (This->props[MXWriter_BOM] == VARIANT_TRUE)
918 /* Windows passes a NULL pointer as the pcbWritten parameter and
919 * ignores any error codes returned from this Write call.
921 IStream_Write(This->dest, utf16BOM, sizeof(utf16BOM), NULL);
927 static HRESULT WINAPI SAXContentHandler_endDocument(ISAXContentHandler *iface)
929 mxwriter *This = impl_from_ISAXContentHandler( iface );
930 TRACE("(%p)\n", This);
931 This->prop_changed = FALSE;
932 return flush_output_buffer(This);
935 static HRESULT WINAPI SAXContentHandler_startPrefixMapping(
936 ISAXContentHandler *iface,
942 mxwriter *This = impl_from_ISAXContentHandler( iface );
943 FIXME("(%p)->(%s %s)\n", This, debugstr_wn(prefix, nprefix), debugstr_wn(uri, nuri));
947 static HRESULT WINAPI SAXContentHandler_endPrefixMapping(
948 ISAXContentHandler *iface,
952 mxwriter *This = impl_from_ISAXContentHandler( iface );
953 FIXME("(%p)->(%s)\n", This, debugstr_wn(prefix, nprefix));
957 static HRESULT WINAPI SAXContentHandler_startElement(
958 ISAXContentHandler *iface,
959 const WCHAR *namespaceUri,
961 const WCHAR *local_name,
965 ISAXAttributes *attr)
967 mxwriter *This = impl_from_ISAXContentHandler( iface );
968 static const WCHAR ltW[] = {'<'};
970 TRACE("(%p)->(%s %s %s %p)\n", This, debugstr_wn(namespaceUri, nnamespaceUri),
971 debugstr_wn(local_name, nlocal_name), debugstr_wn(QName, nQName), attr);
973 if ((!namespaceUri || !local_name || !QName) && This->class_version != MSXML6)
976 close_element_starttag(This);
977 set_element_name(This, QName ? QName : emptyW,
980 write_output_buffer(This->buffer, ltW, 1);
981 write_output_buffer(This->buffer, QName, nQName);
989 hr = ISAXAttributes_getLength(attr, &length);
990 if (FAILED(hr)) return hr;
992 for (i = 0; i < length; i++)
994 static const WCHAR eqW[] = {'='};
999 hr = ISAXAttributes_getQName(attr, i, &str, &len);
1000 if (FAILED(hr)) return hr;
1002 /* space separator in front of every attribute */
1003 write_output_buffer(This->buffer, spaceW, 1);
1004 write_output_buffer(This->buffer, str, len);
1006 write_output_buffer(This->buffer, eqW, 1);
1009 hr = ISAXAttributes_getValue(attr, i, &str, &len);
1010 if (FAILED(hr)) return hr;
1012 escaped = get_escaped_string(str, EscapeValue, &len);
1013 write_output_buffer_quoted(This->buffer, escaped, len);
1021 static HRESULT WINAPI SAXContentHandler_endElement(
1022 ISAXContentHandler *iface,
1023 const WCHAR *namespaceUri,
1025 const WCHAR * local_name,
1030 mxwriter *This = impl_from_ISAXContentHandler( iface );
1032 TRACE("(%p)->(%s:%d %s:%d %s:%d)\n", This, debugstr_wn(namespaceUri, nnamespaceUri), nnamespaceUri,
1033 debugstr_wn(local_name, nlocal_name), nlocal_name, debugstr_wn(QName, nQName), nQName);
1035 if ((!namespaceUri || !local_name || !QName) && This->class_version != MSXML6)
1036 return E_INVALIDARG;
1038 if (This->element && QName && !strncmpW(This->element, QName, nQName))
1040 static const WCHAR closeW[] = {'/','>'};
1042 write_output_buffer(This->buffer, closeW, 2);
1046 static const WCHAR closetagW[] = {'<','/'};
1047 static const WCHAR gtW[] = {'>'};
1049 write_output_buffer(This->buffer, closetagW, 2);
1050 write_output_buffer(This->buffer, QName, nQName);
1051 write_output_buffer(This->buffer, gtW, 1);
1054 set_element_name(This, NULL, 0);
1059 static HRESULT WINAPI SAXContentHandler_characters(
1060 ISAXContentHandler *iface,
1064 mxwriter *This = impl_from_ISAXContentHandler( iface );
1066 TRACE("(%p)->(%s:%d)\n", This, debugstr_wn(chars, nchars), nchars);
1068 if (!chars) return E_INVALIDARG;
1070 close_element_starttag(This);
1071 set_element_name(This, NULL, 0);
1076 write_output_buffer(This->buffer, chars, nchars);
1082 escaped = get_escaped_string(chars, EscapeText, &len);
1083 write_output_buffer(This->buffer, escaped, len);
1091 static HRESULT WINAPI SAXContentHandler_ignorableWhitespace(
1092 ISAXContentHandler *iface,
1096 mxwriter *This = impl_from_ISAXContentHandler( iface );
1097 FIXME("(%p)->(%s)\n", This, debugstr_wn(chars, nchars));
1101 static HRESULT WINAPI SAXContentHandler_processingInstruction(
1102 ISAXContentHandler *iface,
1103 const WCHAR *target,
1108 mxwriter *This = impl_from_ISAXContentHandler( iface );
1109 FIXME("(%p)->(%s %s)\n", This, debugstr_wn(target, ntarget), debugstr_wn(data, ndata));
1113 static HRESULT WINAPI SAXContentHandler_skippedEntity(
1114 ISAXContentHandler *iface,
1118 mxwriter *This = impl_from_ISAXContentHandler( iface );
1119 FIXME("(%p)->(%s)\n", This, debugstr_wn(name, nname));
1123 static const struct ISAXContentHandlerVtbl SAXContentHandlerVtbl =
1125 SAXContentHandler_QueryInterface,
1126 SAXContentHandler_AddRef,
1127 SAXContentHandler_Release,
1128 SAXContentHandler_putDocumentLocator,
1129 SAXContentHandler_startDocument,
1130 SAXContentHandler_endDocument,
1131 SAXContentHandler_startPrefixMapping,
1132 SAXContentHandler_endPrefixMapping,
1133 SAXContentHandler_startElement,
1134 SAXContentHandler_endElement,
1135 SAXContentHandler_characters,
1136 SAXContentHandler_ignorableWhitespace,
1137 SAXContentHandler_processingInstruction,
1138 SAXContentHandler_skippedEntity
1141 /*** ISAXLexicalHandler ***/
1142 static HRESULT WINAPI SAXLexicalHandler_QueryInterface(ISAXLexicalHandler *iface,
1143 REFIID riid, void **obj)
1145 mxwriter *This = impl_from_ISAXLexicalHandler( iface );
1146 return IMXWriter_QueryInterface(&This->IMXWriter_iface, riid, obj);
1149 static ULONG WINAPI SAXLexicalHandler_AddRef(ISAXLexicalHandler *iface)
1151 mxwriter *This = impl_from_ISAXLexicalHandler( iface );
1152 return IMXWriter_AddRef(&This->IMXWriter_iface);
1155 static ULONG WINAPI SAXLexicalHandler_Release(ISAXLexicalHandler *iface)
1157 mxwriter *This = impl_from_ISAXLexicalHandler( iface );
1158 return IMXWriter_Release(&This->IMXWriter_iface);
1161 static HRESULT WINAPI SAXLexicalHandler_startDTD(ISAXLexicalHandler *iface,
1162 const WCHAR *name, int name_len, const WCHAR *publicId, int publicId_len,
1163 const WCHAR *systemId, int systemId_len)
1165 static const WCHAR doctypeW[] = {'<','!','D','O','C','T','Y','P','E',' '};
1166 static const WCHAR openintW[] = {'[','\r','\n'};
1168 mxwriter *This = impl_from_ISAXLexicalHandler( iface );
1170 TRACE("(%p)->(%s %s %s)\n", This, debugstr_wn(name, name_len), debugstr_wn(publicId, publicId_len),
1171 debugstr_wn(systemId, systemId_len));
1173 if (!name) return E_INVALIDARG;
1175 write_output_buffer(This->buffer, doctypeW, sizeof(doctypeW)/sizeof(WCHAR));
1179 write_output_buffer(This->buffer, name, name_len);
1180 write_output_buffer(This->buffer, spaceW, 1);
1185 static const WCHAR publicW[] = {'P','U','B','L','I','C',' '};
1187 write_output_buffer(This->buffer, publicW, sizeof(publicW)/sizeof(WCHAR));
1188 write_output_buffer_quoted(This->buffer, publicId, publicId_len);
1190 if (!systemId) return E_INVALIDARG;
1193 write_output_buffer(This->buffer, spaceW, 1);
1195 write_output_buffer_quoted(This->buffer, systemId, systemId_len);
1198 write_output_buffer(This->buffer, spaceW, 1);
1202 static const WCHAR systemW[] = {'S','Y','S','T','E','M',' '};
1204 write_output_buffer(This->buffer, systemW, sizeof(systemW)/sizeof(WCHAR));
1205 write_output_buffer_quoted(This->buffer, systemId, systemId_len);
1207 write_output_buffer(This->buffer, spaceW, 1);
1210 write_output_buffer(This->buffer, openintW, sizeof(openintW)/sizeof(WCHAR));
1215 static HRESULT WINAPI SAXLexicalHandler_endDTD(ISAXLexicalHandler *iface)
1217 mxwriter *This = impl_from_ISAXLexicalHandler( iface );
1218 static const WCHAR closedtdW[] = {']','>','\r','\n'};
1220 TRACE("(%p)\n", This);
1222 write_output_buffer(This->buffer, closedtdW, sizeof(closedtdW)/sizeof(WCHAR));
1227 static HRESULT WINAPI SAXLexicalHandler_startEntity(ISAXLexicalHandler *iface, const WCHAR *name, int len)
1229 mxwriter *This = impl_from_ISAXLexicalHandler( iface );
1230 FIXME("(%p)->(%s): stub\n", This, debugstr_wn(name, len));
1234 static HRESULT WINAPI SAXLexicalHandler_endEntity(ISAXLexicalHandler *iface, const WCHAR *name, int len)
1236 mxwriter *This = impl_from_ISAXLexicalHandler( iface );
1237 FIXME("(%p)->(%s): stub\n", This, debugstr_wn(name, len));
1241 static HRESULT WINAPI SAXLexicalHandler_startCDATA(ISAXLexicalHandler *iface)
1243 static const WCHAR scdataW[] = {'<','!','[','C','D','A','T','A','['};
1244 mxwriter *This = impl_from_ISAXLexicalHandler( iface );
1246 TRACE("(%p)\n", This);
1248 write_output_buffer(This->buffer, scdataW, sizeof(scdataW)/sizeof(WCHAR));
1254 static HRESULT WINAPI SAXLexicalHandler_endCDATA(ISAXLexicalHandler *iface)
1256 mxwriter *This = impl_from_ISAXLexicalHandler( iface );
1257 static const WCHAR ecdataW[] = {']',']','>'};
1259 TRACE("(%p)\n", This);
1261 write_output_buffer(This->buffer, ecdataW, sizeof(ecdataW)/sizeof(WCHAR));
1262 This->cdata = FALSE;
1267 static HRESULT WINAPI SAXLexicalHandler_comment(ISAXLexicalHandler *iface, const WCHAR *chars, int nchars)
1269 mxwriter *This = impl_from_ISAXLexicalHandler( iface );
1270 static const WCHAR copenW[] = {'<','!','-','-'};
1271 static const WCHAR ccloseW[] = {'-','-','>','\r','\n'};
1273 TRACE("(%p)->(%s:%d)\n", This, debugstr_wn(chars, nchars), nchars);
1275 if (!chars) return E_INVALIDARG;
1277 close_element_starttag(This);
1279 write_output_buffer(This->buffer, copenW, sizeof(copenW)/sizeof(WCHAR));
1281 write_output_buffer(This->buffer, chars, nchars);
1282 write_output_buffer(This->buffer, ccloseW, sizeof(ccloseW)/sizeof(WCHAR));
1287 static const struct ISAXLexicalHandlerVtbl SAXLexicalHandlerVtbl =
1289 SAXLexicalHandler_QueryInterface,
1290 SAXLexicalHandler_AddRef,
1291 SAXLexicalHandler_Release,
1292 SAXLexicalHandler_startDTD,
1293 SAXLexicalHandler_endDTD,
1294 SAXLexicalHandler_startEntity,
1295 SAXLexicalHandler_endEntity,
1296 SAXLexicalHandler_startCDATA,
1297 SAXLexicalHandler_endCDATA,
1298 SAXLexicalHandler_comment
1301 /*** ISAXDeclHandler ***/
1302 static HRESULT WINAPI SAXDeclHandler_QueryInterface(ISAXDeclHandler *iface,
1303 REFIID riid, void **obj)
1305 mxwriter *This = impl_from_ISAXDeclHandler( iface );
1306 return IMXWriter_QueryInterface(&This->IMXWriter_iface, riid, obj);
1309 static ULONG WINAPI SAXDeclHandler_AddRef(ISAXDeclHandler *iface)
1311 mxwriter *This = impl_from_ISAXDeclHandler( iface );
1312 return IMXWriter_AddRef(&This->IMXWriter_iface);
1315 static ULONG WINAPI SAXDeclHandler_Release(ISAXDeclHandler *iface)
1317 mxwriter *This = impl_from_ISAXDeclHandler( iface );
1318 return IMXWriter_Release(&This->IMXWriter_iface);
1321 static HRESULT WINAPI SAXDeclHandler_elementDecl(ISAXDeclHandler *iface,
1322 const WCHAR *name, int n_name, const WCHAR *model, int n_model)
1324 static const WCHAR elementW[] = {'<','!','E','L','E','M','E','N','T',' '};
1325 static const WCHAR closeelementW[] = {'>','\r','\n'};
1326 mxwriter *This = impl_from_ISAXDeclHandler( iface );
1328 TRACE("(%p)->(%s:%d %s:%d)\n", This, debugstr_wn(name, n_name), n_name,
1329 debugstr_wn(model, n_model), n_model);
1331 if (!name || !model) return E_INVALIDARG;
1333 write_output_buffer(This->buffer, elementW, sizeof(elementW)/sizeof(WCHAR));
1335 write_output_buffer(This->buffer, name, n_name);
1336 write_output_buffer(This->buffer, spaceW, sizeof(spaceW)/sizeof(WCHAR));
1339 write_output_buffer(This->buffer, model, n_model);
1340 write_output_buffer(This->buffer, closeelementW, sizeof(closeelementW)/sizeof(WCHAR));
1345 static HRESULT WINAPI SAXDeclHandler_attributeDecl(ISAXDeclHandler *iface,
1346 const WCHAR *element, int n_element, const WCHAR *attr, int n_attr,
1347 const WCHAR *type, int n_type, const WCHAR *Default, int n_default,
1348 const WCHAR *value, int n_value)
1350 mxwriter *This = impl_from_ISAXDeclHandler( iface );
1351 FIXME("(%p)->(%s:%d %s:%d %s:%d %s:%d %s:%d): stub\n", This, debugstr_wn(element, n_element), n_element,
1352 debugstr_wn(attr, n_attr), n_attr, debugstr_wn(type, n_type), n_type, debugstr_wn(Default, n_default), n_default,
1353 debugstr_wn(value, n_value), n_value);
1357 static HRESULT WINAPI SAXDeclHandler_internalEntityDecl(ISAXDeclHandler *iface,
1358 const WCHAR *name, int n_name, const WCHAR *value, int n_value)
1360 mxwriter *This = impl_from_ISAXDeclHandler( iface );
1361 FIXME("(%p)->(%s:%d %s:%d): stub\n", This, debugstr_wn(name, n_name), n_name,
1362 debugstr_wn(value, n_value), n_value);
1366 static HRESULT WINAPI SAXDeclHandler_externalEntityDecl(ISAXDeclHandler *iface,
1367 const WCHAR *name, int n_name, const WCHAR *publicId, int n_publicId,
1368 const WCHAR *systemId, int n_systemId)
1370 mxwriter *This = impl_from_ISAXDeclHandler( iface );
1371 FIXME("(%p)->(%s:%d %s:%d %s:%d): stub\n", This, debugstr_wn(name, n_name), n_name,
1372 debugstr_wn(publicId, n_publicId), n_publicId, debugstr_wn(systemId, n_systemId), n_systemId);
1376 static const ISAXDeclHandlerVtbl SAXDeclHandlerVtbl = {
1377 SAXDeclHandler_QueryInterface,
1378 SAXDeclHandler_AddRef,
1379 SAXDeclHandler_Release,
1380 SAXDeclHandler_elementDecl,
1381 SAXDeclHandler_attributeDecl,
1382 SAXDeclHandler_internalEntityDecl,
1383 SAXDeclHandler_externalEntityDecl
1386 static const tid_t mxwriter_iface_tids[] = {
1391 static dispex_static_data_t mxwriter_dispex = {
1398 HRESULT MXWriter_create(MSXML_VERSION version, IUnknown *outer, void **ppObj)
1400 static const WCHAR version10W[] = {'1','.','0',0};
1404 TRACE("(%p, %p)\n", outer, ppObj);
1406 if (outer) FIXME("support aggregation, outer\n");
1408 This = heap_alloc( sizeof (*This) );
1410 return E_OUTOFMEMORY;
1412 This->IMXWriter_iface.lpVtbl = &MXWriterVtbl;
1413 This->ISAXContentHandler_iface.lpVtbl = &SAXContentHandlerVtbl;
1414 This->ISAXLexicalHandler_iface.lpVtbl = &SAXLexicalHandlerVtbl;
1415 This->ISAXDeclHandler_iface.lpVtbl = &SAXDeclHandlerVtbl;
1417 This->class_version = version;
1419 This->props[MXWriter_BOM] = VARIANT_TRUE;
1420 This->props[MXWriter_DisableEscaping] = VARIANT_FALSE;
1421 This->props[MXWriter_Indent] = VARIANT_FALSE;
1422 This->props[MXWriter_OmitXmlDecl] = VARIANT_FALSE;
1423 This->props[MXWriter_Standalone] = VARIANT_FALSE;
1424 This->prop_changed = FALSE;
1425 This->encoding = SysAllocString(utf16W);
1426 This->version = SysAllocString(version10W);
1427 This->xml_enc = XmlEncoding_UTF16;
1429 This->element = NULL;
1430 This->cdata = FALSE;
1433 This->dest_written = 0;
1435 hr = alloc_output_buffer(This->xml_enc, &This->buffer);
1437 SysFreeString(This->encoding);
1438 SysFreeString(This->version);
1443 init_dispex(&This->dispex, (IUnknown*)&This->IMXWriter_iface, &mxwriter_dispex);
1445 *ppObj = &This->IMXWriter_iface;
1447 TRACE("returning iface %p\n", *ppObj);
1452 static HRESULT WINAPI MXAttributes_QueryInterface(IMXAttributes *iface, REFIID riid, void **ppObj)
1454 mxattributes *This = impl_from_IMXAttributes( iface );
1456 TRACE("(%p)->(%s %p)\n", This, debugstr_guid( riid ), ppObj);
1460 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
1461 IsEqualGUID( riid, &IID_IDispatch ) ||
1462 IsEqualGUID( riid, &IID_IMXAttributes ))
1466 else if (dispex_query_interface(&This->dispex, riid, ppObj))
1468 return *ppObj ? S_OK : E_NOINTERFACE;
1472 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1473 return E_NOINTERFACE;
1476 IMXAttributes_AddRef( iface );
1481 static ULONG WINAPI MXAttributes_AddRef(IMXAttributes *iface)
1483 mxattributes *This = impl_from_IMXAttributes( iface );
1484 ULONG ref = InterlockedIncrement( &This->ref );
1485 TRACE("(%p)->(%d)\n", This, ref );
1489 static ULONG WINAPI MXAttributes_Release(IMXAttributes *iface)
1491 mxattributes *This = impl_from_IMXAttributes( iface );
1492 LONG ref = InterlockedDecrement( &This->ref );
1494 TRACE("(%p)->(%d)\n", This, ref);
1498 release_dispex(&This->dispex);
1505 static HRESULT WINAPI MXAttributes_GetTypeInfoCount(IMXAttributes *iface, UINT* pctinfo)
1507 mxattributes *This = impl_from_IMXAttributes( iface );
1508 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1511 static HRESULT WINAPI MXAttributes_GetTypeInfo(IMXAttributes *iface, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo)
1513 mxattributes *This = impl_from_IMXAttributes( iface );
1514 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1517 static HRESULT WINAPI MXAttributes_GetIDsOfNames(
1518 IMXAttributes *iface,
1520 LPOLESTR* rgszNames,
1525 mxattributes *This = impl_from_IMXAttributes( iface );
1526 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
1527 riid, rgszNames, cNames, lcid, rgDispId);
1530 static HRESULT WINAPI MXAttributes_Invoke(
1531 IMXAttributes *iface,
1532 DISPID dispIdMember,
1536 DISPPARAMS* pDispParams,
1537 VARIANT* pVarResult,
1538 EXCEPINFO* pExcepInfo,
1541 mxattributes *This = impl_from_IMXAttributes( iface );
1542 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
1543 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1546 static HRESULT WINAPI MXAttributes_addAttribute(IMXAttributes *iface,
1547 BSTR uri, BSTR localName, BSTR QName, BSTR type, BSTR value)
1549 mxattributes *This = impl_from_IMXAttributes( iface );
1550 FIXME("(%p)->(%s %s %s %s %s): stub\n", This, debugstr_w(uri), debugstr_w(localName),
1551 debugstr_w(QName), debugstr_w(type), debugstr_w(value));
1555 static HRESULT WINAPI MXAttributes_addAttributeFromIndex(IMXAttributes *iface,
1556 VARIANT atts, int index)
1558 mxattributes *This = impl_from_IMXAttributes( iface );
1559 FIXME("(%p)->(%s %d): stub\n", This, debugstr_variant(&atts), index);
1563 static HRESULT WINAPI MXAttributes_clear(IMXAttributes *iface)
1565 mxattributes *This = impl_from_IMXAttributes( iface );
1566 FIXME("(%p): stub\n", This);
1570 static HRESULT WINAPI MXAttributes_removeAttribute(IMXAttributes *iface, int index)
1572 mxattributes *This = impl_from_IMXAttributes( iface );
1573 FIXME("(%p)->(%d): stub\n", This, index);
1577 static HRESULT WINAPI MXAttributes_setAttribute(IMXAttributes *iface, int index,
1578 BSTR uri, BSTR localName, BSTR QName, BSTR type, BSTR value)
1580 mxattributes *This = impl_from_IMXAttributes( iface );
1581 FIXME("(%p)->(%d %s %s %s %s %s): stub\n", This, index, debugstr_w(uri),
1582 debugstr_w(localName), debugstr_w(QName), debugstr_w(type), debugstr_w(value));
1586 static HRESULT WINAPI MXAttributes_setAttributes(IMXAttributes *iface, VARIANT atts)
1588 mxattributes *This = impl_from_IMXAttributes( iface );
1589 FIXME("(%p)->(%s): stub\n", This, debugstr_variant(&atts));
1593 static HRESULT WINAPI MXAttributes_setLocalName(IMXAttributes *iface, int index,
1596 mxattributes *This = impl_from_IMXAttributes( iface );
1597 FIXME("(%p)->(%d %s): stub\n", This, index, debugstr_w(localName));
1601 static HRESULT WINAPI MXAttributes_setQName(IMXAttributes *iface, int index, BSTR QName)
1603 mxattributes *This = impl_from_IMXAttributes( iface );
1604 FIXME("(%p)->(%d %s): stub\n", This, index, debugstr_w(QName));
1608 static HRESULT WINAPI MXAttributes_setURI(IMXAttributes *iface, int index, BSTR uri)
1610 mxattributes *This = impl_from_IMXAttributes( iface );
1611 FIXME("(%p)->(%d %s): stub\n", This, index, debugstr_w(uri));
1615 static HRESULT WINAPI MXAttributes_setValue(IMXAttributes *iface, int index, BSTR value)
1617 mxattributes *This = impl_from_IMXAttributes( iface );
1618 FIXME("(%p)->(%d %s): stub\n", This, index, debugstr_w(value));
1622 static const IMXAttributesVtbl MXAttributesVtbl = {
1623 MXAttributes_QueryInterface,
1624 MXAttributes_AddRef,
1625 MXAttributes_Release,
1626 MXAttributes_GetTypeInfoCount,
1627 MXAttributes_GetTypeInfo,
1628 MXAttributes_GetIDsOfNames,
1629 MXAttributes_Invoke,
1630 MXAttributes_addAttribute,
1631 MXAttributes_addAttributeFromIndex,
1633 MXAttributes_removeAttribute,
1634 MXAttributes_setAttribute,
1635 MXAttributes_setAttributes,
1636 MXAttributes_setLocalName,
1637 MXAttributes_setQName,
1638 MXAttributes_setURI,
1639 MXAttributes_setValue
1642 static const tid_t mxattrs_iface_tids[] = {
1647 static dispex_static_data_t mxattrs_dispex = {
1654 HRESULT SAXAttributes_create(MSXML_VERSION version, IUnknown *outer, void **ppObj)
1658 TRACE("(%p, %p)\n", outer, ppObj);
1660 This = heap_alloc( sizeof (*This) );
1662 return E_OUTOFMEMORY;
1664 This->IMXAttributes_iface.lpVtbl = &MXAttributesVtbl;
1667 *ppObj = &This->IMXAttributes_iface;
1669 init_dispex(&This->dispex, (IUnknown*)&This->IMXAttributes_iface, &mxattrs_dispex);
1671 TRACE("returning iface %p\n", *ppObj);