From: David Kahurani k.kahurani@gmail.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/tests/writer.c | 13 +++---------- dlls/xmllite/writer.c | 34 ++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 6baff9d8a23..d3263c6911d 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -3294,11 +3294,9 @@ static void test_WriteQualifiedName(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"", L"cd"); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, NULL, L"cd"); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"ab", L"xyz@xyz"); @@ -3315,7 +3313,6 @@ static void test_WriteQualifiedName(void) writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
hr = IXmlWriter_WriteQualifiedName(writer, L"ab", L"cd"); - todo_wine ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
IStream_Release(stream); @@ -3328,7 +3325,6 @@ static void test_WriteQualifiedName(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"a@b", L"cd"); - todo_wine ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -3347,13 +3343,12 @@ static void test_WriteQualifiedName(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"ab", L"de"); - todo_wine ok(hr == WR_E_NAMESPACEUNDECLARED, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- CHECK_OUTPUT_TODO(stream, + CHECK_OUTPUT(stream, "<ab:a xmlns:ab="cd">");
IStream_Release(stream); @@ -3371,7 +3366,6 @@ static void test_WriteQualifiedName(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"xy", L"cd"); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -3380,7 +3374,7 @@ static void test_WriteQualifiedName(void) hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- CHECK_OUTPUT_TODO(stream, + CHECK_OUTPUT(stream, "<a xmlns="cd"><b xmlns="gh">xy</b></a>");
IStream_Release(stream); @@ -3396,7 +3390,6 @@ static void test_WriteQualifiedName(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"xy", L"cd"); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -3405,7 +3398,7 @@ static void test_WriteQualifiedName(void) hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- CHECK_OUTPUT_TODO(stream, + CHECK_OUTPUT(stream, "<ab:a xmlns:ab="cd"><ef:b xmlns:ef="gh">ab:xy</ef:b></ab:a>");
IStream_Release(stream); diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 76b4afafbb5..bd315532629 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1858,26 +1858,48 @@ static HRESULT WINAPI xmlwriter_WriteProcessingInstruction(IXmlWriter *iface, LP return hr; }
-static HRESULT WINAPI xmlwriter_WriteQualifiedName(IXmlWriter *iface, LPCWSTR pwszLocalName, - LPCWSTR pwszNamespaceUri) +static HRESULT WINAPI xmlwriter_WriteQualifiedName(IXmlWriter *iface, + const WCHAR *local_name, const WCHAR *uri) { - xmlwriter *This = impl_from_IXmlWriter(iface); + xmlwriter *writer = impl_from_IXmlWriter(iface); + struct ns *ns; + int local_len; + HRESULT hr;
- FIXME("%p %s %s\n", This, wine_dbgstr_w(pwszLocalName), wine_dbgstr_w(pwszNamespaceUri)); + TRACE("%p, %s, %s.\n", iface, wine_dbgstr_w(local_name), wine_dbgstr_w(uri));
- switch (This->state) + if (is_empty_string(local_name)) + return E_INVALIDARG; + + if (FAILED(hr = is_valid_ncname(local_name, &local_len))) + return hr; + + switch (writer->state) { case XmlWriterState_Initial: return E_UNEXPECTED; case XmlWriterState_InvalidEncoding: return MX_E_ENCODING; + case XmlWriterState_Ready: case XmlWriterState_DocClosed: return WR_E_INVALIDACTION; + case XmlWriterState_ElemStarted: + if (FAILED(hr = writer_close_starttag(writer))) return hr; + break; default: ; }
- return E_NOTIMPL; + if (!(ns = writer_find_ns(writer, NULL, uri))) + return WR_E_NAMESPACEUNDECLARED; + + if (ns->prefix) + { + write_output(writer, ns->prefix, ns->prefix_len, &hr); + write_output(writer, L":", 1, &hr); + } + + return write_output(writer, local_name, local_len, &hr); }
static HRESULT WINAPI xmlwriter_WriteRaw(IXmlWriter *iface, LPCWSTR data)