merge the formfield patch from ooo-build
[ooovba.git] / fpicker / source / win32 / folderpicker / FolderPicker.cxx
blob9d2e67199d849bb4fa5e62e43f384aef7d5a1d7a
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: FolderPicker.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
36 //------------------------------------------------------------------------
37 #include <osl/diagnose.h>
39 #ifndef _FOLDERPICKER_HXX_
40 #include "folderpicker.hxx"
41 #endif
42 #include <com/sun/star/lang/DisposedException.hpp>
43 #include "WinFOPImpl.hxx"
45 //------------------------------------------------------------------------
46 // namespace directives
47 //------------------------------------------------------------------------
49 using com::sun::star::uno::Reference;
50 using com::sun::star::uno::RuntimeException;
51 using com::sun::star::uno::Sequence;
52 using com::sun::star::uno::XInterface;
53 using com::sun::star::lang::XMultiServiceFactory;
54 using com::sun::star::lang::XServiceInfo;
55 using com::sun::star::lang::DisposedException;
56 using com::sun::star::lang::IllegalArgumentException;
57 using rtl::OUString;
58 using osl::MutexGuard;
60 using namespace cppu;
61 using namespace com::sun::star::ui::dialogs;
63 //------------------------------------------------------------------------
64 // defines
65 //------------------------------------------------------------------------
67 #define FOLDERPICKER_IMPL_NAME "com.sun.star.ui.dialogs.Win32FolderPicker"
69 //------------------------------------------------------------------------
70 // helper functions
71 //------------------------------------------------------------------------
73 namespace
75 Sequence< OUString > SAL_CALL FolderPicker_getSupportedServiceNames()
77 Sequence< OUString > aRet(1);
78 aRet[0] = OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFolderPicker");
79 return aRet;
83 //-----------------------------------------------------------------------------------------
85 //-----------------------------------------------------------------------------------------
87 CFolderPicker::CFolderPicker( const Reference< XMultiServiceFactory >& xServiceMgr ) :
88 m_xServiceMgr( xServiceMgr )
90 m_pFolderPickerImpl = std::auto_ptr< CWinFolderPickerImpl > ( new CWinFolderPickerImpl( this ) );
93 //-----------------------------------------------------------------------------------------
95 //-----------------------------------------------------------------------------------------
97 void SAL_CALL CFolderPicker::setTitle( const OUString& aTitle ) throw( RuntimeException )
99 OSL_ASSERT( m_pFolderPickerImpl.get( ) );
100 MutexGuard aGuard( m_aMutex );
101 m_pFolderPickerImpl->setTitle( aTitle );
104 //-----------------------------------------------------------------------------------------
106 //-----------------------------------------------------------------------------------------
108 void SAL_CALL CFolderPicker::setDisplayDirectory( const OUString& aDirectory )
109 throw( IllegalArgumentException, RuntimeException )
111 OSL_ASSERT( m_pFolderPickerImpl.get( ) );
112 MutexGuard aGuard( m_aMutex );
113 m_pFolderPickerImpl->setDisplayDirectory( aDirectory );
116 //-----------------------------------------------------------------------------------------
118 //-----------------------------------------------------------------------------------------
120 OUString SAL_CALL CFolderPicker::getDisplayDirectory( )
121 throw( RuntimeException )
123 OSL_ASSERT( m_pFolderPickerImpl.get( ) );
124 MutexGuard aGuard( m_aMutex );
125 return m_pFolderPickerImpl->getDisplayDirectory( );
128 //-----------------------------------------------------------------------------------------
130 //-----------------------------------------------------------------------------------------
132 OUString SAL_CALL CFolderPicker::getDirectory( ) throw( RuntimeException )
134 OSL_ASSERT( m_pFolderPickerImpl.get( ) );
135 MutexGuard aGuard( m_aMutex );
136 return m_pFolderPickerImpl->getDirectory( );
139 //-----------------------------------------------------------------------------------------
141 //-----------------------------------------------------------------------------------------
143 void SAL_CALL CFolderPicker::setDescription( const OUString& aDescription ) throw( RuntimeException )
145 OSL_ASSERT( m_pFolderPickerImpl.get( ) );
146 MutexGuard aGuard( m_aMutex );
147 m_pFolderPickerImpl->setDescription( aDescription );
150 //-----------------------------------------------------------------------------------------
152 //-----------------------------------------------------------------------------------------
154 sal_Int16 SAL_CALL CFolderPicker::execute( )
155 throw( RuntimeException )
157 OSL_ASSERT( m_pFolderPickerImpl.get( ) );
159 // we should not block in this call else
160 // in the case of an event the client can'tgetPImplFromHandle( hWnd )
161 // call another function an we run into a
162 // deadlock !!!!!
163 return m_pFolderPickerImpl->execute( );
166 // -------------------------------------------------
167 // XServiceInfo
168 // -------------------------------------------------
170 OUString SAL_CALL CFolderPicker::getImplementationName( )
171 throw( RuntimeException )
173 return OUString::createFromAscii( FOLDERPICKER_IMPL_NAME );
176 // -------------------------------------------------
177 // XServiceInfo
178 // -------------------------------------------------
180 sal_Bool SAL_CALL CFolderPicker::supportsService( const OUString& ServiceName )
181 throw( RuntimeException )
183 Sequence < OUString > SupportedServicesNames = FolderPicker_getSupportedServiceNames();
185 for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
186 if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
187 return sal_True;
189 return sal_False;
192 // -------------------------------------------------
193 // XServiceInfo
194 // -------------------------------------------------
196 Sequence< OUString > SAL_CALL CFolderPicker::getSupportedServiceNames( )
197 throw( RuntimeException )
199 return FolderPicker_getSupportedServiceNames();
202 // -------------------------------------------------
203 // XCancellable
204 // -------------------------------------------------
206 void SAL_CALL CFolderPicker::cancel( )
207 throw(RuntimeException)
209 OSL_ASSERT( m_pFolderPickerImpl.get( ) );
210 MutexGuard aGuard( m_aMutex );
211 m_pFolderPickerImpl->cancel( );
214 //------------------------------------------------
215 // overwrite base class method, which is called
216 // by base class dispose function
217 //------------------------------------------------
219 void SAL_CALL CFolderPicker::disposing()