In order to provide a language-independent programming environment, all interfaces and services must be described in an interface definition language (IDL). IDL's similarity with the common programming language C++ is remarkable, however, IDL contains, exclusively, syntax for data description and no statements.
As a rule, UNO interfaces and services are specified in the UNO IDL. UNO interfaces must be derived from a mandatory base interface (com.sun.star.uno.XInterface). This base interface provides three methods: queryInterface(), acquire(), and release(). Because UNO objects may support multiple interfaces, the queryInterface() method is necessary for navigating between the different interfaces (comparable to COM). The acquire() and release() methods handle the life cycle of UNO objects (global reference counting). Cyclic references are handled by the com.sun.star.uno.XComponent interface. Error handling is based on exceptions.
In our example, the service Car and the interfaces XAccelerationControl and XDrivingDirection have to be described in UNO IDL. A possible description of the interface Car could be considered in the following:
module org {
module OOo {
service Car {
interface org::OOo::XAccelerationControl;
interface org::OOo::XDrivingDirection;
[property] long Color;
[property] long Seats;
};
};
};
As mentioned above the service Car consists of the interfaces XAccelerationControl and XDrivingDirection and the properties Color and Seats. The interface XAccelerationControl is described in the following:
module org {
module OOo {
interface XAccelerationControl: com::sun::star::uno::XInterface {
void speedUp( [in] double doubleKilometer );
void slowDown( [in] double doubleKilometer );
};
};
};
The IDL description of the interface XDrivingDirection is illustrated in the following:
module org {
module OOo {
interface XDrivingDirection: com::sun::star::uno::XInterface {
void turnLeft( [in] double doubleAngle );
void turnRight( [in] double doubleAngle );
};
};
};
Because this tutorial is based on the programming language Java, the IDL files must be translated into Java files. All services, interfaces, structures, enumerations, and exceptions, described in the IDL files, will be translated to Java by calling two tools provided by the above mentioned Office Development Kit. The first, the UNO IDL compiler idlc generates an URD (UNO Resource Database) file for each IDL file. In the second step, the tool javamaker generates a Java file for each URD file.