From 6f2c1613175744da3a19c64c3f2dd3d820231e22 Mon Sep 17 00:00:00 2001 From: martynshaw99 Date: Mon, 25 Aug 2014 23:46:50 +0000 Subject: [PATCH] Third of a series of patches from Steve and Richard to fix delivering local and remote help pages. (Second one not committed as it was just a wording change) --- src/widgets/HelpSystem.cpp | 9 ++++++++- src/widgets/HelpSystem.h | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/widgets/HelpSystem.cpp b/src/widgets/HelpSystem.cpp index ada96aeba..4b40d8d95 100644 --- a/src/widgets/HelpSystem.cpp +++ b/src/widgets/HelpSystem.cpp @@ -190,6 +190,13 @@ void HelpSystem::ShowHelpDialog(wxWindow *parent, } } + // Obtain the local file system file name, without the anchor if present. + wxString localfile; + if (localFileName.Find('#', true) != wxNOT_FOUND) + localfile = localFileName.BeforeLast('#'); + else + localfile = localFileName; + if( localFileName.Contains(wxT("Quick_Help")) ) // 'Quick_Help' is installed locally OpenInDefaultBrowser( localFileName ); @@ -198,7 +205,7 @@ void HelpSystem::ShowHelpDialog(wxWindow *parent, // Always go to remote URL. Use External browser. OpenInDefaultBrowser( remoteURL ); } - else if( !wxFileExists( localFileName )) + else if( !wxFileExists( localfile )) { // If you give an empty remote URL, you should have already ensured // that the file exists! diff --git a/src/widgets/HelpSystem.h b/src/widgets/HelpSystem.h index 90d94cb1e..a5cf908eb 100644 --- a/src/widgets/HelpSystem.h +++ b/src/widgets/HelpSystem.h @@ -42,7 +42,12 @@ public: bool bIsFile, bool bModal); /// Displays a file in your browser, if it's available locally, - /// OR else links to the internet. + /// OR else links to the internet. Generally using this outside this class + /// is depreciated in favour of the "smarter" overload below, unless there + /// is a good reason for using this form. + /// @param localFileName Name and path of the file on the local machine + /// file system to be opened. file.name#anchor syntax is allowed, and therefore + /// file names containing a '#' are not (on any platform). static void ShowHelpDialog(wxWindow *parent, const wxString &localFileName, const wxString &remoteURL);