21.08.2013 Views

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Tools for Working with UNO<br />

The following program code shows how DBG_properties and DBG_methods can be used in real-life<br />

applications. It first creates the com.sun.star.frame.Desktop service and then displays the supported properties<br />

and methods in message boxes.<br />

Dim Obj As Object<br />

Obj = createUnoService("com.sun.star.frame.Desktop")<br />

MsgBox Obj.DBG_Properties<br />

MsgBox Obj.DBG_methods<br />

When using DBG_properties, note that the function returns all properties that the services offered by the object<br />

can theoretically support. No assurances are, however, provided for whether these can also be used by the object<br />

in question. In very rare cases, before calling up some property, use the IsEmpty function to check whether it is<br />

actually available.<br />

Debugging tools<br />

Using the DBG_ properties is a very crude method to discover the contents of an API objects.<br />

The watch window of the Basic IDE can display the properties of a Uno object (but not the methods, not the<br />

interfaces).<br />

To display all information available from an object and link to the corresponding API documentation, use instead<br />

Xray tool or MRI tool.<br />

Note – VBA : <strong>OpenOffice</strong>.<strong>org</strong> Basic does not provide code completion. Only at run-time can you find out<br />

which properties or methods are available for an object. All the above debug tools work on a running program.<br />

API Reference<br />

More information about the available services, and their interfaces, methods and properties can be found in the<br />

reference for the <strong>OpenOffice</strong>.<strong>org</strong> API.<br />

Overview of Central Interfaces<br />

Some interfaces of <strong>OpenOffice</strong>.<strong>org</strong> can be found in many parts of the <strong>OpenOffice</strong>.<strong>org</strong> API. They define sets of<br />

methods for abstract tasks which can be applied to various problems. Here, you will find an overview of the most<br />

common of these interfaces.<br />

The origin of the objects is explained at a later point in this guide. At this point, only some of the abstract aspects<br />

of objects, for which the <strong>OpenOffice</strong>.<strong>org</strong> API provides some central interfaces, are discussed.<br />

Creating Context-Dependent Objects<br />

The <strong>OpenOffice</strong>.<strong>org</strong> API provides two options for creating objects. One can be found in the<br />

createUnoService function mentioned at the start of this chapter. createUnoService creates an object<br />

which can be used universally. Such objects and services are also known as context-independent services.<br />

In addition to context-independent services, there are also context-dependent services whose objects are only<br />

useful when used in conjunction with another object. A drawing object for a spreadsheet document, for example,<br />

can therefore only exist in conjunction with this one document.<br />

54 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!