Bug 150281 - VBA Application.CentimetersToPoints must give Double in Calc
Summary: VBA Application.CentimetersToPoints must give Double in Calc
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
(earliest affected)
Hardware: All All
: medium normal
Assignee: Not Assigned
Keywords: difficultyBeginner, easyHack, skillCpp
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
Reported: 2022-08-06 06:59 UTC by Mike Kaganski
Modified: 2022-08-12 19:26 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:
Regression By:


Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2022-08-06 06:59:32 UTC
In both Word and Excel, there are Application.CentimetersToPoints. However, they return different types: Word's return Single [1], while Excel's returns Double [2]. Note that the argument types they take are also different.

Create a text document in Writer; add a macro *to it* (Application object seems to only be available from document modules):

Option VBASupport 1

Sub Main
  msgbox TypeName(Application.CentimetersToPoints(1))
End Sub

The result is the expected "Single".

Now repeat the process with a Calc document. The same macro must give "Double", but gives the same "Single".

The common method is declared in ooo::vba::XApplicationBase [3], and defined in VbaApplicationBase [4].

Interesting thing is, that for Word VBA Application, this function is *also* declared in XApplication [5], and overloaded in SwVbaApplication [6], together with other conversion function absent from Excel's Application object.

I suspect that initially, it was assumed that same-name methods in both VBA Application objects were the same, hence it was declared in the common ancestor class. However, the methods are different, so it makes sense to remove it from the ancestor, and declare/define in Excel VBA Application compatibility class (ScVbaApplication).

[1] https://docs.microsoft.com/en-us/office/vba/api/Word.Application.CentimetersToPoints
[2] https://docs.microsoft.com/en-us/office/vba/api/Excel.Application.CentimetersToPoints
[3] https://opengrok.libreoffice.org/xref/core/oovbaapi/ooo/vba/XApplicationBase.idl?r=5687eba4#40
[4] https://opengrok.libreoffice.org/xref/core/vbahelper/source/vbahelper/vbaapplicationbase.cxx?r=da9b11a5#410
[5] https://opengrok.libreoffice.org/xref/core/oovbaapi/ooo/vba/word/XApplication.idl?r=c9b57b72#55
[6] https://opengrok.libreoffice.org/xref/core/sw/source/ui/vba/vbaapplication.cxx?r=c9b57b72#416
Comment 1 Roman Kuznetsov 2022-08-12 19:26:01 UTC
Confirm the problem in

Version: / LibreOffice Community
Build ID: d75c5c1f61a174b3b333e9db6536ab15cc37d00b
CPU threads: 4; OS: Mac OS X 12.5; UI render: Skia/Metal; VCL: osx
Locale: ru-RU (ru_RU.UTF-8); UI: en-US
Calc: threaded Jumbo