2 * Copyright 2005 James Hawkins
3 * Copyright 2007 Jacek Caban for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
41 #include "wine/itss.h"
42 #include "wine/unicode.h"
45 #define WB_GOFORWARD 1
56 typedef struct ContentItem {
57 struct ContentItem *parent;
58 struct ContentItem *child;
59 struct ContentItem *next;
68 typedef struct IndexSubItem {
73 typedef struct IndexItem {
74 struct IndexItem *next;
85 typedef struct CHMInfo
87 IITStorage *pITStorage;
91 IStream *strings_stream;
100 #define TAB_CONTENTS 0
103 #define TAB_FAVORITES 3
117 IOleClientSite *client_site;
118 IWebBrowser2 *web_browser;
119 IOleObject *wb_object;
133 LPWSTR pszCustomTabs;
136 ContentItem *content;
143 HHTab tabs[TAB_FAVORITES+1];
147 BOOL InitWebBrowser(HHInfo*,HWND);
148 void ReleaseWebBrowser(HHInfo*);
149 void ResizeWebBrowser(HHInfo*,DWORD,DWORD);
150 void DoPageAction(HHInfo*,DWORD);
152 void InitContent(HHInfo*);
153 void ReleaseContent(HHInfo*);
155 void InitIndex(HHInfo*);
156 void ReleaseIndex(HHInfo*);
158 CHMInfo *OpenCHM(LPCWSTR szFile);
159 BOOL LoadWinTypeFromCHM(HHInfo *info);
160 CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
161 void SetChmPath(ChmPath*,LPCWSTR,LPCWSTR);
162 IStream *GetChmStream(CHMInfo*,LPCWSTR,ChmPath*);
163 LPWSTR FindContextAlias(CHMInfo*,DWORD);
165 HHInfo *CreateHelpViewer(LPCWSTR);
166 void ReleaseHelpViewer(HHInfo*);
167 BOOL NavigateToUrl(HHInfo*,LPCWSTR);
168 BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
170 /* memory allocation functions */
172 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
174 return HeapAlloc(GetProcessHeap(), 0, len);
177 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
179 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
182 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
184 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
187 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
189 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
192 static inline BOOL heap_free(void *mem)
194 return HeapFree(GetProcessHeap(), 0, mem);
197 static inline LPWSTR strdupW(LPCWSTR str)
205 size = (strlenW(str)+1)*sizeof(WCHAR);
206 ret = heap_alloc(size);
207 memcpy(ret, str, size);
212 static inline LPWSTR strdupnAtoW(LPCSTR str, LONG lenA)
222 /* find length of string */
223 LPCSTR eos = memchr(str, 0, lenA);
224 if (eos) lenA = eos - str;
227 len = MultiByteToWideChar(CP_ACP, 0, str, lenA, NULL, 0)+1; /* +1 for null pad */
228 ret = heap_alloc(len*sizeof(WCHAR));
229 MultiByteToWideChar(CP_ACP, 0, str, lenA, ret, len);
235 static inline LPWSTR strdupAtoW(LPCSTR str)
237 return strdupnAtoW(str, -1);
242 extern HINSTANCE hhctrl_hinstance;
243 extern BOOL hh_process;