mshtml: Added IHTMLDocument::writeln implementation.

This commit is contained in:
Jacek Caban 2009-09-02 12:27:43 +02:00 committed by Alexandre Julliard
parent 60a85d0749
commit 4eead9d092
2 changed files with 28 additions and 12 deletions

View File

@ -901,17 +901,14 @@ static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray) static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
{ {
HTMLDocument *This = HTMLDOC_THIS(iface);
nsAString nsstr; nsAString nsstr;
VARIANT *var; VARIANT *var;
ULONG i; ULONG i, argc;
nsresult nsres; nsresult nsres;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%p)\n", iface, psarray);
if(!This->nsdoc) { if(!This->nsdoc) {
WARN("NULL nsdoc\n"); WARN("NULL nsdoc\n");
return E_UNEXPECTED; return E_UNEXPECTED;
@ -930,10 +927,14 @@ static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarr
nsAString_Init(&nsstr, NULL); nsAString_Init(&nsstr, NULL);
for(i=0; i < psarray->rgsabound[0].cElements; i++) { argc = psarray->rgsabound[0].cElements;
for(i=0; i < argc; i++) {
if(V_VT(var+i) == VT_BSTR) { if(V_VT(var+i) == VT_BSTR) {
nsAString_SetData(&nsstr, V_BSTR(var+i)); nsAString_SetData(&nsstr, V_BSTR(var+i));
if(!ln || i != argc-1)
nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr); nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr);
else
nsres = nsIDOMHTMLDocument_Writeln(This->nsdoc, &nsstr);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres))
ERR("Write failed: %08x\n", nsres); ERR("Write failed: %08x\n", nsres);
}else { }else {
@ -947,11 +948,22 @@ static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarr
return S_OK; return S_OK;
} }
static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
{
HTMLDocument *This = HTMLDOC_THIS(iface);
TRACE("(%p)->(%p)\n", iface, psarray);
return document_write(This, psarray, FALSE);
}
static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray) static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
{ {
HTMLDocument *This = HTMLDOC_THIS(iface); HTMLDocument *This = HTMLDOC_THIS(iface);
FIXME("(%p)->(%p)\n", This, psarray);
return E_NOTIMPL; TRACE("(%p)->(%p)\n", This, psarray);
return document_write(This, psarray, TRUE);
} }
static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name, static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,

View File

@ -4165,7 +4165,7 @@ static void test_table_elem(IHTMLElement *elem)
IHTMLTable_Release(table); IHTMLTable_Release(table);
} }
static void doc_write(IHTMLDocument2 *doc, const char *text) static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
{ {
SAFEARRAYBOUND dim; SAFEARRAYBOUND dim;
SAFEARRAY *sa; SAFEARRAY *sa;
@ -4181,6 +4181,9 @@ static void doc_write(IHTMLDocument2 *doc, const char *text)
V_BSTR(var) = str = a2bstr(text); V_BSTR(var) = str = a2bstr(text);
SafeArrayUnaccessData(sa); SafeArrayUnaccessData(sa);
if(ln)
hres = IHTMLDocument2_writeln(doc, sa);
else
hres = IHTMLDocument2_write(doc, sa); hres = IHTMLDocument2_write(doc, sa);
ok(hres == S_OK, "write failed: %08x\n", hres); ok(hres == S_OK, "write failed: %08x\n", hres);
@ -4233,7 +4236,8 @@ static void test_iframe_elem(IHTMLElement *elem)
ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n"); ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
IDispatch_Release(disp); IDispatch_Release(disp);
doc_write(content_doc, "<html><head><title>test</title></head><body><br /></body></html>"); doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
doc_write(content_doc, TRUE, "</html>");
hres = IHTMLDocument2_get_all(content_doc, &col); hres = IHTMLDocument2_get_all(content_doc, &col);
ok(hres == S_OK, "get_all failed: %08x\n", hres); ok(hres == S_OK, "get_all failed: %08x\n", hres);