build fix
[LibreOffice.git] / fpicker / source / office / iodlg.hxx
blob49c43e2c9aa16c8c97b1e23557065b0eb73bd7d6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_FPICKER_SOURCE_OFFICE_IODLG_HXX
20 #define INCLUDED_FPICKER_SOURCE_OFFICE_IODLG_HXX
22 #include <vcl/dialog.hxx>
23 #include <vcl/button.hxx>
24 #include <vcl/fixed.hxx>
25 #include <vcl/edit.hxx>
26 #include <vcl/combobox.hxx>
27 #include <vcl/lstbox.hxx>
28 #include <vcl/split.hxx>
29 #include <com/sun/star/beans/StringPair.hpp>
30 #include <com/sun/star/uno/Any.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include <com/sun/star/uno/Reference.hxx>
33 #include <com/sun/star/ucb/IOErrorCode.hpp>
34 #include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp>
35 #include <unotools/confignode.hxx>
36 #include "svl/inettype.hxx"
37 #include "asyncfilepicker.hxx"
38 #include "OfficeControlAccess.hxx"
39 #include "fpsmartcontent.hxx"
40 #include <comphelper/configuration.hxx>
41 #include <comphelper/processfactory.hxx>
42 #include "fpdialogbase.hxx"
44 #include <set>
47 class SvTabListBox;
48 class SvtFileView;
49 class SvtFileDialogFilter_Impl;
50 class SvtURLBox;
51 class SvtExpFileDlg_Impl;
52 class CustomContainer;
54 class SvtFileDialog : public SvtFileDialog_Base
56 private:
57 VclPtr<CheckBox> _pCbReadOnly;
58 VclPtr<CheckBox> _pCbLinkBox;
59 VclPtr<CheckBox> _pCbPreviewBox;
60 VclPtr<CheckBox> _pCbSelection;
61 VclPtr<PushButton> _pPbPlay;
62 VclPtr<vcl::Window> _pPrevWin;
63 VclPtr<FixedBitmap> _pPrevBmp;
64 VclPtr<CustomContainer> _pContainer;
65 VclPtr<SvtFileView> _pFileView;
66 VclPtr<Splitter> _pSplitter;
67 ::svt::IFilePickerListener* _pFileNotifier;
68 std::unique_ptr<SvtExpFileDlg_Impl> pImpl;
69 PickerFlags _nPickerFlags;
70 bool _bIsInExecute : 1;
72 ImageList m_aImages;
73 ::svt::SmartContent m_aContent;
75 ::std::set< VclPtr<Control> >
76 m_aDisabledControls;
78 ::utl::OConfigurationNode m_aConfiguration;
79 ::rtl::Reference< ::svt::AsyncPickerAction >
80 m_pCurrentAsyncAction;
81 bool m_bInExecuteAsync;
82 bool m_bHasFilename;
83 css::uno::Reference < css::uno::XComponentContext >
84 m_context;
86 DECL_LINK( FilterSelectHdl_Impl, ListBox&, void );
87 DECL_LINK( FilterSelectTimerHdl_Impl, Timer*, void );
88 DECL_LINK( NewFolderHdl_Impl, Button*, void );
89 DECL_LINK( OpenUrlHdl_Impl, SvtURLBox*, void );
90 DECL_LINK( OpenClickHdl_Impl, Button*, void );
91 DECL_LINK( CancelHdl_Impl, Button*, void );
92 DECL_LINK( FileNameGetFocusHdl_Impl, Control&, void );
93 DECL_LINK( FileNameModifiedHdl_Impl, Edit&, void );
95 DECL_LINK( URLBoxModifiedHdl_Impl, SvtURLBox*, void );
96 DECL_LINK( ConnectToServerPressed_Hdl, Button*, void );
98 DECL_LINK( AddPlacePressed_Hdl, Button*, void );
99 DECL_LINK( RemovePlacePressed_Hdl, Button*, void );
100 DECL_LINK( Split_Hdl, Splitter*, void );
102 void OpenHdl_Impl(void* pVoid);
103 void Init_Impl( PickerFlags nBits );
104 /** find a filter with the given wildcard
105 @param _rFilter
106 the wildcard pattern to look for in the filter list
107 @param _bMultiExt
108 allow for filters with more than one extension pattern
109 @param _rFilterChanged
110 set to <TRUE/> if the filter changed
111 @return
112 the filter which has been found
114 SvtFileDialogFilter_Impl* FindFilter_Impl( const OUString& _rFilter,
115 bool _bMultiExt,
116 bool& _rFilterChanged
118 void ExecuteFilter();
119 void OpenMultiSelection_Impl();
120 void AddControls_Impl( );
122 DECL_LINK( SelectHdl_Impl, SvTreeListBox*, void );
123 DECL_LINK( DblClickHdl_Impl, SvTreeListBox*, bool);
124 DECL_LINK( EntrySelectHdl_Impl, ComboBox&, void);
125 DECL_LINK( OpenDoneHdl_Impl, SvtFileView*, void );
126 DECL_LINK( AutoExtensionHdl_Impl, Button*, void);
127 DECL_LINK( ClickHdl_Impl, Button*, void );
128 DECL_LINK( PlayButtonHdl_Impl, Button*, void);
131 // removes a filter with wildcards from the path and returns it
132 static bool IsolateFilterFromPath_Impl( OUString& rPath, OUString& rFilter );
134 void implUpdateImages( );
136 protected:
137 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
139 OUString _aPath;
140 OUString _aDefExt;
142 /** enables or disables the complete UI of the file picker, with only offering a
143 cancel button
145 This method preserves the "enabled" state of its controls in the following sense:
146 If you disable a certain control, then disable the dialog UI, then enable the dialog
147 UI, the control will still be disabled.
148 This is under the assumption that you'll use EnableControl. Direct access to the control
149 (such as pControl->Enable()) will break this.
151 void EnableUI( bool _bEnable );
153 /** enables or disables a control
155 You are strongly encouraged to prefer this method over pControl->Enable( _bEnable ). See
156 <member>EnableUI</member> for details.
158 void EnableControl( Control* _pControl, bool _bEnable );
159 short PrepareExecute();
161 public:
162 SvtFileDialog( vcl::Window* _pParent, PickerFlags nBits );
163 virtual ~SvtFileDialog() override;
164 virtual void dispose() override;
166 virtual short Execute() override;
167 virtual void StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) override;
169 void FileSelect();
170 void FilterSelect() override;
172 void SetBlackList( const css::uno::Sequence< OUString >& rBlackList ) override;
173 const css::uno::Sequence< OUString >& GetBlackList() const override;
174 void SetStandardDir( const OUString& rStdDir ) override;
175 const OUString& GetStandardDir() const override;
176 std::vector<OUString> GetPathList() const override; // for MultiSelection
178 void AddFilter( const OUString& rFilter,
179 const OUString& rType ) override;
181 void AddFilterGroup(
182 const OUString& _rFilter,
183 const css::uno::Sequence< css::beans::StringPair >& rFilters ) override;
185 void SetCurFilter( const OUString& rFilter ) override;
186 OUString GetCurFilter() const override;
187 sal_uInt16 GetFilterCount() const;
188 const OUString& GetFilterName( sal_uInt16 nPos ) const;
190 virtual void Resize() override;
191 virtual void DataChanged( const DataChangedEvent& _rDCEvt ) override;
193 void PrevLevel_Impl();
194 void OpenURL_Impl( const OUString& rURL );
196 SvtFileView* GetView() override;
198 void InitSize();
199 void UpdateControls( const OUString& rURL ) override;
200 void EnableAutocompletion( bool _bEnable = true ) override;
202 void SetFileCallback( ::svt::IFilePickerListener *pNotifier ) override { _pFileNotifier = pNotifier; }
204 sal_Int32 getTargetColorDepth() override;
205 sal_Int32 getAvailableWidth() override;
206 sal_Int32 getAvailableHeight() override;
207 void setImage( sal_Int16 aImageFormat, const css::uno::Any& rImage ) override;
208 bool getShowState() override;
209 bool isAutoExtensionEnabled();
211 OUString getCurrentFileText( ) const override;
212 void setCurrentFileText( const OUString& _rText, bool _bSelectAll = false ) override;
214 void onAsyncOperationStarted() override;
215 void onAsyncOperationFinished() override;
217 void RemovablePlaceSelected(bool enable = true);
219 static void displayIOException( const OUString& _rURL, css::ucb::IOErrorCode _eCode );
221 // inline
222 inline void SetPath( const OUString& rNewURL ) override;
223 inline void SetHasFilename( bool bHasFilename ) override;
224 inline const OUString& GetPath() override;
225 inline void SetDefaultExt( const OUString& rExt );
226 inline void EraseDefaultExt( sal_Int32 _nIndex = 0 );
227 inline const OUString& GetDefaultExt() const;
229 inline Image GetButtonImage( sal_uInt16 _nButtonId ) const { return m_aImages.GetImage( _nButtonId ); }
231 bool ContentIsFolder( const OUString& rURL ) override { return m_aContent.isFolder( rURL ) && m_aContent.isValid(); }
232 bool ContentHasParentFolder( const OUString& rURL );
233 bool ContentCanMakeFolder( const OUString& rURL );
234 bool ContentGetTitle( const OUString& rURL, OUString& rTitle );
236 private:
237 SvtFileDialogFilter_Impl* implAddFilter( const OUString& _rFilter, const OUString& _rType );
239 /** updates _pUserFilter with a new filter
240 <p>No checks for necessity are made.</p>
241 @return <TRUE/> if the new filter is "*.*"
243 bool createNewUserFilter( const OUString& _rNewFilter );
245 sal_uInt16 adjustFilter( const OUString& _rFilter );
247 // IFilePickerController, needed by OControlAccess
248 virtual Control* getControl( sal_Int16 _nControlId, bool _bLabelControl = false ) const override;
249 virtual void enableControl( sal_Int16 _nControlId, bool _bEnable ) override;
250 virtual OUString getCurFilter( ) const override;
252 OUString implGetInitialURL( const OUString& _rPath, const OUString& _rFallback );
254 /// executes a certain FileView action asynchronously
255 void executeAsync(
256 ::svt::AsyncPickerAction::Action _eAction,
257 const OUString& _rURL,
258 const OUString& _rFilter
261 /** helper function to check and append the default filter extension if
262 necessary.
263 The function checks if the specified filename already contains one of
264 the valid extensions of the specified filter. If not the filter default
265 extension is appended to the filename.
267 @param _rFileName the filename which is checked and extended if necessary.
268 @param _rFilterDefaultExtension the default extension of the used filter.
269 @param _rFilterExtensions a list of one or more valid filter extensions
270 of the used filter.
273 static void appendDefaultExtension(
274 OUString& _rFileName,
275 const OUString& _rFilterDefaultExtension,
276 const OUString& _rFilterExtensions);
278 void initDefaultPlaces( );
282 inline void SvtFileDialog::SetPath( const OUString& rNewURL )
284 _aPath = rNewURL;
288 inline void SvtFileDialog::SetHasFilename( bool bHasFilename )
290 m_bHasFilename = bHasFilename;
294 inline const OUString& SvtFileDialog::GetPath()
296 return _aPath;
300 inline void SvtFileDialog::SetDefaultExt( const OUString& rExt )
302 _aDefExt = rExt;
305 inline void SvtFileDialog::EraseDefaultExt( sal_Int32 _nIndex )
307 _aDefExt = _aDefExt.copy( 0, _nIndex );
310 inline const OUString& SvtFileDialog::GetDefaultExt() const
312 return _aDefExt;
316 inline SvtFileView* SvtFileDialog::GetView()
318 return _pFileView;
322 #endif // INCLUDED_FPICKER_SOURCE_OFFICE_IODLG_HXX
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */