From Apache OpenOffice Wiki
Jump to: navigation, search

Just like a C++ compiler, the UNOIDL compiler idlc can only use types it already knows. The idlc knows 15 simple types such as boolean, int or string (they are summarized below). Whenever a type other than a simple type is used in the idl file, its declaration has to be included first. For instance, to derive an interface from the interface XInterface, include the corresponding file XInterface.idl. Including means telling the preprocessor to read a given file and execute the instructions found in it.

// searched in include path given in -I parameter
  #include <com/sun/star/uno/XInterface.idl> 
// searched in current path, then in include path
  #include "com/sun/star/uno/XInterface.idl"

There are two ways to include idl files. A file name in angled brackets is searched on the include path passed to idlc using its -I option. File names in double quotes are first searched on the current path and then on the include path.

The XUnoUrlResolver definition above includes and the three exceptions thrown by the method resolve(),, and

In 2.x, it is no longer necessary to explicitly state that an interface type derives from XInterface - if an interface type derives from no other interface type, it is implicitly taken to derive from XInterface. However, even in such situations it is important to explicitly include the file XInterface.idl.

Furthermore, to avoid warnings about redefinition of already included types, use #ifndef and #define as shown above. Note how the entire definition for XUnoUrlResolver is enclosed between #ifndef and #endif. The first thing the preprocessor does is to check if the flag __com_sun_star_bridge_XUnoUrlResolver_idl__ has already been defined. If not, the flag is defined and idlc continues with the definition of XUnoUrlResolver.

Adhere to the naming scheme for include flags used by the Apache OpenOffice developers: Use the file name of the IDL file that is to be included, add double underscores at the beginning and end of the macro, and replace all slashes and dots by underscores.

For other preprocessing instructions supported by idlc refer to Bjarne Stroustrup: The C++ Programming Language.

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