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