xref: /aoo41x/main/fpicker/source/aqua/FPentry.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 //----------------------------------------------
29 //  includes of other projects
30 //----------------------------------------------
31 
32 #include <cppuhelper/factory.hxx>
33 #include <com/sun/star/container/XSet.hpp>
34 
35 // #ifndef _OSL_DIAGNOSE_H_
36 // #include <osl/diagnose.h>
37 // #endif
38 #include "SalAquaFilePicker.hxx"
39 #include "SalAquaFolderPicker.hxx"
40 
41 // #ifndef _SV_SVAPP_HXX
42 // #include <vcl/svapp.hxx>
43 // #endif
44 #include "FPServiceInfo.hxx"
45 
46 //-----------------------------------------------
47 // namespace directives
48 //-----------------------------------------------
49 
50 using namespace ::rtl;
51 using namespace ::com::sun::star::uno;
52 using namespace ::com::sun::star::container;
53 using namespace ::com::sun::star::lang;
54 using namespace ::com::sun::star::registry;
55 using namespace ::cppu;
56 using ::com::sun::star::ui::dialogs::XFilePicker;
57 using ::com::sun::star::ui::dialogs::XFolderPicker;
58 
59 //------------------------------------------------
60 //
61 //------------------------------------------------
62 
63 static Reference< XInterface > SAL_CALL createFileInstance(
64     const Reference< XMultiServiceFactory >& rServiceManager )
65 {
66     return Reference< XInterface >(
67         *new SalAquaFilePicker( rServiceManager ) );
68 }
69 
70 static Reference< XInterface > SAL_CALL createFolderInstance(
71     const Reference< XMultiServiceFactory >& rServiceManager )
72 {
73     return Reference< XInterface >(
74         *new SalAquaFolderPicker( rServiceManager ) );
75 }
76 
77 //------------------------------------------------
78 // the three uno functions that will be exported
79 //------------------------------------------------
80 
81 extern "C"
82 {
83 
84 //------------------------------------------------
85 // component_getImplementationEnvironment
86 //------------------------------------------------
87 
88 void SAL_CALL component_getImplementationEnvironment(
89     const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
90 {
91     *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
92 }
93 
94 //------------------------------------------------
95 //
96 //------------------------------------------------
97 
98 void* SAL_CALL component_getFactory(
99     const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
100 {
101     void* pRet = 0;
102 
103     if( pSrvManager )
104     {
105             // FIXME: PJ: when we do not need native file and folder picker...
106             if (0) return 0;
107 
108             Reference< XSingleServiceFactory > xFactory;
109 
110             if (0 == rtl_str_compare(pImplName, FILE_PICKER_IMPL_NAME))
111             {
112                 Sequence< OUString > aSNS( 1 );
113                 aSNS.getArray( )[0] =
114                     OUString::createFromAscii(FILE_PICKER_SERVICE_NAME);
115 
116                 xFactory = createSingleFactory(
117                     reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
118                     OUString::createFromAscii( pImplName ),
119                     createFileInstance,
120                     aSNS );
121             }
122             else if (0 == rtl_str_compare(pImplName, FOLDER_PICKER_IMPL_NAME))
123             {
124                 Sequence< OUString > aSNS( 1 );
125                 aSNS.getArray( )[0] =
126                     OUString::createFromAscii(FOLDER_PICKER_SERVICE_NAME);
127 
128                 xFactory = createSingleFactory(
129                     reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
130                     OUString::createFromAscii( pImplName ),
131                     createFolderInstance,
132                     aSNS );
133             }
134 
135             if ( xFactory.is() )
136             {
137                 xFactory->acquire();
138                 pRet = xFactory.get();
139             }
140     }
141 
142     return pRet;
143 }
144 
145 } // extern "C"
146