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