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 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_package.hxx" 26 #include <ManifestReader.hxx> 27 #include <ManifestWriter.hxx> 28 #include <cppuhelper/factory.hxx> 29 #ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP 30 #include <com/sun/star/registry/XRegistryKey.hpp> 31 #endif 32 #include <vos/diagnose.hxx> 33 #include <ZipPackage.hxx> 34 35 #include <zipfileaccess.hxx> 36 #include "package/dllapi.h" 37 38 using namespace ::rtl; 39 using namespace ::com::sun::star; 40 using namespace ::com::sun::star::uno; 41 using namespace ::com::sun::star::beans; 42 using namespace ::com::sun::star::lang; 43 using namespace ::com::sun::star::registry; 44 using namespace ::com::sun::star::packages; 45 using namespace ::com::sun::star::packages::manifest; 46 47 // C functions to implement this as a component 48 49 extern "C" PACKAGE_DLLPUBLIC void SAL_CALL component_getImplementationEnvironment( 50 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) 51 { 52 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 53 } 54 55 /** 56 * This function is called to get service factories for an implementation. 57 * @param pImplName name of implementation 58 * @param pServiceManager generic uno interface providing a service manager to instantiate components 59 * @param pRegistryKey registry data key to read and write component persistent data 60 * @return a component factory (generic uno interface) 61 */ 62 extern "C" PACKAGE_DLLPUBLIC void * SAL_CALL component_getFactory( 63 const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) 64 { 65 void * pRet = 0; 66 uno::Reference< XMultiServiceFactory > xSMgr( 67 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) ); 68 uno::Reference< XSingleServiceFactory > xFactory; 69 70 if (ManifestReader::static_getImplementationName().compareToAscii( pImplName ) == 0) 71 xFactory = ManifestReader::createServiceFactory ( xSMgr ); 72 else if (ManifestWriter::static_getImplementationName().compareToAscii( pImplName ) == 0) 73 xFactory = ManifestWriter::createServiceFactory ( xSMgr ); 74 else if (ZipPackage::static_getImplementationName().compareToAscii( pImplName ) == 0) 75 xFactory = ZipPackage::createServiceFactory ( xSMgr ); 76 else if ( OZipFileAccess::impl_staticGetImplementationName().compareToAscii( pImplName ) == 0 ) 77 xFactory = ::cppu::createSingleFactory( xSMgr, 78 OZipFileAccess::impl_staticGetImplementationName(), 79 OZipFileAccess::impl_staticCreateSelfInstance, 80 OZipFileAccess::impl_staticGetSupportedServiceNames() ); 81 82 if ( xFactory.is() ) 83 { 84 xFactory->acquire(); 85 pRet = xFactory.get(); 86 } 87 return pRet; 88 } 89