Java: a must for macros?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
vasa1
Volunteer
Posts: 261
Joined: Sat Dec 26, 2009 1:20 pm
Location: Bombay

Java: a must for macros?

Post by vasa1 »

I'm learning and using Calc of Open Office 3.1.

If I do ctrl+A, then ctrl+X, and then ctrl+home, I clear the current sheet of all data and formatting (I think) and make A1 the active cell.

I can do this with Java disabled.

If I convert these same steps to a "macro", I get a message that Java must be enabled to run the macro. So my question is, "Is it really necessary to have Java on for running a macro?"

I do not recall having to turn on Java for such a simple macro in version 2.4. (Could be wrong, though!)

I don't have a problem turning Java on, I was just hoping to be "safer" with Java off.
LibreOffice 5.2.1.2 on Lubuntu 16.04 (Openbox)
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Java: a must for macros?

Post by Villeroy »

No, Java is not required to write or record macros.
No, Java is not a higher security risk than any other application on a messy system.
I can't use no spreadsheets anymore when I disabled Java with a certain add-in is installed (Java functions from measurements.oxt).
After removing my spreadsheet related Java extensions I can open spreadsheets, write scripts in any language, record stupid Basic dispatches, create and use databases (except for HSQLDB and those useless, misleading database "wizards").
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: Java: a must for macros?

Post by B Marcelly »

Hi,
As far as I remember, when you open the menu Tools > Macros > Run macros you must have Java enabled even to run a Basic macro. Why ? Because in OOo 2.0 Sun designers rewrote this dialog in Java instead of C++ ...

There are other dialogs like this one in OpenOffice.org User Interface. So yes, you need JRE enabled to use OpenOffice.org :x

Without JRE you can however run your Basic macro from Tools > Macros > Organize macros > OpenOffice.org Basic...
You can add a button to this sub-menu item on a toolbar.
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
vasa1
Volunteer
Posts: 261
Joined: Sat Dec 26, 2009 1:20 pm
Location: Bombay

Re: Java: a must for macros?

Post by vasa1 »

Thanks to Villeroy and Marcelly.

Marcelly, I'll try this:
....
Without JRE you can however run your Basic macro from Tools > Macros > Organize macros > OpenOffice.org Basic...
You can add a button to this sub-menu item on a toolbar.
LibreOffice 5.2.1.2 on Lubuntu 16.04 (Openbox)
rudolfo
Volunteer
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Java: a must for macros?

Post by rudolfo »

B Marcelly wrote:Hi,
As far as I remember, when you open the menu Tools > Macros > Run macros you must have Java enabled even to run a Basic macro. Why ? Because in OOo 2.0 Sun designers rewrote this dialog in Java instead of C++ ...
Hi Bernard,
that's good to know, because I thought there might be something wrong on my system. Although I had the IDE open and was editing the macros and had used "Organize Macros" before, it took 3 or 4 seconds until the "Run Macro" Dialog appeared if I used "Run Macro" from the menu. Now it makes sense to me. This is about the time that is typically required on my computer to load the Java runtime. (If I'd really measure this time, it will be surely shorter, maybe 2 seconds ... but it feels like 3 or 4 seconds)
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Java: a must for macros?

Post by Villeroy »

The lag is not Java related. This is because the dialog scans all available libraries in all availlable langauges, loading all the libraries (the libraries become yellow).
The Java runtime should be loaded together with the office, as far as I undertand the matter.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
rudolfo
Volunteer
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Java: a must for macros?

Post by rudolfo »

At least on my MS Windows system the Java runtime is only loaded on demand. I use the process explorer from Sysinternals to check the open file handles. As long as I haven't used "Run Macro" the rt.jar file and 20 other jar files are not opened by OpenOffice. But if Jave is loaded it is loaded completely once for all: I see the jdbc driver jars loaded right after i have executed "run macro" and they are surely rather pointless for the macro dialog.

That doesn't necessarily mean that the parsing of all the macro files in the User directories and in the program directories isn't the most time consuming part. Due to the fact that the other Organise dialogs open more or less instantaniously my bet would still be the Java runtime.
But there may be a difference in how the "Organize ..." dialogs process the files compared to the "run macro" dialog: Though I would say that the organize dialogs have to open all files as well in order to see how many Sub declarations are in the file.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Java: a must for macros?

Post by Villeroy »

Load OOo from scratch. Open the Basic organizer and "open" all the libraries, so they are loaded into memory showing a yellow color in the organizer. Do the same with the JS and Python modules.
Now the run dialog loads instantly because it does not have to load all the code for scanning.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Java: a must for macros?

Post by hanya »

The instance of component implements css.script.provider.MasterScriptProviderFactory create an instance of a script provider that dedicated to a specific language and it is reused.
The script provider is instantiated at first time to open the organizer or run dialog, you can call macro directory from menu also. And the provider returns top node of the macro directory described by css.script.browse.BrowseNode. When the user try to open the tree node shown on the organizer dialog, methods of XBrowseNode is called and children are returned by the provider. These nodes are also held by the implementation of the master script provider factory, the script provider does not keep these instances.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Post Reply