hhctrl.ocx: Create a special structure for holding non-const unicode strings.

This commit is contained in:
Erich Hoover 2012-08-29 19:45:27 -06:00 committed by Alexandre Julliard
parent 1af1601177
commit d39801bef3
4 changed files with 47 additions and 39 deletions

View File

@ -283,16 +283,16 @@ void MergeChmProperties(HH_WINTYPEW *src, HHInfo *info)
* modified by the user. rcHTML and rcMinSize are not currently supported, so don't bother to copy them.
*/
dst->pszType = MergeChmString(src->pszType, &info->pszType);
dst->pszFile = MergeChmString(src->pszFile, &info->pszFile);
dst->pszToc = MergeChmString(src->pszToc, &info->pszToc);
dst->pszIndex = MergeChmString(src->pszIndex, &info->pszIndex);
dst->pszCaption = MergeChmString(src->pszCaption, &info->pszCaption);
dst->pszHome = MergeChmString(src->pszHome, &info->pszHome);
dst->pszJump1 = MergeChmString(src->pszJump1, &info->pszJump1);
dst->pszJump2 = MergeChmString(src->pszJump2, &info->pszJump2);
dst->pszUrlJump1 = MergeChmString(src->pszUrlJump1, &info->pszUrlJump1);
dst->pszUrlJump2 = MergeChmString(src->pszUrlJump2, &info->pszUrlJump2);
dst->pszType = MergeChmString(src->pszType, &info->stringsW.pszType);
dst->pszFile = MergeChmString(src->pszFile, &info->stringsW.pszFile);
dst->pszToc = MergeChmString(src->pszToc, &info->stringsW.pszToc);
dst->pszIndex = MergeChmString(src->pszIndex, &info->stringsW.pszIndex);
dst->pszCaption = MergeChmString(src->pszCaption, &info->stringsW.pszCaption);
dst->pszHome = MergeChmString(src->pszHome, &info->stringsW.pszHome);
dst->pszJump1 = MergeChmString(src->pszJump1, &info->stringsW.pszJump1);
dst->pszJump2 = MergeChmString(src->pszJump2, &info->stringsW.pszJump2);
dst->pszUrlJump1 = MergeChmString(src->pszUrlJump1, &info->stringsW.pszUrlJump1);
dst->pszUrlJump2 = MergeChmString(src->pszUrlJump2, &info->stringsW.pszUrlJump2);
/* FIXME: pszCustomTabs is a list of multiple zero-terminated strings so ReadString won't
* work in this case
@ -381,11 +381,11 @@ BOOL LoadWinTypeFromCHM(HHInfo *info)
/* merge the new data with any pre-existing HH_WINTYPE structure */
MergeChmProperties(&wintype, info);
if (!info->WinType.pszFile)
info->WinType.pszFile = info->pszFile = strdupW(info->pCHMInfo->defTopic ? info->pCHMInfo->defTopic : null);
info->WinType.pszFile = info->stringsW.pszFile = strdupW(info->pCHMInfo->defTopic ? info->pCHMInfo->defTopic : null);
if (!info->WinType.pszToc)
info->WinType.pszToc = info->pszToc = FindHTMLHelpSetting(info, toc_extW);
info->WinType.pszToc = info->stringsW.pszToc = FindHTMLHelpSetting(info, toc_extW);
if (!info->WinType.pszIndex)
info->WinType.pszIndex = info->pszIndex = FindHTMLHelpSetting(info, index_extW);
info->WinType.pszIndex = info->stringsW.pszIndex = FindHTMLHelpSetting(info, index_extW);
heap_free(pszType);
heap_free(pszFile);

View File

@ -278,7 +278,7 @@ static void DoSync(HHInfo *info)
}
/* 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)))
if ((!AppendFullPathURL(info->WinType.pszFile, buf, NULL)) || (len = lstrlenW(buf) > lstrlenW(url)))
{
SysFreeString(url);
return;
@ -1742,6 +1742,20 @@ static BOOL CreateViewer(HHInfo *pHHInfo)
return TRUE;
}
void wintype_stringsW_free(struct wintype_stringsW *stringsW)
{
heap_free(stringsW->pszType);
heap_free(stringsW->pszCaption);
heap_free(stringsW->pszToc);
heap_free(stringsW->pszIndex);
heap_free(stringsW->pszFile);
heap_free(stringsW->pszHome);
heap_free(stringsW->pszJump1);
heap_free(stringsW->pszJump2);
heap_free(stringsW->pszUrlJump1);
heap_free(stringsW->pszUrlJump2);
}
void ReleaseHelpViewer(HHInfo *info)
{
TRACE("(%p)\n", info);
@ -1751,17 +1765,7 @@ void ReleaseHelpViewer(HHInfo *info)
list_remove(&info->entry);
/* Free allocated strings */
heap_free(info->pszType);
heap_free(info->pszCaption);
heap_free(info->pszToc);
heap_free(info->pszIndex);
heap_free(info->pszFile);
heap_free(info->pszHome);
heap_free(info->pszJump1);
heap_free(info->pszJump2);
heap_free(info->pszUrlJump1);
heap_free(info->pszUrlJump2);
wintype_stringsW_free(&info->stringsW);
if (info->pCHMInfo)
CloseCHM(info->pCHMInfo);

View File

@ -191,8 +191,8 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
if(!index)
index = info->WinType.pszFile;
if(!info->pszType)
info->WinType.pszType = info->pszType = window;
if(!info->WinType.pszType)
info->WinType.pszType = info->stringsW.pszType = window;
else
heap_free(window);

View File

@ -140,6 +140,20 @@ typedef struct {
HIMAGELIST hImageList;
} ContentsTab;
struct wintype_stringsW {
WCHAR *pszType;
WCHAR *pszCaption;
WCHAR *pszToc;
WCHAR *pszIndex;
WCHAR *pszFile;
WCHAR *pszHome;
WCHAR *pszJump1;
WCHAR *pszJump2;
WCHAR *pszUrlJump1;
WCHAR *pszUrlJump2;
WCHAR *pszCustomTabs;
};
typedef struct {
IOleClientSite *client_site;
IWebBrowser2 *web_browser;
@ -147,17 +161,7 @@ typedef struct {
HH_WINTYPEW WinType;
LPWSTR pszType;
LPWSTR pszCaption;
LPWSTR pszToc;
LPWSTR pszIndex;
LPWSTR pszFile;
LPWSTR pszHome;
LPWSTR pszJump1;
LPWSTR pszJump2;
LPWSTR pszUrlJump1;
LPWSTR pszUrlJump2;
LPWSTR pszCustomTabs;
struct wintype_stringsW stringsW;
struct list entry;
CHMInfo *pCHMInfo;
@ -204,7 +208,7 @@ void InitSearch(HHInfo *info, const char *needle) DECLSPEC_HIDDEN;
void ReleaseSearch(HHInfo *info) DECLSPEC_HIDDEN;
LPCWSTR skip_schema(LPCWSTR url) 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);
/* memory allocation functions */