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 //---------------------------------------------- 25 // includes of other projects 26 //---------------------------------------------- 27 28 #include <cppuhelper/factory.hxx> 29 #include <com/sun/star/container/XSet.hpp> 30 31 // #ifndef _OSL_DIAGNOSE_H_ 32 // #include <osl/diagnose.h> 33 // #endif 34 #include "SalAquaFilePicker.hxx" 35 #include "SalAquaFolderPicker.hxx" 36 37 // #ifndef _SV_SVAPP_HXX 38 // #include <vcl/svapp.hxx> 39 // #endif 40 #include "FPServiceInfo.hxx" 41 42 //----------------------------------------------- 43 // namespace directives 44 //----------------------------------------------- 45 46 using namespace ::rtl; 47 using namespace ::com::sun::star::uno; 48 using namespace ::com::sun::star::container; 49 using namespace ::com::sun::star::lang; 50 using namespace ::com::sun::star::registry; 51 using namespace ::cppu; 52 using ::com::sun::star::ui::dialogs::XFilePicker; 53 using ::com::sun::star::ui::dialogs::XFolderPicker; 54 55 //------------------------------------------------ 56 // 57 //------------------------------------------------ 58 59 static Reference< XInterface > SAL_CALL createFileInstance( 60 const Reference< XMultiServiceFactory >& rServiceManager ) 61 { 62 return Reference< XInterface >( 63 *new SalAquaFilePicker( rServiceManager ) ); 64 } 65 66 static Reference< XInterface > SAL_CALL createFolderInstance( 67 const Reference< XMultiServiceFactory >& rServiceManager ) 68 { 69 return Reference< XInterface >( 70 *new SalAquaFolderPicker( rServiceManager ) ); 71 } 72 73 //------------------------------------------------ 74 // the three uno functions that will be exported 75 //------------------------------------------------ 76 77 extern "C" 78 { 79 80 //------------------------------------------------ 81 // component_getImplementationEnvironment 82 //------------------------------------------------ 83 84 void SAL_CALL component_getImplementationEnvironment( 85 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) 86 { 87 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 88 } 89 90 //------------------------------------------------ 91 // 92 //------------------------------------------------ 93 94 void* SAL_CALL component_getFactory( 95 const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ ) 96 { 97 void* pRet = 0; 98 99 if( pSrvManager ) 100 { 101 // FIXME: PJ: when we do not need native file and folder picker... 102 if (0) return 0; 103 104 Reference< XSingleServiceFactory > xFactory; 105 106 if (0 == rtl_str_compare(pImplName, FILE_PICKER_IMPL_NAME)) 107 { 108 Sequence< OUString > aSNS( 1 ); 109 aSNS.getArray( )[0] = 110 OUString::createFromAscii(FILE_PICKER_SERVICE_NAME); 111 112 xFactory = createSingleFactory( 113 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ), 114 OUString::createFromAscii( pImplName ), 115 createFileInstance, 116 aSNS ); 117 } 118 else if (0 == rtl_str_compare(pImplName, FOLDER_PICKER_IMPL_NAME)) 119 { 120 Sequence< OUString > aSNS( 1 ); 121 aSNS.getArray( )[0] = 122 OUString::createFromAscii(FOLDER_PICKER_SERVICE_NAME); 123 124 xFactory = createSingleFactory( 125 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ), 126 OUString::createFromAscii( pImplName ), 127 createFolderInstance, 128 aSNS ); 129 } 130 131 if ( xFactory.is() ) 132 { 133 xFactory->acquire(); 134 pRet = xFactory.get(); 135 } 136 } 137 138 return pRet; 139 } 140 141 } // extern "C" 142