From 67c276bdb6187d41aba589cbceb5a62708af48b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 27 Jun 2004 19:40:20 +0000 Subject: [PATCH] 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 --- include/wx/html/helpdata.h | 12 +----------- src/html/helpdata.cpp | 38 +++++++++++++++----------------------- 2 files changed, 16 insertions(+), 34 deletions(-) diff --git a/include/wx/html/helpdata.h b/include/wx/html/helpdata.h index d8e8dab59f..28c73e4da7 100644 --- a/include/wx/html/helpdata.h +++ b/include/wx/html/helpdata.h @@ -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); diff --git a/src/html/helpdata.cpp b/src/html/helpdata.cpp index 00aba6ec32..1b89735338 100644 --- a/src/html/helpdata.cpp +++ b/src/html/helpdata.cpp @@ -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; -- 2.45.2