1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _CPPUHELPER_FACTORY_HXX_ 24 #define _CPPUHELPER_FACTORY_HXX_ 25 26 #include <rtl/ustring.hxx> 27 #include <uno/dispatcher.h> 28 #include <rtl/unload.h> 29 30 #include <com/sun/star/uno/XComponentContext.hpp> 31 #include <com/sun/star/lang/XSingleComponentFactory.hpp> 32 #include <com/sun/star/lang/XSingleServiceFactory.hpp> 33 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 34 #include <com/sun/star/registry/XRegistryKey.hpp> 35 36 #include "cppuhelper/cppuhelperdllapi.h" 37 38 //################################################################################################## 39 40 #define COMPONENT_GETENV "component_getImplementationEnvironment" 41 #define COMPONENT_GETENVEXT "component_getImplementationEnvironmentExt" 42 #define COMPONENT_GETDESCRIPTION "component_getDescription" 43 #define COMPONENT_WRITEINFO "component_writeInfo" 44 #define COMPONENT_GETFACTORY "component_getFactory" 45 46 typedef struct _uno_Environment uno_Environment; 47 48 /** Function pointer declaration. 49 Function determines the environment of the component implementation, i.e. which compiler 50 compiled it. If the environment is NOT session specific (needs no additional context), 51 then this function should return the environment type name and leave ppEnv (to 0). 52 53 @param ppEnvTypeName environment type name; string must be constant 54 @param ppEnv function returns its environment if the environment is session specific, 55 i.e. has special context 56 */ 57 typedef void (SAL_CALL * component_getImplementationEnvironmentFunc)( 58 const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ); 59 60 /** Function pointer declaration. 61 Function determines the environment of the component implementation, i.e. the compiler. 62 If the environment is NOT session specific (needs no additional context), 63 then this function should return the environment type name and leave ppEnv (to 0). 64 65 @param ppEnvTypeName environment type name; string must be a constant 66 @param ppEnv function returns an environment if the environment is session specific, 67 i.e. has special context 68 @param pImplName 69 */ 70 typedef void (SAL_CALL * component_getImplementationEnvironmentExtFunc)( 71 sal_Char const ** ppEnvTypeName, 72 uno_Environment ** ppEnv, 73 sal_Char const * pImplName, 74 uno_Environment * pTargetEnv 75 ); 76 77 /** Function pointer declaration. 78 Function retrieves a component description. 79 80 @return an XML formatted string containing a short component description 81 @deprecated 82 */ 83 typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void); 84 85 /** Function pointer declaration. 86 87 @obsolete component_writeInfo should no longer be used in new components 88 89 Function writes component registry info, at least writing the supported service names. 90 91 @param pServiceManager 92 a service manager (the type is an XMultiServiceFactory that can be used 93 by the environment returned by component_getImplementationEnvironment) 94 @param pRegistryKey a registry key 95 (the type is XRegistryKey that can be used by the environment 96 returned by component_getImplementationEnvironment) 97 @return true if everything went fine 98 */ 99 typedef sal_Bool (SAL_CALL * component_writeInfoFunc)( 100 void * pServiceManager, void * pRegistryKey ); 101 102 /** Function pointer declaration. 103 Retrieves a factory to create component instances. 104 105 @param pImplName 106 desired implementation name 107 @param pServiceManager 108 a service manager (the type is XMultiServiceFactory that can be used by the environment 109 returned by component_getImplementationEnvironment) 110 @param pRegistryKey 111 a registry key (the type is XRegistryKey that can be used by the environment 112 returned by component_getImplementationEnvironment) 113 @return acquired component factory 114 (the type is lang::XSingleComponentFactory or lang::XSingleServiceFactory to be used by the 115 environment returned by component_getImplementationEnvironment) 116 */ 117 typedef void * (SAL_CALL * component_getFactoryFunc)( 118 const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); 119 120 //################################################################################################## 121 122 namespace cppu 123 { 124 125 /** Function pointer declaration. 126 Function creates component instance passing the component context to be used. 127 128 @param xContext component context to be used 129 @return component instance 130 */ 131 typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >( 132 SAL_CALL * ComponentFactoryFunc)( 133 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext ) 134 SAL_THROW( (::com::sun::star::uno::Exception) ); 135 136 /** Creates a single component factory supporting the XSingleComponentFactory interface. 137 138 @param fptr function pointer for instanciating the object 139 @param rImplementationName implementation name of service 140 @param rServiceNames supported services 141 @param pModCount for future extension (library unloading concept). 142 */ 143 CPPUHELPER_DLLPUBLIC 144 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > 145 SAL_CALL createSingleComponentFactory( 146 ComponentFactoryFunc fptr, 147 ::rtl::OUString const & rImplementationName, 148 ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames, 149 rtl_ModuleCount * pModCount = 0 ) 150 SAL_THROW( () ); 151 152 /** Creates a single service factory which holds the instance created only once. 153 154 @param fptr function pointer for instanciating the object 155 @param rImplementationName implementation name of service 156 @param rServiceNames supported services 157 @param pModCount for future extension (library unloading concept). 158 159 @see createSingleComponentFactory 160 */ 161 CPPUHELPER_DLLPUBLIC 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 CPPUHELPER_DLLPUBLIC 193 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL 194 createSingleFactory( 195 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, 196 const ::rtl::OUString & rImplementationName, 197 ComponentInstantiation pCreateFunction, 198 const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames, 199 rtl_ModuleCount * pModCount = 0 ) 200 SAL_THROW( () ); 201 202 /** Deprecated. Creates a factory wrapping another one. 203 This means the methods of the interfaces XServiceProvider, XServiceInfo and 204 XSingleServiceFactory are forwarded. 205 @attention 206 The XComponent interface is not supported! 207 208 @param rServiceManager the service manager used by the implementation. 209 @param xSingleServiceFactory the wrapped service factory. 210 @return a factory that support the interfaces XServiceProvider, XServiceInfo 211 XSingleServiceFactory. 212 213 @see createSingleFactory 214 @deprecated 215 */ 216 CPPUHELPER_DLLPUBLIC 217 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL 218 createFactoryProxy( 219 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, 220 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > & rFactory ) 221 SAL_THROW( () ); 222 223 /** Deprecated. Creates a single service factory which holds the instance created only once. 224 225 @param rServiceManager the service manager used by the implementation. 226 @param rImplementationName the implementation name. An empty string is possible. 227 @param ComponentInstantiation the function pointer to create an object. 228 @param rServiceNames the service supported by the implementation. 229 @param pModCount for future extension (library unloading concept). 230 @return a factory that support the interfaces XServiceProvider, XServiceInfo 231 XSingleServiceFactory and XComponent. 232 233 @see createSingleFactory 234 @deprecated 235 */ 236 CPPUHELPER_DLLPUBLIC 237 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL 238 createOneInstanceFactory( 239 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, 240 const ::rtl::OUString & rComponentName, 241 ComponentInstantiation pCreateFunction, 242 const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames, 243 rtl_ModuleCount * pModCount = 0 ) 244 SAL_THROW( () ); 245 246 /** Deprecated. Creates a single service factory based on a registry. 247 248 @param rServiceManager the service manager used by the implementation. 249 @param rImplementationName the implementation name. An empty string is possible. 250 @param rImplementationKey the registry key of the implementation section. 251 @return a factory that support the interfaces XServiceProvider, XServiceInfo 252 XSingleServiceFactory and XComponent. 253 @deprecated 254 */ 255 CPPUHELPER_DLLPUBLIC 256 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createSingleRegistryFactory( 257 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, 258 const ::rtl::OUString & rImplementationName, 259 const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey ) 260 SAL_THROW( () ); 261 262 /** Deprecated. Creates a single service factory which holds the instance created only once 263 based on a registry. 264 265 @param rServiceManager the service manager used by the implementation. 266 @param rImplementationName the implementation name. An empty string is possible. 267 @param rImplementationKey the registry key of the implementation section. 268 @return a factory that support the interfaces XServiceProvider, XServiceInfo 269 XSingleServiceFactory and XComponent. 270 271 @see createSingleRegistryFactory 272 @deprecated 273 */ 274 CPPUHELPER_DLLPUBLIC 275 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createOneInstanceRegistryFactory( 276 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, 277 const ::rtl::OUString & rComponentName, 278 const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey ) 279 SAL_THROW( () ); 280 281 } 282 283 #endif 284