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