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