Create extension(add-on) in Java

Java, C++, C#, Delphi, ??? - Using the UNO bridges

Create extension(add-on) in Java

Postby pelonchasva » Fri Sep 11, 2015 6:34 pm

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.
OpenOffice 4.0.1 on Windows 8.1
pelonchasva
 
Posts: 7
Joined: Mon Aug 03, 2015 7:37 pm

Re: Create extension(add-on) in Java

Postby RoryOF » Fri Sep 11, 2015 6:39 pm

Apache OpenOffice 4.1.6 on Xubuntu 18.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 28738
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Create extension(add-on) in Java

Postby pelonchasva » Fri Sep 11, 2015 7:24 pm



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
pelonchasva
 
Posts: 7
Joined: Mon Aug 03, 2015 7:37 pm

Re: Create extension(add-on) in Java

Postby johnrdorazio » Thu Sep 17, 2015 5:43 pm

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:

Code: Select all   Expand viewCollapse view
     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;
            }
        }
    }


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.
OpenOffice 4.1.1, NetBeans 8.0.2, Windows 10 x64 Home
johnrdorazio
 
Posts: 31
Joined: Sun Aug 17, 2014 2:04 pm
Location: Italy


Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests