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
25 #define WIN32_NO_STATUS
27 #define COM_NO_WINDOWS_H
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
46 #include <wine/itss.h>
47 #include <wine/unicode.h>
48 #include <wine/list.h>
50 #include <wine/debug.h>
51 WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp
);
56 #define WB_GOFORWARD 1
68 typedef struct ContentItem
{
69 struct ContentItem
*parent
;
70 struct ContentItem
*child
;
71 struct ContentItem
*next
;
80 typedef struct IndexSubItem
{
85 typedef struct IndexItem
{
86 struct IndexItem
*next
;
98 typedef struct SearchItem
{
99 struct SearchItem
*next
;
106 typedef struct CHMInfo
108 IITStorage
*pITStorage
;
112 IStream
*strings_stream
;
125 #define TAB_CONTENTS 0
128 #define TAB_FAVORITES 3
129 #define TAB_NUMTABS TAB_FAVORITES
150 HIMAGELIST hImageList
;
153 struct wintype_stringsW
{
164 WCHAR
*pszCustomTabs
;
167 struct wintype_stringsA
{
182 IOleClientSite
*client_site
;
183 IWebBrowser2
*web_browser
;
184 IOleObject
*wb_object
;
188 struct wintype_stringsA stringsA
;
189 struct wintype_stringsW stringsW
;
193 ContentItem
*content
;
197 ContentsTab contents
;
202 HHTab tabs
[TAB_FAVORITES
+1];
203 int viewer_initialized
;
207 BOOL
InitWebBrowser(HHInfo
*,HWND
) DECLSPEC_HIDDEN
;
208 void ReleaseWebBrowser(HHInfo
*) DECLSPEC_HIDDEN
;
209 void ResizeWebBrowser(HHInfo
*,DWORD
,DWORD
) DECLSPEC_HIDDEN
;
210 void DoPageAction(HHInfo
*,DWORD
) DECLSPEC_HIDDEN
;
212 void InitContent(HHInfo
*) DECLSPEC_HIDDEN
;
213 void ReleaseContent(HHInfo
*) DECLSPEC_HIDDEN
;
214 void ActivateContentTopic(HWND
,LPCWSTR
,ContentItem
*) DECLSPEC_HIDDEN
;
216 void InitIndex(HHInfo
*) DECLSPEC_HIDDEN
;
217 void ReleaseIndex(HHInfo
*) DECLSPEC_HIDDEN
;
219 CHMInfo
*OpenCHM(LPCWSTR szFile
) DECLSPEC_HIDDEN
;
220 BOOL
LoadWinTypeFromCHM(HHInfo
*info
) DECLSPEC_HIDDEN
;
221 CHMInfo
*CloseCHM(CHMInfo
*pCHMInfo
) DECLSPEC_HIDDEN
;
222 void SetChmPath(ChmPath
*,LPCWSTR
,LPCWSTR
) DECLSPEC_HIDDEN
;
223 IStream
*GetChmStream(CHMInfo
*,LPCWSTR
,ChmPath
*) DECLSPEC_HIDDEN
;
224 LPWSTR
FindContextAlias(CHMInfo
*,DWORD
) DECLSPEC_HIDDEN
;
225 WCHAR
*GetDocumentTitle(CHMInfo
*,LPCWSTR
) DECLSPEC_HIDDEN
;
227 HHInfo
*CreateHelpViewer(HHInfo
*,LPCWSTR
,HWND
) DECLSPEC_HIDDEN
;
228 void ReleaseHelpViewer(HHInfo
*) DECLSPEC_HIDDEN
;
229 BOOL
NavigateToUrl(HHInfo
*,LPCWSTR
) DECLSPEC_HIDDEN
;
230 BOOL
NavigateToChm(HHInfo
*,LPCWSTR
,LPCWSTR
) DECLSPEC_HIDDEN
;
231 void MergeChmProperties(HH_WINTYPEW
*,HHInfo
*,BOOL
) DECLSPEC_HIDDEN
;
232 void UpdateHelpWindow(HHInfo
*info
) DECLSPEC_HIDDEN
;
234 void InitSearch(HHInfo
*info
, const char *needle
) DECLSPEC_HIDDEN
;
235 void ReleaseSearch(HHInfo
*info
) DECLSPEC_HIDDEN
;
237 LPCWSTR
skip_schema(LPCWSTR url
) DECLSPEC_HIDDEN
;
238 void wintype_stringsA_free(struct wintype_stringsA
*stringsA
) DECLSPEC_HIDDEN
;
239 void wintype_stringsW_free(struct wintype_stringsW
*stringsW
) DECLSPEC_HIDDEN
;
240 WCHAR
*decode_html(const char *html_fragment
, int html_fragment_len
, UINT code_page
) DECLSPEC_HIDDEN
;
241 HHInfo
*find_window(const WCHAR
*window
) DECLSPEC_HIDDEN
;
243 /* memory allocation functions */
245 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len
)
247 return HeapAlloc(GetProcessHeap(), 0, len
);
250 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len
)
252 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
255 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem
, size_t len
)
257 return HeapReAlloc(GetProcessHeap(), 0, mem
, len
);
260 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem
, size_t len
)
262 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, mem
, len
);
265 static inline BOOL
heap_free(void *mem
)
267 return HeapFree(GetProcessHeap(), 0, mem
);
270 static inline LPWSTR
strdupW(LPCWSTR str
)
278 size
= (strlenW(str
)+1)*sizeof(WCHAR
);
279 ret
= heap_alloc(size
);
280 memcpy(ret
, str
, size
);
285 static inline LPWSTR
strdupnAtoW(LPCSTR str
, LONG lenA
)
295 /* find length of string */
296 LPCSTR eos
= memchr(str
, 0, lenA
);
297 if (eos
) lenA
= eos
- str
;
300 len
= MultiByteToWideChar(CP_ACP
, 0, str
, lenA
, NULL
, 0)+1; /* +1 for null pad */
301 ret
= heap_alloc(len
*sizeof(WCHAR
));
302 MultiByteToWideChar(CP_ACP
, 0, str
, lenA
, ret
, len
);
308 static inline LPWSTR
strdupAtoW(LPCSTR str
)
310 return strdupnAtoW(str
, -1);
313 static inline LPSTR
strdupWtoA(LPCWSTR str
)
321 len
= WideCharToMultiByte(CP_ACP
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
322 ret
= heap_alloc(len
);
323 WideCharToMultiByte(CP_ACP
, 0, str
, -1, ret
, len
, NULL
, NULL
);
328 extern HINSTANCE hhctrl_hinstance DECLSPEC_HIDDEN
;
329 extern BOOL hh_process DECLSPEC_HIDDEN
;