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