LibreOffice Module fpicker (master) 1
iodlg.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include <memory>
22#include <com/sun/star/beans/StringPair.hpp>
23#include <com/sun/star/uno/Any.hxx>
24#include <com/sun/star/uno/Sequence.hxx>
25#include <com/sun/star/uno/Reference.hxx>
26#include <com/sun/star/ucb/IOErrorCode.hpp>
28#include "asyncfilepicker.hxx"
29#include "fpsmartcontent.hxx"
30#include "fpdialogbase.hxx"
32#include <vcl/timer.hxx>
33
34#include <set>
35#include <string_view>
36
37class SvtFileView;
40class SvtURLBox;
41
43 NONE = 0x0000,
44 NonEmpty = 0x0001,
45 Changed = 0x0002,
46 UserFilter = 0x0004,
47};
48namespace o3tl {
49 template<> struct typed_flags<AdjustFilterFlags> : is_typed_flags<AdjustFilterFlags, 0x0007> {};
50}
51
52
54{
55private:
56 std::unique_ptr<weld::CheckButton> m_xCbReadOnly;
57 std::unique_ptr<weld::CheckButton> m_xCbLinkBox;
58 std::unique_ptr<weld::CheckButton> m_xCbPreviewBox;
59 std::unique_ptr<weld::CheckButton> m_xCbSelection;
60 std::unique_ptr<weld::Button> m_xPbPlay;
61 std::unique_ptr<weld::Widget> m_xPreviewFrame;
62 std::unique_ptr<weld::Image> m_xPrevBmp;
63 std::unique_ptr<weld::Container> m_xContainer;
64 std::unique_ptr<SvtFileView> m_xFileView;
66 std::unique_ptr<SvtExpFileDlg_Impl> m_xImpl;
70
72
73 ::std::set<weld::Widget*> m_aDisabledControls;
74
80
81 DECL_LINK( FilterSelectHdl_Impl, weld::ComboBox&, void );
82 DECL_LINK( FilterSelectTimerHdl_Impl, Timer*, void );
83 DECL_LINK( NewFolderHdl_Impl, weld::Button&, void );
84 DECL_LINK( OpenUrlHdl_Impl, weld::ComboBox&, bool );
85 DECL_LINK( OpenClickHdl_Impl, weld::Button&, void );
86 DECL_LINK( CancelHdl_Impl, weld::Button&, void );
87 DECL_LINK( FileNameGetFocusHdl_Impl, weld::Widget&, void );
88 DECL_LINK( FileNameModifiedHdl_Impl, weld::ComboBox&, void );
89
90 DECL_LINK( URLBoxModifiedHdl_Impl, weld::ComboBox&, bool );
91 DECL_LINK( ConnectToServerPressed_Hdl, weld::Button&, void );
92
93 DECL_LINK( AddPlacePressed_Hdl, weld::Button&, void );
94 DECL_LINK( RemovePlacePressed_Hdl, weld::Button&, void );
95 DECL_LINK( PreviewSizeAllocHdl, const Size&, void);
96
97 void OpenHdl_Impl(void const * pVoid);
98
109 SvtFileDialogFilter_Impl* FindFilter_Impl( const OUString& _rFilter,
110 bool _bMultiExt,
111 bool& _rFilterChanged
112 );
113 void ExecuteFilter();
115 void AddControls_Impl( );
116
117 DECL_LINK(SelectHdl_Impl, SvtFileView*, void);
118 DECL_LINK(DblClickHdl_Impl, SvtFileView*, bool);
119 DECL_LINK(EntrySelectHdl_Impl, weld::ComboBox&, void);
120 DECL_LINK(OpenDoneHdl_Impl, SvtFileView*, void);
121 DECL_LINK(AutoExtensionHdl_Impl, weld::Toggleable&, void);
122 DECL_LINK(ClickHdl_Impl, weld::Toggleable&, void);
123 DECL_LINK(PlayButtonHdl_Impl, weld::Button&, void);
124 DECL_LINK(SizeAllocHdl, const Size&, void);
125
126 // removes a filter with wildcards from the path and returns it
127 static bool IsolateFilterFromPath_Impl( OUString& rPath, OUString& rFilter );
128
129 OUString m_aPath;
130 OUString m_aDefExt;
131
141 void EnableUI( bool _bEnable );
142
148 void EnableControl(weld::Widget* pControl, bool bEnable);
149 virtual bool PrepareExecute() override;
150
151public:
152 SvtFileDialog( weld::Window* pParent, PickerFlags nBits );
153 virtual ~SvtFileDialog() override;
154
155 virtual short run() override;
156
157 void FileSelect();
158 void FilterSelect() override;
159
160 void SetDenyList( const css::uno::Sequence< OUString >& rDenyList ) override;
161 const css::uno::Sequence< OUString >& GetDenyList() const override;
162 void SetStandardDir( const OUString& rStdDir ) override;
163 const OUString& GetStandardDir() const override;
164 std::vector<OUString> GetPathList() const override; // for MultiSelection
165
166 void AddFilter( const OUString& rFilter,
167 const OUString& rType ) override;
168
169 void AddFilterGroup(
170 const OUString& _rFilter,
171 const css::uno::Sequence< css::beans::StringPair >& rFilters ) override;
172
173 void SetCurFilter( const OUString& rFilter ) override;
174 OUString GetCurFilter() const override;
175 sal_uInt16 GetFilterCount() const;
176 const OUString& GetFilterName( sal_uInt16 nPos ) const;
177
178 void PrevLevel_Impl();
179 void OpenURL_Impl( const OUString& rURL );
180
181 SvtFileView* GetView() override;
182
183 void InitSize();
184 void UpdateControls( const OUString& rURL ) override;
185 void EnableAutocompletion( bool _bEnable = true ) override;
186
187 void SetFileCallback( ::svt::IFilePickerListener *pNotifier ) override { m_pFileNotifier = pNotifier; }
188
189 sal_Int32 getAvailableWidth() override;
190 sal_Int32 getAvailableHeight() override;
191 void setImage( const css::uno::Any& rImage ) override;
192 bool getShowState() override;
193 bool isAutoExtensionEnabled() const;
194
195 OUString getCurrentFileText( ) const override;
196 void setCurrentFileText( const OUString& _rText, bool _bSelectAll = false ) override;
197
198 void onAsyncOperationStarted() override;
199 void onAsyncOperationFinished() override;
200
201 void RemovablePlaceSelected(bool enable = true);
202
203 static void displayIOException( const OUString& _rURL, css::ucb::IOErrorCode _eCode );
204
205 // inline
206 inline void SetPath( const OUString& rNewURL ) override;
207 inline void SetHasFilename( bool bHasFilename ) override;
208 inline const OUString& GetPath() override;
209 inline void SetDefaultExt( const OUString& rExt );
210 inline void EraseDefaultExt( sal_Int32 _nIndex = 0 );
211 inline const OUString& GetDefaultExt() const;
212
213 bool ContentIsFolder( const OUString& rURL ) override { return m_aContent.isFolder( rURL ) && m_aContent.isValid(); }
214 bool ContentHasParentFolder( const OUString& rURL );
215 bool ContentCanMakeFolder( const OUString& rURL );
216 bool ContentGetTitle( const OUString& rURL, OUString& rTitle );
217
218private:
219 SvtFileDialogFilter_Impl* implAddFilter( const OUString& _rFilter, const OUString& _rType );
220
224 void createNewUserFilter( const OUString& _rNewFilter );
225
226 AdjustFilterFlags adjustFilter( const OUString& _rFilter );
227
228 // IFilePickerController, needed by OControlAccess
229 virtual weld::Widget* getControl( sal_Int16 nControlId, bool bLabelControl = false ) const override;
230 virtual void enableControl( sal_Int16 _nControlId, bool _bEnable ) override;
231 virtual OUString getCurFilter( ) const override;
232
233 OUString implGetInitialURL( const OUString& _rPath, std::u16string_view _rFallback );
234
236 void executeAsync(
238 const OUString& _rURL,
239 const OUString& _rFilter
240 );
241
254 static void appendDefaultExtension(
255 OUString& _rFileName,
256 std::u16string_view _rFilterDefaultExtension,
257 const OUString& _rFilterExtensions);
258
259 void initDefaultPlaces( );
260};
261
262
263inline void SvtFileDialog::SetPath( const OUString& rNewURL )
264{
265 m_aPath = rNewURL;
266}
267
268
269inline void SvtFileDialog::SetHasFilename( bool bHasFilename )
270{
271 m_bHasFilename = bHasFilename;
272}
273
274
275inline const OUString& SvtFileDialog::GetPath()
276{
277 return m_aPath;
278}
279
280
281inline void SvtFileDialog::SetDefaultExt( const OUString& rExt )
282{
283 m_aDefExt = rExt;
284}
285
286inline void SvtFileDialog::EraseDefaultExt( sal_Int32 _nIndex )
287{
288 m_aDefExt = m_aDefExt.copy( 0, _nIndex );
289}
290
291inline const OUString& SvtFileDialog::GetDefaultExt() const
292{
293 return m_aDefExt;
294}
295
296
298{
299 return m_xFileView.get();
300}
301
302/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 nControlId
sal_uInt16 GetFilterCount() const
Definition: iodlg.cxx:1765
std::unique_ptr< SvtExpFileDlg_Impl > m_xImpl
Definition: iodlg.hxx:66
void SetDenyList(const css::uno::Sequence< OUString > &rDenyList) override
Definition: iodlg.cxx:1664
void EraseDefaultExt(sal_Int32 _nIndex=0)
Definition: iodlg.hxx:286
DECL_LINK(PreviewSizeAllocHdl, const Size &, void)
std::unique_ptr< weld::Container > m_xContainer
Definition: iodlg.hxx:63
static bool IsolateFilterFromPath_Impl(OUString &rPath, OUString &rFilter)
Definition: iodlg.cxx:1815
DECL_LINK(FilterSelectTimerHdl_Impl, Timer *, void)
DECL_LINK(EntrySelectHdl_Impl, weld::ComboBox &, void)
DECL_LINK(RemovePlacePressed_Hdl, weld::Button &, void)
void SetHasFilename(bool bHasFilename) override
Definition: iodlg.hxx:269
void EnableControl(weld::Widget *pControl, bool bEnable)
enables or disables a control
Definition: iodlg.cxx:1432
void OpenMultiSelection_Impl()
Definition: iodlg.cxx:1076
static void displayIOException(const OUString &_rURL, css::ucb::IOErrorCode _eCode)
Definition: iodlg.cxx:1379
SvtFileView * GetView() override
Definition: iodlg.hxx:297
bool isAutoExtensionEnabled() const
Definition: iodlg.cxx:2207
virtual void enableControl(sal_Int16 _nControlId, bool _bEnable) override
Definition: iodlg.cxx:2028
DECL_LINK(FileNameModifiedHdl_Impl, weld::ComboBox &, void)
void EnableAutocompletion(bool _bEnable=true) override
Definition: iodlg.cxx:901
DECL_LINK(FilterSelectHdl_Impl, weld::ComboBox &, void)
SvtFileDialogFilter_Impl * implAddFilter(const OUString &_rFilter, const OUString &_rType)
Definition: iodlg.cxx:1701
DECL_LINK(AutoExtensionHdl_Impl, weld::Toggleable &, void)
bool getShowState() override
Definition: iodlg.cxx:2212
DECL_LINK(ConnectToServerPressed_Hdl, weld::Button &, void)
::svt::SmartContent m_aContent
Definition: iodlg.hxx:71
bool m_bHasFilename
Definition: iodlg.hxx:79
OUString m_aPath
Definition: iodlg.hxx:129
DECL_LINK(OpenUrlHdl_Impl, weld::ComboBox &, bool)
OUString m_aDefExt
Definition: iodlg.hxx:130
void SetFileCallback(::svt::IFilePickerListener *pNotifier) override
Definition: iodlg.hxx:187
DECL_LINK(SizeAllocHdl, const Size &, void)
AdjustFilterFlags adjustFilter(const OUString &_rFilter)
Definition: iodlg.cxx:551
DECL_LINK(NewFolderHdl_Impl, weld::Button &, void)
bool ContentCanMakeFolder(const OUString &rURL)
Definition: iodlg.cxx:2230
SvtFileDialogFilter_Impl * FindFilter_Impl(const OUString &_rFilter, bool _bMultiExt, bool &_rFilterChanged)
find a filter with the given wildcard
Definition: iodlg.cxx:1009
void ExecuteFilter()
Definition: iodlg.cxx:1067
std::unique_ptr< SvtFileView > m_xFileView
Definition: iodlg.hxx:64
std::unique_ptr< weld::CheckButton > m_xCbPreviewBox
Definition: iodlg.hxx:58
void SetDefaultExt(const OUString &rExt)
Definition: iodlg.hxx:281
void onAsyncOperationFinished() override
Definition: iodlg.cxx:1364
void FileSelect()
Definition: iodlg.cxx:1637
std::unique_ptr< weld::CheckButton > m_xCbSelection
Definition: iodlg.hxx:59
virtual short run() override
Definition: iodlg.cxx:1325
std::unique_ptr< weld::Button > m_xPbPlay
Definition: iodlg.hxx:60
void onAsyncOperationStarted() override
Definition: iodlg.cxx:1356
std::vector< OUString > GetPathList() const override
Definition: iodlg.cxx:1795
DECL_LINK(ClickHdl_Impl, weld::Toggleable &, void)
void SetPath(const OUString &rNewURL) override
Definition: iodlg.hxx:263
bool ContentGetTitle(const OUString &rURL, OUString &rTitle)
Definition: iodlg.cxx:2240
DECL_LINK(CancelHdl_Impl, weld::Button &, void)
OUString getCurrentFileText() const override
Definition: iodlg.cxx:2189
void EnableUI(bool _bEnable)
enables or disables the complete UI of the file picker, with only offering a cancel button
Definition: iodlg.cxx:1419
void initDefaultPlaces()
Definition: iodlg.cxx:2281
DECL_LINK(AddPlacePressed_Hdl, weld::Button &, void)
static void appendDefaultExtension(OUString &_rFileName, std::u16string_view _rFilterDefaultExtension, const OUString &_rFilterExtensions)
helper function to check and append the default filter extension if necessary.
Definition: iodlg.cxx:2254
bool m_bInExecuteAsync
Definition: iodlg.hxx:78
void setImage(const css::uno::Any &rImage) override
Definition: iodlg.cxx:2166
void OpenURL_Impl(const OUString &rURL)
Definition: iodlg.cxx:1694
const OUString & GetStandardDir() const override
Definition: iodlg.cxx:1680
bool m_bIsInExecute
Definition: iodlg.hxx:69
const OUString & GetDefaultExt() const
Definition: iodlg.hxx:291
void executeAsync(::svt::AsyncPickerAction::Action _eAction, const OUString &_rURL, const OUString &_rFilter)
executes a certain FileView action asynchronously
Definition: iodlg.cxx:1616
void SetCurFilter(const OUString &rFilter) override
Definition: iodlg.cxx:1731
void OpenHdl_Impl(void const *pVoid)
Definition: iodlg.cxx:607
DECL_LINK(DblClickHdl_Impl, SvtFileView *, bool)
OUString GetCurFilter() const override
Definition: iodlg.cxx:1749
Size m_aPreviewSize
Definition: iodlg.hxx:67
void AddControls_Impl()
Definition: iodlg.cxx:2038
::svt::IFilePickerListener * m_pFileNotifier
Definition: iodlg.hxx:65
std::unique_ptr< weld::Widget > m_xPreviewFrame
Definition: iodlg.hxx:61
OUString implGetInitialURL(const OUString &_rPath, std::u16string_view _rFallback)
Definition: iodlg.cxx:1273
void FilterSelect() override
Definition: iodlg.cxx:1644
void createNewUserFilter(const OUString &_rNewFilter)
updates m_xUserFilter with a new filter
Definition: iodlg.cxx:529
void AddFilter(const OUString &rFilter, const OUString &rType) override
Definition: iodlg.cxx:1712
void SetStandardDir(const OUString &rStdDir) override
Definition: iodlg.cxx:1656
DECL_LINK(URLBoxModifiedHdl_Impl, weld::ComboBox &, bool)
sal_Int32 getAvailableWidth() override
Definition: iodlg.cxx:2150
std::unique_ptr< weld::CheckButton > m_xCbReadOnly
Definition: iodlg.hxx:56
::rtl::Reference< ::svt::AsyncPickerAction > m_pCurrentAsyncAction
Definition: iodlg.hxx:77
const OUString & GetPath() override
Definition: iodlg.hxx:275
void setCurrentFileText(const OUString &_rText, bool _bSelectAll=false) override
Definition: iodlg.cxx:2197
virtual bool PrepareExecute() override
Definition: iodlg.cxx:1452
PickerFlags m_nPickerFlags
Definition: iodlg.hxx:68
DECL_LINK(OpenClickHdl_Impl, weld::Button &, void)
DECL_LINK(SelectHdl_Impl, SvtFileView *, void)
bool ContentHasParentFolder(const OUString &rURL)
Definition: iodlg.cxx:2220
SvtFileDialog(weld::Window *pParent, PickerFlags nBits)
Definition: iodlg.cxx:277
sal_Int32 getAvailableHeight() override
Definition: iodlg.cxx:2158
void InitSize()
Definition: iodlg.cxx:1776
const OUString & GetFilterName(sal_uInt16 nPos) const
Definition: iodlg.cxx:1770
void AddFilterGroup(const OUString &_rFilter, const css::uno::Sequence< css::beans::StringPair > &rFilters) override
Definition: iodlg.cxx:1719
void PrevLevel_Impl()
Definition: iodlg.cxx:1686
virtual OUString getCurFilter() const override
Definition: iodlg.cxx:1760
virtual weld::Widget * getControl(sal_Int16 nControlId, bool bLabelControl=false) const override
Definition: iodlg.cxx:1890
DECL_LINK(PlayButtonHdl_Impl, weld::Button &, void)
virtual ~SvtFileDialog() override
Definition: iodlg.cxx:464
DECL_LINK(FileNameGetFocusHdl_Impl, weld::Widget &, void)
void RemovablePlaceSelected(bool enable=true)
Definition: iodlg.cxx:1374
const css::uno::Sequence< OUString > & GetDenyList() const override
Definition: iodlg.cxx:1670
std::unique_ptr< weld::Image > m_xPrevBmp
Definition: iodlg.hxx:62
DECL_LINK(OpenDoneHdl_Impl, SvtFileView *, void)
void UpdateControls(const OUString &rURL) override
Definition: iodlg.cxx:1086
bool ContentIsFolder(const OUString &rURL) override
Definition: iodlg.hxx:213
::std::set< weld::Widget * > m_aDisabledControls
Definition: iodlg.hxx:73
::utl::OConfigurationNode m_aConfiguration
Definition: iodlg.hxx:75
std::unique_ptr< weld::CheckButton > m_xCbLinkBox
Definition: iodlg.hxx:57
a "smart content" which basically wraps a UCB content, but caches some information so that repeatedly...
bool isValid() const
checks if the content is valid
bool isFolder(const OUString &_rURL)
binds to the given URL, checks whether or not it refers to a folder
PickerFlags
AdjustFilterFlags
Definition: iodlg.hxx:42
NONE