hhctrl.ocx: Add support for the CHM code page.
This commit is contained in:
parent
dc482dfe14
commit
a02ad10f99
@ -133,6 +133,13 @@ static BOOL ReadChmSystem(CHMInfo *chm)
|
|||||||
heap_free(chm->defTitle);
|
heap_free(chm->defTitle);
|
||||||
chm->defTitle = strdupnAtoW(buf, entry.len);
|
chm->defTitle = strdupnAtoW(buf, entry.len);
|
||||||
break;
|
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:
|
case 0x5:
|
||||||
TRACE("Default window is %s\n", debugstr_an(buf, entry.len));
|
TRACE("Default window is %s\n", debugstr_an(buf, entry.len));
|
||||||
break;
|
break;
|
||||||
@ -416,6 +423,7 @@ CHMInfo *OpenCHM(LPCWSTR szFile)
|
|||||||
|
|
||||||
if (!(ret = heap_alloc_zero(sizeof(CHMInfo))))
|
if (!(ret = heap_alloc_zero(sizeof(CHMInfo))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
ret->codePage = CP_ACP;
|
||||||
|
|
||||||
if (!(ret->szFile = strdupW(szFile))) {
|
if (!(ret->szFile = strdupW(szFile))) {
|
||||||
heap_free(ret);
|
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;
|
const char *ptr;
|
||||||
LPWSTR *param, merge;
|
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;
|
const char *local = strstr(ptr, "::")+2;
|
||||||
int local_len = len-(local-ptr);
|
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 = &merge;
|
||||||
}
|
}
|
||||||
|
|
||||||
*param = decode_html(ptr, len);
|
*param = decode_html(ptr, len, code_page);
|
||||||
|
|
||||||
if(param == &merge) {
|
if(param == &merge) {
|
||||||
SetChmPath(&item->merge, hhc_root->merge.chm_file, 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"))
|
if(!strcasecmp(node_name.buf, "/object"))
|
||||||
break;
|
break;
|
||||||
if(!strcasecmp(node_name.buf, "param"))
|
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);
|
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.
|
* 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;
|
const char *h = html_fragment;
|
||||||
char *amp, *sem, symbol, *tmp;
|
char *amp, *sem, symbol, *tmp;
|
||||||
@ -1850,9 +1850,9 @@ WCHAR *decode_html(const char *html_fragment, int html_fragment_len)
|
|||||||
tmp_len += len;
|
tmp_len += len;
|
||||||
tmp[tmp_len++] = 0; /* NULL-terminate the string */
|
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));
|
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);
|
heap_free(tmp);
|
||||||
return unicode_text;
|
return unicode_text;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,8 @@ typedef struct CHMInfo
|
|||||||
WCHAR *defTopic;
|
WCHAR *defTopic;
|
||||||
WCHAR *defTitle;
|
WCHAR *defTitle;
|
||||||
WCHAR *defToc;
|
WCHAR *defToc;
|
||||||
|
|
||||||
|
UINT codePage;
|
||||||
} CHMInfo;
|
} CHMInfo;
|
||||||
|
|
||||||
#define TAB_CONTENTS 0
|
#define TAB_CONTENTS 0
|
||||||
@ -193,7 +195,7 @@ void ReleaseSearch(HHInfo *info) DECLSPEC_HIDDEN;
|
|||||||
|
|
||||||
LPCWSTR skip_schema(LPCWSTR url) 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 */
|
/* 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
|
* sub-topic then there isn't really a sub-topic, the index will jump
|
||||||
* directly to the requested item.
|
* 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;
|
const char *ptr;
|
||||||
LPWSTR *param;
|
LPWSTR *param;
|
||||||
@ -109,7 +109,7 @@ static void parse_index_obj_node_param(IndexItem *item, const char *text)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*param = decode_html(ptr, len);
|
*param = decode_html(ptr, len, code_page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the object tag corresponding to a list item.
|
/* 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);
|
TRACE("%s\n", node.buf);
|
||||||
|
|
||||||
if(!strcasecmp(node_name.buf, "param")) {
|
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")) {
|
}else if(!strcasecmp(node_name.buf, "/object")) {
|
||||||
break;
|
break;
|
||||||
}else {
|
}else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user