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