From a02ad10f99fd0ce6b3d756944a30dcb2852b79ce Mon Sep 17 00:00:00 2001 From: Erich Hoover Date: Wed, 20 Jun 2012 14:31:19 -0600 Subject: [PATCH] hhctrl.ocx: Add support for the CHM code page. --- dlls/hhctrl.ocx/chm.c | 8 ++++++++ dlls/hhctrl.ocx/content.c | 8 ++++---- dlls/hhctrl.ocx/help.c | 6 +++--- dlls/hhctrl.ocx/hhctrl.h | 4 +++- dlls/hhctrl.ocx/index.c | 6 +++--- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/dlls/hhctrl.ocx/chm.c b/dlls/hhctrl.ocx/chm.c index f040e5dc51b..f051feb57ab 100644 --- a/dlls/hhctrl.ocx/chm.c +++ b/dlls/hhctrl.ocx/chm.c @@ -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); diff --git a/dlls/hhctrl.ocx/content.c b/dlls/hhctrl.ocx/content.c index e0ec794ffc4..d246c49258e 100644 --- a/dlls/hhctrl.ocx/content.c +++ b/dlls/hhctrl.ocx/content.c @@ -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); } diff --git a/dlls/hhctrl.ocx/help.c b/dlls/hhctrl.ocx/help.c index 1726f054cb8..ef41ec2b753 100644 --- a/dlls/hhctrl.ocx/help.c +++ b/dlls/hhctrl.ocx/help.c @@ -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; } diff --git a/dlls/hhctrl.ocx/hhctrl.h b/dlls/hhctrl.ocx/hhctrl.h index 599b6a5a650..73b2a6b216d 100644 --- a/dlls/hhctrl.ocx/hhctrl.h +++ b/dlls/hhctrl.ocx/hhctrl.h @@ -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 */ diff --git a/dlls/hhctrl.ocx/index.c b/dlls/hhctrl.ocx/index.c index 3b5053a0d30..3cf69de0934 100644 --- a/dlls/hhctrl.ocx/index.c +++ b/dlls/hhctrl.ocx/index.c @@ -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 { -- 2.11.4.GIT