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