|
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 their own needs.
Some fo the examples need a running office
instance listening on a port. If this is necessary you will get further
information in the makefiles.
All examples marked with a are executable and be started
using a run target in the makefile. The name of the binary (C++) can
differ compared to the source file, please see the run target in the
appropriate makefile. Some of the examples which create a component
have no run target. In these cases a document is provided which
instantiates and runs the component (see the makefile output). Also the
Basic examples provide documents which use and shows the implemented
functionality. The database and forms examples need a running database,
please see the description below. But note that is not described in
detail how to create a working data source (see the office help).
|
|
|
|
|
|
|
|
|
Text Document Examples |
Description |
FirstUnoContact |
Shows how to initialize UNO and
get a remote office service manager from a running LibreOffice %PRODUCT_RELEASE% in a
different process space. |
FirstLoadComponent |
Demonstrates how to load a
component into LibreOffice %PRODUCT_RELEASE% by a Java application. |
HelloTextTableShape |
Performs some generic text and
shape operations on a text document, a spreadsheet document and a
drawing document. |
|
|
|
|
|
|
|
Interprocess Connection Example |
Description |
ConnectionAwareClient |
Implements a client which is aware
of losing connection to LibreOffice %PRODUCT_RELEASE%. |
UrlResolver |
Builds a connection to
LibreOffice %PRODUCT_RELEASE% using the URL given on the command line. This example
shows the usage of XUnoUrlResolver . |
|
|
SimpleBootstrap Java Example |
Description |
SimpleBootstrap_java.java |
Shows the transparent use of
office UNO components from Java. The remote office component context is
obtained by using the com.sun.star.comp.helper.Bootstrap.bootstrap()
method, which bootstraps the component context from a UNO installation. |
manifest.mf |
Contains the additional manifest
file entries. |
|
SimpleBootstrap C++ Example |
Description |
SimpleBootstrap_cpp.cxx |
Shows the transparent use of
office UNO components from C++. The remote office component context is
obtained by using the ::cppu::bootstrap() function, which
bootstraps the component context from a UNO installation. |
|
Deployment Features |
Description |
description.xml |
Demonstrates how license files can be embedded, so that they are shown to the user during installation. |
|
|
|
|
|
Jobs Addon Example |
Description |
AsyncJob |
An java example showing how a job
can analyze the given arguments and how the environment can be
detected, in which the job is executed. |
Jobs.xcu |
Contains the example job
configuration. |
Addons.xcu |
Contains the configuration entries
for the Jobs addon where different entries are configured. |
|
ProtocolHandler Addon Java |
Description |
ProtocolHandlerAddon |
Implements a ProtocolHandler addon
component in Java. |
ProtocolHandler.xcu |
Contains the ProtocolHandler
configuration. |
Addons.xcu |
Contains the configuration entries
for the ProtocolHandler addon where different entries are configured. |
|
ProtocolHandler Addon C++ |
Description |
addon.cxx |
Implements a ProtocolHandler addon
component in C++. |
addon.hxx |
Contains the class definition of
the c++ ProtocolHandler example. |
component.cxx |
Implements the administrative
component functions (component_writeInfo, component_getFactory, component_getImplementationEnvironment). |
ProtocolHandler.xcu |
Contains the ProtocolHandler
configuration. |
Addons.xcu |
Contains the configuration entries
for the ProtocolHandler addon where different entries are configured. |
|
|
C++ Component Example |
Description |
TestCppComponent.cxx |
Shows how to create new instances
of the demo services and calls some methods of the demo interface. |
service1_impl.cxx |
Implements a simple UNO service
with an own interface in C++. |
service2_impl.cxx |
Implements another simple UNO
service in C++. |
|
Thumbs Example |
Description |
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 contains the
framework. |
Thumbs |
This example registers a factory
for the image shrink component and instantiates it. |
|
Dialog Component Example |
Description |
DialogComponent.java |
Implements a component accessing a dialog created
with the LibreOffice %PRODUCT_RELEASE% Basic IDE. The component provides methods that
can be bound to dialog respectively control events . |
XTestDialogHandler.idl |
Interface implementing a createDialog method showing the
dialog and some methods to be used as event handler for the dialog.
|
TestDialogHandler.idl |
Service definition for the component implementing
its own interface XTestDialogHandler .
|
DialogComponent.odt |
Document containing Basic code to
instantiate the Dialog Components and a Dialog containing
controls with events bound to methods supported by the
Dialog Component. |
|
|
|
|
|
|
Ascii Filter Example |
Description |
AsciiReplaceFilter |
Implements an example for an
import/export filter service. |
FilterOptions |
Offers some helper methods to
analyze and prepare the arguments of the filter method. |
TypeDetection.xcu |
Contains the necessary
configuration items for the AsciiReplaceFilter. |
|
FlatXmlFilter C++ Example |
Description |
FlatXml.cxx |
Implements an import/export filter
storing the data in one xml stream instead of the normal three streams
in for example an .odt file. The example is implemented in C++. |
FlatXmlFilter_cpp.xcu |
Contains the necessary
configuration items for the C++ flat xml filter. |
|
FlatXmlFilter Java Example |
Description |
FlatXml |
Implements an import/export filter
storing the data in one xml stream instead of the normal three streams
in for example an .odt file. The example is implemented in Java. |
FlatXmlFilter_java.xcu |
Contains the necessary
configuration items for the Java flat xml filter. |
|
FlatXml FilterDetection Example |
Description |
filterdetect.cxx |
Implements an example filter
detection for the flat xml filter. The example is implemented in C++. |
filterdetect.hxx |
Contains the class definition of
the filter detection example. |
fdcomp.cxx |
Implements the administrative
component functions (component_writeInfo, component_getFactory, component_getImplementationEnvironment). |
FlatXmlTypeDetection.xcu |
Contains the necessary
configuration items for the C++ flat xml type detection. |
|
Desktop Environment Example |
Description |
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 LibreOffice %PRODUCT_RELEASE% via system
window handle. This is the same mechanism as used by the OOoBean, but
the OOoBean 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
LibreOffice %PRODUCT_RELEASE% 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 LibreOffice %PRODUCT_RELEASE%. |
Interceptor |
This implements 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
LibreOffice %PRODUCT_RELEASE% and exports its UNO service 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
FeatureStateEvent . |
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 LibreOffice %PRODUCT_RELEASE% shutdown. |
|
Office Development Examples |
Description |
OfficeConnect |
Builds the remote bridge to
LibreOffice %PRODUCT_RELEASE% 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. |
|
Termination Test Example |
Description |
TerminationTest |
This example uses the
TerminateListener and shows the use of them in a running program. |
TerminateListener |
An example implementation of
XTerminateListener . It is called
when LibreOffice %PRODUCT_RELEASE% terminates. |
|
Clipboard Example |
Description |
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. |
|
|
|
Path Substitution Example |
Description |
PathSubstitutionTest |
This code example creates the path
substitution service
com.sun.star.util.PathSubstitution
and retrieves the pre-defined Office path variables. It shows the
variable values on the screen. The reSubstiuteVariables function is
used to show how the service exchanges parts of a path with a path
variable supporting platform independent path usage. |
|
Disable Commands Example |
Description |
DisableCommandsTest |
Implements an example showing how
a developer can use the configuration API to disable/enable commands at
runtime. |
|
|
|
|
|
|
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 as text fields and columns
- using stylesheets
- applying numbering styles
- using references, indexes, footnotes and
autotext
- loading, storing and printing a text document
Adjust the strings at the beginning of the class
definition to match your installation!
|
|
|
|
|
|
|
|
|
|
|
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
and 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 qualified
URLs. |
Helper |
Contains a helper class for the
other examples to connect to LibreOffice %PRODUCT_RELEASE% 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 creating 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. |
|
|
|
|
|
|
Example |
Description |
CalcHelper |
Contains some helper methods for
charts in spreadsheet documents, like accessing sheets by name,
inserting a chart into a sheet, filling cell ranges with random numbers
etc. |
ChartHelper |
Contains 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. |
ChartInWriter |
Inserts an embedded chart object
with a random bar chart in a text document. This example does not
really work, because the API for embedding objects into text documents
is not implemented. To be more precise. |
Helper |
Shows how to connect to
LibreOffice %PRODUCT_RELEASE% 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 add-ins 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. |
SelectionChangeListener |
Shows how to register a handler
which is called when the selection within an embedded chart object
changes. |
|
|
|
|
|
|
Example |
Description |
FirstStepsBasic.odt |
This StarBasic example shows how to
create an own dialog which inserts a graphics object into a text
document. |
SampleDialog |
This example builds a Java
component which creates a simple dialog. |
CreatingDialogs.odt |
This document contains a simple
Basic macro which loads the SampleDialog component. The macro will be
executed by pressing a Push button. |
ToolkitControls |
In this directory you find a Basic
library which implements several examples using toolkit controls. You
can easy pack this Basic library as a UNO package and can install it
using the package manager (see the makefile output).
After the installation you will find a new library "ToolkitControls" in
the Basic IDE containing 4 modules and the necessary dialogs.
Select one of the following modules and press the
Run button:
- FileDialog = simple dialog which ask for a
filename (nothing else)
- MultiPage = a more complex dialog with several
tab pages
- ProgressBar = a dialog which shows a progress
bar
- ScrollBar = a dialog which shows a scroll bar
|
|
|
|
|
|
Database
Access examples |
|
The Database examples use a SQL
database named "MYDB0" with write access. Make sure that you have a
data source operating on such a database in your office before you run
the example. |
|
Database Examples |
Description |
CodeSamples |
Creates the connection to
LibreOffice %PRODUCT_RELEASE% and executes the code SalesMan samples for database API. |
OpenQuery |
Demonstrates the use of XResultSetUpdate
and
XRowUpdate . |
RowSet |
Demonstrates the usage of a row
set. |
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. |
|
Driver Skeleton Example |
Description |
OSubComponent.hxx |
Helper class to delegate special
dispose handling. |
OTypeInfo.hxx |
Contains the database types from
the DatabaseMetaData getTypes call. |
SConnection.hxx |
This file contains the declaration
of a class implementing the service com.sun.star.sdbc.Connection . |
SConnection.cxx |
This file contains the
implementation of the class declared in SConnection.hxx. |
SDatabaseMetaData.hxx |
This file contains the declaration
of a class implementing the interface com.sun.star.sdbc.XDatabaseMetaData . |
SDatabaseMetaData.cxx |
This file contains the
implementation of the class declared in SDatabaseMetaData.hxx. |
SDriver.hxx |
This file contains the declaration
of a class implementing the service com.sun.star.sdbc.Driver . |
SDriver.cxx |
This file contains the
implementation of the class declared in SDriver.hxx. |
SPreparedStatement.hxx |
This file contains the declaration
of a class implementing the service com.sun.star.sdbc.PreparedStatement .
|
SPreparedStatement.cxx |
This file contains the
implementation of the class declared in SPreparedStatement.hxx. |
SResultSet.hxx |
This file contains the declaration
of a class implementing the service com.sun.star.sdbc.ResultSet . |
SResultSet.cxx |
This file contains the
implementation of the class declared in SResultSet.hxx. |
SResultSetMetaData.hxx |
This file contains the declaration
of a class implementing the interface com.sun.star.sdbc.XResultSetMetaData . |
SResultSetMetaData.cxx |
This file contains the
implementation of the class declared in SResultSetMetaData.hxx. |
SServices.cxx |
This file contains a class
implementing the service needed to register the driver. |
SStatement.hxx |
This file contains the declaration
of a class implementing the service com.sun.star.sdbc.Statement . |
SStatement.cxx |
This file contains the
implementation of the class declared in SStatement.hxx. |
propertyids.hxx |
Defines some common used strings
and declare a helper class for properties. |
propertyids.cxx |
Implements the property helper
class. |
|
|
|
|
|
|
Example |
Description |
BooleanValidator |
The class BooleanOperator
implements an validator
for a form control, which can veto certain radio button or check box
states. |
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 traveling
through a tree of
FormComponent's . |
ControlLock |
Helper class for implementing the
locking of control depending on the state of the underlying RowSet . |
ControlValidation |
This is the main class for the
control validation example. It creates a sample document, fills it with
controls, and attaches several validators to those controls |
ControlValidator |
Base class implementing the common
denominator for components validating
form controls. |
DataAwareness |
This class implements the basic
example for a form working on a database. Two tables will be created
and a form (writer document) with a business example will fill its
fields from these tables. |
DateValidator |
The class DateValidator
implements an validator
for a form control, which can check the content of a form date field. |
DocumentBasedExample |
This class collects common
functionality of examples which require a document. |
DocumentHelper |
Helper class for encapsulating
working with a document. |
DocumentType |
A simple enumeration class for
classifying a document. |
DocumentViewHelper |
Helper class for encapsulating
working with a view for a document. |
FLTools |
Various small tools for the form
layer sample program. |
FormLayer |
Helper class for accessing and
manipulating the form layer of a document. |
GridFieldValidator |
GridFieldValidator is
responsible for validating the input in a specific grid control column.
This is not to be mixed up with the control-based validation as
described in the validation
module. Instead, a GridFieldValidator assembles and uses
various other concepts. |
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 (unique) 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. |
ListSelectionValidator |
The class ListSelectionValidator
implements an validator
for a form control, which can veto certain selections in a list box
control. |
NumericValidator |
The class NumericValidator
implements an validator
for a form control, which can veto certain values in every control
which allows exchanging numerical values. |
SingleControlValidation |
Though form documents feature
inbuilt mechanisms for visually indicating invalid control content (see
com.sun.star.form.validation
for discussions about validity), the ControlValidation
example extends this. The validity state of every control in this
example, as well as possible explanations for invalidity, are displayed
in dedicated texts. The SingleControlValidation class
ties together a validatable control and those status texts. |
SpreadsheetDocument |
A specialized DocumentHelper
which represents a spreadsheet document, and offers some form related
functionality. For instance, this class allows the creation of
CellValueBinding instances, which
can be used to couple the content of a form control with the content of
a spreadsheet cell. |
SpreadsheetValueBinding |
This example demonstrates how to
bind form controls to spreadsheet cells. |
SpreadsheetView |
A specialized DocumentViewHelper
which represents a view to a spreadsheet document. |
TableCellTextBinding |
This class allows binding the
control of a form control with a table cell in a text document. For
this, it uses the mechanisms of the
com.sun.star.form.binding module. |
TextValidator |
The class TextValidator
implements an validator
for a form control, which can monitor a form text field. |
TimeValidator |
The class TimeValidator
implements an validator
for a form control, which can monitor the content of a form time field.
|
UNO |
A small UNO-syntax related helper
class. |
ValueBinding |
An example how to bind the content
of a form control to a table cell in a text document. |
WaitForInput |
A pretty small helper for the
interactive examples, which notifies another instance when the user
pressed key on the console. |
|
|
|
|
|
|
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 access 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. |
|
|
|
|
|
|
Example |
Description |
ConfigExamples |
This example connects to a
LibreOffice %PRODUCT_RELEASE%, gets the configuration manager and accesses the
configuration in various ways. |
|
|
|
|
|
|
Example |
Description |
OOoBeanViewer |
Shows how to use the OOoBean
embedded in a Java AWT component. It shows how to load and store
documents as well as how to control toolbar visibility. |
|
|
|
|
|
|
Example |
Description |
SayHello |
A Scripting Framework Java macro
that opens a new Writer document and inserts the word Hello in it. |
ScriptSelector |
A Scripting Framework Java macro
that opens a Java Swing dialog with a tree view of the macro hierarchy
for the Office application. |
|
|
|
|
|
Example |
Description |
DialogDocument |
A sample showing how to display an office document in a dialog window. |
MessageBox |
A sample showing how to display a simple message box. |
UnoDialogSample |
A sample showing how to create various controls in a dialog (fixed text field, currency field, progress bar, fixed line, group box, edit field, time field, date field, pattern field, numeric field, progressbar, check box, radio button, list box, combo box, formatted field, file control, button control, roadmap control) |
UnoDialogSample2 |
A dialog sample showing how to use a roadmap control. |
UnoMenu |
A sample showing a top window with some menus. |
UnoMenu2 |
A dialog sample showing how to use or work with a context menu. |
ImageControlSample2 |
Dialog sample showing how to use an image control. |
|
|
|