Extending OpenOffice.org: Creating template and AutoText extensions


Author: Dmitri Popov

One of the great features of the current version of OpenOffice.org is the support for extensions, which allow you to add to the office suite’s functionality. Every day this week we’ll look some of the most useful OOo extensions available. Today, we’ll look at ways you can improve the way the office suite handles templates and AutoText.

While you can manually add templates and AutoText entries to your copy of OpenOffice.org, packing them as extensions makes them portable. This means that you can easily install them on multiple machines and share them with other users.

Usually, extensions act as small programs, but you can also build so-called non-code extensions that contain document templates, AutoText snippets, and even gallery graphics. Non-code extensions can come in handy in many situations — for example, if you want to easily exchange your AutoText snippets with other users, or if you want to keep tabs on all your Writer templates. Instead of having templates scattered all around your hard disk, you can create a template extension and use it to access the templates directly from within OpenOffice.org. Creating a template extension doesn’t require any particular programming skills and can take only a few minutes.

Start by downloading an empty template extension from the OpenOffice.org wiki. Next, create a Writer document to be your template and format it the way you want. Save the document as a template with the .ott file extension. Now, open the downloaded TemplatePackage.oxt file as if it were a conventional zip file, and add your template to the template directory of the extension. You can add as many templates as you want, and you can even create subdirectories to group the templates.

Once you’re done adding your templates, you can install the resulting extension in OpenOffice.org. To do this, choose Tools -> Extension Manager, select My Extension, press Add and select the template extension (the .oxt file). You can then access your templates by choosing File -> New -> Templates and Documents. In the dialog box, select the Templates section, and you should see your templates in the My Templates folder (or the folders that you added to your extension).

In a similar manner, you can create an AutoText extension. For example, if you prefer to use the classic “Lorem ipsum” dummy text (useful when you need to quickly fill pages with some text) instead of the default one, you can create an AutoText entry and pack it as an extension.

First, create a new AutoText entry with the “Lorem ipsum” text. To do this, create a new Writer document and enter the dummy text (you can use the excellent Lorem ipsum generator for that purpose). Select the entire text by pressing Ctrl-A, choose Edit -> AutoText, and make sure that the My AutoText section is selected. Enter a name and a shortcut in the appropriate fields. Press the AutoText button, and select New. This saves the Lorem ipsum text as a new AutoText entry Next, locate the mytexts.bau file that contains user-defined AutoText entries (the file is stored in the OpenOffice.org2userautotext directory on Windows and in the home/user/.OpenOffice.org2/user/autotext directory on Linux). Make a copy of this file and rename it, for example, to loremipsum.bau.

Download an empty AutoTextPackage.oxt extension from the OpenOffice.org wiki, and copy the Loremipsum.bau file into the autotext directory inside the extension. You might want to rename the extension to something more descriptive, like LoremIpsumDummy.oxt. Install the created extension as described above, and you are done. Now if you choose Edit -> AutoText, you will see your Loremipsum entry in the My AutoText section.

In theory, you should be able to create a gallery extension featuring your own graphics too, and the OpenOffice.org wiki even provides an empty extension for that purpose. However, it seems that creating a gallery extension can be a bit tricky due to a specific bug, so it’s better to leave it alone for now.

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