diff --git a/include/wx/html/helpdata.h b/include/wx/html/helpdata.h
index dd7135f7d2..9bbc121d66 100644
--- a/include/wx/html/helpdata.h
+++ b/include/wx/html/helpdata.h
@@ -60,6 +60,11 @@ public:
void SetBasePath(const wxString& path) { m_BasePath = path; }
void SetStart(const wxString& start) { m_Start = start; }
+ // returns full filename of page (which is part of the book),
+ // i.e. with book's basePath prepended. If page is already absolute
+ // path, basePath is _not_ prepended.
+ wxString GetFullPath(const wxString &page) const;
+
protected:
wxString m_BasePath;
wxString m_Title;
@@ -79,6 +84,9 @@ struct wxHtmlContentsItem
wxChar* m_Name;
wxChar* m_Page;
wxHtmlBookRecord *m_Book;
+
+ // returns full filename of m_Page, i.e. with book's basePath prepended
+ wxString GetFullPath() const { return m_Book->GetFullPath(m_Page); }
};
//------------------------------------------------------------------------------
@@ -196,9 +204,6 @@ protected:
bool SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f);
};
-// Utility function
-wxString wxAddBasePath(const wxString& basePath, const wxString& path) ;
-
#endif
#endif
diff --git a/src/html/helpdata.cpp b/src/html/helpdata.cpp
index 2afd0e5416..e4a0adbdce 100644
--- a/src/html/helpdata.cpp
+++ b/src/html/helpdata.cpp
@@ -344,6 +344,16 @@ void HP_TagHandler::ReadIn(wxHtmlContentsItem* array, int size)
// wxHtmlHelpData
//-----------------------------------------------------------------------------
+wxString wxHtmlBookRecord::GetFullPath(const wxString &page) const
+{
+ if (wxIsAbsolutePath(page))
+ return page;
+ else
+ return m_BasePath + page;
+}
+
+
+
IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpData, wxObject)
wxHtmlHelpData::wxHtmlHelpData()
@@ -766,10 +776,10 @@ wxString wxHtmlHelpData::FindPageByName(const wxString& x)
cnt = m_BookRecords.GetCount();
for (i = 0; i < cnt; i++)
{
- f = fsys.OpenFile(wxAddBasePath(m_BookRecords[i].GetBasePath(), x));
+ f = fsys.OpenFile(m_BookRecords[i].GetFullPath(x));
if (f)
{
- url = wxAddBasePath(m_BookRecords[i].GetBasePath(), x);
+ url = m_BookRecords[i].GetFullPath(x);
delete f;
return url;
}
@@ -782,7 +792,7 @@ wxString wxHtmlHelpData::FindPageByName(const wxString& x)
{
if (m_BookRecords[i].GetTitle() == x)
{
- url = wxAddBasePath(m_BookRecords[i].GetBasePath(), m_BookRecords[i].GetStart());
+ url = m_BookRecords[i].GetFullPath(m_BookRecords[i].GetStart());
return url;
}
}
@@ -794,7 +804,7 @@ wxString wxHtmlHelpData::FindPageByName(const wxString& x)
{
if (wxStrcmp(m_Contents[i].m_Name, x) == 0)
{
- url = wxAddBasePath(m_Contents[i].m_Book->GetBasePath(), m_Contents[i].m_Page);
+ url = m_Contents[i].GetFullPath();
return url;
}
}
@@ -807,7 +817,7 @@ wxString wxHtmlHelpData::FindPageByName(const wxString& x)
{
if (wxStrcmp(m_Index[i].m_Name, x) == 0)
{
- url = wxAddBasePath(m_Index[i].m_Book->GetBasePath(), m_Index[i].m_Page);
+ url = m_Index[i].GetFullPath();
return url;
}
}
@@ -824,7 +834,7 @@ wxString wxHtmlHelpData::FindPageById(int id)
{
if (m_Contents[i].m_ID == id)
{
- url = wxAddBasePath(m_Contents[i].m_Book->GetBasePath(), m_Contents[i].m_Page);
+ url = m_Contents[i].GetFullPath();
return url;
}
}
@@ -903,10 +913,11 @@ bool wxHtmlSearchStatus::Search()
else m_LastPage = thepage;
wxFileSystem fsys;
- file = fsys.OpenFile(wxAddBasePath(m_Data->m_Contents[i].m_Book->GetBasePath(), thepage));
+ file = fsys.OpenFile(m_Data->m_Contents[i].m_Book->GetFullPath(thepage));
if (file)
{
- if (m_Engine.Scan(file->GetStream())) {
+ if (m_Engine.Scan(file->GetStream()))
+ {
m_Name = m_Data->m_Contents[i].m_Name;
m_ContentsItem = m_Data->m_Contents + i;
found = TRUE;
@@ -990,15 +1001,6 @@ bool wxSearchEngine::Scan(wxInputStream *stream)
return found;
}
-// Utility function
-wxString wxAddBasePath(const wxString& basePath, const wxString& path)
-{
- if (wxIsAbsolutePath(path))
- return path;
- else
- return basePath + path;
-}
-
#endif
diff --git a/src/html/helpfrm.cpp b/src/html/helpfrm.cpp
index c10b8254c5..acce6dff82 100644
--- a/src/html/helpfrm.cpp
+++ b/src/html/helpfrm.cpp
@@ -605,7 +605,7 @@ bool wxHtmlHelpFrame::DisplayContents()
{
wxHtmlBookRecord& book = m_Data->GetBookRecArray()[0];
if (!book.GetStart().IsEmpty())
- m_HtmlWin->LoadPage(wxAddBasePath(book.GetBasePath(), book.GetStart()));
+ m_HtmlWin->LoadPage(book.GetFullPath(book.GetStart()));
}
return TRUE;
}
@@ -627,7 +627,7 @@ bool wxHtmlHelpFrame::DisplayIndex()
{
wxHtmlBookRecord& book = m_Data->GetBookRecArray()[0];
if (!book.GetStart().IsEmpty())
- m_HtmlWin->LoadPage(wxAddBasePath(book.GetBasePath(), book.GetStart()));
+ m_HtmlWin->LoadPage(book.GetFullPath(book.GetStart()));
}
return TRUE;
}
@@ -686,7 +686,7 @@ bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword)
wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList->GetClientData(0);
if (it)
{
- m_HtmlWin->LoadPage(wxAddBasePath(it->m_Book->GetBasePath(), it->m_Page));
+ m_HtmlWin->LoadPage(it->GetFullPath());
NotifyPageChanged();
}
}
@@ -725,7 +725,7 @@ void wxHtmlHelpFrame::CreateContents()
roots[it->m_Level + 1] = m_ContentsBox->AppendItem(
roots[it->m_Level], it->m_Name, IMG_Page, -1,
new wxHtmlHelpTreeItemData(i));
- m_PagesHash->Put(wxAddBasePath(it->m_Book->GetBasePath(), it->m_Page),
+ m_PagesHash->Put(it->GetFullPath(),
new wxHtmlHelpHashData(i, roots[it->m_Level + 1]));
if (it->m_Level == 0)
@@ -1114,7 +1114,7 @@ void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index - 1);
if (it->m_Page[0] != 0)
{
- m_HtmlWin->LoadPage(wxAddBasePath(it->m_Book->GetBasePath(), it->m_Page));
+ m_HtmlWin->LoadPage(it->GetFullPath());
NotifyPageChanged();
}
}
@@ -1142,7 +1142,7 @@ void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
{
if (it->m_Page[0] != 0)
{
- m_HtmlWin->LoadPage(wxAddBasePath(it->m_Book->GetBasePath(), it->m_Page));
+ m_HtmlWin->LoadPage(it->GetFullPath());
NotifyPageChanged();
}
}
@@ -1166,11 +1166,11 @@ void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
{
wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index + 1);
- while (wxAddBasePath(it->m_Book->GetBasePath(), it->m_Page) == adr) it++;
+ while (it->GetFullPath() == adr) it++;
if (it->m_Page[0] != 0)
{
- m_HtmlWin->LoadPage(wxAddBasePath(it->m_Book->GetBasePath(), it->m_Page));
+ m_HtmlWin->LoadPage(it->GetFullPath());
NotifyPageChanged();
}
}
@@ -1293,7 +1293,7 @@ void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent& event)
it = m_Data->GetContents() + (pg->m_Id);
m_UpdateContents = FALSE;
if (it->m_Page[0] != 0)
- m_HtmlWin->LoadPage(wxAddBasePath(it->m_Book->GetBasePath(), it->m_Page));
+ m_HtmlWin->LoadPage(it->GetFullPath());
m_UpdateContents = TRUE;
}
}
@@ -1304,7 +1304,7 @@ void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent& WXUNUSED(event))
{
wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_IndexList->GetClientData(m_IndexList->GetSelection());
if (it->m_Page[0] != 0)
- m_HtmlWin->LoadPage(wxAddBasePath(it->m_Book->GetBasePath(), it->m_Page));
+ m_HtmlWin->LoadPage(it->GetFullPath());
NotifyPageChanged();
}
@@ -1343,7 +1343,7 @@ void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent& event)
if (first)
{
if (index[i].m_Page[0] != 0)
- m_HtmlWin->LoadPage(wxAddBasePath(index[i].m_Book->GetBasePath(), index[i].m_Page));
+ m_HtmlWin->LoadPage(index[i].GetFullPath());
NotifyPageChanged();
first = FALSE;
}
@@ -1374,7 +1374,7 @@ void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent& WXUNUSED(event))
if (first)
{
if (index[i].m_Page[0] != 0)
- m_HtmlWin->LoadPage(wxAddBasePath(index[i].m_Book->GetBasePath(), index[i].m_Page));
+ m_HtmlWin->LoadPage(index[i].GetFullPath());
NotifyPageChanged();
first = FALSE;
}
@@ -1392,7 +1392,7 @@ void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent& WXUNUSED(event))
if (it)
{
if (it->m_Page[0] != 0)
- m_HtmlWin->LoadPage(wxAddBasePath(it->m_Book->GetBasePath(), it->m_Page));
+ m_HtmlWin->LoadPage(it->GetFullPath());
NotifyPageChanged();
}
}