1*a3872823SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*a3872823SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*a3872823SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*a3872823SAndrew Rist * distributed with this work for additional information
6*a3872823SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*a3872823SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*a3872823SAndrew Rist * "License"); you may not use this file except in compliance
9*a3872823SAndrew Rist * with the License. You may obtain a copy of the License at
10*a3872823SAndrew Rist *
11*a3872823SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*a3872823SAndrew Rist *
13*a3872823SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*a3872823SAndrew Rist * software distributed under the License is distributed on an
15*a3872823SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*a3872823SAndrew Rist * KIND, either express or implied. See the License for the
17*a3872823SAndrew Rist * specific language governing permissions and limitations
18*a3872823SAndrew Rist * under the License.
19*a3872823SAndrew Rist *
20*a3872823SAndrew Rist *************************************************************/
21*a3872823SAndrew Rist
22*a3872823SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_package.hxx"
26cdf0e10cSrcweir #include <ManifestReader.hxx>
27cdf0e10cSrcweir #include <ManifestWriter.hxx>
28cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
29cdf0e10cSrcweir #ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP
30cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include <vos/diagnose.hxx>
33cdf0e10cSrcweir #include <ZipPackage.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include <zipfileaccess.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir using namespace ::rtl;
38cdf0e10cSrcweir using namespace ::com::sun::star;
39cdf0e10cSrcweir using namespace ::com::sun::star::uno;
40cdf0e10cSrcweir using namespace ::com::sun::star::beans;
41cdf0e10cSrcweir using namespace ::com::sun::star::lang;
42cdf0e10cSrcweir using namespace ::com::sun::star::registry;
43cdf0e10cSrcweir using namespace ::com::sun::star::packages;
44cdf0e10cSrcweir using namespace ::com::sun::star::packages::manifest;
45cdf0e10cSrcweir
46cdf0e10cSrcweir // C functions to implement this as a component
47cdf0e10cSrcweir
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)48cdf0e10cSrcweir extern "C" void SAL_CALL component_getImplementationEnvironment(
49cdf0e10cSrcweir const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
52cdf0e10cSrcweir }
53cdf0e10cSrcweir
54cdf0e10cSrcweir /**
55cdf0e10cSrcweir * This function is called to get service factories for an implementation.
56cdf0e10cSrcweir * @param pImplName name of implementation
57cdf0e10cSrcweir * @param pServiceManager generic uno interface providing a service manager to instantiate components
58cdf0e10cSrcweir * @param pRegistryKey registry data key to read and write component persistent data
59cdf0e10cSrcweir * @return a component factory (generic uno interface)
60cdf0e10cSrcweir */
component_getFactory(const sal_Char * pImplName,void * pServiceManager,void *)61cdf0e10cSrcweir extern "C" void * SAL_CALL component_getFactory(
62cdf0e10cSrcweir const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir void * pRet = 0;
65cdf0e10cSrcweir uno::Reference< XMultiServiceFactory > xSMgr(
66cdf0e10cSrcweir reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
67cdf0e10cSrcweir uno::Reference< XSingleServiceFactory > xFactory;
68cdf0e10cSrcweir
69cdf0e10cSrcweir if (ManifestReader::static_getImplementationName().compareToAscii( pImplName ) == 0)
70cdf0e10cSrcweir xFactory = ManifestReader::createServiceFactory ( xSMgr );
71cdf0e10cSrcweir else if (ManifestWriter::static_getImplementationName().compareToAscii( pImplName ) == 0)
72cdf0e10cSrcweir xFactory = ManifestWriter::createServiceFactory ( xSMgr );
73cdf0e10cSrcweir else if (ZipPackage::static_getImplementationName().compareToAscii( pImplName ) == 0)
74cdf0e10cSrcweir xFactory = ZipPackage::createServiceFactory ( xSMgr );
75cdf0e10cSrcweir else if ( OZipFileAccess::impl_staticGetImplementationName().compareToAscii( pImplName ) == 0 )
76cdf0e10cSrcweir xFactory = ::cppu::createSingleFactory( xSMgr,
77cdf0e10cSrcweir OZipFileAccess::impl_staticGetImplementationName(),
78cdf0e10cSrcweir OZipFileAccess::impl_staticCreateSelfInstance,
79cdf0e10cSrcweir OZipFileAccess::impl_staticGetSupportedServiceNames() );
80cdf0e10cSrcweir
81cdf0e10cSrcweir if ( xFactory.is() )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir xFactory->acquire();
84cdf0e10cSrcweir pRet = xFactory.get();
85cdf0e10cSrcweir }
86cdf0e10cSrcweir return pRet;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
89