mshtml: Added IHTMLTxtRange::pasteHTML implementation.

This commit is contained in:
Jacek Caban 2014-11-12 16:25:31 +01:00 committed by Alexandre Julliard
parent d619fd2d0e
commit e567f309bf
2 changed files with 55 additions and 2 deletions

View File

@ -2148,6 +2148,17 @@ static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRa
}
}
#define test_range_paste_html(a,b) _test_range_paste_html(__LINE__,a,b)
static void _test_range_paste_html(unsigned line, IHTMLTxtRange *range, const char *html)
{
BSTR str = a2bstr(html);
HRESULT hres;
hres = IHTMLTxtRange_pasteHTML(range, str);
ok_(__FILE__,line)(hres == S_OK, "pasteHTML failed: %08x\n", hres);
SysFreeString(str);
}
#define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
{
@ -5050,6 +5061,22 @@ static void test_txtrange(IHTMLDocument2 *doc)
test_range_text(range, "abc xyz abc 123\r\nit's text");
test_range_parent(range, ET_BODY);
test_range_move(range, wordW, 1, 1);
test_range_moveend(range, characterW, 12, 12);
test_range_text(range, "xyz abc 123");
test_range_collapse(range, VARIANT_TRUE);
test_range_paste_html(range, "<br>paste<br>");
test_range_text(range, NULL);
test_range_moveend(range, characterW, 3, 3);
test_range_text(range, "xyz");
hres = IHTMLTxtRange_moveToElementText(range, body);
ok(hres == S_OK, "moveToElementText failed: %08x\n", hres);
test_range_text(range, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
IHTMLElement_Release(body);
IHTMLTxtRange_Release(range);

View File

@ -17,6 +17,7 @@
*/
#include <stdarg.h>
#include <assert.h>
#define COBJMACROS
@ -1572,8 +1573,33 @@ static HRESULT WINAPI HTMLTxtRange_select(IHTMLTxtRange *iface)
static HRESULT WINAPI HTMLTxtRange_pasteHTML(IHTMLTxtRange *iface, BSTR html)
{
HTMLTxtRange *This = impl_from_IHTMLTxtRange(iface);
FIXME("(%p)->(%s)\n", This, debugstr_w(html));
return E_NOTIMPL;
nsIDOMDocumentFragment *doc_frag;
nsAString nsstr;
nsresult nsres;
TRACE("(%p)->(%s)\n", This, debugstr_w(html));
nsres = nsIDOMRange_Collapse(This->nsrange, TRUE);
assert(nsres == NS_OK);
nsAString_InitDepend(&nsstr, html);
nsres = nsIDOMRange_CreateContextualFragment(This->nsrange, &nsstr, &doc_frag);
nsAString_Finish(&nsstr);
if(NS_FAILED(nsres)) {
ERR("CreateContextualFragment failed: %08x\n", nsres);
return E_FAIL;
}
nsres = nsIDOMRange_InsertNode(This->nsrange, (nsIDOMNode*)doc_frag);
nsIDOMDocumentFragment_Release(doc_frag);
if(NS_FAILED(nsres)) {
ERR("InsertNode failed: %08x\n", nsres);
return E_FAIL;
}
nsres = nsIDOMRange_Collapse(This->nsrange, FALSE);
assert(nsres == NS_OK);
return S_OK;
}
static HRESULT WINAPI HTMLTxtRange_moveToElementText(IHTMLTxtRange *iface, IHTMLElement *element)