Important Interfaces and Implementations (Helper Classes)

From Apache OpenOffice Wiki
Jump to: navigation, search



UNO objects implement a set of UNO interfaces, some of which are always dependent on requirements. The interfaces below belong to the assembly called cli_types.dll within your office's program directory:

com.sun.star.lang.XTypeProvider (recommended for all UNO objects)

com.sun.star.uno.XWeak (recommended for all UNO objects)

com.sun.star.lang.XComponent (optional)

com.sun.star.beans.XPropertySet (optional, required for service implementation concerning defined service properties)

Making object development a little easier, the language binding provides helper implementations for most of the above interfaces. The helper classes belong to the uno.util namespace, and are contained in the assembly called cli_ure.dll. Notice that there is a helper missing that implements a listener container similar to the one in C++ or Java. The main reason for its existence is to ensure the automatic notification of event listeners (see com.sun.star.lang.XComponent, com.sun.star.lang.XEventListener). The CLI languages provide a simple mechanism for events (delegates) which makes a helper class superfluous in this particular case, because event notification is easily implemented using language features.

uno.util.WeakBase

This class implements the XTypeProvider and XWeak interfaces. XWeak is used to implement a UNO weak reference mechanism, and it may seem strange that System.WeakReference is not used. You have to remember that your UNO object is held from within other language environments that do not support weak references. This way, weak references are implemented as a UNO concept. Of course, the helper implementation uses System.WeakReference, as can every component or application, as long as it is not passed into calls to UNO interfaces. Also, the compiler will not be able to compile the implementation properly.

uno.util.WeakComponentBase

This class derives from uno.util.WeakBase and implements the XComponent interface. Use this class as base class if the component needs to perform a special cleanup. The class has two protected member functions that are called upon disposal of the object:

  • preDisposing() - called before all registered event listeners are notified
  • postDisposing() - called after all registered event listeners are notified. Resource cleanup should be performed in this method.

Inherit from uno.util.WeakComponentBase and override the appropriate methods.

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