1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_package.hxx" 30*cdf0e10cSrcweir #include <ManifestReader.hxx> 31*cdf0e10cSrcweir #include <ManifestWriter.hxx> 32*cdf0e10cSrcweir #include <cppuhelper/factory.hxx> 33*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP 34*cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp> 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #include <vos/diagnose.hxx> 37*cdf0e10cSrcweir #include <ZipPackage.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <zipfileaccess.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir using namespace ::rtl; 42*cdf0e10cSrcweir using namespace ::com::sun::star; 43*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 44*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 45*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 46*cdf0e10cSrcweir using namespace ::com::sun::star::registry; 47*cdf0e10cSrcweir using namespace ::com::sun::star::packages; 48*cdf0e10cSrcweir using namespace ::com::sun::star::packages::manifest; 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir // C functions to implement this as a component 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir extern "C" void SAL_CALL component_getImplementationEnvironment( 53*cdf0e10cSrcweir const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 56*cdf0e10cSrcweir } 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir /** 59*cdf0e10cSrcweir * This function is called to get service factories for an implementation. 60*cdf0e10cSrcweir * @param pImplName name of implementation 61*cdf0e10cSrcweir * @param pServiceManager generic uno interface providing a service manager to instantiate components 62*cdf0e10cSrcweir * @param pRegistryKey registry data key to read and write component persistent data 63*cdf0e10cSrcweir * @return a component factory (generic uno interface) 64*cdf0e10cSrcweir */ 65*cdf0e10cSrcweir extern "C" void * SAL_CALL component_getFactory( 66*cdf0e10cSrcweir const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir void * pRet = 0; 69*cdf0e10cSrcweir uno::Reference< XMultiServiceFactory > xSMgr( 70*cdf0e10cSrcweir reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) ); 71*cdf0e10cSrcweir uno::Reference< XSingleServiceFactory > xFactory; 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir if (ManifestReader::static_getImplementationName().compareToAscii( pImplName ) == 0) 74*cdf0e10cSrcweir xFactory = ManifestReader::createServiceFactory ( xSMgr ); 75*cdf0e10cSrcweir else if (ManifestWriter::static_getImplementationName().compareToAscii( pImplName ) == 0) 76*cdf0e10cSrcweir xFactory = ManifestWriter::createServiceFactory ( xSMgr ); 77*cdf0e10cSrcweir else if (ZipPackage::static_getImplementationName().compareToAscii( pImplName ) == 0) 78*cdf0e10cSrcweir xFactory = ZipPackage::createServiceFactory ( xSMgr ); 79*cdf0e10cSrcweir else if ( OZipFileAccess::impl_staticGetImplementationName().compareToAscii( pImplName ) == 0 ) 80*cdf0e10cSrcweir xFactory = ::cppu::createSingleFactory( xSMgr, 81*cdf0e10cSrcweir OZipFileAccess::impl_staticGetImplementationName(), 82*cdf0e10cSrcweir OZipFileAccess::impl_staticCreateSelfInstance, 83*cdf0e10cSrcweir OZipFileAccess::impl_staticGetSupportedServiceNames() ); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir if ( xFactory.is() ) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir xFactory->acquire(); 88*cdf0e10cSrcweir pRet = xFactory.get(); 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir return pRet; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93