mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
msxml3: Basic support for encoding property.
This commit is contained in:
parent
92668f1d30
commit
e93125f31b
@ -46,6 +46,7 @@ typedef struct _mxwriter
|
||||
LONG ref;
|
||||
|
||||
VARIANT_BOOL standalone;
|
||||
BSTR encoding;
|
||||
|
||||
IStream *dest;
|
||||
} mxwriter;
|
||||
@ -107,6 +108,7 @@ static ULONG WINAPI mxwriter_Release(IMXWriter *iface)
|
||||
if(!ref)
|
||||
{
|
||||
if (This->dest) IStream_Release(This->dest);
|
||||
SysFreeString(This->encoding);
|
||||
heap_free(This);
|
||||
}
|
||||
|
||||
@ -232,16 +234,35 @@ static HRESULT WINAPI mxwriter_get_output(IMXWriter *iface, VARIANT *dest)
|
||||
|
||||
static HRESULT WINAPI mxwriter_put_encoding(IMXWriter *iface, BSTR encoding)
|
||||
{
|
||||
static const WCHAR utf16W[] = {'U','T','F','-','1','6',0};
|
||||
static const WCHAR utf8W[] = {'U','T','F','-','8',0};
|
||||
mxwriter *This = impl_from_IMXWriter( iface );
|
||||
FIXME("(%p)->(%s)\n", This, debugstr_w(encoding));
|
||||
return E_NOTIMPL;
|
||||
|
||||
TRACE("(%p)->(%s)\n", This, debugstr_w(encoding));
|
||||
|
||||
/* FIXME: filter all supported encodings */
|
||||
if (!strcmpW(encoding, utf16W) || !strcmpW(encoding, utf8W))
|
||||
{
|
||||
SysFreeString(This->encoding);
|
||||
This->encoding = SysAllocString(encoding);
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
FIXME("unsupported encoding %s\n", debugstr_w(encoding));
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
|
||||
static HRESULT WINAPI mxwriter_get_encoding(IMXWriter *iface, BSTR *encoding)
|
||||
{
|
||||
mxwriter *This = impl_from_IMXWriter( iface );
|
||||
FIXME("(%p)->(%p)\n", This, encoding);
|
||||
return E_NOTIMPL;
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, encoding);
|
||||
|
||||
if (!encoding) return E_POINTER;
|
||||
|
||||
return return_bstr(This->encoding, encoding);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI mxwriter_put_byteOrderMark(IMXWriter *iface, VARIANT_BOOL writeBOM)
|
||||
@ -532,6 +553,7 @@ static const struct ISAXContentHandlerVtbl mxwriter_saxcontent_vtbl =
|
||||
|
||||
HRESULT MXWriter_create(IUnknown *pUnkOuter, void **ppObj)
|
||||
{
|
||||
static const WCHAR utf16W[] = {'U','T','F','-','1','6',0};
|
||||
mxwriter *This;
|
||||
|
||||
TRACE("(%p,%p)\n", pUnkOuter, ppObj);
|
||||
@ -547,6 +569,8 @@ HRESULT MXWriter_create(IUnknown *pUnkOuter, void **ppObj)
|
||||
This->ref = 1;
|
||||
|
||||
This->standalone = VARIANT_FALSE;
|
||||
This->encoding = SysAllocString(utf16W);
|
||||
|
||||
This->dest = NULL;
|
||||
|
||||
*ppObj = &This->IMXWriter_iface;
|
||||
|
@ -691,9 +691,13 @@ static void test_mxwriter_contenthandler(void)
|
||||
|
||||
static void test_mxwriter_properties(void)
|
||||
{
|
||||
static const WCHAR utf16W[] = {'U','T','F','-','1','6',0};
|
||||
static const WCHAR emptyW[] = {0};
|
||||
static const WCHAR testW[] = {'t','e','s','t',0};
|
||||
IMXWriter *writer;
|
||||
VARIANT_BOOL b;
|
||||
HRESULT hr;
|
||||
BSTR str, str2;
|
||||
|
||||
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IMXWriter, (void**)&writer);
|
||||
@ -716,6 +720,40 @@ static void test_mxwriter_properties(void)
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
ok(b == VARIANT_TRUE, "got %d\n", b);
|
||||
|
||||
hr = IMXWriter_get_encoding(writer, NULL);
|
||||
ok(hr == E_POINTER, "got %08x\n", hr);
|
||||
|
||||
/* UTF-16 is a default setting apparently */
|
||||
str = (void*)0xdeadbeef;
|
||||
hr = IMXWriter_get_encoding(writer, &str);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
ok(lstrcmpW(str, utf16W) == 0, "expected empty string, got %s\n", wine_dbgstr_w(str));
|
||||
|
||||
str2 = (void*)0xdeadbeef;
|
||||
hr = IMXWriter_get_encoding(writer, &str2);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
ok(str != str2, "expected newly allocated, got same %p\n", str);
|
||||
|
||||
SysFreeString(str2);
|
||||
SysFreeString(str);
|
||||
|
||||
/* put empty string */
|
||||
str = SysAllocString(emptyW);
|
||||
hr = IMXWriter_put_encoding(writer, str);
|
||||
ok(hr == E_INVALIDARG, "got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
|
||||
str = (void*)0xdeadbeef;
|
||||
hr = IMXWriter_get_encoding(writer, &str);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
ok(lstrcmpW(str, utf16W) == 0, "expected empty string, got %s\n", wine_dbgstr_w(str));
|
||||
|
||||
/* invalid encoding name */
|
||||
str = SysAllocString(testW);
|
||||
hr = IMXWriter_put_encoding(writer, str);
|
||||
ok(hr == E_INVALIDARG, "got %08x\n", hr);
|
||||
SysFreeString(str);
|
||||
|
||||
IMXWriter_Release(writer);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user