WinHelp.cpp 3.7 KB

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