Bug 120094 - User function called from custom toolbar button wrongly gets passed a zero of type Integer as parameter
Summary: User function called from custom toolbar button wrongly gets passed a zero of...
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-23 18:20 UTC by Wolfgang Jäger
Modified: 2018-10-14 11:09 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
The attachment announced in Comment #2 (15.79 KB, application/vnd.oasis.opendocument.text)
2018-10-13 22:05 UTC, Wolfgang Jäger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Jäger 2018-09-23 18:20:09 UTC
I have a few macros with optional parameters and expecting to be called mainly on a user action: via a formcontrol event (indirect), a toolbar click (direct), or a keyboard shortcut (direct). A formcontrol button will pass an event which may be evaluated. A keyboard shortcut passes nothing - and this signals correctly that no further information is available and defaults are to use. 

Calling such a macro by a click on a custom button in a toolbar it gets passed a numeric 0 of type 'Integer'. 

This doesn't make sense. It aggravates the checks concerning the optional parameter without giving a useful information. Or is this behaviour intended to tell "Call came from a toolbar." as opposed to "Call was triggered by a shortcut key." 

If information should be provided at all, it should be passed as an event.
Comment 1 Buovjaga 2018-10-13 14:11:30 UTC
Please attach an example document with such a macro.
Set to NEEDINFO.
Change back to UNCONFIRMED after you have provided the document.
Comment 2 Wolfgang Jäger 2018-10-13 22:05:38 UTC
Created attachment 145689 [details]
The attachment announced in Comment #2

The issue was not with specific macros but with the passing of a (useless; no information) parameter when a macro was called from a click on a sensitive area in a ToolBar where it was inserted via Customize. 

When one of the macros was assigned to a shortcut key the issue did not show. 

Background: I once had a Basic Sub that I wanted to call sometimes clicking on a ControlButton, sometimes from a ToolBar icon. The body should distinguish the cases based on testing an optional pEvent parameter with the IsMissing() function. Depending on the result different ptreparing commands should be executed. This failed because the ToolBar case passed an unexpected parameter of type Integer and value 0. No usable information, workaround annoying.

I attach a simple example document containing detailed information how to reproduce the issue. Of course I do not expect anybody to assign document macros to his ToolBars in real life.
Comment 3 Maxim Monastirsky 2018-10-13 22:48:34 UTC
The passed integer is the modifier key that is pressed while clicking the toolbar button. i.e. try to hold CTRL or SHIFT while clicking the button, and you'll get values different than 0. That's a feature of the toolbar, and it works as designed. (As an example, we use that for the shapes buttons (e.g. rectangle). If you hold CTRL while clicking such button, it will just insert that shape w/o the need of drawing it.)
Comment 4 Wolfgang Jäger 2018-10-14 11:09:14 UTC
Good to know. Explanation much appreciated! 
I had speculated about a real purpose for the passed value, but missed this obvious alternative.