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