Commit a02ad10f authored by Erich Hoover's avatar Erich Hoover Committed by Alexandre Julliard

hhctrl.ocx: Add support for the CHM code page.

parent dc482dfe
......@@ -133,6 +133,13 @@ static BOOL ReadChmSystem(CHMInfo *chm)
heap_free(chm->defTitle);
chm->defTitle = strdupnAtoW(buf, entry.len);
break;
case 0x4:
/* TODO: Currently only the Locale ID is loaded from this field */
TRACE("Locale is: %d\n", *(LCID*)&buf[0]);
if(!GetLocaleInfoW(*(LCID*)&buf[0], LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER,
(WCHAR *)&chm->codePage, sizeof(chm->codePage)/sizeof(WCHAR)))
chm->codePage = CP_ACP;
break;
case 0x5:
TRACE("Default window is %s\n", debugstr_an(buf, entry.len));
break;
......@@ -416,6 +423,7 @@ CHMInfo *OpenCHM(LPCWSTR szFile)
if (!(ret = heap_alloc_zero(sizeof(CHMInfo))))
return NULL;
ret->codePage = CP_ACP;
if (!(ret->szFile = strdupW(szFile))) {
heap_free(ret);
......
......@@ -50,7 +50,7 @@ static void free_content_item(ContentItem *item)
}
}
static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text)
static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text, UINT code_page)
{
const char *ptr;
LPWSTR *param, merge;
......@@ -89,11 +89,11 @@ static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const
const char *local = strstr(ptr, "::")+2;
int local_len = len-(local-ptr);
item->local = decode_html(local, local_len);
item->local = decode_html(local, local_len, code_page);
param = &merge;
}
*param = decode_html(ptr, len);
*param = decode_html(ptr, len, code_page);
if(param == &merge) {
SetChmPath(&item->merge, hhc_root->merge.chm_file, merge);
......@@ -151,7 +151,7 @@ static ContentItem *parse_sitemap_object(HHInfo *info, stream_t *stream, Content
if(!strcasecmp(node_name.buf, "/object"))
break;
if(!strcasecmp(node_name.buf, "param"))
parse_obj_node_param(item, hhc_root, node.buf);
parse_obj_node_param(item, hhc_root, node.buf, info->pCHMInfo->codePage);
strbuf_zero(&node);
}
......
......@@ -1793,7 +1793,7 @@ static char find_html_symbol(const char *entity, int entity_len)
/*
* Decode a string containing HTML encoded characters into a unicode string.
*/
WCHAR *decode_html(const char *html_fragment, int html_fragment_len)
WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page)
{
const char *h = html_fragment;
char *amp, *sem, symbol, *tmp;
......@@ -1850,9 +1850,9 @@ WCHAR *decode_html(const char *html_fragment, int html_fragment_len)
tmp_len += len;
tmp[tmp_len++] = 0; /* NULL-terminate the string */
len = MultiByteToWideChar(CP_ACP, 0, tmp, tmp_len, NULL, 0);
len = MultiByteToWideChar(code_page, 0, tmp, tmp_len, NULL, 0);
unicode_text = heap_alloc(len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, tmp, tmp_len, unicode_text, len);
MultiByteToWideChar(code_page, 0, tmp, tmp_len, unicode_text, len);
heap_free(tmp);
return unicode_text;
}
......@@ -106,6 +106,8 @@ typedef struct CHMInfo
WCHAR *defTopic;
WCHAR *defTitle;
WCHAR *defToc;
UINT codePage;
} CHMInfo;
#define TAB_CONTENTS 0
......@@ -193,7 +195,7 @@ void ReleaseSearch(HHInfo *info) DECLSPEC_HIDDEN;
LPCWSTR skip_schema(LPCWSTR url) DECLSPEC_HIDDEN;
WCHAR *decode_html(const char *html_fragment, int html_fragment_len);
WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page);
/* memory allocation functions */
......
......@@ -62,7 +62,7 @@ static void fill_index_tree(HWND hwnd, IndexItem *item)
* sub-topic then there isn't really a sub-topic, the index will jump
* directly to the requested item.
*/
static void parse_index_obj_node_param(IndexItem *item, const char *text)
static void parse_index_obj_node_param(IndexItem *item, const char *text, UINT code_page)
{
const char *ptr;
LPWSTR *param;
......@@ -109,7 +109,7 @@ static void parse_index_obj_node_param(IndexItem *item, const char *text)
return;
}
*param = decode_html(ptr, len);
*param = decode_html(ptr, len, code_page);
}
/* Parse the object tag corresponding to a list item.
......@@ -137,7 +137,7 @@ static IndexItem *parse_index_sitemap_object(HHInfo *info, stream_t *stream)
TRACE("%s\n", node.buf);
if(!strcasecmp(node_name.buf, "param")) {
parse_index_obj_node_param(item, node.buf);
parse_index_obj_node_param(item, node.buf, info->pCHMInfo->codePage);
}else if(!strcasecmp(node_name.buf, "/object")) {
break;
}else {
......
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