Re: add realization of HTMLDocument_write,HTMLDocument_open
Hi Ivan, Ivan Sinitsin wrote:
This patch adds realization of function HTMLDocument_write, and HTMLDocument_open (it needed for method HTMLDocument_write).
Changelog: This patch adds realization of function HTMLDocument_write, and HTMLDocument_open.
First of all, these should be two separated patches.
static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray) { - FIXME("(%p)->(%p)\n", iface, psarray); - return E_NOTIMPL; + HRESULT hres; + VARIANT *pvar; + IHTMLElement *pbody; + BSTR vtext; + int i; + + vtext = SysAllocString(L""); + + HTMLDocument_get_body(iface,&pbody);
You can't assume that write will be called inside body element.
+ + hres = IHTMLElement_get_innerHTML(pbody, &vtext);
You leak vtext memory here. Also you shouldn't use get_innerHTML at all.
+ if (FAILED(hres)) { + vtext = SysAllocString(L""); + } + + hres=SafeArrayAccessData(psarray, (void **)&pvar); + if (FAILED(hres)) return hres; + for (i=0; i < psarray->rgsabound[0].cElements; i++) { + hres = VarBstrCat(vtext, V_BSTR(&(pvar[i])), &vtext);
You should check if pvar[i] is VT_BSTR before using it.
+ if (FAILED(hres)) { + break; + } + } + + IHTMLElement_put_innerHTML(pbody,vtext);
You can't use put_innerHTML here. It will cause recreating of whole body element content. What you probably want is nsIHTMLDocument::Write. I will send the right write implementation.
+ SysFreeString(vtext); + hres = SafeArrayUnaccessData(psarray); + + return S_OK; }
static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray) @@ -688,8 +715,8 @@ static HRESULT WINAPI HTMLDocument_write static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name, VARIANT features, VARIANT replace, IDispatch **pomWindowResult) { - FIXME("(%p)->(%s %p)\n", iface, debugstr_w(url), pomWindowResult); - return E_NOTIMPL; + TRACE("(%p)->(%s %p)\n", iface, debugstr_w(url), pomWindowResult); + return IHTMLDocument2_QueryInterface(iface, &IID_IDispatch, (void**)pomWindowResult); }
This is obviously not IHTMLDocument2::open implementation. Jacek
participants (1)
-
Jacek Caban