1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _CPPUHELPER_FACTORY_HXX_ 28 #define _CPPUHELPER_FACTORY_HXX_ 29 30 #include <rtl/ustring.hxx> 31 #include <uno/dispatcher.h> 32 #include <rtl/unload.h> 33 34 #include <com/sun/star/uno/XComponentContext.hpp> 35 #include <com/sun/star/lang/XSingleComponentFactory.hpp> 36 #include <com/sun/star/lang/XSingleServiceFactory.hpp> 37 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 38 #include <com/sun/star/registry/XRegistryKey.hpp> 39 40 //################################################################################################## 41 42 #define COMPONENT_GETENV "component_getImplementationEnvironment" 43 #define COMPONENT_GETENVEXT "component_getImplementationEnvironmentExt" 44 #define COMPONENT_GETDESCRIPTION "component_getDescription" 45 #define COMPONENT_WRITEINFO "component_writeInfo" 46 #define COMPONENT_GETFACTORY "component_getFactory" 47 48 typedef struct _uno_Environment uno_Environment; 49 50 /** Function pointer declaration. 51 Function determines the environment of the component implementation, i.e. which compiler 52 compiled it. If the environment is NOT session specific (needs no additional context), 53 then this function should return the environment type name and leave ppEnv (to 0). 54 55 @param ppEnvTypeName environment type name; string must be constant 56 @param ppEnv function returns its environment if the environment is session specific, 57 i.e. has special context 58 */ 59 typedef void (SAL_CALL * component_getImplementationEnvironmentFunc)( 60 const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ); 61 62 /** Function pointer declaration. 63 Function determines the environment of the component implementation, i.e. the compiler. 64 If the environment is NOT session specific (needs no additional context), 65 then this function should return the environment type name and leave ppEnv (to 0). 66 67 @param ppEnvTypeName environment type name; string must be a constant 68 @param ppEnv function returns an environment if the environment is session specific, 69 i.e. has special context 70 @param pImplName 71 */ 72 typedef void (SAL_CALL * component_getImplementationEnvironmentExtFunc)( 73 sal_Char const ** ppEnvTypeName, 74 uno_Environment ** ppEnv, 75 sal_Char const * pImplName, 76 uno_Environment * pTargetEnv 77 ); 78 79 /** Function pointer declaration. 80 Function retrieves a component description. 81 82 @return an XML formatted string containing a short component description 83 @deprecated 84 */ 85 typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void); 86 87 /** Function pointer declaration. 88 89 @obsolete component_writeInfo should no longer be used in new components 90 91 Function writes component registry info, at least writing the supported service names. 92 93 @param pServiceManager 94 a service manager (the type is an XMultiServiceFactory that can be used 95 by the environment returned by component_getImplementationEnvironment) 96 @param pRegistryKey a registry key 97 (the type is XRegistryKey that can be used by the environment 98 returned by component_getImplementationEnvironment) 99 @return true if everything went fine 100 */ 101 typedef sal_Bool (SAL_CALL * component_writeInfoFunc)( 102 void * pServiceManager, void * pRegistryKey ); 103 104 /** Function pointer declaration. 105 Retrieves a factory to create component instances. 106 107 @param pImplName 108 desired implementation name 109 @param pServiceManager 110 a service manager (the type is XMultiServiceFactory that can be used by the environment 111 returned by component_getImplementationEnvironment) 112 @param pRegistryKey 113 a registry key (the type is XRegistryKey that can be used by the environment 114 returned by component_getImplementationEnvironment) 115 @return acquired component factory 116 (the type is lang::XSingleComponentFactory or lang::XSingleServiceFactory to be used by the 117 environment returned by component_getImplementationEnvironment) 118 */ 119 typedef void * (SAL_CALL * component_getFactoryFunc)( 120 const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); 121 122 //################################################################################################## 123 124 namespace cppu 125 { 126 127 /** Function pointer declaration. 128 Function creates component instance passing the component context to be used. 129 130 @param xContext component context to be used 131 @return component instance 132 */ 133 typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >( 134 SAL_CALL * ComponentFactoryFunc)( 135 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext ) 136 SAL_THROW( (::com::sun::star::uno::Exception) ); 137 138 /** Creates a single component factory supporting the XSingleComponentFactory interface. 139 140 @param fptr function pointer for instanciating the object 141 @param rImplementationName implementation name of service 142 @param rServiceNames supported services 143 @param pModCount for future extension (library unloading concept). 144 */ 145 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > 146 SAL_CALL createSingleComponentFactory( 147 ComponentFactoryFunc fptr, 148 ::rtl::OUString const & rImplementationName, 149 ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames, 150 rtl_ModuleCount * pModCount = 0 ) 151 SAL_THROW( () ); 152 153 /** Creates a single service factory which holds the instance created only once. 154 155 @param fptr function pointer for instanciating the object 156 @param rImplementationName implementation name of service 157 @param rServiceNames supported services 158 @param pModCount for future extension (library unloading concept). 159 160 @see createSingleComponentFactory 161 */ 162 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > SAL_CALL 163 createOneInstanceComponentFactory( 164 ComponentFactoryFunc fptr, 165 ::rtl::OUString const & rImplementationName, 166 ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames, 167 rtl_ModuleCount * pModCount = 0 ) 168 SAL_THROW( () ); 169 170 /** Deprecated. The type of the instanciate function used as argument of the create*Fcatory functions. 171 172 @see createSingleFactory 173 @see createOneInstanceFactory 174 @deprecated 175 */ 176 typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(SAL_CALL * ComponentInstantiation)( 177 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager ); 178 179 /** Deprecated. Creates a single service factory. 180 181 @param rServiceManager the service manager used by the implementation. 182 @param rImplementationName the implementation name. An empty string is possible. 183 @param ComponentInstantiation the function pointer to create an object. 184 @param rServiceNames the service supported by the implementation. 185 @param pModCount for future extension (library unloading concept). 186 @return a factory that support the interfaces XServiceProvider, XServiceInfo 187 XSingleServiceFactory and XComponent. 188 189 @see createOneInstanceFactory 190 @deprecated 191 */ 192 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL 193 createSingleFactory( 194 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, 195 const ::rtl::OUString & rImplementationName, 196 ComponentInstantiation pCreateFunction, 197 const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames, 198 rtl_ModuleCount * pModCount = 0 ) 199 SAL_THROW( () ); 200 201 /** Deprecated. Creates a factory wrapping another one. 202 This means the methods of the interfaces XServiceProvider, XServiceInfo and 203 XSingleServiceFactory are forwarded. 204 @attention 205 The XComponent interface is not supported! 206 207 @param rServiceManager the service manager used by the implementation. 208 @param xSingleServiceFactory the wrapped service factory. 209 @return a factory that support the interfaces XServiceProvider, XServiceInfo 210 XSingleServiceFactory. 211 212 @see createSingleFactory 213 @deprecated 214 */ 215 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL 216 createFactoryProxy( 217 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, 218 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > & rFactory ) 219 SAL_THROW( () ); 220 221 /** Deprecated. Creates a single service factory which holds the instance created only once. 222 223 @param rServiceManager the service manager used by the implementation. 224 @param rImplementationName the implementation name. An empty string is possible. 225 @param ComponentInstantiation the function pointer to create an object. 226 @param rServiceNames the service supported by the implementation. 227 @param pModCount for future extension (library unloading concept). 228 @return a factory that support the interfaces XServiceProvider, XServiceInfo 229 XSingleServiceFactory and XComponent. 230 231 @see createSingleFactory 232 @deprecated 233 */ 234 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL 235 createOneInstanceFactory( 236 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, 237 const ::rtl::OUString & rComponentName, 238 ComponentInstantiation pCreateFunction, 239 const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames, 240 rtl_ModuleCount * pModCount = 0 ) 241 SAL_THROW( () ); 242 243 /** Deprecated. Creates a single service factory based on a registry. 244 245 @param rServiceManager the service manager used by the implementation. 246 @param rImplementationName the implementation name. An empty string is possible. 247 @param rImplementationKey the registry key of the implementation section. 248 @return a factory that support the interfaces XServiceProvider, XServiceInfo 249 XSingleServiceFactory and XComponent. 250 @deprecated 251 */ 252 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createSingleRegistryFactory( 253 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, 254 const ::rtl::OUString & rImplementationName, 255 const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey ) 256 SAL_THROW( () ); 257 258 /** Deprecated. Creates a single service factory which holds the instance created only once 259 based on a registry. 260 261 @param rServiceManager the service manager used by the implementation. 262 @param rImplementationName the implementation name. An empty string is possible. 263 @param rImplementationKey the registry key of the implementation section. 264 @return a factory that support the interfaces XServiceProvider, XServiceInfo 265 XSingleServiceFactory and XComponent. 266 267 @see createSingleRegistryFactory 268 @deprecated 269 */ 270 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createOneInstanceRegistryFactory( 271 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, 272 const ::rtl::OUString & rComponentName, 273 const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey ) 274 SAL_THROW( () ); 275 276 } 277 278 #endif 279