Jacek Caban : hhctrl.ocx: Added HH_HELP_CONTEXT implementation.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Feb 28 08:19:12 CST 2007
Module: wine
Branch: master
Commit: 736ef403a92ae4d0598d571efdb25bbad9958391
URL: http://source.winehq.org/git/wine.git/?a=commit;h=736ef403a92ae4d0598d571efdb25bbad9958391
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Feb 28 03:55:39 2007 +0100
hhctrl.ocx: Added HH_HELP_CONTEXT implementation.
---
dlls/hhctrl.ocx/chm.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++
dlls/hhctrl.ocx/help.c | 29 +++++++++++++++++++++------
dlls/hhctrl.ocx/hhctrl.c | 30 +++++++++++++++++++++++++---
dlls/hhctrl.ocx/hhctrl.h | 2 +
4 files changed, 97 insertions(+), 11 deletions(-)
diff --git a/dlls/hhctrl.ocx/chm.c b/dlls/hhctrl.ocx/chm.c
index 8e9fcf8..7c3384e 100644
--- a/dlls/hhctrl.ocx/chm.c
+++ b/dlls/hhctrl.ocx/chm.c
@@ -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
diff --git a/dlls/hhctrl.ocx/help.c b/dlls/hhctrl.ocx/help.c
index abbc0c5..baedf88 100644
--- a/dlls/hhctrl.ocx/help.c
+++ b/dlls/hhctrl.ocx/help.c
@@ -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 */
diff --git a/dlls/hhctrl.ocx/hhctrl.c b/dlls/hhctrl.ocx/hhctrl.c
index ec3cf74..de66a8a 100644
--- a/dlls/hhctrl.ocx/hhctrl.c
+++ b/dlls/hhctrl.ocx/hhctrl.c
@@ -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;
diff --git a/dlls/hhctrl.ocx/hhctrl.h b/dlls/hhctrl.ocx/hhctrl.h
index 0de19e2..f9d21f4 100644
--- a/dlls/hhctrl.ocx/hhctrl.h
+++ b/dlls/hhctrl.ocx/hhctrl.h
@@ -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 */
More information about the wine-cvs
mailing list