From fcf77487edae715c75f0f802a96e203d88dd56c6 Mon Sep 17 00:00:00 2001
From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= <vslavik@fastmail.fm>
Date: Sun, 8 Dec 2002 20:30:42 +0000
Subject: [PATCH] added wxHtmlHelpController::AddBook(wxFileName)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18118 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/hthelpct.tex | 20 +++++++++++++++-----
 docs/latex/wx/hthlpdat.tex |  8 ++++----
 src/html/helpctrl.cpp      |  7 ++++++-
 src/html/helpdata.cpp      | 17 +++--------------
 4 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/docs/latex/wx/hthelpct.tex b/docs/latex/wx/hthelpct.tex
index 2e667c66da..acb5cbfe7e 100644
--- a/docs/latex/wx/hthelpct.tex
+++ b/docs/latex/wx/hthelpct.tex
@@ -81,17 +81,27 @@ all other sections (sections, subsections, ...) have a folder icon.}
 
 \membersection{wxHtmlHelpController::AddBook}\label{wxhtmlhelpcontrolleraddbook}
 
-\func{bool}{AddBook}{\param{const wxString\& }{book}, \param{bool }{show\_wait\_msg}}
+\func{bool}{AddBook}{\param{const wxFileName\& }{book\_file}, \param{bool }{show\_wait\_msg}}
+
+\func{bool}{AddBook}{\param{const wxString\& }{book\_url}, \param{bool }{show\_wait\_msg}}
 
 Adds book (\helpref{.hhp file}{helpformat} - HTML Help Workshop project file) into the list of loaded books.
 This must be called at least once before displaying  any help.
 
-{\it book} may be either .hhp file or ZIP archive that contains arbitrary number of .hhp files in 
+{\it book\_file} or {\it book\_url}  may be either .hhp file or ZIP archive
+that contains arbitrary number of .hhp files in 
 top-level directory. This ZIP archive must have .zip or .htb extension
-(the latter stands for "HTML book"). In other words, {\tt AddBook("help.zip")} is possible and, in fact,
-recommended way.
+(the latter stands for "HTML book"). In other words,
+{\tt AddBook(wxFileName("help.zip"))}
+is possible and, in fact, recommended way.
+
+\wxheading{Parameters}
 
-If {\it show\_wait\_msg} is TRUE then a decoration-less window with progress message is displayed.
+\docparam{show\_wait\_msg}{If TRUE then a decoration-less window with progress message is displayed.}
+\docparam{book\_file}{Help book filename. It is recommended to use this prototype
+instead of the one taking URL, because it is less error-prone.}
+\docparam{book\_url}{Help book URL (note that syntax of filename and URL is 
+different on most platforms)}
 
 \wxheading{Note}
 
diff --git a/docs/latex/wx/hthlpdat.tex b/docs/latex/wx/hthlpdat.tex
index c920f9fb07..b92bb0e826 100644
--- a/docs/latex/wx/hthlpdat.tex
+++ b/docs/latex/wx/hthlpdat.tex
@@ -28,11 +28,11 @@ Constructor.
 
 \membersection{wxHtmlHelpData::AddBook}\label{wxhtmlhelpdataaddbook}
 
-\func{bool}{AddBook}{\param{const wxString\& }{book}}
+\func{bool}{AddBook}{\param{const wxString\& }{book\_url}}
 
-Adds new book. 'book' is location of HTML help project (hhp) or ZIP file
-that contains arbitrary number of .hhp projects (this zip file can have
-either .zip or .htb extension, htb stands for "html book").
+Adds new book. {\it book} is URL (not filename!) of HTML help project (hhp)
+or ZIP file that contains arbitrary number of .hhp projects (this zip
+file can have either .zip or .htb extension, htb stands for "html book").
 Returns success.
 
 \membersection{wxHtmlHelpData::FindPageById}\label{wxhtmlhelpdatafindpagebyid}
diff --git a/src/html/helpctrl.cpp b/src/html/helpctrl.cpp
index b55d11fcb9..66b763c641 100644
--- a/src/html/helpctrl.cpp
+++ b/src/html/helpctrl.cpp
@@ -84,6 +84,11 @@ void wxHtmlHelpController::SetTitleFormat(const wxString& title)
 }
 
 
+bool wxHtmlHelpController::AddBook(const wxFileName& book_file, bool show_wait_msg)
+{
+    return AddBook(wxFileSystem::FileNameToURL(book_file), show_wait_msg);
+}
+
 bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg)
 {
     wxBusyCursor cur;
@@ -186,7 +191,7 @@ bool wxHtmlHelpController::Initialize(const wxString& file)
         }
     }
 
-    return AddBook(actualFilename);
+    return AddBook(wxFileName(actualFilename));
 }
 
 bool wxHtmlHelpController::LoadFile(const wxString& WXUNUSED(file))
diff --git a/src/html/helpdata.cpp b/src/html/helpdata.cpp
index 51d0f334d3..1864c907e5 100644
--- a/src/html/helpdata.cpp
+++ b/src/html/helpdata.cpp
@@ -570,7 +570,6 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
     {
         wxFSFile *fi;
         wxFileSystem fsys;
-        wxString bookFull;
 
         wxString title = _("noname"),
                  safetitle,
@@ -579,23 +578,13 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
                  index = wxEmptyString,
                  charset = wxEmptyString;
 
-#if defined(__WXMAC__) && !defined(__DARWIN__)
-        if (wxIsAbsolutePath(book)) bookFull = book;
-        else bookFull = wxGetCwd() + book; // no slash or dot
-        wxFileName fn( bookFull );
-        bookFull = fn.GetFullPath( wxPATH_UNIX );
-#else
-        if (wxIsAbsolutePath(book)) bookFull = book;
-        else bookFull = wxGetCwd() + wxT("/") + book;
-#endif
-
-        fi = fsys.OpenFile(bookFull);
+        fi = fsys.OpenFile(book);
         if (fi == NULL)
         {
-            wxLogError(_("Cannot open HTML help book: %s"), bookFull.c_str());
+            wxLogError(_("Cannot open HTML help book: %s"), book.c_str());
             return FALSE;
         }
-        fsys.ChangePathTo(bookFull);
+        fsys.ChangePathTo(book);
 
         const wxChar *lineptr;
         wxChar linebuf[300];
-- 
2.50.0

