merge the formfield patch from ooo-build
[ooovba.git] / fpicker / source / win32 / filepicker / FPentry.cxx
blob7d2d9d93fc10c739c34434e2ac6cfb1f76a266a3
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.7 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_fpicker.hxx"
34 //----------------------------------------------
35 // includes of other projects
36 //----------------------------------------------
37 #include <cppuhelper/factory.hxx>
38 #include <com/sun/star/container/XSet.hpp>
39 #include <osl/diagnose.h>
40 #include "FilePicker.hxx"
41 #include "FPServiceInfo.hxx"
43 #pragma warning (disable:4917)
44 #include "VistaFilePicker.hxx"
45 #include "..\misc\WinImplHelper.hxx"
46 #include <stdio.h>
48 //-----------------------------------------------
49 // namespace directives
50 //-----------------------------------------------
52 using namespace ::rtl ;
53 using namespace ::com::sun::star::uno ;
54 using namespace ::com::sun::star::container ;
55 using namespace ::com::sun::star::lang ;
56 using namespace ::com::sun::star::registry ;
57 using namespace ::cppu ;
58 using ::com::sun::star::ui::dialogs::XFilePicker;
59 using ::com::sun::star::ui::dialogs::XFilePicker2;
61 //------------------------------------------------
62 //
63 //------------------------------------------------
65 static Reference< XInterface > SAL_CALL createInstance(
66 const Reference< XMultiServiceFactory >& rServiceManager )
68 Reference< XInterface > xDlg;
69 bool bVistaOrNewer = IsWindowsVistaOrNewer();
71 if (bVistaOrNewer)
73 fprintf(stdout, "use special (vista) system file picker ...\n");
74 xDlg.set(
75 static_cast< XFilePicker2* >(
76 new ::fpicker::win32::vista::VistaFilePicker( rServiceManager ) ) );
78 else
80 fprintf(stdout, "use normal system file picker ...\n");
81 xDlg.set(
82 static_cast< XFilePicker2* >(
83 new CFilePicker( rServiceManager ) ) );
86 return xDlg;
89 //------------------------------------------------
90 // the three uno functions that will be exported
91 //------------------------------------------------
93 extern "C"
96 //------------------------------------------------
97 // component_getImplementationEnvironment
98 //------------------------------------------------
100 void SAL_CALL component_getImplementationEnvironment(
101 const sal_Char ** ppEnvTypeName, uno_Environment ** )
103 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
106 //------------------------------------------------
108 //------------------------------------------------
110 sal_Bool SAL_CALL component_writeInfo( void*, void* pRegistryKey )
112 sal_Bool bRetVal = sal_True;
114 if ( pRegistryKey )
118 Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
119 pXNewKey->createKey( OUString::createFromAscii( FILE_PICKER_REGKEY_NAME ) );
121 catch( InvalidRegistryException& )
123 OSL_ENSURE( sal_False, "InvalidRegistryException caught" );
124 bRetVal = sal_False;
128 return bRetVal;
131 //------------------------------------------------
133 //------------------------------------------------
135 void* SAL_CALL component_getFactory(
136 const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* )
138 void* pRet = 0;
140 if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, FILE_PICKER_IMPL_NAME ) ) )
142 Sequence< OUString > aSNS( 1 );
143 aSNS.getArray( )[0] = OUString::createFromAscii( FILE_PICKER_SERVICE_NAME );
145 Reference< XSingleServiceFactory > xFactory ( createSingleFactory(
146 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
147 OUString::createFromAscii( pImplName ),
148 createInstance,
149 aSNS ) );
150 if ( xFactory.is() )
152 xFactory->acquire();
153 pRet = xFactory.get();
157 return pRet;
160 } // extern "C"