#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"
wxHtmlBookRecord *m_Book;
public:
- HP_TagHandler(wxHtmlBookRecord *b) : wxHtmlTagHandler() {m_Book = b; m_Items = NULL; m_ItemsCnt = 0; m_Name = m_Page = wxEmptyString; m_Level = 0; }
+ HP_TagHandler(wxHtmlBookRecord *b) : wxHtmlTagHandler() {m_Book = b; m_Items = NULL; m_ItemsCnt = 0; m_Name = m_Page = wxEmptyString; m_Level = 0; m_ID = -1; }
wxString GetSupportedTags() { return wxT("UL,OBJECT,PARAM"); }
bool HandleTag(const wxHtmlTag& tag);
void WriteOut(wxHtmlContentsItem*& array, int& size);
HP_TagHandler *handler = new HP_TagHandler(book);
parser.AddTagHandler(handler);
- f = ( contentsfile.IsEmpty() ? 0 : fsys.OpenFile(contentsfile) );
+ f = ( contentsfile.IsEmpty() ? (wxFSFile*) NULL : fsys.OpenFile(contentsfile) );
if (f) {
sz = f -> GetStream() -> GetSize();
buf = new char[sz + 1];
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) );
+ f = ( indexfile.IsEmpty() ? (wxFSFile*) NULL : fsys.OpenFile(indexfile) );
if (f) {
sz = f -> GetStream() -> GetSize();
buf = new char[sz + 1];
handler -> WriteOut(m_Index, m_IndexCnt);
delete[] buf;
}
+ else if (!indexfile.IsEmpty())
+ wxLogError(_("Cannot open index file: %s"), indexfile.mb_str());
return TRUE;
}
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));
}
+
+static wxString SafeFileName(const wxString& s)
+{
+ wxString res(s);
+ res.Replace(wxT("#"), wxT("_"));
+ res.Replace(wxT(":"), wxT("_"));
+ res.Replace(wxT("\\"), wxT("_"));
+ res.Replace(wxT("/"), wxT("_"));
+ return res;
+}
+
bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
wxFontEncoding encoding,
const wxString& title, const wxString& contfile,
if (m_TempPath != wxEmptyString)
{
wxFileOutputStream *outs = new wxFileOutputStream(m_TempPath +
- wxFileNameFromPath(bookfile.GetLocation()) + wxT(".cached"));
+ SafeFileName(wxFileNameFromPath(bookfile.GetLocation())) + wxT(".cached"));
SaveCachedBook(bookr, outs);
delete outs;
}
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();