2 * IXmlWriter implementation
4 * Copyright 2011 Alistair Leslie-Hughes
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define WIN32_NO_STATUS
22 #define COM_NO_WINDOWS_H
32 #include <wine/debug.h>
34 WINE_DEFAULT_DEBUG_CHANNEL(xmllite
);
36 typedef struct _xmlwriter
38 IXmlWriter IXmlWriter_iface
;
42 static inline xmlwriter
*impl_from_IXmlWriter(IXmlWriter
*iface
)
44 return CONTAINING_RECORD(iface
, xmlwriter
, IXmlWriter_iface
);
47 static HRESULT WINAPI
xmlwriter_QueryInterface(IXmlWriter
*iface
, REFIID riid
, void **ppvObject
)
49 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
51 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
53 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
54 IsEqualGUID(riid
, &IID_IXmlWriter
))
59 IXmlWriter_AddRef(iface
);
64 static ULONG WINAPI
xmlwriter_AddRef(IXmlWriter
*iface
)
66 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
68 return InterlockedIncrement(&This
->ref
);
71 static ULONG WINAPI
xmlwriter_Release(IXmlWriter
*iface
)
73 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
78 ref
= InterlockedDecrement(&This
->ref
);
81 HeapFree(GetProcessHeap(), 0, This
);
87 /*** IXmlWriter methods ***/
88 static HRESULT WINAPI
xmlwriter_SetOutput(IXmlWriter
*iface
, IUnknown
*pOutput
)
90 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
92 FIXME("%p %p\n", This
, pOutput
);
97 static HRESULT WINAPI
xmlwriter_GetProperty(IXmlWriter
*iface
, UINT nProperty
, LONG_PTR
*ppValue
)
99 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
101 FIXME("%p %u %p\n", This
, nProperty
, ppValue
);
106 static HRESULT WINAPI
xmlwriter_SetProperty(IXmlWriter
*iface
, UINT nProperty
, LONG_PTR pValue
)
108 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
110 FIXME("%p %u %lu\n", This
, nProperty
, pValue
);
115 static HRESULT WINAPI
xmlwriter_WriteAttributes(IXmlWriter
*iface
, IXmlReader
*pReader
,
116 BOOL fWriteDefaultAttributes
)
118 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
120 FIXME("%p %p %d\n", This
, pReader
, fWriteDefaultAttributes
);
125 static HRESULT WINAPI
xmlwriter_WriteAttributeString(IXmlWriter
*iface
, LPCWSTR pwszPrefix
,
126 LPCWSTR pwszLocalName
, LPCWSTR pwszNamespaceUri
,
129 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
131 FIXME("%p %s %s %s %s\n", This
, wine_dbgstr_w(pwszPrefix
), wine_dbgstr_w(pwszLocalName
),
132 wine_dbgstr_w(pwszNamespaceUri
), wine_dbgstr_w(pwszValue
));
137 static HRESULT WINAPI
xmlwriter_WriteCData(IXmlWriter
*iface
, LPCWSTR pwszText
)
139 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
141 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszText
));
146 static HRESULT WINAPI
xmlwriter_WriteCharEntity(IXmlWriter
*iface
, WCHAR wch
)
151 static HRESULT WINAPI
xmlwriter_WriteChars(IXmlWriter
*iface
, const WCHAR
*pwch
, UINT cwch
)
153 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
155 FIXME("%p %s %d\n", This
, wine_dbgstr_w(pwch
), cwch
);
160 static HRESULT WINAPI
xmlwriter_WriteComment(IXmlWriter
*iface
, LPCWSTR pwszComment
)
165 static HRESULT WINAPI
xmlwriter_WriteDocType(IXmlWriter
*iface
, LPCWSTR pwszName
, LPCWSTR pwszPublicId
,
166 LPCWSTR pwszSystemId
, LPCWSTR pwszSubset
)
168 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
170 FIXME("%p %s %s %s %s\n", This
, wine_dbgstr_w(pwszName
), wine_dbgstr_w(pwszPublicId
),
171 wine_dbgstr_w(pwszSystemId
), wine_dbgstr_w(pwszSubset
));
176 static HRESULT WINAPI
xmlwriter_WriteElementString(IXmlWriter
*iface
, LPCWSTR pwszPrefix
,
177 LPCWSTR pwszLocalName
, LPCWSTR pwszNamespaceUri
,
180 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
182 FIXME("%p %s %s %s %s\n", This
, wine_dbgstr_w(pwszPrefix
), wine_dbgstr_w(pwszLocalName
),
183 wine_dbgstr_w(pwszNamespaceUri
), wine_dbgstr_w(pwszValue
));
188 static HRESULT WINAPI
xmlwriter_WriteEndDocument(IXmlWriter
*iface
)
190 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
197 static HRESULT WINAPI
xmlwriter_WriteEndElement(IXmlWriter
*iface
)
199 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
206 static HRESULT WINAPI
xmlwriter_WriteEntityRef(IXmlWriter
*iface
, LPCWSTR pwszName
)
208 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
210 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszName
));
215 static HRESULT WINAPI
xmlwriter_WriteFullEndElement(IXmlWriter
*iface
)
217 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
224 static HRESULT WINAPI
xmlwriter_WriteName(IXmlWriter
*iface
, LPCWSTR pwszName
)
226 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
228 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszName
));
233 static HRESULT WINAPI
xmlwriter_WriteNmToken(IXmlWriter
*iface
, LPCWSTR pwszNmToken
)
235 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
237 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszNmToken
));
242 static HRESULT WINAPI
xmlwriter_WriteNode(IXmlWriter
*iface
, IXmlReader
*pReader
,
243 BOOL fWriteDefaultAttributes
)
245 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
247 FIXME("%p %p %d\n", This
, pReader
, fWriteDefaultAttributes
);
252 static HRESULT WINAPI
xmlwriter_WriteNodeShallow(IXmlWriter
*iface
, IXmlReader
*pReader
,
253 BOOL fWriteDefaultAttributes
)
255 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
257 FIXME("%p %p %d\n", This
, pReader
, fWriteDefaultAttributes
);
262 static HRESULT WINAPI
xmlwriter_WriteProcessingInstruction(IXmlWriter
*iface
, LPCWSTR pwszName
,
265 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
267 FIXME("%p %s %s\n", This
, wine_dbgstr_w(pwszName
), wine_dbgstr_w(pwszText
));
272 static HRESULT WINAPI
xmlwriter_WriteQualifiedName(IXmlWriter
*iface
, LPCWSTR pwszLocalName
,
273 LPCWSTR pwszNamespaceUri
)
275 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
277 FIXME("%p %s %s\n", This
, wine_dbgstr_w(pwszLocalName
), wine_dbgstr_w(pwszNamespaceUri
));
282 static HRESULT WINAPI
xmlwriter_WriteRaw(IXmlWriter
*iface
, LPCWSTR pwszData
)
284 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
286 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszData
));
291 static HRESULT WINAPI
xmlwriter_WriteRawChars(IXmlWriter
*iface
, const WCHAR
*pwch
, UINT cwch
)
293 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
295 FIXME("%p %s %d\n", This
, wine_dbgstr_w(pwch
), cwch
);
300 static HRESULT WINAPI
xmlwriter_WriteStartDocument(IXmlWriter
*iface
, XmlStandalone standalone
)
302 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
309 static HRESULT WINAPI
xmlwriter_WriteStartElement(IXmlWriter
*iface
, LPCWSTR pwszPrefix
,
310 LPCWSTR pwszLocalName
, LPCWSTR pwszNamespaceUri
)
312 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
314 FIXME("%p %s %s %s\n", This
, wine_dbgstr_w(pwszPrefix
), wine_dbgstr_w(pwszLocalName
),
315 wine_dbgstr_w(pwszNamespaceUri
));
320 static HRESULT WINAPI
xmlwriter_WriteString(IXmlWriter
*iface
, LPCWSTR pwszText
)
322 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
324 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszText
));
329 static HRESULT WINAPI
xmlwriter_WriteSurrogateCharEntity(IXmlWriter
*iface
, WCHAR wchLow
, WCHAR wchHigh
)
331 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
333 FIXME("%p %d %d\n", This
, wchLow
, wchHigh
);
338 static HRESULT WINAPI
xmlwriter_WriteWhitespace(IXmlWriter
*iface
, LPCWSTR pwszWhitespace
)
340 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
342 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszWhitespace
));
347 static HRESULT WINAPI
xmlwriter_Flush(IXmlWriter
*iface
)
349 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
356 static const struct IXmlWriterVtbl xmlwriter_vtbl
=
358 xmlwriter_QueryInterface
,
362 xmlwriter_GetProperty
,
363 xmlwriter_SetProperty
,
364 xmlwriter_WriteAttributes
,
365 xmlwriter_WriteAttributeString
,
366 xmlwriter_WriteCData
,
367 xmlwriter_WriteCharEntity
,
368 xmlwriter_WriteChars
,
369 xmlwriter_WriteComment
,
370 xmlwriter_WriteDocType
,
371 xmlwriter_WriteElementString
,
372 xmlwriter_WriteEndDocument
,
373 xmlwriter_WriteEndElement
,
374 xmlwriter_WriteEntityRef
,
375 xmlwriter_WriteFullEndElement
,
377 xmlwriter_WriteNmToken
,
379 xmlwriter_WriteNodeShallow
,
380 xmlwriter_WriteProcessingInstruction
,
381 xmlwriter_WriteQualifiedName
,
383 xmlwriter_WriteRawChars
,
384 xmlwriter_WriteStartDocument
,
385 xmlwriter_WriteStartElement
,
386 xmlwriter_WriteString
,
387 xmlwriter_WriteSurrogateCharEntity
,
388 xmlwriter_WriteWhitespace
,
392 HRESULT WINAPI
CreateXmlWriter(REFIID riid
, void **pObject
, IMalloc
*pMalloc
)
396 TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid
), pObject
, pMalloc
);
398 if (pMalloc
) FIXME("custom IMalloc not supported yet\n");
400 if (!IsEqualGUID(riid
, &IID_IXmlWriter
))
402 ERR("Unexpected IID requested -> (%s)\n", wine_dbgstr_guid(riid
));
406 writer
= HeapAlloc(GetProcessHeap(), 0, sizeof (*writer
));
407 if(!writer
) return E_OUTOFMEMORY
;
409 writer
->IXmlWriter_iface
.lpVtbl
= &xmlwriter_vtbl
;
412 *pObject
= &writer
->IXmlWriter_iface
;
414 TRACE("returning iface %p\n", *pObject
);