mshtml: Added beginning IHTMLScriptElement::put_src implementation.
[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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 #include "resource.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37
38 /**********************************************************
39  * IOleInPlaceActiveObject implementation
40  */
41
42 static inline HTMLDocument *impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject *iface)
43 {
44     return CONTAINING_RECORD(iface, HTMLDocument, IOleInPlaceActiveObject_iface);
45 }
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 static ULONG WINAPI OleInPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
54 {
55     HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
56     return htmldoc_addref(This);
57 }
58
59 static ULONG WINAPI OleInPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
60 {
61     HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
62     return htmldoc_release(This);
63 }
64
65 static HRESULT WINAPI OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface, HWND *phwnd)
66 {
67     HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
68
69     TRACE("(%p)->(%p)\n", This, phwnd);
70
71     if(!phwnd)
72         return E_INVALIDARG;
73
74     if(!This->doc_obj->in_place_active) {
75         *phwnd = NULL;
76         return E_FAIL;
77     }
78
79     *phwnd = This->doc_obj->hwnd;
80     return S_OK;
81 }
82
83 static HRESULT WINAPI OleInPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface, BOOL fEnterMode)
84 {
85     HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
86     FIXME("(%p)->(%x)\n", This, fEnterMode);
87     return E_NOTIMPL;
88 }
89
90 static HRESULT WINAPI OleInPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface, LPMSG lpmsg)
91 {
92     HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
93     FIXME("(%p)->(%p)\n", This, lpmsg);
94     return E_NOTIMPL;
95 }
96
97 static HRESULT WINAPI OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
98         BOOL fActivate)
99 {
100     HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
101
102     TRACE("(%p)->(%x)\n", This, fActivate);
103
104     if(This->doc_obj->hostui)
105         IDocHostUIHandler_OnFrameWindowActivate(This->doc_obj->hostui, fActivate);
106
107     return S_OK;
108 }
109
110 static HRESULT WINAPI OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
111 {
112     HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
113     FIXME("(%p)->(%x)\n", This, fActivate);
114     return E_NOTIMPL;
115 }
116
117 static HRESULT WINAPI OleInPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface, LPCRECT prcBorder,
118                                                 IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
119 {
120     HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
121     FIXME("(%p)->(%p %p %x)\n", This, prcBorder, pUIWindow, fFrameWindow);
122     return E_NOTIMPL;
123 }
124
125 static HRESULT WINAPI OleInPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface, BOOL fEnable)
126 {
127     HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
128     FIXME("(%p)->(%x)\n", This, fEnable);
129     return E_NOTIMPL;
130 }
131
132 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
133     OleInPlaceActiveObject_QueryInterface,
134     OleInPlaceActiveObject_AddRef,
135     OleInPlaceActiveObject_Release,
136     OleInPlaceActiveObject_GetWindow,
137     OleInPlaceActiveObject_ContextSensitiveHelp,
138     OleInPlaceActiveObject_TranslateAccelerator,
139     OleInPlaceActiveObject_OnFrameWindowActivate,
140     OleInPlaceActiveObject_OnDocWindowActivate,
141     OleInPlaceActiveObject_ResizeBorder,
142     OleInPlaceActiveObject_EnableModeless
143 };
144
145 /**********************************************************
146  * IOleInPlaceObjectWindowless implementation
147  */
148
149 static inline HTMLDocument *impl_from_IOleInPlaceObjectWindowless(IOleInPlaceObjectWindowless *iface)
150 {
151     return CONTAINING_RECORD(iface, HTMLDocument, IOleInPlaceObjectWindowless_iface);
152 }
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 static ULONG WINAPI OleInPlaceObjectWindowless_AddRef(IOleInPlaceObjectWindowless *iface)
162 {
163     HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
164     return htmldoc_addref(This);
165 }
166
167 static ULONG WINAPI OleInPlaceObjectWindowless_Release(IOleInPlaceObjectWindowless *iface)
168 {
169     HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
170     return htmldoc_release(This);
171 }
172
173 static HRESULT WINAPI OleInPlaceObjectWindowless_GetWindow(IOleInPlaceObjectWindowless *iface,
174         HWND *phwnd)
175 {
176     HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
177     return IOleInPlaceActiveObject_GetWindow(&This->IOleInPlaceActiveObject_iface, phwnd);
178 }
179
180 static HRESULT WINAPI OleInPlaceObjectWindowless_ContextSensitiveHelp(IOleInPlaceObjectWindowless *iface,
181         BOOL fEnterMode)
182 {
183     HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
184     return IOleInPlaceActiveObject_ContextSensitiveHelp(&This->IOleInPlaceActiveObject_iface, fEnterMode);
185 }
186
187 static HRESULT WINAPI OleInPlaceObjectWindowless_InPlaceDeactivate(IOleInPlaceObjectWindowless *iface)
188 {
189     HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
190
191     TRACE("(%p)\n", This);
192
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         return S_OK;
199
200     if(This->doc_obj->frame) {
201         IOleInPlaceFrame_Release(This->doc_obj->frame);
202         This->doc_obj->frame = NULL;
203     }
204
205     if(This->doc_obj->hwnd) {
206         ShowWindow(This->doc_obj->hwnd, SW_HIDE);
207         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         IOleInPlaceSiteEx *ipsiteex;
216         HRESULT hres;
217
218         hres = IOleInPlaceSite_QueryInterface(This->doc_obj->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
219         if(SUCCEEDED(hres)) {
220             IOleInPlaceSiteEx_OnInPlaceDeactivateEx(ipsiteex, TRUE);
221             IOleInPlaceSiteEx_Release(ipsiteex);
222         }else {
223             IOleInPlaceSite_OnInPlaceDeactivate(This->doc_obj->ipsite);
224         }
225     }
226
227     return S_OK;
228 }
229
230 static HRESULT WINAPI OleInPlaceObjectWindowless_UIDeactivate(IOleInPlaceObjectWindowless *iface)
231 {
232     HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
233     FIXME("(%p)\n", This);
234     return E_NOTIMPL;
235 }
236
237 static HRESULT WINAPI OleInPlaceObjectWindowless_SetObjectRects(IOleInPlaceObjectWindowless *iface,
238         LPCRECT lprcPosRect, LPCRECT lprcClipRect)
239 {
240     HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
241     FIXME("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
242     return E_NOTIMPL;
243 }
244
245 static HRESULT WINAPI OleInPlaceObjectWindowless_ReactivateAndUndo(IOleInPlaceObjectWindowless *iface)
246 {
247     HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
248     FIXME("(%p)\n", This);
249     return E_NOTIMPL;
250 }
251
252 static HRESULT WINAPI OleInPlaceObjectWindowless_OnWindowMessage(IOleInPlaceObjectWindowless *iface,
253         UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *lpResult)
254 {
255     HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
256     FIXME("(%p)->(%u %lu %lu %p)\n", This, msg, wParam, lParam, lpResult);
257     return E_NOTIMPL;
258 }
259
260 static HRESULT WINAPI OleInPlaceObjectWindowless_GetDropTarget(IOleInPlaceObjectWindowless *iface,
261         IDropTarget **ppDropTarget)
262 {
263     HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
264     FIXME("(%p)->(%p)\n", This, ppDropTarget);
265     return E_NOTIMPL;
266 }
267
268 static const IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl = {
269     OleInPlaceObjectWindowless_QueryInterface,
270     OleInPlaceObjectWindowless_AddRef,
271     OleInPlaceObjectWindowless_Release,
272     OleInPlaceObjectWindowless_GetWindow,
273     OleInPlaceObjectWindowless_ContextSensitiveHelp,
274     OleInPlaceObjectWindowless_InPlaceDeactivate,
275     OleInPlaceObjectWindowless_UIDeactivate,
276     OleInPlaceObjectWindowless_SetObjectRects,
277     OleInPlaceObjectWindowless_ReactivateAndUndo,
278     OleInPlaceObjectWindowless_OnWindowMessage,
279     OleInPlaceObjectWindowless_GetDropTarget
280 };
281
282 void HTMLDocument_Window_Init(HTMLDocument *This)
283 {
284     This->IOleInPlaceActiveObject_iface.lpVtbl = &OleInPlaceActiveObjectVtbl;
285     This->IOleInPlaceObjectWindowless_iface.lpVtbl = &OleInPlaceObjectWindowlessVtbl;
286 }