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_extensions.hxx" 26 #include "res_services.hxx" 27 28 /** === begin UNO using === **/ 29 using ::com::sun::star::uno::Reference; 30 using ::com::sun::star::uno::Sequence; 31 using ::com::sun::star::uno::Exception; 32 using ::com::sun::star::lang::XMultiServiceFactory; 33 using ::com::sun::star::lang::XSingleServiceFactory; 34 using ::com::sun::star::uno::UNO_QUERY; 35 /** === end UNO using === **/ 36 37 #include <vector> 38 39 namespace res 40 { 41 ::std::vector< ComponentInfo > getComponentInfos() 42 { 43 ::std::vector< ::res::ComponentInfo > aComponentInfos; 44 aComponentInfos.push_back( getComponentInfo_VclStringResourceLoader() ); 45 aComponentInfos.push_back( getComponentInfo_OpenOfficeResourceLoader() ); 46 return aComponentInfos; 47 } 48 } 49 50 extern "C" { 51 52 void SAL_CALL component_getImplementationEnvironment( 53 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) 54 { 55 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 56 } 57 58 void * SAL_CALL component_getFactory( 59 const sal_Char * pImplName, XMultiServiceFactory * /*pServiceManager*/, void * /*pRegistryKey*/ ) 60 { 61 void * pRet = 0; 62 ::std::vector< ::res::ComponentInfo > aComponentInfos( ::res::getComponentInfos() ); 63 for ( ::std::vector< ::res::ComponentInfo >::const_iterator loop = aComponentInfos.begin(); 64 loop != aComponentInfos.end(); 65 ++loop 66 ) 67 { 68 if ( 0 == loop->sImplementationName.compareToAscii( pImplName ) ) 69 { 70 // create the factory 71 Reference< XSingleServiceFactory > xFactory( ::cppu::createSingleComponentFactory( 72 loop->pFactory, loop->sImplementationName, loop->aSupportedServices ), 73 UNO_QUERY ); 74 // acquire, because we return an interface pointer instead of a reference 75 xFactory->acquire(); 76 pRet = xFactory.get(); 77 } 78 } 79 return pRet; 80 } 81 82 } // extern "C" 83