X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/66a77a748e5c8002f3f9ebd66f5457aca5aabad8..5268c5a32bbe68b834abeaa89c8cfb2099d50d2e:/src/html/htmlfilt.cpp diff --git a/src/html/htmlfilt.cpp b/src/html/htmlfilt.cpp index 4f885e47c9..9c412c1f7b 100644 --- a/src/html/htmlfilt.cpp +++ b/src/html/htmlfilt.cpp @@ -15,14 +15,15 @@ #include "wx/wxprec.h" #include "wx/defs.h" -#if wxUSE_HTML +#if wxUSE_HTML && wxUSE_STREAMS #ifdef __BORDLANDC__ #pragma hdrstop #endif #ifndef WXPRECOMP -#include "wx/wx.h" + #include "wx/log.h" + #include "wx/intl.h" #endif #include "wx/html/htmlfilt.h" @@ -58,9 +59,9 @@ wxString wxHtmlFilterPlainText::ReadFile(const wxFSFile& file) const wxString doc, doc2; if (s == NULL) return wxEmptyString; - src = new char[s -> GetSize()+1]; - src[s -> GetSize()] = 0; - s -> Read(src, s -> GetSize()); + src = new char[s->GetSize()+1]; + src[s->GetSize()] = 0; + s->Read(src, s->GetSize()); doc = src; delete [] src; @@ -94,7 +95,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterImage, wxHtmlFilter) bool wxHtmlFilterImage::CanRead(const wxFSFile& file) const { - return (file.GetMimeType().Left(6) == "image/"); + return (file.GetMimeType().Left(6) == wxT("image/")); } @@ -141,13 +142,25 @@ wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const char *src; wxString doc; - if (s == NULL) return wxEmptyString; - src = new char[s -> GetSize() + 1]; - src[s -> GetSize()] = 0; - s -> Read(src, s -> GetSize()); + if (s == NULL) + { + wxLogError(_("Cannot open HTML document: %s"), file.GetLocation().c_str()); + return wxEmptyString; + } + src = new char[s->GetSize() + 1]; + src[s->GetSize()] = 0; + s->Read(src, s->GetSize()); doc = src; delete[] src; + // add meta tag if we obtained this through http: + if (file.GetMimeType().Find(_T("; charset=")) == 0) + { + wxString s(_T(""); + return s+doc; + } + return doc; }