Commit 4e079d6b authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Initial implementation of transform() method.

parent bb47bab7
...@@ -50,11 +50,12 @@ typedef struct _xslprocessor ...@@ -50,11 +50,12 @@ typedef struct _xslprocessor
IXSLProcessor IXSLProcessor_iface; IXSLProcessor IXSLProcessor_iface;
LONG ref; LONG ref;
xsltemplate *stylesheet;
IXMLDOMNode *input; IXMLDOMNode *input;
IStream *output; IStream *output;
} xslprocessor; } xslprocessor;
static HRESULT XSLProcessor_create(IXSLProcessor**); static HRESULT XSLProcessor_create(xsltemplate*, IXSLProcessor**);
static inline xsltemplate *impl_from_IXSLTemplate( IXSLTemplate *iface ) static inline xsltemplate *impl_from_IXSLTemplate( IXSLTemplate *iface )
{ {
...@@ -226,7 +227,7 @@ static HRESULT WINAPI xsltemplate_createProcessor( IXSLTemplate *iface, ...@@ -226,7 +227,7 @@ static HRESULT WINAPI xsltemplate_createProcessor( IXSLTemplate *iface,
if (!processor) return E_INVALIDARG; if (!processor) return E_INVALIDARG;
return XSLProcessor_create(processor); return XSLProcessor_create(This, processor);
} }
static const struct IXSLTemplateVtbl xsltemplate_vtbl = static const struct IXSLTemplateVtbl xsltemplate_vtbl =
...@@ -308,6 +309,7 @@ static ULONG WINAPI xslprocessor_Release( IXSLProcessor *iface ) ...@@ -308,6 +309,7 @@ static ULONG WINAPI xslprocessor_Release( IXSLProcessor *iface )
{ {
if (This->input) IXMLDOMNode_Release(This->input); if (This->input) IXMLDOMNode_Release(This->input);
if (This->output) IStream_Release(This->output); if (This->output) IStream_Release(This->output);
IXSLTemplate_Release(&This->stylesheet->IXSLTemplate_iface);
heap_free( This ); heap_free( This );
} }
...@@ -516,12 +518,30 @@ static HRESULT WINAPI xslprocessor_get_output( ...@@ -516,12 +518,30 @@ static HRESULT WINAPI xslprocessor_get_output(
static HRESULT WINAPI xslprocessor_transform( static HRESULT WINAPI xslprocessor_transform(
IXSLProcessor *iface, IXSLProcessor *iface,
VARIANT_BOOL *pbool) VARIANT_BOOL *ret)
{ {
xslprocessor *This = impl_from_IXSLProcessor( iface ); xslprocessor *This = impl_from_IXSLProcessor( iface );
HRESULT hr;
BSTR p;
FIXME("(%p)->(%p): stub\n", This, pbool); TRACE("(%p)->(%p)\n", This, ret);
return E_NOTIMPL;
if (!ret) return E_INVALIDARG;
hr = IXMLDOMNode_transformNode(This->input, This->stylesheet->node, &p);
if (hr == S_OK)
{
ULONG len = 0;
/* output to stream */
hr = IStream_Write(This->output, p, SysStringByteLen(p), &len);
*ret = len == SysStringByteLen(p) ? VARIANT_TRUE : VARIANT_FALSE;
SysFreeString(p);
}
else
*ret = VARIANT_FALSE;
return hr;
} }
static HRESULT WINAPI xslprocessor_reset( IXSLProcessor *iface ) static HRESULT WINAPI xslprocessor_reset( IXSLProcessor *iface )
...@@ -601,7 +621,7 @@ static const struct IXSLProcessorVtbl xslprocessor_vtbl = ...@@ -601,7 +621,7 @@ static const struct IXSLProcessorVtbl xslprocessor_vtbl =
xslprocessor_get_stylesheet xslprocessor_get_stylesheet
}; };
HRESULT XSLProcessor_create(IXSLProcessor **ppObj) HRESULT XSLProcessor_create(xsltemplate *template, IXSLProcessor **ppObj)
{ {
xslprocessor *This; xslprocessor *This;
...@@ -615,6 +635,8 @@ HRESULT XSLProcessor_create(IXSLProcessor **ppObj) ...@@ -615,6 +635,8 @@ HRESULT XSLProcessor_create(IXSLProcessor **ppObj)
This->ref = 1; This->ref = 1;
This->input = NULL; This->input = NULL;
This->output = NULL; This->output = NULL;
This->stylesheet = template;
IXSLTemplate_AddRef(&template->IXSLTemplate_iface);
*ppObj = &This->IXSLProcessor_iface; *ppObj = &This->IXSLProcessor_iface;
......
...@@ -7724,9 +7724,17 @@ static void test_xsltemplate(void) ...@@ -7724,9 +7724,17 @@ static void test_xsltemplate(void)
hr = IXSLTemplate_createProcessor(template, NULL); hr = IXSLTemplate_createProcessor(template, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ref = IXSLTemplate_AddRef(template);
IXSLTemplate_Release(template);
ok(ref == 2, "got %d\n", ref);
hr = IXSLTemplate_createProcessor(template, &processor); hr = IXSLTemplate_createProcessor(template, &processor);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ref = IXSLTemplate_AddRef(template);
IXSLTemplate_Release(template);
ok(ref == 3, "got %d\n", ref);
/* input no set yet */ /* input no set yet */
V_VT(&v) = VT_BSTR; V_VT(&v) = VT_BSTR;
V_BSTR(&v) = NULL; V_BSTR(&v) = NULL;
...@@ -7756,6 +7764,9 @@ todo_wine { ...@@ -7756,6 +7764,9 @@ todo_wine {
IStream_Release(stream); IStream_Release(stream);
todo_wine ok(ref == 4, "got %d\n", ref); todo_wine ok(ref == 4, "got %d\n", ref);
hr = IXSLProcessor_transform(processor, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
/* reset and check stream refcount */ /* reset and check stream refcount */
V_VT(&v) = VT_EMPTY; V_VT(&v) = VT_EMPTY;
hr = IXSLProcessor_put_output(processor, v); hr = IXSLProcessor_put_output(processor, v);
......
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