Owen Rudge : hhctrl.ocx: Implement Sync button functionality.
Alexandre Julliard
julliard at winehq.org
Tue Jan 18 10:27:34 CST 2011
Module: wine
Branch: master
Commit: 16b35e00edbbfbc1af92878f8aa5f54090ec6004
URL: http://source.winehq.org/git/wine.git/?a=commit;h=16b35e00edbbfbc1af92878f8aa5f54090ec6004
Author: Owen Rudge <orudge at codeweavers.com>
Date: Mon Jan 17 22:26:46 2011 +0000
hhctrl.ocx: Implement Sync button functionality.
---
dlls/hhctrl.ocx/content.c | 16 +++++++++++
dlls/hhctrl.ocx/help.c | 62 ++++++++++++++++++++++++++++++++++++++------
dlls/hhctrl.ocx/hhctrl.h | 1 +
3 files changed, 70 insertions(+), 9 deletions(-)
diff --git a/dlls/hhctrl.ocx/content.c b/dlls/hhctrl.ocx/content.c
index bfe25cf..2dad7c8 100644
--- a/dlls/hhctrl.ocx/content.c
+++ b/dlls/hhctrl.ocx/content.c
@@ -1,5 +1,6 @@
/*
* Copyright 2007 Jacek Caban for CodeWeavers
+ * Copyright 2011 Owen Rudge for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -312,3 +313,18 @@ void ReleaseContent(HHInfo *info)
{
free_content_item(info->content);
}
+
+void ActivateContentTopic(HWND hWnd, LPCWSTR filename, ContentItem *item)
+{
+ if (lstrcmpiW(item->local, filename) == 0)
+ {
+ SendMessageW(hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM) item->id);
+ return;
+ }
+
+ if (item->next)
+ ActivateContentTopic(hWnd, filename, item->next);
+
+ if (item->child)
+ ActivateContentTopic(hWnd, filename, item->child);
+}
diff --git a/dlls/hhctrl.ocx/help.c b/dlls/hhctrl.ocx/help.c
index 9d732a6..3dcad10 100644
--- a/dlls/hhctrl.ocx/help.c
+++ b/dlls/hhctrl.ocx/help.c
@@ -111,21 +111,15 @@ BOOL NavigateToUrl(HHInfo *info, LPCWSTR surl)
return ret;
}
-BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
+BOOL AppendFullPathURL(LPCWSTR file, LPWSTR buf, LPCWSTR index)
{
- WCHAR buf[INTERNET_MAX_URL_LENGTH];
- WCHAR full_path[MAX_PATH];
- LPWSTR ptr;
-
static const WCHAR url_format[] =
{'m','k',':','@','M','S','I','T','S','t','o','r','e',':','%','s',':',':','%','s','%','s',0};
static const WCHAR slash[] = {'/',0};
static const WCHAR empty[] = {0};
+ WCHAR full_path[MAX_PATH];
- TRACE("%p %s %s\n", info, debugstr_w(file), debugstr_w(index));
-
- if (!info->web_browser)
- return FALSE;
+ TRACE("%s %p %s\n", debugstr_w(file), buf, debugstr_w(index));
if(!GetFullPathNameW(file, sizeof(full_path)/sizeof(full_path[0]), full_path, NULL)) {
WARN("GetFullPathName failed: %u\n", GetLastError());
@@ -133,6 +127,18 @@ BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
}
wsprintfW(buf, url_format, full_path, (!index || index[0] == '/') ? empty : slash, index);
+ return TRUE;
+}
+
+BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
+{
+ WCHAR buf[INTERNET_MAX_URL_LENGTH];
+ LPWSTR ptr;
+
+ TRACE("%p %s %s\n", info, debugstr_w(file), debugstr_w(index));
+
+ if ((!info->web_browser) || !AppendFullPathURL(file, buf, index))
+ return FALSE;
/* FIXME: HACK */
if((ptr = strchrW(buf, '#')))
@@ -141,6 +147,42 @@ BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
return SUCCEEDED(navigate_url(info, buf));
}
+static void DoSync(HHInfo *info)
+{
+ WCHAR buf[INTERNET_MAX_URL_LENGTH];
+ HRESULT hres;
+ DWORD len;
+ BSTR url;
+
+ hres = IWebBrowser2_get_LocationURL(info->web_browser, &url);
+
+ if (FAILED(hres))
+ {
+ WARN("get_LocationURL failed: %08x\n", hres);
+ return;
+ }
+
+ /* If we're not currently viewing a page in the active .chm file, abort */
+ if ((!AppendFullPathURL(info->pszFile, buf, NULL)) || (len = lstrlenW(buf) > lstrlenW(url)))
+ {
+ SysFreeString(url);
+ return;
+ }
+
+ if (lstrcmpiW(buf, url) > 0)
+ {
+ static const WCHAR delimW[] = {':',':','/',0};
+ const WCHAR *index;
+
+ index = strstrW(url, delimW);
+
+ if (index)
+ ActivateContentTopic(info->tabs[TAB_CONTENTS].hwnd, index + 3, info->content); /* skip over ::/ */
+ }
+
+ SysFreeString(url);
+}
+
/* Size Bar */
#define SIZEBAR_WIDTH 4
@@ -654,6 +696,8 @@ static void TB_OnClick(HWND hWnd, DWORD dwID)
ExpandContract(info);
break;
case IDTB_SYNC:
+ DoSync(info);
+ break;
case IDTB_OPTIONS:
case IDTB_BROWSE_FWD:
case IDTB_BROWSE_BACK:
diff --git a/dlls/hhctrl.ocx/hhctrl.h b/dlls/hhctrl.ocx/hhctrl.h
index 03a4807..c0ec009 100644
--- a/dlls/hhctrl.ocx/hhctrl.h
+++ b/dlls/hhctrl.ocx/hhctrl.h
@@ -169,6 +169,7 @@ void DoPageAction(HHInfo*,DWORD);
void InitContent(HHInfo*);
void ReleaseContent(HHInfo*);
+void ActivateContentTopic(HWND,LPCWSTR,ContentItem *);
void InitIndex(HHInfo*);
void ReleaseIndex(HHInfo*);
More information about the wine-cvs
mailing list