Instantiating the UCB

From Apache OpenOffice Wiki
Jump to: navigation, search

The following steps have to be performed before a process can use the UCB:

  • Create and set the UNO service manager.
  • Create an instance of the UNO service, passing the keys identifying a predefined UCB configuration to createInstanceWithArguments().

There are several predefined UCB configurations. Each configuration contains data that describes a set of UCPs. All UCPs contained in a configuration are registered at the UCB that is created using this configuration. A UCB configuration is identified by two keys that are strings. The standard configuration is "Local" and "Office", which generally allows access to all UCPs available in a local installation.

  boolean initUCB() {
      // Obtain Process Service Manager.
      XMultiServiceFactory xServiceFactory = ...
      // Create UCB. This needs to be done only once per process.
      XInterface xUCB;
      try {
          // Supply configuration to use for this UCB instance...
          String[] keys = new String[2];
          keys[ 0 ] = "Local";
          keys[ 1 ] = "Office";
          xUCB = xServiceFactory.createInstanceWithArguments(
              "", keys );
      catch ( e) {
      if (xUCB == null)
          return false;
      return true;

For information about other configurations, refer to Configuration.

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