21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Introduction to the API 65<br />

Introduction to the API<br />

Introduction to the API<br />

<strong>OpenOffice</strong>.<strong>org</strong> objects and methods, such as paragraphs, spreadsheets, and fonts, are<br />

accessible to <strong>OpenOffice</strong>.<strong>org</strong> Basic through the <strong>OpenOffice</strong>.<strong>org</strong> application programming<br />

interface, or API. Through the API, for example, documents can be created, opened,<br />

modified and printed. The API can be used not only by <strong>OpenOffice</strong>.<strong>org</strong> Basic, but also by<br />

other programming languages, such as Java and C++. The interface between the API and<br />

various programming languages is provided by something called Universal Network<br />

Objects (UNO).<br />

This chapter provides a background on the API. Building on this background, the following<br />

chapters will show how the API can be used to make <strong>OpenOffice</strong>.<strong>org</strong> do what you want it to<br />

do.<br />

Source: http:/ / <strong>wiki</strong>. services. openoffice. <strong>org</strong>/ w/ index. php? title=Documentation/ <strong>BASIC</strong>_<br />

<strong>Guide</strong>/ API_ Intro&oldid=96862<br />

Principal Authors: Fpe, Ccornell, Cking<br />

Universal Network Objects (UNO)<br />

<strong>OpenOffice</strong>.<strong>org</strong> provides a programming interface in the form of the Universal Network<br />

Objects (UNO). This is an object-oriented programming interface which <strong>OpenOffice</strong>.<strong>org</strong><br />

sub-divides into various objects which for their part ensure program-controlled access to<br />

the Office package.<br />

Since <strong>OpenOffice</strong>.<strong>org</strong> Basic is a procedural programming language, several linguistic<br />

constructs have had to be added to it which enable the use of UNO.<br />

To use a Universal Network Object in <strong>OpenOffice</strong>.<strong>org</strong> Basic, you will need a variable<br />

declaration for the associated object. The declaration is made using the Dim instruction<br />

(see → The Language of <strong>OpenOffice</strong>.<strong>org</strong> Basic). The Object type designation should be used<br />

to declare an object variable:<br />

Dim Obj As Object<br />

The call declares an object variable named Obj.<br />

The object variable created must then be initialized so that it can be used. This can be done<br />

using the createUnoService function:<br />

Obj = createUnoService("com.sun.star.frame.Desktop")

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

Saved successfully!

Ooh no, something went wrong!