mstask: Actually run a test and fix the expected behaviour.
[wine] / dlls / mshtml / ipwindow.c
1 /*
2  * Copyright 2010 Jacek Caban for CodeWeavers
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22
23 #define COBJMACROS
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "shlobj.h"
30
31 #include "mshtml_private.h"
32 #include "pluginhost.h"
33
34 #include "wine/debug.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37
38 typedef struct {
39     IOleInPlaceFrame IOleInPlaceFrame_iface;
40     LONG ref;
41 } InPlaceFrame;
42
43 static inline InPlaceFrame *impl_from_IOleInPlaceFrame(IOleInPlaceFrame *iface)
44 {
45     return CONTAINING_RECORD(iface, InPlaceFrame, IOleInPlaceFrame_iface);
46 }
47
48 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface,
49                                                   REFIID riid, void **ppv)
50 {
51     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
52
53     if(IsEqualGUID(&IID_IUnknown, riid)) {
54         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
55         *ppv = &This->IOleInPlaceFrame_iface;
56     }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
57         TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
58         *ppv = &This->IOleInPlaceFrame_iface;
59     }else if(IsEqualGUID(&IID_IOleInPlaceUIWindow, riid)) {
60         TRACE("(%p)->(IID_IOleInPlaceUIWindow %p)\n", This, ppv);
61         *ppv = &This->IOleInPlaceFrame_iface;
62     }else if(IsEqualGUID(&IID_IOleInPlaceFrame, riid)) {
63         TRACE("(%p)->(IID_IOleInPlaceFrame %p)\n", This, ppv);
64         *ppv = &This->IOleInPlaceFrame_iface;
65     }else {
66         WARN("Unsopported interface %s\n", debugstr_guid(riid));
67         *ppv = NULL;
68         return E_NOINTERFACE;
69     }
70
71     IUnknown_AddRef((IUnknown*)*ppv);
72     return S_OK;
73 }
74
75 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
76 {
77     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
78     LONG ref = InterlockedIncrement(&This->ref);
79
80     TRACE("(%p) ref=%d\n", This, ref);
81
82     return ref;
83 }
84
85 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
86 {
87     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
88     LONG ref = InterlockedDecrement(&This->ref);
89
90     TRACE("(%p) ref=%d\n", This, ref);
91
92     if(!ref)
93         heap_free(This);
94
95     return ref;
96 }
97
98 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
99 {
100     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
101     FIXME("(%p)->(%p)\n", This, phwnd);
102     return E_NOTIMPL;
103 }
104
105 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface,
106                                                         BOOL fEnterMode)
107 {
108     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
109     FIXME("(%p)->(%x)\n", This, fEnterMode);
110     return E_NOTIMPL;
111 }
112
113 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
114 {
115     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
116     FIXME("(%p)->(%p)\n", This, lprectBorder);
117     return E_NOTIMPL;
118 }
119
120 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
121                                                       LPCBORDERWIDTHS pborderwidths)
122 {
123     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
124     FIXME("(%p)->(%p)\n", This, pborderwidths);
125     return E_NOTIMPL;
126 }
127
128 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
129                                                   LPCBORDERWIDTHS pborderwidths)
130 {
131     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
132     FIXME("(%p)->(%p)\n", This, pborderwidths);
133     return E_NOTIMPL;
134 }
135
136 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
137         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
138 {
139     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
140     FIXME("(%p)->(%p %s)\n", This, pActiveObject, debugstr_w(pszObjName));
141     return E_NOTIMPL;
142 }
143
144 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
145         LPOLEMENUGROUPWIDTHS lpMenuWidths)
146 {
147     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
148     FIXME("(%p)->(%p %p)\n", This, hmenuShared, lpMenuWidths);
149     return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
153         HOLEMENU holemenu, HWND hwndActiveObject)
154 {
155     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
156     FIXME("(%p)->(%p %p %p)\n", This, hmenuShared, holemenu, hwndActiveObject);
157     return E_NOTIMPL;
158 }
159
160 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
161 {
162     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
163     FIXME("(%p)->(%p)\n", This, hmenuShared);
164     return E_NOTIMPL;
165 }
166
167 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface,
168                                                  LPCOLESTR pszStatusText)
169 {
170     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
171     FIXME("(%p)->(%s)\n", This, debugstr_w(pszStatusText));
172     return E_NOTIMPL;
173 }
174
175 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
176 {
177     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
178     FIXME("(%p)->(%x)\n", This, fEnable);
179     return E_NOTIMPL;
180 }
181
182 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg,
183                                                         WORD wID)
184 {
185     InPlaceFrame *This = impl_from_IOleInPlaceFrame(iface);
186     FIXME("(%p)->(%p %d)\n", This, lpmsg, wID);
187     return E_NOTIMPL;
188 }
189
190 static const IOleInPlaceFrameVtbl OleInPlaceFrameVtbl = {
191     InPlaceFrame_QueryInterface,
192     InPlaceFrame_AddRef,
193     InPlaceFrame_Release,
194     InPlaceFrame_GetWindow,
195     InPlaceFrame_ContextSensitiveHelp,
196     InPlaceFrame_GetBorder,
197     InPlaceFrame_RequestBorderSpace,
198     InPlaceFrame_SetBorderSpace,
199     InPlaceFrame_SetActiveObject,
200     InPlaceFrame_InsertMenus,
201     InPlaceFrame_SetMenu,
202     InPlaceFrame_RemoveMenus,
203     InPlaceFrame_SetStatusText,
204     InPlaceFrame_EnableModeless,
205     InPlaceFrame_TranslateAccelerator
206 };
207
208 HRESULT create_ip_frame(IOleInPlaceFrame **ret)
209 {
210     InPlaceFrame *frame;
211
212     frame = heap_alloc_zero(sizeof(*frame));
213     if(!frame)
214         return E_OUTOFMEMORY;
215
216     frame->IOleInPlaceFrame_iface.lpVtbl = &OleInPlaceFrameVtbl;
217     frame->ref = 1;
218
219     *ret = &frame->IOleInPlaceFrame_iface;
220     return S_OK;
221 }
222
223 typedef struct {
224     IOleInPlaceUIWindow IOleInPlaceUIWindow_iface;
225     LONG ref;
226 } InPlaceUIWindow;
227
228 static inline InPlaceUIWindow *impl_from_IOleInPlaceUIWindow(IOleInPlaceUIWindow *iface)
229 {
230     return CONTAINING_RECORD(iface, InPlaceUIWindow, IOleInPlaceUIWindow_iface);
231 }
232
233 static HRESULT WINAPI InPlaceUIWindow_QueryInterface(IOleInPlaceUIWindow *iface, REFIID riid, void **ppv)
234 {
235     InPlaceUIWindow *This = impl_from_IOleInPlaceUIWindow(iface);
236
237     if(IsEqualGUID(&IID_IUnknown, riid)) {
238         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
239         *ppv = &This->IOleInPlaceUIWindow_iface;
240     }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
241         TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
242         *ppv = &This->IOleInPlaceUIWindow_iface;
243     }else if(IsEqualGUID(&IID_IOleInPlaceUIWindow, riid)) {
244         TRACE("(%p)->(IID_IOleInPlaceUIWindow %p)\n", This, ppv);
245         *ppv = &This->IOleInPlaceUIWindow_iface;
246     }else {
247         WARN("Unsopported interface %s\n", debugstr_guid(riid));
248         *ppv = NULL;
249         return E_NOINTERFACE;
250     }
251
252     IUnknown_AddRef((IUnknown*)*ppv);
253     return S_OK;
254 }
255
256 static ULONG WINAPI InPlaceUIWindow_AddRef(IOleInPlaceUIWindow *iface)
257 {
258     InPlaceUIWindow *This = impl_from_IOleInPlaceUIWindow(iface);
259     LONG ref = InterlockedIncrement(&This->ref);
260
261     TRACE("(%p) ref=%d\n", This, ref);
262
263     return ref;
264 }
265
266 static ULONG WINAPI InPlaceUIWindow_Release(IOleInPlaceUIWindow *iface)
267 {
268     InPlaceUIWindow *This = impl_from_IOleInPlaceUIWindow(iface);
269     LONG ref = InterlockedDecrement(&This->ref);
270
271     TRACE("(%p) ref=%d\n", This, ref);
272
273     if(!ref)
274         heap_free(This);
275
276     return ref;
277 }
278
279 static HRESULT WINAPI InPlaceUIWindow_GetWindow(IOleInPlaceUIWindow *iface, HWND *phwnd)
280 {
281     InPlaceUIWindow *This = impl_from_IOleInPlaceUIWindow(iface);
282     FIXME("(%p)->(%p)\n", This, phwnd);
283     return E_NOTIMPL;
284 }
285
286 static HRESULT WINAPI InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceUIWindow *iface,
287         BOOL fEnterMode)
288 {
289     InPlaceUIWindow *This = impl_from_IOleInPlaceUIWindow(iface);
290     FIXME("(%p)->(%x)\n", This, fEnterMode);
291     return E_NOTIMPL;
292 }
293
294 static HRESULT WINAPI InPlaceUIWindow_GetBorder(IOleInPlaceUIWindow *iface, LPRECT lprectBorder)
295 {
296     InPlaceUIWindow *This = impl_from_IOleInPlaceUIWindow(iface);
297     FIXME("(%p)->(%p)\n", This, lprectBorder);
298     return E_NOTIMPL;
299 }
300
301 static HRESULT WINAPI InPlaceUIWindow_RequestBorderSpace(IOleInPlaceUIWindow *iface,
302         LPCBORDERWIDTHS pborderwidths)
303 {
304     InPlaceUIWindow *This = impl_from_IOleInPlaceUIWindow(iface);
305     FIXME("(%p)->(%p)\n", This, pborderwidths);
306     return E_NOTIMPL;
307 }
308
309 static HRESULT WINAPI InPlaceUIWindow_SetBorderSpace(IOleInPlaceUIWindow *iface,
310         LPCBORDERWIDTHS pborderwidths)
311 {
312     InPlaceUIWindow *This = impl_from_IOleInPlaceUIWindow(iface);
313     FIXME("(%p)->(%p)\n", This, pborderwidths);
314     return E_NOTIMPL;
315 }
316
317 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceUIWindow *iface,
318         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
319 {
320     InPlaceUIWindow *This = impl_from_IOleInPlaceUIWindow(iface);
321     FIXME("(%p)->(%p %s)\n", This, pActiveObject, debugstr_w(pszObjName));
322     return E_NOTIMPL;
323 }
324
325 static const IOleInPlaceUIWindowVtbl OleInPlaceUIWindowVtbl = {
326     InPlaceUIWindow_QueryInterface,
327     InPlaceUIWindow_AddRef,
328     InPlaceUIWindow_Release,
329     InPlaceUIWindow_GetWindow,
330     InPlaceUIWindow_ContextSensitiveHelp,
331     InPlaceUIWindow_GetBorder,
332     InPlaceUIWindow_RequestBorderSpace,
333     InPlaceUIWindow_SetBorderSpace,
334     InPlaceUIWindow_SetActiveObject,
335 };
336
337 HRESULT create_ip_window(IOleInPlaceUIWindow **ret)
338 {
339     InPlaceUIWindow *uiwindow;
340
341     uiwindow = heap_alloc_zero(sizeof(*uiwindow));
342     if(!uiwindow)
343         return E_OUTOFMEMORY;
344
345     uiwindow->IOleInPlaceUIWindow_iface.lpVtbl = &OleInPlaceUIWindowVtbl;
346     uiwindow->ref = 1;
347
348     *ret = &uiwindow->IOleInPlaceUIWindow_iface;
349     return S_OK;
350 }