Hi, I'm currently creating an extension for OpenOffice with Java in Netbeans 8.0.2, and what I need to do is to add some macros to every function of my extension that consists into a Menu with Submenus, like this:
Menu
-Option 1
-Option 2
-Option 3
-Option 4
-Option 5
-Submenu
-Option 1
-Option 2
-Option 3
I've already created the extension and the menus and submenus in the Addons.xcu file, but I don't have idea how to add the files of my macros.
Hope someone can help me with this.
Thanks in advance.
Create extension(add-on) in Java
-
- Posts: 7
- Joined: Mon Aug 03, 2015 7:37 pm
Create extension(add-on) in Java
OpenOffice 4.0.1 on Windows 8.1
Re: Create extension(add-on) in Java
Look at
viewtopic.php?f=44&t=54483
http://jacenty.iis.p.lodz.pl/utility_so ... lab_10.pdf
and
https://netbeans.org/projects/platform/ ... message/43
viewtopic.php?f=44&t=54483
http://jacenty.iis.p.lodz.pl/utility_so ... lab_10.pdf
and
https://netbeans.org/projects/platform/ ... message/43
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
-
- Posts: 7
- Joined: Mon Aug 03, 2015 7:37 pm
Re: Create extension(add-on) in Java
Hi RoryOF, I think I need to explain more of what I'm doing.
My macros are developed in Java with JBoss Studio, they are JARs along with a parcel-descriptor.xml that contains the methods of the macro, for me, it is easy to add them in OO in Tools->Customize->Menus->'MyMenu', which are located into the OO macros directory (C:/Program Files (x86)/OpenOffice4/share/Scripts/Java).
But it is very annoying do all this in every document, so I just thought of do it with an extension, but the problem is how to tell the extension to load the correct files for each option?
I'm assuming it is a lot different than doing it with the OO interface, for example:
I have a macro that has 3 different methods, and in OO I can add each one apart because the parcel descriptor is in that directory.
But in code I don't know how to do that either.
Hope this helps to understand more what I am trying to achieve.
Thanks
OpenOffice 4.0.1 on Windows 8.1
-
- Posts: 35
- Joined: Sun Aug 17, 2014 2:04 pm
- Location: Italy
Re: Create extension(add-on) in Java
When you create your menus and submenus, you then have in your main class file a method called "dispatch", and for each menu item you have created you have an "add your own code here" area.
Here is an example of what it can look like:
If you bundle your own classes into the extension, then you just have to invoke your methods from the "//your own code here" area for each menu item.
Here is an example of what it can look like:
Code: Select all
public void dispatch( com.sun.star.util.URL aURL,
com.sun.star.beans.PropertyValue[] aArguments )
{
if ( aURL.Protocol.compareTo("com.yourdomain.yourextension:") == 0 )
{
if ( aURL.Path.compareTo("MenuItem1") == 0 )
{
// add your own code here
return;
}
if ( aURL.Path.compareTo("MenuItem2") == 0 )
{
// add your own code here
return;
}
}
}
OpenOffice 4.1.6, NetBeans 8.1, Windows 10 x64 Home