SServices.cxx (34dd1e25) | SServices.cxx (97581ef4) |
---|---|
1/************************************************************** | 1/************************************************************** |
2 * | 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 | 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 * | 10 * |
11 * http://www.apache.org/licenses/LICENSE-2.0 | 11 * http://www.apache.org/licenses/LICENSE-2.0 |
12 * | 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. | 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 * | 19 * |
20 *************************************************************/ 21 22 23 24#include <sal/types.h> 25#include "SDriver.hxx" 26#include <cppuhelper/factory.hxx> 27#include <osl/diagnose.h> --- 4 unchanged lines hidden (view full) --- 32using ::com::sun::star::uno::Sequence; 33using ::com::sun::star::registry::XRegistryKey; 34using ::com::sun::star::lang::XSingleServiceFactory; 35using ::com::sun::star::lang::XMultiServiceFactory; 36 37typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) 38 ( 39 const Reference< XMultiServiceFactory > & rServiceManager, | 20 *************************************************************/ 21 22 23 24#include <sal/types.h> 25#include "SDriver.hxx" 26#include <cppuhelper/factory.hxx> 27#include <osl/diagnose.h> --- 4 unchanged lines hidden (view full) --- 32using ::com::sun::star::uno::Sequence; 33using ::com::sun::star::registry::XRegistryKey; 34using ::com::sun::star::lang::XSingleServiceFactory; 35using ::com::sun::star::lang::XMultiServiceFactory; 36 37typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) 38 ( 39 const Reference< XMultiServiceFactory > & rServiceManager, |
40 const OUString & rComponentName, | 40 const OUString & rComponentName, |
41 ::cppu::ComponentInstantiation pCreateFunction, 42 const Sequence< OUString > & rServiceNames, 43 rtl_ModuleCount* _pTemp 44 ); 45 46//*************************************************************************************** 47// 48// The required C-Api must be provided! 49// It contains of 3 special functions that have to be exported. 50// 51 52//--------------------------------------------------------------------------------------- 53void REGISTER_PROVIDER( | 41 ::cppu::ComponentInstantiation pCreateFunction, 42 const Sequence< OUString > & rServiceNames, 43 rtl_ModuleCount* _pTemp 44 ); 45 46//*************************************************************************************** 47// 48// The required C-Api must be provided! 49// It contains of 3 special functions that have to be exported. 50// 51 52//--------------------------------------------------------------------------------------- 53void REGISTER_PROVIDER( |
54 const OUString& aServiceImplName, 55 const Sequence< OUString>& Services, | 54 const OUString& aServiceImplName, 55 const Sequence< OUString>& Services, |
56 const Reference< ::com::sun::star::registry::XRegistryKey > & xKey) 57{ 58 OUString aMainKeyName; 59 aMainKeyName = OUString::createFromAscii("/"); 60 aMainKeyName += aServiceImplName; 61 aMainKeyName += OUString::createFromAscii("/UNO/SERVICES"); 62 | 56 const Reference< ::com::sun::star::registry::XRegistryKey > & xKey) 57{ 58 OUString aMainKeyName; 59 aMainKeyName = OUString::createFromAscii("/"); 60 aMainKeyName += aServiceImplName; 61 aMainKeyName += OUString::createFromAscii("/UNO/SERVICES"); 62 |
63 Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) ); | 63 Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) ); |
64 OSL_ENSURE(xNewKey.is(), "SKELETON::component_writeInfo : could not create a registry key !"); 65 66 for (sal_uInt32 i=0; i<Services.getLength(); ++i) 67 xNewKey->createKey(Services[i]); 68} 69 70 71//--------------------------------------------------------------------------------------- --- 9 unchanged lines hidden (view full) --- 81 ) 82 : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) 83 , sImplementationName(OUString::createFromAscii(pImplementationName)) 84 { 85 } 86 87 inline 88 sal_Bool CREATE_PROVIDER( | 64 OSL_ENSURE(xNewKey.is(), "SKELETON::component_writeInfo : could not create a registry key !"); 65 66 for (sal_uInt32 i=0; i<Services.getLength(); ++i) 67 xNewKey->createKey(Services[i]); 68} 69 70 71//--------------------------------------------------------------------------------------- --- 9 unchanged lines hidden (view full) --- 81 ) 82 : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) 83 , sImplementationName(OUString::createFromAscii(pImplementationName)) 84 { 85 } 86 87 inline 88 sal_Bool CREATE_PROVIDER( |
89 const OUString& Implname, 90 const Sequence< OUString > & Services, | 89 const OUString& Implname, 90 const Sequence< OUString > & Services, |
91 ::cppu::ComponentInstantiation Factory, 92 createFactoryFunc creator 93 ) 94 { 95 if (!xRet.is() && (Implname == sImplementationName)) | 91 ::cppu::ComponentInstantiation Factory, 92 createFactoryFunc creator 93 ) 94 { 95 if (!xRet.is() && (Implname == sImplementationName)) |
96 try 97 { 98 xRet = creator( xServiceManager, sImplementationName,Factory, Services,0); | 96 try 97 { 98 xRet = creator( xServiceManager, sImplementationName,Factory, Services,0); |
99 } 100 catch(...) 101 { 102 } 103 return xRet.is(); 104 } | 99 } 100 catch(...) 101 { 102 } 103 return xRet.is(); 104 } |
105 | 105 |
106 void* getProvider() const { return xRet.get(); } 107}; 108 109//--------------------------------------------------------------------------------------- 110 111extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( 112 const sal_Char **ppEnvTypeName, 113 uno_Environment **ppEnv 114 ) 115{ 116 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 117} 118 119// This method not longer necessary since OOo 3.4 where the component registration was 120// was changed to passive component registration. For more details see | 106 void* getProvider() const { return xRet.get(); } 107}; 108 109//--------------------------------------------------------------------------------------- 110 111extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( 112 const sal_Char **ppEnvTypeName, 113 uno_Environment **ppEnv 114 ) 115{ 116 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 117} 118 119// This method not longer necessary since OOo 3.4 where the component registration was 120// was changed to passive component registration. For more details see |
121// http://wiki.services.openoffice.org/wiki/Passive_Component_Registration | 121// https://wiki.openoffice.org/wiki/Passive_Component_Registration |
122//--------------------------------------------------------------------------------------- 123// extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( 124// void* pServiceManager, 125// void* pRegistryKey 126// ) 127// { | 122//--------------------------------------------------------------------------------------- 123// extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( 124// void* pServiceManager, 125// void* pRegistryKey 126// ) 127// { |
128// if (pRegistryKey) 129// try | 128// if (pRegistryKey) 129// try |
130// { 131// Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey)); 132 133// REGISTER_PROVIDER( | 130// { 131// Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey)); 132 133// REGISTER_PROVIDER( |
134// SkeletonDriver::getImplementationName_Static(), 135// SkeletonDriver::getSupportedServiceNames_Static(), xKey); | 134// SkeletonDriver::getImplementationName_Static(), 135// SkeletonDriver::getSupportedServiceNames_Static(), xKey); |
136 137// return sal_True; 138// } 139// catch (::com::sun::star::registry::InvalidRegistryException& ) 140// { 141// OSL_ENSURE(sal_False, "SKELETON::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !"); 142// } 143 --- 7 unchanged lines hidden (view full) --- 151 void* pRegistryKey) 152{ 153 void* pRet = 0; 154 if (pServiceManager) 155 { 156 ProviderRequest aReq(pServiceManager,pImplementationName); 157 158 aReq.CREATE_PROVIDER( | 136 137// return sal_True; 138// } 139// catch (::com::sun::star::registry::InvalidRegistryException& ) 140// { 141// OSL_ENSURE(sal_False, "SKELETON::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !"); 142// } 143 --- 7 unchanged lines hidden (view full) --- 151 void* pRegistryKey) 152{ 153 void* pRet = 0; 154 if (pServiceManager) 155 { 156 ProviderRequest aReq(pServiceManager,pImplementationName); 157 158 aReq.CREATE_PROVIDER( |
159 SkeletonDriver::getImplementationName_Static(), | 159 SkeletonDriver::getImplementationName_Static(), |
160 SkeletonDriver::getSupportedServiceNames_Static(), | 160 SkeletonDriver::getSupportedServiceNames_Static(), |
161 SkeletonDriver_CreateInstance, ::cppu::createSingleFactory) | 161 SkeletonDriver_CreateInstance, ::cppu::createSingleFactory) |
162 ; 163 164 if(aReq.xRet.is()) 165 aReq.xRet->acquire(); 166 167 pRet = aReq.getProvider(); 168 } 169 170 return pRet; 171}; 172 | 162 ; 163 164 if(aReq.xRet.is()) 165 aReq.xRet->acquire(); 166 167 pRet = aReq.getProvider(); 168 } 169 170 return pRet; 171}; 172 |
173 | |