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