added wxLogError/Warning into wxHTML

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5618 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2000-01-23 21:47:41 +00:00
parent b662c13583
commit f3c8285953
5 changed files with 39 additions and 11 deletions

View File

@@ -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();

View File

@@ -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());

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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;