more basic funcs v2 MoreBasicFunctions

Tags: Macro

A LibreOffice Add-On written in Java that provides more basic functions. The new functions are accessible as methods of a service.There are several available services: Tests, Strings, Characters, Regexes, Collections, Dates, Paths.

Description

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:

  • One PC script (typically personal script): install the add-on on the PC and use the services;
  • Prototype: the add-on will help you to write clean code;
  • Developer: the 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.

Tests: Some Junit like functions: assertTrue, assertFalse, assertEquals, assertNotEquals, assertArrayEquals, assertArrayNotEquals.

Strings: For string manipulation: reversed, split, join, lower/upper case, indexOf, substring...

Characters: For character manipulation Ord/Chr and identification: isLetter, isDigit...

Regexes: For regex usage: match, findAll/findFirst, replaceAll/replaceFirst.

Collections: For collections manipulation: sort, shuffle, min, max, avg, concat, flatten, times, chunks, randomElement, contains.

Dates: For date and time manipulation: now, strptime/strftime...

Paths: For path manipulation: list, recursiveList, split/join, parent, withExtension...

Example

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")

Homepage: file:///home/jferard/prog/java/MoreBasicFunctions

Repository: https://github.com/jferard/MoreBasicFunctions

Release List

Release: 0.2.0 with test suite – This version contains examples

Compatibility: 5.0
Operating Systems: Linux, Windows, macOS
License: GPL
ReleaseNotes:

First version.

Release: 0.2.0 without test suite – This version contains only the runtime

Compatibility: 5.0
Operating Systems: Linux, Windows, macOS
License: GPL
ReleaseNotes:

First version

Other Extensions

MoreBasicFunctions

A LibreOffice Add-On written in Java that provides more basic functions. The new functions are accessible as methods of a service.There are several available services: Tests, Strings, Characters, Regexes, Collections, Dates, Paths.

06-2021

Feedback

Post your review

You cannot post reviews until you have logged in. Login Here.

Reviews

No one has commented on this page yet.

RSS feed for reviews on this page | RSS feed for all reviews