|
Contents |
||||||||||
Introduction |
||||||||||
Introduction |
||||||||||
OpenOffice.org Calc is a program for editing spreadsheet documents. For numerous situations this program provides a variety of helpful functions. Nevertheless, particularly in the area of the spread-sheet analysis problems can occur, in which a situation-suitable extension of the function range appears desirable. In the following one describes, where an example can be downloaded and how individual functions can be added and implemented to the Calc program. The possibility of an extension presented here was implemented in the programming language Java. If you like to have more information on creating components with Java you should take a look at the web page Java in UNO and OpenOffice. |
||||||||||
Download the example |
||||||||||
The example described below is available for downloading in a packed version. With the help of the script files for the operating systems Unix and Windows all necessary steps can be carried out. |
||||||||||
Adding functions |
||||||||||
All methods, which should extend the program Calc and should provide a certain functionality, are collected in an interface named XCalcAddins. In order to provide a language-independent
programming environment, all interfaces must be described in an interface
definition language (IDL). The interface XCalcAddins is described
in the UNO
interface definition language (UNOIDL):
You may declare several methods like getMyFirstValue or getMySecondValue.
Each method may have any number of arguments after xOptions. Furthermore,
you could replace the name of the service and the interface, but only
if you want to replace this name in all your project files. This example
will work with the default names. All interfaces specified in UNOIDL must
be derived from com.sun.star.uno.XInterface
. |
||||||||||
Implementing functions |
||||||||||
First the user should look at the file CalcAddins.java, in order to get a first overview of the program code in Java. The file is commentated in numerous places. All positions in the program, at which the user should become active, are already marked by the keyword "TO DO". The file consists of an inner and an outer
class.
The outer class CalcAddins provides
The inner class _CalcAddins provides the component as a concrete implementation of the service description. It implements the needed interfaces: All positions in the Java file marked with the key word "TO DO" should be edited by the user. For a better understanding they are explained in the following. You should replace these method names by the method names of your interface.
For each of your methods you should make up a new constant with a different value.
This is where you implement all methods of your interface. The parameters have to be the same as in your IDL file and their types have to be the correct IDL-to-Java mappings of their types in the IDL file.
You should list all argument names for each of your methods, here.
Assign the name of each of your methods.
Enter a description for each of your methods that office users will understand.
Enter a description for every argument of every method. Make them so that office users will understand.
|
||||||||||
Building the example |
||||||||||
After the above steps were executed, still the script compileCalcAddins<YourOperatingSystem> must be launched. Before you execute the script you should adapt the environment variables to your needs. For the execution of the script files the ODK is needed. Closer information you can find on the web page How to write a UNO component in Java. The script will produce a JAR file. In order to register this jar file you could use a StarBasic macro. You only have to create a new macro (menu Extras/Macro) and copy the following StarBasic script into this macro. Furthermore, you should replace the existing path of the JAR file with your JAR file. Finally you should excecute the new macro. After a restart of your Office your Calc should
provide all new functions (menu Insert/Functions). |
||||||||||
|
||||||||||
|
||||||||||
Author: Bertram
Nolte (Tue Jun 5 17:17:40 MEST 2001) |
||||||||||
|