WinHelp.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //---------------------------------------------------------------------------
  2. #include <WinPCH.h>
  3. #pragma hdrstop
  4. #include <HelpIntfs.hpp>
  5. //---------------------------------------------------------------------------
  6. class TWebHelpSystem : public TCppInterfacedObject<ICustomHelpViewer>
  7. {
  8. public:
  9. __fastcall TWebHelpSystem(const UnicodeString & Version, const UnicodeString & Language);
  10. virtual int __fastcall UnderstandsKeyword(const UnicodeString HelpString);
  11. virtual TStringList * __fastcall GetHelpStrings(const UnicodeString HelpString);
  12. virtual void __fastcall NotifyID(const int ViewerID);
  13. virtual void __fastcall SoftShutDown();
  14. virtual void __fastcall ShutDown();
  15. virtual UnicodeString __fastcall GetViewerName();
  16. virtual bool __fastcall CanShowTableOfContents();
  17. virtual void __fastcall ShowTableOfContents();
  18. virtual void __fastcall ShowHelp(const UnicodeString HelpString);
  19. private:
  20. UnicodeString FVersion;
  21. UnicodeString FLanguage;
  22. };
  23. //---------------------------------------------------------------------------
  24. void __fastcall SearchHelp(const UnicodeString & Message)
  25. {
  26. // Message goes last, as it may exceed URL parameters limit (2048) and get truncated.
  27. // And we need to preserve the other parameters.
  28. OpenBrowser(FMTLOAD(DOCUMENTATION_SEARCH_URL3,
  29. (Configuration->ProductVersion, GUIConfiguration->AppliedLocaleHex,
  30. EncodeUrlString(Message))));
  31. }
  32. //---------------------------------------------------------------------------
  33. void __fastcall InitializeWinHelp()
  34. {
  35. InitializeCustomHelp(new TWebHelpSystem(
  36. Configuration->ProductVersion, GUIConfiguration->AppliedLocaleHex));
  37. }
  38. //---------------------------------------------------------------------------
  39. void __fastcall FinalizeWinHelp()
  40. {
  41. FinalizeCustomHelp();
  42. }
  43. //---------------------------------------------------------------------------
  44. __fastcall TWebHelpSystem::TWebHelpSystem(
  45. const UnicodeString & Version, const UnicodeString & Language) :
  46. FVersion(Version), FLanguage(Language)
  47. {
  48. }
  49. //---------------------------------------------------------------------------
  50. int __fastcall TWebHelpSystem::UnderstandsKeyword(const UnicodeString DebugUsedArg(HelpString))
  51. {
  52. // pretend that we know everything
  53. return 1;
  54. }
  55. //---------------------------------------------------------------------------
  56. TStringList * __fastcall TWebHelpSystem::GetHelpStrings(const UnicodeString HelpString)
  57. {
  58. TStringList * Result = new TStringList();
  59. Result->Add(GetViewerName() + L" : " + HelpString);
  60. return Result;
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TWebHelpSystem::NotifyID(const int /*ViewerID*/)
  64. {
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TWebHelpSystem::SoftShutDown()
  68. {
  69. }
  70. //---------------------------------------------------------------------------
  71. void __fastcall TWebHelpSystem::ShutDown()
  72. {
  73. }
  74. //---------------------------------------------------------------------------
  75. UnicodeString __fastcall TWebHelpSystem::GetViewerName()
  76. {
  77. return L"Web";
  78. }
  79. //---------------------------------------------------------------------------
  80. bool __fastcall TWebHelpSystem::CanShowTableOfContents()
  81. {
  82. return true;
  83. }
  84. //---------------------------------------------------------------------------
  85. void __fastcall TWebHelpSystem::ShowTableOfContents()
  86. {
  87. OpenBrowser(FMTLOAD(DOCUMENTATION_URL2, (FVersion, FLanguage)));
  88. }
  89. //---------------------------------------------------------------------------
  90. void __fastcall TWebHelpSystem::ShowHelp(const UnicodeString AHelpString)
  91. {
  92. if (IsHttpOrHttpsUrl(AHelpString))
  93. {
  94. OpenBrowser(AHelpString);
  95. }
  96. else
  97. {
  98. ::ShowHelp(AHelpString);
  99. }
  100. }