![]() |
MoreBasicFunctions
0.0.1
Java - UNO component that provides more basic functions
|
MoreBasicFunctions - A LibreOffice Add-On written in Java that provides more basic functions.
Copyright (C) 2021 Julien Férard.
Questions: https://github.com/jferard/MoreBasicFunctions/discussions
Bug reports: https://github.com/jferard/MoreBasicFunctions/issues
Documentation: https://jferard.github.io/MoreBasicFunctions
On one hand, LibreOffice Basic is pretty limited, functions names are unusual (think of Mid!). On the other hand, Calc functions are powerful, but cumbersome to call because of a tedious syntax. Hence the idea of this add-on: MoreBasicFunctions exposes very common function as UNO services.
There is a major limitation: the services won't be available unless the add-on is installed. That means that your scripts won't be usable on a standard LibreOffice installation.
Use cases:
Tests service is mandatory on the developer PC but not on the end user PC.There are several services: Tests, Strings, Characters, Regexes, Collections, Dates, Paths.
Some Junit like functions: assertTrue, assertFalse, assertEquals, assertNotEquals, assertArrayEquals, assertArrayNotEquals.
For string manipulation: reversed, split, join, lower/upper case, indexOf, substring...
For character manipulation Ord/Chr and identification: isLetter, isDigit...
For regex usage: match, findAll/findFirst, replaceAll/replaceFirst.
For collections manipulation: sort, shuffle, min, max, avg, concat, flatten, times, chunks, randomElement, contains.
For date and time manipulation: now, strptime/strftime...
For path manipulation: list, recursiveList, split/join, parent, withExtension...
To replace a string by another in a string using a Calc function call:
functionAccess = createUnoService("com.sun.star.sheet.FunctionAccess")
MsgBox functionAccess.callFunction("SUBSTITUTE", Array("123123123", "3", "abc"))
Using MoreBasicFunctions:
Strings = createUnoService("com.github.jferard.mbfs.Strings")
MsgBox Strings.replace("123123123", "3", "abc")
1.8.17