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"
43 #include "wine/list.h"
46 #define WB_GOFORWARD 1
58 typedef struct ContentItem {
59 struct ContentItem *parent;
60 struct ContentItem *child;
61 struct ContentItem *next;
70 typedef struct IndexSubItem {
75 typedef struct IndexItem {
76 struct IndexItem *next;
88 typedef struct SearchItem {
89 struct SearchItem *next;
96 typedef struct CHMInfo
98 IITStorage *pITStorage;
102 IStream *strings_stream;
115 #define TAB_CONTENTS 0
118 #define TAB_FAVORITES 3
119 #define TAB_NUMTABS TAB_FAVORITES
140 HIMAGELIST hImageList;
143 struct wintype_stringsW {
154 WCHAR *pszCustomTabs;
157 struct wintype_stringsA {
172 IOleClientSite *client_site;
173 IWebBrowser2 *web_browser;
174 IOleObject *wb_object;
178 struct wintype_stringsA stringsA;
179 struct wintype_stringsW stringsW;
183 ContentItem *content;
187 ContentsTab contents;
192 HHTab tabs[TAB_FAVORITES+1];
193 int viewer_initialized;
197 BOOL InitWebBrowser(HHInfo*,HWND) DECLSPEC_HIDDEN;
198 void ReleaseWebBrowser(HHInfo*) DECLSPEC_HIDDEN;
199 void ResizeWebBrowser(HHInfo*,DWORD,DWORD) DECLSPEC_HIDDEN;
200 void DoPageAction(HHInfo*,DWORD) DECLSPEC_HIDDEN;
202 void InitContent(HHInfo*) DECLSPEC_HIDDEN;
203 void ReleaseContent(HHInfo*) DECLSPEC_HIDDEN;
204 void ActivateContentTopic(HWND,LPCWSTR,ContentItem *) DECLSPEC_HIDDEN;
206 void InitIndex(HHInfo*) DECLSPEC_HIDDEN;
207 void ReleaseIndex(HHInfo*) DECLSPEC_HIDDEN;
209 CHMInfo *OpenCHM(LPCWSTR szFile) DECLSPEC_HIDDEN;
210 BOOL LoadWinTypeFromCHM(HHInfo *info) DECLSPEC_HIDDEN;
211 CHMInfo *CloseCHM(CHMInfo *pCHMInfo) DECLSPEC_HIDDEN;
212 void SetChmPath(ChmPath*,LPCWSTR,LPCWSTR) DECLSPEC_HIDDEN;
213 IStream *GetChmStream(CHMInfo*,LPCWSTR,ChmPath*) DECLSPEC_HIDDEN;
214 LPWSTR FindContextAlias(CHMInfo*,DWORD) DECLSPEC_HIDDEN;
215 WCHAR *GetDocumentTitle(CHMInfo*,LPCWSTR) DECLSPEC_HIDDEN;
217 HHInfo *CreateHelpViewer(HHInfo*,LPCWSTR,HWND) DECLSPEC_HIDDEN;
218 void ReleaseHelpViewer(HHInfo*) DECLSPEC_HIDDEN;
219 BOOL NavigateToUrl(HHInfo*,LPCWSTR) DECLSPEC_HIDDEN;
220 BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR) DECLSPEC_HIDDEN;
221 void MergeChmProperties(HH_WINTYPEW*,HHInfo*,BOOL) DECLSPEC_HIDDEN;
222 void UpdateHelpWindow(HHInfo *info) DECLSPEC_HIDDEN;
224 void InitSearch(HHInfo *info, const char *needle) DECLSPEC_HIDDEN;
225 void ReleaseSearch(HHInfo *info) DECLSPEC_HIDDEN;
227 LPCWSTR skip_schema(LPCWSTR url) DECLSPEC_HIDDEN;
228 void wintype_stringsA_free(struct wintype_stringsA *stringsA) DECLSPEC_HIDDEN;
229 void wintype_stringsW_free(struct wintype_stringsW *stringsW) DECLSPEC_HIDDEN;
230 WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page) DECLSPEC_HIDDEN;
231 HHInfo *find_window(const WCHAR *window) DECLSPEC_HIDDEN;
233 /* memory allocation functions */
235 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
237 return HeapAlloc(GetProcessHeap(), 0, len);
240 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
242 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
245 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
247 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
250 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
252 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
255 static inline BOOL heap_free(void *mem)
257 return HeapFree(GetProcessHeap(), 0, mem);
260 static inline LPWSTR strdupW(LPCWSTR str)
268 size = (strlenW(str)+1)*sizeof(WCHAR);
269 ret = heap_alloc(size);
270 memcpy(ret, str, size);
275 static inline LPWSTR strdupnAtoW(LPCSTR str, LONG lenA)
285 /* find length of string */
286 LPCSTR eos = memchr(str, 0, lenA);
287 if (eos) lenA = eos - str;
290 len = MultiByteToWideChar(CP_ACP, 0, str, lenA, NULL, 0)+1; /* +1 for null pad */
291 ret = heap_alloc(len*sizeof(WCHAR));
292 MultiByteToWideChar(CP_ACP, 0, str, lenA, ret, len);
298 static inline LPWSTR strdupAtoW(LPCSTR str)
300 return strdupnAtoW(str, -1);
303 static inline LPSTR strdupWtoA(LPCWSTR str)
311 len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
312 ret = heap_alloc(len);
313 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, NULL, NULL);
318 extern HINSTANCE hhctrl_hinstance DECLSPEC_HIDDEN;
319 extern BOOL hh_process DECLSPEC_HIDDEN;