Bug 121262 - User defined function returns argument not result with VBA support enabled
Summary: User defined function returns argument not result with VBA support enabled
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.0.6.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
 
Reported: 2018-11-08 01:28 UTC by David M
Modified: 2019-11-22 08:53 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Bug demo: spreadsheet to call user defined function ADDUP, function in Module1 (9.68 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-11-08 01:28 UTC, David M
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David M 2018-11-08 01:28:55 UTC
Created attachment 146419 [details]
Bug demo: spreadsheet to call user defined function ADDUP, function in Module1

User defined functions return one of their calling arguments rather than their result when VBA support is enabled by declaring;

      Option VBASupport 1

at the start of the module.

I note a warning that imported VBA code may not reliably access LibreOffice objects at https://help.libreoffice.org/latest/he/text/sbasic/shared/03103350.html

However, this is native code and it does not access objects.

Here is the spreadsheet (also see attached file:

     VarA     4
     VarB     2
     ADDUP    =ADDUP(B3,B4)

The user defined ADDUP function was created and stored in the spreadsheet’s own module, as usual i.e. there should be no issue with the spreadsheet not being able to see the code.

The function adds 2 numbers.

     Function Addup(VarA as Single, VarB as Single) as Single
     	Addup = VarA + VarB
     End Function

The result without VBA support is as expected:

     VarA     4
     VarB     2
     ADDUP    6

VBA support is enabled by adding the following at the start of the module:

     Option VBASupport 1

The result with VBA support enabled is that a calling argument is returned, not the function result:

     VarA     4
     VarB     2
     ADDUP    4
Comment 1 Oliver Brinzing 2018-11-08 18:25:15 UTC
i cannot reproduce with:

Version: 6.2.0.0.alpha1+ (x64)
Build ID: 15aee54bb56982d57c27234a4ae946b45354c310
CPU threads: 4; OS: Windows 10.0; UI render: default; VCL: win; 
Locale: de-DE (de_DE); Calc: threaded

Version: 6.1.3.2 (x64)
Build ID: 86daf60bf00efa86ad547e59e09d6bb77c699acb
CPU threads: 4; OS: Windows 10.0; UI render: default; 
Locale: de-DE (de_DE); Calc: 

result is always 6.

Linux only?
Comment 2 Xisco Faulí 2018-12-10 17:02:04 UTC
I can't reproduce it in

Versió: 6.1.3.2
ID de la construcció: 1:6.1.3~rc2-0ubuntu0.16.04.1
Fils de CPU: 4; SO: Linux 4.15; Renderitzador de la IU: per defecte; VCL: gtk3; 
Configuració local: en-US (ca_ES.UTF-8); Calc: group threaded

Could you please try to reproduce it with the latest version of LibreOffice
from https://www.libreoffice.org/download/libreoffice-fresh/ ?
I have set the bug's status to 'NEEDINFO'. Please change it back to
'UNCONFIRMED' if the bug is still present in the latest version.
Comment 3 David M 2018-12-10 23:07:17 UTC
Thanks to Oliver & Xisco for responding.

Issue still present on latest stable version

Version: 6.1.3.2
Build ID: 1:6.1.3~rc2-0ubuntu0.18.04.2
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: en-AU (en_AU.UTF-8); Calc: group threaded

Note that the failure to reproduce on 6.1.3.2 by Xisco Faulí was on Ubuntu 16.0.4, not 18.0.4. Maybe there is something being called from the OS that's causing the problem? I am not a developer, so do not have skills to dig into this possibility.

Did not want to risk installing 6.2, a pre-release version. Also note that the test by  Oliver Brinzing was on a Windows OS not Ubuntu.
Comment 4 Buovjaga 2019-08-13 11:41:57 UTC
(In reply to David M from comment #3)
> Did not want to risk installing 6.2, a pre-release version. Also note that
> the test by  Oliver Brinzing was on a Windows OS not Ubuntu.

A convenient way to test without installing is to use an appimage: https://libreoffice.soluzioniopen.com/
Comment 5 David M 2019-08-18 02:29:53 UTC
Bug found to be fixed when testing a later version of LibreOffice.

Version: 6.2.5.2
Build ID: 1:6.2.5-0ubuntu0.18.04.1~lo1

Thanks to all for comments.