diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index abe7995d616..6346dac54a0 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -193,6 +193,7 @@ typedef struct event_target_t event_target_t; XIID(IHTMLTextAreaElement) \ XIID(IHTMLTextContainer) \ XIID(IHTMLTitleElement) \ + XIID(IHTMLTxtRange) \ XIID(IHTMLUniqueName) \ XIID(IHTMLWindow2) \ XIID(IHTMLWindow3) \ diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index f0f03b81aef..c4766dc9b3d 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -4827,6 +4827,8 @@ static void test_txtrange(IHTMLDocument2 *doc) body_range = test_create_body_range(doc); + test_disp((IUnknown*)body_range, &IID_IHTMLTxtRange, "[object]"); + test_range_text(body_range, "test abc 123\r\nit's text"); hres = IHTMLTxtRange_duplicate(body_range, &range); diff --git a/dlls/mshtml/txtrange.c b/dlls/mshtml/txtrange.c index e88d9604445..6b57eb27178 100644 --- a/dlls/mshtml/txtrange.c +++ b/dlls/mshtml/txtrange.c @@ -36,6 +36,7 @@ static const WCHAR brW[] = {'b','r',0}; static const WCHAR hrW[] = {'h','r',0}; typedef struct { + DispatchEx dispex; IHTMLTxtRange IHTMLTxtRange_iface; IOleCommandTarget IOleCommandTarget_iface; @@ -1004,29 +1005,24 @@ static HRESULT WINAPI HTMLTxtRange_QueryInterface(IHTMLTxtRange *iface, REFIID r { HTMLTxtRange *This = impl_from_IHTMLTxtRange(iface); - *ppv = NULL; + TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); if(IsEqualGUID(&IID_IUnknown, riid)) { - TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); - *ppv = &This->IHTMLTxtRange_iface; - }else if(IsEqualGUID(&IID_IDispatch, riid)) { - TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv); *ppv = &This->IHTMLTxtRange_iface; }else if(IsEqualGUID(&IID_IHTMLTxtRange, riid)) { - TRACE("(%p)->(IID_IHTMLTxtRange %p)\n", This, ppv); *ppv = &This->IHTMLTxtRange_iface; }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) { - TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv); *ppv = &This->IOleCommandTarget_iface; + }else if(dispex_query_interface(&This->dispex, riid, ppv)) { + return *ppv ? S_OK : E_NOINTERFACE; + }else { + *ppv = NULL; + WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + return E_NOINTERFACE; } - if(*ppv) { - IUnknown_AddRef((IUnknown*)*ppv); - return S_OK; - } - - WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); - return E_NOINTERFACE; + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; } static ULONG WINAPI HTMLTxtRange_AddRef(IHTMLTxtRange *iface) @@ -1051,6 +1047,7 @@ static ULONG WINAPI HTMLTxtRange_Release(IHTMLTxtRange *iface) nsIDOMRange_Release(This->nsrange); if(This->doc) list_remove(&This->entry); + release_dispex(&This->dispex); heap_free(This); } @@ -1060,16 +1057,16 @@ static ULONG WINAPI HTMLTxtRange_Release(IHTMLTxtRange *iface) static HRESULT WINAPI HTMLTxtRange_GetTypeInfoCount(IHTMLTxtRange *iface, UINT *pctinfo) { HTMLTxtRange *This = impl_from_IHTMLTxtRange(iface); - FIXME("(%p)->(%p)\n", This, pctinfo); - return E_NOTIMPL; + + return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo); } static HRESULT WINAPI HTMLTxtRange_GetTypeInfo(IHTMLTxtRange *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { HTMLTxtRange *This = impl_from_IHTMLTxtRange(iface); - FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo); - return E_NOTIMPL; + + return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo); } static HRESULT WINAPI HTMLTxtRange_GetIDsOfNames(IHTMLTxtRange *iface, REFIID riid, @@ -1077,9 +1074,9 @@ static HRESULT WINAPI HTMLTxtRange_GetIDsOfNames(IHTMLTxtRange *iface, REFIID ri LCID lcid, DISPID *rgDispId) { HTMLTxtRange *This = impl_from_IHTMLTxtRange(iface); - FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, - lcid, rgDispId); - return E_NOTIMPL; + + return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, + cNames, lcid, rgDispId); } static HRESULT WINAPI HTMLTxtRange_Invoke(IHTMLTxtRange *iface, DISPID dispIdMember, @@ -1087,9 +1084,9 @@ static HRESULT WINAPI HTMLTxtRange_Invoke(IHTMLTxtRange *iface, DISPID dispIdMem VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { HTMLTxtRange *This = impl_from_IHTMLTxtRange(iface); - FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), - lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); - return E_NOTIMPL; + + return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); } static HRESULT WINAPI HTMLTxtRange_get_htmlText(IHTMLTxtRange *iface, BSTR *p) @@ -1850,6 +1847,17 @@ static const IOleCommandTargetVtbl OleCommandTargetVtbl = { RangeCommandTarget_Exec }; +static const tid_t HTMLTxtRange_iface_tids[] = { + IHTMLTxtRange_tid, + 0 +}; +static dispex_static_data_t HTMLTxtRange_dispex = { + NULL, + IHTMLTxtRange_tid, + NULL, + HTMLTxtRange_iface_tids +}; + HRESULT HTMLTxtRange_Create(HTMLDocumentNode *doc, nsIDOMRange *nsrange, IHTMLTxtRange **p) { HTMLTxtRange *ret; @@ -1858,6 +1866,8 @@ HRESULT HTMLTxtRange_Create(HTMLDocumentNode *doc, nsIDOMRange *nsrange, IHTMLTx if(!ret) return E_OUTOFMEMORY; + init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLTxtRange_iface, &HTMLTxtRange_dispex); + ret->IHTMLTxtRange_iface.lpVtbl = &HTMLTxtRangeVtbl; ret->IOleCommandTarget_iface.lpVtbl = &OleCommandTargetVtbl; ret->ref = 1;