Fix protocol test on winxp.
[wine] / dlls / mshtml / olewnd.c
1 /*
2  * Copyright 2005 Jacek Caban
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30
31 #include "wine/debug.h"
32
33 #include "mshtml_private.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36
37 /**********************************************************
38  * IOleInPlaceActiveObject implementation
39  */
40
41 #define ACTOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, OleInPlaceActiveObject, iface)
42
43 static HRESULT WINAPI OleInPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface, REFIID riid, void **ppvObject)
44 {
45     HTMLDocument *This = ACTOBJ_THIS(iface);
46     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
47 }
48
49 static ULONG WINAPI OleInPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
50 {
51     HTMLDocument *This = ACTOBJ_THIS(iface);
52     return IHTMLDocument2_AddRef(HTMLDOC(This));
53 }
54
55 static ULONG WINAPI OleInPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
56 {
57     HTMLDocument *This = ACTOBJ_THIS(iface);
58     return IHTMLDocument2_Release(HTMLDOC(This));
59 }
60
61 static HRESULT WINAPI OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface, HWND *phwnd)
62 {
63     HTMLDocument *This = ACTOBJ_THIS(iface);
64
65     TRACE("(%p)->(%p)\n", This, phwnd);
66
67     if(!phwnd)
68         return E_INVALIDARG;
69
70     if(!This->in_place_active) {
71         *phwnd = NULL;
72         return E_FAIL;
73     }
74
75     *phwnd = This->hwnd;
76     return S_OK;
77 }
78
79 static HRESULT WINAPI OleInPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface, BOOL fEnterMode)
80 {
81     HTMLDocument *This = ACTOBJ_THIS(iface);
82     FIXME("(%p)->(%x)\n", This, fEnterMode);
83     return E_NOTIMPL;
84 }
85
86 static HRESULT WINAPI OleInPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface, LPMSG lpmsg)
87 {
88     HTMLDocument *This = ACTOBJ_THIS(iface);
89     FIXME("(%p)->(%p)\n", This, lpmsg);
90     return E_NOTIMPL;
91 }
92
93 static HRESULT WINAPI OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
94 {
95     HTMLDocument *This = ACTOBJ_THIS(iface);
96     FIXME("(%p)->(%x)\n", This, fActivate);
97     return E_NOTIMPL;
98 }
99
100 static HRESULT WINAPI OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
101 {
102     HTMLDocument *This = ACTOBJ_THIS(iface);
103     FIXME("(%p)->(%x)\n", This, fActivate);
104     return E_NOTIMPL;
105 }
106
107 static HRESULT WINAPI OleInPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface, LPCRECT prcBorder,
108                                                 IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
109 {
110     HTMLDocument *This = ACTOBJ_THIS(iface);
111     FIXME("(%p)->(%p %p %x)\n", This, prcBorder, pUIWindow, fFrameWindow);
112     return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI OleInPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface, BOOL fEnable)
116 {
117     HTMLDocument *This = ACTOBJ_THIS(iface);
118     FIXME("(%p)->(%x)\n", This, fEnable);
119     return E_NOTIMPL;
120 }
121
122 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
123     OleInPlaceActiveObject_QueryInterface,
124     OleInPlaceActiveObject_AddRef,
125     OleInPlaceActiveObject_Release,
126     OleInPlaceActiveObject_GetWindow,
127     OleInPlaceActiveObject_ContextSensitiveHelp,
128     OleInPlaceActiveObject_TranslateAccelerator,
129     OleInPlaceActiveObject_OnFrameWindowActivate,
130     OleInPlaceActiveObject_OnDocWindowActivate,
131     OleInPlaceActiveObject_ResizeBorder,
132     OleInPlaceActiveObject_EnableModeless
133 };
134
135 #undef ACTOBJ_THIS
136
137 /**********************************************************
138  * IOleInPlaceObjectWindowless implementation
139  */
140
141 #define OLEINPLACEWND_THIS(iface) DEFINE_THIS(HTMLDocument, OleInPlaceObjectWindowless, iface)
142
143 static HRESULT WINAPI OleInPlaceObjectWindowless_QueryInterface(IOleInPlaceObjectWindowless *iface,
144         REFIID riid, void **ppvObject)
145 {
146     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
147     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
148 }
149
150 static ULONG WINAPI OleInPlaceObjectWindowless_AddRef(IOleInPlaceObjectWindowless *iface)
151 {
152     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
153     return IHTMLDocument2_AddRef(HTMLDOC(This));
154 }
155
156 static ULONG WINAPI OleInPlaceObjectWindowless_Release(IOleInPlaceObjectWindowless *iface)
157 {
158     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
159     return IHTMLDocument2_Release(HTMLDOC(This));
160 }
161
162 static HRESULT WINAPI OleInPlaceObjectWindowless_GetWindow(IOleInPlaceObjectWindowless *iface,
163         HWND *phwnd)
164 {
165     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
166     return IOleWindow_GetWindow(OLEWIN(This), phwnd);
167 }
168
169 static HRESULT WINAPI OleInPlaceObjectWindowless_ContextSensitiveHelp(IOleInPlaceObjectWindowless *iface,
170         BOOL fEnterMode)
171 {
172     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
173     return IOleWindow_ContextSensitiveHelp(OLEWIN(This), fEnterMode);
174 }
175
176 static HRESULT WINAPI OleInPlaceObjectWindowless_InPlaceDeactivate(IOleInPlaceObjectWindowless *iface)
177 {
178     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
179
180     TRACE("(%p)\n", This);
181
182     if(!This->in_place_active)
183         return S_OK;
184
185     if(This->frame)
186         IOleInPlaceFrame_Release(This->frame);
187
188     if(This->hwnd) {
189         ShowWindow(This->hwnd, SW_HIDE);
190         SetWindowPos(This->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
191     }
192
193     This->in_place_active = FALSE;
194     if(This->ipsite)
195         IOleInPlaceSite_OnInPlaceDeactivate(This->ipsite);
196
197     return S_OK;
198 }
199
200 static HRESULT WINAPI OleInPlaceObjectWindowless_UIDeactivate(IOleInPlaceObjectWindowless *iface)
201 {
202     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
203     FIXME("(%p)\n", This);
204     return E_NOTIMPL;
205 }
206
207 static HRESULT WINAPI OleInPlaceObjectWindowless_SetObjectRects(IOleInPlaceObjectWindowless *iface,
208         LPCRECT lprcPosRect, LPCRECT lprcClipRect)
209 {
210     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
211     FIXME("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
212     return E_NOTIMPL;
213 }
214
215 static HRESULT WINAPI OleInPlaceObjectWindowless_ReactivateAndUndo(IOleInPlaceObjectWindowless *iface)
216 {
217     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
218     FIXME("(%p)\n", This);
219     return E_NOTIMPL;
220 }
221
222 static HRESULT WINAPI OleInPlaceObjectWindowless_OnWindowMessage(IOleInPlaceObjectWindowless *iface,
223         UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *lpResult)
224 {
225     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
226     FIXME("(%p)->(%u %u %lu %p)\n", This, msg, wParam, lParam, lpResult);
227     return E_NOTIMPL;
228 }
229
230 static HRESULT WINAPI OleInPlaceObjectWindowless_GetDropTarget(IOleInPlaceObjectWindowless *iface,
231         IDropTarget **ppDropTarget)
232 {
233     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
234     FIXME("(%p)->(%p)\n", This, ppDropTarget);
235     return E_NOTIMPL;
236 }
237
238 static IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl = {
239     OleInPlaceObjectWindowless_QueryInterface,
240     OleInPlaceObjectWindowless_AddRef,
241     OleInPlaceObjectWindowless_Release,
242     OleInPlaceObjectWindowless_GetWindow,
243     OleInPlaceObjectWindowless_ContextSensitiveHelp,
244     OleInPlaceObjectWindowless_InPlaceDeactivate,
245     OleInPlaceObjectWindowless_UIDeactivate,
246     OleInPlaceObjectWindowless_SetObjectRects,
247     OleInPlaceObjectWindowless_ReactivateAndUndo,
248     OleInPlaceObjectWindowless_OnWindowMessage,
249     OleInPlaceObjectWindowless_GetDropTarget
250 };
251
252 #undef INPLACEWIN_THIS
253
254 void HTMLDocument_Window_Init(HTMLDocument *This)
255 {
256     This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
257     This->lpOleInPlaceObjectWindowlessVtbl = &OleInPlaceObjectWindowlessVtbl;
258 }