[Solved] How to set a user defined built in function?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
sokolowitzky
Posts: 103
Joined: Mon Sep 15, 2014 7:34 pm

[Solved] How to set a user defined built in function?

Post by sokolowitzky »

I know that I can set a global function if I registry it in "My Macros"
But as I know, if the security level does not let, the function can not work.
So I want to set a user defined function into the built-in functions list.

I need a few different functions, but this one could serve as an example. It gives a file's title. Can I set it into the built in functions list?

Code: Select all

FUNCTION filetitle()
filetitle() = THISCOMPONENT.TITLE
End FUNCTION
Last edited by sokolowitzky on Sat Nov 03, 2018 5:49 pm, edited 1 time in total.
Win10-OpenOffice 4.1/LibreOffice 7.4
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: How to set a user defined built in function?

Post by RusselB »

While I'm a beginner with Macros, a common reference for BASIC macros (which is what yours looks like) is OpeOffice.org BASIC Guide
While the PDF shows that it's for OpenOffice 3.2, I'm unaware of anything that is specific for the later versions, and unaware of anything that works in 3.2 that doesn't work in the later versions.
I did a quick look to see if I could find something that matches or is similar to your function (that way it might already be built in), but found nothing that, imo, was close enough. But, by all means, look yourself... I may have missed it, or I may have been using the wrong search.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to set a user defined built in function?

Post by JeJe »

If you create and install an extension with your macros then they can run regardless of the security level.

Extension Compiler may be helpful:

https://wiki.openoffice.org/wiki/Extens ... n_Compiler
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: How to set a user defined built in function?

Post by Lupp »

The setting under Macro Security only applies to macros with location=document.

Macros located in MyMacros.Standard (not tested for different libraries) will even be executed when called if Macro_Security = Very_High.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
sokolowitzky
Posts: 103
Joined: Mon Sep 15, 2014 7:34 pm

Re: How to set a user defined built in function?

Post by sokolowitzky »

Thanks all. It looks like I should spend time for a while to build an extension. Even thought I could not find an exact answer I mark this topic as solved since the solution might be found with another way.
Win10-OpenOffice 4.1/LibreOffice 7.4
Post Reply