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.
Universal Network Objects (UNO)<br />
com.sun.star.frame.Desktop<br />
service, can also include other services for loading documents and for ending the program.<br />
Note – VBA : Whereas the structure of an object in VBA is defined by the class to which it belongs, in<br />
<strong>OpenOffice</strong>.<strong>org</strong> Basic the structure is defined through the services which it supports. A VBA object is always<br />
assigned to precisely one single class. A <strong>OpenOffice</strong>.<strong>org</strong> Basic object can, however, support several services.<br />
Properties and Methods<br />
An object in <strong>OpenOffice</strong>.<strong>org</strong> Basic provides a range of properties and methods which can be called by means of<br />
the object.<br />
Properties<br />
Properties are like the properties of an object; for example, Filename and Title for a Document object.<br />
The properties are set by means of a simple assignment:<br />
Document.Title = "<strong>OpenOffice</strong>.<strong>org</strong> Basic Programmer's <strong>Guide</strong>"<br />
Document.Filename = "basguide.odt"<br />
A property, just like a normal variable, has a type that defines which values it can record. The preceding<br />
Filename and Title properties are of the string type.<br />
Real Properties and Imitated Properties<br />
Most of the properties of an object in <strong>OpenOffice</strong>.<strong>org</strong> Basic are defined as such in the UNO description of the<br />
service. In addition to these "real" properties, there are also properties in <strong>OpenOffice</strong>.<strong>org</strong> Basic which consist of<br />
two methods at the UNO level. One of these is used to query the value of the property and the other is issued to<br />
set it (get and set methods). The property has been virtually imitated from two methods. Character objects in<br />
UNO, for example, provide the getPosition and setPosition methods through which the associated key<br />
point can be called up and changed. The <strong>OpenOffice</strong>.<strong>org</strong> Basic programmer can access the values through the<br />
Position property. Regardless of this, the original methods are also available (in our example, getPosition<br />
and setPosition).<br />
Methods<br />
Methods can be understood as functions that relate directly to an object and through which this object is called.<br />
The preceding Document object could, for example, provide a Save method, which can be called as follows:<br />
Document.Save()<br />
Methods, just like functions, may contain parameters and return values. The syntax of such method calls is<br />
oriented towards classic functions. The following call also specifies the True parameter for the document object<br />
when requesting the Save method.<br />
Ok = Document.Save(True)<br />
Once the method has been completed, Save saves a return value in the Ok variable.<br />
52 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010