Commit d2737dde authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite/writer: Implement GetProperty().

parent 305db0f6
......@@ -123,7 +123,7 @@ static const char *debugstr_nodetype(XmlNodeType nodetype)
return type_names[nodetype];
}
static const char *debugstr_prop(XmlReaderProperty prop)
static const char *debugstr_reader_prop(XmlReaderProperty prop)
{
static const char * const prop_names[] =
{
......@@ -2537,7 +2537,7 @@ static HRESULT WINAPI xmlreader_GetProperty(IXmlReader* iface, UINT property, LO
{
xmlreader *This = impl_from_IXmlReader(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_prop(property), value);
TRACE("(%p)->(%s %p)\n", This, debugstr_reader_prop(property), value);
if (!value) return E_INVALIDARG;
......@@ -2561,7 +2561,7 @@ static HRESULT WINAPI xmlreader_SetProperty(IXmlReader* iface, UINT property, LO
{
xmlreader *This = impl_from_IXmlReader(iface);
TRACE("(%p)->(%s %lu)\n", This, debugstr_prop(property), value);
TRACE("(%p)->(%s %lu)\n", This, debugstr_reader_prop(property), value);
switch (property)
{
......
......@@ -71,6 +71,7 @@ static void test_writer_create(void)
{
HRESULT hr;
IXmlWriter *writer;
LONG_PTR value;
/* crashes native */
if (0)
......@@ -81,6 +82,28 @@ static void test_writer_create(void)
hr = pCreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
/* check default properties values */
value = 0;
hr = IXmlWriter_GetProperty(writer, XmlWriterProperty_ByteOrderMark, &value);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(value == TRUE, "got %ld\n", value);
value = TRUE;
hr = IXmlWriter_GetProperty(writer, XmlWriterProperty_Indent, &value);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(value == FALSE, "got %ld\n", value);
value = TRUE;
hr = IXmlWriter_GetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, &value);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(value == FALSE, "got %ld\n", value);
value = XmlConformanceLevel_Auto;
hr = IXmlWriter_GetProperty(writer, XmlWriterProperty_ConformanceLevel, &value);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(value == XmlConformanceLevel_Document, "got %ld\n", value);
IXmlWriter_Release(writer);
}
......
......@@ -52,6 +52,10 @@ typedef struct _xmlwriter
LONG ref;
IMalloc *imalloc;
xmlwriteroutput *output;
BOOL indent;
BOOL bom;
BOOL omitxmldecl;
XmlConformanceLevel conformance;
} xmlwriter;
static inline xmlwriter *impl_from_IXmlWriter(IXmlWriter *iface)
......@@ -64,6 +68,23 @@ static inline xmlwriteroutput *impl_from_IXmlWriterOutput(IXmlWriterOutput *ifac
return CONTAINING_RECORD(iface, xmlwriteroutput, IXmlWriterOutput_iface);
}
static const char *debugstr_writer_prop(XmlWriterProperty prop)
{
static const char * const prop_names[] =
{
"MultiLanguage",
"Indent",
"ByteOrderMark",
"OmitXmlDeclaration",
"ConformanceLevel"
};
if (prop > _XmlWriterProperty_Last)
return wine_dbg_sprintf("unknown property=%d", prop);
return prop_names[prop];
}
/* writer output memory allocation functions */
static inline void *writeroutput_alloc(xmlwriteroutput *output, size_t len)
{
......@@ -191,13 +212,34 @@ static HRESULT WINAPI xmlwriter_SetOutput(IXmlWriter *iface, IUnknown *output)
return writeroutput_query_for_stream(This->output);
}
static HRESULT WINAPI xmlwriter_GetProperty(IXmlWriter *iface, UINT nProperty, LONG_PTR *ppValue)
static HRESULT WINAPI xmlwriter_GetProperty(IXmlWriter *iface, UINT property, LONG_PTR *value)
{
xmlwriter *This = impl_from_IXmlWriter(iface);
FIXME("%p %u %p\n", This, nProperty, ppValue);
TRACE("(%p)->(%s %p)\n", This, debugstr_writer_prop(property), value);
return E_NOTIMPL;
if (!value) return E_INVALIDARG;
switch (property)
{
case XmlWriterProperty_Indent:
*value = This->indent;
break;
case XmlWriterProperty_ByteOrderMark:
*value = This->bom;
break;
case XmlWriterProperty_OmitXmlDeclaration:
*value = This->omitxmldecl;
break;
case XmlWriterProperty_ConformanceLevel:
*value = This->conformance;
break;
default:
FIXME("Unimplemented property (%u)\n", property);
return E_NOTIMPL;
}
return S_OK;
}
static HRESULT WINAPI xmlwriter_SetProperty(IXmlWriter *iface, UINT nProperty, LONG_PTR pValue)
......@@ -567,6 +609,10 @@ HRESULT WINAPI CreateXmlWriter(REFIID riid, void **obj, IMalloc *imalloc)
writer->imalloc = imalloc;
if (imalloc) IMalloc_AddRef(imalloc);
writer->output = NULL;
writer->indent = FALSE;
writer->bom = TRUE;
writer->omitxmldecl = FALSE;
writer->conformance = XmlConformanceLevel_Document;
*obj = &writer->IXmlWriter_iface;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment