Chapter 10: UNO and the Dispatcher


Overview

This chapter builds on previous coverage of the OpenOffice.org paradigm and then introduces the dispatcher. The dispatcher provides a simple mechanism for invoking internal functionality with limited knowledge of how the internals work, but it is considered the least-favored way of directing OpenOffice.org.

One of the paradigms on which OpenOffice.org is built is called the Universal Network Object (UNO). The major objects in OOo are based on a service. Each service consists of other services, interfaces, UNO structs, and basic data types. The basic data types are the lowest -level components of UNO. UNO structs consist entirely of data members called properties. Although all of the UNO struct properties of which I am aware are basic data types, structs may also contain other structs (see Listing 1 ). Unlike interfaces and services, structs contain only data, not subroutines or functions.

Listing 1: A struct may contain other structs.
start example
 Type PersonType   FirstName As String   LastName As String End Type Type EmployeeType   JobName As String   Person As PersonType End Type Sub ExampleCreateNewType   Dim oPerson As PersonType   Dim oMe As Object   oPerson.FirstName = "Andrew"   oPerson.LastName  = "Pitonyak"   oMe = CreateObject("EmployeeType")   oMe.Person = oPerson   oMe.JobName = "Water Boy"   Print oMe.Person.FirstName & " is a " & oMe.Jobname End Sub 
end example
 
Tip  

"Struct," an abbreviated form of the word "structure," is frequently used by computer programmers. A struct has one or more data members, each of which may have different types. Structs are used to group associated data together.

Tip  

User-defined structures were introduced in OOo version 1.1.1; thanks, Andreas!

Each interface defines a set of subroutines and functions, but this is only a definition, not an implementation. One service may be derived from another, and all services have the com.sun.star.uno.XInterface as the base service. For an object to implement a service, it must implement every subroutine and function that the interface defines, including every subroutine and function in the interface from which it inherits.

A UNO service brings together all of the parts . Each service may be defined to support multiple interfaces, other services, and data. Portions of the service definition may be labeled as optional, in which case a particular implementation may choose to not implement that portion of the service.

Tip  

OOo Basic automatically makes available all of the subroutines, functions, and properties of a UNO component. Other languages such as Java and C++ do not do this automatically; they force you to extract each interface and service individually. The usage in other programming languages is beyond the scope of this book, but it's important to know that if you see code in other languages, there will be many complex manipulations that are not required in OOo Basic.




OpenOffice.org Macros Explained
OpenOffice.org Macros Explained
ISBN: 1930919514
EAN: 2147483647
Year: 2004
Pages: 203

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net