Finish the Wine sync. These components are not just rc file changes
[reactos.git] / reactos / 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 COBJMACROS
26
27 #include <stdarg.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33
34 #include "ole2.h"
35 #include "olectl.h"
36 #include "shlobj.h"
37 #include "exdisp.h"
38 #include "mshtmhst.h"
39 #include "hlink.h"
40 #include "htiframe.h"
41
42 #include "wine/unicode.h"
43 #include "resource.h"
44
45
46 /**********************************************************************
47 * Shell Instance Objects
48 */
49 extern HRESULT SHDOCVW_GetShellInstanceObjectClassObject(REFCLSID rclsid,
50 REFIID riid, LPVOID *ppvClassObj);
51
52 /**********************************************************************
53 * WebBrowser declaration for SHDOCVW.DLL
54 */
55
56 typedef struct ConnectionPoint ConnectionPoint;
57 typedef struct DocHost DocHost;
58
59 typedef struct {
60 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
61
62 ConnectionPoint *wbe2;
63 ConnectionPoint *wbe;
64 ConnectionPoint *pns;
65
66 IUnknown *impl;
67 } ConnectionPointContainer;
68
69 struct _task_header_t;
70
71 typedef void (*task_proc_t)(DocHost*, struct _task_header_t*);
72
73 typedef struct _task_header_t {
74 task_proc_t proc;
75 } task_header_t;
76
77 struct DocHost {
78 const IOleClientSiteVtbl *lpOleClientSiteVtbl;
79 const IOleInPlaceSiteVtbl *lpOleInPlaceSiteVtbl;
80 const IDocHostUIHandler2Vtbl *lpDocHostUIHandlerVtbl;
81 const IOleDocumentSiteVtbl *lpOleDocumentSiteVtbl;
82 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
83 const IDispatchVtbl *lpDispatchVtbl;
84 const IPropertyNotifySinkVtbl *lpIPropertyNotifySinkVtbl;
85 const IServiceProviderVtbl *lpServiceProviderVtbl;
86
87 /* Interfaces of InPlaceFrame object */
88 const IOleInPlaceFrameVtbl *lpOleInPlaceFrameVtbl;
89
90 IDispatch *disp;
91
92 IDispatch *client_disp;
93 IDocHostUIHandler *hostui;
94 IOleInPlaceFrame *frame;
95
96 IUnknown *document;
97 IOleDocumentView *view;
98 IUnknown *doc_navigate;
99
100 HWND hwnd;
101 HWND frame_hwnd;
102
103 LPOLESTR url;
104
105 VARIANT_BOOL silent;
106 VARIANT_BOOL offline;
107 VARIANT_BOOL busy;
108
109 READYSTATE ready_state;
110 READYSTATE doc_state;
111 DWORD prop_notif_cookie;
112 BOOL is_prop_notif;
113
114 ConnectionPointContainer cps;
115 };
116
117 struct WebBrowser {
118 /* Interfaces available via WebBrowser object */
119
120 const IWebBrowser2Vtbl *lpWebBrowser2Vtbl;
121 const IOleObjectVtbl *lpOleObjectVtbl;
122 const IOleInPlaceObjectVtbl *lpOleInPlaceObjectVtbl;
123 const IOleControlVtbl *lpOleControlVtbl;
124 const IPersistStorageVtbl *lpPersistStorageVtbl;
125 const IPersistMemoryVtbl *lpPersistMemoryVtbl;
126 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
127 const IProvideClassInfo2Vtbl *lpProvideClassInfoVtbl;
128 const IViewObject2Vtbl *lpViewObjectVtbl;
129 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
130 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
131 const IHlinkFrameVtbl *lpHlinkFrameVtbl;
132 const ITargetFrame2Vtbl *lpITargetFrame2Vtbl;
133 const IServiceProviderVtbl *lpServiceProviderVtbl;
134 const IDataObjectVtbl *lpDataObjectVtbl;
135
136 LONG ref;
137
138 INT version;
139
140 IOleClientSite *client;
141 IOleContainer *container;
142 IOleInPlaceSite *inplace;
143
144 /* window context */
145
146 HWND frame_hwnd;
147 IOleInPlaceUIWindow *uiwindow;
148 RECT pos_rect;
149 RECT clip_rect;
150 OLEINPLACEFRAMEINFO frameinfo;
151 SIZEL extent;
152
153 HWND shell_embedding_hwnd;
154
155 VARIANT_BOOL register_browser;
156 VARIANT_BOOL visible;
157 VARIANT_BOOL menu_bar;
158 VARIANT_BOOL address_bar;
159 VARIANT_BOOL status_bar;
160 VARIANT_BOOL tool_bar;
161 VARIANT_BOOL full_screen;
162 VARIANT_BOOL theater_mode;
163
164 DocHost doc_host;
165 };
166
167 struct InternetExplorer {
168 const IWebBrowser2Vtbl *lpWebBrowser2Vtbl;
169
170 LONG ref;
171
172 HWND frame_hwnd;
173
174 DocHost doc_host;
175 };
176
177 #define WEBBROWSER(x) ((IWebBrowser*) &(x)->lpWebBrowser2Vtbl)
178 #define WEBBROWSER2(x) ((IWebBrowser2*) &(x)->lpWebBrowser2Vtbl)
179 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
180 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectVtbl)
181 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
182 #define PERSTORAGE(x) ((IPersistStorage*) &(x)->lpPersistStorageVtbl)
183 #define PERMEMORY(x) ((IPersistMemory*) &(x)->lpPersistMemoryVtbl)
184 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
185 #define CLASSINFO(x) ((IProvideClassInfo2*) &(x)->lpProvideClassInfoVtbl)
186 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
187 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObjectVtbl);
188 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObjectVtbl);
189 #define ACTIVEOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
190 #define OLECMD(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
191 #define HLINKFRAME(x) ((IHlinkFrame*) &(x)->lpHlinkFrameVtbl)
192 #define DATAOBJECT(x) ((IDataObject*) &(x)->lpDataObjectVtbl)
193 #define TARGETFRAME2(x) ((ITargetFrame2*) &(x)->lpITargetFrame2Vtbl)
194
195 #define CLIENTSITE(x) ((IOleClientSite*) &(x)->lpOleClientSiteVtbl)
196 #define INPLACESITE(x) ((IOleInPlaceSite*) &(x)->lpOleInPlaceSiteVtbl)
197 #define DOCHOSTUI(x) ((IDocHostUIHandler*) &(x)->lpDocHostUIHandlerVtbl)
198 #define DOCHOSTUI2(x) ((IDocHostUIHandler2*) &(x)->lpDocHostUIHandlerVtbl)
199 #define DOCSITE(x) ((IOleDocumentSite*) &(x)->lpOleDocumentSiteVtbl)
200 #define CLDISP(x) ((IDispatch*) &(x)->lpDispatchVtbl)
201 #define PROPNOTIF(x) ((IPropertyNotifySink*) &(x)->lpIPropertyNotifySinkVtbl)
202 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
203
204 #define INPLACEFRAME(x) ((IOleInPlaceFrame*) &(x)->lpOleInPlaceFrameVtbl)
205
206 void WebBrowser_OleObject_Init(WebBrowser*);
207 void WebBrowser_ViewObject_Init(WebBrowser*);
208 void WebBrowser_DataObject_Init(WebBrowser*);
209 void WebBrowser_Persist_Init(WebBrowser*);
210 void WebBrowser_ClassInfo_Init(WebBrowser*);
211 void WebBrowser_HlinkFrame_Init(WebBrowser*);
212
213 void WebBrowser_OleObject_Destroy(WebBrowser*);
214
215 void DocHost_Init(DocHost*,IDispatch*);
216 void DocHost_ClientSite_Init(DocHost*);
217 void DocHost_Frame_Init(DocHost*);
218 void release_dochost_client(DocHost*);
219
220 void DocHost_Release(DocHost*);
221 void DocHost_ClientSite_Release(DocHost*);
222
223 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
224 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
225
226 HRESULT WebBrowserV1_Create(IUnknown*,REFIID,void**);
227 HRESULT WebBrowserV2_Create(IUnknown*,REFIID,void**);
228
229 void create_doc_view_hwnd(DocHost*);
230 void deactivate_document(DocHost*);
231 HRESULT dochost_object_available(DocHost*,IUnknown*);
232 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*);
233 HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*);
234 HRESULT go_home(DocHost*);
235 void set_doc_state(DocHost*,READYSTATE);
236
237 #define WM_DOCHOSTTASK (WM_USER+0x300)
238 void push_dochost_task(DocHost*,task_header_t*,task_proc_t,BOOL);
239 LRESULT process_dochost_task(DocHost*,LPARAM);
240
241 HRESULT InternetExplorer_Create(IUnknown*,REFIID,void**);
242 void InternetExplorer_WebBrowser_Init(InternetExplorer*);
243
244 HRESULT CUrlHistory_Create(IUnknown*,REFIID,void**);
245
246 HRESULT InternetShortcut_Create(IUnknown*,REFIID,void**);
247
248 HRESULT TaskbarList_Create(IUnknown*,REFIID,void**);
249
250 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
251
252 /**********************************************************************
253 * Dll lifetime tracking declaration for shdocvw.dll
254 */
255 extern LONG SHDOCVW_refCount;
256 static inline void SHDOCVW_LockModule(void) { InterlockedIncrement( &SHDOCVW_refCount ); }
257 static inline void SHDOCVW_UnlockModule(void) { InterlockedDecrement( &SHDOCVW_refCount ); }
258
259 extern HINSTANCE shdocvw_hinstance;
260 extern void register_iewindow_class(void);
261 extern void unregister_iewindow_class(void);
262
263 HRESULT register_class_object(BOOL);
264 HRESULT get_typeinfo(ITypeInfo**);
265 DWORD register_iexplore(BOOL);
266
267 const char *debugstr_variant(const VARIANT*);
268
269 /* memory allocation functions */
270
271 static inline void *heap_alloc(size_t len)
272 {
273 return HeapAlloc(GetProcessHeap(), 0, len);
274 }
275
276 static inline void *heap_alloc_zero(size_t len)
277 {
278 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
279 }
280
281 static inline void *heap_realloc(void *mem, size_t len)
282 {
283 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
284 }
285
286 static inline BOOL heap_free(void *mem)
287 {
288 return HeapFree(GetProcessHeap(), 0, mem);
289 }
290
291 static inline LPWSTR heap_strdupW(LPCWSTR str)
292 {
293 LPWSTR ret = NULL;
294
295 if(str) {
296 DWORD size;
297
298 size = (strlenW(str)+1)*sizeof(WCHAR);
299 ret = heap_alloc(size);
300 memcpy(ret, str, size);
301 }
302
303 return ret;
304 }
305
306 static inline LPWSTR co_strdupW(LPCWSTR str)
307 {
308 WCHAR *ret = CoTaskMemAlloc((strlenW(str) + 1)*sizeof(WCHAR));
309 if (ret)
310 lstrcpyW(ret, str);
311 return ret;
312 }
313
314 static inline LPWSTR co_strdupAtoW(LPCSTR str)
315 {
316 INT len;
317 WCHAR *ret;
318 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
319 ret = CoTaskMemAlloc(len*sizeof(WCHAR));
320 if (ret)
321 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
322 return ret;
323 }
324
325 static inline LPSTR co_strdupWtoA(LPCWSTR str)
326 {
327 INT len;
328 CHAR *ret;
329 len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, 0, 0);
330 ret = CoTaskMemAlloc(len);
331 if (ret)
332 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, 0, 0);
333 return ret;
334 }
335
336 #endif /* __WINE_SHDOCVW_H */