- Sync with trunk r58248 to bring the latest changes from Amine (headers) and others...
[reactos.git] / dll / win32 / shdocvw / shdocvw.h
1 /*
2 * Header includes for shdocvw.dll
3 *
4 * Copyright 2001 John R. Sheets (for CodeWeavers)
5 * Copyright 2005-2006 Jacek Caban for CodeWeavers
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #ifndef __WINE_SHDOCVW_H
23 #define __WINE_SHDOCVW_H
24
25 #define WIN32_NO_STATUS
26 #define _INC_WINDOWS
27 #define COM_NO_WINDOWS_H
28
29 #define COBJMACROS
30
31 #include <stdarg.h>
32
33 #include <windef.h>
34 #include <winbase.h>
35 #include <wingdi.h>
36 //#include "winuser.h"
37 #include <winreg.h>
38 #include <winver.h>
39
40 #include <ole2.h>
41 #include <olectl.h>
42 #include <shellapi.h>
43 #include <shlobj.h>
44 //#include "exdisp.h"
45 #include <mshtmhst.h>
46 #include <hlink.h>
47 #include <htiframe.h>
48
49 #include <wine/unicode.h>
50 #include "resource.h"
51
52
53 #define WM_UPDATEADDRBAR (WM_APP+1)
54
55 /**********************************************************************
56 * Shell Instance Objects
57 */
58 extern HRESULT SHDOCVW_GetShellInstanceObjectClassObject(REFCLSID rclsid,
59 REFIID riid, LPVOID *ppvClassObj);
60
61 /**********************************************************************
62 * WebBrowser declaration for SHDOCVW.DLL
63 */
64
65 typedef struct ConnectionPoint ConnectionPoint;
66 typedef struct DocHost DocHost;
67
68 typedef struct {
69 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
70
71 ConnectionPoint *wbe2;
72 ConnectionPoint *wbe;
73 ConnectionPoint *pns;
74
75 IUnknown *impl;
76 } ConnectionPointContainer;
77
78 typedef struct {
79 const IHlinkFrameVtbl *lpIHlinkFrameVtbl;
80 const ITargetFrame2Vtbl *lpITargetFrame2Vtbl;
81
82 IUnknown *outer;
83 DocHost *doc_host;
84 } HlinkFrame;
85
86 struct _task_header_t;
87
88 typedef void (*task_proc_t)(DocHost*, struct _task_header_t*);
89
90 typedef struct _task_header_t {
91 task_proc_t proc;
92 } task_header_t;
93
94 typedef struct _IDocHostContainerVtbl
95 {
96 void (WINAPI* GetDocObjRect)(DocHost*,RECT*);
97 HRESULT (WINAPI* SetStatusText)(DocHost*,LPCWSTR);
98 void (WINAPI* SetURL)(DocHost*,LPCWSTR);
99 HRESULT (*exec)(DocHost*,const GUID*,DWORD,DWORD,VARIANT*,VARIANT*);
100 } IDocHostContainerVtbl;
101
102 struct DocHost {
103 const IOleClientSiteVtbl *lpOleClientSiteVtbl;
104 const IOleInPlaceSiteVtbl *lpOleInPlaceSiteVtbl;
105 const IDocHostUIHandler2Vtbl *lpDocHostUIHandlerVtbl;
106 const IOleDocumentSiteVtbl *lpOleDocumentSiteVtbl;
107 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
108 const IDispatchVtbl *lpDispatchVtbl;
109 const IPropertyNotifySinkVtbl *lpIPropertyNotifySinkVtbl;
110 const IServiceProviderVtbl *lpServiceProviderVtbl;
111
112 /* Interfaces of InPlaceFrame object */
113 const IOleInPlaceFrameVtbl *lpOleInPlaceFrameVtbl;
114
115 IDispatch *disp;
116
117 IDispatch *client_disp;
118 IDocHostUIHandler *hostui;
119 IOleInPlaceFrame *frame;
120
121 IUnknown *document;
122 IOleDocumentView *view;
123 IUnknown *doc_navigate;
124
125 const IDocHostContainerVtbl *container_vtbl;
126
127 HWND hwnd;
128 HWND frame_hwnd;
129
130 LPOLESTR url;
131
132 VARIANT_BOOL silent;
133 VARIANT_BOOL offline;
134 VARIANT_BOOL busy;
135
136 READYSTATE ready_state;
137 READYSTATE doc_state;
138 DWORD prop_notif_cookie;
139 BOOL is_prop_notif;
140
141 ConnectionPointContainer cps;
142 };
143
144 struct WebBrowser {
145 /* Interfaces available via WebBrowser object */
146
147 const IWebBrowser2Vtbl *lpWebBrowser2Vtbl;
148 const IOleObjectVtbl *lpOleObjectVtbl;
149 const IOleInPlaceObjectVtbl *lpOleInPlaceObjectVtbl;
150 const IOleControlVtbl *lpOleControlVtbl;
151 const IPersistStorageVtbl *lpPersistStorageVtbl;
152 const IPersistMemoryVtbl *lpPersistMemoryVtbl;
153 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
154 const IProvideClassInfo2Vtbl *lpProvideClassInfoVtbl;
155 const IViewObject2Vtbl *lpViewObjectVtbl;
156 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
157 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
158 const IServiceProviderVtbl *lpServiceProviderVtbl;
159 const IDataObjectVtbl *lpDataObjectVtbl;
160 HlinkFrame hlink_frame;
161
162 LONG ref;
163
164 INT version;
165
166 IOleClientSite *client;
167 IOleContainer *container;
168 IOleInPlaceSite *inplace;
169
170 /* window context */
171
172 HWND frame_hwnd;
173 IOleInPlaceUIWindow *uiwindow;
174 RECT pos_rect;
175 RECT clip_rect;
176 OLEINPLACEFRAMEINFO frameinfo;
177 SIZEL extent;
178
179 HWND shell_embedding_hwnd;
180
181 VARIANT_BOOL register_browser;
182 VARIANT_BOOL visible;
183 VARIANT_BOOL menu_bar;
184 VARIANT_BOOL address_bar;
185 VARIANT_BOOL status_bar;
186 VARIANT_BOOL tool_bar;
187 VARIANT_BOOL full_screen;
188 VARIANT_BOOL theater_mode;
189
190 DocHost doc_host;
191 };
192
193 struct InternetExplorer {
194 const IWebBrowser2Vtbl *lpWebBrowser2Vtbl;
195 HlinkFrame hlink_frame;
196
197 LONG ref;
198
199 HWND frame_hwnd;
200 HWND status_hwnd;
201 HMENU menu;
202
203 DocHost doc_host;
204 };
205
206 #define WEBBROWSER(x) ((IWebBrowser*) &(x)->lpWebBrowser2Vtbl)
207 #define WEBBROWSER2(x) ((IWebBrowser2*) &(x)->lpWebBrowser2Vtbl)
208 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
209 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectVtbl)
210 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
211 #define PERSTORAGE(x) ((IPersistStorage*) &(x)->lpPersistStorageVtbl)
212 #define PERMEMORY(x) ((IPersistMemory*) &(x)->lpPersistMemoryVtbl)
213 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
214 #define CLASSINFO(x) ((IProvideClassInfo2*) &(x)->lpProvideClassInfoVtbl)
215 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
216 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObjectVtbl);
217 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObjectVtbl);
218 #define ACTIVEOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
219 #define OLECMD(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
220 #define DATAOBJECT(x) ((IDataObject*) &(x)->lpDataObjectVtbl)
221
222 #define CLIENTSITE(x) ((IOleClientSite*) &(x)->lpOleClientSiteVtbl)
223 #define INPLACESITE(x) ((IOleInPlaceSite*) &(x)->lpOleInPlaceSiteVtbl)
224 #define DOCHOSTUI(x) ((IDocHostUIHandler*) &(x)->lpDocHostUIHandlerVtbl)
225 #define DOCHOSTUI2(x) ((IDocHostUIHandler2*) &(x)->lpDocHostUIHandlerVtbl)
226 #define DOCSITE(x) ((IOleDocumentSite*) &(x)->lpOleDocumentSiteVtbl)
227 #define CLDISP(x) ((IDispatch*) &(x)->lpDispatchVtbl)
228 #define PROPNOTIF(x) ((IPropertyNotifySink*) &(x)->lpIPropertyNotifySinkVtbl)
229 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
230
231 #define INPLACEFRAME(x) ((IOleInPlaceFrame*) &(x)->lpOleInPlaceFrameVtbl)
232
233 #define HLINKFRAME(x) ((IHlinkFrame*) &(x)->lpIHlinkFrameVtbl)
234 #define TARGETFRAME2(x) ((ITargetFrame2*) &(x)->lpITargetFrame2Vtbl)
235
236 void WebBrowser_OleObject_Init(WebBrowser*);
237 void WebBrowser_ViewObject_Init(WebBrowser*);
238 void WebBrowser_DataObject_Init(WebBrowser*);
239 void WebBrowser_Persist_Init(WebBrowser*);
240 void WebBrowser_ClassInfo_Init(WebBrowser*);
241
242 void WebBrowser_OleObject_Destroy(WebBrowser*);
243
244 void DocHost_Init(DocHost*,IDispatch*,const IDocHostContainerVtbl*);
245 void DocHost_ClientSite_Init(DocHost*);
246 void DocHost_Frame_Init(DocHost*);
247 void release_dochost_client(DocHost*);
248
249 void DocHost_Release(DocHost*);
250 void DocHost_ClientSite_Release(DocHost*);
251
252 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
253 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
254
255 void HlinkFrame_Init(HlinkFrame*,IUnknown*,DocHost*);
256 BOOL HlinkFrame_QI(HlinkFrame*,REFIID,void**);
257
258 HRESULT WebBrowserV1_Create(IUnknown*,REFIID,void**);
259 HRESULT WebBrowserV2_Create(IUnknown*,REFIID,void**);
260
261 void create_doc_view_hwnd(DocHost*);
262 void deactivate_document(DocHost*);
263 HRESULT dochost_object_available(DocHost*,IUnknown*);
264 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*);
265 HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*);
266 HRESULT go_home(DocHost*);
267 void set_doc_state(DocHost*,READYSTATE);
268
269 #define WM_DOCHOSTTASK (WM_USER+0x300)
270 void push_dochost_task(DocHost*,task_header_t*,task_proc_t,BOOL);
271 LRESULT process_dochost_task(DocHost*,LPARAM);
272
273 HRESULT InternetExplorer_Create(IUnknown*,REFIID,void**);
274 void InternetExplorer_WebBrowser_Init(InternetExplorer*);
275
276 HRESULT CUrlHistory_Create(IUnknown*,REFIID,void**);
277
278 HRESULT InternetShortcut_Create(IUnknown*,REFIID,void**);
279
280 HRESULT TaskbarList_Create(IUnknown*,REFIID,void**);
281
282 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
283 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
284
285 /**********************************************************************
286 * Dll lifetime tracking declaration for shdocvw.dll
287 */
288 extern LONG SHDOCVW_refCount;
289 static inline void SHDOCVW_LockModule(void) { InterlockedIncrement( &SHDOCVW_refCount ); }
290 static inline void SHDOCVW_UnlockModule(void) { InterlockedDecrement( &SHDOCVW_refCount ); }
291
292 extern HINSTANCE shdocvw_hinstance;
293 extern void register_iewindow_class(void);
294 extern void unregister_iewindow_class(void);
295 extern HRESULT update_ie_statustext(InternetExplorer*, LPCWSTR);
296
297 HRESULT register_class_object(BOOL);
298 HRESULT get_typeinfo(ITypeInfo**);
299 DWORD register_iexplore(BOOL);
300
301 const char *debugstr_variant(const VARIANT*);
302
303 /* memory allocation functions */
304
305 static inline void *heap_alloc(size_t len)
306 {
307 return HeapAlloc(GetProcessHeap(), 0, len);
308 }
309
310 static inline void *heap_alloc_zero(size_t len)
311 {
312 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
313 }
314
315 static inline void *heap_realloc(void *mem, size_t len)
316 {
317 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
318 }
319
320 static inline BOOL heap_free(void *mem)
321 {
322 return HeapFree(GetProcessHeap(), 0, mem);
323 }
324
325 static inline LPWSTR heap_strdupW(LPCWSTR str)
326 {
327 LPWSTR ret = NULL;
328
329 if(str) {
330 DWORD size;
331
332 size = (strlenW(str)+1)*sizeof(WCHAR);
333 ret = heap_alloc(size);
334 memcpy(ret, str, size);
335 }
336
337 return ret;
338 }
339
340 static inline LPWSTR co_strdupW(LPCWSTR str)
341 {
342 WCHAR *ret = CoTaskMemAlloc((strlenW(str) + 1)*sizeof(WCHAR));
343 if (ret)
344 lstrcpyW(ret, str);
345 return ret;
346 }
347
348 static inline LPWSTR co_strdupAtoW(LPCSTR str)
349 {
350 INT len;
351 WCHAR *ret;
352 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
353 ret = CoTaskMemAlloc(len*sizeof(WCHAR));
354 if (ret)
355 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
356 return ret;
357 }
358
359 static inline LPSTR co_strdupWtoA(LPCWSTR str)
360 {
361 INT len;
362 CHAR *ret;
363 len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, 0, 0);
364 ret = CoTaskMemAlloc(len);
365 if (ret)
366 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, 0, 0);
367 return ret;
368 }
369
370 #endif /* __WINE_SHDOCVW_H */