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 #ifndef _SALAQUAFILEPICKER_HXX_ 29*cdf0e10cSrcweir #define _SALAQUAFILEPICKER_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir //_______________________________________________________________________________________________________________________ 32*cdf0e10cSrcweir // includes of other projects 33*cdf0e10cSrcweir //_______________________________________________________________________________________________________________________ 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <cppuhelper/compbase8.hxx> 36*cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/beans/StringPair.hpp> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #ifndef _SALAQUAPICKER_HXX_ 46*cdf0e10cSrcweir #include "SalAquaPicker.hxx" 47*cdf0e10cSrcweir #endif 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include <memory> 50*cdf0e10cSrcweir #include <list> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #ifndef _RTL_USTRING_H_ 53*cdf0e10cSrcweir #include <rtl/ustring.hxx> 54*cdf0e10cSrcweir #endif 55*cdf0e10cSrcweir #include "FilterHelper.hxx" 56*cdf0e10cSrcweir #include "AquaFilePickerDelegate.hxx" 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir //---------------------------------------------------------- 59*cdf0e10cSrcweir // Implementation class for the XFilePicker Interface 60*cdf0e10cSrcweir //---------------------------------------------------------- 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir //---------------------------------------------------------- 63*cdf0e10cSrcweir // forward declarations 64*cdf0e10cSrcweir //---------------------------------------------------------- 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir using namespace rtl; 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir //---------------------------------------------------------- 69*cdf0e10cSrcweir // class declaration 70*cdf0e10cSrcweir //---------------------------------------------------------- 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir class SalAquaFilePicker : 73*cdf0e10cSrcweir public SalAquaPicker, 74*cdf0e10cSrcweir public cppu::WeakComponentImplHelper8< 75*cdf0e10cSrcweir ::com::sun::star::ui::dialogs::XFilterManager, 76*cdf0e10cSrcweir ::com::sun::star::ui::dialogs::XFilterGroupManager, 77*cdf0e10cSrcweir ::com::sun::star::ui::dialogs::XFilePickerControlAccess, 78*cdf0e10cSrcweir ::com::sun::star::ui::dialogs::XFilePickerNotifier, 79*cdf0e10cSrcweir ::com::sun::star::lang::XInitialization, 80*cdf0e10cSrcweir ::com::sun::star::util::XCancellable, 81*cdf0e10cSrcweir ::com::sun::star::lang::XEventListener, 82*cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo > 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir public: 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir // constructor 87*cdf0e10cSrcweir SalAquaFilePicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceMgr ); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 90*cdf0e10cSrcweir // XFilePickerNotifier 91*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) 94*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 95*cdf0e10cSrcweir virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) 96*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 99*cdf0e10cSrcweir // XExecutableDialog functions 100*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle ) 103*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir virtual sal_Int16 SAL_CALL execute( ) 106*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 109*cdf0e10cSrcweir // XFilePicker functions 110*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) 113*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName ) 116*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory ) 119*cdf0e10cSrcweir throw( com::sun::star::lang::IllegalArgumentException, 120*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getDisplayDirectory( ) 123*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( ) 126*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 129*cdf0e10cSrcweir // XFilterManager functions 130*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter ) 133*cdf0e10cSrcweir throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle ) 136*cdf0e10cSrcweir throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getCurrentFilter( ) 139*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 142*cdf0e10cSrcweir // XFilterGroupManager functions 143*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString& sGroupTitle, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair >& aFilters ) 146*cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 149*cdf0e10cSrcweir // XFilePickerControlAccess functions 150*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir virtual void SAL_CALL setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const ::com::sun::star::uno::Any& aValue ) 153*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ) 156*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir virtual void SAL_CALL enableControl( sal_Int16 nControlId, sal_Bool bEnable ) 159*cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException ); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir virtual void SAL_CALL setLabel( sal_Int16 nControlId, const ::rtl::OUString& aLabel ) 162*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 nControlId ) 165*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir //------------------------------------------------ 168*cdf0e10cSrcweir // XInitialization 169*cdf0e10cSrcweir //------------------------------------------------ 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 172*cdf0e10cSrcweir throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir //------------------------------------------------ 175*cdf0e10cSrcweir // XCancellable 176*cdf0e10cSrcweir //------------------------------------------------ 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir virtual void SAL_CALL cancel( ) 179*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir //------------------------------------------------ 182*cdf0e10cSrcweir // XEventListener 183*cdf0e10cSrcweir //------------------------------------------------ 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir using cppu::WeakComponentImplHelperBase::disposing; 186*cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) 187*cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir //------------------------------------------------ 190*cdf0e10cSrcweir // XServiceInfo 191*cdf0e10cSrcweir //------------------------------------------------ 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) 194*cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 197*cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 200*cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 203*cdf0e10cSrcweir // FilePicker Event functions 204*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir void SAL_CALL fileSelectionChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ); 207*cdf0e10cSrcweir void SAL_CALL directoryChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ); 208*cdf0e10cSrcweir // rtl::OUString SAL_CALL helpRequested( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ) const; 209*cdf0e10cSrcweir void SAL_CALL controlStateChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ); 210*cdf0e10cSrcweir void SAL_CALL dialogSizeChanged( ); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir inline AquaFilePickerDelegate * getDelegate() { 213*cdf0e10cSrcweir return m_pDelegate; 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir inline rtl::OUString getSaveFileName() { 217*cdf0e10cSrcweir return m_sSaveFileName; 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir private: 221*cdf0e10cSrcweir // prevent copy and assignment 222*cdf0e10cSrcweir SalAquaFilePicker( const SalAquaFilePicker& ); 223*cdf0e10cSrcweir SalAquaFilePicker& operator=( const SalAquaFilePicker& ); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir virtual void ensureFilterHelper(); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir // to instantiate own services 228*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceMgr; 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener > 231*cdf0e10cSrcweir m_xListener; 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir FilterHelper *m_pFilterHelper; 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir rtl::OUString m_sSaveFileName; 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir AquaFilePickerDelegate *m_pDelegate; 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir void updateFilterUI(); 240*cdf0e10cSrcweir void updateSaveFileNameExtension(); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir public: 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir virtual ~SalAquaFilePicker(); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir void filterControlChanged(); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir void implInitialize(); 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir }; 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir #endif // _SALAQUAFILEPICKER_HXX_ 253