Difference between revisions of "Documentation/BASIC Guide/UNO"

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 14: Line 14:
 
To use a Universal Network Object in {{OOo}} Basic, you will need a variable declaration for the associated object. The declaration is made using the <tt>Dim</tt> instruction (see [[Documentation/BASIC Guide/Language|The Language of {{OOo}} Basic]]). The <tt>Object</tt> type designation should be used to declare an object variable:  
 
To use a Universal Network Object in {{OOo}} Basic, you will need a variable declaration for the associated object. The declaration is made using the <tt>Dim</tt> instruction (see [[Documentation/BASIC Guide/Language|The Language of {{OOo}} Basic]]). The <tt>Object</tt> type designation should be used to declare an object variable:  
  
Dim Obj As Object
+
<source lang="oobas">
 +
Dim Obj As Object
 +
</source>
  
 
The call declares an object variable named <tt>Obj</tt>.  
 
The call declares an object variable named <tt>Obj</tt>.  
Line 20: Line 22:
 
The object variable created must then be initialized so that it can be used. This can be done using the <tt>createUnoService</tt> function:  
 
The object variable created must then be initialized so that it can be used. This can be done using the <tt>createUnoService</tt> function:  
  
Obj = createUnoService("com.sun.star.frame.Desktop")
+
<source lang="oobas">
 +
Obj = createUnoService("com.sun.star.frame.Desktop")
 +
</source>
  
 
This call assigns to the <tt>Obj</tt> variable a reference to the newly created object. <tt>com.sun.star.frame.Desktop</tt> resembles an object type; however in UNO terminology it is called a '''service''' rather than a type. In accordance with UNO philosophy, an Obj is described as a reference to an object which supports the <tt>com.sun.star.frame.Desktop</tt> service. The ''''service'''' term used in {{OOo}} Basic therefore corresponds to the ''''type'''' and ''''class'''' terms used in other programming languages.  
 
This call assigns to the <tt>Obj</tt> variable a reference to the newly created object. <tt>com.sun.star.frame.Desktop</tt> resembles an object type; however in UNO terminology it is called a '''service''' rather than a type. In accordance with UNO philosophy, an Obj is described as a reference to an object which supports the <tt>com.sun.star.frame.Desktop</tt> service. The ''''service'''' term used in {{OOo}} Basic therefore corresponds to the ''''type'''' and ''''class'''' terms used in other programming languages.  

Revision as of 13:39, 2 April 2008


Apache OpenOffice provides a programming interface in the form of the Universal Network Objects (UNO). This is an object-oriented programming interface which Apache OpenOffice sub-divides into various objects which for their part ensure program-controlled access to the Office package.

Since Apache OpenOffice Basic is a procedural programming language, several linguistic constructs have had to be added to it which enable the use of UNO.

To use a Universal Network Object in Apache OpenOffice Basic, you will need a variable declaration for the associated object. The declaration is made using the Dim instruction (see The Language of Apache OpenOffice Basic). The Object type designation should be used to declare an object variable:

Dim Obj As Object

The call declares an object variable named Obj.

The object variable created must then be initialized so that it can be used. This can be done using the createUnoService function:

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

This call assigns to the Obj variable a reference to the newly created object. com.sun.star.frame.Desktop resembles an object type; however in UNO terminology it is called a service rather than a type. In accordance with UNO philosophy, an Obj is described as a reference to an object which supports the com.sun.star.frame.Desktop service. The 'service' term used in Apache OpenOffice Basic therefore corresponds to the 'type' and 'class' terms used in other programming languages.

There is, however, one main difference: a Universal Network Object may support several services at the same time. Some UNO services in turn support other services so that, through one object, you are provided with a whole range of services. For example, that the aforementioned object, which is based on the com.sun.star.frame.Desktop service, can also include other services for loading documents and for ending the program.

Template:Documentation/Note

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools