hhctrl.ocx: Implement HH_GET_WIN_TYPE.

This commit is contained in:
Erich Hoover 2012-08-31 15:26:12 -06:00 committed by Alexandre Julliard
parent b8f4252290
commit af0fa40eff
3 changed files with 102 additions and 9 deletions

View File

@ -1757,6 +1757,21 @@ void wintype_stringsW_free(struct wintype_stringsW *stringsW)
heap_free(stringsW->pszUrlJump2); heap_free(stringsW->pszUrlJump2);
} }
void wintype_stringsA_free(struct wintype_stringsA *stringsA)
{
heap_free(stringsA->pszType);
heap_free(stringsA->pszCaption);
heap_free(stringsA->pszToc);
heap_free(stringsA->pszIndex);
heap_free(stringsA->pszFile);
heap_free(stringsA->pszHome);
heap_free(stringsA->pszJump1);
heap_free(stringsA->pszJump2);
heap_free(stringsA->pszUrlJump1);
heap_free(stringsA->pszUrlJump2);
heap_free(stringsA->pszCustomTabs);
}
void ReleaseHelpViewer(HHInfo *info) void ReleaseHelpViewer(HHInfo *info)
{ {
TRACE("(%p)\n", info); TRACE("(%p)\n", info);
@ -1766,6 +1781,7 @@ void ReleaseHelpViewer(HHInfo *info)
list_remove(&info->entry); list_remove(&info->entry);
wintype_stringsA_free(&info->stringsA);
wintype_stringsW_free(&info->stringsW); wintype_stringsW_free(&info->stringsW);
if (info->pCHMInfo) if (info->pCHMInfo)

View File

@ -330,6 +330,29 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
MergeChmProperties(wintype, info); MergeChmProperties(wintype, info);
return 0; return 0;
} }
case HH_GET_WIN_TYPE: {
HH_WINTYPEW *wintype = (HH_WINTYPEW *)data;
WCHAR *window = NULL;
HHInfo *info = NULL;
if (!filename || !resolve_filename(filename, fullname, MAX_PATH, NULL, &window) || !window)
{
WARN("can't find window name: %s\n", debugstr_w(filename));
return 0;
}
info = find_window(window);
if (!info)
{
WARN("Could not find window named %s.\n", debugstr_w(window));
heap_free(window);
return (HWND)~0;
}
TRACE("Retrieving WINTYPE for %s.\n", debugstr_w(window));
*wintype = info->WinType;
heap_free(window);
return 0;
}
default: default:
FIXME("HH case %s not handled.\n", command_to_string( command )); FIXME("HH case %s not handled.\n", command_to_string( command ));
} }
@ -337,11 +360,8 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
return 0; return 0;
} }
static HH_WINTYPEW *wintypeAtoW(HH_WINTYPEA *data, struct wintype_stringsW *stringsW) static void wintypeAtoW(const HH_WINTYPEA *data, HH_WINTYPEW *wdata, struct wintype_stringsW *stringsW)
{ {
HH_WINTYPEW *wdata;
wdata = heap_alloc(sizeof(*wdata));
memcpy(wdata, data, sizeof(*data)); memcpy(wdata, data, sizeof(*data));
/* convert all of the ANSI strings to Unicode */ /* convert all of the ANSI strings to Unicode */
wdata->pszType = stringsW->pszType = strdupAtoW(data->pszType); wdata->pszType = stringsW->pszType = strdupAtoW(data->pszType);
@ -355,8 +375,23 @@ static HH_WINTYPEW *wintypeAtoW(HH_WINTYPEA *data, struct wintype_stringsW *stri
wdata->pszUrlJump1 = stringsW->pszUrlJump1 = strdupAtoW(data->pszUrlJump1); wdata->pszUrlJump1 = stringsW->pszUrlJump1 = strdupAtoW(data->pszUrlJump1);
wdata->pszUrlJump2 = stringsW->pszUrlJump2 = strdupAtoW(data->pszUrlJump2); wdata->pszUrlJump2 = stringsW->pszUrlJump2 = strdupAtoW(data->pszUrlJump2);
wdata->pszCustomTabs = stringsW->pszCustomTabs = strdupAtoW(data->pszCustomTabs); wdata->pszCustomTabs = stringsW->pszCustomTabs = strdupAtoW(data->pszCustomTabs);
}
return wdata; static void wintypeWtoA(const HH_WINTYPEW *wdata, HH_WINTYPEA *data, struct wintype_stringsA *stringsA)
{
memcpy(data, wdata, sizeof(*wdata));
/* convert all of the Unicode strings to ANSI */
data->pszType = stringsA->pszType = strdupWtoA(wdata->pszType);
data->pszCaption = stringsA->pszCaption = strdupWtoA(wdata->pszCaption);
data->pszToc = stringsA->pszToc = strdupWtoA(wdata->pszToc);
data->pszIndex = stringsA->pszFile = strdupWtoA(wdata->pszIndex);
data->pszFile = stringsA->pszFile = strdupWtoA(wdata->pszFile);
data->pszHome = stringsA->pszHome = strdupWtoA(wdata->pszHome);
data->pszJump1 = stringsA->pszJump1 = strdupWtoA(wdata->pszJump1);
data->pszJump2 = stringsA->pszJump2 = strdupWtoA(wdata->pszJump2);
data->pszUrlJump1 = stringsA->pszUrlJump1 = strdupWtoA(wdata->pszUrlJump1);
data->pszUrlJump2 = stringsA->pszUrlJump2 = strdupWtoA(wdata->pszUrlJump2);
data->pszCustomTabs = stringsA->pszCustomTabs = strdupWtoA(wdata->pszCustomTabs);
} }
/****************************************************************** /******************************************************************
@ -375,7 +410,6 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data
case HH_DISPLAY_SEARCH: case HH_DISPLAY_SEARCH:
case HH_DISPLAY_TEXT_POPUP: case HH_DISPLAY_TEXT_POPUP:
case HH_GET_LAST_ERROR: case HH_GET_LAST_ERROR:
case HH_GET_WIN_TYPE:
case HH_KEYWORD_LOOKUP: case HH_KEYWORD_LOOKUP:
case HH_SYNC: case HH_SYNC:
FIXME("structures not handled yet\n"); FIXME("structures not handled yet\n");
@ -384,10 +418,24 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data
case HH_SET_WIN_TYPE: case HH_SET_WIN_TYPE:
{ {
struct wintype_stringsW stringsW; struct wintype_stringsW stringsW;
HH_WINTYPEW *wdata = wintypeAtoW((HH_WINTYPEA *)data, &stringsW); HH_WINTYPEW wdata;
result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)wdata );
wintypeAtoW((HH_WINTYPEA *)data, &wdata, &stringsW);
result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)&wdata );
wintype_stringsW_free(&stringsW); wintype_stringsW_free(&stringsW);
heap_free( wdata ); goto done;
}
case HH_GET_WIN_TYPE:
{
HH_WINTYPEW wdata;
HHInfo *info;
result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)&wdata );
if (!wdata.pszType) break;
info = find_window(wdata.pszType);
if (!info) break;
wintype_stringsA_free(&info->stringsA);
wintypeWtoA(&wdata, (HH_WINTYPEA *)data, &info->stringsA);
goto done; goto done;
} }

View File

@ -154,6 +154,20 @@ struct wintype_stringsW {
WCHAR *pszCustomTabs; WCHAR *pszCustomTabs;
}; };
struct wintype_stringsA {
char *pszType;
char *pszCaption;
char *pszToc;
char *pszIndex;
char *pszFile;
char *pszHome;
char *pszJump1;
char *pszJump2;
char *pszUrlJump1;
char *pszUrlJump2;
char *pszCustomTabs;
};
typedef struct { typedef struct {
IOleClientSite *client_site; IOleClientSite *client_site;
IWebBrowser2 *web_browser; IWebBrowser2 *web_browser;
@ -161,6 +175,7 @@ typedef struct {
HH_WINTYPEW WinType; HH_WINTYPEW WinType;
struct wintype_stringsA stringsA;
struct wintype_stringsW stringsW; struct wintype_stringsW stringsW;
struct list entry; struct list entry;
@ -209,6 +224,7 @@ void InitSearch(HHInfo *info, const char *needle) DECLSPEC_HIDDEN;
void ReleaseSearch(HHInfo *info) DECLSPEC_HIDDEN; void ReleaseSearch(HHInfo *info) DECLSPEC_HIDDEN;
LPCWSTR skip_schema(LPCWSTR url) DECLSPEC_HIDDEN; LPCWSTR skip_schema(LPCWSTR url) DECLSPEC_HIDDEN;
void wintype_stringsA_free(struct wintype_stringsA *stringsA) DECLSPEC_HIDDEN;
void wintype_stringsW_free(struct wintype_stringsW *stringsW) DECLSPEC_HIDDEN; void wintype_stringsW_free(struct wintype_stringsW *stringsW) DECLSPEC_HIDDEN;
WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page); WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page);
@ -282,6 +298,19 @@ static inline LPWSTR strdupAtoW(LPCSTR str)
return strdupnAtoW(str, -1); return strdupnAtoW(str, -1);
} }
static inline LPSTR strdupWtoA(LPCWSTR str)
{
LPSTR ret;
DWORD len;
if(!str)
return NULL;
len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
ret = heap_alloc(len);
WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, NULL, NULL);
return ret;
}
extern HINSTANCE hhctrl_hinstance DECLSPEC_HIDDEN; extern HINSTANCE hhctrl_hinstance DECLSPEC_HIDDEN;