Accessing the UNO API
- Accessing the UNO API
- Special Behavior of OpenOffice Basic
In OpenOffice.org Basic, the interaction between Basic and UNO is described on an elementary level. This section describes the interface between Basic and the UNO API at the level of the OpenOffice.org application.
This is realized by two predefined Basic properties:
-
StarDesktop
-
ThisComponent
The property StarDesktop
gives access to the global OpenOffice.org application API while the property ThisComponent
accesses the document related API.
StarDesktop
The property StarDesktop
is a shortcut for the service com.sun.star.frame.Desktop.
Example:
MsgBox StarDesktop.Dbg_SupportedInterfaces ' is the same as Dim oDesktop oDesktop = CreateUnoService( "com.sun.star.frame.Desktop" ) MsgBox oDesktop.Dbg_SupportedInterfaces
The displayed message box differs slightly because Dbg_SupportedInterfaces
displays "StarDesktop" as an object type of the desktop object in the first case and "com.sun.star.frame.Desktop" in the second. But the two objects are the same.
ThisComponent
The property ThisComponent
is used from document Basic, where it represents the document the Basic belongs to. The type of object accessed by ThisComponent
depends on the document type. The following example shows the differences.
Basic module in a OpenOffice.org document:
Sub Main MsgBox ThisComponent.Dbg_SupportedInterfaces End Sub
The execution of this Basic routine shows different results for a Text, Spreadsheet and Presentation document. Depending on the document type, a different set of interfaces are supported by the object. A portion of the interfaces are common to all these document types representing the general functionality that documents of any type offer. In particular, all OpenOffice.org documents support the com.sun.star.document.OfficeDocument service, including the interfaces com.sun.star.frame.XStorable and com.sun.star.view.XPrintable. Another interface is com.sun.star.frame.XModel.
The following list shows the interfaces supported by all document types:
- com.sun.star.beans.XPropertySet
- com.sun.star.container.XChild
- com.sun.star.document.XDocumentInfoSupplier
- com.sun.star.document.XEventBroadcaster
- com.sun.star.document.XViewDataSupplier
- com.sun.star.document.XEventsSupplier
- com.sun.star.document.XLinkTargetSupplier
- com.sun.star.frame.XModel
- com.sun.star.frame.XStorable
- com.sun.star.lang.XServiceInfo
- com.sun.star.lang.XMultiServiceFactory
- com.sun.star.lang.XEventListener
- com.sun.star.style.XStyleFamiliesSupplier
- com.sun.star.util.XModifiable
- com.sun.star.view.XPrintable
For more information about the functionality of these interfaces, see Frame-Controller-Model Paradigm in OpenOffice.org. This section also goes into detail about the general document API.
In addition to the common services or interfaces, each document type supports specific services or interfaces. The following list outlines the supported services and important interfaces:
A Text document supports:
- The service com.sun.star.text.TextDocument supports the interface com.sun.star.text.XTextDocument.
- Several interfaces, especially from the com.sun.star.text package.
A Spreadsheet document supports:
- The service com.sun.star.sheet.SpreadsheetDocument,
- The service com.sun.star.sheet.SpreadsheetDocumentSettings.
- Several other interfaces, especially from the com.sun.star.sheet package.
Presentation and Drawing documents support:
- The service com.sun.star.drawing.DrawingDocument.
- Several other interfaces, especially from the com.sun.star.drawing package.
The usage of these services and interfaces is explained in the document type specific chapters Text Documents, Spreadsheet Documents and Drawing Documents and Presentation Documents.
As previously mentioned, ThisComponent
is used from document Basic, but it is also possible to use it from application Basic. In an application wide Basic module, ThisComponent
is identical to the current component that can also be accessed through StarDesktop.CurrentComponent
. The only difference between the two is that if the BasicIDE is active, StarDesktop.CurrentComponent
refers to the BasicIDE itself while ThisComponent
always refers to the component that was active before the BasicIDE became the top window.
Content on this page is licensed under the Public Documentation License (PDL). |