Bug 145752 - CompatibilityMode Basic function documentation is incomplete
Summary: CompatibilityMode Basic function documentation is incomplete
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.4.0
Keywords:
Depends on:
Blocks: Macro-VBA Macro-StarBasic
  Show dependency treegraph
 
Reported: 2021-11-18 10:48 UTC by Mike Kaganski
Modified: 2022-03-25 08:13 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2021-11-18 10:48:54 UTC
CompatibilityMode documentation [1] lacks the information about its return value, and about its boolean argument being optional.

It only sets new compatibility mode when the optional argument is present; it always returns the mode that is active after its execution (i.e., if called with argument, it returns the new mode; if called without argument, it returns active mode without modifying it). The source code is at [2].

Also, there are examples making use of this function: e.g., [3]. They do not reset the compatibility mode back after changing it for a task; that is bad practice, and *may* create a false impression in readers that the mode that is set by the function is local to current method scope - while the new mode will be active to all the code run after leaving current method, potentially creating unwanted changes in logic. Those samples should be corrected to properly record the original state, and restore it after completing the necessary operations.

[1] https://help.libreoffice.org/7.2/en-US/text/sbasic/shared/compatibilitymode.html
[2] https://opengrok.libreoffice.org/xref/core/basic/source/runtime/methods1.cxx?r=81a7d46d&mo=77319&fi=2960#2960
[3] https://help.libreoffice.org/7.2/en-US/text/sbasic/shared/01020300.html
Comment 1 Mike Kaganski 2021-11-18 10:55:10 UTC
Additionally, the help page mentions both 'Option Compatible' and 'Option VBASupport', but it is not apparent from the discussion which of the two is actually relevant here. Setting compile-time 'Option Compatible' does *not* automatically make 'CompatibilityMode()' called without arguments to return true; while 'Option VBASupport 1' does. IMO the mention of the 'Option Compatible' should be removed from this page completely, except for a proposed "note that this function is not related to Option Compatible, and relates to Option VBASupport" notice.

It is not clear how can this *run-time* function affect "Creating enumerations with Enum statement" compile-time thing (also mentioned on this help page) - maybe it should be removed from here, and moved to 'Option Compatible' page.
Comment 2 Alain Romedenne 2021-12-14 16:09:11 UTC
Hi Mike

For those no reading C++ like, can you descibe a bit more compMode() arguments?
I may then be able to rework the affected help pages
Comment 3 Alain Romedenne 2021-12-14 16:13:32 UTC
I borrowed from:

[Compatibility of Star/OpenOffice Basic to VBA]
(https://jezzper.com/jezzper/discussions.nsf/0/3C030B7CC3F24D5FC1256F65002BC1B5)

..to write 'Option Compatible' and 'CompatibilityMode()' help content.

It surely needs refreshment
Comment 4 Mike Kaganski 2021-12-14 16:15:02 UTC
(In reply to Alain Romedenne from comment #2)
> For those no reading C++ like, can you descibe a bit more compMode()
> arguments?

Sorry, what is "compMode"?
Comment 5 Commit Notification 2022-03-24 16:17:17 UTC
Alain Romedenne committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/8e0ace084d46ae8758b8f6ba36be31059f201537

tdf#145752 Correction to CompatibilityMode() help page