2 * MXWriter implementation
4 * Copyright 2011-2014 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',' '};
31 /* should be ordered as encoding names are sorted */
34 XmlEncoding_ISO_8859_1
= 0,
35 XmlEncoding_ISO_8859_13
,
36 XmlEncoding_ISO_8859_15
,
37 XmlEncoding_ISO_8859_2
,
38 XmlEncoding_ISO_8859_3
,
39 XmlEncoding_ISO_8859_4
,
40 XmlEncoding_ISO_8859_5
,
41 XmlEncoding_ISO_8859_7
,
42 XmlEncoding_ISO_8859_9
,
48 struct xml_encoding_data
50 const WCHAR
*encoding
;
55 static const WCHAR iso_8859_1W
[] = {'i','s','o','-','8','8','5','9','-','1',0};
56 static const WCHAR iso_8859_2W
[] = {'i','s','o','-','8','8','5','9','-','2',0};
57 static const WCHAR iso_8859_3W
[] = {'i','s','o','-','8','8','5','9','-','3',0};
58 static const WCHAR iso_8859_4W
[] = {'i','s','o','-','8','8','5','9','-','4',0};
59 static const WCHAR iso_8859_5W
[] = {'i','s','o','-','8','8','5','9','-','5',0};
60 static const WCHAR iso_8859_7W
[] = {'i','s','o','-','8','8','5','9','-','7',0};
61 static const WCHAR iso_8859_9W
[] = {'i','s','o','-','8','8','5','9','-','9',0};
62 static const WCHAR iso_8859_13W
[] = {'i','s','o','-','8','8','5','9','-','1','3',0};
63 static const WCHAR iso_8859_15W
[] = {'i','s','o','-','8','8','5','9','-','1','5',0};
64 static const WCHAR utf16W
[] = {'U','T','F','-','1','6',0};
65 static const WCHAR utf8W
[] = {'U','T','F','-','8',0};
67 static const struct xml_encoding_data xml_encoding_map
[] = {
68 { iso_8859_1W
, XmlEncoding_ISO_8859_1
, 28591 },
69 { iso_8859_13W
, XmlEncoding_ISO_8859_13
, 28603 },
70 { iso_8859_15W
, XmlEncoding_ISO_8859_15
, 28605 },
71 { iso_8859_2W
, XmlEncoding_ISO_8859_2
, 28592 },
72 { iso_8859_3W
, XmlEncoding_ISO_8859_3
, 28593 },
73 { iso_8859_4W
, XmlEncoding_ISO_8859_4
, 28594 },
74 { iso_8859_5W
, XmlEncoding_ISO_8859_5
, 28595 },
75 { iso_8859_7W
, XmlEncoding_ISO_8859_7
, 28597 },
76 { iso_8859_9W
, XmlEncoding_ISO_8859_9
, 28599 },
77 { utf16W
, XmlEncoding_UTF16
, ~0 },
78 { utf8W
, XmlEncoding_UTF8
, CP_UTF8
}
83 OutputBuffer_Native
= 0x001,
84 OutputBuffer_Encoded
= 0x010,
85 OutputBuffer_Both
= 0x100
91 MXWriter_DisableEscaping
,
107 unsigned int allocated
;
108 unsigned int written
;
113 encoded_buffer utf16
;
114 encoded_buffer encoded
;
121 IMXWriter IMXWriter_iface
;
122 ISAXContentHandler ISAXContentHandler_iface
;
123 ISAXLexicalHandler ISAXLexicalHandler_iface
;
124 ISAXDeclHandler ISAXDeclHandler_iface
;
125 ISAXDTDHandler ISAXDTDHandler_iface
;
126 ISAXErrorHandler ISAXErrorHandler_iface
;
127 IVBSAXDeclHandler IVBSAXDeclHandler_iface
;
128 IVBSAXLexicalHandler IVBSAXLexicalHandler_iface
;
129 IVBSAXContentHandler IVBSAXContentHandler_iface
;
130 IVBSAXDTDHandler IVBSAXDTDHandler_iface
;
131 IVBSAXErrorHandler IVBSAXErrorHandler_iface
;
134 MSXML_VERSION class_version
;
136 VARIANT_BOOL props
[MXWriter_LastProp
];
140 BOOL text
; /* last node was text node, so we shouldn't indent next node */
141 BOOL newline
; /* newline was already added as a part of previous call */
142 UINT indent
; /* indentation level for next node */
146 BSTR encoding
; /* exact property value */
147 xml_encoding xml_enc
;
149 /* contains a pending (or not closed yet) element name or NULL if
150 we don't have to close */
156 output_buffer
*buffer
;
171 IMXAttributes IMXAttributes_iface
;
172 ISAXAttributes ISAXAttributes_iface
;
173 IVBSAXAttributes IVBSAXAttributes_iface
;
176 MSXML_VERSION class_version
;
183 static inline mxattributes
*impl_from_IMXAttributes( IMXAttributes
*iface
)
185 return CONTAINING_RECORD(iface
, mxattributes
, IMXAttributes_iface
);
188 static inline mxattributes
*impl_from_ISAXAttributes( ISAXAttributes
*iface
)
190 return CONTAINING_RECORD(iface
, mxattributes
, ISAXAttributes_iface
);
193 static inline mxattributes
*impl_from_IVBSAXAttributes( IVBSAXAttributes
*iface
)
195 return CONTAINING_RECORD(iface
, mxattributes
, IVBSAXAttributes_iface
);
198 static HRESULT
mxattributes_grow(mxattributes
*This
)
200 if (This
->length
< This
->allocated
) return S_OK
;
202 This
->allocated
*= 2;
203 This
->attr
= heap_realloc(This
->attr
, This
->allocated
*sizeof(mxattribute
));
205 return This
->attr
? S_OK
: E_OUTOFMEMORY
;
208 static xml_encoding
parse_encoding_name(const WCHAR
*encoding
)
213 max
= sizeof(xml_encoding_map
)/sizeof(struct xml_encoding_data
) - 1;
219 c
= strcmpiW(xml_encoding_map
[n
].encoding
, encoding
);
221 return xml_encoding_map
[n
].enc
;
229 return XmlEncoding_Unknown
;
232 static HRESULT
init_encoded_buffer(encoded_buffer
*buffer
)
234 const int initial_len
= 0x2000;
235 buffer
->data
= heap_alloc(initial_len
);
236 if (!buffer
->data
) return E_OUTOFMEMORY
;
238 memset(buffer
->data
, 0, 4);
239 buffer
->allocated
= initial_len
;
245 static void free_encoded_buffer(encoded_buffer
*buffer
)
247 heap_free(buffer
->data
);
250 static HRESULT
get_code_page(xml_encoding encoding
, UINT
*cp
)
252 const struct xml_encoding_data
*data
;
254 if (encoding
== XmlEncoding_Unknown
)
256 FIXME("unsupported encoding %d\n", encoding
);
260 data
= &xml_encoding_map
[encoding
];
266 static HRESULT
alloc_output_buffer(xml_encoding encoding
, output_buffer
**buffer
)
271 ret
= heap_alloc(sizeof(*ret
));
272 if (!ret
) return E_OUTOFMEMORY
;
274 hr
= get_code_page(encoding
, &ret
->code_page
);
280 hr
= init_encoded_buffer(&ret
->utf16
);
286 /* currently we always create a default output buffer that is UTF-16 only,
287 but it's possible to allocate with specific encoding too */
288 if (encoding
!= XmlEncoding_UTF16
) {
289 hr
= init_encoded_buffer(&ret
->encoded
);
291 free_encoded_buffer(&ret
->utf16
);
297 memset(&ret
->encoded
, 0, sizeof(ret
->encoded
));
304 static void free_output_buffer(output_buffer
*buffer
)
306 free_encoded_buffer(&buffer
->encoded
);
307 free_encoded_buffer(&buffer
->utf16
);
311 static void grow_buffer(encoded_buffer
*buffer
, int length
)
313 /* grow if needed, plus 4 bytes to be sure null terminator will fit in */
314 if (buffer
->allocated
< buffer
->written
+ length
+ 4)
316 int grown_size
= max(2*buffer
->allocated
, buffer
->allocated
+ length
);
317 buffer
->data
= heap_realloc(buffer
->data
, grown_size
);
318 buffer
->allocated
= grown_size
;
322 static HRESULT
write_output_buffer_mode(output_buffer
*buffer
, output_mode mode
, const WCHAR
*data
, int len
)
327 if (mode
& (OutputBuffer_Encoded
| OutputBuffer_Both
)) {
328 if (buffer
->code_page
!= ~0)
330 length
= WideCharToMultiByte(buffer
->code_page
, 0, data
, len
, NULL
, 0, NULL
, NULL
);
331 grow_buffer(&buffer
->encoded
, length
);
332 ptr
= buffer
->encoded
.data
+ buffer
->encoded
.written
;
333 length
= WideCharToMultiByte(buffer
->code_page
, 0, data
, len
, ptr
, length
, NULL
, NULL
);
334 buffer
->encoded
.written
+= len
== -1 ? length
-1 : length
;
338 if (mode
& (OutputBuffer_Native
| OutputBuffer_Both
)) {
339 /* WCHAR data just copied */
340 length
= len
== -1 ? strlenW(data
) : len
;
343 length
*= sizeof(WCHAR
);
345 grow_buffer(&buffer
->utf16
, length
);
346 ptr
= buffer
->utf16
.data
+ buffer
->utf16
.written
;
348 memcpy(ptr
, data
, length
);
349 buffer
->utf16
.written
+= length
;
351 /* null termination */
352 memset(ptr
, 0, sizeof(WCHAR
));
359 static HRESULT
write_output_buffer(output_buffer
*buffer
, const WCHAR
*data
, int len
)
361 return write_output_buffer_mode(buffer
, OutputBuffer_Both
, data
, len
);
364 static HRESULT
write_output_buffer_quoted(output_buffer
*buffer
, const WCHAR
*data
, int len
)
366 write_output_buffer(buffer
, quotW
, 1);
367 write_output_buffer(buffer
, data
, len
);
368 write_output_buffer(buffer
, quotW
, 1);
373 /* frees buffer data, reallocates with a default lengths */
374 static void close_output_buffer(mxwriter
*This
)
376 heap_free(This
->buffer
->utf16
.data
);
377 heap_free(This
->buffer
->encoded
.data
);
378 init_encoded_buffer(&This
->buffer
->utf16
);
379 init_encoded_buffer(&This
->buffer
->encoded
);
380 get_code_page(This
->xml_enc
, &This
->buffer
->code_page
);
383 /* Escapes special characters like:
389 On call 'len' contains a length of 'str' in chars or -1 if it's null terminated.
390 After a call it's updated with actual new length if it wasn't -1 initially.
392 static WCHAR
*get_escaped_string(const WCHAR
*str
, escape_mode mode
, int *len
)
394 static const WCHAR ltW
[] = {'&','l','t',';'};
395 static const WCHAR ampW
[] = {'&','a','m','p',';'};
396 static const WCHAR equotW
[] = {'&','q','u','o','t',';'};
397 static const WCHAR gtW
[] = {'&','g','t',';'};
399 const int default_alloc
= 100;
400 const int grow_thresh
= 10;
401 int p
= *len
, conv_len
;
404 /* default buffer size to something if length is unknown */
405 conv_len
= *len
== -1 ? default_alloc
: max(2**len
, default_alloc
);
406 ptr
= ret
= heap_alloc(conv_len
*sizeof(WCHAR
));
410 if (ptr
- ret
> conv_len
- grow_thresh
)
412 int written
= ptr
- ret
;
414 ptr
= ret
= heap_realloc(ret
, conv_len
*sizeof(WCHAR
));
421 memcpy(ptr
, ltW
, sizeof(ltW
));
422 ptr
+= sizeof(ltW
)/sizeof(WCHAR
);
425 memcpy(ptr
, ampW
, sizeof(ampW
));
426 ptr
+= sizeof(ampW
)/sizeof(WCHAR
);
429 memcpy(ptr
, gtW
, sizeof(gtW
));
430 ptr
+= sizeof(gtW
)/sizeof(WCHAR
);
433 if (mode
== EscapeValue
)
435 memcpy(ptr
, equotW
, sizeof(equotW
));
436 ptr
+= sizeof(equotW
)/sizeof(WCHAR
);
439 /* fallthrough for text mode */
449 if (*len
!= -1) *len
= ptr
-ret
;
455 static void write_prolog_buffer(mxwriter
*This
)
457 static const WCHAR versionW
[] = {'<','?','x','m','l',' ','v','e','r','s','i','o','n','='};
458 static const WCHAR encodingW
[] = {' ','e','n','c','o','d','i','n','g','=','\"'};
459 static const WCHAR standaloneW
[] = {' ','s','t','a','n','d','a','l','o','n','e','=','\"'};
460 static const WCHAR yesW
[] = {'y','e','s','\"','?','>'};
461 static const WCHAR noW
[] = {'n','o','\"','?','>'};
464 write_output_buffer(This
->buffer
, versionW
, sizeof(versionW
)/sizeof(WCHAR
));
465 write_output_buffer_quoted(This
->buffer
, This
->version
, -1);
468 write_output_buffer(This
->buffer
, encodingW
, sizeof(encodingW
)/sizeof(WCHAR
));
470 /* always write UTF-16 to WCHAR buffer */
471 write_output_buffer_mode(This
->buffer
, OutputBuffer_Native
, utf16W
, sizeof(utf16W
)/sizeof(WCHAR
) - 1);
472 write_output_buffer_mode(This
->buffer
, OutputBuffer_Encoded
, This
->encoding
, -1);
473 write_output_buffer(This
->buffer
, quotW
, 1);
476 write_output_buffer(This
->buffer
, standaloneW
, sizeof(standaloneW
)/sizeof(WCHAR
));
477 if (This
->props
[MXWriter_Standalone
] == VARIANT_TRUE
)
478 write_output_buffer(This
->buffer
, yesW
, sizeof(yesW
)/sizeof(WCHAR
));
480 write_output_buffer(This
->buffer
, noW
, sizeof(noW
)/sizeof(WCHAR
));
482 write_output_buffer(This
->buffer
, crlfW
, sizeof(crlfW
)/sizeof(WCHAR
));
483 This
->newline
= TRUE
;
486 /* Attempts to the write data from the mxwriter's buffer to
487 * the destination stream (if there is one).
489 static HRESULT
write_data_to_stream(mxwriter
*This
)
491 encoded_buffer
*buffer
;
498 if (This
->xml_enc
!= XmlEncoding_UTF16
)
499 buffer
= &This
->buffer
->encoded
;
501 buffer
= &This
->buffer
->utf16
;
503 if (This
->dest_written
> buffer
->written
) {
504 ERR("Failed sanity check! Not sure what to do... (%d > %d)\n", This
->dest_written
, buffer
->written
);
506 } else if (This
->dest_written
== buffer
->written
&& This
->xml_enc
!= XmlEncoding_UTF8
)
507 /* Windows seems to make an empty write call when the encoding is UTF-8 and
508 * all the data has been written to the stream. It doesn't seem make this call
509 * for any other encodings.
513 /* Write the current content from the output buffer into 'dest'.
514 * TODO: Check what Windows does if the IStream doesn't write all of
515 * the data we give it at once.
517 hr
= IStream_Write(This
->dest
, buffer
->data
+This
->dest_written
,
518 buffer
->written
-This
->dest_written
, &written
);
520 WARN("Failed to write data to IStream (0x%08x)\n", hr
);
524 This
->dest_written
+= written
;
528 /* Newly added element start tag left unclosed cause for empty elements
529 we have to close it differently. */
530 static void close_element_starttag(const mxwriter
*This
)
532 static const WCHAR gtW
[] = {'>'};
533 if (!This
->element
) return;
534 write_output_buffer(This
->buffer
, gtW
, 1);
537 static void write_node_indent(mxwriter
*This
)
539 static const WCHAR tabW
[] = {'\t'};
540 int indent
= This
->indent
;
542 if (!This
->props
[MXWriter_Indent
] || This
->text
)
548 /* This is to workaround PI output logic that always puts newline chars,
549 document prolog PI does that too. */
551 write_output_buffer(This
->buffer
, crlfW
, sizeof(crlfW
)/sizeof(WCHAR
));
553 write_output_buffer(This
->buffer
, tabW
, 1);
555 This
->newline
= FALSE
;
559 static inline void writer_inc_indent(mxwriter
*This
)
564 static inline void writer_dec_indent(mxwriter
*This
)
566 if (This
->indent
) This
->indent
--;
567 /* depth is decreased only when element is closed, meaning it's not a text node
572 static void set_element_name(mxwriter
*This
, const WCHAR
*name
, int len
)
574 SysFreeString(This
->element
);
576 This
->element
= len
!= -1 ? SysAllocStringLen(name
, len
) : SysAllocString(name
);
578 This
->element
= NULL
;
581 static inline HRESULT
flush_output_buffer(mxwriter
*This
)
583 close_element_starttag(This
);
584 set_element_name(This
, NULL
, 0);
586 return write_data_to_stream(This
);
589 /* Resets the mxwriter's output buffer by closing it, then creating a new
590 * output buffer using the given encoding.
592 static inline void reset_output_buffer(mxwriter
*This
)
594 close_output_buffer(This
);
595 This
->dest_written
= 0;
598 static HRESULT
writer_set_property(mxwriter
*writer
, mxwriter_prop property
, VARIANT_BOOL value
)
600 writer
->props
[property
] = value
;
601 writer
->prop_changed
= TRUE
;
605 static HRESULT
writer_get_property(const mxwriter
*writer
, mxwriter_prop property
, VARIANT_BOOL
*value
)
607 if (!value
) return E_POINTER
;
608 *value
= writer
->props
[property
];
612 static inline mxwriter
*impl_from_IMXWriter(IMXWriter
*iface
)
614 return CONTAINING_RECORD(iface
, mxwriter
, IMXWriter_iface
);
617 static inline mxwriter
*impl_from_ISAXContentHandler(ISAXContentHandler
*iface
)
619 return CONTAINING_RECORD(iface
, mxwriter
, ISAXContentHandler_iface
);
622 static inline mxwriter
*impl_from_IVBSAXContentHandler(IVBSAXContentHandler
*iface
)
624 return CONTAINING_RECORD(iface
, mxwriter
, IVBSAXContentHandler_iface
);
627 static inline mxwriter
*impl_from_ISAXLexicalHandler(ISAXLexicalHandler
*iface
)
629 return CONTAINING_RECORD(iface
, mxwriter
, ISAXLexicalHandler_iface
);
632 static inline mxwriter
*impl_from_IVBSAXLexicalHandler(IVBSAXLexicalHandler
*iface
)
634 return CONTAINING_RECORD(iface
, mxwriter
, IVBSAXLexicalHandler_iface
);
637 static inline mxwriter
*impl_from_ISAXDeclHandler(ISAXDeclHandler
*iface
)
639 return CONTAINING_RECORD(iface
, mxwriter
, ISAXDeclHandler_iface
);
642 static inline mxwriter
*impl_from_IVBSAXDeclHandler(IVBSAXDeclHandler
*iface
)
644 return CONTAINING_RECORD(iface
, mxwriter
, IVBSAXDeclHandler_iface
);
647 static inline mxwriter
*impl_from_ISAXDTDHandler(ISAXDTDHandler
*iface
)
649 return CONTAINING_RECORD(iface
, mxwriter
, ISAXDTDHandler_iface
);
652 static inline mxwriter
*impl_from_IVBSAXDTDHandler(IVBSAXDTDHandler
*iface
)
654 return CONTAINING_RECORD(iface
, mxwriter
, IVBSAXDTDHandler_iface
);
657 static inline mxwriter
*impl_from_ISAXErrorHandler(ISAXErrorHandler
*iface
)
659 return CONTAINING_RECORD(iface
, mxwriter
, ISAXErrorHandler_iface
);
662 static inline mxwriter
*impl_from_IVBSAXErrorHandler(IVBSAXErrorHandler
*iface
)
664 return CONTAINING_RECORD(iface
, mxwriter
, IVBSAXErrorHandler_iface
);
667 static HRESULT WINAPI
mxwriter_QueryInterface(IMXWriter
*iface
, REFIID riid
, void **obj
)
669 mxwriter
*This
= impl_from_IMXWriter( iface
);
671 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
675 if ( IsEqualGUID( riid
, &IID_IMXWriter
) ||
676 IsEqualGUID( riid
, &IID_IDispatch
) ||
677 IsEqualGUID( riid
, &IID_IUnknown
) )
679 *obj
= &This
->IMXWriter_iface
;
681 else if ( IsEqualGUID( riid
, &IID_ISAXContentHandler
) )
683 *obj
= &This
->ISAXContentHandler_iface
;
685 else if ( IsEqualGUID( riid
, &IID_ISAXLexicalHandler
) )
687 *obj
= &This
->ISAXLexicalHandler_iface
;
689 else if ( IsEqualGUID( riid
, &IID_ISAXDeclHandler
) )
691 *obj
= &This
->ISAXDeclHandler_iface
;
693 else if ( IsEqualGUID( riid
, &IID_ISAXDTDHandler
) )
695 *obj
= &This
->ISAXDTDHandler_iface
;
697 else if ( IsEqualGUID( riid
, &IID_ISAXErrorHandler
) )
699 *obj
= &This
->ISAXErrorHandler_iface
;
701 else if ( IsEqualGUID( riid
, &IID_IVBSAXDeclHandler
) )
703 *obj
= &This
->IVBSAXDeclHandler_iface
;
705 else if ( IsEqualGUID( riid
, &IID_IVBSAXLexicalHandler
) )
707 *obj
= &This
->IVBSAXLexicalHandler_iface
;
709 else if ( IsEqualGUID( riid
, &IID_IVBSAXContentHandler
) )
711 *obj
= &This
->IVBSAXContentHandler_iface
;
713 else if ( IsEqualGUID( riid
, &IID_IVBSAXDTDHandler
) )
715 *obj
= &This
->IVBSAXDTDHandler_iface
;
717 else if ( IsEqualGUID( riid
, &IID_IVBSAXErrorHandler
) )
719 *obj
= &This
->IVBSAXErrorHandler_iface
;
721 else if (dispex_query_interface(&This
->dispex
, riid
, obj
))
723 return *obj
? S_OK
: E_NOINTERFACE
;
727 ERR("interface %s not implemented\n", debugstr_guid(riid
));
729 return E_NOINTERFACE
;
732 IMXWriter_AddRef(iface
);
736 static ULONG WINAPI
mxwriter_AddRef(IMXWriter
*iface
)
738 mxwriter
*This
= impl_from_IMXWriter( iface
);
739 LONG ref
= InterlockedIncrement(&This
->ref
);
741 TRACE("(%p)->(%d)\n", This
, ref
);
746 static ULONG WINAPI
mxwriter_Release(IMXWriter
*iface
)
748 mxwriter
*This
= impl_from_IMXWriter( iface
);
749 ULONG ref
= InterlockedDecrement(&This
->ref
);
751 TRACE("(%p)->(%d)\n", This
, ref
);
755 /* Windows flushes the buffer when the interface is destroyed. */
756 flush_output_buffer(This
);
757 free_output_buffer(This
->buffer
);
759 if (This
->dest
) IStream_Release(This
->dest
);
760 SysFreeString(This
->version
);
761 SysFreeString(This
->encoding
);
763 SysFreeString(This
->element
);
770 static HRESULT WINAPI
mxwriter_GetTypeInfoCount(IMXWriter
*iface
, UINT
* pctinfo
)
772 mxwriter
*This
= impl_from_IMXWriter( iface
);
773 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
776 static HRESULT WINAPI
mxwriter_GetTypeInfo(
778 UINT iTInfo
, LCID lcid
,
779 ITypeInfo
** ppTInfo
)
781 mxwriter
*This
= impl_from_IMXWriter( iface
);
782 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
,
783 iTInfo
, lcid
, ppTInfo
);
786 static HRESULT WINAPI
mxwriter_GetIDsOfNames(
788 REFIID riid
, LPOLESTR
* rgszNames
,
789 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
791 mxwriter
*This
= impl_from_IMXWriter( iface
);
792 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
,
793 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
796 static HRESULT WINAPI
mxwriter_Invoke(
798 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
799 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
800 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
802 mxwriter
*This
= impl_from_IMXWriter( iface
);
803 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
,
804 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
807 static HRESULT WINAPI
mxwriter_put_output(IMXWriter
*iface
, VARIANT dest
)
809 mxwriter
*This
= impl_from_IMXWriter( iface
);
812 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&dest
));
814 hr
= flush_output_buffer(This
);
822 if (This
->dest
) IStream_Release(This
->dest
);
824 reset_output_buffer(This
);
831 hr
= IUnknown_QueryInterface(V_UNKNOWN(&dest
), &IID_IStream
, (void**)&stream
);
834 /* Recreate the output buffer to make sure it's using the correct encoding. */
835 reset_output_buffer(This
);
837 if (This
->dest
) IStream_Release(This
->dest
);
842 FIXME("unhandled interface type for VT_UNKNOWN destination\n");
846 FIXME("unhandled destination type %s\n", debugstr_variant(&dest
));
853 static HRESULT WINAPI
mxwriter_get_output(IMXWriter
*iface
, VARIANT
*dest
)
855 mxwriter
*This
= impl_from_IMXWriter( iface
);
857 TRACE("(%p)->(%p)\n", This
, dest
);
859 if (!dest
) return E_POINTER
;
863 HRESULT hr
= flush_output_buffer(This
);
867 V_VT(dest
) = VT_BSTR
;
868 V_BSTR(dest
) = SysAllocString((WCHAR
*)This
->buffer
->utf16
.data
);
873 /* we only support IStream output so far */
874 V_VT(dest
) = VT_UNKNOWN
;
875 V_UNKNOWN(dest
) = (IUnknown
*)This
->dest
;
876 IStream_AddRef(This
->dest
);
881 static HRESULT WINAPI
mxwriter_put_encoding(IMXWriter
*iface
, BSTR encoding
)
883 mxwriter
*This
= impl_from_IMXWriter( iface
);
887 TRACE("(%p)->(%s)\n", This
, debugstr_w(encoding
));
889 enc
= parse_encoding_name(encoding
);
890 if (enc
== XmlEncoding_Unknown
)
892 FIXME("unsupported encoding %s\n", debugstr_w(encoding
));
896 hr
= flush_output_buffer(This
);
900 SysReAllocString(&This
->encoding
, encoding
);
903 TRACE("got encoding %d\n", This
->xml_enc
);
904 reset_output_buffer(This
);
908 static HRESULT WINAPI
mxwriter_get_encoding(IMXWriter
*iface
, BSTR
*encoding
)
910 mxwriter
*This
= impl_from_IMXWriter( iface
);
912 TRACE("(%p)->(%p)\n", This
, encoding
);
914 if (!encoding
) return E_POINTER
;
916 *encoding
= SysAllocString(This
->encoding
);
917 if (!*encoding
) return E_OUTOFMEMORY
;
922 static HRESULT WINAPI
mxwriter_put_byteOrderMark(IMXWriter
*iface
, VARIANT_BOOL value
)
924 mxwriter
*This
= impl_from_IMXWriter( iface
);
926 TRACE("(%p)->(%d)\n", This
, value
);
927 return writer_set_property(This
, MXWriter_BOM
, value
);
930 static HRESULT WINAPI
mxwriter_get_byteOrderMark(IMXWriter
*iface
, VARIANT_BOOL
*value
)
932 mxwriter
*This
= impl_from_IMXWriter( iface
);
934 TRACE("(%p)->(%p)\n", This
, value
);
935 return writer_get_property(This
, MXWriter_BOM
, value
);
938 static HRESULT WINAPI
mxwriter_put_indent(IMXWriter
*iface
, VARIANT_BOOL value
)
940 mxwriter
*This
= impl_from_IMXWriter( iface
);
942 TRACE("(%p)->(%d)\n", This
, value
);
943 return writer_set_property(This
, MXWriter_Indent
, value
);
946 static HRESULT WINAPI
mxwriter_get_indent(IMXWriter
*iface
, VARIANT_BOOL
*value
)
948 mxwriter
*This
= impl_from_IMXWriter( iface
);
950 TRACE("(%p)->(%p)\n", This
, value
);
951 return writer_get_property(This
, MXWriter_Indent
, value
);
954 static HRESULT WINAPI
mxwriter_put_standalone(IMXWriter
*iface
, VARIANT_BOOL value
)
956 mxwriter
*This
= impl_from_IMXWriter( iface
);
958 TRACE("(%p)->(%d)\n", This
, value
);
959 return writer_set_property(This
, MXWriter_Standalone
, value
);
962 static HRESULT WINAPI
mxwriter_get_standalone(IMXWriter
*iface
, VARIANT_BOOL
*value
)
964 mxwriter
*This
= impl_from_IMXWriter( iface
);
966 TRACE("(%p)->(%p)\n", This
, value
);
967 return writer_get_property(This
, MXWriter_Standalone
, value
);
970 static HRESULT WINAPI
mxwriter_put_omitXMLDeclaration(IMXWriter
*iface
, VARIANT_BOOL value
)
972 mxwriter
*This
= impl_from_IMXWriter( iface
);
974 TRACE("(%p)->(%d)\n", This
, value
);
975 return writer_set_property(This
, MXWriter_OmitXmlDecl
, value
);
978 static HRESULT WINAPI
mxwriter_get_omitXMLDeclaration(IMXWriter
*iface
, VARIANT_BOOL
*value
)
980 mxwriter
*This
= impl_from_IMXWriter( iface
);
982 TRACE("(%p)->(%p)\n", This
, value
);
983 return writer_get_property(This
, MXWriter_OmitXmlDecl
, value
);
986 static HRESULT WINAPI
mxwriter_put_version(IMXWriter
*iface
, BSTR version
)
988 mxwriter
*This
= impl_from_IMXWriter( iface
);
990 TRACE("(%p)->(%s)\n", This
, debugstr_w(version
));
992 if (!version
) return E_INVALIDARG
;
994 SysFreeString(This
->version
);
995 This
->version
= SysAllocString(version
);
1000 static HRESULT WINAPI
mxwriter_get_version(IMXWriter
*iface
, BSTR
*version
)
1002 mxwriter
*This
= impl_from_IMXWriter( iface
);
1004 TRACE("(%p)->(%p)\n", This
, version
);
1006 if (!version
) return E_POINTER
;
1008 return return_bstr(This
->version
, version
);
1011 static HRESULT WINAPI
mxwriter_put_disableOutputEscaping(IMXWriter
*iface
, VARIANT_BOOL value
)
1013 mxwriter
*This
= impl_from_IMXWriter( iface
);
1015 TRACE("(%p)->(%d)\n", This
, value
);
1016 return writer_set_property(This
, MXWriter_DisableEscaping
, value
);
1019 static HRESULT WINAPI
mxwriter_get_disableOutputEscaping(IMXWriter
*iface
, VARIANT_BOOL
*value
)
1021 mxwriter
*This
= impl_from_IMXWriter( iface
);
1023 TRACE("(%p)->(%p)\n", This
, value
);
1024 return writer_get_property(This
, MXWriter_DisableEscaping
, value
);
1027 static HRESULT WINAPI
mxwriter_flush(IMXWriter
*iface
)
1029 mxwriter
*This
= impl_from_IMXWriter( iface
);
1030 TRACE("(%p)\n", This
);
1031 return flush_output_buffer(This
);
1034 static const struct IMXWriterVtbl MXWriterVtbl
=
1036 mxwriter_QueryInterface
,
1039 mxwriter_GetTypeInfoCount
,
1040 mxwriter_GetTypeInfo
,
1041 mxwriter_GetIDsOfNames
,
1043 mxwriter_put_output
,
1044 mxwriter_get_output
,
1045 mxwriter_put_encoding
,
1046 mxwriter_get_encoding
,
1047 mxwriter_put_byteOrderMark
,
1048 mxwriter_get_byteOrderMark
,
1049 mxwriter_put_indent
,
1050 mxwriter_get_indent
,
1051 mxwriter_put_standalone
,
1052 mxwriter_get_standalone
,
1053 mxwriter_put_omitXMLDeclaration
,
1054 mxwriter_get_omitXMLDeclaration
,
1055 mxwriter_put_version
,
1056 mxwriter_get_version
,
1057 mxwriter_put_disableOutputEscaping
,
1058 mxwriter_get_disableOutputEscaping
,
1062 /*** ISAXContentHandler ***/
1063 static HRESULT WINAPI
SAXContentHandler_QueryInterface(
1064 ISAXContentHandler
*iface
,
1068 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1069 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
1072 static ULONG WINAPI
SAXContentHandler_AddRef(ISAXContentHandler
*iface
)
1074 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1075 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
1078 static ULONG WINAPI
SAXContentHandler_Release(ISAXContentHandler
*iface
)
1080 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1081 return IMXWriter_Release(&This
->IMXWriter_iface
);
1084 static HRESULT WINAPI
SAXContentHandler_putDocumentLocator(
1085 ISAXContentHandler
*iface
,
1086 ISAXLocator
*locator
)
1088 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1089 FIXME("(%p)->(%p)\n", This
, locator
);
1093 static HRESULT WINAPI
SAXContentHandler_startDocument(ISAXContentHandler
*iface
)
1095 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1097 TRACE("(%p)\n", This
);
1099 /* If properties have been changed since the last "endDocument" call
1100 * we need to reset the output buffer. If we don't the output buffer
1101 * could end up with multiple XML documents in it, plus this seems to
1102 * be how Windows works.
1104 if (This
->prop_changed
) {
1105 reset_output_buffer(This
);
1106 This
->prop_changed
= FALSE
;
1109 if (This
->props
[MXWriter_OmitXmlDecl
] == VARIANT_TRUE
) return S_OK
;
1111 write_prolog_buffer(This
);
1113 if (This
->dest
&& This
->xml_enc
== XmlEncoding_UTF16
) {
1114 static const char utf16BOM
[] = {0xff,0xfe};
1116 if (This
->props
[MXWriter_BOM
] == VARIANT_TRUE
)
1117 /* Windows passes a NULL pointer as the pcbWritten parameter and
1118 * ignores any error codes returned from this Write call.
1120 IStream_Write(This
->dest
, utf16BOM
, sizeof(utf16BOM
), NULL
);
1126 static HRESULT WINAPI
SAXContentHandler_endDocument(ISAXContentHandler
*iface
)
1128 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1129 TRACE("(%p)\n", This
);
1130 This
->prop_changed
= FALSE
;
1131 return flush_output_buffer(This
);
1134 static HRESULT WINAPI
SAXContentHandler_startPrefixMapping(
1135 ISAXContentHandler
*iface
,
1136 const WCHAR
*prefix
,
1141 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1142 TRACE("(%p)->(%s %s)\n", This
, debugstr_wn(prefix
, nprefix
), debugstr_wn(uri
, nuri
));
1146 static HRESULT WINAPI
SAXContentHandler_endPrefixMapping(
1147 ISAXContentHandler
*iface
,
1148 const WCHAR
*prefix
,
1151 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1152 TRACE("(%p)->(%s)\n", This
, debugstr_wn(prefix
, nprefix
));
1156 static void mxwriter_write_attribute(mxwriter
*writer
, const WCHAR
*qname
, int qname_len
,
1157 const WCHAR
*value
, int value_len
, BOOL escape
)
1159 static const WCHAR eqW
[] = {'='};
1161 /* space separator in front of every attribute */
1162 write_output_buffer(writer
->buffer
, spaceW
, 1);
1163 write_output_buffer(writer
->buffer
, qname
, qname_len
);
1164 write_output_buffer(writer
->buffer
, eqW
, 1);
1168 WCHAR
*escaped
= get_escaped_string(value
, EscapeValue
, &value_len
);
1169 write_output_buffer_quoted(writer
->buffer
, escaped
, value_len
);
1173 write_output_buffer_quoted(writer
->buffer
, value
, value_len
);
1176 static void mxwriter_write_starttag(mxwriter
*writer
, const WCHAR
*qname
, int len
)
1178 static const WCHAR ltW
[] = {'<'};
1180 close_element_starttag(writer
);
1181 set_element_name(writer
, qname
? qname
: emptyW
, qname
? len
: 0);
1183 write_node_indent(writer
);
1185 write_output_buffer(writer
->buffer
, ltW
, 1);
1186 write_output_buffer(writer
->buffer
, qname
? qname
: emptyW
, qname
? len
: 0);
1187 writer_inc_indent(writer
);
1190 static HRESULT WINAPI
SAXContentHandler_startElement(
1191 ISAXContentHandler
*iface
,
1192 const WCHAR
*namespaceUri
,
1194 const WCHAR
*local_name
,
1198 ISAXAttributes
*attr
)
1200 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1202 TRACE("(%p)->(%s %s %s %p)\n", This
, debugstr_wn(namespaceUri
, nnamespaceUri
),
1203 debugstr_wn(local_name
, nlocal_name
), debugstr_wn(QName
, nQName
), attr
);
1205 if (((!namespaceUri
|| !local_name
|| !QName
) && This
->class_version
!= MSXML6
) ||
1206 (nQName
== -1 && This
->class_version
== MSXML6
))
1207 return E_INVALIDARG
;
1209 mxwriter_write_starttag(This
, QName
, nQName
);
1213 int length
, i
, escape
;
1216 hr
= ISAXAttributes_getLength(attr
, &length
);
1217 if (FAILED(hr
)) return hr
;
1219 escape
= This
->props
[MXWriter_DisableEscaping
] == VARIANT_FALSE
||
1220 (This
->class_version
== MSXML4
|| This
->class_version
== MSXML6
);
1222 for (i
= 0; i
< length
; i
++)
1224 int qname_len
= 0, value_len
= 0;
1225 const WCHAR
*qname
, *value
;
1227 hr
= ISAXAttributes_getQName(attr
, i
, &qname
, &qname_len
);
1228 if (FAILED(hr
)) return hr
;
1230 hr
= ISAXAttributes_getValue(attr
, i
, &value
, &value_len
);
1231 if (FAILED(hr
)) return hr
;
1233 mxwriter_write_attribute(This
, qname
, qname_len
, value
, value_len
, escape
);
1240 static HRESULT WINAPI
SAXContentHandler_endElement(
1241 ISAXContentHandler
*iface
,
1242 const WCHAR
*namespaceUri
,
1244 const WCHAR
* local_name
,
1249 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1251 TRACE("(%p)->(%s:%d %s:%d %s:%d)\n", This
, debugstr_wn(namespaceUri
, nnamespaceUri
), nnamespaceUri
,
1252 debugstr_wn(local_name
, nlocal_name
), nlocal_name
, debugstr_wn(QName
, nQName
), nQName
);
1254 if (((!namespaceUri
|| !local_name
|| !QName
) && This
->class_version
!= MSXML6
) ||
1255 (nQName
== -1 && This
->class_version
== MSXML6
))
1256 return E_INVALIDARG
;
1258 writer_dec_indent(This
);
1262 static const WCHAR closeW
[] = {'/','>'};
1263 write_output_buffer(This
->buffer
, closeW
, 2);
1267 static const WCHAR closetagW
[] = {'<','/'};
1268 static const WCHAR gtW
[] = {'>'};
1270 write_node_indent(This
);
1271 write_output_buffer(This
->buffer
, closetagW
, 2);
1272 write_output_buffer(This
->buffer
, QName
, nQName
);
1273 write_output_buffer(This
->buffer
, gtW
, 1);
1276 set_element_name(This
, NULL
, 0);
1281 static HRESULT WINAPI
SAXContentHandler_characters(
1282 ISAXContentHandler
*iface
,
1286 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1288 TRACE("(%p)->(%s:%d)\n", This
, debugstr_wn(chars
, nchars
), nchars
);
1290 if (!chars
) return E_INVALIDARG
;
1292 close_element_starttag(This
);
1293 set_element_name(This
, NULL
, 0);
1300 if (This
->cdata
|| This
->props
[MXWriter_DisableEscaping
] == VARIANT_TRUE
)
1301 write_output_buffer(This
->buffer
, chars
, nchars
);
1307 escaped
= get_escaped_string(chars
, EscapeText
, &len
);
1308 write_output_buffer(This
->buffer
, escaped
, len
);
1316 static HRESULT WINAPI
SAXContentHandler_ignorableWhitespace(
1317 ISAXContentHandler
*iface
,
1321 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1323 TRACE("(%p)->(%s)\n", This
, debugstr_wn(chars
, nchars
));
1325 if (!chars
) return E_INVALIDARG
;
1327 write_output_buffer(This
->buffer
, chars
, nchars
);
1332 static HRESULT WINAPI
SAXContentHandler_processingInstruction(
1333 ISAXContentHandler
*iface
,
1334 const WCHAR
*target
,
1339 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1340 static const WCHAR openpiW
[] = {'<','?'};
1341 static const WCHAR closepiW
[] = {'?','>','\r','\n'};
1343 TRACE("(%p)->(%s %s)\n", This
, debugstr_wn(target
, ntarget
), debugstr_wn(data
, ndata
));
1345 if (!target
) return E_INVALIDARG
;
1347 write_node_indent(This
);
1348 write_output_buffer(This
->buffer
, openpiW
, sizeof(openpiW
)/sizeof(WCHAR
));
1351 write_output_buffer(This
->buffer
, target
, ntarget
);
1353 if (data
&& *data
&& ndata
)
1355 write_output_buffer(This
->buffer
, spaceW
, 1);
1356 write_output_buffer(This
->buffer
, data
, ndata
);
1359 write_output_buffer(This
->buffer
, closepiW
, sizeof(closepiW
)/sizeof(WCHAR
));
1360 This
->newline
= TRUE
;
1365 static HRESULT WINAPI
SAXContentHandler_skippedEntity(
1366 ISAXContentHandler
*iface
,
1370 mxwriter
*This
= impl_from_ISAXContentHandler( iface
);
1371 FIXME("(%p)->(%s)\n", This
, debugstr_wn(name
, nname
));
1375 static const struct ISAXContentHandlerVtbl SAXContentHandlerVtbl
=
1377 SAXContentHandler_QueryInterface
,
1378 SAXContentHandler_AddRef
,
1379 SAXContentHandler_Release
,
1380 SAXContentHandler_putDocumentLocator
,
1381 SAXContentHandler_startDocument
,
1382 SAXContentHandler_endDocument
,
1383 SAXContentHandler_startPrefixMapping
,
1384 SAXContentHandler_endPrefixMapping
,
1385 SAXContentHandler_startElement
,
1386 SAXContentHandler_endElement
,
1387 SAXContentHandler_characters
,
1388 SAXContentHandler_ignorableWhitespace
,
1389 SAXContentHandler_processingInstruction
,
1390 SAXContentHandler_skippedEntity
1393 /*** ISAXLexicalHandler ***/
1394 static HRESULT WINAPI
SAXLexicalHandler_QueryInterface(ISAXLexicalHandler
*iface
,
1395 REFIID riid
, void **obj
)
1397 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1398 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
1401 static ULONG WINAPI
SAXLexicalHandler_AddRef(ISAXLexicalHandler
*iface
)
1403 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1404 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
1407 static ULONG WINAPI
SAXLexicalHandler_Release(ISAXLexicalHandler
*iface
)
1409 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1410 return IMXWriter_Release(&This
->IMXWriter_iface
);
1413 static HRESULT WINAPI
SAXLexicalHandler_startDTD(ISAXLexicalHandler
*iface
,
1414 const WCHAR
*name
, int name_len
, const WCHAR
*publicId
, int publicId_len
,
1415 const WCHAR
*systemId
, int systemId_len
)
1417 static const WCHAR doctypeW
[] = {'<','!','D','O','C','T','Y','P','E',' '};
1418 static const WCHAR openintW
[] = {'[','\r','\n'};
1420 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1422 TRACE("(%p)->(%s %s %s)\n", This
, debugstr_wn(name
, name_len
), debugstr_wn(publicId
, publicId_len
),
1423 debugstr_wn(systemId
, systemId_len
));
1425 if (!name
) return E_INVALIDARG
;
1427 write_output_buffer(This
->buffer
, doctypeW
, sizeof(doctypeW
)/sizeof(WCHAR
));
1431 write_output_buffer(This
->buffer
, name
, name_len
);
1432 write_output_buffer(This
->buffer
, spaceW
, 1);
1437 static const WCHAR publicW
[] = {'P','U','B','L','I','C',' '};
1439 write_output_buffer(This
->buffer
, publicW
, sizeof(publicW
)/sizeof(WCHAR
));
1440 write_output_buffer_quoted(This
->buffer
, publicId
, publicId_len
);
1442 if (!systemId
) return E_INVALIDARG
;
1445 write_output_buffer(This
->buffer
, spaceW
, 1);
1447 write_output_buffer_quoted(This
->buffer
, systemId
, systemId_len
);
1450 write_output_buffer(This
->buffer
, spaceW
, 1);
1454 static const WCHAR systemW
[] = {'S','Y','S','T','E','M',' '};
1456 write_output_buffer(This
->buffer
, systemW
, sizeof(systemW
)/sizeof(WCHAR
));
1457 write_output_buffer_quoted(This
->buffer
, systemId
, systemId_len
);
1459 write_output_buffer(This
->buffer
, spaceW
, 1);
1462 write_output_buffer(This
->buffer
, openintW
, sizeof(openintW
)/sizeof(WCHAR
));
1467 static HRESULT WINAPI
SAXLexicalHandler_endDTD(ISAXLexicalHandler
*iface
)
1469 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1470 static const WCHAR closedtdW
[] = {']','>','\r','\n'};
1472 TRACE("(%p)\n", This
);
1474 write_output_buffer(This
->buffer
, closedtdW
, sizeof(closedtdW
)/sizeof(WCHAR
));
1479 static HRESULT WINAPI
SAXLexicalHandler_startEntity(ISAXLexicalHandler
*iface
, const WCHAR
*name
, int len
)
1481 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1482 FIXME("(%p)->(%s): stub\n", This
, debugstr_wn(name
, len
));
1486 static HRESULT WINAPI
SAXLexicalHandler_endEntity(ISAXLexicalHandler
*iface
, const WCHAR
*name
, int len
)
1488 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1489 FIXME("(%p)->(%s): stub\n", This
, debugstr_wn(name
, len
));
1493 static HRESULT WINAPI
SAXLexicalHandler_startCDATA(ISAXLexicalHandler
*iface
)
1495 static const WCHAR scdataW
[] = {'<','!','[','C','D','A','T','A','['};
1496 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1498 TRACE("(%p)\n", This
);
1500 write_node_indent(This
);
1501 write_output_buffer(This
->buffer
, scdataW
, sizeof(scdataW
)/sizeof(WCHAR
));
1507 static HRESULT WINAPI
SAXLexicalHandler_endCDATA(ISAXLexicalHandler
*iface
)
1509 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1510 static const WCHAR ecdataW
[] = {']',']','>'};
1512 TRACE("(%p)\n", This
);
1514 write_output_buffer(This
->buffer
, ecdataW
, sizeof(ecdataW
)/sizeof(WCHAR
));
1515 This
->cdata
= FALSE
;
1520 static HRESULT WINAPI
SAXLexicalHandler_comment(ISAXLexicalHandler
*iface
, const WCHAR
*chars
, int nchars
)
1522 mxwriter
*This
= impl_from_ISAXLexicalHandler( iface
);
1523 static const WCHAR copenW
[] = {'<','!','-','-'};
1524 static const WCHAR ccloseW
[] = {'-','-','>','\r','\n'};
1526 TRACE("(%p)->(%s:%d)\n", This
, debugstr_wn(chars
, nchars
), nchars
);
1528 if (!chars
) return E_INVALIDARG
;
1530 close_element_starttag(This
);
1531 write_node_indent(This
);
1533 write_output_buffer(This
->buffer
, copenW
, sizeof(copenW
)/sizeof(WCHAR
));
1535 write_output_buffer(This
->buffer
, chars
, nchars
);
1536 write_output_buffer(This
->buffer
, ccloseW
, sizeof(ccloseW
)/sizeof(WCHAR
));
1541 static const struct ISAXLexicalHandlerVtbl SAXLexicalHandlerVtbl
=
1543 SAXLexicalHandler_QueryInterface
,
1544 SAXLexicalHandler_AddRef
,
1545 SAXLexicalHandler_Release
,
1546 SAXLexicalHandler_startDTD
,
1547 SAXLexicalHandler_endDTD
,
1548 SAXLexicalHandler_startEntity
,
1549 SAXLexicalHandler_endEntity
,
1550 SAXLexicalHandler_startCDATA
,
1551 SAXLexicalHandler_endCDATA
,
1552 SAXLexicalHandler_comment
1555 /*** ISAXDeclHandler ***/
1556 static HRESULT WINAPI
SAXDeclHandler_QueryInterface(ISAXDeclHandler
*iface
,
1557 REFIID riid
, void **obj
)
1559 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1560 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
1563 static ULONG WINAPI
SAXDeclHandler_AddRef(ISAXDeclHandler
*iface
)
1565 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1566 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
1569 static ULONG WINAPI
SAXDeclHandler_Release(ISAXDeclHandler
*iface
)
1571 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1572 return IMXWriter_Release(&This
->IMXWriter_iface
);
1575 static HRESULT WINAPI
SAXDeclHandler_elementDecl(ISAXDeclHandler
*iface
,
1576 const WCHAR
*name
, int n_name
, const WCHAR
*model
, int n_model
)
1578 static const WCHAR elementW
[] = {'<','!','E','L','E','M','E','N','T',' '};
1579 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1581 TRACE("(%p)->(%s:%d %s:%d)\n", This
, debugstr_wn(name
, n_name
), n_name
,
1582 debugstr_wn(model
, n_model
), n_model
);
1584 if (!name
|| !model
) return E_INVALIDARG
;
1586 write_output_buffer(This
->buffer
, elementW
, sizeof(elementW
)/sizeof(WCHAR
));
1588 write_output_buffer(This
->buffer
, name
, n_name
);
1589 write_output_buffer(This
->buffer
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1592 write_output_buffer(This
->buffer
, model
, n_model
);
1593 write_output_buffer(This
->buffer
, closetagW
, sizeof(closetagW
)/sizeof(WCHAR
));
1598 static HRESULT WINAPI
SAXDeclHandler_attributeDecl(ISAXDeclHandler
*iface
,
1599 const WCHAR
*element
, int n_element
, const WCHAR
*attr
, int n_attr
,
1600 const WCHAR
*type
, int n_type
, const WCHAR
*Default
, int n_default
,
1601 const WCHAR
*value
, int n_value
)
1603 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1604 static const WCHAR attlistW
[] = {'<','!','A','T','T','L','I','S','T',' '};
1605 static const WCHAR closetagW
[] = {'>','\r','\n'};
1607 TRACE("(%p)->(%s:%d %s:%d %s:%d %s:%d %s:%d)\n", This
, debugstr_wn(element
, n_element
), n_element
,
1608 debugstr_wn(attr
, n_attr
), n_attr
, debugstr_wn(type
, n_type
), n_type
, debugstr_wn(Default
, n_default
), n_default
,
1609 debugstr_wn(value
, n_value
), n_value
);
1611 write_output_buffer(This
->buffer
, attlistW
, sizeof(attlistW
)/sizeof(WCHAR
));
1613 write_output_buffer(This
->buffer
, element
, n_element
);
1614 write_output_buffer(This
->buffer
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1618 write_output_buffer(This
->buffer
, attr
, n_attr
);
1619 write_output_buffer(This
->buffer
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1623 write_output_buffer(This
->buffer
, type
, n_type
);
1624 write_output_buffer(This
->buffer
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1628 write_output_buffer(This
->buffer
, Default
, n_default
);
1629 write_output_buffer(This
->buffer
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1633 write_output_buffer_quoted(This
->buffer
, value
, n_value
);
1635 write_output_buffer(This
->buffer
, closetagW
, sizeof(closetagW
)/sizeof(WCHAR
));
1640 static HRESULT WINAPI
SAXDeclHandler_internalEntityDecl(ISAXDeclHandler
*iface
,
1641 const WCHAR
*name
, int n_name
, const WCHAR
*value
, int n_value
)
1643 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1645 TRACE("(%p)->(%s:%d %s:%d)\n", This
, debugstr_wn(name
, n_name
), n_name
,
1646 debugstr_wn(value
, n_value
), n_value
);
1648 if (!name
|| !value
) return E_INVALIDARG
;
1650 write_output_buffer(This
->buffer
, entityW
, sizeof(entityW
)/sizeof(WCHAR
));
1652 write_output_buffer(This
->buffer
, name
, n_name
);
1653 write_output_buffer(This
->buffer
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1657 write_output_buffer_quoted(This
->buffer
, value
, n_value
);
1659 write_output_buffer(This
->buffer
, closetagW
, sizeof(closetagW
)/sizeof(WCHAR
));
1664 static HRESULT WINAPI
SAXDeclHandler_externalEntityDecl(ISAXDeclHandler
*iface
,
1665 const WCHAR
*name
, int n_name
, const WCHAR
*publicId
, int n_publicId
,
1666 const WCHAR
*systemId
, int n_systemId
)
1668 static const WCHAR publicW
[] = {'P','U','B','L','I','C',' '};
1669 static const WCHAR systemW
[] = {'S','Y','S','T','E','M',' '};
1670 mxwriter
*This
= impl_from_ISAXDeclHandler( iface
);
1672 TRACE("(%p)->(%s:%d %s:%d %s:%d)\n", This
, debugstr_wn(name
, n_name
), n_name
,
1673 debugstr_wn(publicId
, n_publicId
), n_publicId
, debugstr_wn(systemId
, n_systemId
), n_systemId
);
1675 if (!name
) return E_INVALIDARG
;
1676 if (publicId
&& !systemId
) return E_INVALIDARG
;
1677 if (!publicId
&& !systemId
) return E_INVALIDARG
;
1679 write_output_buffer(This
->buffer
, entityW
, sizeof(entityW
)/sizeof(WCHAR
));
1681 write_output_buffer(This
->buffer
, name
, n_name
);
1682 write_output_buffer(This
->buffer
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1687 write_output_buffer(This
->buffer
, publicW
, sizeof(publicW
)/sizeof(WCHAR
));
1688 write_output_buffer_quoted(This
->buffer
, publicId
, n_publicId
);
1689 write_output_buffer(This
->buffer
, spaceW
, sizeof(spaceW
)/sizeof(WCHAR
));
1690 write_output_buffer_quoted(This
->buffer
, systemId
, n_systemId
);
1694 write_output_buffer(This
->buffer
, systemW
, sizeof(systemW
)/sizeof(WCHAR
));
1695 write_output_buffer_quoted(This
->buffer
, systemId
, n_systemId
);
1698 write_output_buffer(This
->buffer
, closetagW
, sizeof(closetagW
)/sizeof(WCHAR
));
1703 static const ISAXDeclHandlerVtbl SAXDeclHandlerVtbl
= {
1704 SAXDeclHandler_QueryInterface
,
1705 SAXDeclHandler_AddRef
,
1706 SAXDeclHandler_Release
,
1707 SAXDeclHandler_elementDecl
,
1708 SAXDeclHandler_attributeDecl
,
1709 SAXDeclHandler_internalEntityDecl
,
1710 SAXDeclHandler_externalEntityDecl
1713 /*** IVBSAXDeclHandler ***/
1714 static HRESULT WINAPI
VBSAXDeclHandler_QueryInterface(IVBSAXDeclHandler
*iface
,
1715 REFIID riid
, void **obj
)
1717 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1718 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
1721 static ULONG WINAPI
VBSAXDeclHandler_AddRef(IVBSAXDeclHandler
*iface
)
1723 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1724 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
1727 static ULONG WINAPI
VBSAXDeclHandler_Release(IVBSAXDeclHandler
*iface
)
1729 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1730 return IMXWriter_Release(&This
->IMXWriter_iface
);
1733 static HRESULT WINAPI
VBSAXDeclHandler_GetTypeInfoCount(IVBSAXDeclHandler
*iface
, UINT
* pctinfo
)
1735 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1736 return IMXWriter_GetTypeInfoCount(&This
->IMXWriter_iface
, pctinfo
);
1739 static HRESULT WINAPI
VBSAXDeclHandler_GetTypeInfo(IVBSAXDeclHandler
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1741 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1742 return IMXWriter_GetTypeInfo(&This
->IMXWriter_iface
, iTInfo
, lcid
, ppTInfo
);
1745 static HRESULT WINAPI
VBSAXDeclHandler_GetIDsOfNames(IVBSAXDeclHandler
*iface
, REFIID riid
, LPOLESTR
* rgszNames
,
1746 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
1748 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1749 return IMXWriter_GetIDsOfNames(&This
->IMXWriter_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1752 static HRESULT WINAPI
VBSAXDeclHandler_Invoke(IVBSAXDeclHandler
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
1753 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
1755 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1756 return IMXWriter_Invoke(&This
->IMXWriter_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
,
1757 pExcepInfo
, puArgErr
);
1760 static HRESULT WINAPI
VBSAXDeclHandler_elementDecl(IVBSAXDeclHandler
*iface
, BSTR
*name
, BSTR
*model
)
1762 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1764 TRACE("(%p)->(%p %p)\n", This
, name
, model
);
1766 if (!name
|| !model
)
1769 return ISAXDeclHandler_elementDecl(&This
->ISAXDeclHandler_iface
, *name
, -1, *model
, -1);
1772 static HRESULT WINAPI
VBSAXDeclHandler_attributeDecl(IVBSAXDeclHandler
*iface
,
1773 BSTR
*element
, BSTR
*attr
, BSTR
*type
, BSTR
*default_value
, BSTR
*value
)
1775 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1777 TRACE("(%p)->(%p %p %p %p %p)\n", This
, element
, attr
, type
, default_value
, value
);
1779 if (!element
|| !attr
|| !type
|| !default_value
|| !value
)
1782 return ISAXDeclHandler_attributeDecl(&This
->ISAXDeclHandler_iface
, *element
, -1, *attr
, -1, *type
, -1,
1783 *default_value
, -1, *value
, -1);
1786 static HRESULT WINAPI
VBSAXDeclHandler_internalEntityDecl(IVBSAXDeclHandler
*iface
, BSTR
*name
, BSTR
*value
)
1788 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1790 TRACE("(%p)->(%p %p)\n", This
, name
, value
);
1792 if (!name
|| !value
)
1795 return ISAXDeclHandler_internalEntityDecl(&This
->ISAXDeclHandler_iface
, *name
, -1, *value
, -1);
1798 static HRESULT WINAPI
VBSAXDeclHandler_externalEntityDecl(IVBSAXDeclHandler
*iface
,
1799 BSTR
*name
, BSTR
*publicid
, BSTR
*systemid
)
1801 mxwriter
*This
= impl_from_IVBSAXDeclHandler( iface
);
1803 TRACE("(%p)->(%p %p %p)\n", This
, name
, publicid
, systemid
);
1805 if (!name
|| !publicid
|| !systemid
)
1808 return ISAXDeclHandler_externalEntityDecl(&This
->ISAXDeclHandler_iface
, *name
, -1, *publicid
, -1, *systemid
, -1);
1811 static const IVBSAXDeclHandlerVtbl VBSAXDeclHandlerVtbl
= {
1812 VBSAXDeclHandler_QueryInterface
,
1813 VBSAXDeclHandler_AddRef
,
1814 VBSAXDeclHandler_Release
,
1815 VBSAXDeclHandler_GetTypeInfoCount
,
1816 VBSAXDeclHandler_GetTypeInfo
,
1817 VBSAXDeclHandler_GetIDsOfNames
,
1818 VBSAXDeclHandler_Invoke
,
1819 VBSAXDeclHandler_elementDecl
,
1820 VBSAXDeclHandler_attributeDecl
,
1821 VBSAXDeclHandler_internalEntityDecl
,
1822 VBSAXDeclHandler_externalEntityDecl
1825 /*** IVBSAXLexicalHandler ***/
1826 static HRESULT WINAPI
VBSAXLexicalHandler_QueryInterface(IVBSAXLexicalHandler
*iface
,
1827 REFIID riid
, void **obj
)
1829 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1830 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
1833 static ULONG WINAPI
VBSAXLexicalHandler_AddRef(IVBSAXLexicalHandler
*iface
)
1835 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1836 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
1839 static ULONG WINAPI
VBSAXLexicalHandler_Release(IVBSAXLexicalHandler
*iface
)
1841 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1842 return IMXWriter_Release(&This
->IMXWriter_iface
);
1845 static HRESULT WINAPI
VBSAXLexicalHandler_GetTypeInfoCount(IVBSAXLexicalHandler
*iface
, UINT
* pctinfo
)
1847 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1848 return IMXWriter_GetTypeInfoCount(&This
->IMXWriter_iface
, pctinfo
);
1851 static HRESULT WINAPI
VBSAXLexicalHandler_GetTypeInfo(IVBSAXLexicalHandler
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1853 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1854 return IMXWriter_GetTypeInfo(&This
->IMXWriter_iface
, iTInfo
, lcid
, ppTInfo
);
1857 static HRESULT WINAPI
VBSAXLexicalHandler_GetIDsOfNames(IVBSAXLexicalHandler
*iface
, REFIID riid
, LPOLESTR
* rgszNames
,
1858 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
1860 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1861 return IMXWriter_GetIDsOfNames(&This
->IMXWriter_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1864 static HRESULT WINAPI
VBSAXLexicalHandler_Invoke(IVBSAXLexicalHandler
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
1865 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
1867 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1868 return IMXWriter_Invoke(&This
->IMXWriter_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
,
1869 pExcepInfo
, puArgErr
);
1872 static HRESULT WINAPI
VBSAXLexicalHandler_startDTD(IVBSAXLexicalHandler
*iface
, BSTR
*name
, BSTR
*publicId
, BSTR
*systemId
)
1874 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1876 TRACE("(%p)->(%p %p %p)\n", This
, name
, publicId
, systemId
);
1878 if (!name
|| !publicId
|| !systemId
)
1881 return ISAXLexicalHandler_startDTD(&This
->ISAXLexicalHandler_iface
, *name
, -1, *publicId
, -1, *systemId
, -1);
1884 static HRESULT WINAPI
VBSAXLexicalHandler_endDTD(IVBSAXLexicalHandler
*iface
)
1886 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1887 return ISAXLexicalHandler_endDTD(&This
->ISAXLexicalHandler_iface
);
1890 static HRESULT WINAPI
VBSAXLexicalHandler_startEntity(IVBSAXLexicalHandler
*iface
, BSTR
*name
)
1892 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1894 TRACE("(%p)->(%p)\n", This
, name
);
1899 return ISAXLexicalHandler_startEntity(&This
->ISAXLexicalHandler_iface
, *name
, -1);
1902 static HRESULT WINAPI
VBSAXLexicalHandler_endEntity(IVBSAXLexicalHandler
*iface
, BSTR
*name
)
1904 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1906 TRACE("(%p)->(%p)\n", This
, name
);
1911 return ISAXLexicalHandler_endEntity(&This
->ISAXLexicalHandler_iface
, *name
, -1);
1914 static HRESULT WINAPI
VBSAXLexicalHandler_startCDATA(IVBSAXLexicalHandler
*iface
)
1916 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1917 return ISAXLexicalHandler_startCDATA(&This
->ISAXLexicalHandler_iface
);
1920 static HRESULT WINAPI
VBSAXLexicalHandler_endCDATA(IVBSAXLexicalHandler
*iface
)
1922 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1923 return ISAXLexicalHandler_endCDATA(&This
->ISAXLexicalHandler_iface
);
1926 static HRESULT WINAPI
VBSAXLexicalHandler_comment(IVBSAXLexicalHandler
*iface
, BSTR
*chars
)
1928 mxwriter
*This
= impl_from_IVBSAXLexicalHandler( iface
);
1930 TRACE("(%p)->(%p)\n", This
, chars
);
1935 return ISAXLexicalHandler_comment(&This
->ISAXLexicalHandler_iface
, *chars
, -1);
1938 static const IVBSAXLexicalHandlerVtbl VBSAXLexicalHandlerVtbl
= {
1939 VBSAXLexicalHandler_QueryInterface
,
1940 VBSAXLexicalHandler_AddRef
,
1941 VBSAXLexicalHandler_Release
,
1942 VBSAXLexicalHandler_GetTypeInfoCount
,
1943 VBSAXLexicalHandler_GetTypeInfo
,
1944 VBSAXLexicalHandler_GetIDsOfNames
,
1945 VBSAXLexicalHandler_Invoke
,
1946 VBSAXLexicalHandler_startDTD
,
1947 VBSAXLexicalHandler_endDTD
,
1948 VBSAXLexicalHandler_startEntity
,
1949 VBSAXLexicalHandler_endEntity
,
1950 VBSAXLexicalHandler_startCDATA
,
1951 VBSAXLexicalHandler_endCDATA
,
1952 VBSAXLexicalHandler_comment
1955 /*** IVBSAXContentHandler ***/
1956 static HRESULT WINAPI
VBSAXContentHandler_QueryInterface(IVBSAXContentHandler
*iface
, REFIID riid
, void **obj
)
1958 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
1959 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
1962 static ULONG WINAPI
VBSAXContentHandler_AddRef(IVBSAXContentHandler
*iface
)
1964 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
1965 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
1968 static ULONG WINAPI
VBSAXContentHandler_Release(IVBSAXContentHandler
*iface
)
1970 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
1971 return IMXWriter_Release(&This
->IMXWriter_iface
);
1974 static HRESULT WINAPI
VBSAXContentHandler_GetTypeInfoCount(IVBSAXContentHandler
*iface
, UINT
* pctinfo
)
1976 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
1977 return IMXWriter_GetTypeInfoCount(&This
->IMXWriter_iface
, pctinfo
);
1980 static HRESULT WINAPI
VBSAXContentHandler_GetTypeInfo(IVBSAXContentHandler
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1982 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
1983 return IMXWriter_GetTypeInfo(&This
->IMXWriter_iface
, iTInfo
, lcid
, ppTInfo
);
1986 static HRESULT WINAPI
VBSAXContentHandler_GetIDsOfNames(IVBSAXContentHandler
*iface
, REFIID riid
, LPOLESTR
* rgszNames
,
1987 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
1989 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
1990 return IMXWriter_GetIDsOfNames(&This
->IMXWriter_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1993 static HRESULT WINAPI
VBSAXContentHandler_Invoke(IVBSAXContentHandler
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
1994 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
1996 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
1997 return IMXWriter_Invoke(&This
->IMXWriter_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
,
1998 pExcepInfo
, puArgErr
);
2001 static HRESULT WINAPI
VBSAXContentHandler_putref_documentLocator(IVBSAXContentHandler
*iface
, IVBSAXLocator
*locator
)
2003 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2004 TRACE("(%p)->(%p)\n", This
, locator
);
2008 static HRESULT WINAPI
VBSAXContentHandler_startDocument(IVBSAXContentHandler
*iface
)
2010 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2011 return ISAXContentHandler_startDocument(&This
->ISAXContentHandler_iface
);
2014 static HRESULT WINAPI
VBSAXContentHandler_endDocument(IVBSAXContentHandler
*iface
)
2016 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2017 return ISAXContentHandler_endDocument(&This
->ISAXContentHandler_iface
);
2020 static HRESULT WINAPI
VBSAXContentHandler_startPrefixMapping(IVBSAXContentHandler
*iface
, BSTR
*prefix
, BSTR
*uri
)
2022 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2024 TRACE("(%p)->(%p %p)\n", This
, prefix
, uri
);
2026 if (!prefix
|| !uri
)
2029 return ISAXContentHandler_startPrefixMapping(&This
->ISAXContentHandler_iface
, *prefix
, -1, *uri
, -1);
2032 static HRESULT WINAPI
VBSAXContentHandler_endPrefixMapping(IVBSAXContentHandler
*iface
, BSTR
*prefix
)
2034 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2036 TRACE("(%p)->(%p)\n", This
, prefix
);
2041 return ISAXContentHandler_endPrefixMapping(&This
->ISAXContentHandler_iface
, *prefix
, -1);
2044 static HRESULT WINAPI
VBSAXContentHandler_startElement(IVBSAXContentHandler
*iface
,
2045 BSTR
*namespaceURI
, BSTR
*localName
, BSTR
*QName
, IVBSAXAttributes
*attrs
)
2047 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2049 TRACE("(%p)->(%p %p %p %p)\n", This
, namespaceURI
, localName
, QName
, attrs
);
2051 if (!namespaceURI
|| !localName
|| !QName
)
2054 TRACE("(%s %s %s)\n", debugstr_w(*namespaceURI
), debugstr_w(*localName
), debugstr_w(*QName
));
2056 mxwriter_write_starttag(This
, *QName
, SysStringLen(*QName
));
2060 int length
, i
, escape
;
2063 hr
= IVBSAXAttributes_get_length(attrs
, &length
);
2064 if (FAILED(hr
)) return hr
;
2066 escape
= This
->props
[MXWriter_DisableEscaping
] == VARIANT_FALSE
||
2067 (This
->class_version
== MSXML4
|| This
->class_version
== MSXML6
);
2069 for (i
= 0; i
< length
; i
++)
2073 hr
= IVBSAXAttributes_getQName(attrs
, i
, &qname
);
2074 if (FAILED(hr
)) return hr
;
2076 hr
= IVBSAXAttributes_getValue(attrs
, i
, &value
);
2079 SysFreeString(qname
);
2083 mxwriter_write_attribute(This
, qname
, SysStringLen(qname
), value
, SysStringLen(value
), escape
);
2084 SysFreeString(qname
);
2085 SysFreeString(value
);
2092 static HRESULT WINAPI
VBSAXContentHandler_endElement(IVBSAXContentHandler
*iface
, BSTR
*namespaceURI
,
2093 BSTR
*localName
, BSTR
*QName
)
2095 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2097 TRACE("(%p)->(%p %p %p)\n", This
, namespaceURI
, localName
, QName
);
2099 if (!namespaceURI
|| !localName
|| !QName
)
2102 return ISAXContentHandler_endElement(&This
->ISAXContentHandler_iface
,
2103 *namespaceURI
, SysStringLen(*namespaceURI
),
2104 *localName
, SysStringLen(*localName
),
2105 *QName
, SysStringLen(*QName
));
2108 static HRESULT WINAPI
VBSAXContentHandler_characters(IVBSAXContentHandler
*iface
, BSTR
*chars
)
2110 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2112 TRACE("(%p)->(%p)\n", This
, chars
);
2117 return ISAXContentHandler_characters(&This
->ISAXContentHandler_iface
, *chars
, -1);
2120 static HRESULT WINAPI
VBSAXContentHandler_ignorableWhitespace(IVBSAXContentHandler
*iface
, BSTR
*chars
)
2122 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2124 TRACE("(%p)->(%p)\n", This
, chars
);
2129 return ISAXContentHandler_ignorableWhitespace(&This
->ISAXContentHandler_iface
, *chars
, -1);
2132 static HRESULT WINAPI
VBSAXContentHandler_processingInstruction(IVBSAXContentHandler
*iface
,
2133 BSTR
*target
, BSTR
*data
)
2135 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2137 TRACE("(%p)->(%p %p)\n", This
, target
, data
);
2139 if (!target
|| !data
)
2142 return ISAXContentHandler_processingInstruction(&This
->ISAXContentHandler_iface
, *target
, -1, *data
, -1);
2145 static HRESULT WINAPI
VBSAXContentHandler_skippedEntity(IVBSAXContentHandler
*iface
, BSTR
*name
)
2147 mxwriter
*This
= impl_from_IVBSAXContentHandler( iface
);
2149 TRACE("(%p)->(%p)\n", This
, name
);
2154 return ISAXContentHandler_skippedEntity(&This
->ISAXContentHandler_iface
, *name
, -1);
2157 static const IVBSAXContentHandlerVtbl VBSAXContentHandlerVtbl
= {
2158 VBSAXContentHandler_QueryInterface
,
2159 VBSAXContentHandler_AddRef
,
2160 VBSAXContentHandler_Release
,
2161 VBSAXContentHandler_GetTypeInfoCount
,
2162 VBSAXContentHandler_GetTypeInfo
,
2163 VBSAXContentHandler_GetIDsOfNames
,
2164 VBSAXContentHandler_Invoke
,
2165 VBSAXContentHandler_putref_documentLocator
,
2166 VBSAXContentHandler_startDocument
,
2167 VBSAXContentHandler_endDocument
,
2168 VBSAXContentHandler_startPrefixMapping
,
2169 VBSAXContentHandler_endPrefixMapping
,
2170 VBSAXContentHandler_startElement
,
2171 VBSAXContentHandler_endElement
,
2172 VBSAXContentHandler_characters
,
2173 VBSAXContentHandler_ignorableWhitespace
,
2174 VBSAXContentHandler_processingInstruction
,
2175 VBSAXContentHandler_skippedEntity
2178 static HRESULT WINAPI
SAXDTDHandler_QueryInterface(ISAXDTDHandler
*iface
, REFIID riid
, void **obj
)
2180 mxwriter
*This
= impl_from_ISAXDTDHandler( iface
);
2181 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
2184 static ULONG WINAPI
SAXDTDHandler_AddRef(ISAXDTDHandler
*iface
)
2186 mxwriter
*This
= impl_from_ISAXDTDHandler( iface
);
2187 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
2190 static ULONG WINAPI
SAXDTDHandler_Release(ISAXDTDHandler
*iface
)
2192 mxwriter
*This
= impl_from_ISAXDTDHandler( iface
);
2193 return IMXWriter_Release(&This
->IMXWriter_iface
);
2196 static HRESULT WINAPI
SAXDTDHandler_notationDecl(ISAXDTDHandler
*iface
,
2197 const WCHAR
*name
, INT nname
,
2198 const WCHAR
*publicid
, INT npublicid
,
2199 const WCHAR
*systemid
, INT nsystemid
)
2201 mxwriter
*This
= impl_from_ISAXDTDHandler( iface
);
2202 FIXME("(%p)->(%s:%d, %s:%d, %s:%d): stub\n", This
, debugstr_wn(name
, nname
), nname
,
2203 debugstr_wn(publicid
, npublicid
), npublicid
, debugstr_wn(systemid
, nsystemid
), nsystemid
);
2207 static HRESULT WINAPI
SAXDTDHandler_unparsedEntityDecl(ISAXDTDHandler
*iface
,
2208 const WCHAR
*name
, INT nname
,
2209 const WCHAR
*publicid
, INT npublicid
,
2210 const WCHAR
*systemid
, INT nsystemid
,
2211 const WCHAR
*notation
, INT nnotation
)
2213 mxwriter
*This
= impl_from_ISAXDTDHandler( iface
);
2214 FIXME("(%p)->(%s:%d, %s:%d, %s:%d, %s:%d): stub\n", This
, debugstr_wn(name
, nname
), nname
,
2215 debugstr_wn(publicid
, npublicid
), npublicid
, debugstr_wn(systemid
, nsystemid
), nsystemid
,
2216 debugstr_wn(notation
, nnotation
), nnotation
);
2220 static const ISAXDTDHandlerVtbl SAXDTDHandlerVtbl
= {
2221 SAXDTDHandler_QueryInterface
,
2222 SAXDTDHandler_AddRef
,
2223 SAXDTDHandler_Release
,
2224 SAXDTDHandler_notationDecl
,
2225 SAXDTDHandler_unparsedEntityDecl
2228 /*** IVBSAXDTDHandler ***/
2229 static HRESULT WINAPI
VBSAXDTDHandler_QueryInterface(IVBSAXDTDHandler
*iface
, REFIID riid
, void **obj
)
2231 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2232 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
2235 static ULONG WINAPI
VBSAXDTDHandler_AddRef(IVBSAXDTDHandler
*iface
)
2237 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2238 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
2241 static ULONG WINAPI
VBSAXDTDHandler_Release(IVBSAXDTDHandler
*iface
)
2243 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2244 return IMXWriter_Release(&This
->IMXWriter_iface
);
2247 static HRESULT WINAPI
VBSAXDTDHandler_GetTypeInfoCount(IVBSAXDTDHandler
*iface
, UINT
* pctinfo
)
2249 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2250 return IMXWriter_GetTypeInfoCount(&This
->IMXWriter_iface
, pctinfo
);
2253 static HRESULT WINAPI
VBSAXDTDHandler_GetTypeInfo(IVBSAXDTDHandler
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2255 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2256 return IMXWriter_GetTypeInfo(&This
->IMXWriter_iface
, iTInfo
, lcid
, ppTInfo
);
2259 static HRESULT WINAPI
VBSAXDTDHandler_GetIDsOfNames(IVBSAXDTDHandler
*iface
, REFIID riid
, LPOLESTR
* rgszNames
,
2260 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
2262 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2263 return IMXWriter_GetIDsOfNames(&This
->IMXWriter_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
2266 static HRESULT WINAPI
VBSAXDTDHandler_Invoke(IVBSAXDTDHandler
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
2267 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
2269 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2270 return IMXWriter_Invoke(&This
->IMXWriter_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
,
2271 pExcepInfo
, puArgErr
);
2274 static HRESULT WINAPI
VBSAXDTDHandler_notationDecl(IVBSAXDTDHandler
*iface
, BSTR
*name
, BSTR
*publicId
, BSTR
*systemId
)
2276 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2278 TRACE("(%p)->(%p %p %p)\n", This
, name
, publicId
, systemId
);
2280 if (!name
|| !publicId
|| !systemId
)
2283 return ISAXDTDHandler_notationDecl(&This
->ISAXDTDHandler_iface
, *name
, -1, *publicId
, -1, *systemId
, -1);
2286 static HRESULT WINAPI
VBSAXDTDHandler_unparsedEntityDecl(IVBSAXDTDHandler
*iface
, BSTR
*name
, BSTR
*publicId
,
2287 BSTR
*systemId
, BSTR
*notation
)
2289 mxwriter
*This
= impl_from_IVBSAXDTDHandler( iface
);
2291 TRACE("(%p)->(%p %p %p %p)\n", This
, name
, publicId
, systemId
, notation
);
2293 if (!name
|| !publicId
|| !systemId
|| !notation
)
2296 return ISAXDTDHandler_unparsedEntityDecl(&This
->ISAXDTDHandler_iface
, *name
, -1, *publicId
, -1,
2297 *systemId
, -1, *notation
, -1);
2300 static const IVBSAXDTDHandlerVtbl VBSAXDTDHandlerVtbl
= {
2301 VBSAXDTDHandler_QueryInterface
,
2302 VBSAXDTDHandler_AddRef
,
2303 VBSAXDTDHandler_Release
,
2304 VBSAXDTDHandler_GetTypeInfoCount
,
2305 VBSAXDTDHandler_GetTypeInfo
,
2306 VBSAXDTDHandler_GetIDsOfNames
,
2307 VBSAXDTDHandler_Invoke
,
2308 VBSAXDTDHandler_notationDecl
,
2309 VBSAXDTDHandler_unparsedEntityDecl
2312 /* ISAXErrorHandler */
2313 static HRESULT WINAPI
SAXErrorHandler_QueryInterface(ISAXErrorHandler
*iface
, REFIID riid
, void **obj
)
2315 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2316 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
2319 static ULONG WINAPI
SAXErrorHandler_AddRef(ISAXErrorHandler
*iface
)
2321 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2322 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
2325 static ULONG WINAPI
SAXErrorHandler_Release(ISAXErrorHandler
*iface
)
2327 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2328 return IMXWriter_Release(&This
->IMXWriter_iface
);
2331 static HRESULT WINAPI
SAXErrorHandler_error(ISAXErrorHandler
*iface
,
2332 ISAXLocator
*locator
, const WCHAR
*message
, HRESULT hr
)
2334 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2336 FIXME("(%p)->(%p %s 0x%08x)\n", This
, locator
, debugstr_w(message
), hr
);
2341 static HRESULT WINAPI
SAXErrorHandler_fatalError(ISAXErrorHandler
*iface
,
2342 ISAXLocator
*locator
, const WCHAR
*message
, HRESULT hr
)
2344 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2346 FIXME("(%p)->(%p %s 0x%08x)\n", This
, locator
, debugstr_w(message
), hr
);
2351 static HRESULT WINAPI
SAXErrorHandler_ignorableWarning(ISAXErrorHandler
*iface
,
2352 ISAXLocator
*locator
, const WCHAR
*message
, HRESULT hr
)
2354 mxwriter
*This
= impl_from_ISAXErrorHandler( iface
);
2356 FIXME("(%p)->(%p %s 0x%08x)\n", This
, locator
, debugstr_w(message
), hr
);
2361 static const ISAXErrorHandlerVtbl SAXErrorHandlerVtbl
= {
2362 SAXErrorHandler_QueryInterface
,
2363 SAXErrorHandler_AddRef
,
2364 SAXErrorHandler_Release
,
2365 SAXErrorHandler_error
,
2366 SAXErrorHandler_fatalError
,
2367 SAXErrorHandler_ignorableWarning
2370 /*** IVBSAXErrorHandler ***/
2371 static HRESULT WINAPI
VBSAXErrorHandler_QueryInterface(IVBSAXErrorHandler
*iface
, REFIID riid
, void **obj
)
2373 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2374 return IMXWriter_QueryInterface(&This
->IMXWriter_iface
, riid
, obj
);
2377 static ULONG WINAPI
VBSAXErrorHandler_AddRef(IVBSAXErrorHandler
*iface
)
2379 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2380 return IMXWriter_AddRef(&This
->IMXWriter_iface
);
2383 static ULONG WINAPI
VBSAXErrorHandler_Release(IVBSAXErrorHandler
*iface
)
2385 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2386 return IMXWriter_Release(&This
->IMXWriter_iface
);
2389 static HRESULT WINAPI
VBSAXErrorHandler_GetTypeInfoCount(IVBSAXErrorHandler
*iface
, UINT
* pctinfo
)
2391 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2392 return IMXWriter_GetTypeInfoCount(&This
->IMXWriter_iface
, pctinfo
);
2395 static HRESULT WINAPI
VBSAXErrorHandler_GetTypeInfo(IVBSAXErrorHandler
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2397 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2398 return IMXWriter_GetTypeInfo(&This
->IMXWriter_iface
, iTInfo
, lcid
, ppTInfo
);
2401 static HRESULT WINAPI
VBSAXErrorHandler_GetIDsOfNames(IVBSAXErrorHandler
*iface
, REFIID riid
, LPOLESTR
* rgszNames
,
2402 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
2404 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2405 return IMXWriter_GetIDsOfNames(&This
->IMXWriter_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
2408 static HRESULT WINAPI
VBSAXErrorHandler_Invoke(IVBSAXErrorHandler
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
2409 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
2411 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2412 return IMXWriter_Invoke(&This
->IMXWriter_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
,
2413 pExcepInfo
, puArgErr
);
2416 static HRESULT WINAPI
VBSAXErrorHandler_error(IVBSAXErrorHandler
*iface
, IVBSAXLocator
*locator
, BSTR
*message
, LONG code
)
2418 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2419 FIXME("(%p)->(%p %p %x): stub\n", This
, locator
, message
, code
);
2423 static HRESULT WINAPI
VBSAXErrorHandler_fatalError(IVBSAXErrorHandler
*iface
, IVBSAXLocator
*locator
, BSTR
*message
, LONG code
)
2425 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2426 FIXME("(%p)->(%p %p %x): stub\n", This
, locator
, message
, code
);
2430 static HRESULT WINAPI
VBSAXErrorHandler_ignorableWarning(IVBSAXErrorHandler
*iface
, IVBSAXLocator
*locator
, BSTR
*message
, LONG code
)
2432 mxwriter
*This
= impl_from_IVBSAXErrorHandler( iface
);
2433 FIXME("(%p)->(%p %p %x): stub\n", This
, locator
, message
, code
);
2437 static const IVBSAXErrorHandlerVtbl VBSAXErrorHandlerVtbl
= {
2438 VBSAXErrorHandler_QueryInterface
,
2439 VBSAXErrorHandler_AddRef
,
2440 VBSAXErrorHandler_Release
,
2441 VBSAXErrorHandler_GetTypeInfoCount
,
2442 VBSAXErrorHandler_GetTypeInfo
,
2443 VBSAXErrorHandler_GetIDsOfNames
,
2444 VBSAXErrorHandler_Invoke
,
2445 VBSAXErrorHandler_error
,
2446 VBSAXErrorHandler_fatalError
,
2447 VBSAXErrorHandler_ignorableWarning
2450 static const tid_t mxwriter_iface_tids
[] = {
2455 static dispex_static_data_t mxwriter_dispex
= {
2462 HRESULT
MXWriter_create(MSXML_VERSION version
, void **ppObj
)
2464 static const WCHAR version10W
[] = {'1','.','0',0};
2468 TRACE("(%p)\n", ppObj
);
2470 This
= heap_alloc( sizeof (*This
) );
2472 return E_OUTOFMEMORY
;
2474 This
->IMXWriter_iface
.lpVtbl
= &MXWriterVtbl
;
2475 This
->ISAXContentHandler_iface
.lpVtbl
= &SAXContentHandlerVtbl
;
2476 This
->ISAXLexicalHandler_iface
.lpVtbl
= &SAXLexicalHandlerVtbl
;
2477 This
->ISAXDeclHandler_iface
.lpVtbl
= &SAXDeclHandlerVtbl
;
2478 This
->ISAXDTDHandler_iface
.lpVtbl
= &SAXDTDHandlerVtbl
;
2479 This
->ISAXErrorHandler_iface
.lpVtbl
= &SAXErrorHandlerVtbl
;
2480 This
->IVBSAXDeclHandler_iface
.lpVtbl
= &VBSAXDeclHandlerVtbl
;
2481 This
->IVBSAXLexicalHandler_iface
.lpVtbl
= &VBSAXLexicalHandlerVtbl
;
2482 This
->IVBSAXContentHandler_iface
.lpVtbl
= &VBSAXContentHandlerVtbl
;
2483 This
->IVBSAXDTDHandler_iface
.lpVtbl
= &VBSAXDTDHandlerVtbl
;
2484 This
->IVBSAXErrorHandler_iface
.lpVtbl
= &VBSAXErrorHandlerVtbl
;
2486 This
->class_version
= version
;
2488 This
->props
[MXWriter_BOM
] = VARIANT_TRUE
;
2489 This
->props
[MXWriter_DisableEscaping
] = VARIANT_FALSE
;
2490 This
->props
[MXWriter_Indent
] = VARIANT_FALSE
;
2491 This
->props
[MXWriter_OmitXmlDecl
] = VARIANT_FALSE
;
2492 This
->props
[MXWriter_Standalone
] = VARIANT_FALSE
;
2493 This
->prop_changed
= FALSE
;
2494 This
->encoding
= SysAllocString(utf16W
);
2495 This
->version
= SysAllocString(version10W
);
2496 This
->xml_enc
= XmlEncoding_UTF16
;
2498 This
->element
= NULL
;
2499 This
->cdata
= FALSE
;
2502 This
->newline
= FALSE
;
2505 This
->dest_written
= 0;
2507 hr
= alloc_output_buffer(This
->xml_enc
, &This
->buffer
);
2509 SysFreeString(This
->encoding
);
2510 SysFreeString(This
->version
);
2515 init_dispex(&This
->dispex
, (IUnknown
*)&This
->IMXWriter_iface
, &mxwriter_dispex
);
2517 *ppObj
= &This
->IMXWriter_iface
;
2519 TRACE("returning iface %p\n", *ppObj
);
2524 static HRESULT WINAPI
MXAttributes_QueryInterface(IMXAttributes
*iface
, REFIID riid
, void **ppObj
)
2526 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2528 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid( riid
), ppObj
);
2532 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
2533 IsEqualGUID( riid
, &IID_IDispatch
) ||
2534 IsEqualGUID( riid
, &IID_IMXAttributes
))
2538 else if ( IsEqualGUID( riid
, &IID_ISAXAttributes
))
2540 *ppObj
= &This
->ISAXAttributes_iface
;
2542 else if ( IsEqualGUID( riid
, &IID_IVBSAXAttributes
))
2544 *ppObj
= &This
->IVBSAXAttributes_iface
;
2546 else if (dispex_query_interface(&This
->dispex
, riid
, ppObj
))
2548 return *ppObj
? S_OK
: E_NOINTERFACE
;
2552 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
2553 return E_NOINTERFACE
;
2556 IMXAttributes_AddRef( iface
);
2561 static ULONG WINAPI
MXAttributes_AddRef(IMXAttributes
*iface
)
2563 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2564 ULONG ref
= InterlockedIncrement( &This
->ref
);
2565 TRACE("(%p)->(%d)\n", This
, ref
);
2569 static ULONG WINAPI
MXAttributes_Release(IMXAttributes
*iface
)
2571 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2572 LONG ref
= InterlockedDecrement( &This
->ref
);
2574 TRACE("(%p)->(%d)\n", This
, ref
);
2580 for (i
= 0; i
< This
->length
; i
++)
2582 SysFreeString(This
->attr
[i
].qname
);
2583 SysFreeString(This
->attr
[i
].local
);
2584 SysFreeString(This
->attr
[i
].uri
);
2585 SysFreeString(This
->attr
[i
].type
);
2586 SysFreeString(This
->attr
[i
].value
);
2589 heap_free(This
->attr
);
2596 static HRESULT WINAPI
MXAttributes_GetTypeInfoCount(IMXAttributes
*iface
, UINT
* pctinfo
)
2598 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2599 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2602 static HRESULT WINAPI
MXAttributes_GetTypeInfo(IMXAttributes
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2604 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2605 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2608 static HRESULT WINAPI
MXAttributes_GetIDsOfNames(
2609 IMXAttributes
*iface
,
2611 LPOLESTR
* rgszNames
,
2616 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2617 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
,
2618 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
2621 static HRESULT WINAPI
MXAttributes_Invoke(
2622 IMXAttributes
*iface
,
2623 DISPID dispIdMember
,
2627 DISPPARAMS
* pDispParams
,
2628 VARIANT
* pVarResult
,
2629 EXCEPINFO
* pExcepInfo
,
2632 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2633 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
,
2634 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2637 static HRESULT WINAPI
MXAttributes_addAttribute(IMXAttributes
*iface
,
2638 BSTR uri
, BSTR localName
, BSTR QName
, BSTR type
, BSTR value
)
2640 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2644 TRACE("(%p)->(%s %s %s %s %s)\n", This
, debugstr_w(uri
), debugstr_w(localName
),
2645 debugstr_w(QName
), debugstr_w(type
), debugstr_w(value
));
2647 if ((!uri
|| !localName
|| !QName
|| !type
|| !value
) && This
->class_version
!= MSXML6
)
2648 return E_INVALIDARG
;
2650 /* ensure array is large enough */
2651 hr
= mxattributes_grow(This
);
2652 if (hr
!= S_OK
) return hr
;
2654 attr
= &This
->attr
[This
->length
];
2656 attr
->qname
= SysAllocString(QName
);
2657 attr
->local
= SysAllocString(localName
);
2658 attr
->uri
= SysAllocString(uri
);
2659 attr
->type
= SysAllocString(type
? type
: emptyW
);
2660 attr
->value
= SysAllocString(value
);
2666 static HRESULT WINAPI
MXAttributes_addAttributeFromIndex(IMXAttributes
*iface
,
2667 VARIANT atts
, int index
)
2669 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2670 FIXME("(%p)->(%s %d): stub\n", This
, debugstr_variant(&atts
), index
);
2674 static HRESULT WINAPI
MXAttributes_clear(IMXAttributes
*iface
)
2676 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2679 TRACE("(%p)\n", This
);
2681 for (i
= 0; i
< This
->length
; i
++)
2683 SysFreeString(This
->attr
[i
].qname
);
2684 SysFreeString(This
->attr
[i
].local
);
2685 SysFreeString(This
->attr
[i
].uri
);
2686 SysFreeString(This
->attr
[i
].type
);
2687 SysFreeString(This
->attr
[i
].value
);
2688 memset(&This
->attr
[i
], 0, sizeof(mxattribute
));
2696 static mxattribute
*get_attribute_byindex(mxattributes
*attrs
, int index
)
2698 if (index
< 0 || index
>= attrs
->length
) return NULL
;
2699 return &attrs
->attr
[index
];
2702 static HRESULT WINAPI
MXAttributes_removeAttribute(IMXAttributes
*iface
, int index
)
2704 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2707 TRACE("(%p)->(%d)\n", This
, index
);
2709 if (!(dst
= get_attribute_byindex(This
, index
))) return E_INVALIDARG
;
2711 /* no need to remove last attribute, just make it inaccessible */
2712 if (index
+ 1 == This
->length
)
2718 memmove(dst
, dst
+ 1, (This
->length
-index
-1)*sizeof(*dst
));
2724 static HRESULT WINAPI
MXAttributes_setAttribute(IMXAttributes
*iface
, int index
,
2725 BSTR uri
, BSTR localName
, BSTR QName
, BSTR type
, BSTR value
)
2727 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2728 FIXME("(%p)->(%d %s %s %s %s %s): stub\n", This
, index
, debugstr_w(uri
),
2729 debugstr_w(localName
), debugstr_w(QName
), debugstr_w(type
), debugstr_w(value
));
2733 static HRESULT WINAPI
MXAttributes_setAttributes(IMXAttributes
*iface
, VARIANT atts
)
2735 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2736 FIXME("(%p)->(%s): stub\n", This
, debugstr_variant(&atts
));
2740 static HRESULT WINAPI
MXAttributes_setLocalName(IMXAttributes
*iface
, int index
,
2743 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2746 TRACE("(%p)->(%d %s)\n", This
, index
, debugstr_w(localName
));
2748 if (!(attr
= get_attribute_byindex(This
, index
))) return E_INVALIDARG
;
2750 SysFreeString(attr
->local
);
2751 attr
->local
= SysAllocString(localName
);
2756 static HRESULT WINAPI
MXAttributes_setQName(IMXAttributes
*iface
, int index
, BSTR QName
)
2758 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2761 TRACE("(%p)->(%d %s)\n", This
, index
, debugstr_w(QName
));
2763 if (!(attr
= get_attribute_byindex(This
, index
))) return E_INVALIDARG
;
2765 SysFreeString(attr
->qname
);
2766 attr
->qname
= SysAllocString(QName
);
2771 static HRESULT WINAPI
MXAttributes_setURI(IMXAttributes
*iface
, int index
, BSTR uri
)
2773 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2776 TRACE("(%p)->(%d %s)\n", This
, index
, debugstr_w(uri
));
2778 if (!(attr
= get_attribute_byindex(This
, index
))) return E_INVALIDARG
;
2780 SysFreeString(attr
->uri
);
2781 attr
->uri
= SysAllocString(uri
);
2786 static HRESULT WINAPI
MXAttributes_setValue(IMXAttributes
*iface
, int index
, BSTR value
)
2788 mxattributes
*This
= impl_from_IMXAttributes( iface
);
2791 TRACE("(%p)->(%d %s)\n", This
, index
, debugstr_w(value
));
2793 if (!(attr
= get_attribute_byindex(This
, index
))) return E_INVALIDARG
;
2795 SysFreeString(attr
->value
);
2796 attr
->value
= SysAllocString(value
);
2801 static const IMXAttributesVtbl MXAttributesVtbl
= {
2802 MXAttributes_QueryInterface
,
2803 MXAttributes_AddRef
,
2804 MXAttributes_Release
,
2805 MXAttributes_GetTypeInfoCount
,
2806 MXAttributes_GetTypeInfo
,
2807 MXAttributes_GetIDsOfNames
,
2808 MXAttributes_Invoke
,
2809 MXAttributes_addAttribute
,
2810 MXAttributes_addAttributeFromIndex
,
2812 MXAttributes_removeAttribute
,
2813 MXAttributes_setAttribute
,
2814 MXAttributes_setAttributes
,
2815 MXAttributes_setLocalName
,
2816 MXAttributes_setQName
,
2817 MXAttributes_setURI
,
2818 MXAttributes_setValue
2821 static HRESULT WINAPI
SAXAttributes_QueryInterface(ISAXAttributes
*iface
, REFIID riid
, void **ppObj
)
2823 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2824 return IMXAttributes_QueryInterface(&This
->IMXAttributes_iface
, riid
, ppObj
);
2827 static ULONG WINAPI
SAXAttributes_AddRef(ISAXAttributes
*iface
)
2829 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2830 return IMXAttributes_AddRef(&This
->IMXAttributes_iface
);
2833 static ULONG WINAPI
SAXAttributes_Release(ISAXAttributes
*iface
)
2835 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2836 return IMXAttributes_Release(&This
->IMXAttributes_iface
);
2839 static HRESULT WINAPI
SAXAttributes_getLength(ISAXAttributes
*iface
, int *length
)
2841 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2842 TRACE("(%p)->(%p)\n", This
, length
);
2844 if (!length
&& (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
))
2847 *length
= This
->length
;
2852 static HRESULT WINAPI
SAXAttributes_getURI(ISAXAttributes
*iface
, int index
, const WCHAR
**uri
,
2855 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2857 TRACE("(%p)->(%d %p %p)\n", This
, index
, uri
, len
);
2859 if (index
>= This
->length
|| index
< 0) return E_INVALIDARG
;
2860 if (!uri
|| !len
) return E_POINTER
;
2862 *len
= SysStringLen(This
->attr
[index
].uri
);
2863 *uri
= This
->attr
[index
].uri
;
2868 static HRESULT WINAPI
SAXAttributes_getLocalName(ISAXAttributes
*iface
, int index
, const WCHAR
**name
,
2871 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2873 TRACE("(%p)->(%d %p %p)\n", This
, index
, name
, len
);
2875 if (index
>= This
->length
|| index
< 0) return E_INVALIDARG
;
2876 if (!name
|| !len
) return E_POINTER
;
2878 *len
= SysStringLen(This
->attr
[index
].local
);
2879 *name
= This
->attr
[index
].local
;
2884 static HRESULT WINAPI
SAXAttributes_getQName(ISAXAttributes
*iface
, int index
, const WCHAR
**qname
, int *length
)
2886 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2888 TRACE("(%p)->(%d %p %p)\n", This
, index
, qname
, length
);
2890 if (index
>= This
->length
) return E_INVALIDARG
;
2891 if (!qname
|| !length
) return E_POINTER
;
2893 *qname
= This
->attr
[index
].qname
;
2894 *length
= SysStringLen(This
->attr
[index
].qname
);
2899 static HRESULT WINAPI
SAXAttributes_getName(ISAXAttributes
*iface
, int index
, const WCHAR
**uri
, int *uri_len
,
2900 const WCHAR
**local
, int *local_len
, const WCHAR
**qname
, int *qname_len
)
2902 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2904 TRACE("(%p)->(%d %p %p %p %p %p %p)\n", This
, index
, uri
, uri_len
, local
, local_len
, qname
, qname_len
);
2906 if (index
>= This
->length
|| index
< 0)
2907 return E_INVALIDARG
;
2909 if (!uri
|| !uri_len
|| !local
|| !local_len
|| !qname
|| !qname_len
)
2912 *uri_len
= SysStringLen(This
->attr
[index
].uri
);
2913 *uri
= This
->attr
[index
].uri
;
2915 *local_len
= SysStringLen(This
->attr
[index
].local
);
2916 *local
= This
->attr
[index
].local
;
2918 *qname_len
= SysStringLen(This
->attr
[index
].qname
);
2919 *qname
= This
->attr
[index
].qname
;
2921 TRACE("(%s, %s, %s)\n", debugstr_w(*uri
), debugstr_w(*local
), debugstr_w(*qname
));
2926 static HRESULT WINAPI
SAXAttributes_getIndexFromName(ISAXAttributes
*iface
, const WCHAR
*uri
, int uri_len
,
2927 const WCHAR
*name
, int len
, int *index
)
2929 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2932 TRACE("(%p)->(%s:%d %s:%d %p)\n", This
, debugstr_wn(uri
, uri_len
), uri_len
,
2933 debugstr_wn(name
, len
), len
, index
);
2935 if (!index
&& (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
))
2938 if (!uri
|| !name
|| !index
) return E_INVALIDARG
;
2940 for (i
= 0; i
< This
->length
; i
++)
2942 if (uri_len
!= SysStringLen(This
->attr
[i
].uri
)) continue;
2943 if (strncmpW(uri
, This
->attr
[i
].uri
, uri_len
)) continue;
2945 if (len
!= SysStringLen(This
->attr
[i
].local
)) continue;
2946 if (strncmpW(name
, This
->attr
[i
].local
, len
)) continue;
2952 return E_INVALIDARG
;
2955 static HRESULT WINAPI
SAXAttributes_getIndexFromQName(ISAXAttributes
*iface
, const WCHAR
*qname
,
2956 int len
, int *index
)
2958 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2961 TRACE("(%p)->(%s:%d %p)\n", This
, debugstr_wn(qname
, len
), len
, index
);
2963 if (!index
&& (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
))
2966 if (!qname
|| !index
|| !len
) return E_INVALIDARG
;
2968 for (i
= 0; i
< This
->length
; i
++)
2970 if (len
!= SysStringLen(This
->attr
[i
].qname
)) continue;
2971 if (strncmpW(qname
, This
->attr
[i
].qname
, len
)) continue;
2977 return E_INVALIDARG
;
2980 static HRESULT WINAPI
SAXAttributes_getType(ISAXAttributes
*iface
, int index
, const WCHAR
**type
,
2983 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
2985 TRACE("(%p)->(%d %p %p)\n", This
, index
, type
, len
);
2987 if (index
>= This
->length
) return E_INVALIDARG
;
2989 if ((!type
|| !len
) && (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
))
2992 *type
= This
->attr
[index
].type
;
2993 *len
= SysStringLen(This
->attr
[index
].type
);
2998 static HRESULT WINAPI
SAXAttributes_getTypeFromName(ISAXAttributes
*iface
, const WCHAR
* pUri
, int nUri
,
2999 const WCHAR
* pLocalName
, int nLocalName
, const WCHAR
** pType
, int * nType
)
3001 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3002 FIXME("(%p)->(%s:%d %s:%d %p %p): stub\n", This
, debugstr_wn(pUri
, nUri
), nUri
,
3003 debugstr_wn(pLocalName
, nLocalName
), nLocalName
, pType
, nType
);
3007 static HRESULT WINAPI
SAXAttributes_getTypeFromQName(ISAXAttributes
*iface
, const WCHAR
* pQName
,
3008 int nQName
, const WCHAR
** pType
, int * nType
)
3010 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3011 FIXME("(%p)->(%s:%d %p %p): stub\n", This
, debugstr_wn(pQName
, nQName
), nQName
, pType
, nType
);
3015 static HRESULT WINAPI
SAXAttributes_getValue(ISAXAttributes
*iface
, int index
, const WCHAR
**value
,
3018 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3020 TRACE("(%p)->(%d %p %p)\n", This
, index
, value
, len
);
3022 if (index
>= This
->length
) return E_INVALIDARG
;
3024 if ((!value
|| !len
) && (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
))
3027 *value
= This
->attr
[index
].value
;
3028 *len
= SysStringLen(This
->attr
[index
].value
);
3033 static HRESULT WINAPI
SAXAttributes_getValueFromName(ISAXAttributes
*iface
, const WCHAR
*uri
,
3034 int uri_len
, const WCHAR
*name
, int name_len
, const WCHAR
**value
, int *value_len
)
3036 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3040 TRACE("(%p)->(%s:%d %s:%d %p %p)\n", This
, debugstr_wn(uri
, uri_len
), uri_len
,
3041 debugstr_wn(name
, name_len
), name_len
, value
, value_len
);
3043 if (!uri
|| !name
|| !value
|| !value_len
)
3044 return (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
) ? E_POINTER
: E_INVALIDARG
;
3046 hr
= ISAXAttributes_getIndexFromName(iface
, uri
, uri_len
, name
, name_len
, &index
);
3048 hr
= ISAXAttributes_getValue(iface
, index
, value
, value_len
);
3053 static HRESULT WINAPI
SAXAttributes_getValueFromQName(ISAXAttributes
*iface
, const WCHAR
*qname
,
3054 int qname_len
, const WCHAR
**value
, int *value_len
)
3056 mxattributes
*This
= impl_from_ISAXAttributes( iface
);
3060 TRACE("(%p)->(%s:%d %p %p)\n", This
, debugstr_wn(qname
, qname_len
), qname_len
, value
, value_len
);
3062 if (!qname
|| !value
|| !value_len
)
3063 return (This
->class_version
== MSXML_DEFAULT
|| This
->class_version
== MSXML3
) ? E_POINTER
: E_INVALIDARG
;
3065 hr
= ISAXAttributes_getIndexFromQName(iface
, qname
, qname_len
, &index
);
3067 hr
= ISAXAttributes_getValue(iface
, index
, value
, value_len
);
3072 static const ISAXAttributesVtbl SAXAttributesVtbl
= {
3073 SAXAttributes_QueryInterface
,
3074 SAXAttributes_AddRef
,
3075 SAXAttributes_Release
,
3076 SAXAttributes_getLength
,
3077 SAXAttributes_getURI
,
3078 SAXAttributes_getLocalName
,
3079 SAXAttributes_getQName
,
3080 SAXAttributes_getName
,
3081 SAXAttributes_getIndexFromName
,
3082 SAXAttributes_getIndexFromQName
,
3083 SAXAttributes_getType
,
3084 SAXAttributes_getTypeFromName
,
3085 SAXAttributes_getTypeFromQName
,
3086 SAXAttributes_getValue
,
3087 SAXAttributes_getValueFromName
,
3088 SAXAttributes_getValueFromQName
3091 static HRESULT WINAPI
VBSAXAttributes_QueryInterface(
3092 IVBSAXAttributes
* iface
,
3096 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3097 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
3098 return ISAXAttributes_QueryInterface(&This
->ISAXAttributes_iface
, riid
, ppvObject
);
3101 static ULONG WINAPI
VBSAXAttributes_AddRef(IVBSAXAttributes
* iface
)
3103 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3104 return ISAXAttributes_AddRef(&This
->ISAXAttributes_iface
);
3107 static ULONG WINAPI
VBSAXAttributes_Release(IVBSAXAttributes
* iface
)
3109 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3110 return ISAXAttributes_Release(&This
->ISAXAttributes_iface
);
3113 static HRESULT WINAPI
VBSAXAttributes_GetTypeInfoCount( IVBSAXAttributes
*iface
, UINT
* pctinfo
)
3115 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3117 TRACE("(%p)->(%p)\n", This
, pctinfo
);
3124 static HRESULT WINAPI
VBSAXAttributes_GetTypeInfo(
3125 IVBSAXAttributes
*iface
,
3126 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
3128 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3129 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
3130 return get_typeinfo(IVBSAXAttributes_tid
, ppTInfo
);
3133 static HRESULT WINAPI
VBSAXAttributes_GetIDsOfNames(
3134 IVBSAXAttributes
*iface
,
3136 LPOLESTR
* rgszNames
,
3141 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3142 ITypeInfo
*typeinfo
;
3145 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
3148 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
3149 return E_INVALIDARG
;
3151 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
3154 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
3155 ITypeInfo_Release(typeinfo
);
3161 static HRESULT WINAPI
VBSAXAttributes_Invoke(
3162 IVBSAXAttributes
*iface
,
3163 DISPID dispIdMember
,
3167 DISPPARAMS
* pDispParams
,
3168 VARIANT
* pVarResult
,
3169 EXCEPINFO
* pExcepInfo
,
3172 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3173 ITypeInfo
*typeinfo
;
3176 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
3177 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
3179 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
3182 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXAttributes_iface
, dispIdMember
, wFlags
,
3183 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
3184 ITypeInfo_Release(typeinfo
);
3190 static HRESULT WINAPI
VBSAXAttributes_get_length(IVBSAXAttributes
* iface
, int *len
)
3192 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3193 return ISAXAttributes_getLength(&This
->ISAXAttributes_iface
, len
);
3196 static HRESULT WINAPI
VBSAXAttributes_getURI(IVBSAXAttributes
* iface
, int index
, BSTR
*uri
)
3198 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3203 TRACE("(%p)->(%d %p)\n", This
, index
, uri
);
3209 hr
= ISAXAttributes_getURI(&This
->ISAXAttributes_iface
, index
, &uriW
, &len
);
3213 return return_bstrn(uriW
, len
, uri
);
3216 static HRESULT WINAPI
VBSAXAttributes_getLocalName(IVBSAXAttributes
* iface
, int index
, BSTR
*name
)
3218 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3223 TRACE("(%p)->(%d %p)\n", This
, index
, name
);
3229 hr
= ISAXAttributes_getLocalName(&This
->ISAXAttributes_iface
, index
, &nameW
, &len
);
3233 return return_bstrn(nameW
, len
, name
);
3236 static HRESULT WINAPI
VBSAXAttributes_getQName(IVBSAXAttributes
* iface
, int index
, BSTR
*qname
)
3238 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3239 const WCHAR
*qnameW
;
3243 TRACE("(%p)->(%d %p)\n", This
, index
, qname
);
3249 hr
= ISAXAttributes_getQName(&This
->ISAXAttributes_iface
, index
, &qnameW
, &len
);
3253 return return_bstrn(qnameW
, len
, qname
);
3256 static HRESULT WINAPI
VBSAXAttributes_getIndexFromName(IVBSAXAttributes
* iface
, BSTR uri
, BSTR name
, int *index
)
3258 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3259 return ISAXAttributes_getIndexFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
3260 name
, SysStringLen(name
), index
);
3263 static HRESULT WINAPI
VBSAXAttributes_getIndexFromQName(IVBSAXAttributes
* iface
, BSTR qname
, int *index
)
3265 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3266 return ISAXAttributes_getIndexFromQName(&This
->ISAXAttributes_iface
, qname
,
3267 SysStringLen(qname
), index
);
3270 static HRESULT WINAPI
VBSAXAttributes_getType(IVBSAXAttributes
* iface
, int index
, BSTR
*type
)
3272 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3277 TRACE("(%p)->(%d %p)\n", This
, index
, type
);
3283 hr
= ISAXAttributes_getType(&This
->ISAXAttributes_iface
, index
, &typeW
, &len
);
3287 return return_bstrn(typeW
, len
, type
);
3290 static HRESULT WINAPI
VBSAXAttributes_getTypeFromName(IVBSAXAttributes
* iface
, BSTR uri
,
3291 BSTR name
, BSTR
*type
)
3293 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3298 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(uri
), debugstr_w(name
), type
);
3304 hr
= ISAXAttributes_getTypeFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
3305 name
, SysStringLen(name
), &typeW
, &len
);
3309 return return_bstrn(typeW
, len
, type
);
3312 static HRESULT WINAPI
VBSAXAttributes_getTypeFromQName(IVBSAXAttributes
* iface
, BSTR qname
, BSTR
*type
)
3314 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3319 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(qname
), type
);
3325 hr
= ISAXAttributes_getTypeFromQName(&This
->ISAXAttributes_iface
, qname
, SysStringLen(qname
),
3330 return return_bstrn(typeW
, len
, type
);
3333 static HRESULT WINAPI
VBSAXAttributes_getValue(IVBSAXAttributes
* iface
, int index
, BSTR
*value
)
3335 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3336 const WCHAR
*valueW
;
3340 TRACE("(%p)->(%d %p)\n", This
, index
, value
);
3346 hr
= ISAXAttributes_getValue(&This
->ISAXAttributes_iface
, index
, &valueW
, &len
);
3350 return return_bstrn(valueW
, len
, value
);
3353 static HRESULT WINAPI
VBSAXAttributes_getValueFromName(IVBSAXAttributes
* iface
, BSTR uri
, BSTR name
,
3356 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3357 const WCHAR
*valueW
;
3361 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(uri
), debugstr_w(name
), value
);
3367 hr
= ISAXAttributes_getValueFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
3368 name
, SysStringLen(name
), &valueW
, &len
);
3372 return return_bstrn(valueW
, len
, value
);
3375 static HRESULT WINAPI
VBSAXAttributes_getValueFromQName(IVBSAXAttributes
* iface
, BSTR qname
, BSTR
*value
)
3377 mxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
3378 const WCHAR
*valueW
;
3382 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(qname
), value
);
3388 hr
= ISAXAttributes_getValueFromQName(&This
->ISAXAttributes_iface
, qname
, SysStringLen(qname
),
3393 return return_bstrn(valueW
, len
, value
);
3396 static const struct IVBSAXAttributesVtbl VBSAXAttributesVtbl
=
3398 VBSAXAttributes_QueryInterface
,
3399 VBSAXAttributes_AddRef
,
3400 VBSAXAttributes_Release
,
3401 VBSAXAttributes_GetTypeInfoCount
,
3402 VBSAXAttributes_GetTypeInfo
,
3403 VBSAXAttributes_GetIDsOfNames
,
3404 VBSAXAttributes_Invoke
,
3405 VBSAXAttributes_get_length
,
3406 VBSAXAttributes_getURI
,
3407 VBSAXAttributes_getLocalName
,
3408 VBSAXAttributes_getQName
,
3409 VBSAXAttributes_getIndexFromName
,
3410 VBSAXAttributes_getIndexFromQName
,
3411 VBSAXAttributes_getType
,
3412 VBSAXAttributes_getTypeFromName
,
3413 VBSAXAttributes_getTypeFromQName
,
3414 VBSAXAttributes_getValue
,
3415 VBSAXAttributes_getValueFromName
,
3416 VBSAXAttributes_getValueFromQName
3419 static const tid_t mxattrs_iface_tids
[] = {
3424 static dispex_static_data_t mxattrs_dispex
= {
3431 HRESULT
SAXAttributes_create(MSXML_VERSION version
, void **ppObj
)
3433 static const int default_count
= 10;
3436 TRACE("(%p)\n", ppObj
);
3438 This
= heap_alloc( sizeof (*This
) );
3440 return E_OUTOFMEMORY
;
3442 This
->IMXAttributes_iface
.lpVtbl
= &MXAttributesVtbl
;
3443 This
->ISAXAttributes_iface
.lpVtbl
= &SAXAttributesVtbl
;
3444 This
->IVBSAXAttributes_iface
.lpVtbl
= &VBSAXAttributesVtbl
;
3447 This
->class_version
= version
;
3449 This
->attr
= heap_alloc(default_count
*sizeof(mxattribute
));
3451 This
->allocated
= default_count
;
3453 *ppObj
= &This
->IMXAttributes_iface
;
3455 init_dispex(&This
->dispex
, (IUnknown
*)&This
->IMXAttributes_iface
, &mxattrs_dispex
);
3457 TRACE("returning iface %p\n", *ppObj
);