class WXDLLEXPORT wxHtmlBookRecord : public wxObject
{
public:
- wxHtmlBookRecord(const wxString& basepath, const wxString& title,
- const wxString& start)
+ wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
+ const wxString& title, const wxString& start)
{
+ m_BookFile = bookfile;
m_BasePath = basepath;
m_Title = title;
m_Start = start;
// for debugging, give the contents index obvious default values
m_ContentsStart = m_ContentsEnd = -1;
}
+ wxString GetBookFile() const { return m_BookFile; }
wxString GetTitle() const { return m_Title; }
wxString GetStart() const { return m_Start; }
wxString GetBasePath() const { return m_BasePath; }
wxString GetFullPath(const wxString &page) const;
protected:
+ wxString m_BookFile;
wxString m_BasePath;
wxString m_Title;
wxString m_Start;
const wxString& deftopic = wxEmptyString,
const wxString& path = wxEmptyString);
- bool AlreadyHasBook(wxHtmlBookRecord * bookr) ;
// Some accessing stuff:
// returns URL of page on basis of (file)name
return res;
}
-bool wxHtmlHelpData::AlreadyHasBook(wxHtmlBookRecord * bookr)
-{
- size_t bookCount = m_BookRecords.GetCount();
- if (bookCount == 0) return FALSE ;
-
- wxHtmlBookRecord currentBook(wxEmptyString,wxEmptyString,wxEmptyString);
- size_t i;
- for (i=0; i<bookCount; i++)
- {
- currentBook = m_BookRecords.Item(i) ;
- if (currentBook.GetBasePath().IsSameAs(bookr->GetBasePath()) &&
- currentBook.GetTitle().IsSameAs(bookr->GetTitle()) &&
- currentBook.GetStart().IsSameAs(bookr->GetStart()) )
- return TRUE ;
-
- }
- return FALSE ;
-}
-
bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
wxFontEncoding encoding,
const wxString& title, const wxString& contfile,
int IndexOld = m_IndexCnt,
ContentsOld = m_ContentsCnt;
- if (! path.IsEmpty())
+ if (!path.IsEmpty())
fsys.ChangePathTo(path, TRUE);
- bookr = new wxHtmlBookRecord(fsys.GetPath(), title, deftopic);
- // return TRUE to indicate book is loaded
- if (AlreadyHasBook(bookr)) return TRUE ;
+ size_t booksCnt = m_BookRecords.GetCount();
+ for (size_t i = 0; i < booksCnt; i++)
+ {
+ if ( m_BookRecords[i].GetBookFile() == bookfile.GetLocation() )
+ return TRUE; // book is (was) loaded
+ }
+
+ bookr = new wxHtmlBookRecord(bookfile.GetLocation(), fsys.GetPath(), title, deftopic);
if (m_ContentsCnt % wxHTML_REALLOC_STEP == 0)
m_Contents = (wxHtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt + wxHTML_REALLOC_STEP) * sizeof(wxHtmlContentsItem));