1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FolderPicker.cxx,v $
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 //------------------------------------------------------------------------
36 //------------------------------------------------------------------------
37 #include <osl/diagnose.h>
39 #ifndef _FOLDERPICKER_HXX_
40 #include "folderpicker.hxx"
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
;
58 using osl::MutexGuard
;
61 using namespace com::sun::star::ui::dialogs
;
63 //------------------------------------------------------------------------
65 //------------------------------------------------------------------------
67 #define FOLDERPICKER_IMPL_NAME "com.sun.star.ui.dialogs.Win32FolderPicker"
69 //------------------------------------------------------------------------
71 //------------------------------------------------------------------------
75 Sequence
< OUString
> SAL_CALL
FolderPicker_getSupportedServiceNames()
77 Sequence
< OUString
> aRet(1);
78 aRet
[0] = OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFolderPicker");
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
163 return m_pFolderPickerImpl
->execute( );
166 // -------------------------------------------------
168 // -------------------------------------------------
170 OUString SAL_CALL
CFolderPicker::getImplementationName( )
171 throw( RuntimeException
)
173 return OUString::createFromAscii( FOLDERPICKER_IMPL_NAME
);
176 // -------------------------------------------------
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)
192 // -------------------------------------------------
194 // -------------------------------------------------
196 Sequence
< OUString
> SAL_CALL
CFolderPicker::getSupportedServiceNames( )
197 throw( RuntimeException
)
199 return FolderPicker_getSupportedServiceNames();
202 // -------------------------------------------------
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()