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
29cdf0e10cSrcweir //------------------------------------------------------------------------
30cdf0e10cSrcweir #include <osl/diagnose.h>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #ifndef _FOLDERPICKER_HXX_
33cdf0e10cSrcweir #include "folderpicker.hxx"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
36cdf0e10cSrcweir #include "WinFOPImpl.hxx"
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //------------------------------------------------------------------------
39cdf0e10cSrcweir // namespace directives
40cdf0e10cSrcweir //------------------------------------------------------------------------
41cdf0e10cSrcweir 
42cdf0e10cSrcweir using com::sun::star::uno::Reference;
43cdf0e10cSrcweir using com::sun::star::uno::RuntimeException;
44cdf0e10cSrcweir using com::sun::star::uno::Sequence;
45cdf0e10cSrcweir using com::sun::star::uno::XInterface;
46cdf0e10cSrcweir using com::sun::star::lang::XMultiServiceFactory;
47cdf0e10cSrcweir using com::sun::star::lang::XServiceInfo;
48cdf0e10cSrcweir using com::sun::star::lang::DisposedException;
49cdf0e10cSrcweir using com::sun::star::lang::IllegalArgumentException;
50cdf0e10cSrcweir using rtl::OUString;
51cdf0e10cSrcweir using osl::MutexGuard;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir using namespace cppu;
54cdf0e10cSrcweir using namespace com::sun::star::ui::dialogs;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir //------------------------------------------------------------------------
57cdf0e10cSrcweir // defines
58cdf0e10cSrcweir //------------------------------------------------------------------------
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #define FOLDERPICKER_IMPL_NAME  "com.sun.star.ui.dialogs.Win32FolderPicker"
61cdf0e10cSrcweir 
62cdf0e10cSrcweir //------------------------------------------------------------------------
63cdf0e10cSrcweir // helper functions
64cdf0e10cSrcweir //------------------------------------------------------------------------
65cdf0e10cSrcweir 
66cdf0e10cSrcweir namespace
67cdf0e10cSrcweir {
FolderPicker_getSupportedServiceNames()68cdf0e10cSrcweir 	Sequence< OUString > SAL_CALL FolderPicker_getSupportedServiceNames()
69cdf0e10cSrcweir 	{
70cdf0e10cSrcweir         Sequence< OUString > aRet(1);
71cdf0e10cSrcweir         aRet[0] = OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFolderPicker");
72cdf0e10cSrcweir 		return aRet;
73cdf0e10cSrcweir 	}
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
77cdf0e10cSrcweir //
78cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
79cdf0e10cSrcweir 
CFolderPicker(const Reference<XMultiServiceFactory> & xServiceMgr)80cdf0e10cSrcweir CFolderPicker::CFolderPicker( const Reference< XMultiServiceFactory >& xServiceMgr ) :
81cdf0e10cSrcweir 	m_xServiceMgr( xServiceMgr )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir 	m_pFolderPickerImpl = std::auto_ptr< CWinFolderPickerImpl > ( new CWinFolderPickerImpl( this ) );
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
87cdf0e10cSrcweir //
88cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
89cdf0e10cSrcweir 
setTitle(const OUString & aTitle)90cdf0e10cSrcweir void SAL_CALL CFolderPicker::setTitle( const OUString& aTitle ) throw( RuntimeException )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	OSL_ASSERT( m_pFolderPickerImpl.get( ) );
93cdf0e10cSrcweir 	MutexGuard aGuard( m_aMutex );
94cdf0e10cSrcweir 	m_pFolderPickerImpl->setTitle( aTitle );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
98cdf0e10cSrcweir //
99cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
100cdf0e10cSrcweir 
setDisplayDirectory(const OUString & aDirectory)101cdf0e10cSrcweir void SAL_CALL CFolderPicker::setDisplayDirectory( const OUString& aDirectory )
102cdf0e10cSrcweir 	throw( IllegalArgumentException, RuntimeException )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 	OSL_ASSERT( m_pFolderPickerImpl.get( ) );
105cdf0e10cSrcweir 	MutexGuard aGuard( m_aMutex );
106cdf0e10cSrcweir 	m_pFolderPickerImpl->setDisplayDirectory( aDirectory );
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
110cdf0e10cSrcweir //
111cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
112cdf0e10cSrcweir 
getDisplayDirectory()113cdf0e10cSrcweir OUString SAL_CALL CFolderPicker::getDisplayDirectory( )
114cdf0e10cSrcweir 	throw( RuntimeException )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir 	OSL_ASSERT( m_pFolderPickerImpl.get( ) );
117cdf0e10cSrcweir 	MutexGuard aGuard( m_aMutex );
118cdf0e10cSrcweir 	return m_pFolderPickerImpl->getDisplayDirectory( );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
122cdf0e10cSrcweir //
123cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
124cdf0e10cSrcweir 
getDirectory()125cdf0e10cSrcweir OUString SAL_CALL CFolderPicker::getDirectory( ) throw( RuntimeException )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     OSL_ASSERT( m_pFolderPickerImpl.get( ) );
128cdf0e10cSrcweir 	MutexGuard aGuard( m_aMutex );
129cdf0e10cSrcweir 	return m_pFolderPickerImpl->getDirectory( );
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
133cdf0e10cSrcweir //
134cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
135cdf0e10cSrcweir 
setDescription(const OUString & aDescription)136cdf0e10cSrcweir void SAL_CALL CFolderPicker::setDescription( const OUString& aDescription ) throw( RuntimeException )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir     OSL_ASSERT( m_pFolderPickerImpl.get( ) );
139cdf0e10cSrcweir     MutexGuard aGuard( m_aMutex );
140cdf0e10cSrcweir     m_pFolderPickerImpl->setDescription( aDescription );
141cdf0e10cSrcweir }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
144cdf0e10cSrcweir //
145cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
146cdf0e10cSrcweir 
execute()147cdf0e10cSrcweir sal_Int16 SAL_CALL CFolderPicker::execute( )
148cdf0e10cSrcweir 	throw( RuntimeException )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	OSL_ASSERT( m_pFolderPickerImpl.get( ) );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	// we should not block in this call else
153cdf0e10cSrcweir 	// in the case of an event the client can'tgetPImplFromHandle( hWnd )
154cdf0e10cSrcweir 	// call another function an we run into a
155cdf0e10cSrcweir 	// deadlock !!!!!
156cdf0e10cSrcweir 	return m_pFolderPickerImpl->execute( );
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir // -------------------------------------------------
160cdf0e10cSrcweir // XServiceInfo
161cdf0e10cSrcweir // -------------------------------------------------
162cdf0e10cSrcweir 
getImplementationName()163cdf0e10cSrcweir OUString SAL_CALL CFolderPicker::getImplementationName(  )
164cdf0e10cSrcweir 	throw( RuntimeException )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir 	return OUString::createFromAscii( FOLDERPICKER_IMPL_NAME );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir // -------------------------------------------------
170cdf0e10cSrcweir //	XServiceInfo
171cdf0e10cSrcweir // -------------------------------------------------
172cdf0e10cSrcweir 
supportsService(const OUString & ServiceName)173cdf0e10cSrcweir sal_Bool SAL_CALL CFolderPicker::supportsService( const OUString& ServiceName )
174cdf0e10cSrcweir 	throw( RuntimeException )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir 	Sequence < OUString > SupportedServicesNames = FolderPicker_getSupportedServiceNames();
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
179cdf0e10cSrcweir 		if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
180cdf0e10cSrcweir 			return sal_True;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	return sal_False;
183cdf0e10cSrcweir }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir // -------------------------------------------------
186cdf0e10cSrcweir //	XServiceInfo
187cdf0e10cSrcweir // -------------------------------------------------
188cdf0e10cSrcweir 
getSupportedServiceNames()189cdf0e10cSrcweir Sequence< OUString > SAL_CALL CFolderPicker::getSupportedServiceNames(	 )
190cdf0e10cSrcweir 	throw( RuntimeException )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir 	return FolderPicker_getSupportedServiceNames();
193cdf0e10cSrcweir }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir // -------------------------------------------------
196cdf0e10cSrcweir //	XCancellable
197cdf0e10cSrcweir // -------------------------------------------------
198cdf0e10cSrcweir 
cancel()199cdf0e10cSrcweir void SAL_CALL CFolderPicker::cancel( )
200cdf0e10cSrcweir 	throw(RuntimeException)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     OSL_ASSERT( m_pFolderPickerImpl.get( ) );
203cdf0e10cSrcweir     MutexGuard aGuard( m_aMutex );
204cdf0e10cSrcweir     m_pFolderPickerImpl->cancel( );
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir //------------------------------------------------
208cdf0e10cSrcweir // overwrite base class method, which is called
209cdf0e10cSrcweir // by base class dispose function
210cdf0e10cSrcweir //------------------------------------------------
211cdf0e10cSrcweir 
disposing()212cdf0e10cSrcweir void SAL_CALL CFolderPicker::disposing()
213cdf0e10cSrcweir {
214cdf0e10cSrcweir }
215cdf0e10cSrcweir 
216