2 * MXWriter implementation
4 * Copyright 2011-2014, 2016 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
24 static const WCHAR emptyW
[] = {0};
25 static const WCHAR spaceW
[] = {' '};
26 static const WCHAR quotW
[] = {'\"'};
27 static const WCHAR closetagW
[] = {'>','\r','\n'};
28 static const WCHAR crlfW
[] = {'\r','\n'};
29 static const WCHAR entityW
[] = {'<','!','E','N','T','I','T','Y',' '};
30 static const WCHAR publicW
[] = {'P','U','B','L','I','C',' '};
31 static const WCHAR systemW
[] = {'S','Y','S','T','E','M',' '};
33 /* should be ordered as encoding names are sorted */
36 XmlEncoding_ISO_8859_1
= 0,
37 XmlEncoding_ISO_8859_13
,
38 XmlEncoding_ISO_8859_15
,
39 XmlEncoding_ISO_8859_2
,
40 XmlEncoding_ISO_8859_3
,
41 XmlEncoding_ISO_8859_4
,
42 XmlEncoding_ISO_8859_5
,
43 XmlEncoding_ISO_8859_7
,
44 XmlEncoding_ISO_8859_9
,
50 struct xml_encoding_data
52 const WCHAR
*encoding
;
57 static const WCHAR iso_8859_1W
[] = {'i','s','o','-','8','8','5','9','-','1',0};
58 static const WCHAR iso_8859_2W
[] = {'i','s','o','-','8','8','5','9','-','2',0};
59 static const WCHAR iso_8859_3W
[] = {'i','s','o','-','8','8','5','9','-','3',0};
60 static const WCHAR iso_8859_4W
[] = {'i','s','o','-','8','8','5','9','-','4',0};
61 static const WCHAR iso_8859_5W
[] = {'i','s','o','-','8','8','5','9','-','5',0};
62 static const WCHAR iso_8859_7W
[] = {'i','s','o','-','8','8','5','9','-','7',0};
63 static const WCHAR iso_8859_9W
[] = {'i','s','o','-','8','8','5','9','-','9',0};
64 static const WCHAR iso_8859_13W
[] = {'i','s','o','-','8','8','5','9','-','1','3',0};
65 static const WCHAR iso_8859_15W
[] = {'i','s','o','-','8','8','5','9','-','1','5',0};
66 static const WCHAR utf16W
[] = {'U','T','F','-','1','6',0};
67 static const WCHAR utf8W
[] = {'U','T','F','-','8',0};
69 static const struct xml_encoding_data xml_encoding_map
[] = {
70 { iso_8859_1W
, XmlEncoding_ISO_8859_1
, 28591 },
71 { iso_8859_13W
, XmlEncoding_ISO_8859_13
, 28603 },
72 { iso_8859_15W
, XmlEncoding_ISO_8859_15
, 28605 },
73 { iso_8859_2W
, XmlEncoding_ISO_8859_2
, 28592 },
74 { iso_8859_3W
, XmlEncoding_ISO_8859_3
, 28593 },
75 { iso_8859_4W
, XmlEncoding_ISO_8859_4
, 28594 },
76 { iso_8859_5W
, XmlEncoding_ISO_8859_5
, 28595 },
77 { iso_8859_7W
, XmlEncoding_ISO_8859_7
, 28597 },
78 { iso_8859_9W
, XmlEncoding_ISO_8859_9
, 28599 },
79 { utf16W
, XmlEncoding_UTF16
, ~0 },
80 { utf8W
, XmlEncoding_UTF8
, CP_UTF8
}
86 MXWriter_DisableEscaping
,
103 unsigned int allocated
;
104 unsigned int written
;
109 encoded_buffer encoded
;
111 UINT utf16_total
; /* total number of bytes written since last buffer reinitialization */
112 struct list blocks
; /* only used when output was not set, for BSTR case */
118 IMXWriter IMXWriter_iface
;
119 ISAXContentHandler ISAXContentHandler_iface
;
120 ISAXLexicalHandler ISAXLexicalHandler_iface
;
121 ISAXDeclHandler ISAXDeclHandler_iface
;
122 ISAXDTDHandler ISAXDTDHandler_iface
;
123 ISAXErrorHandler ISAXErrorHandler_iface
;
124 IVBSAXDeclHandler IVBSAXDeclHandler_iface
;
125 IVBSAXLexicalHandler IVBSAXLexicalHandler_iface
;
126 IVBSAXContentHandler IVBSAXContentHandler_iface
;
127 IVBSAXDTDHandler IVBSAXDTDHandler_iface
;
128 IVBSAXErrorHandler IVBSAXErrorHandler_iface
;
131 MSXML_VERSION class_version
;
133 VARIANT_BOOL props
[MXWriter_LastProp
];
137 BOOL text
; /* last node was text node, so we shouldn't indent next node */
138 BOOL newline
; /* newline was already added as a part of previous call */
139 UINT indent
; /* indentation level for next node */
143 BSTR encoding
; /* exact property value */
144 xml_encoding xml_enc
;
146 /* contains a pending (or not closed yet) element name or NULL if
147 we don't have to close */
152 output_buffer buffer
;
167 IMXAttributes IMXAttributes_iface
;
168 ISAXAttributes ISAXAttributes_iface
;
169 IVBSAXAttributes IVBSAXAttributes_iface
;
172 MSXML_VERSION class_version
;
179 static inline mxattributes
*impl_from_IMXAttributes( IMXAttributes
*iface
)
181 return CONTAINING_RECORD(iface
, mxattributes
, IMXAttributes_iface
);
184 static inline mxattributes
*impl_from_ISAXAttributes( ISAXAttributes
*iface
)
186 return CONTAINING_RECORD(iface
, mxattributes
, ISAXAttributes_iface
);
189 static inline mxattributes
*impl_from_IVBSAXAttributes( IVBSAXAttributes
*iface
)
191 return CONTAINING_RECORD(iface
, mxattributes
, IVBSAXAttributes_iface
);
194 static HRESULT
mxattributes_grow(mxattributes
*This
)
196 if (This
->length
< This
->allocated
) return S_OK
;
198 This
->allocated
*= 2;
199 This
->attr
= heap_realloc(This
->attr
, This
->allocated
*sizeof(mxattribute
));
201 return This
->attr
? S_OK
: E_OUTOFMEMORY
;
204 static xml_encoding
parse_encoding_name(const WCHAR
*encoding
)
209 max
= sizeof(xml_encoding_map
)/sizeof(struct xml_encoding_data
) - 1;
215 c
= strcmpiW(xml_encoding_map
[n
].encoding
, encoding
);
217 return xml_encoding_map
[n
].enc
;
225 return XmlEncoding_Unknown
;
228 static HRESULT
init_encoded_buffer(encoded_buffer
*buffer
)
230 const int initial_len
= 0x1000;
231 buffer
->data
= heap_alloc(initial_len
);
232 if (!buffer
->data
) return E_OUTOFMEMORY
;
234 memset(buffer
->data
, 0, 4);
235 buffer
->allocated
= initial_len
;
241 static void free_encoded_buffer(encoded_buffer
*buffer
)
243 heap_free(buffer
->data
);
246 static HRESULT
get_code_page(xml_encoding encoding
, UINT
*cp
)
248 const struct xml_encoding_data
*data
;
250 if (encoding
== XmlEncoding_Unknown
)
252 FIXME("unsupported encoding %d\n", encoding
);
256 data
= &xml_encoding_map
[encoding
];
262 static HRESULT
init_output_buffer(xml_encoding encoding
, output_buffer
*buffer
)
266 hr
= get_code_page(encoding
, &buffer
->code_page
);
270 hr
= init_encoded_buffer(&buffer
->encoded
);
274 list_init(&buffer
->blocks
);
275 buffer
->utf16_total
= 0;
280 static void free_output_buffer(output_buffer
*buffer
)
282 encoded_buffer
*cur
, *cur2
;
284 free_encoded_buffer(&buffer
->encoded
);
286 LIST_FOR_EACH_ENTRY_SAFE(cur
, cur2
, &buffer
->blocks
, encoded_buffer
, entry
)
288 list_remove(&cur
->entry
);
289 free_encoded_buffer(cur
);
294 static HRESULT
write_output_buffer(mxwriter
*writer
, const WCHAR
*data
, int len
)
296 output_buffer
*buffer
= &writer
->buffer
;
297 encoded_buffer
*buff
;
298 unsigned int written
;
304 src_len
= len
== -1 ? strlenW(data
) : len
;
307 buff
= &buffer
->encoded
;
309 if (buffer
->code_page
== ~0)
311 unsigned int avail
= buff
->allocated
- buff
->written
;
313 src_len
*= sizeof(WCHAR
);
314 written
= min(avail
, src_len
);
316 /* fill internal buffer first */
319 memcpy(buff
->data
+ buff
->written
, data
, written
);
320 data
+= written
/ sizeof(WCHAR
);
321 buff
->written
+= written
;
328 IStream_Write(writer
->dest
, buff
->data
, buff
->written
, &written
);
330 if (src_len
>= buff
->allocated
)
331 IStream_Write(writer
->dest
, data
, src_len
, &written
);
334 memcpy(buff
->data
, data
, src_len
);
335 buff
->written
+= src_len
;
341 unsigned int avail
= buff
->allocated
- buff
->written
;
344 length
= WideCharToMultiByte(buffer
->code_page
, 0, data
, src_len
, NULL
, 0, NULL
, NULL
);
347 length
= WideCharToMultiByte(buffer
->code_page
, 0, data
, src_len
, buff
->data
+ buff
->written
, length
, NULL
, NULL
);
348 buff
->written
+= length
;
352 /* drain what we go so far */
355 IStream_Write(writer
->dest
, buff
->data
, buff
->written
, &written
);
357 avail
= buff
->allocated
;
362 length
= WideCharToMultiByte(buffer
->code_page
, 0, data
, src_len
, buff
->data
+ buff
->written
, length
, NULL
, NULL
);
363 buff
->written
+= length
;
369 /* if current chunk is larger than total buffer size, convert it at once using temporary allocated buffer */
370 mb
= heap_alloc(length
);
372 return E_OUTOFMEMORY
;
374 length
= WideCharToMultiByte(buffer
->code_page
, 0, data
, src_len
, mb
, length
, NULL
, NULL
);
375 IStream_Write(writer
->dest
, mb
, length
, &written
);
381 /* When writer has no output set we have to accumulate everything to return it later in a form of BSTR.
384 - fill a buffer already allocated as part of output buffer;
385 - when current buffer is full, allocate another one and switch to it; buffers themselves never grow,
386 but are linked together, with head pointing to first allocated buffer after initial one got filled;
387 - later during get_output() contents are concatenated by copying one after another to destination BSTR buffer,
388 that's returned to the client. */
391 /* select last used block */
392 if (list_empty(&buffer
->blocks
))
393 buff
= &buffer
->encoded
;
395 buff
= LIST_ENTRY(list_tail(&buffer
->blocks
), encoded_buffer
, entry
);
397 src_len
*= sizeof(WCHAR
);
400 unsigned int avail
= buff
->allocated
- buff
->written
;
401 unsigned int written
= min(avail
, src_len
);
405 memcpy(buff
->data
+ buff
->written
, data
, written
);
406 buff
->written
+= written
;
407 buffer
->utf16_total
+= written
;
411 /* alloc new block if needed and retry */
414 encoded_buffer
*next
= heap_alloc(sizeof(*next
));
417 if (FAILED(hr
= init_encoded_buffer(next
))) {
422 list_add_tail(&buffer
->blocks
, &next
->entry
);
431 static HRESULT
write_output_buffer_quoted(mxwriter
*writer
, const WCHAR
*data
, int len
)
433 write_output_buffer(writer
, quotW
, 1);
434 write_output_buffer(writer
, data
, len
);
435 write_output_buffer(writer
, quotW
, 1);
440 /* frees buffer data, reallocates with a default lengths */
441 static void close_output_buffer(mxwriter
*writer
)
443 encoded_buffer
*cur
, *cur2
;
445 heap_free(writer
->buffer
.encoded
.data
);
447 LIST_FOR_EACH_ENTRY_SAFE(cur
, cur2
, &writer
->buffer
.blocks
, encoded_buffer
, entry
)
449 list_remove(&cur
->entry
);
450 free_encoded_buffer(cur
);
454 init_encoded_buffer(&writer
->buffer
.encoded
);
455 get_code_page(writer
->xml_enc
, &writer
->buffer
.code_page
);
456 writer
->buffer
.utf16_total
= 0;
457 list_init(&writer
->buffer
.blocks
);
460 /* Escapes special characters like:
466 On call 'len' contains a length of 'str' in chars or -1 if it's null terminated.
467 After a call it's updated with actual new length if it wasn't -1 initially.
469 static WCHAR
*get_escaped_string(const WCHAR
*str
, escape_mode mode
, int *len
)
471 static const WCHAR ltW
[] = {'&','l','t',';'};
472 static const WCHAR ampW
[] = {'&','a','m','p',';'};
473 static const WCHAR equotW
[] = {'&','q','u','o','t',';'};
474 static const WCHAR gtW
[] = {'&','g','t',';'};
476 const int default_alloc
= 100;
477 const int grow_thresh
= 10;
478 int p
= *len
, conv_len
;
481 /* default buffer size to something if length is unknown */
482 conv_len
= *len
== -1 ? default_alloc
: max(2**len
, default_alloc
);
483 ptr
= ret
= heap_alloc(conv_len
*sizeof(WCHAR
));
487 if (ptr
- ret
> conv_len
- grow_thresh
)
489 int written
= ptr
- ret
;
491 ptr
= ret
= heap_realloc(ret
, conv_len
*sizeof(WCHAR
));
498 memcpy(ptr
, ltW
, sizeof(ltW
));
499 ptr
+= sizeof(ltW
)/sizeof(WCHAR
);
502 memcpy(ptr
, ampW
, sizeof(ampW
));
503 ptr
+= sizeof(ampW
)/sizeof(WCHAR
);
506 memcpy(ptr
, gtW
, sizeof(gtW
));
507 ptr
+= sizeof(gtW
)/sizeof(WCHAR
);
510 if (mode
== EscapeValue
)
512 memcpy(ptr
, equotW
, sizeof(equotW
));
513 ptr
+= sizeof(equotW
)/sizeof(WCHAR
);
516 /* fallthrough for text mode */
526 if (*len
!= -1) *len
= ptr
-ret
;
532 static void write_prolog_buffer(mxwriter
*writer
)
534 static const WCHAR versionW
[] = {'<','?','x','m','l',' ','v','e','r','s','i','o','n','='};
535 static const WCHAR encodingW
[] = {' ','e','n','c','o','d','i','n','g','=','\"'};
536 static const WCHAR standaloneW
[] = {' ','s','t','a','n','d','a','l','o','n','e','=','\"'};
537 static const WCHAR yesW
[] = {'y','e','s','\"','?','>'};
538 static const WCHAR noW
[] = {'n','o','\"','?','>'};
541 write_output_buffer(writer
, versionW
, sizeof(versionW
)/sizeof(WCHAR
));
542 write_output_buffer_quoted(writer
, writer
->version
, -1);
545 write_output_buffer(writer
, encodingW
, sizeof(encodingW
)/sizeof(WCHAR
));
548 write_output_buffer(writer
, writer
->encoding
, -1);
550 write_output_buffer(writer
, utf16W
, sizeof(utf16W
)/sizeof(WCHAR
) - 1);
551 write_output_buffer(writer
, quotW
, 1);
554 write_output_buffer(writer
, standaloneW
, sizeof(standaloneW
)/sizeof(WCHAR
));
555 if (writer
->props
[MXWriter_Standalone
] == VARIANT_TRUE
)
556 write_output_buffer(writer
, yesW
, sizeof(yesW
)/sizeof(WCHAR
));
558 write_output_buffer(writer
, noW
, sizeof(noW
)/sizeof(WCHAR
));
560 write_output_buffer(writer
, crlfW
, sizeof(crlfW
)/sizeof(WCHAR
));
561 writer
->newline
= TRUE
;
564 /* Attempts to the write data from the mxwriter's buffer to
565 * the destination stream (if there is one).
567 static HRESULT
write_data_to_stream(mxwriter
*writer
)
569 encoded_buffer
*buffer
= &writer
->buffer
.encoded
;
575 if (buffer
->written
== 0)
577 if (writer
->xml_enc
== XmlEncoding_UTF8
)
578 IStream_Write(writer
->dest
, buffer
->data
, 0, &written
);
582 IStream_Write(writer
->dest
, buffer
->data
, buffer
->written
, &written
);
589 /* Newly added element start tag left unclosed cause for empty elements
590 we have to close it differently. */
591 static void close_element_starttag(mxwriter
*writer
)
593 static const WCHAR gtW
[] = {'>'};
594 if (!writer
->element
) return;
595 write_output_buffer(writer
, gtW
, 1);
598 static void write_node_indent(mxwriter
*writer
)
600 static const WCHAR tabW
[] = {'\t'};
601 int indent
= writer
->indent
;
603 if (!writer
->props
[MXWriter_Indent
] || writer
->text
)
605 writer
->text
= FALSE
;
609 /* This is to workaround PI output logic that always puts newline chars,
610 document prolog PI does that too. */
611 if (!writer
->newline
)
612 write_output_buffer(writer
, crlfW
, sizeof(crlfW
)/sizeof(WCHAR
));
614 write_output_buffer(writer
, tabW
, 1);
616 writer
->newline
= FALSE
;
617 writer
->text
= FALSE
;
620 static inline void writer_inc_indent(mxwriter
*This
)
625 static inline void writer_dec_indent(mxwriter
*This
)
627 if (This
->indent
) This
->indent
--;
628 /* depth is decreased only when element is closed, meaning it's not a text node
633 static void set_element_name(mxwriter
*This
, const WCHAR
*name
, int len
)
635 SysFreeString(This
->element
);
637 This
->element
= len
!= -1 ? SysAllocStringLen(name
, len
) : SysAllocString(name
);
639 This
->element
= NULL
;
642 static inline HRESULT
flush_output_buffer(mxwriter
*This
)
644 close_element_starttag(This
);
645 set_element_name(This
, NULL
, 0);
647 return write_data_to_stream(This
);
650 /* Resets the mxwriter's output buffer by closing it, then creating a new
651 * output buffer using the given encoding.
653 static inline void reset_output_buffer(mxwriter
*This
)
655 close_output_buffer(This
);
658 static HRESULT
writer_set_property(mxwriter
*writer
, mxwriter_prop property
, VARIANT_BOOL value
)
660 writer
->props
[property
] = value
;
661 writer
->prop_changed
= TRUE
;
665 static HRESULT
writer_get_property(const mxwriter
*writer
, mxwriter_prop property
, VARIANT_BOOL
*value
)
667 if (!value
) return E_POINTER
;
668 *value
= writer
->props
[property
];
672 static inline mxwriter
*impl_from_IMXWriter(IMXWriter
*iface
)
674 return CONTAINING_RECORD(iface
, mxwriter
, IMXWriter_iface
);
677 static inline mxwriter
*impl_from_ISAXContentHandler(ISAXContentHandler
*iface
)
679 return CONTAINING_RECORD(iface
, mxwriter
, ISAXContentHandler_iface
);
682 static inline mxwriter
*impl_from_IVBSAXContentHandler(IVBSAXContentHandler
*iface
)
684 return CONTAINING_RECORD(iface
, mxwriter
, IVBSAXContentHandler_iface
);
687 static inline mxwriter
*impl_from_ISAXLexicalHandler(ISAXLexicalHandler
*iface
)
689 return CONTAINING_RECORD(iface
, mxwriter
, ISAXLexicalHandler_iface
);
692 static inline mxwriter
*impl_from_IVBSAXLexicalHandler(IVBSAXLexicalHandler
*iface
)
694 return CONTAINING_RECORD(iface
, mxwriter
, IVBSAXLexicalHandler_iface
);
697 static inline mxwriter
*impl_from_ISAXDeclHandler(ISAXDeclHandler
*iface
)
699 return CONTAINING_RECORD(iface
, mxwriter
, ISAXDeclHandler_iface
);
702 static inline mxwriter
*impl_from_IVBSAXDeclHandler(IVBSAXDeclHandler
*iface
)
704 return CONTAINING_RECORD(iface
, mxwriter
, IVBSAXDeclHandler_iface
);
707 static inline mxwriter
*impl_from_ISAXDTDHandler(ISAXDTDHandler
*iface
)
709 return CONTAINING_RECORD(iface
, mxwriter
, ISAXDTDHandler_iface
);
712 static inline mxwriter
*impl_from_IVBSAXDTDHandler(IVBSAXDTDHandler
*iface
)
714 return CONTAINING_RECORD(iface
, mxwriter
, IVBSAXDTDHandler_iface
);
717 static inline mxwriter
*impl_from_ISAXErrorHandler(ISAXErrorHandler
*iface
)
719 return CONTAINING_RECORD(iface
, mxwriter
, ISAXErrorHandler_iface
);
722 static inline mxwriter
*impl_from_IVBSAXErrorHandler(IVBSAXErrorHandler
*iface
)
724 return CONTAINING_RECORD(iface
, mxwriter
, IVBSAXErrorHandler_iface
);
727 static HRESULT WINAPI
mxwriter_QueryInterface(IMXWriter
*iface
, REFIID riid
, void **obj
)
729 mxwriter
*This
= impl_from_IMXWriter( iface
);
731 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
735 if ( IsEqualGUID( riid
, &IID_IMXWriter
) ||
736 IsEqualGUID( riid
, &IID_IDispatch
) ||
737 IsEqualGUID( riid
, &IID_IUnknown
) )
739 *obj
= &This
->IMXWriter_iface
;
741 else if ( IsEqualGUID( riid
, &IID_ISAXContentHandler
) )
743 *obj
= &This
->ISAXContentHandler_iface
;
745 else if ( IsEqualGUID( riid
, &IID_ISAXLexicalHandler
) )
747 *obj
= &This
->ISAXLexicalHandler_iface
;
749 else if ( IsEqualGUID( riid
, &IID_ISAXDeclHandler
) )
751 *obj
= &This
->ISAXDeclHandler_iface
;
753 else if ( IsEqualGUID( riid
, &IID_ISAXDTDHandler
) )
755 *obj
= &This
->ISAXDTDHandler_iface
;
757 else if ( IsEqualGUID( riid
, &IID_ISAXErrorHandler
) )
759 *obj
= &This
->ISAXErrorHandler_iface
;
761 else if ( IsEqualGUID( riid
, &IID_IVBSAXDeclHandler
) )
763 *obj
= &This
->IVBSAXDeclHandler_iface
;
765 else if ( IsEqualGUID( riid
, &IID_IVBSAXLexicalHandler
) )
767 *obj
= &This
->IVBSAXLexicalHandler_iface
;
769 else if ( IsEqualGUID( riid
, &IID_IVBSAXContentHandler
) )
771 *obj
= &This
->IVBSAXContentHandler_iface
;
773 else if ( IsEqualGUID( riid
, &IID_IVBSAXDTDHandler
) )
775 *obj
= &This
->IVBSAXDTDHandler_iface
;
777 else if ( IsEqualGUID( riid
, &IID_IVBSAXErrorHandler
) )
779 *obj
= &This
->IVBSAXErrorHandler_iface
;
781 else if (dispex_query_interface(&This
->dispex
, riid
, obj
))
783 return *obj
? S_OK
: E_NOINTERFACE
;
787 ERR("interface %s not implemented\n", debugstr_guid(riid
));
789 return E_NOINTERFACE
;
792 IMXWriter_AddRef(iface
);
796 static ULONG WINAPI
mxwriter_AddRef(IMXWriter
*iface
)
798 mxwriter
*This
= impl_from_IMXWriter( iface
);
799 LONG ref
= InterlockedIncrement(&This
->ref
);
801 TRACE("(%p)->(%d)\n", This
, ref
);
806 static ULONG WINAPI
mxwriter_Release(IMXWriter
*iface
)
808 mxwriter
*This
= impl_from_IMXWriter( iface
);
809 ULONG ref
= InterlockedDecrement(&This
->ref
);
811 TRACE("(%p)->(%d)\n", This
, ref
);
815 /* Windows flushes the buffer when the interface is destroyed. */
816 flush_output_buffer(This
);
817 free_output_buffer(&This
->buffer
);
819 if (This
->dest
) IStream_Release(This
->dest
);
820 SysFreeString(This
->version
);
821 SysFreeString(This
->encoding
);
823 SysFreeString(This
->element
);
830 static HRESULT WINAPI
mxwriter_GetTypeInfoCount(IMXWriter
*iface
, UINT
* pctinfo
)
832 mxwriter
*This
= impl_from_IMXWriter( iface
);
833 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
836 static HRESULT WINAPI
mxwriter_GetTypeInfo(
838 UINT iTInfo
, LCID lcid
,
839 ITypeInfo
** ppTInfo
)
841 mxwriter
*This
= impl_from_IMXWriter( iface
);
842 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
,
843 iTInfo
, lcid
, ppTInfo
);
846 static HRESULT WINAPI
mxwriter_GetIDsOfNames(
848 REFIID riid
, LPOLESTR
* rgszNames
,
849 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
851 mxwriter
*This
= impl_from_IMXWriter( iface
);
852 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
,
853 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
856 static HRESULT WINAPI
mxwriter_Invoke(
858 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
859 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
860 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
862 mxwriter
*This
= impl_from_IMXWriter( iface
);
863 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
,
864 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
867 static HRESULT WINAPI
mxwriter_put_output(IMXWriter
*iface
, VARIANT dest
)
869 mxwriter
*This
= impl_from_IMXWriter( iface
);
872 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&dest
));
874 hr
= flush_output_buffer(This
);
882 if (This
->dest
) IStream_Release(This
->dest
);
884 reset_output_buffer(This
);
891 hr
= IUnknown_QueryInterface(V_UNKNOWN(&dest
), &IID_IStream
, (void**)&stream
);
894 /* Recreate the output buffer to make sure it's using the correct encoding. */
895 reset_output_buffer(This
);
897 if (This
->dest
) IStream_Release(This
->dest
);
902 FIXME("unhandled interface type for VT_UNKNOWN destination\n");
906 FIXME("unhandled destination type %s\n", debugstr_variant(&dest
));
913 static HRESULT WINAPI
mxwriter_get_output(IMXWriter
*iface
, VARIANT
*dest
)
915 mxwriter
*This
= impl_from_IMXWriter( iface
);
917 TRACE("(%p)->(%p)\n", This
, dest
);
919 if (!dest
) return E_POINTER
;
923 /* we only support IStream output so far */
924 V_VT(dest
) = VT_UNKNOWN
;
925 V_UNKNOWN(dest
) = (IUnknown
*)This
->dest
;
926 IStream_AddRef(This
->dest
);
930 encoded_buffer
*buff
;
934 hr
= flush_output_buffer(This
);
938 V_VT(dest
) = VT_BSTR
;
939 V_BSTR(dest
) = SysAllocStringLen(NULL
, This
->buffer
.utf16_total
/ sizeof(WCHAR
));
941 return E_OUTOFMEMORY
;
943 dest_ptr
= (char*)V_BSTR(dest
);
944 buff
= &This
->buffer
.encoded
;
948 memcpy(dest_ptr
, buff
->data
, buff
->written
);
949 dest_ptr
+= buff
->written
;
952 LIST_FOR_EACH_ENTRY(buff
, &This
->buffer
.blocks
, encoded_buffer
, entry
)
954 memcpy(dest_ptr
, buff
->data
, buff
->written
);
955 dest_ptr
+= buff
->written
;
962 static HRESULT WINAPI
mxwriter_put_encoding(IMXWriter
*iface
, BSTR encoding
)
964 mxwriter
*This
= impl_from_IMXWriter( iface
);
968 TRACE("(%p)->(%s)\n", This
, debugstr_w(encoding
));
970 enc
= parse_encoding_name(encoding
);
971 if (enc
== XmlEncoding_Unknown
)
973 FIXME("unsupported encoding %s\n", debugstr_w(encoding
));
977 hr
= flush_output_buffer(This
);
981 SysReAllocString(&This
->encoding
, encoding
);
984 TRACE("got encoding %d\n", This
->xml_enc
);
985 reset_output_buffer(This
);
989 static HRESULT WINAPI
mxwriter_get_encoding(IMXWriter
*iface
, BSTR
*encoding
)
991 mxwriter
*This
= impl_from_IMXWriter( iface
);
993 TRACE("(%p)->(%p)\n", This
, encoding
);
995 if (!encoding
) return E_POINTER
;
997 *encoding
= SysAllocString(This
->encoding
);
998 if (!*encoding
) return E_OUTOFMEMORY
;
1003 static HRESULT WINAPI
mxwriter_put_byteOrderMark(IMXWriter
*iface
, VARIANT_BOOL value
)
1005 mxwriter
*This
= impl_from_IMXWriter( iface
);
1007 TRACE("(%p)->(%d)\n", This
, value
);
1008 return writer_set_property(This
, MXWriter_BOM
, value
);
1011 static HRESULT WINAPI
mxwriter_get_byteOrderMark(IMXWriter
*iface
, VARIANT_BOOL
*value
)
1013 mxwriter
*This
= impl_from_IMXWriter( iface
);
1015 TRACE("(%p)->(%p)\n", This
, value
);
1016 return writer_get_property(This
, MXWriter_BOM
, value
);
1019 static HRESULT WINAPI
mxwriter_put_indent(IMXWriter
*iface
, VARIANT_BOOL value
)
1021 mxwriter
*This
= impl_from_IMXWriter( iface
);
1023 TRACE("(%p)->(%d)\n", This
, value
);
1024 return writer_set_property(This
, MXWriter_Indent
, value
);
1027 static HRESULT WINAPI
mxwriter_get_indent(IMXWriter
*iface
, VARIANT_BOOL
*value
)
1029 mxwriter
*This
= impl_from_IMXWriter( iface
);
1031 TRACE("(%p)->(%p)\n", This
, value
);
1032 return writer_get_property(This
, MXWriter_Indent
, value
);
1035 static HRESULT WINAPI
mxwriter_put_standalone(IMXWriter
*iface
, VARIANT_BOOL value
)
1037 mxwriter
*This
= impl_from_IMXWriter( iface
);
1039 TRACE("(%p)->(%d)\n", This
, value
);
1040 return writer_set_property(This
, MXWriter_Standalone
, value
);
1043 static HRESULT WINAPI
mxwriter_get_standalone(IMXWriter
*iface
, VARIANT_BOOL
*value
)
1045 mxwriter
*This
= impl_from_IMXWriter( iface
);
1047 TRACE("(%p)->(%p)\n", This
, value
);
1048 return writer_get_property(This
, MXWriter_Standalone
, value
);
1051 static HRESULT WINAPI
mxwriter_put_omitXMLDeclaration(IMXWriter
*iface
, VARIANT_BOOL value
)
1053 mxwriter
*This
= impl_from_IMXWriter( iface
);
1055 TRACE("(%p)->(%d)\n", This
, value
);
1056 return writer_set_property(This
, MXWriter_OmitXmlDecl
, value
);
1059 static HRESULT WINAPI
mxwriter_get_omitXMLDeclaration(IMXWriter
*iface
, VARIANT_BOOL
*value
)
1061 mxwriter
*This
= impl_from_IMXWriter( iface
);
1063 TRACE("(%p)->(%p)\n", This
, value
);
1064 return writer_get_property(This
, MXWriter_OmitXmlDecl
, value
);
1067 static HRESULT WINAPI
mxwriter_put_version(IMXWriter
*iface
, BSTR version
)
1069 mxwriter
*This
= impl_from_IMXWriter( iface
);
1071 TRACE("(%p)->(%s)\n", This
, debugstr_w(version
));
1073 if (!version
) return E_INVALIDARG
;
1075 SysFreeString(This
->version
);
1076 This
->version
= SysAllocString(version
);
1081 static HRESULT WINAPI
mxwriter_get_version(IMXWriter
*iface
, BSTR
*version
)
1083 mxwriter
*This
= impl_from_IMXWriter( iface
);
1085 TRACE("(%p)->(%p)\n", This
, version
);
1087 if (!version
) return E_POINTER
;
1089 return return_bstr(This
->version
, version
);
1092 static HRESULT WINAPI
mxwriter_put_disableOutputEscaping(IMXWriter
*iface
, VARIANT_BOOL value
)
1094 mxwriter
*This
= impl_from_IMXWriter( iface
);
1096 TRACE("(%p)->(%d)\n", This
, value
);
1097 return writer_set_property(This
, MXWriter_DisableEscaping
, value
);
1100 static HRESULT WINAPI
mxwriter_get_disableOutputEscaping(IMXWriter
*iface
, VARIANT_BOOL
*value
)
1102 mxwriter
*This
= impl_from_IMXWriter( iface
);
1104 TRACE("(%p)->(%p)\n", This
, value
);
1105 return writer_get_property(This
, MXWriter_DisableEscaping
, value
);
1108 static HRESULT WINAPI
mxwriter_flush(IMXWriter
*iface
)
1110 mxwriter
*This
= impl_from_IMXWriter( iface
);
1111 TRACE("(%p)\n", This
);
1112 return flush_output_buffer(This
);
1115 static const struct IMXWriterVtbl MXWriterVtbl
=
1117 mxwriter_QueryInterface
,
1120 mxwriter_GetTypeInfoCount
,
1121 mxwriter_GetTypeInfo
,
1122 mxwriter_GetIDsOfNames
,
1124 mxwriter_put_output
,
1125 mxwriter_get_output
,
1126 mxwriter_put_encoding
,
1127 mxwriter_get_encoding
,
1128 mxwriter_put_byteOrderMark
,
1129 mxwriter_get_byteOrderMark
,
1130 mxwriter_put_indent
,
1131 mxwriter_get_indent
,
1132 mxwriter_put_standalone
,
1133 mxwriter_get_standalone
,
1134 mxwriter_put_omitXMLDeclaration
,
1135 mxwriter_get_omitXMLDeclaration
,
1136 mxwriter_put_version
,
1137 mxwriter_get_version
,
1138 mxwriter_put_disableOutputEscaping
,
1139 mxwriter_get_disableOutputEscaping
,
1143 /*** ISAXContentHandler ***/
1144 static HRESULT WINAPI
SAXContentHandler_QueryInterface(
1145 ISAXContentHandler
*iface
,
1149 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1150 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
1153 static ULONG WINAPI
SAXContentHandler_AddRef(ISAXContentHandler
*iface
)
1155 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1156 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
1159 static ULONG WINAPI
SAXContentHandler_Release(ISAXContentHandler
*iface
)
1161 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1162 return IMXWriter_Release(&This
->IMXWriter_iface
);
1165 static HRESULT WINAPI
SAXContentHandler_putDocumentLocator(
1166 ISAXContentHandler
*iface
,
1167 ISAXLocator
*locator
)
1169 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1170 FIXME("(%p)->(%p)\n", This
, locator
);
1174 static HRESULT WINAPI
SAXContentHandler_startDocument(ISAXContentHandler
*iface
)
1176 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1178 TRACE("(%p)\n", This
);
1180 /* If properties have been changed since the last "endDocument" call
1181 * we need to reset the output buffer. If we don't the output buffer
1182 * could end up with multiple XML documents in it, plus this seems to
1183 * be how Windows works.
1185 if (This
->prop_changed
) {
1186 reset_output_buffer(This
);
1187 This
->prop_changed
= FALSE
;
1190 if (This
->props
[MXWriter_OmitXmlDecl
] == VARIANT_TRUE
) return S_OK
;
1192 write_prolog_buffer(This
);
1194 if (This
->dest
&& This
->xml_enc
== XmlEncoding_UTF16
) {
1195 static const char utf16BOM
[] = {0xff,0xfe};
1197 if (This
->props
[MXWriter_BOM
] == VARIANT_TRUE
)
1198 /* Windows passes a NULL pointer as the pcbWritten parameter and
1199 * ignores any error codes returned from this Write call.
1201 IStream_Write(This
->dest
, utf16BOM
, sizeof(utf16BOM
), NULL
);
1207 static HRESULT WINAPI
SAXContentHandler_endDocument(ISAXContentHandler
*iface
)
1209 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1210 TRACE("(%p)\n", This
);
1211 This
->prop_changed
= FALSE
;
1212 return flush_output_buffer(This
);
1215 static HRESULT WINAPI
SAXContentHandler_startPrefixMapping(
1216 ISAXContentHandler
*iface
,
1217 const WCHAR
*prefix
,
1222 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1223 TRACE("(%p)->(%s %s)\n", This
, debugstr_wn(prefix
, nprefix
), debugstr_wn(uri
, nuri
));
1227 static HRESULT WINAPI
SAXContentHandler_endPrefixMapping(
1228 ISAXContentHandler
*iface
,
1229 const WCHAR
*prefix
,
1232 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1233 TRACE("(%p)->(%s)\n", This
, debugstr_wn(prefix
, nprefix
));
1237 static void mxwriter_write_attribute(mxwriter
*writer
, const WCHAR
*qname
, int qname_len
,
1238 const WCHAR
*value
, int value_len
, BOOL escape
)
1240 static const WCHAR eqW
[] = {'='};
1242 /* space separator in front of every attribute */
1243 write_output_buffer(writer
, spaceW
, 1);
1244 write_output_buffer(writer
, qname
, qname_len
);
1245 write_output_buffer(writer
, eqW
, 1);
1249 WCHAR
*escaped
= get_escaped_string(value
, EscapeValue
, &value_len
);
1250 write_output_buffer_quoted(writer
, escaped
, value_len
);
1254 write_output_buffer_quoted(writer
, value
, value_len
);
1257 static void mxwriter_write_starttag(mxwriter
*writer
, const WCHAR
*qname
, int len
)
1259 static const WCHAR ltW
[] = {'<'};
1261 close_element_starttag(writer
);
1262 set_element_name(writer
, qname
? qname
: emptyW
, qname
? len
: 0);
1264 write_node_indent(writer
);
1266 write_output_buffer(writer
, ltW
, 1);
1267 write_output_buffer(writer
, qname
? qname
: emptyW
, qname
? len
: 0);
1268 writer_inc_indent(writer
);
1271 static HRESULT WINAPI
SAXContentHandler_startElement(
1272 ISAXContentHandler
*iface
,
1273 const WCHAR
*namespaceUri
,
1275 const WCHAR
*local_name
,
1279 ISAXAttributes
*attr
)
1281 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1283 TRACE("(%p)->(%s %s %s %p)\n", This
, debugstr_wn(namespaceUri
, nnamespaceUri
),
1284 debugstr_wn(local_name
, nlocal_name
), debugstr_wn(QName
, nQName
), attr
);
1286 if (((!namespaceUri
|| !local_name
|| !QName
) && This
->class_version
!= MSXML6
) ||
1287 (nQName
== -1 && This
->class_version
== MSXML6
))
1288 return E_INVALIDARG
;
1290 mxwriter_write_starttag(This
, QName
, nQName
);
1294 int length
, i
, escape
;
1297 hr
= ISAXAttributes_getLength(attr
, &length
);
1298 if (FAILED(hr
)) return hr
;
1300 escape
= This
->props
[MXWriter_DisableEscaping
] == VARIANT_FALSE
||
1301 (This
->class_version
== MSXML4
|| This
->class_version
== MSXML6
);
1303 for (i
= 0; i
< length
; i
++)
1305 int qname_len
= 0, value_len
= 0;
1306 const WCHAR
*qname
, *value
;
1308 hr
= ISAXAttributes_getQName(attr
, i
, &qname
, &qname_len
);
1309 if (FAILED(hr
)) return hr
;
1311 hr
= ISAXAttributes_getValue(attr
, i
, &value
, &value_len
);
1312 if (FAILED(hr
)) return hr
;
1314 mxwriter_write_attribute(This
, qname
, qname_len
, value
, value_len
, escape
);
1321 static HRESULT WINAPI
SAXContentHandler_endElement(
1322 ISAXContentHandler
*iface
,
1323 const WCHAR
*namespaceUri
,
1325 const WCHAR
* local_name
,
1330 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1332 TRACE("(%p)->(%s:%d %s:%d %s:%d)\n", This
, debugstr_wn(namespaceUri
, nnamespaceUri
), nnamespaceUri
,
1333 debugstr_wn(local_name
, nlocal_name
), nlocal_name
, debugstr_wn(QName
, nQName
), nQName
);
1335 if (((!namespaceUri
|| !local_name
|| !QName
) && This
->class_version
!= MSXML6
) ||
1336 (nQName
== -1 && This
->class_version
== MSXML6
))
1337 return E_INVALIDARG
;
1339 writer_dec_indent(This
);
1343 static const WCHAR closeW
[] = {'/','>'};
1344 write_output_buffer(This
, closeW
, 2);
1348 static const WCHAR closetagW
[] = {'<','/'};
1349 static const WCHAR gtW
[] = {'>'};
1351 write_node_indent(This
);
1352 write_output_buffer(This
, closetagW
, 2);
1353 write_output_buffer(This
, QName
, nQName
);
1354 write_output_buffer(This
, gtW
, 1);
1357 set_element_name(This
, NULL
, 0);
1362 static HRESULT WINAPI
SAXContentHandler_characters(
1363 ISAXContentHandler
*iface
,
1367 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1369 TRACE("(%p)->(%s:%d)\n", This
, debugstr_wn(chars
, nchars
), nchars
);
1371 if (!chars
) return E_INVALIDARG
;
1373 close_element_starttag(This
);
1374 set_element_name(This
, NULL
, 0);
1381 if (This
->cdata
|| This
->props
[MXWriter_DisableEscaping
] == VARIANT_TRUE
)
1382 write_output_buffer(This
, chars
, nchars
);
1388 escaped
= get_escaped_string(chars
, EscapeText
, &len
);
1389 write_output_buffer(This
, escaped
, len
);
1397 static HRESULT WINAPI
SAXContentHandler_ignorableWhitespace(
1398 ISAXContentHandler
*iface
,
1402 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1404 TRACE("(%p)->(%s)\n", This
, debugstr_wn(chars
, nchars
));
1406 if (!chars
) return E_INVALIDARG
;
1408 write_output_buffer(This
, chars
, nchars
);
1413 static HRESULT WINAPI
SAXContentHandler_processingInstruction(
1414 ISAXContentHandler
*iface
,
1415 const WCHAR
*target
,
1420 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1421 static const WCHAR openpiW
[] = {'<','?'};
1422 static const WCHAR closepiW
[] = {'?','>','\r','\n'};
1424 TRACE("(%p)->(%s %s)\n", This
, debugstr_wn(target
, ntarget
), debugstr_wn(data
, ndata
));
1426 if (!target
) return E_INVALIDARG
;
1428 write_node_indent(This
);
1429 write_output_buffer(This
, openpiW
, sizeof(openpiW
)/sizeof(WCHAR
));
1432 write_output_buffer(This
, target
, ntarget
);
1434 if (data
&& *data
&& ndata
)
1436 write_output_buffer(This
, spaceW
, 1);
1437 write_output_buffer(This
, data
, ndata
);
1440 write_output_buffer(This
, closepiW
, sizeof(closepiW
)/sizeof(WCHAR
));
1441 This
->newline
= TRUE
;
1446 static HRESULT WINAPI
SAXContentHandler_skippedEntity(
1447 ISAXContentHandler
*iface
,
1451 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1452 FIXME("(%p)->(%s)\n", This
, debugstr_wn(name
, nname
));
1456 static const struct ISAXContentHandlerVtbl SAXContentHandlerVtbl
=
1458 SAXContentHandler_QueryInterface
,
1459 SAXContentHandler_AddRef
,
1460 SAXContentHandler_Release
,
1461 SAXContentHandler_putDocumentLocator
,
1462 SAXContentHandler_startDocument
,
1463 SAXContentHandler_endDocument
,
1464 SAXContentHandler_startPrefixMapping
,
1465 SAXContentHandler_endPrefixMapping
,
1466 SAXContentHandler_startElement
,
1467 SAXContentHandler_endElement
,
1468 SAXContentHandler_characters
,
1469 SAXContentHandler_ignorableWhitespace
,
1470 SAXContentHandler_processingInstruction
,
1471 SAXContentHandler_skippedEntity
1474 /*** ISAXLexicalHandler ***/
1475 static HRESULT WINAPI
SAXLexicalHandler_QueryInterface(ISAXLexicalHandler
*iface
,
1476 REFIID riid
, void **obj
)
1478 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1479 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
1482 static ULONG WINAPI
SAXLexicalHandler_AddRef(ISAXLexicalHandler
*iface
)
1484 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1485 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
1488 static ULONG WINAPI
SAXLexicalHandler_Release(ISAXLexicalHandler
*iface
)
1490 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1491 return IMXWriter_Release(&This
->IMXWriter_iface
);
1494 static HRESULT WINAPI
SAXLexicalHandler_startDTD(ISAXLexicalHandler
*iface
,
1495 const WCHAR
*name
, int name_len
, const WCHAR
*publicId
, int publicId_len
,
1496 const WCHAR
*systemId
, int systemId_len
)
1498 static const WCHAR doctypeW
[] = {'<','!','D','O','C','T','Y','P','E',' '};
1499 static const WCHAR openintW
[] = {'[','\r','\n'};
1501 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1503 TRACE("(%p)->(%s %s %s)\n", This
, debugstr_wn(name
, name_len
), debugstr_wn(publicId
, publicId_len
),
1504 debugstr_wn(systemId
, systemId_len
));
1506 if (!name
) return E_INVALIDARG
;
1508 write_output_buffer(This
, doctypeW
, sizeof(doctypeW
)/sizeof(WCHAR
));
1512 write_output_buffer(This
, name
, name_len
);
1513 write_output_buffer(This
, spaceW
, 1);
1518 write_output_buffer(This
, publicW
, sizeof(publicW
)/sizeof(WCHAR
));
1519 write_output_buffer_quoted(This
, publicId
, publicId_len
);
1521 if (!systemId
) return E_INVALIDARG
;
1524 write_output_buffer(This
, spaceW
, 1);
1526 write_output_buffer_quoted(This
, systemId
, systemId_len
);
1529 write_output_buffer(This
, spaceW
, 1);
1533 write_output_buffer(This
, systemW
, sizeof(systemW
)/sizeof(WCHAR
));
1534 write_output_buffer_quoted(This
, systemId
, systemId_len
);
1536 write_output_buffer(This
, spaceW
, 1);
1539 write_output_buffer(This
, openintW
, sizeof(openintW
)/sizeof(WCHAR
));
1544 static HRESULT WINAPI
SAXLexicalHandler_endDTD(ISAXLexicalHandler
*iface
)
1546 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1547 static const WCHAR closedtdW
[] = {']','>','\r','\n'};
1549 TRACE("(%p)\n", This
);
1551 write_output_buffer(This
, closedtdW
, sizeof(closedtdW
)/sizeof(WCHAR
));
1556 static HRESULT WINAPI
SAXLexicalHandler_startEntity(ISAXLexicalHandler
*iface
, const WCHAR
*name
, int len
)
1558 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1559 FIXME("(%p)->(%s): stub\n", This
, debugstr_wn(name
, len
));
1563 static HRESULT WINAPI
SAXLexicalHandler_endEntity(ISAXLexicalHandler
*iface
, const WCHAR
*name
, int len
)
1565 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1566 FIXME("(%p)->(%s): stub\n", This
, debugstr_wn(name
, len
));
1570 static HRESULT WINAPI
SAXLexicalHandler_startCDATA(ISAXLexicalHandler
*iface
)
1572 static const WCHAR scdataW
[] = {'<','!','[','C','D','A','T','A','['};
1573 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1575 TRACE("(%p)\n", This
);
1577 write_node_indent(This
);
1578 write_output_buffer(This
, scdataW
, sizeof(scdataW
)/sizeof(WCHAR
));
1584 static HRESULT WINAPI
SAXLexicalHandler_endCDATA(ISAXLexicalHandler
*iface
)
1586 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1587 static const WCHAR ecdataW
[] = {']',']','>'};
1589 TRACE("(%p)\n", This
);
1591 write_output_buffer(This
, ecdataW
, sizeof(ecdataW
)/sizeof(WCHAR
));
1592 This
->cdata
= FALSE
;
1597 static HRESULT WINAPI
SAXLexicalHandler_comment(ISAXLexicalHandler
*iface
, const WCHAR
*chars
, int nchars
)
1599 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1600 static const WCHAR copenW
[] = {'<','!','-','-'};
1601 static const WCHAR ccloseW
[] = {'-','-','>','\r','\n'};
1603 TRACE("(%p)->(%s:%d)\n", This
, debugstr_wn(chars
, nchars
), nchars
);
1605 if (!chars
) return E_INVALIDARG
;
1607 close_element_starttag(This
);
1608 write_node_indent(This
);
1610 write_output_buffer(This
, copenW
, sizeof(copenW
)/sizeof(WCHAR
));
1612 write_output_buffer(This
, chars
, nchars
);
1613 write_output_buffer(This
, ccloseW
, sizeof(ccloseW
)/sizeof(WCHAR
));
1618 static const struct ISAXLexicalHandlerVtbl SAXLexicalHandlerVtbl
=
1620 SAXLexicalHandler_QueryInterface
,
1621 SAXLexicalHandler_AddRef
,
1622 SAXLexicalHandler_Release
,
1623 SAXLexicalHandler_startDTD
,
1624 SAXLexicalHandler_endDTD
,
1625 SAXLexicalHandler_startEntity
,
1626 SAXLexicalHandler_endEntity
,
1627 SAXLexicalHandler_startCDATA
,
1628 SAXLexicalHandler_endCDATA
,
1629 SAXLexicalHandler_comment
1632 /*** ISAXDeclHandler ***/
1633 static HRESULT WINAPI
SAXDeclHandler_QueryInterface(ISAXDeclHandler
*iface
,
1634 REFIID riid
, void **obj
)
1636 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1637 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
1640 static ULONG WINAPI
SAXDeclHandler_AddRef(ISAXDeclHandler
*iface
)
1642 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1643 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
1646 static ULONG WINAPI
SAXDeclHandler_Release(ISAXDeclHandler
*iface
)
1648 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1649 return IMXWriter_Release(&This
->IMXWriter_iface
);
1652 static HRESULT WINAPI
SAXDeclHandler_elementDecl(ISAXDeclHandler
*iface
,
1653 const WCHAR
*name
, int n_name
, const WCHAR
*model
, int n_model
)
1655 static const WCHAR elementW
[] = {'<','!','E','L','E','M','E','N','T',' '};
1656 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1658 TRACE("(%p)->(%s:%d %s:%d)\n", This
, debugstr_wn(name
, n_name
), n_name
,
1659 debugstr_wn(model
, n_model
), n_model
);
1661 if (!name
|| !model
) return E_INVALIDARG
;
1663 write_output_buffer(This
, elementW
, sizeof(elementW
)/sizeof(WCHAR
));
1665 write_output_buffer(This
, name
, n_name
);
1666 write_output_buffer(This
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1669 write_output_buffer(This
, model
, n_model
);
1670 write_output_buffer(This
, closetagW
, sizeof(closetagW
)/sizeof(WCHAR
));
1675 static HRESULT WINAPI
SAXDeclHandler_attributeDecl(ISAXDeclHandler
*iface
,
1676 const WCHAR
*element
, int n_element
, const WCHAR
*attr
, int n_attr
,
1677 const WCHAR
*type
, int n_type
, const WCHAR
*Default
, int n_default
,
1678 const WCHAR
*value
, int n_value
)
1680 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1681 static const WCHAR attlistW
[] = {'<','!','A','T','T','L','I','S','T',' '};
1682 static const WCHAR closetagW
[] = {'>','\r','\n'};
1684 TRACE("(%p)->(%s:%d %s:%d %s:%d %s:%d %s:%d)\n", This
, debugstr_wn(element
, n_element
), n_element
,
1685 debugstr_wn(attr
, n_attr
), n_attr
, debugstr_wn(type
, n_type
), n_type
, debugstr_wn(Default
, n_default
), n_default
,
1686 debugstr_wn(value
, n_value
), n_value
);
1688 write_output_buffer(This
, attlistW
, sizeof(attlistW
)/sizeof(WCHAR
));
1690 write_output_buffer(This
, element
, n_element
);
1691 write_output_buffer(This
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1695 write_output_buffer(This
, attr
, n_attr
);
1696 write_output_buffer(This
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1700 write_output_buffer(This
, type
, n_type
);
1701 write_output_buffer(This
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1705 write_output_buffer(This
, Default
, n_default
);
1706 write_output_buffer(This
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1710 write_output_buffer_quoted(This
, value
, n_value
);
1712 write_output_buffer(This
, closetagW
, sizeof(closetagW
)/sizeof(WCHAR
));
1717 static HRESULT WINAPI
SAXDeclHandler_internalEntityDecl(ISAXDeclHandler
*iface
,
1718 const WCHAR
*name
, int n_name
, const WCHAR
*value
, int n_value
)
1720 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1722 TRACE("(%p)->(%s:%d %s:%d)\n", This
, debugstr_wn(name
, n_name
), n_name
,
1723 debugstr_wn(value
, n_value
), n_value
);
1725 if (!name
|| !value
) return E_INVALIDARG
;
1727 write_output_buffer(This
, entityW
, sizeof(entityW
)/sizeof(WCHAR
));
1729 write_output_buffer(This
, name
, n_name
);
1730 write_output_buffer(This
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1734 write_output_buffer_quoted(This
, value
, n_value
);
1736 write_output_buffer(This
, closetagW
, sizeof(closetagW
)/sizeof(WCHAR
));
1741 static HRESULT WINAPI
SAXDeclHandler_externalEntityDecl(ISAXDeclHandler
*iface
,
1742 const WCHAR
*name
, int n_name
, const WCHAR
*publicId
, int n_publicId
,
1743 const WCHAR
*systemId
, int n_systemId
)
1745 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1747 TRACE("(%p)->(%s:%d %s:%d %s:%d)\n", This
, debugstr_wn(name
, n_name
), n_name
,
1748 debugstr_wn(publicId
, n_publicId
), n_publicId
, debugstr_wn(systemId
, n_systemId
), n_systemId
);
1750 if (!name
|| !systemId
) return E_INVALIDARG
;
1752 write_output_buffer(This
, entityW
, sizeof(entityW
)/sizeof(WCHAR
));
1754 write_output_buffer(This
, name
, n_name
);
1755 write_output_buffer(This
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1760 write_output_buffer(This
, publicW
, sizeof(publicW
)/sizeof(WCHAR
));
1761 write_output_buffer_quoted(This
, publicId
, n_publicId
);
1762 write_output_buffer(This
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1763 write_output_buffer_quoted(This
, systemId
, n_systemId
);
1767 write_output_buffer(This
, systemW
, sizeof(systemW
)/sizeof(WCHAR
));
1768 write_output_buffer_quoted(This
, systemId
, n_systemId
);
1771 write_output_buffer(This
, closetagW
, sizeof(closetagW
)/sizeof(WCHAR
));
1776 static const ISAXDeclHandlerVtbl SAXDeclHandlerVtbl
= {
1777 SAXDeclHandler_QueryInterface
,
1778 SAXDeclHandler_AddRef
,
1779 SAXDeclHandler_Release
,
1780 SAXDeclHandler_elementDecl
,
1781 SAXDeclHandler_attributeDecl
,
1782 SAXDeclHandler_internalEntityDecl
,
1783 SAXDeclHandler_externalEntityDecl
1786 /*** IVBSAXDeclHandler ***/
1787 static HRESULT WINAPI
VBSAXDeclHandler_QueryInterface(IVBSAXDeclHandler
*iface
,
1788 REFIID riid
, void **obj
)
1790 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1791 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
1794 static ULONG WINAPI
VBSAXDeclHandler_AddRef(IVBSAXDeclHandler
*iface
)
1796 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1797 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
1800 static ULONG WINAPI
VBSAXDeclHandler_Release(IVBSAXDeclHandler
*iface
)
1802 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1803 return IMXWriter_Release(&This
->IMXWriter_iface
);
1806 static HRESULT WINAPI
VBSAXDeclHandler_GetTypeInfoCount(IVBSAXDeclHandler
*iface
, UINT
* pctinfo
)
1808 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1809 return IMXWriter_GetTypeInfoCount(&This
->IMXWriter_iface
, pctinfo
);
1812 static HRESULT WINAPI
VBSAXDeclHandler_GetTypeInfo(IVBSAXDeclHandler
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1814 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1815 return IMXWriter_GetTypeInfo(&This
->IMXWriter_iface
, iTInfo
, lcid
, ppTInfo
);
1818 static HRESULT WINAPI
VBSAXDeclHandler_GetIDsOfNames(IVBSAXDeclHandler
*iface
, REFIID riid
, LPOLESTR
* rgszNames
,
1819 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
1821 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1822 return IMXWriter_GetIDsOfNames(&This
->IMXWriter_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1825 static HRESULT WINAPI
VBSAXDeclHandler_Invoke(IVBSAXDeclHandler
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
1826 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
1828 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1829 return IMXWriter_Invoke(&This
->IMXWriter_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
,
1830 pExcepInfo
, puArgErr
);
1833 static HRESULT WINAPI
VBSAXDeclHandler_elementDecl(IVBSAXDeclHandler
*iface
, BSTR
*name
, BSTR
*model
)
1835 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1837 TRACE("(%p)->(%p %p)\n", This
, name
, model
);
1839 if (!name
|| !model
)
1842 return ISAXDeclHandler_elementDecl(&This
->ISAXDeclHandler_iface
, *name
, -1, *model
, -1);
1845 static HRESULT WINAPI
VBSAXDeclHandler_attributeDecl(IVBSAXDeclHandler
*iface
,
1846 BSTR
*element
, BSTR
*attr
, BSTR
*type
, BSTR
*default_value
, BSTR
*value
)
1848 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1850 TRACE("(%p)->(%p %p %p %p %p)\n", This
, element
, attr
, type
, default_value
, value
);
1852 if (!element
|| !attr
|| !type
|| !default_value
|| !value
)
1855 return ISAXDeclHandler_attributeDecl(&This
->ISAXDeclHandler_iface
, *element
, -1, *attr
, -1, *type
, -1,
1856 *default_value
, -1, *value
, -1);
1859 static HRESULT WINAPI
VBSAXDeclHandler_internalEntityDecl(IVBSAXDeclHandler
*iface
, BSTR
*name
, BSTR
*value
)
1861 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1863 TRACE("(%p)->(%p %p)\n", This
, name
, value
);
1865 if (!name
|| !value
)
1868 return ISAXDeclHandler_internalEntityDecl(&This
->ISAXDeclHandler_iface
, *name
, -1, *value
, -1);
1871 static HRESULT WINAPI
VBSAXDeclHandler_externalEntityDecl(IVBSAXDeclHandler
*iface
,
1872 BSTR
*name
, BSTR
*publicid
, BSTR
*systemid
)
1874 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1876 TRACE("(%p)->(%p %p %p)\n", This
, name
, publicid
, systemid
);
1878 if (!name
|| !publicid
|| !systemid
)
1881 return ISAXDeclHandler_externalEntityDecl(&This
->ISAXDeclHandler_iface
, *name
, -1, *publicid
, -1, *systemid
, -1);
1884 static const IVBSAXDeclHandlerVtbl VBSAXDeclHandlerVtbl
= {
1885 VBSAXDeclHandler_QueryInterface
,
1886 VBSAXDeclHandler_AddRef
,
1887 VBSAXDeclHandler_Release
,
1888 VBSAXDeclHandler_GetTypeInfoCount
,
1889 VBSAXDeclHandler_GetTypeInfo
,
1890 VBSAXDeclHandler_GetIDsOfNames
,
1891 VBSAXDeclHandler_Invoke
,
1892 VBSAXDeclHandler_elementDecl
,
1893 VBSAXDeclHandler_attributeDecl
,
1894 VBSAXDeclHandler_internalEntityDecl
,
1895 VBSAXDeclHandler_externalEntityDecl
1898 /*** IVBSAXLexicalHandler ***/
1899 static HRESULT WINAPI
VBSAXLexicalHandler_QueryInterface(IVBSAXLexicalHandler
*iface
,
1900 REFIID riid
, void **obj
)
1902 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1903 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
1906 static ULONG WINAPI
VBSAXLexicalHandler_AddRef(IVBSAXLexicalHandler
*iface
)
1908 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1909 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
1912 static ULONG WINAPI
VBSAXLexicalHandler_Release(IVBSAXLexicalHandler
*iface
)
1914 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1915 return IMXWriter_Release(&This
->IMXWriter_iface
);
1918 static HRESULT WINAPI
VBSAXLexicalHandler_GetTypeInfoCount(IVBSAXLexicalHandler
*iface
, UINT
* pctinfo
)
1920 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1921 return IMXWriter_GetTypeInfoCount(&This
->IMXWriter_iface
, pctinfo
);
1924 static HRESULT WINAPI
VBSAXLexicalHandler_GetTypeInfo(IVBSAXLexicalHandler
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1926 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1927 return IMXWriter_GetTypeInfo(&This
->IMXWriter_iface
, iTInfo
, lcid
, ppTInfo
);
1930 static HRESULT WINAPI
VBSAXLexicalHandler_GetIDsOfNames(IVBSAXLexicalHandler
*iface
, REFIID riid
, LPOLESTR
* rgszNames
,
1931 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
1933 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1934 return IMXWriter_GetIDsOfNames(&This
->IMXWriter_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1937 static HRESULT WINAPI
VBSAXLexicalHandler_Invoke(IVBSAXLexicalHandler
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
1938 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
1940 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1941 return IMXWriter_Invoke(&This
->IMXWriter_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
,
1942 pExcepInfo
, puArgErr
);
1945 static HRESULT WINAPI
VBSAXLexicalHandler_startDTD(IVBSAXLexicalHandler
*iface
, BSTR
*name
, BSTR
*publicId
, BSTR
*systemId
)
1947 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1949 TRACE("(%p)->(%p %p %p)\n", This
, name
, publicId
, systemId
);
1951 if (!name
|| !publicId
|| !systemId
)
1954 return ISAXLexicalHandler_startDTD(&This
->ISAXLexicalHandler_iface
, *name
, -1, *publicId
, -1, *systemId
, -1);
1957 static HRESULT WINAPI
VBSAXLexicalHandler_endDTD(IVBSAXLexicalHandler
*iface
)
1959 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1960 return ISAXLexicalHandler_endDTD(&This
->ISAXLexicalHandler_iface
);
1963 static HRESULT WINAPI
VBSAXLexicalHandler_startEntity(IVBSAXLexicalHandler
*iface
, BSTR
*name
)
1965 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1967 TRACE("(%p)->(%p)\n", This
, name
);
1972 return ISAXLexicalHandler_startEntity(&This
->ISAXLexicalHandler_iface
, *name
, -1);
1975 static HRESULT WINAPI
VBSAXLexicalHandler_endEntity(IVBSAXLexicalHandler
*iface
, BSTR
*name
)
1977 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1979 TRACE("(%p)->(%p)\n", This
, name
);
1984 return ISAXLexicalHandler_endEntity(&This
->ISAXLexicalHandler_iface
, *name
, -1);
1987 static HRESULT WINAPI
VBSAXLexicalHandler_startCDATA(IVBSAXLexicalHandler
*iface
)
1989 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1990 return ISAXLexicalHandler_startCDATA(&This
->ISAXLexicalHandler_iface
);
1993 static HRESULT WINAPI
VBSAXLexicalHandler_endCDATA(IVBSAXLexicalHandler
*iface
)
1995 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1996 return ISAXLexicalHandler_endCDATA(&This
->ISAXLexicalHandler_iface
);
1999 static HRESULT WINAPI
VBSAXLexicalHandler_comment(IVBSAXLexicalHandler
*iface
, BSTR
*chars
)
2001 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
2003 TRACE("(%p)->(%p)\n", This
, chars
);
2008 return ISAXLexicalHandler_comment(&This
->ISAXLexicalHandler_iface
, *chars
, -1);
2011 static const IVBSAXLexicalHandlerVtbl VBSAXLexicalHandlerVtbl
= {
2012 VBSAXLexicalHandler_QueryInterface
,
2013 VBSAXLexicalHandler_AddRef
,
2014 VBSAXLexicalHandler_Release
,
2015 VBSAXLexicalHandler_GetTypeInfoCount
,
2016 VBSAXLexicalHandler_GetTypeInfo
,
2017 VBSAXLexicalHandler_GetIDsOfNames
,
2018 VBSAXLexicalHandler_Invoke
,
2019 VBSAXLexicalHandler_startDTD
,
2020 VBSAXLexicalHandler_endDTD
,
2021 VBSAXLexicalHandler_startEntity
,
2022 VBSAXLexicalHandler_endEntity
,
2023 VBSAXLexicalHandler_startCDATA
,
2024 VBSAXLexicalHandler_endCDATA
,
2025 VBSAXLexicalHandler_comment
2028 /*** IVBSAXContentHandler ***/
2029 static HRESULT WINAPI
VBSAXContentHandler_QueryInterface(IVBSAXContentHandler
*iface
, REFIID riid
, void **obj
)
2031 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2032 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
2035 static ULONG WINAPI
VBSAXContentHandler_AddRef(IVBSAXContentHandler
*iface
)
2037 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2038 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
2041 static ULONG WINAPI
VBSAXContentHandler_Release(IVBSAXContentHandler
*iface
)
2043 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2044 return IMXWriter_Release(&This
->IMXWriter_iface
);
2047 static HRESULT WINAPI
VBSAXContentHandler_GetTypeInfoCount(IVBSAXContentHandler
*iface
, UINT
* pctinfo
)
2049 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2050 return IMXWriter_GetTypeInfoCount(&This
->IMXWriter_iface
, pctinfo
);
2053 static HRESULT WINAPI
VBSAXContentHandler_GetTypeInfo(IVBSAXContentHandler
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2055 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2056 return IMXWriter_GetTypeInfo(&This
->IMXWriter_iface
, iTInfo
, lcid
, ppTInfo
);
2059 static HRESULT WINAPI
VBSAXContentHandler_GetIDsOfNames(IVBSAXContentHandler
*iface
, REFIID riid
, LPOLESTR
* rgszNames
,
2060 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
2062 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2063 return IMXWriter_GetIDsOfNames(&This
->IMXWriter_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
2066 static HRESULT WINAPI
VBSAXContentHandler_Invoke(IVBSAXContentHandler
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
2067 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
2069 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2070 return IMXWriter_Invoke(&This
->IMXWriter_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
,
2071 pExcepInfo
, puArgErr
);
2074 static HRESULT WINAPI
VBSAXContentHandler_putref_documentLocator(IVBSAXContentHandler
*iface
, IVBSAXLocator
*locator
)
2076 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2077 TRACE("(%p)->(%p)\n", This
, locator
);
2081 static HRESULT WINAPI
VBSAXContentHandler_startDocument(IVBSAXContentHandler
*iface
)
2083 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2084 return ISAXContentHandler_startDocument(&This
->ISAXContentHandler_iface
);
2087 static HRESULT WINAPI
VBSAXContentHandler_endDocument(IVBSAXContentHandler
*iface
)
2089 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2090 return ISAXContentHandler_endDocument(&This
->ISAXContentHandler_iface
);
2093 static HRESULT WINAPI
VBSAXContentHandler_startPrefixMapping(IVBSAXContentHandler
*iface
, BSTR
*prefix
, BSTR
*uri
)
2095 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2097 TRACE("(%p)->(%p %p)\n", This
, prefix
, uri
);
2099 if (!prefix
|| !uri
)
2102 return ISAXContentHandler_startPrefixMapping(&This
->ISAXContentHandler_iface
, *prefix
, -1, *uri
, -1);
2105 static HRESULT WINAPI
VBSAXContentHandler_endPrefixMapping(IVBSAXContentHandler
*iface
, BSTR
*prefix
)
2107 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2109 TRACE("(%p)->(%p)\n", This
, prefix
);
2114 return ISAXContentHandler_endPrefixMapping(&This
->ISAXContentHandler_iface
, *prefix
, -1);
2117 static HRESULT WINAPI
VBSAXContentHandler_startElement(IVBSAXContentHandler
*iface
,
2118 BSTR
*namespaceURI
, BSTR
*localName
, BSTR
*QName
, IVBSAXAttributes
*attrs
)
2120 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2122 TRACE("(%p)->(%p %p %p %p)\n", This
, namespaceURI
, localName
, QName
, attrs
);
2124 if (!namespaceURI
|| !localName
|| !QName
)
2127 TRACE("(%s %s %s)\n", debugstr_w(*namespaceURI
), debugstr_w(*localName
), debugstr_w(*QName
));
2129 mxwriter_write_starttag(This
, *QName
, SysStringLen(*QName
));
2133 int length
, i
, escape
;
2136 hr
= IVBSAXAttributes_get_length(attrs
, &length
);
2137 if (FAILED(hr
)) return hr
;
2139 escape
= This
->props
[MXWriter_DisableEscaping
] == VARIANT_FALSE
||
2140 (This
->class_version
== MSXML4
|| This
->class_version
== MSXML6
);
2142 for (i
= 0; i
< length
; i
++)
2146 hr
= IVBSAXAttributes_getQName(attrs
, i
, &qname
);
2147 if (FAILED(hr
)) return hr
;
2149 hr
= IVBSAXAttributes_getValue(attrs
, i
, &value
);
2152 SysFreeString(qname
);
2156 mxwriter_write_attribute(This
, qname
, SysStringLen(qname
), value
, SysStringLen(value
), escape
);
2157 SysFreeString(qname
);
2158 SysFreeString(value
);
2165 static HRESULT WINAPI
VBSAXContentHandler_endElement(IVBSAXContentHandler
*iface
, BSTR
*namespaceURI
,
2166 BSTR
*localName
, BSTR
*QName
)
2168 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2170 TRACE("(%p)->(%p %p %p)\n", This
, namespaceURI
, localName
, QName
);
2172 if (!namespaceURI
|| !localName
|| !QName
)
2175 return ISAXContentHandler_endElement(&This
->ISAXContentHandler_iface
,
2176 *namespaceURI
, SysStringLen(*namespaceURI
),
2177 *localName
, SysStringLen(*localName
),
2178 *QName
, SysStringLen(*QName
));
2181 static HRESULT WINAPI
VBSAXContentHandler_characters(IVBSAXContentHandler
*iface
, BSTR
*chars
)
2183 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2185 TRACE("(%p)->(%p)\n", This
, chars
);
2190 return ISAXContentHandler_characters(&This
->ISAXContentHandler_iface
, *chars
, -1);
2193 static HRESULT WINAPI
VBSAXContentHandler_ignorableWhitespace(IVBSAXContentHandler
*iface
, BSTR
*chars
)
2195 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2197 TRACE("(%p)->(%p)\n", This
, chars
);
2202 return ISAXContentHandler_ignorableWhitespace(&This
->ISAXContentHandler_iface
, *chars
, -1);
2205 static HRESULT WINAPI
VBSAXContentHandler_processingInstruction(IVBSAXContentHandler
*iface
,
2206 BSTR
*target
, BSTR
*data
)
2208 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2210 TRACE("(%p)->(%p %p)\n", This
, target
, data
);
2212 if (!target
|| !data
)
2215 return ISAXContentHandler_processingInstruction(&This
->ISAXContentHandler_iface
, *target
, -1, *data
, -1);
2218 static HRESULT WINAPI
VBSAXContentHandler_skippedEntity(IVBSAXContentHandler
*iface
, BSTR
*name
)
2220 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2222 TRACE("(%p)->(%p)\n", This
, name
);
2227 return ISAXContentHandler_skippedEntity(&This
->ISAXContentHandler_iface
, *name
, -1);
2230 static const IVBSAXContentHandlerVtbl VBSAXContentHandlerVtbl
= {
2231 VBSAXContentHandler_QueryInterface
,
2232 VBSAXContentHandler_AddRef
,
2233 VBSAXContentHandler_Release
,
2234 VBSAXContentHandler_GetTypeInfoCount
,
2235 VBSAXContentHandler_GetTypeInfo
,
2236 VBSAXContentHandler_GetIDsOfNames
,
2237 VBSAXContentHandler_Invoke
,
2238 VBSAXContentHandler_putref_documentLocator
,
2239 VBSAXContentHandler_startDocument
,
2240 VBSAXContentHandler_endDocument
,
2241 VBSAXContentHandler_startPrefixMapping
,
2242 VBSAXContentHandler_endPrefixMapping
,
2243 VBSAXContentHandler_startElement
,
2244 VBSAXContentHandler_endElement
,
2245 VBSAXContentHandler_characters
,
2246 VBSAXContentHandler_ignorableWhitespace
,
2247 VBSAXContentHandler_processingInstruction
,
2248 VBSAXContentHandler_skippedEntity
2251 static HRESULT WINAPI
SAXDTDHandler_QueryInterface(ISAXDTDHandler
*iface
, REFIID riid
, void **obj
)
2253 mxwriter
*This
= impl_from_ISAXDTDHandler( iface
);
2254 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
2257 static ULONG WINAPI
SAXDTDHandler_AddRef(ISAXDTDHandler
*iface
)
2259 mxwriter
*This
= impl_from_ISAXDTDHandler( iface
);
2260 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
2263 static ULONG WINAPI
SAXDTDHandler_Release(ISAXDTDHandler
*iface
)
2265 mxwriter
*This
= impl_from_ISAXDTDHandler( iface
);
2266 return IMXWriter_Release(&This
->IMXWriter_iface
);
2269 static HRESULT WINAPI
SAXDTDHandler_notationDecl(ISAXDTDHandler
*iface
,
2270 const WCHAR
*name
, INT n_name
,
2271 const WCHAR
*publicid
, INT n_publicid
,
2272 const WCHAR
*systemid
, INT n_systemid
)
2274 static const WCHAR notationW
[] = {'<','!','N','O','T','A','T','I','O','N',' '};
2275 mxwriter
*This
= impl_from_ISAXDTDHandler( iface
);
2277 TRACE("(%p)->(%s:%d, %s:%d, %s:%d)\n", This
, debugstr_wn(name
, n_name
), n_name
,
2278 debugstr_wn(publicid
, n_publicid
), n_publicid
, debugstr_wn(systemid
, n_systemid
), n_systemid
);
2280 if (!name
|| !n_name
)
2281 return E_INVALIDARG
;
2283 write_output_buffer(This
, notationW
, sizeof(notationW
)/sizeof(WCHAR
));
2284 write_output_buffer(This
, name
, n_name
);
2286 if (!publicid
&& !systemid
)
2287 return E_INVALIDARG
;
2289 write_output_buffer(This
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
2292 write_output_buffer(This
, publicW
, sizeof(publicW
)/sizeof(WCHAR
));
2293 write_output_buffer_quoted(This
, publicid
, n_publicid
);
2296 write_output_buffer(This
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
2297 write_output_buffer_quoted(This
, systemid
, n_systemid
);
2302 write_output_buffer(This
, systemW
, sizeof(systemW
)/sizeof(WCHAR
));
2303 write_output_buffer_quoted(This
, systemid
, n_systemid
);
2306 write_output_buffer(This
, closetagW
, sizeof(closetagW
)/sizeof(WCHAR
));
2311 static HRESULT WINAPI
SAXDTDHandler_unparsedEntityDecl(ISAXDTDHandler
*iface
,
2312 const WCHAR
*name
, INT nname
,
2313 const WCHAR
*publicid
, INT npublicid
,
2314 const WCHAR
*systemid
, INT nsystemid
,
2315 const WCHAR
*notation
, INT nnotation
)
2317 mxwriter
*This
= impl_from_ISAXDTDHandler( iface
);
2318 FIXME("(%p)->(%s:%d, %s:%d, %s:%d, %s:%d): stub\n", This
, debugstr_wn(name
, nname
), nname
,
2319 debugstr_wn(publicid
, npublicid
), npublicid
, debugstr_wn(systemid
, nsystemid
), nsystemid
,
2320 debugstr_wn(notation
, nnotation
), nnotation
);
2324 static const ISAXDTDHandlerVtbl SAXDTDHandlerVtbl
= {
2325 SAXDTDHandler_QueryInterface
,
2326 SAXDTDHandler_AddRef
,
2327 SAXDTDHandler_Release
,
2328 SAXDTDHandler_notationDecl
,
2329 SAXDTDHandler_unparsedEntityDecl
2332 /*** IVBSAXDTDHandler ***/
2333 static HRESULT WINAPI
VBSAXDTDHandler_QueryInterface(IVBSAXDTDHandler
*iface
, REFIID riid
, void **obj
)
2335 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2336 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
2339 static ULONG WINAPI
VBSAXDTDHandler_AddRef(IVBSAXDTDHandler
*iface
)
2341 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2342 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
2345 static ULONG WINAPI
VBSAXDTDHandler_Release(IVBSAXDTDHandler
*iface
)
2347 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2348 return IMXWriter_Release(&This
->IMXWriter_iface
);
2351 static HRESULT WINAPI
VBSAXDTDHandler_GetTypeInfoCount(IVBSAXDTDHandler
*iface
, UINT
* pctinfo
)
2353 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2354 return IMXWriter_GetTypeInfoCount(&This
->IMXWriter_iface
, pctinfo
);
2357 static HRESULT WINAPI
VBSAXDTDHandler_GetTypeInfo(IVBSAXDTDHandler
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2359 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2360 return IMXWriter_GetTypeInfo(&This
->IMXWriter_iface
, iTInfo
, lcid
, ppTInfo
);
2363 static HRESULT WINAPI
VBSAXDTDHandler_GetIDsOfNames(IVBSAXDTDHandler
*iface
, REFIID riid
, LPOLESTR
* rgszNames
,
2364 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
2366 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2367 return IMXWriter_GetIDsOfNames(&This
->IMXWriter_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
2370 static HRESULT WINAPI
VBSAXDTDHandler_Invoke(IVBSAXDTDHandler
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
2371 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
2373 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2374 return IMXWriter_Invoke(&This
->IMXWriter_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
,
2375 pExcepInfo
, puArgErr
);
2378 static HRESULT WINAPI
VBSAXDTDHandler_notationDecl(IVBSAXDTDHandler
*iface
, BSTR
*name
, BSTR
*publicId
, BSTR
*systemId
)
2380 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2382 TRACE("(%p)->(%p %p %p)\n", This
, name
, publicId
, systemId
);
2384 if (!name
|| !publicId
|| !systemId
)
2387 return ISAXDTDHandler_notationDecl(&This
->ISAXDTDHandler_iface
, *name
, -1, *publicId
, -1, *systemId
, -1);
2390 static HRESULT WINAPI
VBSAXDTDHandler_unparsedEntityDecl(IVBSAXDTDHandler
*iface
, BSTR
*name
, BSTR
*publicId
,
2391 BSTR
*systemId
, BSTR
*notation
)
2393 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2395 TRACE("(%p)->(%p %p %p %p)\n", This
, name
, publicId
, systemId
, notation
);
2397 if (!name
|| !publicId
|| !systemId
|| !notation
)
2400 return ISAXDTDHandler_unparsedEntityDecl(&This
->ISAXDTDHandler_iface
, *name
, -1, *publicId
, -1,
2401 *systemId
, -1, *notation
, -1);
2404 static const IVBSAXDTDHandlerVtbl VBSAXDTDHandlerVtbl
= {
2405 VBSAXDTDHandler_QueryInterface
,
2406 VBSAXDTDHandler_AddRef
,
2407 VBSAXDTDHandler_Release
,
2408 VBSAXDTDHandler_GetTypeInfoCount
,
2409 VBSAXDTDHandler_GetTypeInfo
,
2410 VBSAXDTDHandler_GetIDsOfNames
,
2411 VBSAXDTDHandler_Invoke
,
2412 VBSAXDTDHandler_notationDecl
,
2413 VBSAXDTDHandler_unparsedEntityDecl
2416 /* ISAXErrorHandler */
2417 static HRESULT WINAPI
SAXErrorHandler_QueryInterface(ISAXErrorHandler
*iface
, REFIID riid
, void **obj
)
2419 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2420 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
2423 static ULONG WINAPI
SAXErrorHandler_AddRef(ISAXErrorHandler
*iface
)
2425 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2426 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
2429 static ULONG WINAPI
SAXErrorHandler_Release(ISAXErrorHandler
*iface
)
2431 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2432 return IMXWriter_Release(&This
->IMXWriter_iface
);
2435 static HRESULT WINAPI
SAXErrorHandler_error(ISAXErrorHandler
*iface
,
2436 ISAXLocator
*locator
, const WCHAR
*message
, HRESULT hr
)
2438 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2440 FIXME("(%p)->(%p %s 0x%08x)\n", This
, locator
, debugstr_w(message
), hr
);
2445 static HRESULT WINAPI
SAXErrorHandler_fatalError(ISAXErrorHandler
*iface
,
2446 ISAXLocator
*locator
, const WCHAR
*message
, HRESULT hr
)
2448 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2450 FIXME("(%p)->(%p %s 0x%08x)\n", This
, locator
, debugstr_w(message
), hr
);
2455 static HRESULT WINAPI
SAXErrorHandler_ignorableWarning(ISAXErrorHandler
*iface
,
2456 ISAXLocator
*locator
, const WCHAR
*message
, HRESULT hr
)
2458 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2460 FIXME("(%p)->(%p %s 0x%08x)\n", This
, locator
, debugstr_w(message
), hr
);
2465 static const ISAXErrorHandlerVtbl SAXErrorHandlerVtbl
= {
2466 SAXErrorHandler_QueryInterface
,
2467 SAXErrorHandler_AddRef
,
2468 SAXErrorHandler_Release
,
2469 SAXErrorHandler_error
,
2470 SAXErrorHandler_fatalError
,
2471 SAXErrorHandler_ignorableWarning
2474 /*** IVBSAXErrorHandler ***/
2475 static HRESULT WINAPI
VBSAXErrorHandler_QueryInterface(IVBSAXErrorHandler
*iface
, REFIID riid
, void **obj
)
2477 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2478 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
2481 static ULONG WINAPI
VBSAXErrorHandler_AddRef(IVBSAXErrorHandler
*iface
)
2483 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2484 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
2487 static ULONG WINAPI
VBSAXErrorHandler_Release(IVBSAXErrorHandler
*iface
)
2489 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2490 return IMXWriter_Release(&This
->IMXWriter_iface
);
2493 static HRESULT WINAPI
VBSAXErrorHandler_GetTypeInfoCount(IVBSAXErrorHandler
*iface
, UINT
* pctinfo
)
2495 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2496 return IMXWriter_GetTypeInfoCount(&This
->IMXWriter_iface
, pctinfo
);
2499 static HRESULT WINAPI
VBSAXErrorHandler_GetTypeInfo(IVBSAXErrorHandler
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2501 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2502 return IMXWriter_GetTypeInfo(&This
->IMXWriter_iface
, iTInfo
, lcid
, ppTInfo
);
2505 static HRESULT WINAPI
VBSAXErrorHandler_GetIDsOfNames(IVBSAXErrorHandler
*iface
, REFIID riid
, LPOLESTR
* rgszNames
,
2506 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
2508 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2509 return IMXWriter_GetIDsOfNames(&This
->IMXWriter_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
2512 static HRESULT WINAPI
VBSAXErrorHandler_Invoke(IVBSAXErrorHandler
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
2513 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
2515 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2516 return IMXWriter_Invoke(&This
->IMXWriter_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
,
2517 pExcepInfo
, puArgErr
);
2520 static HRESULT WINAPI
VBSAXErrorHandler_error(IVBSAXErrorHandler
*iface
, IVBSAXLocator
*locator
, BSTR
*message
, LONG code
)
2522 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2523 FIXME("(%p)->(%p %p %x): stub\n", This
, locator
, message
, code
);
2527 static HRESULT WINAPI
VBSAXErrorHandler_fatalError(IVBSAXErrorHandler
*iface
, IVBSAXLocator
*locator
, BSTR
*message
, LONG code
)
2529 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2530 FIXME("(%p)->(%p %p %x): stub\n", This
, locator
, message
, code
);
2534 static HRESULT WINAPI
VBSAXErrorHandler_ignorableWarning(IVBSAXErrorHandler
*iface
, IVBSAXLocator
*locator
, BSTR
*message
, LONG code
)
2536 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2537 FIXME("(%p)->(%p %p %x): stub\n", This
, locator
, message
, code
);
2541 static const IVBSAXErrorHandlerVtbl VBSAXErrorHandlerVtbl
= {
2542 VBSAXErrorHandler_QueryInterface
,
2543 VBSAXErrorHandler_AddRef
,
2544 VBSAXErrorHandler_Release
,
2545 VBSAXErrorHandler_GetTypeInfoCount
,
2546 VBSAXErrorHandler_GetTypeInfo
,
2547 VBSAXErrorHandler_GetIDsOfNames
,
2548 VBSAXErrorHandler_Invoke
,
2549 VBSAXErrorHandler_error
,
2550 VBSAXErrorHandler_fatalError
,
2551 VBSAXErrorHandler_ignorableWarning
2554 static const tid_t mxwriter_iface_tids
[] = {
2559 static dispex_static_data_t mxwriter_dispex
= {
2566 HRESULT
MXWriter_create(MSXML_VERSION version
, void **ppObj
)
2568 static const WCHAR version10W
[] = {'1','.','0',0};
2572 TRACE("(%p)\n", ppObj
);
2574 This
= heap_alloc( sizeof (*This
) );
2576 return E_OUTOFMEMORY
;
2578 This
->IMXWriter_iface
.lpVtbl
= &MXWriterVtbl
;
2579 This
->ISAXContentHandler_iface
.lpVtbl
= &SAXContentHandlerVtbl
;
2580 This
->ISAXLexicalHandler_iface
.lpVtbl
= &SAXLexicalHandlerVtbl
;
2581 This
->ISAXDeclHandler_iface
.lpVtbl
= &SAXDeclHandlerVtbl
;
2582 This
->ISAXDTDHandler_iface
.lpVtbl
= &SAXDTDHandlerVtbl
;
2583 This
->ISAXErrorHandler_iface
.lpVtbl
= &SAXErrorHandlerVtbl
;
2584 This
->IVBSAXDeclHandler_iface
.lpVtbl
= &VBSAXDeclHandlerVtbl
;
2585 This
->IVBSAXLexicalHandler_iface
.lpVtbl
= &VBSAXLexicalHandlerVtbl
;
2586 This
->IVBSAXContentHandler_iface
.lpVtbl
= &VBSAXContentHandlerVtbl
;
2587 This
->IVBSAXDTDHandler_iface
.lpVtbl
= &VBSAXDTDHandlerVtbl
;
2588 This
->IVBSAXErrorHandler_iface
.lpVtbl
= &VBSAXErrorHandlerVtbl
;
2590 This
->class_version
= version
;
2592 This
->props
[MXWriter_BOM
] = VARIANT_TRUE
;
2593 This
->props
[MXWriter_DisableEscaping
] = VARIANT_FALSE
;
2594 This
->props
[MXWriter_Indent
] = VARIANT_FALSE
;
2595 This
->props
[MXWriter_OmitXmlDecl
] = VARIANT_FALSE
;
2596 This
->props
[MXWriter_Standalone
] = VARIANT_FALSE
;
2597 This
->prop_changed
= FALSE
;
2598 This
->encoding
= SysAllocString(utf16W
);
2599 This
->version
= SysAllocString(version10W
);
2600 This
->xml_enc
= XmlEncoding_UTF16
;
2602 This
->element
= NULL
;
2603 This
->cdata
= FALSE
;
2606 This
->newline
= FALSE
;
2610 hr
= init_output_buffer(This
->xml_enc
, &This
->buffer
);
2612 SysFreeString(This
->encoding
);
2613 SysFreeString(This
->version
);
2618 init_dispex(&This
->dispex
, (IUnknown
*)&This
->IMXWriter_iface
, &mxwriter_dispex
);
2620 *ppObj
= &This
->IMXWriter_iface
;
2622 TRACE("returning iface %p\n", *ppObj
);
2627 static HRESULT WINAPI
MXAttributes_QueryInterface(IMXAttributes
*iface
, REFIID riid
, void **ppObj
)
2629 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2631 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid( riid
), ppObj
);
2635 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
2636 IsEqualGUID( riid
, &IID_IDispatch
) ||
2637 IsEqualGUID( riid
, &IID_IMXAttributes
))
2641 else if ( IsEqualGUID( riid
, &IID_ISAXAttributes
))
2643 *ppObj
= &This
->ISAXAttributes_iface
;
2645 else if ( IsEqualGUID( riid
, &IID_IVBSAXAttributes
))
2647 *ppObj
= &This
->IVBSAXAttributes_iface
;
2649 else if (dispex_query_interface(&This
->dispex
, riid
, ppObj
))
2651 return *ppObj
? S_OK
: E_NOINTERFACE
;
2655 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
2656 return E_NOINTERFACE
;
2659 IMXAttributes_AddRef( iface
);
2664 static ULONG WINAPI
MXAttributes_AddRef(IMXAttributes
*iface
)
2666 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2667 ULONG ref
= InterlockedIncrement( &This
->ref
);
2668 TRACE("(%p)->(%d)\n", This
, ref
);
2672 static ULONG WINAPI
MXAttributes_Release(IMXAttributes
*iface
)
2674 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2675 LONG ref
= InterlockedDecrement( &This
->ref
);
2677 TRACE("(%p)->(%d)\n", This
, ref
);
2683 for (i
= 0; i
< This
->length
; i
++)
2685 SysFreeString(This
->attr
[i
].qname
);
2686 SysFreeString(This
->attr
[i
].local
);
2687 SysFreeString(This
->attr
[i
].uri
);
2688 SysFreeString(This
->attr
[i
].type
);
2689 SysFreeString(This
->attr
[i
].value
);
2692 heap_free(This
->attr
);
2699 static HRESULT WINAPI
MXAttributes_GetTypeInfoCount(IMXAttributes
*iface
, UINT
* pctinfo
)
2701 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2702 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2705 static HRESULT WINAPI
MXAttributes_GetTypeInfo(IMXAttributes
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2707 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2708 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2711 static HRESULT WINAPI
MXAttributes_GetIDsOfNames(
2712 IMXAttributes
*iface
,
2714 LPOLESTR
* rgszNames
,
2719 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2720 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
,
2721 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
2724 static HRESULT WINAPI
MXAttributes_Invoke(
2725 IMXAttributes
*iface
,
2726 DISPID dispIdMember
,
2730 DISPPARAMS
* pDispParams
,
2731 VARIANT
* pVarResult
,
2732 EXCEPINFO
* pExcepInfo
,
2735 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2736 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
,
2737 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2740 static HRESULT WINAPI
MXAttributes_addAttribute(IMXAttributes
*iface
,
2741 BSTR uri
, BSTR localName
, BSTR QName
, BSTR type
, BSTR value
)
2743 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2747 TRACE("(%p)->(%s %s %s %s %s)\n", This
, debugstr_w(uri
), debugstr_w(localName
),
2748 debugstr_w(QName
), debugstr_w(type
), debugstr_w(value
));
2750 if ((!uri
|| !localName
|| !QName
|| !type
|| !value
) && This
->class_version
!= MSXML6
)
2751 return E_INVALIDARG
;
2753 /* ensure array is large enough */
2754 hr
= mxattributes_grow(This
);
2755 if (hr
!= S_OK
) return hr
;
2757 attr
= &This
->attr
[This
->length
];
2759 attr
->qname
= SysAllocString(QName
);
2760 attr
->local
= SysAllocString(localName
);
2761 attr
->uri
= SysAllocString(uri
);
2762 attr
->type
= SysAllocString(type
? type
: emptyW
);
2763 attr
->value
= SysAllocString(value
);
2769 static HRESULT WINAPI
MXAttributes_addAttributeFromIndex(IMXAttributes
*iface
,
2770 VARIANT atts
, int index
)
2772 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2773 FIXME("(%p)->(%s %d): stub\n", This
, debugstr_variant(&atts
), index
);
2777 static HRESULT WINAPI
MXAttributes_clear(IMXAttributes
*iface
)
2779 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2782 TRACE("(%p)\n", This
);
2784 for (i
= 0; i
< This
->length
; i
++)
2786 SysFreeString(This
->attr
[i
].qname
);
2787 SysFreeString(This
->attr
[i
].local
);
2788 SysFreeString(This
->attr
[i
].uri
);
2789 SysFreeString(This
->attr
[i
].type
);
2790 SysFreeString(This
->attr
[i
].value
);
2791 memset(&This
->attr
[i
], 0, sizeof(mxattribute
));
2799 static mxattribute
*get_attribute_byindex(mxattributes
*attrs
, int index
)
2801 if (index
< 0 || index
>= attrs
->length
) return NULL
;
2802 return &attrs
->attr
[index
];
2805 static HRESULT WINAPI
MXAttributes_removeAttribute(IMXAttributes
*iface
, int index
)
2807 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2810 TRACE("(%p)->(%d)\n", This
, index
);
2812 if (!(dst
= get_attribute_byindex(This
, index
))) return E_INVALIDARG
;
2814 /* no need to remove last attribute, just make it inaccessible */
2815 if (index
+ 1 == This
->length
)
2821 memmove(dst
, dst
+ 1, (This
->length
-index
-1)*sizeof(*dst
));
2827 static HRESULT WINAPI
MXAttributes_setAttribute(IMXAttributes
*iface
, int index
,
2828 BSTR uri
, BSTR localName
, BSTR QName
, BSTR type
, BSTR value
)
2830 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2831 FIXME("(%p)->(%d %s %s %s %s %s): stub\n", This
, index
, debugstr_w(uri
),
2832 debugstr_w(localName
), debugstr_w(QName
), debugstr_w(type
), debugstr_w(value
));
2836 static HRESULT WINAPI
MXAttributes_setAttributes(IMXAttributes
*iface
, VARIANT atts
)
2838 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2839 FIXME("(%p)->(%s): stub\n", This
, debugstr_variant(&atts
));
2843 static HRESULT WINAPI
MXAttributes_setLocalName(IMXAttributes
*iface
, int index
,
2846 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2849 TRACE("(%p)->(%d %s)\n", This
, index
, debugstr_w(localName
));
2851 if (!(attr
= get_attribute_byindex(This
, index
))) return E_INVALIDARG
;
2853 SysFreeString(attr
->local
);
2854 attr
->local
= SysAllocString(localName
);
2859 static HRESULT WINAPI
MXAttributes_setQName(IMXAttributes
*iface
, int index
, BSTR QName
)
2861 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2864 TRACE("(%p)->(%d %s)\n", This
, index
, debugstr_w(QName
));
2866 if (!(attr
= get_attribute_byindex(This
, index
))) return E_INVALIDARG
;
2868 SysFreeString(attr
->qname
);
2869 attr
->qname
= SysAllocString(QName
);
2874 static HRESULT WINAPI
MXAttributes_setURI(IMXAttributes
*iface
, int index
, BSTR uri
)
2876 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2879 TRACE("(%p)->(%d %s)\n", This
, index
, debugstr_w(uri
));
2881 if (!(attr
= get_attribute_byindex(This
, index
))) return E_INVALIDARG
;
2883 SysFreeString(attr
->uri
);
2884 attr
->uri
= SysAllocString(uri
);
2889 static HRESULT WINAPI
MXAttributes_setValue(IMXAttributes
*iface
, int index
, BSTR value
)
2891 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2894 TRACE("(%p)->(%d %s)\n", This
, index
, debugstr_w(value
));
2896 if (!(attr
= get_attribute_byindex(This
, index
))) return E_INVALIDARG
;
2898 SysFreeString(attr
->value
);
2899 attr
->value
= SysAllocString(value
);
2904 static const IMXAttributesVtbl MXAttributesVtbl
= {
2905 MXAttributes_QueryInterface
,
2906 MXAttributes_AddRef
,
2907 MXAttributes_Release
,
2908 MXAttributes_GetTypeInfoCount
,
2909 MXAttributes_GetTypeInfo
,
2910 MXAttributes_GetIDsOfNames
,
2911 MXAttributes_Invoke
,
2912 MXAttributes_addAttribute
,
2913 MXAttributes_addAttributeFromIndex
,
2915 MXAttributes_removeAttribute
,
2916 MXAttributes_setAttribute
,
2917 MXAttributes_setAttributes
,
2918 MXAttributes_setLocalName
,
2919 MXAttributes_setQName
,
2920 MXAttributes_setURI
,
2921 MXAttributes_setValue
2924 static HRESULT WINAPI
SAXAttributes_QueryInterface(ISAXAttributes
*iface
, REFIID riid
, void **ppObj
)
2926 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2927 return IMXAttributes_QueryInterface(&This
->IMXAttributes_iface
, riid
, ppObj
);
2930 static ULONG WINAPI
SAXAttributes_AddRef(ISAXAttributes
*iface
)
2932 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2933 return IMXAttributes_AddRef(&This
->IMXAttributes_iface
);
2936 static ULONG WINAPI
SAXAttributes_Release(ISAXAttributes
*iface
)
2938 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2939 return IMXAttributes_Release(&This
->IMXAttributes_iface
);
2942 static HRESULT WINAPI
SAXAttributes_getLength(ISAXAttributes
*iface
, int *length
)
2944 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2945 TRACE("(%p)->(%p)\n", This
, length
);
2947 if (!length
&& (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
))
2950 *length
= This
->length
;
2955 static HRESULT WINAPI
SAXAttributes_getURI(ISAXAttributes
*iface
, int index
, const WCHAR
**uri
,
2958 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2960 TRACE("(%p)->(%d %p %p)\n", This
, index
, uri
, len
);
2962 if (index
>= This
->length
|| index
< 0) return E_INVALIDARG
;
2963 if (!uri
|| !len
) return E_POINTER
;
2965 *len
= SysStringLen(This
->attr
[index
].uri
);
2966 *uri
= This
->attr
[index
].uri
;
2971 static HRESULT WINAPI
SAXAttributes_getLocalName(ISAXAttributes
*iface
, int index
, const WCHAR
**name
,
2974 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2976 TRACE("(%p)->(%d %p %p)\n", This
, index
, name
, len
);
2978 if (index
>= This
->length
|| index
< 0) return E_INVALIDARG
;
2979 if (!name
|| !len
) return E_POINTER
;
2981 *len
= SysStringLen(This
->attr
[index
].local
);
2982 *name
= This
->attr
[index
].local
;
2987 static HRESULT WINAPI
SAXAttributes_getQName(ISAXAttributes
*iface
, int index
, const WCHAR
**qname
, int *length
)
2989 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2991 TRACE("(%p)->(%d %p %p)\n", This
, index
, qname
, length
);
2993 if (index
>= This
->length
) return E_INVALIDARG
;
2994 if (!qname
|| !length
) return E_POINTER
;
2996 *qname
= This
->attr
[index
].qname
;
2997 *length
= SysStringLen(This
->attr
[index
].qname
);
3002 static HRESULT WINAPI
SAXAttributes_getName(ISAXAttributes
*iface
, int index
, const WCHAR
**uri
, int *uri_len
,
3003 const WCHAR
**local
, int *local_len
, const WCHAR
**qname
, int *qname_len
)
3005 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3007 TRACE("(%p)->(%d %p %p %p %p %p %p)\n", This
, index
, uri
, uri_len
, local
, local_len
, qname
, qname_len
);
3009 if (index
>= This
->length
|| index
< 0)
3010 return E_INVALIDARG
;
3012 if (!uri
|| !uri_len
|| !local
|| !local_len
|| !qname
|| !qname_len
)
3015 *uri_len
= SysStringLen(This
->attr
[index
].uri
);
3016 *uri
= This
->attr
[index
].uri
;
3018 *local_len
= SysStringLen(This
->attr
[index
].local
);
3019 *local
= This
->attr
[index
].local
;
3021 *qname_len
= SysStringLen(This
->attr
[index
].qname
);
3022 *qname
= This
->attr
[index
].qname
;
3024 TRACE("(%s, %s, %s)\n", debugstr_w(*uri
), debugstr_w(*local
), debugstr_w(*qname
));
3029 static HRESULT WINAPI
SAXAttributes_getIndexFromName(ISAXAttributes
*iface
, const WCHAR
*uri
, int uri_len
,
3030 const WCHAR
*name
, int len
, int *index
)
3032 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3035 TRACE("(%p)->(%s:%d %s:%d %p)\n", This
, debugstr_wn(uri
, uri_len
), uri_len
,
3036 debugstr_wn(name
, len
), len
, index
);
3038 if (!index
&& (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
))
3041 if (!uri
|| !name
|| !index
) return E_INVALIDARG
;
3043 for (i
= 0; i
< This
->length
; i
++)
3045 if (uri_len
!= SysStringLen(This
->attr
[i
].uri
)) continue;
3046 if (strncmpW(uri
, This
->attr
[i
].uri
, uri_len
)) continue;
3048 if (len
!= SysStringLen(This
->attr
[i
].local
)) continue;
3049 if (strncmpW(name
, This
->attr
[i
].local
, len
)) continue;
3055 return E_INVALIDARG
;
3058 static HRESULT WINAPI
SAXAttributes_getIndexFromQName(ISAXAttributes
*iface
, const WCHAR
*qname
,
3059 int len
, int *index
)
3061 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3064 TRACE("(%p)->(%s:%d %p)\n", This
, debugstr_wn(qname
, len
), len
, index
);
3066 if (!index
&& (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
))
3069 if (!qname
|| !index
|| !len
) return E_INVALIDARG
;
3071 for (i
= 0; i
< This
->length
; i
++)
3073 if (len
!= SysStringLen(This
->attr
[i
].qname
)) continue;
3074 if (strncmpW(qname
, This
->attr
[i
].qname
, len
)) continue;
3080 return E_INVALIDARG
;
3083 static HRESULT WINAPI
SAXAttributes_getType(ISAXAttributes
*iface
, int index
, const WCHAR
**type
,
3086 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3088 TRACE("(%p)->(%d %p %p)\n", This
, index
, type
, len
);
3090 if (index
>= This
->length
) return E_INVALIDARG
;
3092 if ((!type
|| !len
) && (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
))
3095 *type
= This
->attr
[index
].type
;
3096 *len
= SysStringLen(This
->attr
[index
].type
);
3101 static HRESULT WINAPI
SAXAttributes_getTypeFromName(ISAXAttributes
*iface
, const WCHAR
* pUri
, int nUri
,
3102 const WCHAR
* pLocalName
, int nLocalName
, const WCHAR
** pType
, int * nType
)
3104 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3105 FIXME("(%p)->(%s:%d %s:%d %p %p): stub\n", This
, debugstr_wn(pUri
, nUri
), nUri
,
3106 debugstr_wn(pLocalName
, nLocalName
), nLocalName
, pType
, nType
);
3110 static HRESULT WINAPI
SAXAttributes_getTypeFromQName(ISAXAttributes
*iface
, const WCHAR
* pQName
,
3111 int nQName
, const WCHAR
** pType
, int * nType
)
3113 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3114 FIXME("(%p)->(%s:%d %p %p): stub\n", This
, debugstr_wn(pQName
, nQName
), nQName
, pType
, nType
);
3118 static HRESULT WINAPI
SAXAttributes_getValue(ISAXAttributes
*iface
, int index
, const WCHAR
**value
,
3121 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3123 TRACE("(%p)->(%d %p %p)\n", This
, index
, value
, len
);
3125 if (index
>= This
->length
) return E_INVALIDARG
;
3127 if ((!value
|| !len
) && (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
))
3130 *value
= This
->attr
[index
].value
;
3131 *len
= SysStringLen(This
->attr
[index
].value
);
3136 static HRESULT WINAPI
SAXAttributes_getValueFromName(ISAXAttributes
*iface
, const WCHAR
*uri
,
3137 int uri_len
, const WCHAR
*name
, int name_len
, const WCHAR
**value
, int *value_len
)
3139 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3143 TRACE("(%p)->(%s:%d %s:%d %p %p)\n", This
, debugstr_wn(uri
, uri_len
), uri_len
,
3144 debugstr_wn(name
, name_len
), name_len
, value
, value_len
);
3146 if (!uri
|| !name
|| !value
|| !value_len
)
3147 return (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
) ? E_POINTER
: E_INVALIDARG
;
3149 hr
= ISAXAttributes_getIndexFromName(iface
, uri
, uri_len
, name
, name_len
, &index
);
3151 hr
= ISAXAttributes_getValue(iface
, index
, value
, value_len
);
3156 static HRESULT WINAPI
SAXAttributes_getValueFromQName(ISAXAttributes
*iface
, const WCHAR
*qname
,
3157 int qname_len
, const WCHAR
**value
, int *value_len
)
3159 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3163 TRACE("(%p)->(%s:%d %p %p)\n", This
, debugstr_wn(qname
, qname_len
), qname_len
, value
, value_len
);
3165 if (!qname
|| !value
|| !value_len
)
3166 return (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
) ? E_POINTER
: E_INVALIDARG
;
3168 hr
= ISAXAttributes_getIndexFromQName(iface
, qname
, qname_len
, &index
);
3170 hr
= ISAXAttributes_getValue(iface
, index
, value
, value_len
);
3175 static const ISAXAttributesVtbl SAXAttributesVtbl
= {
3176 SAXAttributes_QueryInterface
,
3177 SAXAttributes_AddRef
,
3178 SAXAttributes_Release
,
3179 SAXAttributes_getLength
,
3180 SAXAttributes_getURI
,
3181 SAXAttributes_getLocalName
,
3182 SAXAttributes_getQName
,
3183 SAXAttributes_getName
,
3184 SAXAttributes_getIndexFromName
,
3185 SAXAttributes_getIndexFromQName
,
3186 SAXAttributes_getType
,
3187 SAXAttributes_getTypeFromName
,
3188 SAXAttributes_getTypeFromQName
,
3189 SAXAttributes_getValue
,
3190 SAXAttributes_getValueFromName
,
3191 SAXAttributes_getValueFromQName
3194 static HRESULT WINAPI
VBSAXAttributes_QueryInterface(
3195 IVBSAXAttributes
* iface
,
3199 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3200 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
3201 return ISAXAttributes_QueryInterface(&This
->ISAXAttributes_iface
, riid
, ppvObject
);
3204 static ULONG WINAPI
VBSAXAttributes_AddRef(IVBSAXAttributes
* iface
)
3206 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3207 return ISAXAttributes_AddRef(&This
->ISAXAttributes_iface
);
3210 static ULONG WINAPI
VBSAXAttributes_Release(IVBSAXAttributes
* iface
)
3212 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3213 return ISAXAttributes_Release(&This
->ISAXAttributes_iface
);
3216 static HRESULT WINAPI
VBSAXAttributes_GetTypeInfoCount( IVBSAXAttributes
*iface
, UINT
* pctinfo
)
3218 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3220 TRACE("(%p)->(%p)\n", This
, pctinfo
);
3227 static HRESULT WINAPI
VBSAXAttributes_GetTypeInfo(
3228 IVBSAXAttributes
*iface
,
3229 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
3231 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3232 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
3233 return get_typeinfo(IVBSAXAttributes_tid
, ppTInfo
);
3236 static HRESULT WINAPI
VBSAXAttributes_GetIDsOfNames(
3237 IVBSAXAttributes
*iface
,
3239 LPOLESTR
* rgszNames
,
3244 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3245 ITypeInfo
*typeinfo
;
3248 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
3251 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
3252 return E_INVALIDARG
;
3254 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
3257 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
3258 ITypeInfo_Release(typeinfo
);
3264 static HRESULT WINAPI
VBSAXAttributes_Invoke(
3265 IVBSAXAttributes
*iface
,
3266 DISPID dispIdMember
,
3270 DISPPARAMS
* pDispParams
,
3271 VARIANT
* pVarResult
,
3272 EXCEPINFO
* pExcepInfo
,
3275 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3276 ITypeInfo
*typeinfo
;
3279 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
3280 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
3282 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
3285 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXAttributes_iface
, dispIdMember
, wFlags
,
3286 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
3287 ITypeInfo_Release(typeinfo
);
3293 static HRESULT WINAPI
VBSAXAttributes_get_length(IVBSAXAttributes
* iface
, int *len
)
3295 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3296 return ISAXAttributes_getLength(&This
->ISAXAttributes_iface
, len
);
3299 static HRESULT WINAPI
VBSAXAttributes_getURI(IVBSAXAttributes
* iface
, int index
, BSTR
*uri
)
3301 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3306 TRACE("(%p)->(%d %p)\n", This
, index
, uri
);
3312 hr
= ISAXAttributes_getURI(&This
->ISAXAttributes_iface
, index
, &uriW
, &len
);
3316 return return_bstrn(uriW
, len
, uri
);
3319 static HRESULT WINAPI
VBSAXAttributes_getLocalName(IVBSAXAttributes
* iface
, int index
, BSTR
*name
)
3321 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3326 TRACE("(%p)->(%d %p)\n", This
, index
, name
);
3332 hr
= ISAXAttributes_getLocalName(&This
->ISAXAttributes_iface
, index
, &nameW
, &len
);
3336 return return_bstrn(nameW
, len
, name
);
3339 static HRESULT WINAPI
VBSAXAttributes_getQName(IVBSAXAttributes
* iface
, int index
, BSTR
*qname
)
3341 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3342 const WCHAR
*qnameW
;
3346 TRACE("(%p)->(%d %p)\n", This
, index
, qname
);
3352 hr
= ISAXAttributes_getQName(&This
->ISAXAttributes_iface
, index
, &qnameW
, &len
);
3356 return return_bstrn(qnameW
, len
, qname
);
3359 static HRESULT WINAPI
VBSAXAttributes_getIndexFromName(IVBSAXAttributes
* iface
, BSTR uri
, BSTR name
, int *index
)
3361 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3362 return ISAXAttributes_getIndexFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
3363 name
, SysStringLen(name
), index
);
3366 static HRESULT WINAPI
VBSAXAttributes_getIndexFromQName(IVBSAXAttributes
* iface
, BSTR qname
, int *index
)
3368 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3369 return ISAXAttributes_getIndexFromQName(&This
->ISAXAttributes_iface
, qname
,
3370 SysStringLen(qname
), index
);
3373 static HRESULT WINAPI
VBSAXAttributes_getType(IVBSAXAttributes
* iface
, int index
, BSTR
*type
)
3375 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3380 TRACE("(%p)->(%d %p)\n", This
, index
, type
);
3386 hr
= ISAXAttributes_getType(&This
->ISAXAttributes_iface
, index
, &typeW
, &len
);
3390 return return_bstrn(typeW
, len
, type
);
3393 static HRESULT WINAPI
VBSAXAttributes_getTypeFromName(IVBSAXAttributes
* iface
, BSTR uri
,
3394 BSTR name
, BSTR
*type
)
3396 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3401 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(uri
), debugstr_w(name
), type
);
3407 hr
= ISAXAttributes_getTypeFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
3408 name
, SysStringLen(name
), &typeW
, &len
);
3412 return return_bstrn(typeW
, len
, type
);
3415 static HRESULT WINAPI
VBSAXAttributes_getTypeFromQName(IVBSAXAttributes
* iface
, BSTR qname
, BSTR
*type
)
3417 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3422 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(qname
), type
);
3428 hr
= ISAXAttributes_getTypeFromQName(&This
->ISAXAttributes_iface
, qname
, SysStringLen(qname
),
3433 return return_bstrn(typeW
, len
, type
);
3436 static HRESULT WINAPI
VBSAXAttributes_getValue(IVBSAXAttributes
* iface
, int index
, BSTR
*value
)
3438 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3439 const WCHAR
*valueW
;
3443 TRACE("(%p)->(%d %p)\n", This
, index
, value
);
3449 hr
= ISAXAttributes_getValue(&This
->ISAXAttributes_iface
, index
, &valueW
, &len
);
3453 return return_bstrn(valueW
, len
, value
);
3456 static HRESULT WINAPI
VBSAXAttributes_getValueFromName(IVBSAXAttributes
* iface
, BSTR uri
, BSTR name
,
3459 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3460 const WCHAR
*valueW
;
3464 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(uri
), debugstr_w(name
), value
);
3470 hr
= ISAXAttributes_getValueFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
3471 name
, SysStringLen(name
), &valueW
, &len
);
3475 return return_bstrn(valueW
, len
, value
);
3478 static HRESULT WINAPI
VBSAXAttributes_getValueFromQName(IVBSAXAttributes
* iface
, BSTR qname
, BSTR
*value
)
3480 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3481 const WCHAR
*valueW
;
3485 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(qname
), value
);
3491 hr
= ISAXAttributes_getValueFromQName(&This
->ISAXAttributes_iface
, qname
, SysStringLen(qname
),
3496 return return_bstrn(valueW
, len
, value
);
3499 static const struct IVBSAXAttributesVtbl VBSAXAttributesVtbl
=
3501 VBSAXAttributes_QueryInterface
,
3502 VBSAXAttributes_AddRef
,
3503 VBSAXAttributes_Release
,
3504 VBSAXAttributes_GetTypeInfoCount
,
3505 VBSAXAttributes_GetTypeInfo
,
3506 VBSAXAttributes_GetIDsOfNames
,
3507 VBSAXAttributes_Invoke
,
3508 VBSAXAttributes_get_length
,
3509 VBSAXAttributes_getURI
,
3510 VBSAXAttributes_getLocalName
,
3511 VBSAXAttributes_getQName
,
3512 VBSAXAttributes_getIndexFromName
,
3513 VBSAXAttributes_getIndexFromQName
,
3514 VBSAXAttributes_getType
,
3515 VBSAXAttributes_getTypeFromName
,
3516 VBSAXAttributes_getTypeFromQName
,
3517 VBSAXAttributes_getValue
,
3518 VBSAXAttributes_getValueFromName
,
3519 VBSAXAttributes_getValueFromQName
3522 static const tid_t mxattrs_iface_tids
[] = {
3527 static dispex_static_data_t mxattrs_dispex
= {
3534 HRESULT
SAXAttributes_create(MSXML_VERSION version
, void **ppObj
)
3536 static const int default_count
= 10;
3539 TRACE("(%p)\n", ppObj
);
3541 This
= heap_alloc( sizeof (*This
) );
3543 return E_OUTOFMEMORY
;
3545 This
->IMXAttributes_iface
.lpVtbl
= &MXAttributesVtbl
;
3546 This
->ISAXAttributes_iface
.lpVtbl
= &SAXAttributesVtbl
;
3547 This
->IVBSAXAttributes_iface
.lpVtbl
= &VBSAXAttributesVtbl
;
3550 This
->class_version
= version
;
3552 This
->attr
= heap_alloc(default_count
*sizeof(mxattribute
));
3554 This
->allocated
= default_count
;
3556 *ppObj
= &This
->IMXAttributes_iface
;
3558 init_dispex(&This
->dispex
, (IUnknown
*)&This
->IMXAttributes_iface
, &mxattrs_dispex
);
3560 TRACE("returning iface %p\n", *ppObj
);