wizards/source/scriptforge/SF_Exception.xba   |   43 +++++++++++++++++++++++---
 wizards/source/scriptforge/SF_Root.xba        |   19 +++++++----
 wizards/source/scriptforge/po/ScriptForge.pot |   11 +++++-
 wizards/source/scriptforge/po/en.po           |   11 +++++-
 4 files changed, 69 insertions(+), 15 deletions(-)

New commits:
commit 57f6c7f4c913368f1ef34859e6c973c9c1660c65
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Mon Jan 31 17:18:39 2022 +0100
Commit:     Jean-Pierre Ledure <j...@ledure.be>
CommitDate: Tue Feb 1 12:17:03 2022 +0100

    ScriptForge - (SF_Exception) error messages give access to help page
    
    When ScriptForge detects an error in a user script,
    a message box is displayed with a summary of the
    syntax and validation rules the invoked method
    should respect, and/or any other reason the library
    has identified.
    
    Now the error message is completed with
    - the sentence "Do you want to receive more information
      about the '%1' method ?"
    - 2 buttons Yes/No (No being the default)
    
    When the Yes button is pressed the local browser opens
    the help page/anchor of the invoked service/method.
    
    The pot template and the english po files are modified.
    
    There is no difference between Basic and Python in this
    matter.
    
    Change-Id: Ie6210b9d108c9a1e98a46173504680e3985125b0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129232
    Tested-by: Jenkins
    Tested-by: Jean-Pierre Ledure <j...@ledure.be>
    Reviewed-by: Jean-Pierre Ledure <j...@ledure.be>

diff --git a/wizards/source/scriptforge/SF_Exception.xba 
b/wizards/source/scriptforge/SF_Exception.xba
index 57ac5090d6a9..a7fde7b69ea4 100644
--- a/wizards/source/scriptforge/SF_Exception.xba
+++ b/wizards/source/scriptforge/SF_Exception.xba
@@ -739,10 +739,15 @@ Public Sub RaiseFatal(Optional ByVal ErrorCode As Variant 
_
 &apos;&apos;&apos;             pvArgs: the arguments to insert in the error 
message
 
 Dim sLocation As String                &apos;  Common header in error 
messages: location of error
+Dim sService As String         &apos;  Service name having detected the error
+Dim sMethod As String          &apos;  Method name having detected the error
 Dim vLocation As Variant       &apos;  Split array (library, module, method)
 Dim sMessage As String         &apos;  Message to log and display
 Dim L10N As Object                     &apos;  Alias of Interface
 Dim sAlt As String                     &apos;  Alternative error messages
+Dim iButtons As Integer                &apos;  MB_OK or MB_YESNO
+Dim iMsgBox As Integer         &apos;  Return value of the message box
+
 Const cstTabSize = 4
 Const cstThisSub = &quot;Exception.RaiseFatal&quot;
 Const cstSubArgs = &quot;ErrorCode, [Arg0[, Arg1 ...]]&quot;
@@ -762,9 +767,13 @@ Try:
        If Len(_SF_.MainFunction) &gt; 0 Then   &apos;  MainFunction = 
[Library.]Module.Method
                vLocation = Split(_SF_.MainFunction, &quot;.&quot;)
                If UBound(vLocation) &lt; 2 Then vLocation = 
SF_Array.Prepend(vLocation, &quot;ScriptForge&quot;)
-               sLocation = L10N.GetText(&quot;VALIDATESOURCE&quot;, 
vLocation(0), vLocation(1), vLocation(2)) _
+               sService = vLocation(1)
+               sMethod = vLocation(2)
+               sLocation = L10N.GetText(&quot;VALIDATESOURCE&quot;, 
vLocation(0), sService, sMethod) _
                                        &amp; &quot;\n&quot; &amp; 
L10N.GetText(&quot;VALIDATEARGS&quot;, _RightCaseArgs(_SF_.MainFunctionArgs))
        Else
+               sService = &quot;&quot;
+               sMethod = &quot;&quot;
                sLocation = &quot;&quot;
        End If
 
@@ -1025,9 +1034,19 @@ Try:
        &apos;  Display fatal event, if relevant (default)
        If _SF_.DisplayEnabled Then
                If _SF_.StopWhenError Then sMessage = sMessage &amp; 
&quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; 
L10N.GetText(&quot;STOPEXECUTION&quot;)
-               MsgBox SF_String.ExpandTabs(SF_String.Unescape(sMessage), 
cstTabSize) _
-                               , MB_OK + MB_ICONEXCLAMATION _
-                               , L10N.GetText(&quot;ERRORNUMBER&quot;, 
ErrorCode)
+               &apos;  Do you need more help ?
+               If Len(sMethod) &gt; 0 Then
+                       sMessage = sMessage &amp; &quot;\n&quot; &amp; 
&quot;\n&quot; &amp; L10N.GetText(&quot;NEEDMOREHELP&quot;, sMethod)
+                       iButtons = MB_YESNO + MB_DEFBUTTON2
+               Else
+                       iButtons = MB_OK
+               End If
+               iMsgBox = 
MsgBox(SF_String.ExpandTabs(SF_String.Unescape(sMessage), cstTabSize) _
+                                       , iButtons + MB_ICONEXCLAMATION _
+                                       , L10N.GetText(&quot;ERRORNUMBER&quot;, 
ErrorCode) _
+                                       )
+               &apos;  If more help needed ...
+               If iMsgBox = IDYES Then _OpenHelpInBrowser(sService, sMethod)
        End If
        
 Finally:
@@ -1185,6 +1204,22 @@ Finally:
        Exit Sub
 End Sub                        &apos;  ScriptForge.SF_Exception._ConsoleRefresh
 
+REM 
-----------------------------------------------------------------------------
+Private Sub _OpenHelpInBrowser(ByVal psService As String, ByVal psMethod As 
String)
+&apos;&apos;&apos;     Open the help page and help anchor related to the given 
ScriptForge service and method
+
+Dim sUrl As String                     &apos;  URL to open
+Const cstURL = 
&quot;https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_%1.html?&amp;DbPAR=BASIC#%2&quot;
+
+       On Local Error GoTo Finally             &apos;  No reason to risk abort 
here
+Try:
+       sUrl = SF_String.ReplaceStr(cstURL, Array(&quot;%1&quot;, 
&quot;%2&quot;), Array(LCase(psService), psMethod))
+       SF_Session.OpenUrlInBrowser(sUrl)
+
+Finally:
+       Exit Sub
+End Sub                        &apos;  
ScriptForge.SF_Exception._OpenHelpInBrowser
+
 REM 
-----------------------------------------------------------------------------
 Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
 &apos;&apos;&apos;     Return the value of the named property
diff --git a/wizards/source/scriptforge/SF_Root.xba 
b/wizards/source/scriptforge/SF_Root.xba
index 3ec4c2936908..9d03fcd6f160 100644
--- a/wizards/source/scriptforge/SF_Root.xba
+++ b/wizards/source/scriptforge/SF_Root.xba
@@ -300,25 +300,30 @@ Try:
        &apos;  SF_Exception.Raise
                        .AddText(       Context := &quot;CLOSEBUTTON&quot; _
                                                , MsgId := &quot;Close&quot; _
-                                               , Comment := &quot;Text in 
close buttons of progress and console dialog boxes&quot; _
+                                               , Comment :=    &quot;Text in 
close buttons of progress and console dialog boxes&quot; _
                                        )
                        .AddText(       Context := &quot;ERRORNUMBER&quot; _
                                                , MsgId := &quot;Error %1&quot; 
_
-                                               , Comment := &quot;Title in 
error message box\n&quot; _
-                                                                       &amp; 
&quot;%1: an error number&quot; _
+                                               , Comment :=    &quot;Title in 
error message box\n&quot; _
+                                                                       &amp;   
&quot;%1: an error number&quot; _
                                        )
                        .AddText(       Context := &quot;ERRORLOCATION&quot; _
                                                , MsgId := &quot;Location : 
%1&quot; _
-                                               , Comment := &quot;Error 
message box\n&quot; _
-                                                                       &amp; 
&quot;%1: a line number&quot; _
+                                               , Comment :=    &quot;Error 
message box\n&quot; _
+                                                                       &amp;   
&quot;%1: a line number&quot; _
                                        )
                        .AddText(       Context := &quot;LONGERRORDESC&quot; _
                                                , MsgId := &quot;Error %1 - 
Location = %2 - Description = %3&quot; _
-                                               , Comment := &quot;Logfile 
record&quot; _
+                                               , Comment :=    &quot;Logfile 
record&quot; _
                                        )
                        .AddText(       Context := &quot;STOPEXECUTION&quot; _
                                                , MsgId := &quot;THE EXECUTION 
IS CANCELLED.&quot; _
-                                               , Comment :=    
&quot;SF_Utils._Validate error message&quot; _
+                                               , Comment :=    &quot;Any 
blocking error message&quot; _
+                                       )
+                       .AddText(       Context := &quot;NEEDMOREHELP&quot; _
+                                               , MsgId := &quot;Do you want to 
receive more information about the &apos;%1&apos; method ?&quot; _
+                                               , Comment :=    &quot;Any 
blocking error message\n&quot; _
+                                                                       &amp;   
&quot;%1: a method name&quot; _
                                        )
        &apos;  SF_Exception.RaiseAbort
                        .AddText(       Context := &quot;INTERNALERROR&quot; _
diff --git a/wizards/source/scriptforge/po/ScriptForge.pot 
b/wizards/source/scriptforge/po/ScriptForge.pot
index cd5abaf03367..9976fb866a25 100644
--- a/wizards/source/scriptforge/po/ScriptForge.pot
+++ b/wizards/source/scriptforge/po/ScriptForge.pot
@@ -14,7 +14,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: 
https://bugs.libreoffice.org/enter_bug.cgi?product=LibreOffice&bug_status=UNCONFIRMED&component=UI\n";
-"POT-Creation-Date: 2021-07-30 13:10:57\n"
+"POT-Creation-Date: 2022-01-31 16:58:10\n"
 "PO-Revision-Date: YYYY-MM-DD HH:MM:SS\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
@@ -51,11 +51,18 @@ msgctxt "LONGERRORDESC"
 msgid  "Error %1 - Location = %2 - Description = %3"
 msgstr ""
 
-#. SF_Utils._Validate error message
+#. Any blocking error message
 msgctxt "STOPEXECUTION"
 msgid  "THE EXECUTION IS CANCELLED."
 msgstr ""
 
+#. Any blocking error message
+#. %1: a method name
+#, kde-format
+msgctxt "NEEDMOREHELP"
+msgid  "Do you want to receive more information about the '%1' method ?"
+msgstr ""
+
 #. SF_Exception.RaiseAbort error message
 msgctxt "INTERNALERROR"
 msgid  ""
diff --git a/wizards/source/scriptforge/po/en.po 
b/wizards/source/scriptforge/po/en.po
index cd5abaf03367..9976fb866a25 100644
--- a/wizards/source/scriptforge/po/en.po
+++ b/wizards/source/scriptforge/po/en.po
@@ -14,7 +14,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: 
https://bugs.libreoffice.org/enter_bug.cgi?product=LibreOffice&bug_status=UNCONFIRMED&component=UI\n";
-"POT-Creation-Date: 2021-07-30 13:10:57\n"
+"POT-Creation-Date: 2022-01-31 16:58:10\n"
 "PO-Revision-Date: YYYY-MM-DD HH:MM:SS\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
@@ -51,11 +51,18 @@ msgctxt "LONGERRORDESC"
 msgid  "Error %1 - Location = %2 - Description = %3"
 msgstr ""
 
-#. SF_Utils._Validate error message
+#. Any blocking error message
 msgctxt "STOPEXECUTION"
 msgid  "THE EXECUTION IS CANCELLED."
 msgstr ""
 
+#. Any blocking error message
+#. %1: a method name
+#, kde-format
+msgctxt "NEEDMOREHELP"
+msgid  "Do you want to receive more information about the '%1' method ?"
+msgstr ""
+
 #. SF_Exception.RaiseAbort error message
 msgctxt "INTERNALERROR"
 msgid  ""

Reply via email to