Commit 8e0bc11f authored by Kirill K Smirnov's avatar Kirill K Smirnov Committed by Alexandre Julliard

winhelp: Properly implement context help and JumpContext macro.

parent 08884514
......@@ -84,6 +84,7 @@ static BOOL HLPFILE_UncompressLZ77_Phrases(HLPFILE*);
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, LONG lHash)
/***********************************************************************
*
* 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 lpszPath)
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(HLPFILE *hlpfile, LPCSTR lpszPath)
ref = GET_UINT(buf, 0xc);
} while (ref != 0xffffffff);
HLPFILE_GetMap(hlpfile);
return HLPFILE_GetContext(hlpfile);
}
......@@ -1902,6 +1928,29 @@ static BOOL HLPFILE_GetContext(HLPFILE *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* hlpfile)
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);
......
......@@ -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);
......
......@@ -680,8 +680,14 @@ void CALLBACK MACRO_JumpContents(LPCSTR lpszPath, LPCSTR lpszWindow)
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)
......
......@@ -362,6 +362,7 @@ static LRESULT WINHELP_HandleCommand(HWND hSrcWnd, LPARAM lParam)
/* 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(HLPFILE* hlpfile, LONG lHash,
/***********************************************************************
*
* 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)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment