Module: wine Branch: master Commit: 8e0bc11f7266714319a46af171ab517b032f9c71 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8e0bc11f7266714319a46af171...
Author: Kirill K Smirnov Kirill.K.Smirnov@star.math.spbu.ru Date: Thu Oct 26 13:21:44 2006 +0400
winhelp: Properly implement context help and JumpContext macro.
---
programs/winhelp/hlpfile.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ programs/winhelp/hlpfile.h | 9 ++++++++ programs/winhelp/macro.c | 10 +++++++- programs/winhelp/winhelp.c | 15 +++++++++++++ programs/winhelp/winhelp.h | 1 + 5 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/programs/winhelp/hlpfile.c b/programs/winhelp/hlpfile.c index 04e5645..e95dfdf 100644 --- a/programs/winhelp/hlpfile.c +++ b/programs/winhelp/hlpfile.c @@ -84,6 +84,7 @@ static BOOL HLPFILE_UncompressLZ77_Phra static BOOL HLPFILE_Uncompress_Phrases40(HLPFILE*); static BOOL HLPFILE_Uncompress_Topic(HLPFILE*); static BOOL HLPFILE_GetContext(HLPFILE*); +static BOOL HLPFILE_GetMap(HLPFILE*); static BOOL HLPFILE_AddPage(HLPFILE*, BYTE*, BYTE*, unsigned); static BOOL HLPFILE_AddParagraph(HLPFILE*, BYTE *, BYTE*, unsigned*); static void HLPFILE_Uncompress2(const BYTE*, const BYTE*, BYTE*, const BYTE*); @@ -174,6 +175,28 @@ HLPFILE_PAGE *HLPFILE_PageByHash(HLPFILE
/*********************************************************************** * + * HLPFILE_PageByMap + */ +HLPFILE_PAGE *HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap) +{ + int i; + + if (!hlpfile) return 0; + + WINE_TRACE("<%s>[%x]\n", hlpfile->lpszPath, lMap); + + for (i = 0; i < hlpfile->wMapLen; i++) + { + if (hlpfile->Map[i].lMap == lMap) + return HLPFILE_PageByOffset(hlpfile, hlpfile->Map[i].offset); + } + + WINE_ERR("Page of Map %x not found in file %s\n", lMap, hlpfile->lpszPath); + return NULL; +} + +/*********************************************************************** + * * HLPFILE_Contents */ HLPFILE_PAGE* HLPFILE_Contents(HLPFILE *hlpfile) @@ -237,6 +260,8 @@ HLPFILE *HLPFILE_ReadHlpFile(LPCSTR lpsz hlpfile->first_macro = NULL; hlpfile->wContextLen = 0; hlpfile->Context = NULL; + hlpfile->wMapLen = 0; + hlpfile->Map = NULL; hlpfile->contents_start = 0xFFFFFFFF; hlpfile->prev = NULL; hlpfile->next = first_hlpfile; @@ -347,6 +372,7 @@ static BOOL HLPFILE_DoReadHlpFile(HLPFIL ref = GET_UINT(buf, 0xc); } while (ref != 0xffffffff);
+ HLPFILE_GetMap(hlpfile); return HLPFILE_GetContext(hlpfile); }
@@ -1902,6 +1928,29 @@ static BOOL HLPFILE_GetContext(HLPFILE * return TRUE; }
+/*********************************************************************** + * + * HLPFILE_GetMap + */ +static BOOL HLPFILE_GetMap(HLPFILE *hlpfile) +{ + BYTE *cbuf, *cend; + unsigned entries, i; + + if (!HLPFILE_FindSubFile("|CTXOMAP", &cbuf, &cend)) {WINE_WARN("no map section\n"); return FALSE;} + + entries = GET_USHORT(cbuf, 9); + hlpfile->Map = HeapAlloc(GetProcessHeap(), 0, entries * sizeof(HLPFILE_MAP)); + if (!hlpfile->Map) return FALSE; + hlpfile->wMapLen = entries; + for (i = 0; i < entries; i++) + { + hlpfile->Map[i].lMap = GET_UINT(cbuf+11,i*8); + hlpfile->Map[i].offset = GET_UINT(cbuf+11,i*8+4); + } + return TRUE; +} + /****************************************************************** * HLPFILE_DeleteLink * @@ -2006,6 +2055,7 @@ void HLPFILE_FreeHlpFile(HLPFILE* hlpfil
if (hlpfile->numWindows) HeapFree(GetProcessHeap(), 0, hlpfile->windows); HeapFree(GetProcessHeap(), 0, hlpfile->Context); + HeapFree(GetProcessHeap(), 0, hlpfile->Map); HeapFree(GetProcessHeap(), 0, hlpfile->lpszTitle); HeapFree(GetProcessHeap(), 0, hlpfile->lpszCopyright); HeapFree(GetProcessHeap(), 0, hlpfile); diff --git a/programs/winhelp/hlpfile.h b/programs/winhelp/hlpfile.h index 2f3ffed..4d62cdd 100644 --- a/programs/winhelp/hlpfile.h +++ b/programs/winhelp/hlpfile.h @@ -110,6 +110,12 @@ typedef struct
typedef struct { + LONG lMap; + unsigned long offset; +} HLPFILE_MAP; + +typedef struct +{ LOGFONT LogFont; HFONT hFont; COLORREF color; @@ -124,6 +130,8 @@ typedef struct tagHlpFileFile HLPFILE_MACRO* first_macro; unsigned wContextLen; HLPFILE_CONTEXT* Context; + unsigned wMapLen; + HLPFILE_MAP* Map; unsigned long contents_start;
struct tagHlpFileFile* prev; @@ -148,6 +156,7 @@ typedef struct tagHlpFileFile HLPFILE* HLPFILE_ReadHlpFile(LPCSTR lpszPath); HLPFILE_PAGE* HLPFILE_Contents(HLPFILE* hlpfile); HLPFILE_PAGE* HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash); +HLPFILE_PAGE* HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap); HLPFILE_PAGE* HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset); LONG HLPFILE_Hash(LPCSTR lpszContext); void HLPFILE_FreeLink(HLPFILE_LINK* link); diff --git a/programs/winhelp/macro.c b/programs/winhelp/macro.c index 663a24c..712ff18 100644 --- a/programs/winhelp/macro.c +++ b/programs/winhelp/macro.c @@ -680,8 +680,14 @@ void CALLBACK MACRO_JumpContents(LPCSTR
void CALLBACK MACRO_JumpContext(LPCSTR lpszPath, LPCSTR lpszWindow, LONG context) { - WINE_FIXME("("%s", "%s", %d)semi-stub\n", lpszPath, lpszWindow, context); - return MACRO_JumpContents(lpszPath, lpszWindow); + HLPFILE* hlpfile; + + WINE_TRACE("("%s", "%s", %d)", lpszPath, lpszWindow, context); + hlpfile = WINHELP_LookupHelpFile(lpszPath); + /* Some madness: what user calls 'context', hlpfile calls 'map' */ + WINHELP_CreateHelpWindowByMap(hlpfile, context, + WINHELP_GetWindowInfo(hlpfile, lpszWindow), + SW_NORMAL); }
void CALLBACK MACRO_JumpHash(LPCSTR lpszPath, LPCSTR lpszWindow, LONG lHash) diff --git a/programs/winhelp/winhelp.c b/programs/winhelp/winhelp.c index 4e9a717..1bf476f 100644 --- a/programs/winhelp/winhelp.c +++ b/programs/winhelp/winhelp.c @@ -362,6 +362,7 @@ static LRESULT WINHELP_HandleCommand(HW /* case HELP_CONTEXTMENU: */ case HELP_FINDER: /* in fact, should be the topic dialog box */ + WINE_FIXME("HELP_FINDER: stub\n"); if (ptr) { MACRO_JumpHash(ptr, "main", 0); @@ -587,6 +588,20 @@ BOOL WINHELP_CreateHelpWindowByHash(HLPF
/*********************************************************************** * + * WINHELP_CreateHelpWindowByMap + */ +BOOL WINHELP_CreateHelpWindowByMap(HLPFILE* hlpfile, LONG lMap, + HLPFILE_WINDOWINFO* wi, int nCmdShow) +{ + HLPFILE_PAGE* page = NULL; + + page = HLPFILE_PageByMap(hlpfile, lMap); + if (page) page->file->wRefCount++; + return WINHELP_CreateHelpWindow(page, wi, nCmdShow); +} + +/*********************************************************************** + * * WINHELP_MainWndProc */ static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) diff --git a/programs/winhelp/winhelp.h b/programs/winhelp/winhelp.h index 7b10019..ce14352 100644 --- a/programs/winhelp/winhelp.h +++ b/programs/winhelp/winhelp.h @@ -172,6 +172,7 @@ extern WINHELP_GLOBALS Globals; extern FARPROC Callbacks[];
BOOL WINHELP_CreateHelpWindowByHash(HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int); +BOOL WINHELP_CreateHelpWindowByMap(HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int); BOOL WINHELP_CreateHelpWindow(HLPFILE_PAGE*, HLPFILE_WINDOWINFO*, int); INT WINHELP_MessageBoxIDS(UINT, UINT, WORD); INT WINHELP_MessageBoxIDS_s(UINT, LPCSTR, UINT, WORD);