Difference between revisions of "Documentation/DevGuide/WritingUNO/XInitialization"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (FINAL VERSION FOR L10N)
 
Line 11: Line 11:
  
 
The specification for <code>XInitialization</code> looks like this:
 
The specification for <code>XInitialization</code> looks like this:
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   // module com::sun::star::lang
 
   // module com::sun::star::lang
 
    
 
    
Line 18: Line 18:
 
       void initialize(sequence< any > aArguments) raises (com::sun::star::uno::Exception);  
 
       void initialize(sequence< any > aArguments) raises (com::sun::star::uno::Exception);  
 
   };
 
   };
</source>
+
</syntaxhighlight>
 
An old-style UNOIDL service specification will typically specify which arguments and in which order are expected within the any sequence.
 
An old-style UNOIDL service specification will typically specify which arguments and in which order are expected within the any sequence.
  

Latest revision as of 17:21, 23 December 2020



The interface com.sun.star.lang.XInitialization 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