When I try to pass a Long
via script.invoke
it is passed as 0 if the receiving argument is declared as Long
but the value fits in an Integer. If the same value is passed to Any
or Integer
, the correct value is received. Values that need a Long
are also correctly received.
Whenever Script_invoke_Bug_invokee_3
in the code below is called (because the value fits in an Integer
), it reports y_A
as 0! In all other cases the correct value is reported.
I am running this version:
Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 8; OS: Linux 5.3; UI render: default; VCL: kf5 (cairo+xcb)
Locale: en-GB (en_GB.UTF-8); UI: en-GB
Calc: threaded
Const Int_Max = 2 ^ 15 - 1 ' Seems to be right
Const Int_Min = - 2 ^ 15 ' Seems to be right
Sub Script_invoke_Bug
Dim z_Integer as Integer : z_Integer = 1024
Script_invoke_Bug_invoker (z_Integer)
Dim z_Long_1024 as Integer : z_Long_1024 = 1024
Script_invoke_Bug_invoker (z_Long_1024)
Dim z_Long as Long : z_Long = 1048576
Script_invoke_Bug_invoker (z_Long)
Script_invoke_Bug_invoker (1048575)
Script_invoke_Bug_invoker (Int_Max)
Script_invoke_Bug_invoker (Int_Max + 1)
Script_invoke_Bug_invoker (Int_Min)
Script_invoke_Bug_invoker (Int_Min - 1)
End Sub
Sub Script_invoke_Bug_invoker (y as Any)
Dim z_Count as Integer : z_Count = IIf (y < Int_Min or Int_Max < y, 2, 3)
Dim z_Invokee as String : z_Invokee = "Script_invoke_Bug_invokee_" + z_Count
Dim z_URI as String : z_URI = "vnd.sun.star.script:Standard.Pjt_Scratch." + z_Invokee + "?language=Basic&location=application"
Dim z_Script as Object : z_Script = ThisComponent.scriptProvider.getScript (z_URI)
Dim z_Parameters (0 to 2) as Any
z_Parameters (0) = y
z_Parameters (1) = y
z_Parameters (2) = y
Dim z_Out_Parameter_Indices () as Integer
Dim z_Out_Parameters () as Any
z_Script.invoke (z_Parameters, z_Out_Parameter_Indices, z_Out_Parameters)
End Sub
Sub Script_invoke_Bug_invokee_3 (y_A as Long, y_B as Integer, y_C as Any)
MsgBox ("A = " + y_A + ", B = " + y_B + ", C = " + y_C)
End Sub
Sub Script_invoke_Bug_invokee_2 (y_A as Long, y_C as Any)
MsgBox ("A = " + y_A + ", C = " + y_C)
End Sub