Bug 148645 - com.sun.star.sheet.addin.Analysis.getDec2Hex does not take integer 'places' value
Summary: com.sun.star.sheet.addin.Analysis.getDec2Hex does not take integer 'places' v...
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Hao Liu
URL: https://ask.libreoffice.org/t/need-fo...
Whiteboard:
Keywords: difficultyMedium, easyHack, skillCpp
Depends on:
Blocks:
 
Reported: 2022-04-18 09:15 UTC by Mike Kaganski
Modified: 2023-08-27 02:23 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 2022-04-18 09:15:12 UTC
Consider this code:

sub TestDec2Hex
   oService = createUNOService("com.sun.star.sheet.addin.Analysis")

   MsgBox oService.getDec2Hex(Nothing, 1234, Empty)
   MsgBox oService.getDec2Hex(Nothing, 1234, "")
   MsgBox oService.getDec2Hex(Nothing, 1234, "8")
   MsgBox oService.getDec2Hex(Nothing, 1234, 8.1)
   MsgBox oService.getDec2Hex(Nothing, 1234, 8.0)
   MsgBox oService.getDec2Hex(Nothing, 1234, 8)
end sub

All the calls to getDec2Hex will succeed, *except for the last two*, where '8.0' and '8' are passed as the last 'places' argument. So, the most natural way of using the function is unavailable.

Code pointer:
The function is implemented in scaddins/source/analysis/analysis.cxx. It uses ScaAnyConverter::getInt32 to handle the uno::Any value of the places argument. The task is to change the code that extracts the value, to allow not only empty values, strings and doubles, but also other numerical types, as the argument value.

The easy hack should include a unit test.
Comment 1 Buovjaga 2022-05-04 06:12:09 UTC
Changing to medium difficulty as unit test is included