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. // See documentation for details on its format.
// Returns success. // Returns success.
bool AddBook(const wxString& book); bool AddBook(const wxString& book);
#if WXWIN_COMPATIBILITY_2_4
wxDEPRECATED(
bool AddBookParam(const wxFSFile& bookfile, bool AddBookParam(const wxFSFile& bookfile,
wxFontEncoding encoding, wxFontEncoding encoding,
const wxString& title, const wxString& contfile, const wxString& title, const wxString& contfile,
const wxString& indexfile = wxEmptyString, const wxString& indexfile = wxEmptyString,
const wxString& deftopic = wxEmptyString, const wxString& deftopic = wxEmptyString,
const wxString& path = wxEmptyString) ); const wxString& path = wxEmptyString);
#endif
// Some accessing stuff: // Some accessing stuff:
@@ -206,13 +203,6 @@ protected:
int m_IndexCnt; // list of index items int m_IndexCnt; // list of index items
protected: 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) // Imports .hhp files (MS HTML Help Workshop)
bool LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys, bool LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys,
const wxString& indexfile, const wxString& contentsfile); 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 class HP_Parser : public wxHtmlParser
{ {
public: public:
HP_Parser() { } HP_Parser()
{
GetEntitiesParser()->SetEncoding(wxFONTENCODING_ISO8859_1);
}
wxObject* GetProduct() { return NULL; } wxObject* GetProduct() { return NULL; }
@@ -247,7 +250,9 @@ wxHtmlHelpData::~wxHtmlHelpData()
delete[] m_Index; 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; wxFSFile *f;
wxHtmlFilterHTML filter; wxHtmlFilterHTML filter;
@@ -444,28 +449,11 @@ static wxString SafeFileName(const wxString& s)
return res; return res;
} }
#ifdef WXWIN_COMPATIBILITY_2_4
bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile, bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
wxFontEncoding encoding, wxFontEncoding encoding,
const wxString& title, const wxString& contfile, const wxString& title, const wxString& contfile,
const wxString& indexfile, const wxString& deftopic, const wxString& indexfile, const wxString& deftopic,
const wxString& path) 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; wxFileSystem fsys;
wxFSFile *fi; 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 // in that the data are iso-8859-1 (including HTML entities), but must
// be interpreted as being in language's windows charset. Correct the // be interpreted as being in language's windows charset. Correct the
// differences here and also convert to wxConvLocal in ANSI build // differences here and also convert to wxConvLocal in ANSI build
if (!charset.empty()) if (encoding != wxFONTENCODING_SYSTEM)
{ {
#if wxUSE_UNICODE #if wxUSE_UNICODE
#define CORRECT_STR(str, conv) \ #define CORRECT_STR(str, conv) \
@@ -549,7 +537,7 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
#define CORRECT_STR(str, conv) \ #define CORRECT_STR(str, conv) \
str = wxString((str).wc_str(conv), wxConvLocal) str = wxString((str).wc_str(conv), wxConvLocal)
#endif #endif
wxCSConv conv(charset); wxCSConv conv(encoding);
int i; int i;
for (i = IndexOld; i < m_IndexCnt; i++) for (i = IndexOld; i < m_IndexCnt; i++)
{ {
@@ -564,7 +552,7 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
#else #else
wxUnusedVar(IndexOld); wxUnusedVar(IndexOld);
wxUnusedVar(ContentsOld); 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 #endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
m_BookRecords.Add(bookr); m_BookRecords.Add(bookr);
@@ -648,7 +636,11 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
charset = linebuf + wxStrlen(_T("charset=")); charset = linebuf + wxStrlen(_T("charset="));
} while (lineptr != NULL); } while (lineptr != NULL);
bool rtval = AddBookParam(*fi, charset, wxFontEncoding enc;
if (charset == wxEmptyString) enc = wxFONTENCODING_SYSTEM;
else enc = wxFontMapper::Get()->CharsetToEncoding(charset);
bool rtval = AddBookParam(*fi, enc,
title, contents, index, start, fsys.GetPath()); title, contents, index, start, fsys.GetPath());
delete fi; delete fi;
return rtval; return rtval;