olewnd.c 9.47 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
 */

#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"
34
#include "resource.h"
35 36 37 38 39 40 41

WINE_DEFAULT_DEBUG_CHANNEL(mshtml);

/**********************************************************
 * IOleInPlaceActiveObject implementation
 */

42 43 44 45
static inline HTMLDocument *impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject *iface)
{
    return CONTAINING_RECORD(iface, HTMLDocument, IOleInPlaceActiveObject_iface);
}
46

47
static HRESULT WINAPI OleInPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface, REFIID riid, void **ppv)
48
{
49
    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
50
    return htmldoc_query_interface(This, riid, ppv);
51 52 53 54
}

static ULONG WINAPI OleInPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
{
55
    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
56
    return htmldoc_addref(This);
57 58 59 60
}

static ULONG WINAPI OleInPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
{
61
    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
62
    return htmldoc_release(This);
63 64 65 66
}

static HRESULT WINAPI OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface, HWND *phwnd)
{
67
    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
Jacek Caban's avatar
Jacek Caban committed
68

69 70 71 72 73
    TRACE("(%p)->(%p)\n", This, phwnd);

    if(!phwnd)
        return E_INVALIDARG;

74
    if(!This->doc_obj->in_place_active) {
Jacek Caban's avatar
Jacek Caban committed
75
        *phwnd = NULL;
76
        return E_FAIL;
Jacek Caban's avatar
Jacek Caban committed
77
    }
78

79
    *phwnd = This->doc_obj->hwnd;
80 81 82 83 84
    return S_OK;
}

static HRESULT WINAPI OleInPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface, BOOL fEnterMode)
{
85
    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
86 87 88 89 90 91
    FIXME("(%p)->(%x)\n", This, fEnterMode);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleInPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface, LPMSG lpmsg)
{
92
    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
93 94 95 96
    FIXME("(%p)->(%p)\n", This, lpmsg);
    return E_NOTIMPL;
}

97 98
static HRESULT WINAPI OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
        BOOL fActivate)
99
{
100
    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
101 102 103

    TRACE("(%p)->(%x)\n", This, fActivate);

104 105
    if(This->doc_obj->hostui)
        IDocHostUIHandler_OnFrameWindowActivate(This->doc_obj->hostui, fActivate);
106 107

    return S_OK;
108 109 110 111
}

static HRESULT WINAPI OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
{
112
    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
113 114 115 116 117 118 119
    FIXME("(%p)->(%x)\n", This, fActivate);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleInPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface, LPCRECT prcBorder,
                                                IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
{
120
    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
121 122 123 124 125 126
    FIXME("(%p)->(%p %p %x)\n", This, prcBorder, pUIWindow, fFrameWindow);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleInPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface, BOOL fEnable)
{
127
    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
    FIXME("(%p)->(%x)\n", This, fEnable);
    return E_NOTIMPL;
}

static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
    OleInPlaceActiveObject_QueryInterface,
    OleInPlaceActiveObject_AddRef,
    OleInPlaceActiveObject_Release,
    OleInPlaceActiveObject_GetWindow,
    OleInPlaceActiveObject_ContextSensitiveHelp,
    OleInPlaceActiveObject_TranslateAccelerator,
    OleInPlaceActiveObject_OnFrameWindowActivate,
    OleInPlaceActiveObject_OnDocWindowActivate,
    OleInPlaceActiveObject_ResizeBorder,
    OleInPlaceActiveObject_EnableModeless
};

/**********************************************************
 * IOleInPlaceObjectWindowless implementation
 */

149 150 151 152
static inline HTMLDocument *impl_from_IOleInPlaceObjectWindowless(IOleInPlaceObjectWindowless *iface)
{
    return CONTAINING_RECORD(iface, HTMLDocument, IOleInPlaceObjectWindowless_iface);
}
153 154

static HRESULT WINAPI OleInPlaceObjectWindowless_QueryInterface(IOleInPlaceObjectWindowless *iface,
155
        REFIID riid, void **ppv)
156
{
157
    HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
158
    return htmldoc_query_interface(This, riid, ppv);
159 160 161 162
}

static ULONG WINAPI OleInPlaceObjectWindowless_AddRef(IOleInPlaceObjectWindowless *iface)
{
163
    HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
164
    return htmldoc_addref(This);
165 166 167 168
}

static ULONG WINAPI OleInPlaceObjectWindowless_Release(IOleInPlaceObjectWindowless *iface)
{
169
    HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
170
    return htmldoc_release(This);
171 172 173 174 175
}

static HRESULT WINAPI OleInPlaceObjectWindowless_GetWindow(IOleInPlaceObjectWindowless *iface,
        HWND *phwnd)
{
176
    HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
177
    return IOleInPlaceActiveObject_GetWindow(&This->IOleInPlaceActiveObject_iface, phwnd);
178 179 180 181 182
}

static HRESULT WINAPI OleInPlaceObjectWindowless_ContextSensitiveHelp(IOleInPlaceObjectWindowless *iface,
        BOOL fEnterMode)
{
183
    HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
184
    return IOleInPlaceActiveObject_ContextSensitiveHelp(&This->IOleInPlaceActiveObject_iface, fEnterMode);
185 186 187 188
}

static HRESULT WINAPI OleInPlaceObjectWindowless_InPlaceDeactivate(IOleInPlaceObjectWindowless *iface)
{
189
    HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
190 191 192

    TRACE("(%p)\n", This);

193
    if(This->doc_obj->ui_active)
194
        IOleDocumentView_UIActivate(&This->IOleDocumentView_iface, FALSE);
195
    This->doc_obj->window_active = FALSE;
196

197
    if(!This->doc_obj->in_place_active)
198 199
        return S_OK;

200
    if(This->doc_obj->frame) {
201
        IOleInPlaceFrame_Release(This->doc_obj->frame);
202 203
        This->doc_obj->frame = NULL;
    }
204

205 206 207
    if(This->doc_obj->hwnd) {
        ShowWindow(This->doc_obj->hwnd, SW_HIDE);
        SetWindowPos(This->doc_obj->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
208 209
    }

210
    This->doc_obj->focus = FALSE;
211
    notif_focus(This->doc_obj);
212

213
    This->doc_obj->in_place_active = FALSE;
214
    if(This->doc_obj->ipsite) {
215 216 217
        IOleInPlaceSiteEx *ipsiteex;
        HRESULT hres;

218
        hres = IOleInPlaceSite_QueryInterface(This->doc_obj->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
219 220 221 222
        if(SUCCEEDED(hres)) {
            IOleInPlaceSiteEx_OnInPlaceDeactivateEx(ipsiteex, TRUE);
            IOleInPlaceSiteEx_Release(ipsiteex);
        }else {
223
            IOleInPlaceSite_OnInPlaceDeactivate(This->doc_obj->ipsite);
224 225
        }
    }
226 227

    return S_OK;
228 229 230 231
}

static HRESULT WINAPI OleInPlaceObjectWindowless_UIDeactivate(IOleInPlaceObjectWindowless *iface)
{
232
    HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
233 234 235 236 237 238 239
    FIXME("(%p)\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleInPlaceObjectWindowless_SetObjectRects(IOleInPlaceObjectWindowless *iface,
        LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{
240
    HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
241 242 243 244 245 246
    FIXME("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleInPlaceObjectWindowless_ReactivateAndUndo(IOleInPlaceObjectWindowless *iface)
{
247
    HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
248 249 250 251 252 253 254
    FIXME("(%p)\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI OleInPlaceObjectWindowless_OnWindowMessage(IOleInPlaceObjectWindowless *iface,
        UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *lpResult)
{
255
    HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
256
    FIXME("(%p)->(%u %lu %lu %p)\n", This, msg, wParam, lParam, lpResult);
257 258 259 260 261 262
    return E_NOTIMPL;
}

static HRESULT WINAPI OleInPlaceObjectWindowless_GetDropTarget(IOleInPlaceObjectWindowless *iface,
        IDropTarget **ppDropTarget)
{
263
    HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
264 265 266 267
    FIXME("(%p)->(%p)\n", This, ppDropTarget);
    return E_NOTIMPL;
}

268
static const IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl = {
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
    OleInPlaceObjectWindowless_QueryInterface,
    OleInPlaceObjectWindowless_AddRef,
    OleInPlaceObjectWindowless_Release,
    OleInPlaceObjectWindowless_GetWindow,
    OleInPlaceObjectWindowless_ContextSensitiveHelp,
    OleInPlaceObjectWindowless_InPlaceDeactivate,
    OleInPlaceObjectWindowless_UIDeactivate,
    OleInPlaceObjectWindowless_SetObjectRects,
    OleInPlaceObjectWindowless_ReactivateAndUndo,
    OleInPlaceObjectWindowless_OnWindowMessage,
    OleInPlaceObjectWindowless_GetDropTarget
};

void HTMLDocument_Window_Init(HTMLDocument *This)
{
284
    This->IOleInPlaceActiveObject_iface.lpVtbl = &OleInPlaceActiveObjectVtbl;
285
    This->IOleInPlaceObjectWindowless_iface.lpVtbl = &OleInPlaceObjectWindowlessVtbl;
286
}