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
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(xmllite
);
32 typedef struct _xmlwriter
34 IXmlWriter IXmlWriter_iface
;
38 static inline xmlwriter
*impl_from_IXmlWriter(IXmlWriter
*iface
)
40 return CONTAINING_RECORD(iface
, xmlwriter
, IXmlWriter_iface
);
43 static HRESULT WINAPI
xmlwriter_QueryInterface(IXmlWriter
*iface
, REFIID riid
, void **ppvObject
)
45 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
47 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
49 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
50 IsEqualGUID(riid
, &IID_IXmlWriter
))
55 IXmlWriter_AddRef(iface
);
60 static ULONG WINAPI
xmlwriter_AddRef(IXmlWriter
*iface
)
62 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
64 return InterlockedIncrement(&This
->ref
);
67 static ULONG WINAPI
xmlwriter_Release(IXmlWriter
*iface
)
69 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
74 ref
= InterlockedDecrement(&This
->ref
);
77 HeapFree(GetProcessHeap(), 0, This
);
83 /*** IXmlWriter methods ***/
84 static HRESULT WINAPI
xmlwriter_SetOutput(IXmlWriter
*iface
, IUnknown
*pOutput
)
86 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
88 FIXME("%p %p\n", This
, pOutput
);
93 static HRESULT WINAPI
xmlwriter_GetProperty(IXmlWriter
*iface
, UINT nProperty
, LONG_PTR
*ppValue
)
95 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
97 FIXME("%p %u %p\n", This
, nProperty
, ppValue
);
102 static HRESULT WINAPI
xmlwriter_SetProperty(IXmlWriter
*iface
, UINT nProperty
, LONG_PTR pValue
)
104 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
106 FIXME("%p %u %lu\n", This
, nProperty
, pValue
);
111 static HRESULT WINAPI
xmlwriter_WriteAttributes(IXmlWriter
*iface
, IXmlReader
*pReader
,
112 BOOL fWriteDefaultAttributes
)
114 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
116 FIXME("%p %p %d\n", This
, pReader
, fWriteDefaultAttributes
);
121 static HRESULT WINAPI
xmlwriter_WriteAttributeString(IXmlWriter
*iface
, LPCWSTR pwszPrefix
,
122 LPCWSTR pwszLocalName
, LPCWSTR pwszNamespaceUri
,
125 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
127 FIXME("%p %s %s %s %s\n", This
, wine_dbgstr_w(pwszPrefix
), wine_dbgstr_w(pwszLocalName
),
128 wine_dbgstr_w(pwszNamespaceUri
), wine_dbgstr_w(pwszValue
));
133 static HRESULT WINAPI
xmlwriter_WriteCData(IXmlWriter
*iface
, LPCWSTR pwszText
)
135 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
137 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszText
));
142 static HRESULT WINAPI
xmlwriter_WriteCharEntity(IXmlWriter
*iface
, WCHAR wch
)
147 static HRESULT WINAPI
xmlwriter_WriteChars(IXmlWriter
*iface
, const WCHAR
*pwch
, UINT cwch
)
149 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
151 FIXME("%p %s %d\n", This
, wine_dbgstr_w(pwch
), cwch
);
156 static HRESULT WINAPI
xmlwriter_WriteComment(IXmlWriter
*iface
, LPCWSTR pwszComment
)
161 static HRESULT WINAPI
xmlwriter_WriteDocType(IXmlWriter
*iface
, LPCWSTR pwszName
, LPCWSTR pwszPublicId
,
162 LPCWSTR pwszSystemId
, LPCWSTR pwszSubset
)
164 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
166 FIXME("%p %s %s %s %s\n", This
, wine_dbgstr_w(pwszName
), wine_dbgstr_w(pwszPublicId
),
167 wine_dbgstr_w(pwszSystemId
), wine_dbgstr_w(pwszSubset
));
172 static HRESULT WINAPI
xmlwriter_WriteElementString(IXmlWriter
*iface
, LPCWSTR pwszPrefix
,
173 LPCWSTR pwszLocalName
, LPCWSTR pwszNamespaceUri
,
176 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
178 FIXME("%p %s %s %s %s\n", This
, wine_dbgstr_w(pwszPrefix
), wine_dbgstr_w(pwszLocalName
),
179 wine_dbgstr_w(pwszNamespaceUri
), wine_dbgstr_w(pwszValue
));
184 static HRESULT WINAPI
xmlwriter_WriteEndDocument(IXmlWriter
*iface
)
186 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
193 static HRESULT WINAPI
xmlwriter_WriteEndElement(IXmlWriter
*iface
)
195 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
202 static HRESULT WINAPI
xmlwriter_WriteEntityRef(IXmlWriter
*iface
, LPCWSTR pwszName
)
204 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
206 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszName
));
211 static HRESULT WINAPI
xmlwriter_WriteFullEndElement(IXmlWriter
*iface
)
213 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
220 static HRESULT WINAPI
xmlwriter_WriteName(IXmlWriter
*iface
, LPCWSTR pwszName
)
222 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
224 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszName
));
229 static HRESULT WINAPI
xmlwriter_WriteNmToken(IXmlWriter
*iface
, LPCWSTR pwszNmToken
)
231 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
233 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszNmToken
));
238 static HRESULT WINAPI
xmlwriter_WriteNode(IXmlWriter
*iface
, IXmlReader
*pReader
,
239 BOOL fWriteDefaultAttributes
)
241 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
243 FIXME("%p %p %d\n", This
, pReader
, fWriteDefaultAttributes
);
248 static HRESULT WINAPI
xmlwriter_WriteNodeShallow(IXmlWriter
*iface
, IXmlReader
*pReader
,
249 BOOL fWriteDefaultAttributes
)
251 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
253 FIXME("%p %p %d\n", This
, pReader
, fWriteDefaultAttributes
);
258 static HRESULT WINAPI
xmlwriter_WriteProcessingInstruction(IXmlWriter
*iface
, LPCWSTR pwszName
,
261 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
263 FIXME("%p %s %s\n", This
, wine_dbgstr_w(pwszName
), wine_dbgstr_w(pwszText
));
268 static HRESULT WINAPI
xmlwriter_WriteQualifiedName(IXmlWriter
*iface
, LPCWSTR pwszLocalName
,
269 LPCWSTR pwszNamespaceUri
)
271 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
273 FIXME("%p %s %s\n", This
, wine_dbgstr_w(pwszLocalName
), wine_dbgstr_w(pwszNamespaceUri
));
278 static HRESULT WINAPI
xmlwriter_WriteRaw(IXmlWriter
*iface
, LPCWSTR pwszData
)
280 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
282 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszData
));
287 static HRESULT WINAPI
xmlwriter_WriteRawChars(IXmlWriter
*iface
, const WCHAR
*pwch
, UINT cwch
)
289 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
291 FIXME("%p %s %d\n", This
, wine_dbgstr_w(pwch
), cwch
);
296 static HRESULT WINAPI
xmlwriter_WriteStartDocument(IXmlWriter
*iface
, XmlStandalone standalone
)
298 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
305 static HRESULT WINAPI
xmlwriter_WriteStartElement(IXmlWriter
*iface
, LPCWSTR pwszPrefix
,
306 LPCWSTR pwszLocalName
, LPCWSTR pwszNamespaceUri
)
308 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
310 FIXME("%p %s %s %s\n", This
, wine_dbgstr_w(pwszPrefix
), wine_dbgstr_w(pwszLocalName
),
311 wine_dbgstr_w(pwszNamespaceUri
));
316 static HRESULT WINAPI
xmlwriter_WriteString(IXmlWriter
*iface
, LPCWSTR pwszText
)
318 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
320 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszText
));
325 static HRESULT WINAPI
xmlwriter_WriteSurrogateCharEntity(IXmlWriter
*iface
, WCHAR wchLow
, WCHAR wchHigh
)
327 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
329 FIXME("%p %d %d\n", This
, wchLow
, wchHigh
);
334 static HRESULT WINAPI
xmlwriter_WriteWhitespace(IXmlWriter
*iface
, LPCWSTR pwszWhitespace
)
336 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
338 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszWhitespace
));
343 static HRESULT WINAPI
xmlwriter_Flush(IXmlWriter
*iface
)
345 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
352 static const struct IXmlWriterVtbl xmlwriter_vtbl
=
354 xmlwriter_QueryInterface
,
358 xmlwriter_GetProperty
,
359 xmlwriter_SetProperty
,
360 xmlwriter_WriteAttributes
,
361 xmlwriter_WriteAttributeString
,
362 xmlwriter_WriteCData
,
363 xmlwriter_WriteCharEntity
,
364 xmlwriter_WriteChars
,
365 xmlwriter_WriteComment
,
366 xmlwriter_WriteDocType
,
367 xmlwriter_WriteElementString
,
368 xmlwriter_WriteEndDocument
,
369 xmlwriter_WriteEndElement
,
370 xmlwriter_WriteEntityRef
,
371 xmlwriter_WriteFullEndElement
,
373 xmlwriter_WriteNmToken
,
375 xmlwriter_WriteNodeShallow
,
376 xmlwriter_WriteProcessingInstruction
,
377 xmlwriter_WriteQualifiedName
,
379 xmlwriter_WriteRawChars
,
380 xmlwriter_WriteStartDocument
,
381 xmlwriter_WriteStartElement
,
382 xmlwriter_WriteString
,
383 xmlwriter_WriteSurrogateCharEntity
,
384 xmlwriter_WriteWhitespace
,
388 HRESULT WINAPI
CreateXmlWriter(REFIID riid
, void **pObject
, IMalloc
*pMalloc
)
392 TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid
), pObject
, pMalloc
);
394 if (pMalloc
) FIXME("custom IMalloc not supported yet\n");
396 if (!IsEqualGUID(riid
, &IID_IXmlWriter
))
398 ERR("Unexpected IID requested -> (%s)\n", wine_dbgstr_guid(riid
));
402 writer
= HeapAlloc(GetProcessHeap(), 0, sizeof (*writer
));
403 if(!writer
) return E_OUTOFMEMORY
;
405 writer
->IXmlWriter_iface
.lpVtbl
= &xmlwriter_vtbl
;
408 *pObject
= &writer
->IXmlWriter_iface
;
410 TRACE("returning iface %p\n", *pObject
);