xref: /AOO41X/main/fpicker/source/win32/folderpicker/Fopentry.cxx (revision b557fc96600fce3029f73c89748b6c08fd00b34d)
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_fpicker.hxx"
26 
27 //-----------------------------------------------------------------------
28 //  includes of other projects
29 //-----------------------------------------------------------------------
30 #include <cppuhelper/factory.hxx>
31 #include <com/sun/star/container/XSet.hpp>
32 #include <osl/diagnose.h>
33 
34 #ifndef _FILEPICKER_HXX_
35 #include "folderpicker.hxx"
36 #endif
37 
38 #ifndef _FPSERVICEINFO_HXX_
39 #include "FOPServiceInfo.hxx"
40 #endif
41 #include "WinFOPImpl.hxx"
42 
43 //-----------------------------------------------------------------------
44 // namespace directives
45 //-----------------------------------------------------------------------
46 
47 using namespace ::rtl                       ;
48 using namespace ::com::sun::star::uno       ;
49 using namespace ::com::sun::star::container ;
50 using namespace ::com::sun::star::lang      ;
51 using namespace ::com::sun::star::registry  ;
52 using namespace ::cppu                      ;
53 using com::sun::star::ui::dialogs::XFolderPicker;
54 
55 
56 namespace
57 {
58 
59     //-----------------------------------------------------------------------
60     //
61     //-----------------------------------------------------------------------
62 
createInstance(const Reference<XMultiServiceFactory> & rServiceManager)63     Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
64     {
65         return Reference< XInterface >( static_cast< XFolderPicker* >( new CFolderPicker( rServiceManager ) ) );
66     }
67 }
68 
69 //-----------------------------------------------------------------------
70 // the 3 important functions which will be exported
71 //-----------------------------------------------------------------------
72 
73 extern "C"
74 {
75 
76 //----------------------------------------------------------------------
77 // component_getImplementationEnvironment
78 //----------------------------------------------------------------------
79 
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)80 void SAL_CALL component_getImplementationEnvironment(
81     const sal_Char ** ppEnvTypeName, uno_Environment ** )
82 {
83     *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
84 }
85 
86 //----------------------------------------------------------------------
87 // component_getFactory
88 // returns a factory to create XFilePicker-Services
89 //----------------------------------------------------------------------
90 
component_getFactory(const sal_Char * pImplName,uno_Interface * pSrvManager,uno_Interface *)91 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* )
92 {
93     void* pRet = 0;
94 
95     if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, FOLDER_PICKER_IMPL_NAME ) ) )
96     {
97         Sequence< OUString > aSNS( 1 );
98         aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( FOLDER_PICKER_SERVICE_NAME ) );
99 
100         Reference< XSingleServiceFactory > xFactory ( createSingleFactory(
101             reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
102             OUString::createFromAscii( pImplName ),
103             createInstance,
104             aSNS ) );
105         if ( xFactory.is() )
106         {
107             xFactory->acquire();
108             pRet = xFactory.get();
109         }
110     }
111 
112     return pRet;
113 }
114 
115 } // extern "C"
116