Module: wine Branch: master Commit: cf5e6bcec9e0fba7ecfee1951be666569bd8e628 URL: http://source.winehq.org/git/wine.git/?a=commit;h=cf5e6bcec9e0fba7ecfee1951b...
Author: Hin-Tak Leung Hin-Tak@localhost.localdomain Date: Tue Mar 25 20:55:07 2008 +0000
hhctrl.ocx: Implement more navigation of chm to TOC, default topic and specific title.
---
dlls/hhctrl.ocx/chm.c | 33 ++++++++++++++++++++++++++++++++- dlls/hhctrl.ocx/hhctrl.c | 1 + dlls/hhctrl.ocx/hhctrl.h | 25 ++++++++++++++++++++++--- 3 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/dlls/hhctrl.ocx/chm.c b/dlls/hhctrl.ocx/chm.c index 710013e..ece05f0 100644 --- a/dlls/hhctrl.ocx/chm.c +++ b/dlls/hhctrl.ocx/chm.c @@ -113,11 +113,20 @@ static BOOL ReadChmSystem(CHMInfo *chm) break;
switch(entry.code) { + case 0x0: + TRACE("TOC is %s\n", debugstr_an(buf, entry.len)); + heap_free(chm->defToc); + chm->defToc = strdupnAtoW(buf, entry.len); + break; case 0x2: TRACE("Default topic is %s\n", debugstr_an(buf, entry.len)); + heap_free(chm->defTopic); + chm->defTopic = strdupnAtoW(buf, entry.len); break; case 0x3: TRACE("Title is %s\n", debugstr_an(buf, entry.len)); + heap_free(chm->defTitle); + chm->defTitle = strdupnAtoW(buf, entry.len); break; case 0x5: TRACE("Default window is %s\n", debugstr_an(buf, entry.len)); @@ -212,7 +221,26 @@ BOOL LoadWinTypeFromCHM(HHInfo *info)
hr = IStorage_OpenStream(pStorage, windowsW, NULL, STGM_READ, 0, &pStream); if (FAILED(hr)) - return FALSE; + { + /* no defined window types so use (hopefully) sane defaults */ + static const WCHAR defaultwinW[] = {'d','e','f','a','u','l','t','w','i','n','\0'}; + static const WCHAR null[] = {0}; + memset((void*)&(info->WinType), 0, sizeof(info->WinType)); + info->WinType.cbStruct=sizeof(info->WinType); + info->WinType.fUniCodeStrings=TRUE; + info->WinType.pszType=strdupW(defaultwinW); + info->WinType.pszToc = strdupW(info->pCHMInfo->defToc); + info->WinType.pszIndex = strdupW(null); + info->WinType.fsValidMembers=0; + info->WinType.fsWinProperties=HHWIN_PROP_TRI_PANE; + info->WinType.pszCaption=strdupW(info->pCHMInfo->defTitle); + info->WinType.dwStyles=WS_POPUP; + info->WinType.dwExStyles=0; + info->WinType.nShowState=SW_SHOW; + info->WinType.pszFile=strdupW(info->pCHMInfo->defTopic); + info->WinType.curNavType=HHWIN_NAVTYPE_TOC; + return TRUE; + }
/* jump past the #WINDOWS header */ liOffset.QuadPart = sizeof(DWORD) * 2; @@ -393,6 +421,9 @@ CHMInfo *CloseCHM(CHMInfo *chm) }
heap_free(chm->strings); + heap_free(chm->defTitle); + heap_free(chm->defTopic); + heap_free(chm->defToc); heap_free(chm);
return NULL; diff --git a/dlls/hhctrl.ocx/hhctrl.c b/dlls/hhctrl.ocx/hhctrl.c index f8b5c99..472b7cf 100644 --- a/dlls/hhctrl.ocx/hhctrl.c +++ b/dlls/hhctrl.ocx/hhctrl.c @@ -114,6 +114,7 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat memcpy(chm_file, filename, (index-filename)*sizeof(WCHAR)); chm_file[index-filename] = 0; filename = chm_file; + index += 2; /* advance beyond "::" for calling NavigateToChm() later */ } else { diff --git a/dlls/hhctrl.ocx/hhctrl.h b/dlls/hhctrl.ocx/hhctrl.h index 26c9d4d..6f7c96b 100644 --- a/dlls/hhctrl.ocx/hhctrl.h +++ b/dlls/hhctrl.ocx/hhctrl.h @@ -74,6 +74,10 @@ typedef struct CHMInfo IStream *strings_stream; char **strings; DWORD strings_size; + + WCHAR *defTopic; + WCHAR *defTitle; + WCHAR *defToc; } CHMInfo;
#define TAB_CONTENTS 0 @@ -177,7 +181,7 @@ static inline LPWSTR strdupW(LPCWSTR str) return ret; }
-static inline LPWSTR strdupAtoW(LPCSTR str) +static inline LPWSTR strdupnAtoW(LPCSTR str, LONG lenA) { LPWSTR ret; DWORD len; @@ -185,13 +189,28 @@ static inline LPWSTR strdupAtoW(LPCSTR str) if(!str) return NULL;
- len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + if (lenA > 0) + { + /* find length of string */ + LPCSTR eos = memchr(str, 0, lenA); + if (eos) lenA = eos - str; + } + + len = MultiByteToWideChar(CP_ACP, 0, str, lenA, NULL, 0)+1; /* +1 for null pad */ ret = heap_alloc(len*sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); + MultiByteToWideChar(CP_ACP, 0, str, lenA, ret, len); + ret[len-1] = 0;
return ret; }
+static inline LPWSTR strdupAtoW(LPCSTR str) +{ + return strdupnAtoW(str, -1); +} + + + extern HINSTANCE hhctrl_hinstance; extern BOOL hh_process;