From Apache OpenOffice Wiki
Jump to: navigation, search

The interface is usually implemented manually, because only the programmer knows how to initialize the object with arguments received from the service manager through createInstanceWithArguments() or createInstanceWithArgumentsAndContext(). In Java, XInitialization is used as well, but know that the Java factory helper provides a shortcut that uses arguments without implementing XInitialization directly. The Java factory helper can pass arguments to the class constructor under certain conditions. Refer to the section Create Instance with Arguments for more information.

The specification for XInitialization looks like this:

  // module com::sun::star::lang
  interface XInitialization : com::sun::star::uno::XInterface 
      void initialize(sequence< any > aArguments) raises (com::sun::star::uno::Exception); 

An old-style UNOIDL service specification will typically specify which arguments and in which order are expected within the any sequence.

With the advent of new-style service specifications with explicit constructors, you can now declare explicitly what arguments can be passed to an object when creating it. The arguments listed in a constructor are exactly the arguments passed to XInitialization.initialize (the various language bindings currently use XInitialization internally to implement service constructors; that may change in the future, however).

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