Developer's Guide Examples         SDK home
 

The Developer's Guide comes with a wide range of examples from all application areas which shows the use of the API in the context of the different functional areas. Furthermore the examples can be used as a first starting point to modify an existing example to thier own needs.
In order to connect most of the following client programs to the running office server, before running those programs, you should invoke the office with the following command:

soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"

You could also customize the mentioned host and port to your needs.

 
First Steps Text Documents OpenOffice.org 1.0.2 Basic and Dialogs
Professional UNO Spreadsheet Documents Database Access
Writing UNO components Office Bean Forms
Advanced UNO (no examples available) Drawing and Presentation Documents Universal Content Broker (UCB)
Office Development Charts Configuration Management
 

FirstSteps examples          SDK home  examples overview

Example Description
FirstConnection Shows how to set up a connection to a OpenOffice.org 1.0.2 in a different process space or even on a remote machine.
FirstLoadComponent Demonstrates how to load a component into OpenOffice.org 1.0.2 by a Java application.
HelloTextTableShape Performs some generic text and shape operations on a text document, a spreadsheet document and a drawing document.
 

Professional UNO examples          SDK home  examples overview

Example Description
MyUnoObject Shows that it depends on the implementation of the Java VM whether finalize() will be called or not.
object_lifetime.cxx Shows the UNO reference counting mechanism in C++.
ConnectionAwareClient Implements a client which is aware of losing connection to OpenOffice.org 1.0.2.
UrlResolver Builds a connection to OpenOffice.org 1.0.2 using the URL given on the command line. This example shows the usage of XUnoUrlResolver.
office_connect.cxx Builds a connection to OpenOffice.org 1.0.2 using C++.
string_samples.cxx Demonstrates usage of RTL string classes OString, OUString and OUStringBuffer.
 

Writing UNO components examples          SDK home  examples overview

Example Description
RunComponent Demonstrates how to extend the service provider with a new factory and instanciates the example components.
TestComponentA Shows a simple demo component which implements XTypeProvider, XServiceInfo and an own interface XSomethingA.
TestComponentB Shows a simple demo component which implements XTypeProvider, XServiceInfo and an own interface XSomethingB.
TestServiceProvider Implements a factory (service provider) which can create the two test components.
service1_impl.cxx Implements a simple UNO service with an own interface in C++.
service2_impl.cxx Implements another simple UNO service in C++.
ImageShrink Contains a framework for a component which scales images in a directory and stores them to another directory. This code does not really do anything, it just conatins the framework.
Thumbs This example registers a factory for the image shrink component and instantiates it.
 

Office Development examples          SDK home  examples overview

Example Description
AsciiReplaceFilter Implements the an example for an import/export filter service.
Factory Implements a factory class which can be registered for the UNO service manager. It is used to create new instances of the filter service.
FilterOptions Offers some helper methods to analyze and prepare the arguments of the filter method.
CustomizeView Offers a view which allows hiding and showing of the menubar, toolbar and objectbar of the related document component.
Desk This is the main part of a demo application based on the framework APIs. It mainly shows the mechanisms to load, store and convert documents, as well as dispatch and dispatch interception. It integrates windows from OpenOffice.org 1.0.2 via system window handle. This is the same mechanism as used by the OfficeBean, but the OfficeBean itself is not used here, just the JNI window handle access.
DocumentView Deals with the application window and it's actions.
FunctionHelper This helper comprises all OpenOffice.org 1.0.2 API calls. Thus it is possible to learn about these aspects separately from the rest of the application example.
IOnewayLink This is an interface to receive asynchronous events from UNO oneway calls.
IShutdownListener This is a listener interface to clean up on shutdown of OpenOffice.org 1.0.2.
Interceptor This implments a dispatch interceptor for a specific URL.
JavaWindowPeerFake Fakes an XWindowPeer for the Java native window handle to create a child window for the office frame.
NativeView Implements native JNI methods to get the window handle of the Java window.
OfficeConnect Builds the remote bridge to OpenOffice.org 1.0.2 and exports its UNO serice manager for the Java side of the application.
OnewayExecutor Implements IOnewayLink to decouple asynchronous oneway calls in the Java process.
StatusListener Implements a listener for a StatusEvent.
StatusView Shows the current status for which the application is registered as an event listener.
ViewContainer Performs a clean up on the Java side on OpenOffice.org 1.0.2 shutdown.
OfficeConnect Builds the remote bridge to OpenOffice.org 1.0.2 and exports its UNO service manager to the Java side.
ContextMenuInterceptor This example shows a context menu interceptor that creates a new menu entry that has a sub menu. This sub menu is in inserted into the context menu on the topmost position. It provides some helper functions to the user that are reachable through the menu Help.
MenuElement A helper class for the context menu interceptor example. It determines the menu element type.
Number_Formats Demonstrates the use of number formats in a spreadsheet document.
TerminateListener An example implementation of XTerminateListener. It is called when OpenOffice.org 1.0.2 terminates.
Clipboard Demonstrates the usage of the clipboard service by registering a clipboard listener, getting a list of formats from the current clipboard content and copying some data to the clipboard.
ClipboardListener Implements a clipboard listener for the Clipboard example. In such a class, actions can be implemented which happen whenever the clipboard content changes.
ClipboardOwner Implements a clipboard owner for the Clipboard example. This class is notified when it loses ownership of the clipboard.
TextTransferable Implements a data object for the Clipboard example. Such classes supply clients with data in a variety of formats.
LinguisticExamples A short example that uses most of the functionality from the OpenOffice.org 1.0.2 linguistic API.
OneInstanceFactory This class is used to provide a service factory for the linguistic services. It enforces that the actual implementations are only instantiated once.
PropChgHelper The base class for several property change helpers which are used to keep track of the changes of the service relevant linguistic properties. It is also used by the thesaurus directly.
PropChgHelper_Hyph The property change helper that is tracking the hypenation relevant properties.
PropChgHelper_Spell The property change helper that is tracking the spell checking relevant properties.
SampleHyphenator A simple implementation for a Hyphenator service.
SampleSpellChecker A simple implementation for a SpellChecker service.
SampleThesaurus A simple implementation for a Thesaurus service.
XHyphenatedWord_impl An object implementing the XHyphenatedWord interface. An instance of this type may be returned by the hyphenator.
XMeaning_impl An object implementing the XMeaning interface. An instance of this type may be returned by the thesaurus.
XPossibleHyphens_impl An object implementing the XPossibleHyphens interface. An instance of this type may be returned by the hyphenator.
XSpellAlternatives_impl An object implementing the XSpellAlternatives interface. An instance of this type may be returned by the spell checker.
 

Text Documents examples          SDK home  examples overview

Example Description
TextDocuments

Demonstrates a wide variety of API functions in text documents and text document views.

  • use of templates
  • using the view cursor, including visible text selections
  • changing the paragraph style
  • using various editing facilities like text insertion
  • using various cursor interfaces
  • creating text contents, like tables, sections and frames, well es text fields and columns
  • using stylesheets
  • applying numbering styles
  • using references, indexes, footnotes and autotext
  • loading, storing and printing a text document

Adjust the string at the beginning of the class definition to match your local printer!

 

Spreadsheet Documents examples          SDK home  examples overview

Example Description
ExampleAddIn Implements a simple addin component for spreadsheet documents. This component needs to be deployed before it can be used.
ExampleDataPilotSource Shows useage of a wide variety of spreadsheet interfaces like XCellRangeData, XCellSeries, XArrayFormulaRange and XMultipleOperations as well as named ranges, label ranges and data pilot.
GeneralTableSample Executes some examples working on generic tables.
SpreadsheetDocHelper Definies a helper class for the other examples to access spreadsheet documents, sheets and cells.
SpreadsheetSample Executes some examples working on a spreadsheet document.
ViewSample Shows how to manipulate view settings like splitting sheeting sheets and selecting cells.
 

Office Bean examples          SDK home  examples overview

Example Description
OfficeCommand A helper class to send UI events (see XDispatch) to OpenOffice.org 1.0.2.
BasicOfficeBean Shows a JavaBean which can contain arbitrary OpenOffice.org 1.0.2 documents.
BeanInfoAdapter Implements a helper class to make it easier to create BeanInfo classes.
SimpleBean Extends the BasicOfficeBean by a method to show and hide the menu bar.
SimpleBeanBeanInfo Implements BeanInfo for the SimpleBean example.
SimpleViewer A Java wrapper application which makes it possible to view OpenOffice.org 1.0.2 documents in OpenOffice.org 1.0.2 beans.
DocViewer Demonstrates a JavaBean with which arbitrary OpenOffice.org 1.0.2 documents can be viewed.
Office A generic base class for the OfficeWrite JavaBean example. This class could be used as a base class for other specialized JavaBeans too.
OfficeBeanInfo Example implementation of a BeanInfo object for an office JavaBean.
OfficeWriter Demonstrates how an specialized JavaBean can look like. This example is for the text document component.
OfficeWriterBeanInfo Implementation of the BeanInfo for the OficeWriter JavaBean example.
 

Drawing and Presentation Documents examples          SDK home  examples overview

Example Description
ChangeOrderDemo Shows how to change the painting order of shapes.
ControlAndSelectDemo Demonstrates the creation of a control shape and selects it in the current view.
CustomShowDemo Creates two custom shows and selects one of these.
DrawViewDemo Prints the view data properties and the controller properties of a drawing view and shows an example of setting such a property.
DrawingDemo Creates several shapes on several slides. Nice pattern included!
FillAndLineStyleDemo Demonstrates usage of area fill an line style properties.
GluePointDemo Creates two shapes with glue points and connects them with two connectors.
GraphicExportDemo Loads a drawing document and exports it to a GIF file. Run this program with source URL, target URL and page index on the command line, where the URLs are fully quallified URLs.
Helper Contains a helper classe for the other examples to connect to OpenOffice.org 1.0.2 and open or create a drawing document.
LayerDemo Creates shapes in different layers to show how to protect shapes from modifications.
ObjectTransformationDemo Shows geometric transformations on a shape using a homogenous matrix.
Organigram Demonstrates the creation of an organigram consisting of shapes and connectors.
PageHelper Contains a helper class for accessing several kinds of draw pages in a presentation or drawing document.
PresentationDemo Creates a presentation and runs it with some user interaction.
ShapeHelper Contains a helper class for accessing and creatung shapes for the other examples.
StyleDemo Creates a shape and applies a predefined shape stylesheet.
TextDemo Demonstrates usage of text and text styles in shapes.
 

Charts examples          SDK home  examples overview

Example Description
CalcHelper Contains some helper methdos for charts in spreadsheet documents, like accessing sheets by name, inserting a chart into a sheet, filling cell ranges with random numbers etc.
ChartHelper Constains some helper methods for charts, like creating a chart as an embedded object.
ChartInCalc Demonstrates how to create an embedded chart object with a random scatter chart within a spreadsheet.
ChartInDraw Inserts a 3D-bar chart into a drawing document.
Helper Shows how to connect to OpenOffice.org 1.0.2 and create text, drawing or spreadsheet document. This class is used as a helper class for the other examples.
JavaSampleChartAddIn Gives an example of how to implement chart addins to create new or specialized diagram types. The resulting component has to be deployed before it can be used.
ListenAtCalcRangeInDraw This helper class is used to build connection between an embedded chart object in a drawing document and a data range in a spreadsheet document.
 

OpenOffice.org 1.0.2 Basic and Dialogs examples          SDK home  examples overview

Example Description
FirstStepBasic.sxw This StarBASIC example shows how to create an own dialog which inserts a graphics object into a text document.
SampleDialog.java This example builds a Java component which creates a simple dialog.
CreatingDialogs.sxw This document contains a simple Basic macro which loads the SampleDialog component. The macro will be executed by pressing a Push button.
 

Database Access examples          SDK home  examples overview

Example Description
CodeSamples Creates the connection to OpenOffice.org 1.0.2 and executes the code SalesMan samples for database API. This example uses a database "MYDB0", make sure that you have created a data source which operates on a database "MYDB0".
OpenQuery Demonstrates XResultSetUpdate and XRowUpdate . This example uses a database "MYDB0", make sure that you have created a data source which operates on a database "MYDB0".
RowSet Demonstrates the usage of a row set. This example uses a database "MYDB0", make sure that you have created a data source which operates on a database "MYDB0".
RowSetEventListener Demonstrates how to define listener for the row set example.
Sales Creates a simple database table.
SalesMan Creates a simple database table.
sdbcx Demonstrates the usage of the SDBCX layer services.
 

Forms examples          SDK home  examples overview

For running the Forms example you should start your office with the following command:

soffice "-accept=socket,host=localhost,port=8100;urp,ForceSynchronous=1,Negotiate=0;StarOffice.ServiceManager"

Example Description
ButtonOperator The form created by the sample program contains various buttons which are tied to certain functionality. The class ButtonOperator, well, operates these buttons.
ComponentTreeTraversal Helper classes for travelling through a tree of FormComponent's.
ControlLock Helper class for implementing the locking of control depending on the state of the underlying RowSet.
DocumentHelper Helper class for encapsulating working with a (logical) form document.
DocumentType A simple enumeration class for classifying a document.
DocumentViewHelper Helper class for encapsulating working with a view for a form document.
FLTools Various small tools for the form layer sample program.
FormLayer Main class for central form operation. This example uses a data source "OO_SDK_Demo_DB ", make sure that you have created a data source with this name "OO_SDK_Demo_DB".
GridFieldValidator GridFieldValidator is responsible for validating the input in a specific grid control column.
InteractionRequest A simple implementation of a XInteractionRequest. Not tied to the form layer example, but a general helper.
KeyGenerator Helper class which is able to generate (uniuqe) keys for a (RowSet) column. An instance of this class can be tied to a specific row set column. It then monitors the state of the underlying row set, and upon inserting a new record into it (two operation modi are possible here), it automatically inserts a newly created (two modi, too) key into the column.
SalesFilter Helper class operating the on-the-fly filter control in the sample document. The document contains several controls which can be used to interactively change the filter of the form. The class SalesFilter operates these controls.
UNO A small UNO-syntax related helper class.
 

Universal Content Broker (UCB) examples          SDK home  examples overview

Example Description
ChildrenRetriever Shows child entries of a given folder. Try -help or -? on the command line to view optional parameters.
DataStreamComposer Demonstrates usage of the data stream by copying the data from one UCB node to another.
DataStreamRetriever Shows how to obtain the data stream from a document resource.
Helper Some helper methods to acess the UCB which are used by the other examples.
MyActiveDataSink A helper class for the DataStreamRetriever example which implements a data sink.
PropertiesComposer Shows how to set property values of an UCB resource.
PropertiesRetriever Shows how to access property values of an UCB resource.
ResourceCreator Creates a new file in an existing file system folder.
ResourceManager Demonstrates how to copy and move UCB resources.
ResourceRemover Demonstrates how to remove UCB resources.
 

Configuration Management examples          SDK home  examples overview

Example Description
ConfigExamples This example connects to a OpenOffice.org 1.0.2, gets the configuration manager and accesses the configuration in various ways.
 

Copyright 2003 Sun Microsystems, Inc.