OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Modules, Services and Interfaces<br />
Modules, Services and Interfaces<br />
<strong>OpenOffice</strong>.<strong>org</strong> provides hundreds of services. To provide an overview of these services, they have been<br />
combined into modules. The modules are of no other functional importance for <strong>OpenOffice</strong>.<strong>org</strong> Basic<br />
programmers. When specifying a service name, it is only the module name which is of any importance because<br />
this must be also listed in the name. The complete name of a service consists of the com.sun.star expression,<br />
which specifies that it is a <strong>OpenOffice</strong>.<strong>org</strong> service, followed by the module name, such as frame, and finally the<br />
actual service name, such as Desktop. The complete name in the named example would be:<br />
com.sun.star.frame.Desktop<br />
In addition to the module and service terms, UNO introduces the term 'interface'. While this term may be<br />
familiar to Java programmers, it is not used in Basic.<br />
An interface combines several methods. In the strictest sense of the word, a service in UNO does not support<br />
methods, but rather interfaces, which in turn provide different methods. In other words, the methods are assigned<br />
(as combinations) to the service in interfaces. This detail may be of interest in particular to Java- or C++<br />
programmers, since in these languages, the interface is needed to request a method. In <strong>OpenOffice</strong>.<strong>org</strong> Basic, this<br />
is irrelevant. Here, the methods are called directly by means of the relevant object.<br />
For an understanding of the API, it is, however, useful to have the assignment of methods to various interfaces<br />
handy, since many interfaces are used in the different services. If you are familiar with an interface, then you can<br />
transfer your knowledge from one service to another.<br />
Some central interfaces are used so frequently, triggered by different services, that they are shown again at the end<br />
of this chapter.<br />
Tools for Working with UNO<br />
The question remains as to which objects — or services if we are going to remain with UNO terminology —<br />
support which properties, methods and interfaces and how these can be determined. In addition to this guide, you<br />
can get more information about objects from the following sources: the supportsService method, the debug<br />
methods as well as the Developer's <strong>Guide</strong>, and the API reference.<br />
The supportsService Method<br />
A number of UNO objects support the supportsService method, with which you can establish whether an<br />
object supports a particular service. The following call, for example, determines whether the TextElement object<br />
supports the com.sun.star.text.Paragraph service.<br />
Ok = TextElement.supportsService("com.sun.star.text.Paragraph")<br />
Debug Properties<br />
Every UNO object knows what properties, methods and interfaces it already contains. <strong>OpenOffice</strong>.<strong>org</strong> Basic<br />
provides properties that return these in the form of a string containing a list. The corresponding properties are:<br />
DBG_properties<br />
returns a string containing all properties of an object<br />
DBG_methods<br />
returns a string containing all methods of an object<br />
DBG_supportedInterfaces<br />
returns a string containing all interfaces which support an object.<br />
Chapter 4 · Introduction to the API 53