Predefined Values

From Apache OpenOffice Wiki
Jump to: navigation, search

The API offers many predefined values, that are used as method parameters, or returned by methods. In UNO IDL there are two different data types for predefined values: constants and enumerations.


A const defines a named value of a valid UNO IDL type. The value depends on the specified type and can be a literal (integer number, floating point number or a character), an identifier of another const type or an arithmetic term using the operators: +, -, *, /, ~, &, |, %, ^, <<, >>.

Since a wide selection of types and values is possible in a const, const is occasionally used to build bit vectors which encode combined values.

  const short ID = 23;
  const boolean ERROR = true;
  const double PI = 3.1415;

Usually const definitions are part of a constants group.


The constants type defines a named group of const values. A const in a constants group is denoted by the group name and the const name. In the UNO IDL example below, ImageAlign.RIGHT refers to the value 2:

  constants ImageAlign {
      const short LEFT = 0;
      const short TOP = 1;
      const short RIGHT = 2;
      const short BOTTOM = 3;


An enum type is equivalent to an enumeration type in C++. It contains an ordered list of one or more identifiers representing long values of the enum type. By default, the values are numbered sequentially, beginning with 0 and adding 1 for each new value. If an enum value has been assigned a value, all following enum values without a predefined value get a value starting from this assigned value.

  enum TypeClass {
  enum Error {
      SYSTEM = 10, // value 10
      RUNTIME, // value 11
      FATAL, // value 12
      USER = 30, // value 30
      SOFT // value 31

If enums are used during debugging, you should be able to derive the numeric value of an enum by counting its position in the API reference. However, never use literal numeric values instead of enums in your programs.

Documentation caution.png Once an enum type has been specified and published, you can trust that it is not extended later on, for that would break existing code. However, new const values may be added to a constant group.

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