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 #ifndef INCLUDED_SVT_FILEPICKER_HXX 28*cdf0e10cSrcweir #define INCLUDED_SVT_FILEPICKER_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <cppuhelper/implbase7.hxx> 31*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePreview.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/lang/XEventListener.hpp> 40*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_XCOMPONENT_CONTEXT_HPP_ 41*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 42*cdf0e10cSrcweir #endif 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include <tools/wintypes.hxx> 46*cdf0e10cSrcweir #include "commonpicker.hxx" 47*cdf0e10cSrcweir #include "pickercallbacks.hxx" 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include <list> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir class Dialog; 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir struct FilterEntry; 54*cdf0e10cSrcweir struct ElementEntry_Impl; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir typedef ::std::list< FilterEntry > FilterList; // can be maintained more effectively 57*cdf0e10cSrcweir typedef ::std::list < ElementEntry_Impl > ElementList; 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir typedef ::com::sun::star::beans::StringPair UnoFilterEntry; 60*cdf0e10cSrcweir typedef ::com::sun::star::uno::Sequence< UnoFilterEntry > UnoFilterList; // can be transported more effectively 61*cdf0e10cSrcweir typedef ::com::sun::star::uno::Sequence< ::rtl::OUString > OUStringList; // can be transported more effectively 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir // class SvtFilePicker --------------------------------------------------- 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir typedef ::cppu::ImplHelper7 < ::com::sun::star::ui::dialogs::XFilePickerControlAccess 66*cdf0e10cSrcweir , ::com::sun::star::ui::dialogs::XFilePickerNotifier 67*cdf0e10cSrcweir , ::com::sun::star::ui::dialogs::XFilePreview 68*cdf0e10cSrcweir , ::com::sun::star::ui::dialogs::XFilterManager 69*cdf0e10cSrcweir , ::com::sun::star::ui::dialogs::XFilterGroupManager 70*cdf0e10cSrcweir , ::com::sun::star::lang::XServiceInfo 71*cdf0e10cSrcweir , ::com::sun::star::ui::dialogs::XAsynchronousExecutableDialog 72*cdf0e10cSrcweir > SvtFilePicker_Base; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir class SvtFilePicker :public SvtFilePicker_Base 75*cdf0e10cSrcweir ,public ::svt::OCommonPicker 76*cdf0e10cSrcweir ,public ::svt::IFilePickerListener 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir private: 79*cdf0e10cSrcweir FilterList* m_pFilterList; 80*cdf0e10cSrcweir ElementList* m_pElemList; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir sal_Bool m_bMultiSelection; 83*cdf0e10cSrcweir sal_Int16 m_nServiceType; 84*cdf0e10cSrcweir ::rtl::OUString m_aDefaultName; 85*cdf0e10cSrcweir ::rtl::OUString m_aCurrentFilter; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir // #97148# -------------- 88*cdf0e10cSrcweir ::rtl::OUString m_aOldDisplayDirectory; 89*cdf0e10cSrcweir ::rtl::OUString m_aOldHideDirectory; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir ::rtl::OUString m_aStandardDir; 92*cdf0e10cSrcweir OUStringList m_aBlackList; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener > 95*cdf0e10cSrcweir m_xListener; 96*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener > 97*cdf0e10cSrcweir m_xDlgClosedListener; 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir public: 100*cdf0e10cSrcweir SvtFilePicker( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& xFactory ); 101*cdf0e10cSrcweir virtual ~SvtFilePicker(); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 104*cdf0e10cSrcweir // disambiguate XInterface 105*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 106*cdf0e10cSrcweir DECLARE_XINTERFACE( ) 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 109*cdf0e10cSrcweir // disambiguate XTypeProvider 110*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 111*cdf0e10cSrcweir DECLARE_XTYPEPROVIDER( ) 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 114*cdf0e10cSrcweir // XExecutableDialog functions 115*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 116*cdf0e10cSrcweir virtual void SAL_CALL setTitle( const ::rtl::OUString& _rTitle ) throw (::com::sun::star::uno::RuntimeException); 117*cdf0e10cSrcweir virtual sal_Int16 SAL_CALL execute( ) throw (::com::sun::star::uno::RuntimeException); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 120*cdf0e10cSrcweir // XAsynchronousExecutableDialog functions 121*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 122*cdf0e10cSrcweir virtual void SAL_CALL setDialogTitle( const ::rtl::OUString& _rTitle ) throw (::com::sun::star::uno::RuntimeException); 123*cdf0e10cSrcweir virtual void SAL_CALL startExecuteModal( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 126*cdf0e10cSrcweir // XFilePicker functions 127*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) throw( ::com::sun::star::uno::RuntimeException ); 130*cdf0e10cSrcweir virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName ) throw( ::com::sun::star::uno::RuntimeException ); 131*cdf0e10cSrcweir virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 132*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getDisplayDirectory() throw( ::com::sun::star::uno::RuntimeException ); 133*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles() throw( ::com::sun::star::uno::RuntimeException ); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 136*cdf0e10cSrcweir // XFilePickerControlAccess functions 137*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir virtual void SAL_CALL setValue( sal_Int16 ElementID, sal_Int16 ControlAction, const com::sun::star::uno::Any& value ) throw( ::com::sun::star::uno::RuntimeException ); 140*cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 ElementID, sal_Int16 ControlAction ) throw( ::com::sun::star::uno::RuntimeException ); 141*cdf0e10cSrcweir virtual void SAL_CALL setLabel( sal_Int16 ElementID, const ::rtl::OUString& aValue ) throw ( ::com::sun::star::uno::RuntimeException ); 142*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 ElementID ) throw ( ::com::sun::star::uno::RuntimeException ); 143*cdf0e10cSrcweir virtual void SAL_CALL enableControl( sal_Int16 ElementID, sal_Bool bEnable ) throw( ::com::sun::star::uno::RuntimeException ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 146*cdf0e10cSrcweir // XFilePickerNotifier functions 147*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw ( ::com::sun::star::uno::RuntimeException ); 150*cdf0e10cSrcweir virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw ( ::com::sun::star::uno::RuntimeException ); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 153*cdf0e10cSrcweir // XFilePreview functions 154*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats() throw ( ::com::sun::star::uno::RuntimeException ); 157*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getTargetColorDepth() throw ( ::com::sun::star::uno::RuntimeException ); 158*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getAvailableWidth() throw ( ::com::sun::star::uno::RuntimeException ); 159*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getAvailableHeight() throw ( ::com::sun::star::uno::RuntimeException ); 160*cdf0e10cSrcweir virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const com::sun::star::uno::Any& aImage ) throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 161*cdf0e10cSrcweir virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw ( ::com::sun::star::uno::RuntimeException ); 162*cdf0e10cSrcweir virtual sal_Bool SAL_CALL getShowState() throw ( ::com::sun::star::uno::RuntimeException ); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 165*cdf0e10cSrcweir // XFilterManager functions 166*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 169*cdf0e10cSrcweir virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 170*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getCurrentFilter() throw( ::com::sun::star::uno::RuntimeException ); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 173*cdf0e10cSrcweir // XFilterGroupManager functions 174*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 175*cdf0e10cSrcweir virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString& sGroupTitle, const com::sun::star::uno::Sequence< com::sun::star::beans::StringPair >& aFilters ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 178*cdf0e10cSrcweir // XInitialization functions 179*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir virtual void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) throw ( com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 184*cdf0e10cSrcweir // XServiceInfo functions 185*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir /* XServiceInfo */ 188*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); 189*cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) throw( ::com::sun::star::uno::RuntimeException ); 190*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 191*cdf0e10cSrcweir getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir /* Helper for XServiceInfo */ 194*cdf0e10cSrcweir static com::sun::star::uno::Sequence< ::rtl::OUString > 195*cdf0e10cSrcweir impl_getStaticSupportedServiceNames(); 196*cdf0e10cSrcweir static ::rtl::OUString impl_getStaticImplementationName(); 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir /* Helper for registry */ 199*cdf0e10cSrcweir static ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL impl_createInstance ( 200*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext ) 201*cdf0e10cSrcweir throw( com::sun::star::uno::Exception ); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir protected: 204*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 205*cdf0e10cSrcweir // OCommonPicker overridables 206*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 207*cdf0e10cSrcweir virtual SvtFileDialog* implCreateDialog( Window* _pParent ); 208*cdf0e10cSrcweir virtual sal_Int16 implExecutePicker( ); 209*cdf0e10cSrcweir virtual sal_Bool implHandleInitializationArgument( 210*cdf0e10cSrcweir const ::rtl::OUString& _rName, 211*cdf0e10cSrcweir const ::com::sun::star::uno::Any& _rValue 212*cdf0e10cSrcweir ) 213*cdf0e10cSrcweir SAL_THROW( ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) ); 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir private: 216*cdf0e10cSrcweir WinBits getWinBits( WinBits& rExtraBits ); 217*cdf0e10cSrcweir virtual void notify( sal_Int16 _nEventId, sal_Int16 _nControlId ); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir sal_Bool FilterNameExists( const ::rtl::OUString& rTitle ); 220*cdf0e10cSrcweir sal_Bool FilterNameExists( const UnoFilterList& _rGroupedFilters ); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir void ensureFilterList( const ::rtl::OUString& _rInitialCurrentFilter ); 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir void prepareExecute( ); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir DECL_LINK( DialogClosedHdl, Dialog* ); 227*cdf0e10cSrcweir }; 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir #endif // INCLUDED_SVT_FILEPICKER_HXX 230*cdf0e10cSrcweir 231