Revert tree-restructure attempt: r66583, r66582, r66581, r66578, sauf ntdll changes...
[reactos.git] / reactos / dll / win32 / 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #include "mshtml_private.h"
20
21 /**********************************************************
22 * IOleInPlaceActiveObject implementation
23 */
24
25 static inline HTMLDocument *impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject *iface)
26 {
27 return CONTAINING_RECORD(iface, HTMLDocument, IOleInPlaceActiveObject_iface);
28 }
29
30 static HRESULT WINAPI OleInPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface, REFIID riid, void **ppv)
31 {
32 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
33 return htmldoc_query_interface(This, riid, ppv);
34 }
35
36 static ULONG WINAPI OleInPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
37 {
38 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
39 return htmldoc_addref(This);
40 }
41
42 static ULONG WINAPI OleInPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
43 {
44 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
45 return htmldoc_release(This);
46 }
47
48 static HRESULT WINAPI OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface, HWND *phwnd)
49 {
50 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
51
52 TRACE("(%p)->(%p)\n", This, phwnd);
53
54 if(!phwnd)
55 return E_INVALIDARG;
56
57 if(!This->doc_obj->in_place_active) {
58 *phwnd = NULL;
59 return E_FAIL;
60 }
61
62 *phwnd = This->doc_obj->hwnd;
63 return S_OK;
64 }
65
66 static HRESULT WINAPI OleInPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface, BOOL fEnterMode)
67 {
68 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
69 FIXME("(%p)->(%x)\n", This, fEnterMode);
70 return E_NOTIMPL;
71 }
72
73 static HRESULT WINAPI OleInPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface, LPMSG lpmsg)
74 {
75 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
76 FIXME("(%p)->(%p)\n", This, lpmsg);
77 return E_NOTIMPL;
78 }
79
80 static HRESULT WINAPI OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
81 BOOL fActivate)
82 {
83 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
84
85 TRACE("(%p)->(%x)\n", This, fActivate);
86
87 if(This->doc_obj->hostui)
88 IDocHostUIHandler_OnFrameWindowActivate(This->doc_obj->hostui, fActivate);
89
90 return S_OK;
91 }
92
93 static HRESULT WINAPI OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
94 {
95 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
96 FIXME("(%p)->(%x)\n", This, fActivate);
97 return E_NOTIMPL;
98 }
99
100 static HRESULT WINAPI OleInPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface, LPCRECT prcBorder,
101 IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
102 {
103 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
104 FIXME("(%p)->(%p %p %x)\n", This, prcBorder, pUIWindow, fFrameWindow);
105 return E_NOTIMPL;
106 }
107
108 static HRESULT WINAPI OleInPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface, BOOL fEnable)
109 {
110 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
111 FIXME("(%p)->(%x)\n", This, fEnable);
112 return E_NOTIMPL;
113 }
114
115 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
116 OleInPlaceActiveObject_QueryInterface,
117 OleInPlaceActiveObject_AddRef,
118 OleInPlaceActiveObject_Release,
119 OleInPlaceActiveObject_GetWindow,
120 OleInPlaceActiveObject_ContextSensitiveHelp,
121 OleInPlaceActiveObject_TranslateAccelerator,
122 OleInPlaceActiveObject_OnFrameWindowActivate,
123 OleInPlaceActiveObject_OnDocWindowActivate,
124 OleInPlaceActiveObject_ResizeBorder,
125 OleInPlaceActiveObject_EnableModeless
126 };
127
128 /**********************************************************
129 * IOleInPlaceObjectWindowless implementation
130 */
131
132 static inline HTMLDocument *impl_from_IOleInPlaceObjectWindowless(IOleInPlaceObjectWindowless *iface)
133 {
134 return CONTAINING_RECORD(iface, HTMLDocument, IOleInPlaceObjectWindowless_iface);
135 }
136
137 static HRESULT WINAPI OleInPlaceObjectWindowless_QueryInterface(IOleInPlaceObjectWindowless *iface,
138 REFIID riid, void **ppv)
139 {
140 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
141 return htmldoc_query_interface(This, riid, ppv);
142 }
143
144 static ULONG WINAPI OleInPlaceObjectWindowless_AddRef(IOleInPlaceObjectWindowless *iface)
145 {
146 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
147 return htmldoc_addref(This);
148 }
149
150 static ULONG WINAPI OleInPlaceObjectWindowless_Release(IOleInPlaceObjectWindowless *iface)
151 {
152 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
153 return htmldoc_release(This);
154 }
155
156 static HRESULT WINAPI OleInPlaceObjectWindowless_GetWindow(IOleInPlaceObjectWindowless *iface,
157 HWND *phwnd)
158 {
159 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
160 return IOleInPlaceActiveObject_GetWindow(&This->IOleInPlaceActiveObject_iface, phwnd);
161 }
162
163 static HRESULT WINAPI OleInPlaceObjectWindowless_ContextSensitiveHelp(IOleInPlaceObjectWindowless *iface,
164 BOOL fEnterMode)
165 {
166 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
167 return IOleInPlaceActiveObject_ContextSensitiveHelp(&This->IOleInPlaceActiveObject_iface, fEnterMode);
168 }
169
170 static HRESULT WINAPI OleInPlaceObjectWindowless_InPlaceDeactivate(IOleInPlaceObjectWindowless *iface)
171 {
172 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
173
174 TRACE("(%p)\n", This);
175
176 if(This->doc_obj->ui_active)
177 IOleDocumentView_UIActivate(&This->IOleDocumentView_iface, FALSE);
178 This->doc_obj->window_active = FALSE;
179
180 if(!This->doc_obj->in_place_active)
181 return S_OK;
182
183 if(This->doc_obj->frame) {
184 IOleInPlaceFrame_Release(This->doc_obj->frame);
185 This->doc_obj->frame = NULL;
186 }
187
188 if(This->doc_obj->hwnd) {
189 ShowWindow(This->doc_obj->hwnd, SW_HIDE);
190 SetWindowPos(This->doc_obj->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
191 }
192
193 This->doc_obj->focus = FALSE;
194 notif_focus(This->doc_obj);
195
196 This->doc_obj->in_place_active = FALSE;
197 if(This->doc_obj->ipsite) {
198 IOleInPlaceSiteEx *ipsiteex;
199 HRESULT hres;
200
201 hres = IOleInPlaceSite_QueryInterface(This->doc_obj->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
202 if(SUCCEEDED(hres)) {
203 IOleInPlaceSiteEx_OnInPlaceDeactivateEx(ipsiteex, TRUE);
204 IOleInPlaceSiteEx_Release(ipsiteex);
205 }else {
206 IOleInPlaceSite_OnInPlaceDeactivate(This->doc_obj->ipsite);
207 }
208 }
209
210 return S_OK;
211 }
212
213 static HRESULT WINAPI OleInPlaceObjectWindowless_UIDeactivate(IOleInPlaceObjectWindowless *iface)
214 {
215 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
216 FIXME("(%p)\n", This);
217 return E_NOTIMPL;
218 }
219
220 static HRESULT WINAPI OleInPlaceObjectWindowless_SetObjectRects(IOleInPlaceObjectWindowless *iface,
221 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
222 {
223 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
224 FIXME("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
225 return E_NOTIMPL;
226 }
227
228 static HRESULT WINAPI OleInPlaceObjectWindowless_ReactivateAndUndo(IOleInPlaceObjectWindowless *iface)
229 {
230 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
231 FIXME("(%p)\n", This);
232 return E_NOTIMPL;
233 }
234
235 static HRESULT WINAPI OleInPlaceObjectWindowless_OnWindowMessage(IOleInPlaceObjectWindowless *iface,
236 UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *lpResult)
237 {
238 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
239 FIXME("(%p)->(%u %lu %lu %p)\n", This, msg, wParam, lParam, lpResult);
240 return E_NOTIMPL;
241 }
242
243 static HRESULT WINAPI OleInPlaceObjectWindowless_GetDropTarget(IOleInPlaceObjectWindowless *iface,
244 IDropTarget **ppDropTarget)
245 {
246 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
247 FIXME("(%p)->(%p)\n", This, ppDropTarget);
248 return E_NOTIMPL;
249 }
250
251 static const IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl = {
252 OleInPlaceObjectWindowless_QueryInterface,
253 OleInPlaceObjectWindowless_AddRef,
254 OleInPlaceObjectWindowless_Release,
255 OleInPlaceObjectWindowless_GetWindow,
256 OleInPlaceObjectWindowless_ContextSensitiveHelp,
257 OleInPlaceObjectWindowless_InPlaceDeactivate,
258 OleInPlaceObjectWindowless_UIDeactivate,
259 OleInPlaceObjectWindowless_SetObjectRects,
260 OleInPlaceObjectWindowless_ReactivateAndUndo,
261 OleInPlaceObjectWindowless_OnWindowMessage,
262 OleInPlaceObjectWindowless_GetDropTarget
263 };
264
265 void HTMLDocument_Window_Init(HTMLDocument *This)
266 {
267 This->IOleInPlaceActiveObject_iface.lpVtbl = &OleInPlaceActiveObjectVtbl;
268 This->IOleInPlaceObjectWindowless_iface.lpVtbl = &OleInPlaceObjectWindowlessVtbl;
269 }