rewrote Chris' fix properly

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14485 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2002-03-07 21:45:03 +00:00
parent 18fc9fa3b5
commit 5ecdcaa78f
3 changed files with 15 additions and 27 deletions

View File

@@ -35,15 +35,17 @@ class WXDLLEXPORT wxHtmlHelpData;
class WXDLLEXPORT wxHtmlBookRecord : public wxObject class WXDLLEXPORT wxHtmlBookRecord : public wxObject
{ {
public: public:
wxHtmlBookRecord(const wxString& basepath, const wxString& title, wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
const wxString& start) const wxString& title, const wxString& start)
{ {
m_BookFile = bookfile;
m_BasePath = basepath; m_BasePath = basepath;
m_Title = title; m_Title = title;
m_Start = start; m_Start = start;
// for debugging, give the contents index obvious default values // for debugging, give the contents index obvious default values
m_ContentsStart = m_ContentsEnd = -1; m_ContentsStart = m_ContentsEnd = -1;
} }
wxString GetBookFile() const { return m_BookFile; }
wxString GetTitle() const { return m_Title; } wxString GetTitle() const { return m_Title; }
wxString GetStart() const { return m_Start; } wxString GetStart() const { return m_Start; }
wxString GetBasePath() const { return m_BasePath; } wxString GetBasePath() const { return m_BasePath; }
@@ -66,6 +68,7 @@ public:
wxString GetFullPath(const wxString &page) const; wxString GetFullPath(const wxString &page) const;
protected: protected:
wxString m_BookFile;
wxString m_BasePath; wxString m_BasePath;
wxString m_Title; wxString m_Title;
wxString m_Start; wxString m_Start;
@@ -171,7 +174,6 @@ public:
const wxString& deftopic = wxEmptyString, const wxString& deftopic = wxEmptyString,
const wxString& path = wxEmptyString); const wxString& path = wxEmptyString);
bool AlreadyHasBook(wxHtmlBookRecord * bookr) ;
// Some accessing stuff: // Some accessing stuff:
// returns URL of page on basis of (file)name // returns URL of page on basis of (file)name

View File

@@ -97,7 +97,7 @@ bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg)
delete busy; delete busy;
#endif #endif
if (m_helpFrame) if (m_helpFrame)
m_helpFrame->RefreshLists() ; m_helpFrame->RefreshLists();
return retval; return retval;
} }

View File

@@ -439,25 +439,6 @@ static wxString SafeFileName(const wxString& s)
return res; 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, bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
wxFontEncoding encoding, wxFontEncoding encoding,
const wxString& title, const wxString& contfile, const wxString& title, const wxString& contfile,
@@ -471,12 +452,17 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
int IndexOld = m_IndexCnt, int IndexOld = m_IndexCnt,
ContentsOld = m_ContentsCnt; ContentsOld = m_ContentsCnt;
if (! path.IsEmpty()) if (!path.IsEmpty())
fsys.ChangePathTo(path, TRUE); fsys.ChangePathTo(path, TRUE);
bookr = new wxHtmlBookRecord(fsys.GetPath(), title, deftopic); size_t booksCnt = m_BookRecords.GetCount();
// return TRUE to indicate book is loaded for (size_t i = 0; i < booksCnt; i++)
if (AlreadyHasBook(bookr)) return TRUE ; {
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) if (m_ContentsCnt % wxHTML_REALLOC_STEP == 0)
m_Contents = (wxHtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt + wxHTML_REALLOC_STEP) * sizeof(wxHtmlContentsItem)); m_Contents = (wxHtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt + wxHTML_REALLOC_STEP) * sizeof(wxHtmlContentsItem));