Getting Started Guide

Figure 313: PrintHello is assigned to the Open Document event
Extensions
An extension is a package that can be installed into OpenOffice.org to add new
functionality. Extensions can be written in almost any programming language and
may be simple or sophisticated. Extensions can be grouped into types:
Calc Add-Ins, which provide new functionality for Calc, including new
functions that act like normal built-in functions
New components and functionality, which normally include some level of UI
integration such as new menus or toolbars
Data pilots that are used directly in Calc
Chart Add-Ins with new chart types
Linguistic components such as spell checkers
Document templates and images
Although individual extensions can be found in different places, there is an extension
repository at: http://extensions.services.openoffice.org/.
For more about obtaining and installing extensions, see Chapter 14 (Customizing
OpenOffice.org).
Writing macros without the recorder
The examples covered in this chapter are created using the macro recorder and the
dispatcher. You can also write macros that directly access the objects that comprise
OpenOffice.org. In other words, you can directly manipulate a document.
Directly manipulating OOo’s internal objects is an advanced topic that is beyond the
scope of this chapter. A simple example, however, demonstrates how this works.
Listing 7: Append the text “Hello” to the current document.
Sub AppendHello
Dim oDoc
Dim sTextService$
Dim oCurs
REM ThisComponent refers to the currently active document.
oDoc = ThisComponent
REM Verify that this is a text document
sTextService = "com.sun.star.text.TextDocument"
If NOT oDoc.supportsService(sTextService) Then
342 Getting Started with OpenOffice.org 3.3