C++ UNO Components |
![]() |
Overview
C++ Components
UNO components, normally, provide an implementation of one or more services. A service description is written in idl. A service describes the interaction of different interfaces to support a special functionality. An idl description of a service specifies a set of interfaces which supports the expected functionality. It can also contain references to other services which are needed for this service. A service could be implemented by more than one component. At this time, the component which is registered last, will be used as the default implementation for the supported services of this component.
It is also possible to register or revoke components at runtime. For this it is necessary to use a registration service (com.sun.star.registry.ImplementationRegistration) to register external components in the runtime environment of the office suite. It should be possible to use almost any programming language to implement a component, since only two things are necessary: first, an appropriate language binding for the programming language used, and second, an appropriate loader service for components implemented in this language.
C++ UNO components are usually implemented as shared libraries. Such a shared library must provide a special interface which contains 4 exported "C" functions. These functions are searched by the appropriate loader service ("com.sun.star.loader.SharedLibrary") to register the component or to instantiate an object providing the service.
The exported "C" functions are:
component_getDescriptionFunc
component_getImplementationEnvironmentFunc
component_writeInfo
component_getFactory
extern "C" const sal_Char* SAL_CALL component_getDescriptionFunc(void);
extern "C" void SAL_CALL component_getImplementationEnvironmentFunc(const
sal_Char** ppEnvTypeName, uno_Environment** ppEnv );
extern "C" sal_Bool SAL_CALL component_writeInfoFunc(void*
pServiceManager, void* pRegistryKey );
Structure of an implementation section:
/IMPLEMENTATIONS/<implementation_name>/UNO/SERVICES/<service_name1>[/attribute_subkeys] /<service_name2>... ... [/REGISTRY_LINKS] (AsciiListValue) <registry_link1> <registry_link2> ... [/DATA]
Under the reserved key ".../UNO/SERVICES" there could be one or more services specified as a subkey with the name of the service. Each service key could also have subkeys to specify service-specific attributes. ".../REGISTRY_LINKS" specifies also a reserved key which is interpreted by the registration service. This key must have an ASCII list value. The values of these lists, specifies links which are created by the registration service. The notation of such a link name shows where the link is created and where the target is. If the link name begins with '/' the link will be created under the rootkey, if not the link will be created relative to the <implementation_name>. If the linkname contains a unique '%', then the part after the '%' is used as the link target; otherwise, the link target is the <implementation_name>. If a link target is specified, it is always relative to the <implementation_name>. To specify one's own service specific data, it is useful to create a special ".../DATA" section.
extern "C" void* SAL_CALL component_getFactoryFunc(const
sal_Char* pImplName, void* pServiceManager, void* pRegistryKey );
Author: Jürgen Schmidt ($Date: 2004/11/30 13:11:29 $) Copyright 2001 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA 94303 USA. |