1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef INCLUDED_SVT_FILEPICKER_HXX 28 #define INCLUDED_SVT_FILEPICKER_HXX 29 30 #include <cppuhelper/implbase7.hxx> 31 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> 32 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp> 33 #include <com/sun/star/ui/dialogs/XFilePreview.hpp> 34 #include <com/sun/star/ui/dialogs/XFilterManager.hpp> 35 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp> 36 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp> 37 #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> 38 #include <com/sun/star/lang/XServiceInfo.hpp> 39 #include <com/sun/star/lang/XEventListener.hpp> 40 #ifndef _COM_SUN_STAR_UNO_XCOMPONENT_CONTEXT_HPP_ 41 #include <com/sun/star/uno/XComponentContext.hpp> 42 #endif 43 44 45 #include <tools/wintypes.hxx> 46 #include "commonpicker.hxx" 47 #include "pickercallbacks.hxx" 48 49 #include <list> 50 51 class Dialog; 52 53 struct FilterEntry; 54 struct ElementEntry_Impl; 55 56 typedef ::std::list< FilterEntry > FilterList; // can be maintained more effectively 57 typedef ::std::list < ElementEntry_Impl > ElementList; 58 59 typedef ::com::sun::star::beans::StringPair UnoFilterEntry; 60 typedef ::com::sun::star::uno::Sequence< UnoFilterEntry > UnoFilterList; // can be transported more effectively 61 typedef ::com::sun::star::uno::Sequence< ::rtl::OUString > OUStringList; // can be transported more effectively 62 63 // class SvtFilePicker --------------------------------------------------- 64 65 typedef ::cppu::ImplHelper7 < ::com::sun::star::ui::dialogs::XFilePickerControlAccess 66 , ::com::sun::star::ui::dialogs::XFilePickerNotifier 67 , ::com::sun::star::ui::dialogs::XFilePreview 68 , ::com::sun::star::ui::dialogs::XFilterManager 69 , ::com::sun::star::ui::dialogs::XFilterGroupManager 70 , ::com::sun::star::lang::XServiceInfo 71 , ::com::sun::star::ui::dialogs::XAsynchronousExecutableDialog 72 > SvtFilePicker_Base; 73 74 class SvtFilePicker :public SvtFilePicker_Base 75 ,public ::svt::OCommonPicker 76 ,public ::svt::IFilePickerListener 77 { 78 private: 79 FilterList* m_pFilterList; 80 ElementList* m_pElemList; 81 82 sal_Bool m_bMultiSelection; 83 sal_Int16 m_nServiceType; 84 ::rtl::OUString m_aDefaultName; 85 ::rtl::OUString m_aCurrentFilter; 86 87 // #97148# -------------- 88 ::rtl::OUString m_aOldDisplayDirectory; 89 ::rtl::OUString m_aOldHideDirectory; 90 91 ::rtl::OUString m_aStandardDir; 92 OUStringList m_aBlackList; 93 94 ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener > 95 m_xListener; 96 ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener > 97 m_xDlgClosedListener; 98 99 public: 100 SvtFilePicker( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& xFactory ); 101 virtual ~SvtFilePicker(); 102 103 //------------------------------------------------------------------------------------ 104 // disambiguate XInterface 105 //------------------------------------------------------------------------------------ 106 DECLARE_XINTERFACE( ) 107 108 //------------------------------------------------------------------------------------ 109 // disambiguate XTypeProvider 110 //------------------------------------------------------------------------------------ 111 DECLARE_XTYPEPROVIDER( ) 112 113 //------------------------------------------------------------------------------------ 114 // XExecutableDialog functions 115 //------------------------------------------------------------------------------------ 116 virtual void SAL_CALL setTitle( const ::rtl::OUString& _rTitle ) throw (::com::sun::star::uno::RuntimeException); 117 virtual sal_Int16 SAL_CALL execute( ) throw (::com::sun::star::uno::RuntimeException); 118 119 //------------------------------------------------------------------------------------ 120 // XAsynchronousExecutableDialog functions 121 //------------------------------------------------------------------------------------ 122 virtual void SAL_CALL setDialogTitle( const ::rtl::OUString& _rTitle ) throw (::com::sun::star::uno::RuntimeException); 123 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 125 //------------------------------------------------------------------------------------ 126 // XFilePicker functions 127 //------------------------------------------------------------------------------------ 128 129 virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) throw( ::com::sun::star::uno::RuntimeException ); 130 virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName ) throw( ::com::sun::star::uno::RuntimeException ); 131 virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 132 virtual ::rtl::OUString SAL_CALL getDisplayDirectory() throw( ::com::sun::star::uno::RuntimeException ); 133 virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles() throw( ::com::sun::star::uno::RuntimeException ); 134 135 //------------------------------------------------------------------------------------ 136 // XFilePickerControlAccess functions 137 //------------------------------------------------------------------------------------ 138 139 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 virtual com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 ElementID, sal_Int16 ControlAction ) throw( ::com::sun::star::uno::RuntimeException ); 141 virtual void SAL_CALL setLabel( sal_Int16 ElementID, const ::rtl::OUString& aValue ) throw ( ::com::sun::star::uno::RuntimeException ); 142 virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 ElementID ) throw ( ::com::sun::star::uno::RuntimeException ); 143 virtual void SAL_CALL enableControl( sal_Int16 ElementID, sal_Bool bEnable ) throw( ::com::sun::star::uno::RuntimeException ); 144 145 //------------------------------------------------------------------------------------ 146 // XFilePickerNotifier functions 147 //------------------------------------------------------------------------------------ 148 149 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 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 152 //------------------------------------------------------------------------------------ 153 // XFilePreview functions 154 //------------------------------------------------------------------------------------ 155 156 virtual com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats() throw ( ::com::sun::star::uno::RuntimeException ); 157 virtual sal_Int32 SAL_CALL getTargetColorDepth() throw ( ::com::sun::star::uno::RuntimeException ); 158 virtual sal_Int32 SAL_CALL getAvailableWidth() throw ( ::com::sun::star::uno::RuntimeException ); 159 virtual sal_Int32 SAL_CALL getAvailableHeight() throw ( ::com::sun::star::uno::RuntimeException ); 160 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 virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw ( ::com::sun::star::uno::RuntimeException ); 162 virtual sal_Bool SAL_CALL getShowState() throw ( ::com::sun::star::uno::RuntimeException ); 163 164 //------------------------------------------------------------------------------------ 165 // XFilterManager functions 166 //------------------------------------------------------------------------------------ 167 168 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 virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 170 virtual ::rtl::OUString SAL_CALL getCurrentFilter() throw( ::com::sun::star::uno::RuntimeException ); 171 172 //------------------------------------------------------------------------------------ 173 // XFilterGroupManager functions 174 //------------------------------------------------------------------------------------ 175 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 177 //------------------------------------------------------------------------------------ 178 // XInitialization functions 179 //------------------------------------------------------------------------------------ 180 181 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 183 //------------------------------------------------------------------------------------ 184 // XServiceInfo functions 185 //------------------------------------------------------------------------------------ 186 187 /* XServiceInfo */ 188 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); 189 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) throw( ::com::sun::star::uno::RuntimeException ); 190 virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 191 getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); 192 193 /* Helper for XServiceInfo */ 194 static com::sun::star::uno::Sequence< ::rtl::OUString > 195 impl_getStaticSupportedServiceNames(); 196 static ::rtl::OUString impl_getStaticImplementationName(); 197 198 /* Helper for registry */ 199 static ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL impl_createInstance ( 200 const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext ) 201 throw( com::sun::star::uno::Exception ); 202 203 protected: 204 //------------------------------------------------------------------------------------ 205 // OCommonPicker overridables 206 //------------------------------------------------------------------------------------ 207 virtual SvtFileDialog* implCreateDialog( Window* _pParent ); 208 virtual sal_Int16 implExecutePicker( ); 209 virtual sal_Bool implHandleInitializationArgument( 210 const ::rtl::OUString& _rName, 211 const ::com::sun::star::uno::Any& _rValue 212 ) 213 SAL_THROW( ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) ); 214 215 private: 216 WinBits getWinBits( WinBits& rExtraBits ); 217 virtual void notify( sal_Int16 _nEventId, sal_Int16 _nControlId ); 218 219 sal_Bool FilterNameExists( const ::rtl::OUString& rTitle ); 220 sal_Bool FilterNameExists( const UnoFilterList& _rGroupedFilters ); 221 222 void ensureFilterList( const ::rtl::OUString& _rInitialCurrentFilter ); 223 224 void prepareExecute( ); 225 226 DECL_LINK( DialogClosedHdl, Dialog* ); 227 }; 228 229 #endif // INCLUDED_SVT_FILEPICKER_HXX 230 231