Commit 736ef403 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

hhctrl.ocx: Added HH_HELP_CONTEXT implementation.

parent 5d011551
......@@ -146,6 +146,53 @@ static BOOL ReadChmSystem(CHMInfo *chm)
return SUCCEEDED(hres);
}
LPWSTR FindContextAlias(CHMInfo *chm, DWORD index)
{
IStream *ivb_stream;
DWORD size, read, i;
DWORD *buf;
LPCSTR ret = NULL;
HRESULT hres;
static const WCHAR wszIVB[] = {'#','I','V','B',0};
hres = IStorage_OpenStream(chm->pStorage, wszIVB, NULL, STGM_READ, 0, &ivb_stream);
if(FAILED(hres)) {
WARN("Could not open #IVB stream: %08x\n", hres);
return NULL;
}
hres = IStream_Read(ivb_stream, &size, sizeof(size), &read);
if(FAILED(hres)) {
WARN("Read failed: %08x\n", hres);
IStream_Release(ivb_stream);
return NULL;
}
buf = hhctrl_alloc(size);
hres = IStream_Read(ivb_stream, buf, size, &read);
IStream_Release(ivb_stream);
if(FAILED(hres)) {
WARN("Read failed: %08x\n", hres);
hhctrl_free(buf);
return NULL;
}
size /= 2*sizeof(DWORD);
for(i=0; i<size; i++) {
if(buf[2*i] == index) {
ret = GetChmString(chm, buf[2*i+1]);
break;
}
}
hhctrl_free(buf);
TRACE("returning %s\n", debugstr_a(ret));
return strdupAtoW(ret);
}
/* Loads the HH_WINTYPE data from the CHM file
*
* FIXME: There may be more than one window type in the file, so
......
......@@ -57,15 +57,32 @@ static LPWSTR HH_LoadString(DWORD dwID)
return string;
}
BOOL NavigateToUrl(HHInfo *info, LPCWSTR surl)
{
VARIANT url;
HRESULT hres;
V_VT(&url) = VT_BSTR;
V_BSTR(&url) = SysAllocString(surl);
hres = IWebBrowser2_Navigate2(info->web_browser, &url, 0, 0, 0, 0);
VariantClear(&url);
return SUCCEEDED(hres);
}
BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
{
WCHAR buf[INTERNET_MAX_URL_LENGTH];
WCHAR full_path[MAX_PATH];
VARIANT url;
LPWSTR ptr;
static const WCHAR url_format[] =
{'m','k',':','@','M','S','I','T','S','t','o','r','e',':','%','s',':',':','/','%','s',0};
TRACE("%p %s %s\n", info, debugstr_w(file), debugstr_w(index));
if (!info->web_browser)
return FALSE;
......@@ -76,13 +93,11 @@ BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
wsprintfW(buf, url_format, full_path, index);
V_VT(&url) = VT_BSTR;
V_BSTR(&url) = SysAllocString(buf);
IWebBrowser2_Navigate2(info->web_browser, &url, 0, 0, 0, 0);
VariantClear(&url);
/* FIXME: HACK */
if((ptr = strchrW(buf, '#')))
*ptr = 0;
return TRUE;
return NavigateToUrl(info, buf);
}
/* Size Bar */
......
......@@ -2,6 +2,7 @@
* hhctrl implementation
*
* Copyright 2004 Krzysztof Foltman
* Copyright 2007 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -26,7 +27,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
HINSTANCE hhctrl_hinstance;
BOOL hh_process;
BOOL hh_process = FALSE;
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved)
{
......@@ -84,9 +85,11 @@ static const char *command_to_string(UINT command)
#undef X
}
/******************************************************************
* HtmlHelpW (hhctrl.ocx.15)
*/
HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
{
TRACE("(%p, %s, command=%s, data=%d)\n",
caller, debugstr_w( filename ),
command_to_string( command ), data);
......@@ -95,8 +98,7 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
{
case HH_DISPLAY_TOPIC:
case HH_DISPLAY_TOC:
case HH_DISPLAY_SEARCH:
case HH_HELP_CONTEXT: {
case HH_DISPLAY_SEARCH:{
HHInfo *info;
BOOL res;
......@@ -110,6 +112,23 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
return NULL; /* FIXME */
}
case HH_HELP_CONTEXT: {
HHInfo *info;
LPWSTR url;
info = CreateHelpViewer(filename);
if(!info)
return NULL;
url = FindContextAlias(info->pCHMInfo, data);
if(!url)
return NULL;
NavigateToUrl(info, url);
hhctrl_free(url);
return NULL; /* FIXME */
}
default:
FIXME("HH case %s not handled.\n", command_to_string( command ));
}
......@@ -117,6 +136,9 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
return 0;
}
/******************************************************************
* HtmlHelpA (hhctrl.ocx.14)
*/
HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD data)
{
WCHAR *wfile = NULL;
......
......@@ -79,9 +79,11 @@ void DoPageAction(HHInfo*,DWORD);
CHMInfo *OpenCHM(LPCWSTR szFile);
BOOL LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
LPWSTR FindContextAlias(CHMInfo*,DWORD);
HHInfo *CreateHelpViewer(LPCWSTR);
void ReleaseHelpViewer(HHInfo*);
BOOL NavigateToUrl(HHInfo*,LPCWSTR);
BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
/* memory allocation functions */
......
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