Update ooo320-m1
[ooovba.git] / fpicker / source / aqua / FPentry.cxx
blob21fc269a59c5e744ebffa10af181721bdc89d572
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FPentry.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 //----------------------------------------------
32 // includes of other projects
33 //----------------------------------------------
35 #include <cppuhelper/factory.hxx>
36 #include <com/sun/star/container/XSet.hpp>
38 // #ifndef _OSL_DIAGNOSE_H_
39 // #include <osl/diagnose.h>
40 // #endif
41 #include "SalAquaFilePicker.hxx"
42 #include "SalAquaFolderPicker.hxx"
44 // #ifndef _SV_SVAPP_HXX
45 // #include <vcl/svapp.hxx>
46 // #endif
47 #include "FPServiceInfo.hxx"
49 //-----------------------------------------------
50 // namespace directives
51 //-----------------------------------------------
53 using namespace ::rtl;
54 using namespace ::com::sun::star::uno;
55 using namespace ::com::sun::star::container;
56 using namespace ::com::sun::star::lang;
57 using namespace ::com::sun::star::registry;
58 using namespace ::cppu;
59 using ::com::sun::star::ui::dialogs::XFilePicker;
60 using ::com::sun::star::ui::dialogs::XFolderPicker;
62 //------------------------------------------------
64 //------------------------------------------------
66 static Reference< XInterface > SAL_CALL createFileInstance(
67 const Reference< XMultiServiceFactory >& rServiceManager )
69 return Reference< XInterface >(
70 *new SalAquaFilePicker( rServiceManager ) );
73 static Reference< XInterface > SAL_CALL createFolderInstance(
74 const Reference< XMultiServiceFactory >& rServiceManager )
76 return Reference< XInterface >(
77 *new SalAquaFolderPicker( rServiceManager ) );
80 //------------------------------------------------
81 // the three uno functions that will be exported
82 //------------------------------------------------
84 extern "C"
87 //------------------------------------------------
88 // component_getImplementationEnvironment
89 //------------------------------------------------
91 void SAL_CALL component_getImplementationEnvironment(
92 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
94 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
97 //------------------------------------------------
99 //------------------------------------------------
101 sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
103 sal_Bool bRetVal = sal_True;
105 if ( pRegistryKey )
109 Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
110 pXNewKey->createKey( OUString::createFromAscii( FILE_PICKER_REGKEY_NAME ) );
111 pXNewKey->createKey( OUString::createFromAscii( FOLDER_PICKER_REGKEY_NAME ) );
113 catch( InvalidRegistryException& )
115 OSL_ENSURE( sal_False, "InvalidRegistryException caught" );
116 bRetVal = sal_False;
120 return bRetVal;
123 //------------------------------------------------
125 //------------------------------------------------
127 void* SAL_CALL component_getFactory(
128 const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
130 void* pRet = 0;
132 if( pSrvManager )
134 // FIXME: PJ: when we do not need native file and folder picker...
135 if (0) return 0;
137 Reference< XSingleServiceFactory > xFactory;
139 if (0 == rtl_str_compare(pImplName, FILE_PICKER_IMPL_NAME))
141 Sequence< OUString > aSNS( 1 );
142 aSNS.getArray( )[0] =
143 OUString::createFromAscii(FILE_PICKER_SERVICE_NAME);
145 xFactory = createSingleFactory(
146 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
147 OUString::createFromAscii( pImplName ),
148 createFileInstance,
149 aSNS );
151 else if (0 == rtl_str_compare(pImplName, FOLDER_PICKER_IMPL_NAME))
153 Sequence< OUString > aSNS( 1 );
154 aSNS.getArray( )[0] =
155 OUString::createFromAscii(FOLDER_PICKER_SERVICE_NAME);
157 xFactory = createSingleFactory(
158 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
159 OUString::createFromAscii( pImplName ),
160 createFolderInstance,
161 aSNS );
164 if ( xFactory.is() )
166 xFactory->acquire();
167 pRet = xFactory.get();
171 return pRet;
174 } // extern "C"