service.c 8.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright 2005 Jacek Caban
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
 */

#include "config.h"

#include <stdarg.h>
#include <stdio.h>

#define COBJMACROS

#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"

#include "wine/debug.h"

#include "mshtml_private.h"

WINE_DEFAULT_DEBUG_CHANNEL(mshtml);

37
typedef struct {
38
    IOleUndoManager IOleUndoManager_iface;
39 40 41 42

    LONG ref;
} UndoManager;

43 44 45 46
static inline UndoManager *impl_from_IOleUndoManager(IOleUndoManager *iface)
{
    return CONTAINING_RECORD(iface, UndoManager, IOleUndoManager_iface);
}
47 48 49

static HRESULT WINAPI OleUndoManager_QueryInterface(IOleUndoManager *iface, REFIID riid, void **ppv)
{
50
    UndoManager *This = impl_from_IOleUndoManager(iface);
51 52 53

    if(IsEqualGUID(riid, &IID_IUnknown)) {
        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
54
        *ppv = &This->IOleUndoManager_iface;
55 56
    }else if(IsEqualGUID(riid, &IID_IOleUndoManager)) {
        TRACE("(%p)->(IID_IOleUndoManager %p)\n", This, ppv);
57
        *ppv = &This->IOleUndoManager_iface;
58 59 60 61
    }else {
        *ppv = NULL;
        FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
        return E_NOINTERFACE;
62 63
    }

64 65
    IUnknown_AddRef((IUnknown*)*ppv);
    return S_OK;
66 67 68 69
}

static ULONG WINAPI OleUndoManager_AddRef(IOleUndoManager *iface)
{
70
    UndoManager *This = impl_from_IOleUndoManager(iface);
71 72 73 74 75 76 77 78 79
    LONG ref = InterlockedIncrement(&This->ref);

    TRACE("(%p) ref=%d\n", This, ref);

    return ref;
}

static ULONG WINAPI OleUndoManager_Release(IOleUndoManager *iface)
{
80
    UndoManager *This = impl_from_IOleUndoManager(iface);
81 82 83 84 85
    LONG ref = InterlockedDecrement(&This->ref);

    TRACE("(%p) ref=%d\n", This, ref);

    if(!ref)
86
        heap_free(This);
87 88 89 90 91 92

    return ref;
}

static HRESULT WINAPI OleUndoManager_Open(IOleUndoManager *iface, IOleParentUndoUnit *pPUU)
{
93
    UndoManager *This = impl_from_IOleUndoManager(iface);
94 95 96 97 98 99 100
    FIXME("(%p)->(%p)\n", This, pPUU);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleUndoManager_Close(IOleUndoManager *iface, IOleParentUndoUnit *pPUU,
        BOOL fCommit)
{
101
    UndoManager *This = impl_from_IOleUndoManager(iface);
102 103 104 105 106 107
    FIXME("(%p)->(%p %x)\n", This, pPUU, fCommit);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleUndoManager_Add(IOleUndoManager *iface, IOleUndoUnit *pUU)
{
108
    UndoManager *This = impl_from_IOleUndoManager(iface);
109 110 111 112 113 114
    FIXME("(%p)->(%p)\n", This, pUU);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleUndoManager_GetOpenParentState(IOleUndoManager *iface, DWORD *pdwState)
{
115
    UndoManager *This = impl_from_IOleUndoManager(iface);
116 117 118 119 120 121
    FIXME("(%p)->(%p)\n", This, pdwState);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleUndoManager_DiscardFrom(IOleUndoManager *iface, IOleUndoUnit *pUU)
{
122
    UndoManager *This = impl_from_IOleUndoManager(iface);
123 124 125 126 127 128
    FIXME("(%p)->(%p)\n", This, pUU);
    return S_OK;
}

static HRESULT WINAPI OleUndoManager_UndoTo(IOleUndoManager *iface, IOleUndoUnit *pUU)
{
129
    UndoManager *This = impl_from_IOleUndoManager(iface);
130 131 132 133 134 135
    FIXME("(%p)->(%p)\n", This, pUU);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleUndoManager_RedoTo(IOleUndoManager *iface, IOleUndoUnit *pUU)
{
136
    UndoManager *This = impl_from_IOleUndoManager(iface);
137 138 139 140 141 142 143
    FIXME("(%p)->(%p)\n", This, pUU);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleUndoManager_EnumUndoable(IOleUndoManager *iface,
        IEnumOleUndoUnits **ppEnum)
{
144
    UndoManager *This = impl_from_IOleUndoManager(iface);
145 146 147 148 149 150 151
    FIXME("(%p)->(%p)\n", This, ppEnum);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleUndoManager_EnumRedoable(IOleUndoManager *iface,
        IEnumOleUndoUnits **ppEnum)
{
152
    UndoManager *This = impl_from_IOleUndoManager(iface);
153 154 155 156 157 158
    FIXME("(%p)->(%p)\n", This, ppEnum);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleUndoManager_GetLastUndoDescription(IOleUndoManager *iface, BSTR *pBstr)
{
159
    UndoManager *This = impl_from_IOleUndoManager(iface);
160 161 162 163 164 165
    FIXME("(%p)->(%p)\n", This, pBstr);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleUndoManager_GetLastRedoDescription(IOleUndoManager *iface, BSTR *pBstr)
{
166
    UndoManager *This = impl_from_IOleUndoManager(iface);
167 168 169 170 171 172
    FIXME("(%p)->(%p)\n", This, pBstr);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleUndoManager_Enable(IOleUndoManager *iface, BOOL fEnable)
{
173
    UndoManager *This = impl_from_IOleUndoManager(iface);
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
    FIXME("(%p)->(%x)\n", This, fEnable);
    return E_NOTIMPL;
}

static const IOleUndoManagerVtbl OleUndoManagerVtbl = {
    OleUndoManager_QueryInterface,
    OleUndoManager_AddRef,
    OleUndoManager_Release,
    OleUndoManager_Open,
    OleUndoManager_Close,
    OleUndoManager_Add,
    OleUndoManager_GetOpenParentState,
    OleUndoManager_DiscardFrom,
    OleUndoManager_UndoTo,
    OleUndoManager_RedoTo,
    OleUndoManager_EnumUndoable,
    OleUndoManager_EnumRedoable,
    OleUndoManager_GetLastUndoDescription,
    OleUndoManager_GetLastRedoDescription,
    OleUndoManager_Enable
};

static IOleUndoManager *create_undomgr(void)
{
198
    UndoManager *ret = heap_alloc(sizeof(UndoManager));
199

200
    ret->IOleUndoManager_iface.lpVtbl = &OleUndoManagerVtbl;
201 202
    ret->ref = 1;

203
    return &ret->IOleUndoManager_iface;
204 205
}

206
/**********************************************************
Austin English's avatar
Austin English committed
207
 * IServiceProvider implementation
208 209
 */

210 211 212 213
static inline HTMLDocument *impl_from_IServiceProvider(IServiceProvider *iface)
{
    return CONTAINING_RECORD(iface, HTMLDocument, IServiceProvider_iface);
}
214 215 216

static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
{
217
    HTMLDocument *This = impl_from_IServiceProvider(iface);
218
    return htmldoc_query_interface(This, riid, ppv);
219 220 221 222
}

static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
{
223
    HTMLDocument *This = impl_from_IServiceProvider(iface);
224
    return htmldoc_addref(This);
225 226 227 228
}

static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
{
229
    HTMLDocument *This = impl_from_IServiceProvider(iface);
230
    return htmldoc_release(This);
231 232 233 234 235
}

static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
        REFIID riid, void **ppv)
{
236 237
    HTMLDocument *This = impl_from_IServiceProvider(iface);

238 239 240 241
    if(IsEqualGUID(&CLSID_CMarkup, guidService)) {
        FIXME("(%p)->(CLSID_CMarkup %s %p)\n", This, debugstr_guid(riid), ppv);
        return E_NOINTERFACE;
    }
242

243 244
    if(IsEqualGUID(&SID_SOleUndoManager, guidService)) {
        TRACE("SID_SOleUndoManager\n");
245

246 247
        if(!This->doc_obj->undomgr)
            This->doc_obj->undomgr = create_undomgr();
248

249
        return IOleUndoManager_QueryInterface(This->doc_obj->undomgr, riid, ppv);
250 251
    }

252 253 254 255 256
    if(IsEqualGUID(&SID_SContainerDispatch, guidService)) {
        TRACE("SID_SContainerDispatch\n");
        return IHTMLDocument2_QueryInterface(&This->IHTMLDocument2_iface, riid, ppv);
    }

257 258 259 260 261
    if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) {
        TRACE("IID_IWindowForBindingUI\n");
        return IWindowForBindingUI_QueryInterface(&This->doc_obj->IWindowForBindingUI_iface, riid, ppv);
    }

262 263
    TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);

264 265 266
    if(This->doc_obj->client) {
        HRESULT hres;

267 268 269
        hres = do_query_service((IUnknown*)This->doc_obj->client, guidService, riid, ppv);
        if(SUCCEEDED(hres))
            return hres;
270 271
    }

272
    FIXME("unknown service %s\n", debugstr_guid(guidService));
273
    return E_NOINTERFACE;
274 275 276 277 278 279 280 281 282 283 284
}

static const IServiceProviderVtbl ServiceProviderVtbl = {
    ServiceProvider_QueryInterface,
    ServiceProvider_AddRef,
    ServiceProvider_Release,
    ServiceProvider_QueryService
};

void HTMLDocument_Service_Init(HTMLDocument *This)
{
285
    This->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
286
}