mshtml: Implement IHTMLBody get/put_Text.

This commit is contained in:
Alistair Leslie-Hughes 2008-09-17 20:41:47 +10:00 committed by Alexandre Julliard
parent b64b5ea5ea
commit 995835e113
2 changed files with 72 additions and 4 deletions

View File

@ -300,15 +300,46 @@ static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIA
static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
{
HTMLBodyElement *This = HTMLBODY_THIS(iface);
FIXME("(%p)->()\n", This);
return E_NOTIMPL;
nsAString text;
nsresult nsres;
TRACE("(%p)->(v%d)\n", This, V_VT(&v));
if(!variant_to_nscolor(&v, &text))
return S_OK;
nsres = nsIDOMHTMLBodyElement_SetText(This->nsbody, &text);
nsAString_Finish(&text);
return S_OK;
}
static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
{
HTMLBodyElement *This = HTMLBODY_THIS(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
nsAString text;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&text, NULL);
V_VT(p) = VT_BSTR;
V_BSTR(p) = NULL;
nsres = nsIDOMHTMLBodyElement_GetText(This->nsbody, &text);
if(NS_SUCCEEDED(nsres))
{
const PRUnichar *sText;
nsAString_GetData(&text, &sText);
V_VT(p) = VT_BSTR;
V_BSTR(p) = SysAllocString(sText);
}
nsAString_Finish(&text);
return S_OK;
}
static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)

View File

@ -2064,6 +2064,10 @@ static void test_default_body(IHTMLBodyElement *body)
long l;
BSTR bstr;
HRESULT hres;
VARIANT v;
WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
WCHAR sResInvalid[] = {'#','0','0','a','0','d','0',0};
bstr = (void*)0xdeadbeef;
hres = IHTMLBodyElement_get_background(body, &bstr);
@ -2077,6 +2081,39 @@ static void test_default_body(IHTMLBodyElement *body)
l = elem_get_scroll_top((IUnknown*)body);
ok(!l, "scrollTop = %ld\n", l);
elem_get_scroll_left((IUnknown*)body);
/* get_text tests */
hres = IHTMLBodyElement_get_text(body, &v);
ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
ok(bstr == NULL, "bstr != NULL\n");
/* get_text - Invalid Text */
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = SysAllocString(sTextInvalid);
hres = IHTMLBodyElement_put_text(body, v);
ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
V_VT(&v) = VT_NULL;
hres = IHTMLBodyElement_get_text(body, &v);
ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
ok(!lstrcmpW(sResInvalid, V_BSTR(&v)), "bstr != sResInvalid\n");
VariantClear(&v);
/* get_text - Valid Text */
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = SysAllocString(sBodyText);
hres = IHTMLBodyElement_put_text(body, v);
ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
V_VT(&v) = VT_NULL;
hres = IHTMLBodyElement_get_text(body, &v);
ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
ok(lstrcmpW(bstr, V_BSTR(&v)), "bstr != V_BSTR(&v)\n");
VariantClear(&v);
}
static void test_body_funs(IHTMLBodyElement *body)