This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Office Software

Create an OpenOffice.org extension the easy way with BasicAddonBuilder

By Dmitri Popov on November 12, 2007 (4:00:00 PM)

Share    Print    Comments   

So you've written a nifty OpenOffice.org macro and want to share it with the world. You can, of course, publish the code on your Web site, but a better way to go is to pack it as an easy-to-install OpenOffice.org extension.

An extension is just a plain zip archive containing, besides the macro itself, a few XML-based files that OpenOffice.org needs to properly install the package. Theoretically, it's possible to create the required XML files in a text editor, but it would be as effective as digging a garden using a teaspoon. Fortunately, there is a tool that you can use to create an extension in a point-and-click fashion.

The name of this wonder tool is BasicAddonBuilder (BAB). Once installed, it adds a new toolbar with a single button on it that launches the extension builder wizard. However, before you push the button, you should do some preparatory work. First of all, it's a good idea to move the macro (or macros) you want to add to the extension into a separate library; that way BAB won't interfere with other macros in your system. To move the macro into a separate library, choose Tools -> Macros -> Organize Macros -> OpenOffice.org Basic and press the Organizer button. You can then add a new library and move the macro into it.

If you want to add icons to the menu items, you should also have graphics files ready. To find quality icons for your extension, try the IconLet icon search engine. You will need at least one 16x16-pixel icon in PNG format for each macro that you want to include as a menu item. Since OpenOffice.org supports small (16x16) and large (26x26) toolbar icons, you might want to prepare large icons as well.

When you have all the bits ready, you can start building the extension. Press the BasicAddonBuilder button in the toolbar to open a wizard that guides you through the entire process of creating the extension. Start with choosing the library containing the macro you want to add to the extension. Next, you have to decide how to integrate the extension into OpenOffice.org. You have several options here. As a rule of thumb, a separate toolbar and a top-level menu are perfect for extensions containing multiple macros (and thus several menu items), while the Tools -> Add-on or Help menu works best for extensions with one or two macros.

As an example, let's create a top-level menu. Tick Add top level menu, and press the Forward button to move to the next window, where you build the menu structure of the extension. The first thing you have to do here is create a top-level menu. Press the Edit button next to the Menu title field. In the dialog window that appears, enter a menu title in the Item label field. You also have to specify so-called Office context, or OpenOffice.org applications where the top-level menu should be visible. For example, if you have an extension that works only with Writer documents, tick the Writer check box, and the top-level menu will appear only in the specified application.

The next step is to specify the menu items. To do this, press the Add menu button. This opens a dialog window similar to the previous one, but it has a few more options you need to specify. Besides the menu item label, you must link the item to a particular macro. Press on the button next to the Command field, select the appropriate library from the drop-down list, choose the desired module in the left pane, then pick the macro you want in the right pane.

In the Icons section, you can add icons to the menu item by clicking in the empty icon square and selecting the desired icon of the right size. Repeat this step for other icon sizes, if necessary. Specify the applications you want in the Office context section and press OK. In a similar manner, you can add other menu items. You can also add menu separators to logically group the menu items.

When you are satisfied with the result, press the Forward button, add an optional description to your extension, and press Finish to generate the oxt package. That's it -- your extension is ready to go.

You can install and distribute the created extension as it is, but there is one more thing you might want to add to it -- a description.xml file that contains additional info about your extension, including its current version, the required version of OpenOffice.org, and licensing information. To do this, create a text file and paste the following code into it:

<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="http://openoffice.org/extensions/description/2006"
xmlns:d="http://openoffice.org/extensions/description/2006"
xmlns:xlink="http://www.w3.org/1999/xlink">
<identifier value="Extension Name" />
<version value="0.0.1" />
<dependencies>
<OpenOffice.org-minimal-version value="2.1" d:name="OpenOffice.org 2.1"/>
</dependencies>
</description>

Replace the default values such as identifier, version, and OpenOffice.org-minimal-version with the correct values, save the file as description.xml, and add it to the .oxt package. If you'd like to add a mandatory license agreement that is displayed when the user installs the extension, add the following code to the description.xml file right before the closing </description> tag (this works only with OpenOffice.org 2.3 or higher):

<registration>
<simple-license accept-by="user" default-license-id="en-US" suppress-on-update="true" >
<license-text xlink:href="GPL.txt" lang="en-US" license-id="en-US" />
</simple-license>
</registration>

Make sure that the license-text xlink:href="GPL.txt" points to the correct file (in this case, GPL.txt), and add the specified license file to the .oxt package.

Dmitri Popov is a freelance writer whose articles have appeared in Russian, British, US, German, and Danish computer magazines.

Share    Print    Comments   

Comments

on Create an OpenOffice.org extension the easy way with BasicAddonBuilder

Note: Comments are owned by the poster. We are not responsible for their content.

Create an OpenOffice.org extension the easy way with BasicAddonBuilder

Posted by: toronto on November 21, 2007 10:22 PM
Great resource article. Thanks for the article. Dave in Toronto.

#

Create an OpenOffice.org extension the easy way with BasicAddonBuilder

Posted by: Anonymous [ip: 193.173.109.226] on December 06, 2007 03:40 PM
Does anyone has an example on how to create an automatic update (add update URL or something like that) so the extension can be updated from a specific website location? (B.t.w. thanks very much for the article. It's great!)
[Modified by: Anonymous on December 06, 2007 03:41 PM]

#

Re: Create an OpenOffice.org extension the easy way with BasicAddonBuilder

Posted by: Anonymous [ip: 213.230.130.54] on February 16, 2008 01:38 AM
Try out the latest version of the BAB.
Now it automatically creates the description.xml file and the auto-update information

ciao
Paolo Mantovani

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya