1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef INCLUDED_SVT_FILEPICKER_HXX 24 #define INCLUDED_SVT_FILEPICKER_HXX 25 26 #include <cppuhelper/implbase7.hxx> 27 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> 28 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp> 29 #include <com/sun/star/ui/dialogs/XFilePreview.hpp> 30 #include <com/sun/star/ui/dialogs/XFilterManager.hpp> 31 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp> 32 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp> 33 #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> 34 #include <com/sun/star/lang/XServiceInfo.hpp> 35 #include <com/sun/star/lang/XEventListener.hpp> 36 #ifndef _COM_SUN_STAR_UNO_XCOMPONENT_CONTEXT_HPP_ 37 #include <com/sun/star/uno/XComponentContext.hpp> 38 #endif 39 40 41 #include <tools/wintypes.hxx> 42 #include "commonpicker.hxx" 43 #include "pickercallbacks.hxx" 44 45 #include <list> 46 47 class Dialog; 48 49 struct FilterEntry; 50 struct ElementEntry_Impl; 51 52 typedef ::std::list< FilterEntry > FilterList; // can be maintained more effectively 53 typedef ::std::list < ElementEntry_Impl > ElementList; 54 55 typedef ::com::sun::star::beans::StringPair UnoFilterEntry; 56 typedef ::com::sun::star::uno::Sequence< UnoFilterEntry > UnoFilterList; // can be transported more effectively 57 typedef ::com::sun::star::uno::Sequence< ::rtl::OUString > OUStringList; // can be transported more effectively 58 59 // class SvtFilePicker --------------------------------------------------- 60 61 typedef ::cppu::ImplHelper7 < ::com::sun::star::ui::dialogs::XFilePickerControlAccess 62 , ::com::sun::star::ui::dialogs::XFilePickerNotifier 63 , ::com::sun::star::ui::dialogs::XFilePreview 64 , ::com::sun::star::ui::dialogs::XFilterManager 65 , ::com::sun::star::ui::dialogs::XFilterGroupManager 66 , ::com::sun::star::lang::XServiceInfo 67 , ::com::sun::star::ui::dialogs::XAsynchronousExecutableDialog 68 > SvtFilePicker_Base; 69 70 class SvtFilePicker :public SvtFilePicker_Base 71 ,public ::svt::OCommonPicker 72 ,public ::svt::IFilePickerListener 73 { 74 private: 75 FilterList* m_pFilterList; 76 ElementList* m_pElemList; 77 78 sal_Bool m_bMultiSelection; 79 sal_Int16 m_nServiceType; 80 ::rtl::OUString m_aDefaultName; 81 ::rtl::OUString m_aCurrentFilter; 82 83 // #97148# -------------- 84 ::rtl::OUString m_aOldDisplayDirectory; 85 ::rtl::OUString m_aOldHideDirectory; 86 87 ::rtl::OUString m_aStandardDir; 88 OUStringList m_aBlackList; 89 90 ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener > 91 m_xListener; 92 ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener > 93 m_xDlgClosedListener; 94 95 public: 96 SvtFilePicker( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& xFactory ); 97 virtual ~SvtFilePicker(); 98 99 //------------------------------------------------------------------------------------ 100 // disambiguate XInterface 101 //------------------------------------------------------------------------------------ 102 DECLARE_XINTERFACE( ) 103 104 //------------------------------------------------------------------------------------ 105 // disambiguate XTypeProvider 106 //------------------------------------------------------------------------------------ 107 DECLARE_XTYPEPROVIDER( ) 108 109 //------------------------------------------------------------------------------------ 110 // XExecutableDialog functions 111 //------------------------------------------------------------------------------------ 112 virtual void SAL_CALL setTitle( const ::rtl::OUString& _rTitle ) throw (::com::sun::star::uno::RuntimeException); 113 virtual sal_Int16 SAL_CALL execute( ) throw (::com::sun::star::uno::RuntimeException); 114 115 //------------------------------------------------------------------------------------ 116 // XAsynchronousExecutableDialog functions 117 //------------------------------------------------------------------------------------ 118 virtual void SAL_CALL setDialogTitle( const ::rtl::OUString& _rTitle ) throw (::com::sun::star::uno::RuntimeException); 119 virtual void SAL_CALL startExecuteModal( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 120 121 //------------------------------------------------------------------------------------ 122 // XFilePicker functions 123 //------------------------------------------------------------------------------------ 124 125 virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) throw( ::com::sun::star::uno::RuntimeException ); 126 virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName ) throw( ::com::sun::star::uno::RuntimeException ); 127 virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 128 virtual ::rtl::OUString SAL_CALL getDisplayDirectory() throw( ::com::sun::star::uno::RuntimeException ); 129 virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles() throw( ::com::sun::star::uno::RuntimeException ); 130 131 //------------------------------------------------------------------------------------ 132 // XFilePickerControlAccess functions 133 //------------------------------------------------------------------------------------ 134 135 virtual void SAL_CALL setValue( sal_Int16 ElementID, sal_Int16 ControlAction, const com::sun::star::uno::Any& value ) throw( ::com::sun::star::uno::RuntimeException ); 136 virtual com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 ElementID, sal_Int16 ControlAction ) throw( ::com::sun::star::uno::RuntimeException ); 137 virtual void SAL_CALL setLabel( sal_Int16 ElementID, const ::rtl::OUString& aValue ) throw ( ::com::sun::star::uno::RuntimeException ); 138 virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 ElementID ) throw ( ::com::sun::star::uno::RuntimeException ); 139 virtual void SAL_CALL enableControl( sal_Int16 ElementID, sal_Bool bEnable ) throw( ::com::sun::star::uno::RuntimeException ); 140 141 //------------------------------------------------------------------------------------ 142 // XFilePickerNotifier functions 143 //------------------------------------------------------------------------------------ 144 145 virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw ( ::com::sun::star::uno::RuntimeException ); 146 virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw ( ::com::sun::star::uno::RuntimeException ); 147 148 //------------------------------------------------------------------------------------ 149 // XFilePreview functions 150 //------------------------------------------------------------------------------------ 151 152 virtual com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats() throw ( ::com::sun::star::uno::RuntimeException ); 153 virtual sal_Int32 SAL_CALL getTargetColorDepth() throw ( ::com::sun::star::uno::RuntimeException ); 154 virtual sal_Int32 SAL_CALL getAvailableWidth() throw ( ::com::sun::star::uno::RuntimeException ); 155 virtual sal_Int32 SAL_CALL getAvailableHeight() throw ( ::com::sun::star::uno::RuntimeException ); 156 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 ); 157 virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw ( ::com::sun::star::uno::RuntimeException ); 158 virtual sal_Bool SAL_CALL getShowState() throw ( ::com::sun::star::uno::RuntimeException ); 159 160 //------------------------------------------------------------------------------------ 161 // XFilterManager functions 162 //------------------------------------------------------------------------------------ 163 164 virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 165 virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 166 virtual ::rtl::OUString SAL_CALL getCurrentFilter() throw( ::com::sun::star::uno::RuntimeException ); 167 168 //------------------------------------------------------------------------------------ 169 // XFilterGroupManager functions 170 //------------------------------------------------------------------------------------ 171 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); 172 173 //------------------------------------------------------------------------------------ 174 // XInitialization functions 175 //------------------------------------------------------------------------------------ 176 177 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 ); 178 179 //------------------------------------------------------------------------------------ 180 // XServiceInfo functions 181 //------------------------------------------------------------------------------------ 182 183 /* XServiceInfo */ 184 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); 185 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) throw( ::com::sun::star::uno::RuntimeException ); 186 virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 187 getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); 188 189 /* Helper for XServiceInfo */ 190 static com::sun::star::uno::Sequence< ::rtl::OUString > 191 impl_getStaticSupportedServiceNames(); 192 static ::rtl::OUString impl_getStaticImplementationName(); 193 194 /* Helper for registry */ 195 static ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL impl_createInstance ( 196 const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext ) 197 throw( com::sun::star::uno::Exception ); 198 199 protected: 200 //------------------------------------------------------------------------------------ 201 // OCommonPicker overridables 202 //------------------------------------------------------------------------------------ 203 virtual SvtFileDialog* implCreateDialog( Window* _pParent ); 204 virtual sal_Int16 implExecutePicker( ); 205 virtual sal_Bool implHandleInitializationArgument( 206 const ::rtl::OUString& _rName, 207 const ::com::sun::star::uno::Any& _rValue 208 ) 209 SAL_THROW( ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) ); 210 211 private: 212 WinBits getWinBits( WinBits& rExtraBits ); 213 virtual void notify( sal_Int16 _nEventId, sal_Int16 _nControlId ); 214 215 sal_Bool FilterNameExists( const ::rtl::OUString& rTitle ); 216 sal_Bool FilterNameExists( const UnoFilterList& _rGroupedFilters ); 217 218 void ensureFilterList( const ::rtl::OUString& _rInitialCurrentFilter ); 219 220 void prepareExecute( ); 221 222 DECL_LINK( DialogClosedHdl, Dialog* ); 223 }; 224 225 #endif // INCLUDED_SVT_FILEPICKER_HXX 226 227