Bug 146909 - Missing/confused constants for MsgBox arg & return value
Summary: Missing/confused constants for MsgBox arg & return value
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.3.0.0.alpha1+
Hardware: All All
: medium normal
Assignee: Julien Nabet
URL:
Whiteboard: target:7.4.0 target:7.3.1
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-22 00:38 UTC by Jim Avera
Modified: 2022-01-23 04:04 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Regression test for the constants (see STEPS TO REPRODUCE) (1.49 KB, text/plain)
2022-01-22 00:40 UTC, Jim Avera
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Avera 2022-01-22 00:38:33 UTC
In BASIC macros, the MsgBox function takes a parameter which specifies which buttons to display, and returns an integer indicating which button was pressed.

Constants for these values are documented at

   https://help.libreoffice.org/6.4/en-US/text/sbasic/shared/03010102.html

However the contstants 
   MB_ABORTRETRYCANCEL and
   IDIGNORE 
are not defined and referencing them returns an empty value, or if Option Explicit is used, a runtime error.


However the mix-up is more complicated:

MB_ABORTRETRYCANCEL (value 2) is documented to "display Abort, Retry, and *Ignore* buttons" (not "Abort"), and does so.  So the name of the constant is misleading. 

Sure enough, there does exist a symbol MB_ABORTRETRYIGNORE defined by the runtime system with value 2.  So that should be documented, not ...CANCEL.

If MB_ABORTRETRYIGNORE is used and the user clicks the "Ignore" button, then 5 is returned.  However there is no documented constant for 5 except for IDIGNORE, which is missing.

====
SUMMARY:
  1. MB_ABORTRETRYCANCEL in the documentation should be replaced with MB_ABORTRETRYIGNORE

  2. IDIGNORE, which appears to be correctly documented, needs to be defined so it can be used.

(Check: Is there a different symbol defined for return value 5?)
===

I will attach a regression script which tests all the documented constants.

STEPS TO REPRODUCE:
  1.  start calc or open any spreadsheet
  2.  Tools->Macros->Edit Macros
  3.  Navigate to 'Module1' (or any available module) and past in the attached test code.  Do NOT use "Option Explicit" (or else run-time errors will occur rather than error messages from the tester).
  4.  Put cursor in "TestMain" and Run->Run (or press F5)
Comment 1 Jim Avera 2022-01-22 00:40:27 UTC
Created attachment 177697 [details]
Regression test for the constants (see STEPS TO REPRODUCE)
Comment 2 Julien Nabet 2022-01-22 11:51:36 UTC
About MB_ABORTRETRYCANCEL, it's been fixed with ebc9cb8ae21c5930887cf27e1dbbe2c7493f3e30
Update git submodules
* Update helpcontent2 from branch 'master'
  to 84b6347bd05d0a7e5a7ea5075702f5f2892b5c1f
  - tdf#146299: MsgBox can have the parameter MB_ABORTRETRYIGNORE
    
    not MB_ABORTRETRYCANCEL

This link https://help.libreoffice.org/7.3/en-US/text/sbasic/shared/03010102.html shows it's ok.

Mike: ok to add IDIGNORE part?
In comparison, git grep -n IDABORT gives:
basic/source/inc/rtlproto.hxx:73:extern void SbRtl_IDABORT(StarBASIC * pBasic, SbxArray & rPar, bool bWrite);
basic/source/runtime/props.cxx:108:void SbRtl_IDABORT(StarBASIC*, SbxArray& rPar, bool) { rPar.Get(0)->PutInteger(3); }
basic/source/runtime/stdobj.cxx:452:{ u"IDABORT",                       SbxINTEGER,      CPROP_,           SbRtl_IDABORT              },
wizards/source/scriptforge/python/scriptforge.py:633:        IDABORT, IDCANCEL, IDIGNORE, IDNO, IDOK, IDRETRY, IDYES = 3, 2, 5, 7, 1, 4, 6

I can submit a patch with IDIGNORE by using these, what do you think?
Comment 3 Mike Kaganski 2022-01-22 12:57:25 UTC
(In reply to Julien Nabet from comment #2)

Please do - it would be great!
Comment 4 Julien Nabet 2022-01-22 13:32:03 UTC
(In reply to Mike Kaganski from comment #3)
> (In reply to Julien Nabet from comment #2)
> 
> Please do - it would be great!
Thank you for your quick feedback!
Done here:
https://gerrit.libreoffice.org/c/core/+/128780
Comment 5 Commit Notification 2022-01-22 14:56:53 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/c1205c1cf6e08d94e6e2e2753679d99bc1842ca0

Related tdf#146909: add missing IDIGNORE in Basic

It will be available in 7.4.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Julien Nabet 2022-01-22 14:58:00 UTC
Patch for 7.3 branch waiting for review there:
https://gerrit.libreoffice.org/c/core/+/128685
Comment 7 Commit Notification 2022-01-23 04:04:46 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/6e6fcc5ed141b25acee31686ee8792b0507e75c5

Related tdf#146909: add missing IDIGNORE in Basic

It will be available in 7.3.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.