* Implement <autoregister>
[reactos.git] / reactos / lib / shdocvw / client.c
1 /*
2 * Copyright 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 #include "wine/debug.h"
20 #include "shdocvw.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
23
24 #define CLIENTSITE_THIS(iface) DEFINE_THIS(WebBrowser, OleClientSite, iface)
25
26 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
27 {
28 WebBrowser *This = CLIENTSITE_THIS(iface);
29
30 *ppv = NULL;
31
32 if(IsEqualGUID(&IID_IUnknown, riid)) {
33 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
34 *ppv = CLIENTSITE(This);
35 }else if(IsEqualGUID(&IID_IOleClientSite, riid)) {
36 TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppv);
37 *ppv = CLIENTSITE(This);
38 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
39 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
40 *ppv = INPLACESITE(This);
41 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
42 TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppv);
43 *ppv = INPLACESITE(This);
44 }else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)) {
45 TRACE("(%p)->(IID_IDocHostUIHandler %p)\n", This, ppv);
46 *ppv = DOCHOSTUI(This);
47 }else if(IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
48 TRACE("(%p)->(IID_IDocHostUIHandler2 %p)\n", This, ppv);
49 *ppv = DOCHOSTUI2(This);
50 }
51
52 if(*ppv) {
53 IWebBrowser2_AddRef(WEBBROWSER(This));
54 return S_OK;
55 }
56
57 WARN("Unsupported intrface %s\n", debugstr_guid(riid));
58
59 return E_NOINTERFACE;
60 }
61
62 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
63 {
64 WebBrowser *This = CLIENTSITE_THIS(iface);
65 return IWebBrowser2_AddRef(WEBBROWSER(This));
66 }
67
68 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
69 {
70 WebBrowser *This = CLIENTSITE_THIS(iface);
71 return IWebBrowser2_Release(WEBBROWSER(This));
72 }
73
74 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
75 {
76 WebBrowser *This = CLIENTSITE_THIS(iface);
77 FIXME("(%p)\n", This);
78 return E_NOTIMPL;
79 }
80
81 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign,
82 DWORD dwWhichMoniker, IMoniker **ppmk)
83 {
84 WebBrowser *This = CLIENTSITE_THIS(iface);
85 FIXME("(%p)->(%ld %ld %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
86 return E_NOTIMPL;
87 }
88
89 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
90 {
91 WebBrowser *This = CLIENTSITE_THIS(iface);
92 FIXME("(%p)->(%p)\n", This, ppContainer);
93 return E_NOTIMPL;
94 }
95
96 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
97 {
98 WebBrowser *This = CLIENTSITE_THIS(iface);
99 FIXME("(%p)\n", This);
100 return E_NOTIMPL;
101 }
102
103 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
104 {
105 WebBrowser *This = CLIENTSITE_THIS(iface);
106 FIXME("(%p)->(%x)\n", This, fShow);
107 return E_NOTIMPL;
108 }
109
110 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
111 {
112 WebBrowser *This = CLIENTSITE_THIS(iface);
113 FIXME("(%p)\n", This);
114 return E_NOTIMPL;
115 }
116
117 #undef CLIENTSITE_THIS
118
119 static const IOleClientSiteVtbl OleClientSiteVtbl = {
120 ClientSite_QueryInterface,
121 ClientSite_AddRef,
122 ClientSite_Release,
123 ClientSite_SaveObject,
124 ClientSite_GetMoniker,
125 ClientSite_GetContainer,
126 ClientSite_ShowObject,
127 ClientSite_OnShowWindow,
128 ClientSite_RequestNewObjectLayout
129 };
130
131 #define INPLACESITE_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceSite, iface)
132
133 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
134 {
135 WebBrowser *This = INPLACESITE_THIS(iface);
136 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
137 }
138
139 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
140 {
141 WebBrowser *This = INPLACESITE_THIS(iface);
142 return IOleClientSite_AddRef(CLIENTSITE(This));
143 }
144
145 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
146 {
147 WebBrowser *This = INPLACESITE_THIS(iface);
148 return IOleClientSite_Release(CLIENTSITE(This));
149 }
150
151 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
152 {
153 WebBrowser *This = INPLACESITE_THIS(iface);
154
155 TRACE("(%p)->(%p)\n", This, phwnd);
156
157 *phwnd = This->doc_view_hwnd;
158 return S_OK;
159 }
160
161 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
162 {
163 WebBrowser *This = INPLACESITE_THIS(iface);
164 FIXME("(%p)->(%x)\n", This, fEnterMode);
165 return E_NOTIMPL;
166 }
167
168 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
169 {
170 WebBrowser *This = INPLACESITE_THIS(iface);
171 FIXME("(%p)\n", This);
172 return E_NOTIMPL;
173 }
174
175 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
176 {
177 WebBrowser *This = INPLACESITE_THIS(iface);
178 FIXME("(%p)\n", This);
179 return E_NOTIMPL;
180 }
181
182 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
183 {
184 WebBrowser *This = INPLACESITE_THIS(iface);
185 FIXME("(%p)\n", This);
186 return E_NOTIMPL;
187 }
188
189 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
190 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
191 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
192 {
193 WebBrowser *This = INPLACESITE_THIS(iface);
194 FIXME("(%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect,
195 lprcClipRect, lpFrameInfo);
196 return E_NOTIMPL;
197 }
198
199 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtent)
200 {
201 WebBrowser *This = INPLACESITE_THIS(iface);
202 FIXME("(%p)->({%ld %ld})\n", This, scrollExtent.cx, scrollExtent.cy);
203 return E_NOTIMPL;
204 }
205
206 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
207 {
208 WebBrowser *This = INPLACESITE_THIS(iface);
209 FIXME("(%p)->(%x)\n", This, fUndoable);
210 return E_NOTIMPL;
211 }
212
213 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
214 {
215 WebBrowser *This = INPLACESITE_THIS(iface);
216 FIXME("(%p)\n", This);
217 return E_NOTIMPL;
218 }
219
220 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
221 {
222 WebBrowser *This = INPLACESITE_THIS(iface);
223 FIXME("(%p)\n", This);
224 return E_NOTIMPL;
225 }
226
227 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
228 {
229 WebBrowser *This = INPLACESITE_THIS(iface);
230 FIXME("(%p)\n", This);
231 return E_NOTIMPL;
232 }
233
234 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface,
235 LPCRECT lprcPosRect)
236 {
237 WebBrowser *This = INPLACESITE_THIS(iface);
238 FIXME("(%p)->(%p)\n", This, lprcPosRect);
239 return E_NOTIMPL;
240 }
241
242 #undef INPLACESITE_THIS
243
244 static const IOleInPlaceSiteVtbl OleInPlaceSiteVtbl = {
245 InPlaceSite_QueryInterface,
246 InPlaceSite_AddRef,
247 InPlaceSite_Release,
248 InPlaceSite_GetWindow,
249 InPlaceSite_ContextSensitiveHelp,
250 InPlaceSite_CanInPlaceActivate,
251 InPlaceSite_OnInPlaceActivate,
252 InPlaceSite_OnUIActivate,
253 InPlaceSite_GetWindowContext,
254 InPlaceSite_Scroll,
255 InPlaceSite_OnUIDeactivate,
256 InPlaceSite_OnInPlaceDeactivate,
257 InPlaceSite_DiscardUndoState,
258 InPlaceSite_DeactivateAndUndo,
259 InPlaceSite_OnPosRectChange
260 };
261
262 void WebBrowser_ClientSite_Init(WebBrowser *This)
263 {
264 This->lpOleClientSiteVtbl = &OleClientSiteVtbl;
265 This->lpOleInPlaceSiteVtbl = &OleInPlaceSiteVtbl;
266 }