From 3662980f41be2be3e5ae59062e5445edbe240270 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Tue, 13 Oct 2015 14:41:30 +0800 Subject: [PATCH] mshtml: Add IHTMLEditServices stub implementation. Signed-off-by: Dmitry Timoshkov Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/mshtml/htmldoc.c | 2 + dlls/mshtml/main.c | 1 + dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/service.c | 137 +++++++++++++++++++++++++++++++++++++++++++ dlls/mshtml/tests/htmldoc.c | 4 ++ 5 files changed, 145 insertions(+) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 2b660df7be8..8e53b8bcefc 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -4761,6 +4761,8 @@ static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface) IOleDocumentView_SetInPlaceSite(&This->basedoc.IOleDocumentView_iface, NULL); if(This->undomgr) IOleUndoManager_Release(This->undomgr); + if(This->editsvcs) + IHTMLEditServices_Release(This->editsvcs); if(This->tooltips_hwnd) DestroyWindow(This->tooltips_hwnd); diff --git a/dlls/mshtml/main.c b/dlls/mshtml/main.c index 8938f01e157..0b6f6aca8a5 100644 --- a/dlls/mshtml/main.c +++ b/dlls/mshtml/main.c @@ -554,6 +554,7 @@ const char *debugstr_mshtml_guid(const GUID *iid) X(IID_IHlinkTarget); X(IID_IHTMLDocument6); X(IID_IHTMLDocument7); + X(IID_IHTMLEditServices); X(IID_IHTMLFramesCollection2); X(IID_IHTMLPrivateWindow); X(IID_IHtmlLoadOptions); diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 55375d42b00..c32824e385e 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -602,6 +602,7 @@ struct HTMLDocumentObj { DOCHOSTUIINFO hostinfo; IOleUndoManager *undomgr; + IHTMLEditServices *editsvcs; HWND hwnd; HWND tooltips_hwnd; diff --git a/dlls/mshtml/service.c b/dlls/mshtml/service.c index 8b2a6b7b648..d344293f6e3 100644 --- a/dlls/mshtml/service.c +++ b/dlls/mshtml/service.c @@ -205,6 +205,131 @@ static IOleUndoManager *create_undomgr(void) return &ret->IOleUndoManager_iface; } +typedef struct { + IHTMLEditServices IHTMLEditServices_iface; + LONG ref; +} editsvcs; + +static inline editsvcs *impl_from_IHTMLEditServices(IHTMLEditServices *iface) +{ + return CONTAINING_RECORD(iface, editsvcs, IHTMLEditServices_iface); +} + +static HRESULT WINAPI editsvcs_QueryInterface(IHTMLEditServices *iface, REFIID riid, void **ppv) +{ + editsvcs *This = impl_from_IHTMLEditServices(iface); + + TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); + + if(IsEqualGUID(riid, &IID_IUnknown)) { + *ppv = &This->IHTMLEditServices_iface; + } else if(IsEqualGUID(riid, &IID_IHTMLEditServices)) { + *ppv = &This->IHTMLEditServices_iface; + } else { + *ppv = NULL; + FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static ULONG WINAPI editsvcs_AddRef(IHTMLEditServices *iface) +{ + editsvcs *This = impl_from_IHTMLEditServices(iface); + LONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + return ref; +} + +static ULONG WINAPI editsvcs_Release(IHTMLEditServices *iface) +{ + editsvcs *This = impl_from_IHTMLEditServices(iface); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if(!ref) + heap_free(This); + + return ref; +} + +static HRESULT WINAPI editsvcs_AddDesigner(IHTMLEditServices *iface, + IHTMLEditDesigner *pIDesigner) +{ + editsvcs *This = impl_from_IHTMLEditServices(iface); + FIXME("(%p)->(%p)\n", This, pIDesigner); + return E_NOTIMPL; +} + +static HRESULT WINAPI editsvcs_RemoveDesigner(IHTMLEditServices *iface, + IHTMLEditDesigner *pIDesigner) +{ + editsvcs *This = impl_from_IHTMLEditServices(iface); + FIXME("(%p)->(%p)\n", This, pIDesigner); + return E_NOTIMPL; +} + +static HRESULT WINAPI editsvcs_GetSelectionServices(IHTMLEditServices *iface, + IMarkupContainer *pIContainer, ISelectionServices **ppSelSvc) +{ + editsvcs *This = impl_from_IHTMLEditServices(iface); + FIXME("(%p)->(%p,%p)\n", This, pIContainer, ppSelSvc); + return E_NOTIMPL; +} + +static HRESULT WINAPI editsvcs_MoveToSelectionAnchor(IHTMLEditServices *iface, + IMarkupPointer *pIStartAnchor) +{ + editsvcs *This = impl_from_IHTMLEditServices(iface); + FIXME("(%p)->(%p)\n", This, pIStartAnchor); + return E_NOTIMPL; +} + +static HRESULT WINAPI editsvcs_MoveToSelectionEnd(IHTMLEditServices *iface, + IMarkupPointer *pIEndAnchor) +{ + editsvcs *This = impl_from_IHTMLEditServices(iface); + FIXME("(%p)->(%p)\n", This, pIEndAnchor); + return E_NOTIMPL; +} + +static HRESULT WINAPI editsvcs_SelectRange(IHTMLEditServices *iface, + IMarkupPointer *pStart, IMarkupPointer *pEnd, SELECTION_TYPE eType) +{ + editsvcs *This = impl_from_IHTMLEditServices(iface); + FIXME("(%p)->(%p,%p,%#x)\n", This, pStart, pEnd, eType); + return E_NOTIMPL; +} + +static const IHTMLEditServicesVtbl editsvcsVtbl = { + editsvcs_QueryInterface, + editsvcs_AddRef, + editsvcs_Release, + editsvcs_AddDesigner, + editsvcs_RemoveDesigner, + editsvcs_GetSelectionServices, + editsvcs_MoveToSelectionAnchor, + editsvcs_MoveToSelectionEnd, + editsvcs_SelectRange, +}; + +static IHTMLEditServices *create_editsvcs(void) +{ + editsvcs *ret = heap_alloc(sizeof(*ret)); + + if (ret) { + ret->IHTMLEditServices_iface.lpVtbl = &editsvcsVtbl; + ret->ref = 1; + return &ret->IHTMLEditServices_iface; + } + + return NULL; +} + /********************************************************** * IServiceProvider implementation */ @@ -264,6 +389,18 @@ static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFG return IWindowForBindingUI_QueryInterface(&This->doc_obj->IWindowForBindingUI_iface, riid, ppv); } + if(IsEqualGUID(&SID_SHTMLEditServices, guidService)) { + TRACE("SID_SHTMLEditServices\n"); + + if(!This->doc_obj->editsvcs) + This->doc_obj->editsvcs = create_editsvcs(); + + if (!This->doc_obj->editsvcs) + return E_OUTOFMEMORY; + + return IHTMLEditServices_QueryInterface(This->doc_obj->editsvcs, riid, ppv); + } + TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv); if(This->doc_obj->client) { diff --git a/dlls/mshtml/tests/htmldoc.c b/dlls/mshtml/tests/htmldoc.c index 899cd739afa..bdb3eb2a760 100644 --- a/dlls/mshtml/tests/htmldoc.c +++ b/dlls/mshtml/tests/htmldoc.c @@ -8498,8 +8498,12 @@ static void test_ServiceProvider(void) hres = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IUnknown, (void**)&unk); ok(hres == S_OK, "got 0x%08x\n", hres); ok(iface_cmp((IUnknown*)doc, unk), "got wrong pointer\n"); + IUnknown_Release(unk); + hres = IServiceProvider_QueryService(provider, &SID_SHTMLEditServices, &IID_IHTMLEditServices, (void**)&unk); + ok(hres == S_OK, "QueryService(HTMLEditServices) failed: %08x\n", hres); IUnknown_Release(unk); + IServiceProvider_Release(provider); release_document(doc); } -- 2.11.4.GIT