Convert decimal to ieee745

@karolus thanks, updated to use that syntax.

@Zizi64: the older method is described in https://www.openoffice.org/udk/common/man/tools.html#idlc.
But I used the newer unoidl-write: from the SDK command prompt, I run

unoidl-write "C:\Program Files\LibreOffice\program\types.rdb" D:\pyFloatToHex\XPyFloatToHex.idl D:\pyFloatToHex\XPyFloatToHex.rdb
4 Likes

And for completeness, the third practical option listed in @erAck 's answer. We place in the document (for example, using APSO) the utils.py module containing the functions from @karolus 's answer.
To the Standard library, the Basic module:

Option Explicit

Global oScriptDTH As Object

' Returns a string of 16 hexadecimal digits corresponding to
' the internal representation of double.
Function DoubleToHex(ByVal d As Double) As String
  If oScriptDTH Is Nothing Then
    oScriptDTH = ThisComponent.getScriptProvider.getScript("vnd.sun.star.script:utils.py$doub_hex?language=Python&location=document")
  End If  
  DoubleToHex=oScriptDTH.invoke(Array(d), array(), array())
End Function
1 Like

sorry…one more suggestion:

…
    @staticmethod # with staticmethod …
    def FloatToIEEE754Hex( f ): # … no  ***self***argument
1 Like

Thank you!
The unoidl-write works for me in the 7.4.6 version of the LO.

Note that unoidl-write format is only supported since LO 4.1; I assume that AOO would not support it. The extensions created using the new tool would need a LibreOffice-minimal-version with value of no less than 4.1.

Note also that the older idlc tool is discontinued in LO SDK since 7.5.

Are you sure with »since LO 4.1« ?
with me:

Version: 7.0.4.2
Build ID: 00(Build:2)
CPU threads: 4; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: de-DE (de_DE.UTF-8); UI: de-DE
Raspbian package version: 1:7.0.4-4+rpi1+deb11u3
Calc: threaded

WITH installed sdk, I cannot find any hint to »unoidl-write« ?

Yes I’m sure that that format is supported since then (which was what I wrote); yet, the tool itself wasn’t included in the SDK until commit 40f2aee6584eafcf4cd1d95fcf1f775e5435440d in 2022.

1 Like

ok thanks for the clarification!

This looks interesting, how is it used? I have upgraded to latest version of Libreoffice.

Just download this and store it without ».ods«
doubleclick the File … install it … restart LO and use the functions

One small issue related to the Add-in function in LO 7.x.y versions?

In a localized LO installation appears the CompatibilityName instead of the displayed names (if if they are localized or not) in the formula wizzard (in the list of the functions) - when I set the “language” of the Formulas back to “English”.

When that option is not set, then the names are right, even if the Addin has NOT contain localised versions of the Displayed names for the functions.)

It worked fine in the LO 6.x.y versions: always appeared the Displayed names.

Checked in LO 7.4.5, LO 7.5.1. (Same issue with the test of Add-in named DoobieDoo):
.
With NOT English function names:


.
With English function names:

it works the same way (fallback to en - Displayname) in:
sorry was wrong, same issue… fallback to CompatibilityName IF Option [x]english Functionnames is set.

Version: 7.0.4.2
Build ID: 00(Build:2)
CPU threads: 4; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: de-DE (de_DE.UTF-8); UI: de-DE
Raspbian package version: 1:7.0.4-4+rpi1+deb11u3
Calc: threaded

Note that this goes farther and farther into the off-topic area :wink: Please file a bug report. This is definitely related to @erAck’s work on tdf#135993.

Reported: 154582 – Add-in function names appears as "Compatibility names" in "English function names" state of the Calc setting.