While StarOffice software offers a full-featured office suite, you can make it even better by extending it with the StarOffice Software Development Kit (SDK). You can create customized extensions for your own organization or full-featured plug-ins that other organizations may want to license.
This article provides answers to the following questions: Here are just a few examples of things you can do with the StarOffice SDK:
In a nutshell, the StarOffice SDK is a developer package that allows software developers to write applications that interact with local or remote StarOffice processes.
Component Technology
The StarOffice SDK is based on a component technology called Universal Network Objects (UNO). UNO provides a framework for cross-platform and language-independent programming. With the StarOffice SDK, you can develop applications in several programming languages, including Java, C++, StarOffice Basic and any .Net language, for use on the Solaris Operating System and Linux and Windows platforms. UNO is the model, or environment, that allows network objects to communicate across programming languages and platform boundaries.
One of the differences between UNO components and the objects you are familiar with in programming languages such as Java and C++ is that UNO components must consist of interfaces and properties. Rather than use the top-down inheritance approach of objects written in C++ and the Java programming language, UNO components rely heavily on interfaces as defined by the UNO Interface Definition Language (IDL). From a coding standpoint, this requires a different way of accessing components, which is illustrated in the sample application provided later in this article. All communication between applications and a StarOffice process is done through UNO components. For example, if you write an independent application that creates or accesses a StarOffice document, before communication can begin, the application must create a UNO component. Your application must also obtain access to a UNO component from a local or remote StarOffice process. The UNO component you create will be able to communicate with the UNO component you get from the StarOffice process. If you use the StarOffice SDK to write a StarOffice plug-in, you write a UNO component that a StarOffice process can instantiate. To use this plug-in, the StarOffice process must instantiate your UNO component.
Communication Between Components
Communication between UNO components is defined by the UNO IDL. If you are familiar with CORBA, it should help to know that the UNO IDL is similar to the CORBA IDL; the UNO IDL is an abstract meta language that defines the interface that all components must support. To run in the UNO environment, a component must support the UNO interface.
TCP/IP is used as the medium for communication between UNO components. When communicating with a StarOffice process, an independent application is considered the client, and the StarOffice process is considered the server. StarOffice components can be implemented in any language supported by UNO, as long as they communicate with other components through their IDL interfaces. UNO provides a protocol called the UNO Remote Protocol (URP) that provides a bridge between UNO environments. This bridge allows processes and objects to send method calls and to receive return values. UNO objects in different environments are connected by way of this interprocess bridge. The underlying connection is made through a socket or pipe. Remote UNO objects are connected by means of TCP/IP using the high-level protocol of the URP.
Service Managers
UNO uses a factory concept to instantiate components in a target environment. This factory is called the service manager. The service manager maintains a database of registered components. Your application can instantiate and communicate with any component known by the service manager, no matter what language it was implemented in. Communication takes place through interface calls specified by the UNO IDL.
StarOffice Application Programming Interface
The StarOffice application programming interface (API) provides access to the functionality of the StarOffice software, allowing developers to extend the StarOffice software by adding their own new features and solutions. UNO components, and any other objects that need to specify functionality in the StarOffice software, access a StarOffice process using the StarOffice API.
The StarOffice SDK comes with a complete guide, the StarOffice SDK Developer's Guide, which describes in detail both UNO and the StarOffice API. When you download and unpack the StarOffice SDK, you can link to the Developer's Guide by pointing your browser to the index.html file at the root of the StarOffice SDK installation. For more information about the UNO environment and the StarOffice API, please see the complete documentation set that comes with the StarOffice SDK.You can download the StarOffice SDK for the Solaris OS, Linux, and Microsoft Windows from Sun.com: StarOffice 8 Software Development Kit (SDK) Download Instructions. This section shows you how to run a simple Java application that opens a new StarOffice Writer document and adds some text to that document.
Before running the sample application, be sure that you have the required software on your system. All of the required software can be downloaded for free from the Sun web site -- either as licensed full versions or as evaluation copies. You will also need to set up your StarOffice installation as described in this section.
Downloading and Installing the Required Software
To run the sample program, you need to have the following software available on your system:
If you do not already have the J2SE SDK installed on your computer, you can download it for free from Sun.com: Java 2 Platform Standard Edition 5.0. Please note that the Java runtime environment software is not sufficient for developing with the StarOffice SDK. You must have the J2SE SDK installed to compile and run the sample application supplied with this article. The last software item you need to run the sample application is the StarOffice SDK. You can download the free StarOffice SDK from Sun.com: StarOffice 8 Software Development Kit (SDK) Download Instructions. When developing with the StarOffice SDK, you will find it convenient to use an integrated developer environment (IDE) such as Sun Java Studio software, but with the simple sample application provided here, command-line deployment is sufficient. If you decide to develop your own StarOffice programs, you will probably want to use an IDE. Sun is currently offering Sun Developer Network (SDN) members free copies of the Java Studio Enterprise software ($1,895 value). The Developer's Guide provides instructions on how to set up the NetBeans IDE to work with the StarOffice SDK. Sun Java Studio software is based on NetBeans architecture; you can use the same instructions for setting up the Sun Java Studio developer tools to work with the StarOffice SDK as are listed in the Developer's Guide for setting up NetBeans software.
Running the Sample Application
To compile and run the sample application from a command line, you will need to add the StarOffice SDK JAR files to your classpath. Several JAR files are located in the directory StarOfficeInstallation /program/classes. You will only need a few of these JAR files for any application, but it is easier to include all of them, just in case you need them. Add the directories classes/com and classes/win to the class path for the StarOffice bootstrap mechanism.
For your convenience, you can use one of the following command lines to temporarily set up the classpath on your system:
Now you can compile and run the sample application as usual:
At this point, if everything is set up correctly, you should see StarOffice open up a Writer document, complete with a short text passage. It will take a few moments for StarOffice to open.
This section provides a high-level look at the code of the sample application. Because the details can be overwhelming, it is best to start with a functional view. You can find a more complete explanation in the Developer's Guide; this code is a simplification of a sample from the guide.
The first thing the application must do is to import several components from the StarOffice SDK. Note that it is a good idea to include only the specific components you need rather than the full namespace, such as com.sun.star.uno.*. This limits the memory requirements for your application.
Next, initialize components that will be used to connect to the StarOffice process, and define the text that will be added to the Writer document.
In the main method, call methods to connect to StarOffice and to open and add text to a new Writer document.
The method
getDesktop uses the StarOffice Bootstrap mechanism to start StarOffice if it is not running and establish a connection. It returns an interface from the type com.sun.star.frame.XDesktop, which provides the interfaces to create a new document.Note the call to the UnoRuntime.queryInterface method. This method is called several times in any StarOffice program. Because UNO objects must be accessed through their interfaces and properties, the compiler must be given the correct type of object reference before you can call a method from it. The method UnoRuntime.queryInterface returns an object of type java.lang.Object that specifies the desired object reference. This object must then be casted to the appropriate StarOffice object type.
Take a look at the method to get a feel for what is going on, noting the use of the method
UnoRuntime.queryInterface. Before you attempt your own application, you will probably want to spend some time reading more about the details of what each API call does. You can find these details in the Developer's Guide.The method useWriter calls the method newDocComponent to open a new StarOffice Writer document, then adds text to that document. Note, once again, the use of the method UnoRuntime.queryInterface.
The method
newDocComponent creates a new Writer document. Notice that newDocComponent uses the method loadComponentFromURL to create a new document owing to the private:factory/swriter URL. The same method would load an existing document with a URL file:///documents/mydocument.odt like this. Once again, note the use of the method UnoRuntime.queryInterface.
Now that you have seen a very simple example of what you can do with the StarOffice SDK, you should be better prepared to tackle the complete documentation set that comes with the SDK. From here, a good next step is to read the chapter "First Steps" of the StarOffice SDK Developer's Guide. When you unpack the StarOffice SDK download, you can easily get to all of the StarOffice documentation by starting from the
index.html file in the installation directory.
| |||||||||||||||||||
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
|
| ||||||||||||