From f3c8285953e9e92229e1ff65cac135fdb60e789c Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 23 Jan 2000 21:47:41 +0000 Subject: [PATCH] added wxLogError/Warning into wxHTML git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5618 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/html/helpdata.cpp | 19 ++++++++++++++++--- src/html/htmlfilt.cpp | 6 +++++- src/html/htmlpars.cpp | 7 ++++++- src/html/htmlwin.cpp | 15 +++++++++------ src/html/winpars.cpp | 3 +++ 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/html/helpdata.cpp b/src/html/helpdata.cpp index bc928a7ccb..0c34284d53 100644 --- a/src/html/helpdata.cpp +++ b/src/html/helpdata.cpp @@ -34,6 +34,7 @@ #include "wx/busyinfo.h" #include "wx/encconv.h" #include "wx/fontmap.h" +#include "wx/log.h" #include "wx/html/htmlpars.h" #include "wx/html/htmldefs.h" @@ -233,6 +234,8 @@ bool wxHtmlHelpData::LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys, c handler -> WriteOut(m_Contents, m_ContentsCnt); delete[] buf; } + else + wxLogError(_("Cannot open contents file: %s"), contentsfile.mb_str()); f = ( indexfile.IsEmpty() ? 0 : fsys.OpenFile(indexfile) ); if (f) { @@ -246,6 +249,8 @@ bool wxHtmlHelpData::LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys, c handler -> WriteOut(m_Index, m_IndexCnt); delete[] buf; } + else + wxLogError(_("Cannot open index file: %s"), indexfile.mb_str()); return TRUE; } @@ -278,9 +283,13 @@ bool wxHtmlHelpData::LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f) f -> Read(&x, sizeof(x)); version = wxINT32_SWAP_ON_BE(x); - if (version != CURRENT_CACHED_BOOK_VERSION) return FALSE; + if (version != CURRENT_CACHED_BOOK_VERSION) + { + wxLogError(_("Incorrect version of HTML help book")); + return FALSE; // NOTE: when adding new version, please ensure backward compatibility! - + } + /* load contents : */ f -> Read(&x, sizeof(x)); @@ -517,7 +526,11 @@ bool wxHtmlHelpData::AddBook(const wxString& book) else bookFull = wxGetCwd() + "/" + book; fi = fsys.OpenFile(bookFull); - if (fi == NULL) return FALSE; + if (fi == NULL) + { + wxLogError(_("Cannot open HTML help book: %s"), bookFull.mb_str()); + return FALSE; + } fsys.ChangePathTo(bookFull); s = fi -> GetStream(); sz = s -> GetSize(); diff --git a/src/html/htmlfilt.cpp b/src/html/htmlfilt.cpp index 199b91c6c4..fff367cc45 100644 --- a/src/html/htmlfilt.cpp +++ b/src/html/htmlfilt.cpp @@ -141,7 +141,11 @@ wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const char *src; wxString doc; - if (s == NULL) return wxEmptyString; + if (s == NULL) + { + wxLogError(_("Cannot open HTML document: %s"), file.GetLocation().mb_str()); + return wxEmptyString; + } src = new char[s -> GetSize() + 1]; src[s -> GetSize()] = 0; s -> Read(src, s -> GetSize()); diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index 5c07054f58..4cec1c5cd1 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -173,7 +173,12 @@ void wxHtmlParser::PopTagHandler() { wxNode *first; - if (m_HandlersStack == NULL || (first = m_HandlersStack -> GetFirst()) == NULL) return; + if (m_HandlersStack == NULL || + (first = m_HandlersStack -> GetFirst()) == NULL) + { + wxLogWarning(_("Warning: attempt to remove HTML tag handler from empty stack.")); + return; + } m_HandlersHash = *((wxHashTable*) first -> GetData()); m_HandlersStack -> DeleteNode(first); } diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index c1af6ac461..31cc7feb00 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -27,6 +27,7 @@ #include "wx/html/htmlwin.h" #include "wx/html/forcelnk.h" +#include "wx/log.h" //----------------------------------------------------------------------------- @@ -154,10 +155,8 @@ bool wxHtmlWindow::LoadPage(const wxString& location) if (f == NULL) { wxString err; - err.Printf(_("Unable to open requested location :\n\n%s"), WXSTRINGCAST location); + wxLogError(_("Unable to open requested HTML document: %s"), location.mb_str()); m_tmpCanDrawLocks--; - Refresh(); - wxMessageBox(err, "Error"); SetCursor(*wxSTANDARD_CURSOR); return FALSE; @@ -224,7 +223,11 @@ bool wxHtmlWindow::LoadPage(const wxString& location) bool wxHtmlWindow::ScrollToAnchor(const wxString& anchor) { const wxHtmlCell *c = m_Cell -> Find(wxHTML_COND_ISANCHOR, &anchor); - if (!c) return FALSE; + if (!c) + { + wxLogWarning(_("HTML anchor %s does not exist."), anchor.mb_str()); + return FALSE; + } else { int y; @@ -474,11 +477,11 @@ void wxHtmlWindow::OnKeyDown(wxKeyEvent& event) switch (event.KeyCode()) { case WXK_PAGEUP : case WXK_PRIOR : - Scroll(-1, sty - (2 * cliy / 3)); + Scroll(-1, sty - (5 * cliy / 6)); break; case WXK_PAGEDOWN : case WXK_NEXT : - Scroll(-1, sty + (2 * cliy / 3)); + Scroll(-1, sty + (5 * cliy / 6)); break; case WXK_HOME : Scroll(-1, 0); diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index 2148fa371e..4681967547 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -29,6 +29,7 @@ #include "wx/html/winpars.h" #include "wx/html/htmlwin.h" #include "wx/fontmap.h" +#include "wx/log.h" //----------------------------------------------------------------------------- @@ -353,6 +354,8 @@ void wxHtmlWinParser::SetInputEncoding(wxFontEncoding enc) wxFONTENCODING_ISO8859_1 : m_OutputEnc, wxCONVERT_SUBSTITUTE)) { // total failture :-( + wxLogError(_("Failed to display HTML document in %s encoding"), + wxFontMapper::GetEncodingName(enc).mb_str()); m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT; delete m_EncConv; m_EncConv = NULL; -- 2.47.2