1*b557fc96SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b557fc96SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b557fc96SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b557fc96SAndrew Rist  * distributed with this work for additional information
6*b557fc96SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b557fc96SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b557fc96SAndrew Rist  * "License"); you may not use this file except in compliance
9*b557fc96SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b557fc96SAndrew Rist  *
11*b557fc96SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b557fc96SAndrew Rist  *
13*b557fc96SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b557fc96SAndrew Rist  * software distributed under the License is distributed on an
15*b557fc96SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b557fc96SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b557fc96SAndrew Rist  * specific language governing permissions and limitations
18*b557fc96SAndrew Rist  * under the License.
19*b557fc96SAndrew Rist  *
20*b557fc96SAndrew Rist  *************************************************************/
21*b557fc96SAndrew Rist 
22*b557fc96SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_fpicker.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //----------------------------------------------
28cdf0e10cSrcweir //	includes of other projects
29cdf0e10cSrcweir //----------------------------------------------
30cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
31cdf0e10cSrcweir #include <com/sun/star/container/XSet.hpp>
32cdf0e10cSrcweir #include <osl/diagnose.h>
33cdf0e10cSrcweir #include "FilePicker.hxx"
34cdf0e10cSrcweir #include "FPServiceInfo.hxx"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #pragma warning (disable:4917)
37cdf0e10cSrcweir #include "VistaFilePicker.hxx"
38cdf0e10cSrcweir #include "..\misc\WinImplHelper.hxx"
39cdf0e10cSrcweir #include <stdio.h>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir //-----------------------------------------------
42cdf0e10cSrcweir // namespace directives
43cdf0e10cSrcweir //-----------------------------------------------
44cdf0e10cSrcweir 
45cdf0e10cSrcweir using namespace ::rtl						;
46cdf0e10cSrcweir using namespace ::com::sun::star::uno		;
47cdf0e10cSrcweir using namespace ::com::sun::star::container	;
48cdf0e10cSrcweir using namespace ::com::sun::star::lang		;
49cdf0e10cSrcweir using namespace ::com::sun::star::registry	;
50cdf0e10cSrcweir using namespace ::cppu					    ;
51cdf0e10cSrcweir using ::com::sun::star::ui::dialogs::XFilePicker;
52cdf0e10cSrcweir using ::com::sun::star::ui::dialogs::XFilePicker2;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //------------------------------------------------
55cdf0e10cSrcweir //
56cdf0e10cSrcweir //------------------------------------------------
57cdf0e10cSrcweir 
createInstance(const Reference<XMultiServiceFactory> & rServiceManager)58cdf0e10cSrcweir static Reference< XInterface > SAL_CALL createInstance(
59cdf0e10cSrcweir 	const Reference< XMultiServiceFactory >& rServiceManager )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir 	Reference< XInterface > xDlg;
62cdf0e10cSrcweir 	bool					bVistaOrNewer = IsWindowsVistaOrNewer();
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	if (bVistaOrNewer)
65cdf0e10cSrcweir 	{
66cdf0e10cSrcweir         OSL_TRACE("use special (vista) system file picker ...");
67cdf0e10cSrcweir 		xDlg.set(
68cdf0e10cSrcweir 			static_cast< XFilePicker2* >(
69cdf0e10cSrcweir 				new ::fpicker::win32::vista::VistaFilePicker( rServiceManager ) ) );
70cdf0e10cSrcweir 	}
71cdf0e10cSrcweir 	else
72cdf0e10cSrcweir 	{
73cdf0e10cSrcweir         OSL_TRACE("use normal system file picker ...");
74cdf0e10cSrcweir 		xDlg.set(
75cdf0e10cSrcweir 			static_cast< XFilePicker2* >(
76cdf0e10cSrcweir 				new CFilePicker( rServiceManager ) ) );
77cdf0e10cSrcweir 	}
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	return xDlg;
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir //------------------------------------------------
83cdf0e10cSrcweir // the three uno functions that will be exported
84cdf0e10cSrcweir //------------------------------------------------
85cdf0e10cSrcweir 
86cdf0e10cSrcweir extern "C"
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 
89cdf0e10cSrcweir //------------------------------------------------
90cdf0e10cSrcweir // component_getImplementationEnvironment
91cdf0e10cSrcweir //------------------------------------------------
92cdf0e10cSrcweir 
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)93cdf0e10cSrcweir void SAL_CALL component_getImplementationEnvironment(
94cdf0e10cSrcweir 	const sal_Char ** ppEnvTypeName, uno_Environment ** )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir //------------------------------------------------
100cdf0e10cSrcweir //
101cdf0e10cSrcweir //------------------------------------------------
102cdf0e10cSrcweir 
component_getFactory(const sal_Char * pImplName,uno_Interface * pSrvManager,uno_Interface *)103cdf0e10cSrcweir void* SAL_CALL component_getFactory(
104cdf0e10cSrcweir 	const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	void* pRet = 0;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, FILE_PICKER_IMPL_NAME ) ) )
109cdf0e10cSrcweir 	{
110cdf0e10cSrcweir 		Sequence< OUString > aSNS( 1 );
111cdf0e10cSrcweir 		aSNS.getArray( )[0] = OUString::createFromAscii( FILE_PICKER_SERVICE_NAME );
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 		Reference< XSingleServiceFactory > xFactory ( createSingleFactory(
114cdf0e10cSrcweir 			reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
115cdf0e10cSrcweir 			OUString::createFromAscii( pImplName ),
116cdf0e10cSrcweir 			createInstance,
117cdf0e10cSrcweir 			aSNS ) );
118cdf0e10cSrcweir 		if ( xFactory.is() )
119cdf0e10cSrcweir 		{
120cdf0e10cSrcweir 			xFactory->acquire();
121cdf0e10cSrcweir 			pRet = xFactory.get();
122cdf0e10cSrcweir 		}
123cdf0e10cSrcweir 	}
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	return pRet;
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir } // extern "C"
129