Unicodify wineesd.
[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 #include "docobj.h"
31
32 #include "mshtml.h"
33 #include "mshtmhst.h"
34
35 #include "wine/debug.h"
36
37 #include "mshtml_private.h"
38
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
40
41 /**********************************************************
42  * IOleInPlaceActiveObject implementation
43  */
44
45 #define ACTOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, OleInPlaceActiveObject, iface)
46
47 static HRESULT WINAPI OleInPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface, REFIID riid, void **ppvObject)
48 {
49     HTMLDocument *This = ACTOBJ_THIS(iface);
50     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
51 }
52
53 static ULONG WINAPI OleInPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
54 {
55     HTMLDocument *This = ACTOBJ_THIS(iface);
56     return IHTMLDocument2_AddRef(HTMLDOC(This));
57 }
58
59 static ULONG WINAPI OleInPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
60 {
61     HTMLDocument *This = ACTOBJ_THIS(iface);
62     return IHTMLDocument2_Release(HTMLDOC(This));
63 }
64
65 static HRESULT WINAPI OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface, HWND *phwnd)
66 {
67     HTMLDocument *This = ACTOBJ_THIS(iface);
68
69     TRACE("(%p)->(%p)\n", This, phwnd);
70
71     if(!phwnd)
72         return E_INVALIDARG;
73
74     if(!This->in_place_active) {
75         *phwnd = NULL;
76         return E_FAIL;
77     }
78
79     *phwnd = This->hwnd;
80     return S_OK;
81 }
82
83 static HRESULT WINAPI OleInPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface, BOOL fEnterMode)
84 {
85     HTMLDocument *This = ACTOBJ_THIS(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 = ACTOBJ_THIS(iface);
93     FIXME("(%p)->(%p)\n", This, lpmsg);
94     return E_NOTIMPL;
95 }
96
97 static HRESULT WINAPI OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
98 {
99     HTMLDocument *This = ACTOBJ_THIS(iface);
100     FIXME("(%p)->(%x)\n", This, fActivate);
101     return E_NOTIMPL;
102 }
103
104 static HRESULT WINAPI OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
105 {
106     HTMLDocument *This = ACTOBJ_THIS(iface);
107     FIXME("(%p)->(%x)\n", This, fActivate);
108     return E_NOTIMPL;
109 }
110
111 static HRESULT WINAPI OleInPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface, LPCRECT prcBorder,
112                                                 IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
113 {
114     HTMLDocument *This = ACTOBJ_THIS(iface);
115     FIXME("(%p)->(%p %p %x)\n", This, prcBorder, pUIWindow, fFrameWindow);
116     return E_NOTIMPL;
117 }
118
119 static HRESULT WINAPI OleInPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface, BOOL fEnable)
120 {
121     HTMLDocument *This = ACTOBJ_THIS(iface);
122     FIXME("(%p)->(%x)\n", This, fEnable);
123     return E_NOTIMPL;
124 }
125
126 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
127     OleInPlaceActiveObject_QueryInterface,
128     OleInPlaceActiveObject_AddRef,
129     OleInPlaceActiveObject_Release,
130     OleInPlaceActiveObject_GetWindow,
131     OleInPlaceActiveObject_ContextSensitiveHelp,
132     OleInPlaceActiveObject_TranslateAccelerator,
133     OleInPlaceActiveObject_OnFrameWindowActivate,
134     OleInPlaceActiveObject_OnDocWindowActivate,
135     OleInPlaceActiveObject_ResizeBorder,
136     OleInPlaceActiveObject_EnableModeless
137 };
138
139 #undef ACTOBJ_THIS
140
141 /**********************************************************
142  * IOleInPlaceObjectWindowless implementation
143  */
144
145 #define OLEINPLACEWND_THIS(iface) DEFINE_THIS(HTMLDocument, OleInPlaceObjectWindowless, iface)
146
147 static HRESULT WINAPI OleInPlaceObjectWindowless_QueryInterface(IOleInPlaceObjectWindowless *iface,
148         REFIID riid, void **ppvObject)
149 {
150     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
151     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
152 }
153
154 static ULONG WINAPI OleInPlaceObjectWindowless_AddRef(IOleInPlaceObjectWindowless *iface)
155 {
156     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
157     return IHTMLDocument2_AddRef(HTMLDOC(This));
158 }
159
160 static ULONG WINAPI OleInPlaceObjectWindowless_Release(IOleInPlaceObjectWindowless *iface)
161 {
162     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
163     return IHTMLDocument2_Release(HTMLDOC(This));
164 }
165
166 static HRESULT WINAPI OleInPlaceObjectWindowless_GetWindow(IOleInPlaceObjectWindowless *iface,
167         HWND *phwnd)
168 {
169     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
170     return IOleWindow_GetWindow(OLEWIN(This), phwnd);
171 }
172
173 static HRESULT WINAPI OleInPlaceObjectWindowless_ContextSensitiveHelp(IOleInPlaceObjectWindowless *iface,
174         BOOL fEnterMode)
175 {
176     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
177     return IOleWindow_ContextSensitiveHelp(OLEWIN(This), fEnterMode);
178 }
179
180 static HRESULT WINAPI OleInPlaceObjectWindowless_InPlaceDeactivate(IOleInPlaceObjectWindowless *iface)
181 {
182     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
183
184     TRACE("(%p)\n", This);
185
186     if(!This->in_place_active)
187         return S_OK;
188
189     if(This->frame)
190         IOleInPlaceFrame_Release(This->frame);
191
192     if(This->hwnd) {
193         ShowWindow(This->hwnd, SW_HIDE);
194         SetWindowPos(This->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
195     }
196
197     This->in_place_active = FALSE;
198     if(This->ipsite)
199         IOleInPlaceSite_OnInPlaceDeactivate(This->ipsite);
200
201     return S_OK;
202 }
203
204 static HRESULT WINAPI OleInPlaceObjectWindowless_UIDeactivate(IOleInPlaceObjectWindowless *iface)
205 {
206     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
207     FIXME("(%p)\n", This);
208     return E_NOTIMPL;
209 }
210
211 static HRESULT WINAPI OleInPlaceObjectWindowless_SetObjectRects(IOleInPlaceObjectWindowless *iface,
212         LPCRECT lprcPosRect, LPCRECT lprcClipRect)
213 {
214     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
215     FIXME("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
216     return E_NOTIMPL;
217 }
218
219 static HRESULT WINAPI OleInPlaceObjectWindowless_ReactivateAndUndo(IOleInPlaceObjectWindowless *iface)
220 {
221     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
222     FIXME("(%p)\n", This);
223     return E_NOTIMPL;
224 }
225
226 static HRESULT WINAPI OleInPlaceObjectWindowless_OnWindowMessage(IOleInPlaceObjectWindowless *iface,
227         UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *lpResult)
228 {
229     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
230     FIXME("(%p)->(%u %u %lu %p)\n", This, msg, wParam, lParam, lpResult);
231     return E_NOTIMPL;
232 }
233
234 static HRESULT WINAPI OleInPlaceObjectWindowless_GetDropTarget(IOleInPlaceObjectWindowless *iface,
235         IDropTarget **ppDropTarget)
236 {
237     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
238     FIXME("(%p)->(%p)\n", This, ppDropTarget);
239     return E_NOTIMPL;
240 }
241
242 static IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl = {
243     OleInPlaceObjectWindowless_QueryInterface,
244     OleInPlaceObjectWindowless_AddRef,
245     OleInPlaceObjectWindowless_Release,
246     OleInPlaceObjectWindowless_GetWindow,
247     OleInPlaceObjectWindowless_ContextSensitiveHelp,
248     OleInPlaceObjectWindowless_InPlaceDeactivate,
249     OleInPlaceObjectWindowless_UIDeactivate,
250     OleInPlaceObjectWindowless_SetObjectRects,
251     OleInPlaceObjectWindowless_ReactivateAndUndo,
252     OleInPlaceObjectWindowless_OnWindowMessage,
253     OleInPlaceObjectWindowless_GetDropTarget
254 };
255
256 #undef INPLACEWIN_THIS
257
258 void HTMLDocument_Window_Init(HTMLDocument *This)
259 {
260     This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
261     This->lpOleInPlaceObjectWindowlessVtbl = &OleInPlaceObjectWindowlessVtbl;
262 }