more fixes to HTML entities parsing when loading .hhk and .hhc

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28044 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2004-06-27 19:40:20 +00:00
parent 1171e2e56e
commit 67c276bdb6
2 changed files with 16 additions and 34 deletions

View File

@ -172,15 +172,12 @@ public:
// See documentation for details on its format.
// Returns success.
bool AddBook(const wxString& book);
#if WXWIN_COMPATIBILITY_2_4
wxDEPRECATED(
bool AddBookParam(const wxFSFile& bookfile,
wxFontEncoding encoding,
const wxString& title, const wxString& contfile,
const wxString& indexfile = wxEmptyString,
const wxString& deftopic = wxEmptyString,
const wxString& path = wxEmptyString) );
#endif
const wxString& path = wxEmptyString);
// Some accessing stuff:
@ -206,13 +203,6 @@ protected:
int m_IndexCnt; // list of index items
protected:
bool AddBookParam(const wxFSFile& bookfile,
const wxString& charset,
const wxString& title, const wxString& contfile,
const wxString& indexfile = wxEmptyString,
const wxString& deftopic = wxEmptyString,
const wxString& path = wxEmptyString);
// Imports .hhp files (MS HTML Help Workshop)
bool LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys,
const wxString& indexfile, const wxString& contentsfile);

View File

@ -95,7 +95,10 @@ static T* ReallocArray(T *arr, size_t oldsize, size_t newsize)
class HP_Parser : public wxHtmlParser
{
public:
HP_Parser() { }
HP_Parser()
{
GetEntitiesParser()->SetEncoding(wxFONTENCODING_ISO8859_1);
}
wxObject* GetProduct() { return NULL; }
@ -247,7 +250,9 @@ wxHtmlHelpData::~wxHtmlHelpData()
delete[] m_Index;
}
bool wxHtmlHelpData::LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys, const wxString& indexfile, const wxString& contentsfile)
bool wxHtmlHelpData::LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys,
const wxString& indexfile,
const wxString& contentsfile)
{
wxFSFile *f;
wxHtmlFilterHTML filter;
@ -444,28 +449,11 @@ static wxString SafeFileName(const wxString& s)
return res;
}
#ifdef WXWIN_COMPATIBILITY_2_4
bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
wxFontEncoding encoding,
const wxString& title, const wxString& contfile,
const wxString& indexfile, const wxString& deftopic,
const wxString& path)
{
wxString charset;
#if wxUSE_FONTMAP
if (encoding != wxFONTENCODING_SYSTEM)
charset = wxFontMapper::Get()->GetEncodingName(encoding);
#endif
return AddBookParam(bookfile, charset, title, contfile, indexfile,
deftopic, path);
}
#endif // WXWIN_COMPATIBILITY_2_4
bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
const wxString& charset,
const wxString& title, const wxString& contfile,
const wxString& indexfile, const wxString& deftopic,
const wxString& path)
{
wxFileSystem fsys;
wxFSFile *fi;
@ -540,7 +528,7 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
// in that the data are iso-8859-1 (including HTML entities), but must
// be interpreted as being in language's windows charset. Correct the
// differences here and also convert to wxConvLocal in ANSI build
if (!charset.empty())
if (encoding != wxFONTENCODING_SYSTEM)
{
#if wxUSE_UNICODE
#define CORRECT_STR(str, conv) \
@ -549,7 +537,7 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
#define CORRECT_STR(str, conv) \
str = wxString((str).wc_str(conv), wxConvLocal)
#endif
wxCSConv conv(charset);
wxCSConv conv(encoding);
int i;
for (i = IndexOld; i < m_IndexCnt; i++)
{
@ -564,7 +552,7 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
#else
wxUnusedVar(IndexOld);
wxUnusedVar(ContentsOld);
wxASSERT_MSG(charset.empty(), wxT("Help files need charset conversion, but wxUSE_WCHAR_T is 0"));
wxASSERT_MSG(encoding == wxFONTENCODING_SYSTEM, wxT("Help files need charset conversion, but wxUSE_WCHAR_T is 0"));
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
m_BookRecords.Add(bookr);
@ -647,8 +635,12 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
if (wxStrstr(linebuf, _T("charset=")) == linebuf)
charset = linebuf + wxStrlen(_T("charset="));
} while (lineptr != NULL);
wxFontEncoding enc;
if (charset == wxEmptyString) enc = wxFONTENCODING_SYSTEM;
else enc = wxFontMapper::Get()->CharsetToEncoding(charset);
bool rtval = AddBookParam(*fi, charset,
bool rtval = AddBookParam(*fi, enc,
title, contents, index, start, fsys.GetPath());
delete fi;
return rtval;