- contents = wxEmptyString, index = wxEmptyString;
-
- if (wxIsAbsolutePath(book)) bookFull = book;
- else bookFull = wxGetCwd() + "/" + book;
-
- fi = fsys.OpenFile(bookFull);
- if (fi == NULL) return FALSE;
- fsys.ChangePathTo(bookFull);
- s = fi -> GetStream();
- sz = s -> GetSize();
- buff = new char[sz+1];
- buff[sz] = 0;
- s -> Read(buff, sz);
- lineptr = buff;
+ contents = wxEmptyString,
+ index = wxEmptyString,
+ charset = wxEmptyString;
+
+ fi = fsys.OpenFile(book);
+ if (fi == NULL)
+ {
+ wxLogError(_("Cannot open HTML help book: %s"), book.c_str());
+ return false;
+ }
+ fsys.ChangePathTo(book);
+
+ const wxChar *lineptr;
+ wxChar linebuf[300];
+ wxString tmp;
+ wxHtmlFilterPlainText filter;
+ tmp = filter.ReadFile(*fi);
+ lineptr = tmp.c_str();
+
+ do
+ {
+ lineptr = ReadLine(lineptr, linebuf, 300);
+
+ for (wxChar *ch = linebuf; *ch != wxT('\0') && *ch != wxT('='); ch++)
+ *ch = (wxChar)wxTolower(*ch);
+
+ if (wxStrstr(linebuf, _T("title=")) == linebuf)
+ title = linebuf + wxStrlen(_T("title="));
+ if (wxStrstr(linebuf, _T("default topic=")) == linebuf)
+ start = linebuf + wxStrlen(_T("default topic="));
+ if (wxStrstr(linebuf, _T("index file=")) == linebuf)
+ index = linebuf + wxStrlen(_T("index file="));
+ if (wxStrstr(linebuf, _T("contents file=")) == linebuf)
+ contents = linebuf + wxStrlen(_T("contents file="));
+ if (wxStrstr(linebuf, _T("charset=")) == linebuf)
+ charset = linebuf + wxStrlen(_T("charset="));
+ } while (lineptr != NULL);
+
+ wxFontEncoding enc = wxFONTENCODING_SYSTEM;
+#if wxUSE_FONTMAP
+ if (charset != wxEmptyString)
+ enc = wxFontMapper::Get()->CharsetToEncoding(charset);
+#endif
+
+ bool rtval = AddBookParam(*fi, enc,
+ title, contents, index, start, fsys.GetPath());