Bug 162431 - Executing method insertControlCharacter in Basic without parameter nControlCharacter does not throw error
Summary: Executing method insertControlCharacter in Basic without parameter nControlCh...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
24.2.5.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:25.2.0 target:24.8.2
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-11 19:10 UTC by Ray Culp
Modified: 2024-10-30 09:44 UTC (History)
2 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 Ray Culp 2024-08-11 19:10:37 UTC
Description:

Executing the method insertControlCharacter in debug mode ("step into") in the Basic IDE without the parameter nControlCharacter does not raise an error, but it also does not appear to do anything.

Additional information:

Discussion on forum: https://ask.libreoffice.org/t/insertcontrolcharacter-ncontrolcharacter-parameter-optional/109240
Short video clip showing the behavior: https://nextcloud.culp.de/index.php/s/ACWaSm2N7NTgHAy
Comment 1 elmau 2024-08-11 20:09:35 UTC
I confirm it in:

Version: 24.2.5.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 16; OS: Linux 6.10; UI render: default; VCL: gtk3
Locale: es-MX (en_US.UTF-8); UI: en-US
24.2.5-1
Calc: threaded
Comment 2 Mike Kaganski 2024-08-12 14:02:06 UTC
Thanks for filing!

Now let me add what is more important that discussion on forum and short video clip, and what needed to be from start: namely, steps to reproduce.

1. Create a new text document.
2. Execute this Basic code:

sub TestMissingParam
  txt = ThisComponent.Text
  txt.insertControlCharacter(txt.End, , false)
end sub

Expected: either an error telling that the second argument is missing, or an effect associated with a (some) default argument value.

Actual result: the code succeeds silently, doing nothing.
Comment 3 Mike Kaganski 2024-08-12 14:32:37 UTC
The "is missing" error gets silently converted to the expected "short" integer type value 448, which is not any known control character identifier.

I believe, that the change is needed in sbxToUnoValue [1]; it needs to check for "is missing" variable (similar to [2]), and set an error, when the target type can't handle a missing value (like integers, or strings - possibly anything except plain Any, the latter can simply be returned empty), even prior to the external call.

Andreas: are you interested to take this? :-)

[1] https://opengrok.libreoffice.org/xref/core/basic/source/classes/sbunoobj.cxx?r=8f008bf4#1167
[2] https://opengrok.libreoffice.org/xref/core/basic/source/runtime/methods.cxx?r=45290d41#3165
Comment 4 Commit Notification 2024-09-20 14:57:02 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4506cd04c78baf628c8c6fd7e9c5f27a407d8f87

tdf#162431 - Check for missing parameters

It will be available in 25.2.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 5 Commit Notification 2024-09-23 09:50:36 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

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

tdf#162431 - Check for missing parameters

It will be available in 24.8.2.

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.