1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_fpicker.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir //------------------------------------------------------------------------ 32*cdf0e10cSrcweir // includes 33*cdf0e10cSrcweir //------------------------------------------------------------------------ 34*cdf0e10cSrcweir #include <osl/diagnose.h> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #ifndef _FOLDERPICKER_HXX_ 37*cdf0e10cSrcweir #include "folderpicker.hxx" 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 40*cdf0e10cSrcweir #include "WinFOPImpl.hxx" 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir //------------------------------------------------------------------------ 43*cdf0e10cSrcweir // namespace directives 44*cdf0e10cSrcweir //------------------------------------------------------------------------ 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir using com::sun::star::uno::Reference; 47*cdf0e10cSrcweir using com::sun::star::uno::RuntimeException; 48*cdf0e10cSrcweir using com::sun::star::uno::Sequence; 49*cdf0e10cSrcweir using com::sun::star::uno::XInterface; 50*cdf0e10cSrcweir using com::sun::star::lang::XMultiServiceFactory; 51*cdf0e10cSrcweir using com::sun::star::lang::XServiceInfo; 52*cdf0e10cSrcweir using com::sun::star::lang::DisposedException; 53*cdf0e10cSrcweir using com::sun::star::lang::IllegalArgumentException; 54*cdf0e10cSrcweir using rtl::OUString; 55*cdf0e10cSrcweir using osl::MutexGuard; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir using namespace cppu; 58*cdf0e10cSrcweir using namespace com::sun::star::ui::dialogs; 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir //------------------------------------------------------------------------ 61*cdf0e10cSrcweir // defines 62*cdf0e10cSrcweir //------------------------------------------------------------------------ 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #define FOLDERPICKER_IMPL_NAME "com.sun.star.ui.dialogs.Win32FolderPicker" 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir //------------------------------------------------------------------------ 67*cdf0e10cSrcweir // helper functions 68*cdf0e10cSrcweir //------------------------------------------------------------------------ 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir namespace 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir Sequence< OUString > SAL_CALL FolderPicker_getSupportedServiceNames() 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir Sequence< OUString > aRet(1); 75*cdf0e10cSrcweir aRet[0] = OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFolderPicker"); 76*cdf0e10cSrcweir return aRet; 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 81*cdf0e10cSrcweir // 82*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir CFolderPicker::CFolderPicker( const Reference< XMultiServiceFactory >& xServiceMgr ) : 85*cdf0e10cSrcweir m_xServiceMgr( xServiceMgr ) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir m_pFolderPickerImpl = std::auto_ptr< CWinFolderPickerImpl > ( new CWinFolderPickerImpl( this ) ); 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 91*cdf0e10cSrcweir // 92*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir void SAL_CALL CFolderPicker::setTitle( const OUString& aTitle ) throw( RuntimeException ) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir OSL_ASSERT( m_pFolderPickerImpl.get( ) ); 97*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 98*cdf0e10cSrcweir m_pFolderPickerImpl->setTitle( aTitle ); 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 102*cdf0e10cSrcweir // 103*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir void SAL_CALL CFolderPicker::setDisplayDirectory( const OUString& aDirectory ) 106*cdf0e10cSrcweir throw( IllegalArgumentException, RuntimeException ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir OSL_ASSERT( m_pFolderPickerImpl.get( ) ); 109*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 110*cdf0e10cSrcweir m_pFolderPickerImpl->setDisplayDirectory( aDirectory ); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 114*cdf0e10cSrcweir // 115*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir OUString SAL_CALL CFolderPicker::getDisplayDirectory( ) 118*cdf0e10cSrcweir throw( RuntimeException ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir OSL_ASSERT( m_pFolderPickerImpl.get( ) ); 121*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 122*cdf0e10cSrcweir return m_pFolderPickerImpl->getDisplayDirectory( ); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 126*cdf0e10cSrcweir // 127*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir OUString SAL_CALL CFolderPicker::getDirectory( ) throw( RuntimeException ) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir OSL_ASSERT( m_pFolderPickerImpl.get( ) ); 132*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 133*cdf0e10cSrcweir return m_pFolderPickerImpl->getDirectory( ); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 137*cdf0e10cSrcweir // 138*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir void SAL_CALL CFolderPicker::setDescription( const OUString& aDescription ) throw( RuntimeException ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir OSL_ASSERT( m_pFolderPickerImpl.get( ) ); 143*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 144*cdf0e10cSrcweir m_pFolderPickerImpl->setDescription( aDescription ); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 148*cdf0e10cSrcweir // 149*cdf0e10cSrcweir //----------------------------------------------------------------------------------------- 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir sal_Int16 SAL_CALL CFolderPicker::execute( ) 152*cdf0e10cSrcweir throw( RuntimeException ) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir OSL_ASSERT( m_pFolderPickerImpl.get( ) ); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir // we should not block in this call else 157*cdf0e10cSrcweir // in the case of an event the client can'tgetPImplFromHandle( hWnd ) 158*cdf0e10cSrcweir // call another function an we run into a 159*cdf0e10cSrcweir // deadlock !!!!! 160*cdf0e10cSrcweir return m_pFolderPickerImpl->execute( ); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir // ------------------------------------------------- 164*cdf0e10cSrcweir // XServiceInfo 165*cdf0e10cSrcweir // ------------------------------------------------- 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir OUString SAL_CALL CFolderPicker::getImplementationName( ) 168*cdf0e10cSrcweir throw( RuntimeException ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir return OUString::createFromAscii( FOLDERPICKER_IMPL_NAME ); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir // ------------------------------------------------- 174*cdf0e10cSrcweir // XServiceInfo 175*cdf0e10cSrcweir // ------------------------------------------------- 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir sal_Bool SAL_CALL CFolderPicker::supportsService( const OUString& ServiceName ) 178*cdf0e10cSrcweir throw( RuntimeException ) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir Sequence < OUString > SupportedServicesNames = FolderPicker_getSupportedServiceNames(); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; ) 183*cdf0e10cSrcweir if (SupportedServicesNames[n].compareTo(ServiceName) == 0) 184*cdf0e10cSrcweir return sal_True; 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir return sal_False; 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir // ------------------------------------------------- 190*cdf0e10cSrcweir // XServiceInfo 191*cdf0e10cSrcweir // ------------------------------------------------- 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir Sequence< OUString > SAL_CALL CFolderPicker::getSupportedServiceNames( ) 194*cdf0e10cSrcweir throw( RuntimeException ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir return FolderPicker_getSupportedServiceNames(); 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir // ------------------------------------------------- 200*cdf0e10cSrcweir // XCancellable 201*cdf0e10cSrcweir // ------------------------------------------------- 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir void SAL_CALL CFolderPicker::cancel( ) 204*cdf0e10cSrcweir throw(RuntimeException) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir OSL_ASSERT( m_pFolderPickerImpl.get( ) ); 207*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 208*cdf0e10cSrcweir m_pFolderPickerImpl->cancel( ); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir //------------------------------------------------ 212*cdf0e10cSrcweir // overwrite base class method, which is called 213*cdf0e10cSrcweir // by base class dispose function 214*cdf0e10cSrcweir //------------------------------------------------ 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir void SAL_CALL CFolderPicker::disposing() 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir 220