update emoji autocorrect entries from po-files
[LibreOffice.git] / fpicker / source / office / iodlg.hxx
blobbf01b492d9a9a0e81fda214bc3d8c28690517662
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>
43 #include <set>
45 // @@@ using namespace com::sun::star::ucb;
49 class SvTabListBox;
50 class SvtFileView;
51 class SvtFileDialogFilter_Impl;
55 #define SFXWB_INSERT ( 0x04000000L | WB_OPEN )
56 #define SFXWB_PASSWORD WB_PASSWORD
57 #define SFXWB_READONLY WB_READONLY
58 #define SFXWB_PATHDIALOG WB_PATH
59 #define SFXWB_CLASSPATH ( 0x08000000L | SFXWB_PATHDIALOG )
60 #define SFXWB_MULTISELECTION 0x20000000L // activate Multiselection
61 #define SFXWB_NOREMOTE 0x40000000L
63 #define SFX_EXTRA_AUTOEXTENSION 0x00000001L
64 #define SFX_EXTRA_FILTEROPTIONS 0x00000002L
65 #define SFX_EXTRA_SHOWVERSIONS 0x00000004L
66 #define SFX_EXTRA_INSERTASLINK 0x00000008L
67 #define SFX_EXTRA_SHOWPREVIEW 0x00000010L
68 #define SFX_EXTRA_TEMPLATES 0x00000020L
69 #define SFX_EXTRA_PLAYBUTTON 0x00000040L
70 #define SFX_EXTRA_SELECTION 0x00000080L
71 #define SFX_EXTRA_IMAGE_TEMPLATE 0x00000100L
73 #define FILEDIALOG_FILTER_ALL "*.*"
76 // SvtFileDialog
79 class SvtExpFileDlg_Impl;
80 class CustomContainer;
82 class SvtFileDialog : public ModalDialog, public ::svt::IFilePickerController
84 private:
85 VclPtr<CheckBox> _pCbReadOnly;
86 VclPtr<CheckBox> _pCbLinkBox;
87 VclPtr<CheckBox> _pCbPreviewBox;
88 VclPtr<CheckBox> _pCbSelection;
89 VclPtr<PushButton> _pPbPlay;
90 VclPtr<vcl::Window> _pPrevWin;
91 VclPtr<FixedBitmap> _pPrevBmp;
92 VclPtr<CustomContainer> _pContainer;
93 VclPtr<SvtFileView> _pFileView;
94 VclPtr<Splitter> _pSplitter;
95 ::svt::IFilePickerListener* _pFileNotifier;
96 SvtExpFileDlg_Impl* _pImp;
97 WinBits _nExtraBits;
98 bool _bIsInExecute : 1;
100 ImageList m_aImages;
101 ::svt::SmartContent m_aContent;
103 ::std::set< VclPtr<Control> > m_aDisabledControls;
105 ::utl::OConfigurationNode m_aConfiguration;
106 ::rtl::Reference< ::svt::AsyncPickerAction >
107 m_pCurrentAsyncAction;
108 ::com::sun::star::uno::Reference<
109 ::com::sun::star::ui::dialogs::XDialogClosedListener >
110 m_xListener;
111 bool m_bInExecuteAsync;
112 bool m_bHasFilename;
113 ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_context;
115 DECL_LINK( FilterSelectHdl_Impl, void* );
116 DECL_LINK_TYPED( FilterSelectTimerHdl_Impl, Timer*, void );
117 DECL_LINK( NewFolderHdl_Impl, PushButton* );
118 DECL_LINK( OpenHdl_Impl, void* );
119 DECL_LINK ( CancelHdl_Impl, void* );
120 DECL_LINK( FileNameGetFocusHdl_Impl, void* );
121 DECL_LINK( FileNameModifiedHdl_Impl, void* );
123 DECL_LINK( URLBoxModifiedHdl_Impl, void* );
124 DECL_LINK( ConnectToServerPressed_Hdl, void* );
126 DECL_LINK ( AddPlacePressed_Hdl, void* );
127 DECL_LINK ( RemovePlacePressed_Hdl, void* );
128 DECL_LINK ( Split_Hdl, void* );
130 void Init_Impl( WinBits nBits );
131 /** find a filter with the given wildcard
132 @param _rFilter
133 the wildcard pattern to look for in the filter list
134 @param _bMultiExt
135 allow for filters with more than one extension pattern
136 @param _rFilterChanged
137 set to <TRUE/> if the filter changed
138 @return
139 the filter which has been found
141 SvtFileDialogFilter_Impl* FindFilter_Impl( const OUString& _rFilter,
142 bool _bMultiExt,
143 bool& _rFilterChanged
145 void ExecuteFilter();
146 void OpenMultiSelection_Impl();
147 void AddControls_Impl( );
149 DECL_LINK( SelectHdl_Impl, SvTabListBox* );
150 DECL_LINK(DblClickHdl_Impl, void *);
151 DECL_LINK(EntrySelectHdl_Impl, void *);
152 DECL_LINK( OpenDoneHdl_Impl, SvtFileView* );
153 DECL_LINK(AutoExtensionHdl_Impl, void *);
154 DECL_LINK( ClickHdl_Impl, CheckBox* );
155 DECL_LINK(PlayButtonHdl_Impl, void *);
158 // removes a filter with wildcards from the path and returns it
159 static bool IsolateFilterFromPath_Impl( OUString& rPath, OUString& rFilter );
161 void implUpdateImages( );
163 protected:
164 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
165 void EnableInternet( bool bInternet );
167 // originally from VclFileDialog
168 Link<> _aOKHdl;
169 Link<> _aFileSelectHdl;
170 Link<> _aFilterSelectHdl;
172 OUString _aPath;
173 OUString _aDefExt;
175 /** enables or disables the complete UI of the file picker, with only offering a
176 cancel button
178 This method preserves the "enabled" state of its controls in the following sense:
179 If you disable a certain control, then disable the dialog UI, then enable the dialog
180 UI, the control will still be disabled.
181 This is under the assumption that you'll use EnableControl. Direct access to the control
182 (such as pControl->Enable()) will break this.
184 void EnableUI( bool _bEnable );
186 /** enables or disables a control
188 You are strongly encouraged to prefer this method over pControl->Enable( _bEnable ). See
189 <member>EnableUI</member> for details.
191 void EnableControl( Control* _pControl, bool _bEnable );
192 short PrepareExecute();
194 public:
195 SvtFileDialog( vcl::Window* _pParent, WinBits nBits, WinBits nExtraBits );
196 SvtFileDialog( vcl::Window* _pParent, WinBits nBits );
197 virtual ~SvtFileDialog();
198 virtual void dispose() SAL_OVERRIDE;
200 virtual short Execute() SAL_OVERRIDE;
201 virtual void StartExecuteModal( const Link<>& rEndDialogHdl ) SAL_OVERRIDE;
203 void FileSelect();
204 void FilterSelect();
206 void SetBlackList( const ::com::sun::star::uno::Sequence< OUString >& rBlackList );
207 const ::com::sun::star::uno::Sequence< OUString >& GetBlackList() const;
208 void SetStandardDir( const OUString& rStdDir );
209 const OUString& GetStandardDir() const;
210 std::vector<OUString> GetPathList() const; // for MultiSelection
212 void AddFilter( const OUString& rFilter,
213 const OUString& rType );
215 void AddFilterGroup(
216 const OUString& _rFilter,
217 const com::sun::star::uno::Sequence< com::sun::star::beans::StringPair >& rFilters );
219 void SetCurFilter( const OUString& rFilter );
220 OUString GetCurFilter() const;
221 sal_uInt16 GetFilterCount() const;
222 const OUString& GetFilterName( sal_uInt16 nPos ) const;
224 virtual void Resize() SAL_OVERRIDE;
225 virtual void DataChanged( const DataChangedEvent& _rDCEvt ) SAL_OVERRIDE;
227 void PrevLevel_Impl();
228 void OpenURL_Impl( const OUString& rURL );
230 inline SvtFileView* GetView() const;
232 void DisableSaveLastDirectory();
233 void InitSize();
234 void UpdateControls( const OUString& rURL );
235 void EnableAutocompletion( bool _bEnable = true );
237 void SetFileCallback( ::svt::IFilePickerListener *pNotifier ) { _pFileNotifier = pNotifier; }
239 sal_Int32 getTargetColorDepth();
240 sal_Int32 getAvailableWidth();
241 sal_Int32 getAvailableHeight();
242 void setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& rImage );
243 bool getShowState();
244 bool isAutoExtensionEnabled();
246 OUString getCurrentFileText( ) const;
247 void setCurrentFileText( const OUString& _rText, bool _bSelectAll = false );
249 void onAsyncOperationStarted();
250 void onAsyncOperationFinished();
252 void RemovablePlaceSelected(bool enable = true);
254 static void displayIOException( const OUString& _rURL, ::com::sun::star::ucb::IOErrorCode _eCode );
256 // inline
257 inline void SetPath( const OUString& rNewURL );
258 inline void SetHasFilename( bool bHasFilename );
259 inline const OUString& GetPath() const;
260 inline void SetDefaultExt( const OUString& rExt );
261 inline void EraseDefaultExt( sal_Int32 _nIndex = 0 );
262 inline const OUString& GetDefaultExt() const;
263 inline void SetOKHdl( const Link<>& rLink );
264 inline const Link<>& GetOKHdl() const;
265 inline void SetFileSelectHdl( const Link<>& rLink );
266 inline const Link<>& GetFileSelectHdl() const;
267 inline void SetFilterSelectHdl( const Link<>& rLink );
268 inline const Link<>& GetFilterSelectHdl() const;
270 inline Image GetButtonImage( sal_uInt16 _nButtonId ) const { return m_aImages.GetImage( _nButtonId ); }
272 bool ContentIsFolder( const OUString& rURL ) { return m_aContent.isFolder( rURL ) && m_aContent.isValid(); }
273 bool ContentHasParentFolder( const OUString& rURL );
274 bool ContentCanMakeFolder( const OUString& rURL );
275 bool ContentGetTitle( const OUString& rURL, OUString& rTitle );
277 private:
278 SvtFileDialogFilter_Impl* implAddFilter( const OUString& _rFilter, const OUString& _rType );
280 /** updates _pUserFilter with a new filter
281 <p>No checks for necessity are made.</p>
282 @param _bAllowUserDefExt
283 set to <TRUE/> if a filter like "*.txt" should reset the DefaultExtension to doc.
285 In a file-save-dialog this would have the following effect:<br/>
286 Say that auto-extension is checked, and the user enters *.txt, while a non-txt filter is selected.<br/>
287 If _bAllowUserDefExt is set to <TRUE/>, then a user input of "foo" would save a foo.txt, but in a format
288 which is determined by the filter selected (which is no txt file as said above).<br/>
289 If _bAllowUserDefExt is set to <FALSE/>, the default extension will be the one of the selected filter, means
290 in the above scenario a file "foo.<ext>" will be saved where ext is the extension of the selected filter.
291 </p>
292 @return <TRUE/> if the new filter is "*.*"
294 bool createNewUserFilter( const OUString& _rNewFilter, bool _bAllowUserDefExt );
296 sal_uInt16 adjustFilter( const OUString& _rFilter );
298 // IFilePickerController, needed by OControlAccess
299 virtual Control* getControl( sal_Int16 _nControlId, bool _bLabelControl = false ) const SAL_OVERRIDE;
300 virtual void enableControl( sal_Int16 _nControlId, bool _bEnable ) SAL_OVERRIDE;
301 virtual OUString getCurFilter( ) const SAL_OVERRIDE;
303 OUString implGetInitialURL( const OUString& _rPath, const OUString& _rFallback );
305 /// executes a certain FileView action asynchronously
306 void executeAsync(
307 ::svt::AsyncPickerAction::Action _eAction,
308 const OUString& _rURL,
309 const OUString& _rFilter
312 /** helper function to check and append the default filter extension if
313 necessary.
314 The function checks if the specified filename already contains one of
315 the valid extensions of the specified filter. If not the filter default
316 extension is appended to the filename.
318 @param _rFileName the filename which is checked and extended if necessary.
319 @param _rFilterDefaultExtension the default extension of the used filter.
320 @param _rFilterExtensions a list of one or more valid filter extensions
321 of the used filter.
324 static void appendDefaultExtension(
325 OUString& _rFileName,
326 const OUString& _rFilterDefaultExtension,
327 const OUString& _rFilterExtensions);
329 void initDefaultPlaces( );
334 inline void SvtFileDialog::SetPath( const OUString& rNewURL )
336 _aPath = rNewURL;
341 inline void SvtFileDialog::SetHasFilename( bool bHasFilename )
343 m_bHasFilename = bHasFilename;
348 inline const OUString& SvtFileDialog::GetPath() const
350 return _aPath;
355 inline void SvtFileDialog::SetDefaultExt( const OUString& rExt )
357 _aDefExt = rExt;
360 inline void SvtFileDialog::EraseDefaultExt( sal_Int32 _nIndex )
362 _aDefExt = _aDefExt.copy( 0, _nIndex );
365 inline const OUString& SvtFileDialog::GetDefaultExt() const
367 return _aDefExt;
372 inline void SvtFileDialog::SetOKHdl
374 const Link<>& rLink
377 _aOKHdl = rLink;
382 inline const Link<>& SvtFileDialog::GetOKHdl() const
384 return _aOKHdl;
389 inline void SvtFileDialog::SetFileSelectHdl
391 const Link<>& rLink
394 _aFileSelectHdl = rLink;
399 inline const Link<>& SvtFileDialog::GetFileSelectHdl() const
401 return _aFileSelectHdl;
406 inline void SvtFileDialog::SetFilterSelectHdl
408 const Link<>& rLink
411 _aFilterSelectHdl = rLink;
416 inline const Link<>& SvtFileDialog::GetFilterSelectHdl() const
418 return _aFilterSelectHdl;
423 inline SvtFileView* SvtFileDialog::GetView() const
425 return _pFileView;
432 #define FILE_SELECTION_CHANGED 1
433 #define DIRECTORY_CHANGED 2
434 #define HELP_REQUESTED 3
435 #define CTRL_STATE_CHANGED 4
436 #define DIALOG_SIZE_CHANGED 5
439 #endif // INCLUDED_FPICKER_SOURCE_OFFICE_IODLG_HXX
441 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */