LibreOffice Module fpicker (master) 1
iodlg.cxx
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
20#include <sal/config.h>
21
22#include <sal/log.hxx>
23#include "fileview.hxx"
24#include "iodlg.hxx"
27#include "PlacesListBox.hxx"
29#include <tools/debug.hxx>
31#include <tools/stream.hxx>
32#include <tools/urlobj.hxx>
33#include <vcl/errinf.hxx>
34#include <vcl/graph.hxx>
35#include <vcl/svapp.hxx>
36#include <vcl/timer.hxx>
40#include <svtools/sfxecode.hxx>
41
42#include <fpicker/strings.hrc>
43#include <svtools/helpids.h>
44#include <strings.hrc>
45#include "asyncfilepicker.hxx"
46#include "iodlgimp.hxx"
47#include <svtools/inettbc.hxx>
48#include "QueryFolderName.hxx"
49#include <rtl/ustring.hxx>
50#include <com/sun/star/ucb/UniversalContentBroker.hpp>
51#include <com/sun/star/ucb/CommandAbortedException.hpp>
52#include <com/sun/star/ucb/ContentCreationException.hpp>
53#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
54#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
55#include <com/sun/star/beans/PropertyValue.hpp>
56#include <com/sun/star/sdbc/XResultSet.hpp>
57#include <com/sun/star/uno/Exception.hpp>
58#include <com/sun/star/uno/Reference.hxx>
59#include <com/sun/star/beans/XPropertySet.hpp>
60
62#include <comphelper/lok.hxx>
64#include <comphelper/string.hxx>
65
66#include <osl/file.hxx>
67#include <vcl/dibtools.hxx>
68
69#include <com/sun/star/task/InteractionHandler.hpp>
70#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
71#include "fpinteraction.hxx"
72#include <osl/process.h>
73#include <o3tl/string_view.hxx>
74
75#include <officecfg/Office/Common.hxx>
76
77#include <algorithm>
78#include <memory>
79#include <string_view>
80
81using namespace ::com::sun::star::beans;
82using namespace ::com::sun::star::ui::dialogs;
83using namespace ::com::sun::star::uno;
84using namespace ::com::sun::star::lang;
85using namespace ::com::sun::star::ucb;
86using namespace ::com::sun::star::container;
87using namespace ::com::sun::star::task;
88using namespace ::com::sun::star::sdbc;
89using namespace ::utl;
90using namespace ::svt;
91
92using namespace ExtendedFilePickerElementIds;
93using namespace CommonFilePickerElementIds;
94using namespace InternalFilePickerElementIds;
95
96// functions -------------------------------------------------------------
97
98namespace
99{
100 OUString getMostCurrentFilter( std::unique_ptr<SvtExpFileDlg_Impl> const & pImpl )
101 {
102 assert( pImpl && "invalid impl pointer" );
103 const SvtFileDialogFilter_Impl* pFilter = pImpl->m_xUserFilter.get();
104
105 if ( !pFilter )
106 pFilter = pImpl->GetCurFilter();
107
108 if ( !pFilter )
109 return OUString();
110
111 return pFilter->GetType();
112 }
113
114 void restoreCurrentFilter( std::unique_ptr<SvtExpFileDlg_Impl> const & pImpl )
115 {
116 SAL_WARN_IF( !pImpl->GetCurFilter(), "fpicker.office", "restoreCurrentFilter: no current filter!" );
117 SAL_WARN_IF( pImpl->GetCurFilterDisplayName().isEmpty(), "fpicker.office", "restoreCurrentFilter: no current filter (no display name)!" );
118
119 pImpl->SelectFilterListEntry( pImpl->GetCurFilterDisplayName() );
120
121#ifdef DBG_UTIL
122 OUString sSelectedDisplayName;
123 DBG_ASSERT( ( pImpl->GetSelectedFilterEntry( sSelectedDisplayName ) == pImpl->GetCurFilter() )
124 && ( sSelectedDisplayName == pImpl->GetCurFilterDisplayName() ),
125 "restoreCurrentFilter: inconsistence!" );
126#endif
127 }
128
129
130 OUString GetFsysExtension_Impl( std::u16string_view rFile, const OUString& rLastFilterExt )
131 {
132 size_t nDotPos = rFile.rfind( '.' );
133 if ( nDotPos != std::u16string_view::npos )
134 {
135 if ( !rLastFilterExt.isEmpty() )
136 {
137 if ( o3tl::equalsIgnoreAsciiCase(rFile.substr( nDotPos + 1 ), rLastFilterExt ) )
138 return rLastFilterExt;
139 }
140 else
141 return OUString(rFile.substr( nDotPos ));
142 }
143 return OUString();
144 }
145
146
147 void SetFsysExtension_Impl( OUString& rFile, std::u16string_view rExtension )
148 {
149 const sal_Int32 nDotPos{ rFile.lastIndexOf('.') };
150 if (nDotPos>=0)
151 {
152 if (!rExtension.empty())
153 rFile = OUString::Concat(rFile.subView(0, nDotPos)) + rExtension; // replace old extension with new (not empty) one
154 else if (nDotPos)
155 rFile = rFile.copy(0, nDotPos-1); // truncate extension (new one is empty)
156 else
157 rFile.clear(); // Filename was just an extension
158 }
159 else if (!rExtension.empty())
160 rFile += OUString::Concat(".") + rExtension;
161 // no extension was present, append new one if not empty
162 }
163
164 void lcl_autoUpdateFileExtension( SvtFileDialog* _pDialog, const OUString& _rLastFilterExt )
165 {
166 // if auto extension is enabled...
167 if ( !_pDialog->isAutoExtensionEnabled() )
168 return;
169
170 // automatically switch to the extension of the (maybe just newly selected) extension
171 OUString aNewFile = _pDialog->getCurrentFileText( );
172 OUString aExt = GetFsysExtension_Impl( aNewFile, _rLastFilterExt );
173
174 // but only if there already is an extension
175 if ( aExt.isEmpty() )
176 return;
177
178 // check if it is a real file extension, and not only the "post-dot" part in
179 // a directory name
180 bool bRealExtensions = true;
181 if ( -1 != aExt.indexOf( '/' ) )
182 bRealExtensions = false;
183 else if ( -1 != aExt.indexOf( '\\' ) )
184 bRealExtensions = false;
185 else
186 {
187 // no easy way to tell, because the part containing the dot already is the last
188 // segment of the complete file name
189 // So we have to check if the file name denotes a folder or a file.
190 // For performance reasons, we do this for file urls only
191 INetURLObject aURL( aNewFile );
192 if ( INetProtocol::NotValid == aURL.GetProtocol() )
193 {
194 OUString sURL;
195 if ( osl::FileBase::getFileURLFromSystemPath( aNewFile, sURL )
196 == osl::FileBase::E_None )
197 aURL = INetURLObject( sURL );
198 }
199 if ( INetProtocol::File == aURL.GetProtocol() )
200 {
201 try
202 {
203 bRealExtensions = !_pDialog->ContentIsFolder( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
204 }
205 catch( const css::uno::Exception& )
206 {
207 SAL_INFO( "fpicker.office", "Exception in lcl_autoUpdateFileExtension" );
208 }
209 }
210 }
211
212 if ( bRealExtensions )
213 {
214 SetFsysExtension_Impl( aNewFile, _pDialog->GetDefaultExt() );
215 _pDialog->setCurrentFileText( aNewFile );
216 }
217 }
218
219#if defined( UNX )
220 bool lcl_getHomeDirectory( const OUString& _rForURL, OUString& /* [out] */ _rHomeDir )
221 {
222 _rHomeDir.clear();
223
224 // now ask the content broker for a provider for this scheme
225
226 try
227 {
228 // get the provider for the current scheme
229 Reference< XContentProvider > xProvider(
230 UniversalContentBroker::create(
232 queryContentProvider( _rForURL ) );
233
234 SAL_WARN_IF( !xProvider.is(), "fpicker.office", "lcl_getHomeDirectory: could not find a (valid) content provider for the current URL!" );
235 Reference< XPropertySet > xProviderProps( xProvider, UNO_QUERY );
236 if ( xProviderProps.is() )
237 {
238 Reference< XPropertySetInfo > xPropInfo = xProviderProps->getPropertySetInfo();
239 static constexpr OUStringLiteral sHomeDirPropertyName( u"HomeDirectory" );
240 if ( !xPropInfo.is() || xPropInfo->hasPropertyByName( sHomeDirPropertyName ) )
241 {
242 OUString sHomeDirectory;
243 xProviderProps->getPropertyValue( sHomeDirPropertyName ) >>= sHomeDirectory;
244 _rHomeDir = sHomeDirectory;
245 }
246 }
247 }
248 catch( const Exception& )
249 {
250 TOOLS_WARN_EXCEPTION( "fpicker", "lcl_getHomeDirectory" );
251 }
252 return !_rHomeDir.isEmpty();
253 }
254#endif
255
256 OUString lcl_ensureFinalSlash( std::u16string_view _rDir )
257 {
258 INetURLObject aWorkPathObj( _rDir, INetProtocol::File );
259 aWorkPathObj.setFinalSlash();
260 return aWorkPathObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
261 }
262
263
267 bool getEnvironmentValue( const char* _pAsciiEnvName, OUString& _rValue )
268 {
269 _rValue.clear();
270 OUString sEnvName = OUString::createFromAscii( _pAsciiEnvName );
271 osl_getEnvironment( sEnvName.pData, &_rValue.pData );
272 return !_rValue.isEmpty();
273 }
274}
275
276// SvtFileDialog
278 : SvtFileDialog_Base(pParent, "fps/ui/explorerfiledialog.ui", "ExplorerFileDialog")
279 , m_xCbReadOnly(m_xBuilder->weld_check_button("readonly"))
280 , m_xCbLinkBox(m_xBuilder->weld_check_button("link"))
281 , m_xCbPreviewBox(m_xBuilder->weld_check_button("cb_preview"))
282 , m_xCbSelection(m_xBuilder->weld_check_button("selection"))
283 , m_xPbPlay(m_xBuilder->weld_button("play"))
284 , m_xPreviewFrame(m_xBuilder->weld_widget("previewframe"))
285 , m_xPrevBmp(m_xBuilder->weld_image("preview"))
286 , m_pFileNotifier(nullptr)
287 , m_xImpl(new SvtExpFileDlg_Impl)
288 , m_nPickerFlags(nStyle)
289 , m_bIsInExecute(false)
290 , m_bInExecuteAsync(false)
291 , m_bHasFilename(false)
292{
293 m_xImpl->m_xCbOptions = m_xBuilder->weld_check_button("options");
294 m_xImpl->m_xFtFileName = m_xBuilder->weld_label("file_name_label");
295 m_xImpl->m_xEdFileName.reset(new SvtURLBox(m_xBuilder->weld_combo_box("file_name")));
296 m_xImpl->m_xFtFileType = m_xBuilder->weld_label("file_type_label");
297 m_xImpl->m_xLbFilter = m_xBuilder->weld_combo_box("file_type");
298 m_xImpl->m_xEdCurrentPath.reset(new SvtURLBox(m_xBuilder->weld_combo_box("current_path")));
299 m_xImpl->m_xBtnFileOpen = m_xBuilder->weld_button("open");
300 m_xImpl->m_xBtnCancel = m_xBuilder->weld_button("cancel");
301 m_xImpl->m_xBtnHelp = m_xBuilder->weld_button("help");
302 m_xImpl->m_xBtnConnectToServer = m_xBuilder->weld_button("connect_to_server");
303 m_xImpl->m_xBtnNewFolder = m_xBuilder->weld_button("new_folder");
304 m_xImpl->m_xCbPassword = m_xBuilder->weld_check_button("password");
305 m_xImpl->m_xCbGPGEncrypt = m_xBuilder->weld_check_button("gpgencrypt");
306 m_xImpl->m_xCbAutoExtension = m_xBuilder->weld_check_button("extension");
307 m_xImpl->m_xSharedLabel = m_xBuilder->weld_label("shared_label");
308 m_xImpl->m_xSharedListBox = m_xBuilder->weld_combo_box("shared");
309
310 // because the "<All Formats> (*.bmp,*...)" entry is too wide,
311 // we need to disable the auto width feature of the filter box
312 int nWidth = m_xImpl->m_xLbFilter->get_approximate_digit_width() * 60;
313 m_xImpl->m_xSharedListBox->set_size_request(nWidth, -1);
314 m_xImpl->m_xLbFilter->set_size_request(nWidth, -1);
315
316 m_xImpl->m_xBtnUp.reset(new SvtUpButton_Impl(m_xBuilder->weld_toolbar("up_bar"),
317 m_xBuilder->weld_menu("up_menu"),
318 this));
319 m_xImpl->m_xBtnUp->set_help_id(HID_FILEOPEN_LEVELUP);
320 m_xImpl->m_xBtnUp->show();
321
322 m_xImpl->m_nStyle = nStyle;
324 m_xImpl->m_eDlgType = FILEDLG_TYPE_FILEDLG;
325
326 if (nStyle & PickerFlags::PathDialog)
327 m_xImpl->m_eDlgType = FILEDLG_TYPE_PATHDLG;
328
329 // Set the directory for the "back to the default dir" button
330 INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() );
332
333 // Create control element, the order defines the tab control.
334 m_xImpl->m_xEdFileName->connect_changed( LINK( this, SvtFileDialog, EntrySelectHdl_Impl ) );
335 m_xImpl->m_xEdFileName->connect_entry_activate( LINK( this, SvtFileDialog, OpenUrlHdl_Impl ) );
336
337 // in folder picker mode, only auto-complete directories (no files)
338 bool bIsFolderPicker = m_xImpl->m_eDlgType == FILEDLG_TYPE_PATHDLG;
339 m_xImpl->m_xEdFileName->SetOnlyDirectories( bIsFolderPicker );
340
341 // in save mode, don't use the autocompletion as selection in the edit part
342 bool bSaveMode = FILEDLG_MODE_SAVE == m_xImpl->m_eMode;
343 m_xImpl->m_xEdFileName->SetNoURLSelection( bSaveMode );
344
345 if (nStyle & PickerFlags::MultiSelection)
346 m_xImpl->m_bMultiSelection = true;
347
348 m_xContainer = m_xBuilder->weld_container("container");
349 m_xContainer->set_size_request(m_xContainer->get_approximate_digit_width() * 95, -1);
350
351 m_xFileView.reset(new SvtFileView(m_xDialog.get(),
352 m_xBuilder->weld_tree_view("fileview"),
353 m_xBuilder->weld_icon_view("iconview"),
354 FILEDLG_TYPE_PATHDLG == m_xImpl->m_eDlgType,
355 m_xImpl->m_bMultiSelection));
356 m_xFileView->set_help_id( HID_FILEDLG_STANDARD );
357
358 if ( nStyle & PickerFlags::ReadOnly )
359 {
360 m_xCbReadOnly->set_help_id( HID_FILEOPEN_READONLY );
361 m_xCbReadOnly->set_label( FpsResId( STR_SVT_FILEPICKER_READONLY ) );
362 m_xCbReadOnly->connect_toggled( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
363 m_xCbReadOnly->show();
364 }
365
366 if ( nStyle & PickerFlags::Password )
367 {
368 m_xImpl->m_xCbPassword->set_label( FpsResId( STR_SVT_FILEPICKER_PASSWORD ) );
369 m_xImpl->m_xCbPassword->connect_toggled( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
370 m_xImpl->m_xCbPassword->show();
371 m_xImpl->m_xCbGPGEncrypt->connect_toggled( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
372 m_xImpl->m_xCbGPGEncrypt->show();
373 }
374
375 // set the ini file for extracting the size
376 m_xImpl->m_aIniKey = "FileDialog";
377
379
380 // adjust the labels to the mode
381 TranslateId pResId = STR_EXPLORERFILE_OPEN;
382 TranslateId pButtonResId;
383
384 if ( nStyle & PickerFlags::SaveAs )
385 {
386 pResId = STR_EXPLORERFILE_SAVE;
387 pButtonResId = STR_EXPLORERFILE_BUTTONSAVE;
388 }
389
390 if ( nStyle & PickerFlags::PathDialog )
391 {
392 m_xImpl->m_xFtFileName->set_label( FpsResId( STR_PATHNAME ) );
393 pResId = STR_PATHSELECT;
394 pButtonResId = STR_BUTTONSELECT;
395 }
396
397 m_xDialog->set_title(FpsResId(pResId));
398
399 if ( pButtonResId )
400 m_xImpl->m_xBtnFileOpen->set_label( FpsResId( pButtonResId ) );
401
402 if ( FILEDLG_TYPE_FILEDLG != m_xImpl->m_eDlgType )
403 {
404 m_xImpl->m_xFtFileType->hide();
405 m_xImpl->GetFilterListControl()->hide();
406 }
407
408 // Setting preferences of the control elements.
409 m_xImpl->m_xBtnNewFolder->connect_clicked( LINK( this, SvtFileDialog, NewFolderHdl_Impl ) );
410 m_xImpl->m_xBtnFileOpen->connect_clicked( LINK( this, SvtFileDialog, OpenClickHdl_Impl ) );
411 m_xImpl->m_xBtnCancel->connect_clicked( LINK( this, SvtFileDialog, CancelHdl_Impl ) );
412 m_xImpl->SetFilterListSelectHdl( LINK( this, SvtFileDialog, FilterSelectHdl_Impl ) );
413 m_xImpl->m_xEdFileName->connect_focus_in( LINK( this, SvtFileDialog, FileNameGetFocusHdl_Impl ) );
414 m_xImpl->m_xEdFileName->connect_changed( LINK( this, SvtFileDialog, FileNameModifiedHdl_Impl ) );
415 m_xImpl->m_xEdCurrentPath->connect_entry_activate( LINK( this, SvtFileDialog, URLBoxModifiedHdl_Impl ) );
416 m_xImpl->m_xBtnConnectToServer->connect_clicked( LINK ( this, SvtFileDialog, ConnectToServerPressed_Hdl ) );
417
418 m_xFileView->SetSelectHdl( LINK( this, SvtFileDialog, SelectHdl_Impl ) );
419 m_xFileView->SetDoubleClickHdl( LINK( this, SvtFileDialog, DblClickHdl_Impl ) );
420 m_xFileView->SetOpenDoneHdl( LINK( this, SvtFileDialog, OpenDoneHdl_Impl ) );
421
422 // set timer for the filterbox travel
423 m_xImpl->m_aFilterIdle.SetPriority(TaskPriority::LOWEST);
424 m_xImpl->m_aFilterIdle.SetInvokeHandler( LINK( this, SvtFileDialog, FilterSelectTimerHdl_Impl ) );
425
426 if ( PickerFlags::SaveAs & nStyle )
427 {
428 // different help ids if in save-as mode
429 m_xDialog->set_help_id( HID_FILESAVE_DIALOG );
430
431 m_xImpl->m_xEdFileName->set_help_id( HID_FILESAVE_FILEURL );
432 m_xImpl->m_xBtnFileOpen->set_help_id( HID_FILESAVE_DOSAVE );
433 m_xImpl->m_xBtnNewFolder->set_help_id( HID_FILESAVE_CREATEDIRECTORY );
434 m_xImpl->m_xBtnUp->set_help_id( HID_FILESAVE_LEVELUP );
435 m_xImpl->GetFilterListControl()->set_help_id( HID_FILESAVE_FILETYPE );
436 m_xFileView->set_help_id( HID_FILESAVE_FILEVIEW );
437
438 // formerly, there was only _pLbFileVersion, which was used for 3 different
439 // use cases. For reasons of maintainability, I introduced extra members (_pLbTemplates, _pLbImageTemplates)
440 // for the extra use cases, and separated _pLbFileVersion
441 // I did not find out in which cases the help ID is really needed HID_FILESAVE_TEMPLATE - all
442 // tests I made lead to a dialog where _no_ of the three list boxes was present.
443 if (m_xImpl->m_xSharedListBox)
444 m_xImpl->m_xSharedListBox->set_help_id( HID_FILESAVE_TEMPLATE );
445
446 if ( m_xImpl->m_xCbPassword ) m_xImpl->m_xCbPassword->set_help_id( HID_FILESAVE_SAVEWITHPASSWORD );
447 if ( m_xImpl->m_xCbAutoExtension ) m_xImpl->m_xCbAutoExtension->set_help_id( HID_FILESAVE_AUTOEXTENSION );
448 if ( m_xImpl->m_xCbOptions ) m_xImpl->m_xCbOptions->set_help_id( HID_FILESAVE_CUSTOMIZEFILTER );
450 }
451
453 m_aConfiguration = OConfigurationTreeRoot::createWithComponentContext(
454 ::comphelper::getProcessComponentContext(),
455 "/org.openoffice.Office.UI/FilePicker"
456 );
457
458 m_xDialog->connect_size_allocate(LINK(this, SvtFileDialog, SizeAllocHdl));
459 SizeAllocHdl(Size());
460
461 m_xImpl->m_xEdFileName->grab_focus();
462}
463
465{
466 if (!m_xImpl->m_aIniKey.isEmpty())
467 {
468 // save window state
469 SvtViewOptions aDlgOpt( EViewType::Dialog, m_xImpl->m_aIniKey );
470 aDlgOpt.SetWindowState(m_xDialog->get_window_state(vcl::WindowDataMask::All));
471 OUString sUserData = m_xFileView->GetConfigString();
472 aDlgOpt.SetUserItem( "UserData",
473 Any( sUserData ) );
474 }
475
476 m_xFileView->SetSelectHdl(Link<SvtFileView*,void>());
477
478 // Save bookmarked places
479 if (!m_xImpl->m_xPlaces->IsUpdated())
480 return;
481
482 const std::vector<PlacePtr> aPlaces = m_xImpl->m_xPlaces->GetPlaces();
483 Sequence< OUString > placesUrlsList(m_xImpl->m_xPlaces->GetNbEditablePlaces());
484 auto placesUrlsListRange = asNonConstRange(placesUrlsList);
485 Sequence< OUString > placesNamesList(m_xImpl->m_xPlaces->GetNbEditablePlaces());
486 auto placesNamesListRange = asNonConstRange(placesNamesList);
487 int i(0);
488 for (auto const& place : aPlaces)
489 {
490 if(place->IsEditable()) {
491 placesUrlsListRange[i] = place->GetUrl();
492 placesNamesListRange[i] = place->GetName();
493 ++i;
494 }
495 }
496
497 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
498 officecfg::Office::Common::Misc::FilePickerPlacesUrls::set(placesUrlsList, batch);
499 officecfg::Office::Common::Misc::FilePickerPlacesNames::set(placesNamesList, batch);
500 batch->commit();
501}
502
503IMPL_LINK_NOARG(SvtFileDialog, NewFolderHdl_Impl, weld::Button&, void)
504{
505 m_xFileView->EndInplaceEditing();
506
507 SmartContent aContent( m_xFileView->GetViewURL( ) );
508 OUString aTitle;
509 aContent.getTitle( aTitle );
510 QueryFolderNameDialog aDlg(m_xDialog.get(), aTitle, FpsResId(STR_SVT_NEW_FOLDER));
511 bool bHandled = false;
512
513 while ( !bHandled )
514 {
515 if (aDlg.run() == RET_OK)
516 {
517 OUString aUrl = aContent.createFolder(aDlg.GetName());
518 if ( !aUrl.isEmpty( ) )
519 {
520 m_xFileView->CreatedFolder(aUrl, aDlg.GetName());
521 bHandled = true;
522 }
523 }
524 else
525 bHandled = true;
526 }
527}
528
529void SvtFileDialog::createNewUserFilter( const OUString& _rNewFilter )
530{
531 // delete the old user filter and create a new one
532 m_xImpl->m_xUserFilter.reset( new SvtFileDialogFilter_Impl( _rNewFilter, _rNewFilter ) );
533
534 // remember the extension
535 bool bIsAllFiles = _rNewFilter == FILEDIALOG_FILTER_ALL;
536 if ( bIsAllFiles )
538 else
539 SetDefaultExt( _rNewFilter.copy( 2 ) );
540 // TODO: this is nonsense. In the whole file there are a lot of places where we assume that a user filter
541 // is always "*.<something>". But changing this would take some more time than I have now...
542
543 // now, the default extension is set to the one of the user filter (or empty)
544 if ( m_xImpl->GetCurFilter( ) )
545 SetDefaultExt( m_xImpl->GetCurFilter( )->GetExtension() );
546 else
548}
549
550
552{
554
555 const bool bNonEmpty = !rFilter.isEmpty();
556 if ( bNonEmpty )
557 {
559
560 bool bFilterChanged = true;
561
562 // search for a corresponding filter
563 SvtFileDialogFilter_Impl* pFilter = FindFilter_Impl( rFilter, false, bFilterChanged );
564
565 // look for multi-ext filters if necessary
566 if ( !pFilter )
567 pFilter = FindFilter_Impl( rFilter, true, bFilterChanged );
568
569 if ( bFilterChanged )
571
572 if ( !pFilter )
573 {
575 // no filter found : use it as user defined filter
576 createNewUserFilter( rFilter );
577 }
578 }
579
580 return nReturn;
581}
582
584{
585 if ( m_pCurrentAsyncAction.is() )
586 {
587 m_pCurrentAsyncAction->cancel();
588 onAsyncOperationFinished();
589 }
590 else
591 {
592 m_xDialog->response(RET_CANCEL);
593 }
594}
595
596IMPL_LINK( SvtFileDialog, OpenClickHdl_Impl, weld::Button&, rVoid, void )
597{
598 OpenHdl_Impl(&rVoid);
599}
600
601IMPL_LINK( SvtFileDialog, OpenUrlHdl_Impl, weld::ComboBox&, rVoid, bool )
602{
603 OpenHdl_Impl(&rVoid);
604 return true;
605}
606
607void SvtFileDialog::OpenHdl_Impl(void const * pVoid)
608{
609 if ( m_xImpl->m_bMultiSelection && m_xFileView->GetSelectionCount() > 1 )
610 {
611 // special open in case of multiselection
613 return;
614 }
615
616 OUString aFileName;
617 OUString aOldPath(m_xFileView->GetViewURL());
618 if ( m_xImpl->m_bDoubleClick || m_xFileView->has_focus() )
619 {
620 // Selection done by doubleclicking in the view, get filename from the view
621 aFileName = m_xFileView->GetCurrentURL();
622 }
623
624 if ( aFileName.isEmpty() )
625 {
626 // if an entry is selected in the view...
627 if ( m_xFileView->GetSelectionCount() )
628 { // -> use this one. This will allow us to step down this folder
629 aFileName = m_xFileView->GetCurrentURL();
630 }
631 }
632
633 if ( aFileName.isEmpty() )
634 {
635 // get the URL from the edit field ( if not empty )
636 if ( !m_xImpl->m_xEdFileName->get_active_text().isEmpty() )
637 {
638 OUString aText = m_xImpl->m_xEdFileName->get_active_text();
639
640 // did we reach the root?
641 if ( !INetURLObject( aOldPath ).getSegmentCount() )
642 {
643 if ( ( aText.getLength() == 2 && aText == ".." ) ||
644 ( aText.getLength() == 3 && ( aText == "..\\" || aText == "../" ) ) )
645 // don't go higher than the root
646 return;
647 }
648
649#if defined( UNX )
650 if ( ( 1 == aText.getLength() ) && ( '~' == aText[0] ) )
651 {
652 // go to the home directory
653 if ( lcl_getHomeDirectory( m_xFileView->GetViewURL(), aFileName ) )
654 // in case we got a home dir, reset the text of the edit
655 m_xImpl->m_xEdFileName->set_entry_text( OUString() );
656 }
657 if ( aFileName.isEmpty() )
658#endif
659 {
660 // get url from autocomplete edit
661 aFileName = m_xImpl->m_xEdFileName->GetURL();
662 }
663 }
664 else if ( pVoid == m_xImpl->m_xBtnFileOpen.get() )
665 // OpenHdl was called for the "Open" Button; if edit field is empty, use selected element in the view
666 aFileName = m_xFileView->GetCurrentURL();
667 }
668
669 // MBA->PB: ?!
670 if ( aFileName.isEmpty() && pVoid == m_xImpl->m_xEdFileName.get() && m_xImpl->m_xUserFilter )
671 {
672 m_xImpl->m_xUserFilter.reset();
673 return;
674 }
675
676 sal_Int32 nLen = aFileName.getLength();
677 if ( !nLen )
678 {
679 // if the dialog was opened to select a folder, the last selected folder should be selected
680 if( m_xImpl->m_eDlgType == FILEDLG_TYPE_PATHDLG )
681 {
682 aFileName = m_xImpl->m_xEdCurrentPath->get_active_text();
683 nLen = aFileName.getLength();
684 }
685 else
686 // no file selected !
687 return;
688 }
689
690 // mark input as selected
691 m_xImpl->m_xEdFileName->select_entry_region(0, nLen);
692
693 // if a path with wildcards is given, divide the string into path and wildcards
694 OUString aFilter;
695 if ( !SvtFileDialog::IsolateFilterFromPath_Impl( aFileName, aFilter ) )
696 return;
697
698 // if a filter was retrieved, there were wildcards !
699 AdjustFilterFlags nNewFilterFlags = adjustFilter( aFilter );
700 if ( nNewFilterFlags & AdjustFilterFlags::Changed )
701 {
702 // cut off all text before wildcard in edit and select wildcard
703 m_xImpl->m_xEdFileName->set_entry_text( aFilter );
704 m_xImpl->m_xEdFileName->select_entry_region(0, -1);
705 }
706
707 {
708 INetURLObject aFileObject( aFileName );
709 if ( ( aFileObject.GetProtocol() == INetProtocol::NotValid ) && !aFileName.isEmpty() )
710 {
711 OUString sCompleted = SvtURLBox::ParseSmart( aFileName, m_xFileView->GetViewURL() );
712 if ( !sCompleted.isEmpty() )
713 aFileName = sCompleted;
714 }
715 }
716
717 // check if it is a folder
718 bool bIsFolder = false;
719
720 // first thing before doing anything with the content: Reset it. When the user presses "open" (or "save" or "export",
721 // for that matter), s/he wants the complete handling, including all possible error messages, even if s/he
722 // does the same thing for the same content twice, s/he wants both fails to be displayed.
723 // Without the reset, it could be that the content cached all relevant information, and will not display any
724 // error messages for the same content a second time...
725 m_aContent.bindTo( OUString( ) );
726
727 if ( !aFileName.isEmpty() )
728 {
729 // Make sure we have own Interaction Handler in place. We do not need
730 // to intercept interactions here, but to record the fact that there
731 // was an interaction.
732 SmartContent::InteractionHandlerType eInterActionHandlerType
734 if ( ( eInterActionHandlerType == SmartContent::IHT_NONE ) ||
735 ( eInterActionHandlerType == SmartContent::IHT_DEFAULT ) )
737 OFilePickerInteractionHandler::E_NOINTERCEPTION );
738
739 bIsFolder = m_aContent.isFolder( aFileName );
740
741 // access denied to the given resource - and interaction was already
742 // used => break following operations
743 OFilePickerInteractionHandler* pHandler
745
746 OSL_ENSURE( pHandler, "Got no Interaction Handler!!!" );
747
748 if ( pHandler->wasAccessDenied() )
749 return;
750
751 if ( m_aContent.isInvalid() &&
752 ( m_xImpl->m_eMode == FILEDLG_MODE_OPEN ) )
753 {
754 if ( !pHandler->wasUsed() )
756
757 return;
758 }
759
760 // restore previous Interaction Handler
761 if ( eInterActionHandlerType == SmartContent::IHT_NONE )
763 else if ( eInterActionHandlerType == SmartContent::IHT_DEFAULT )
765 }
766
767 if ( !bIsFolder // no existent folder
768 && m_xImpl->m_xCbAutoExtension // auto extension is enabled in general
769 && m_xImpl->m_xCbAutoExtension->get_active()// auto extension is really to be used
770 && !GetDefaultExt().isEmpty() // there is a default extension
771 && GetDefaultExt() != "*" // the default extension is not "all"
772 && !( FILEDLG_MODE_SAVE == m_xImpl->m_eMode // we're saving a file
773 && m_xFileView->GetSelectionCount() // there is a selected file in the file view -> it will later on
774 ) // (in SvtFileDialog::GetPathList) be taken as file to save to
775
776 && FILEDLG_MODE_OPEN != m_xImpl->m_eMode // #i83408# don't append extension on open
777 )
778 {
779 // check extension and append the default extension if necessary
780 appendDefaultExtension(aFileName,
782 m_xImpl->GetCurFilter()->GetType());
783 }
784
785 bool bOpenFolder = ( FILEDLG_TYPE_PATHDLG == m_xImpl->m_eDlgType ) &&
786 !m_xImpl->m_bDoubleClick && pVoid != m_xImpl->m_xEdFileName.get();
787 if ( bIsFolder )
788 {
789 if ( bOpenFolder )
790 {
791 m_aPath = aFileName;
792 }
793 else
794 {
795 if ( aFileName != m_xFileView->GetViewURL() )
796 {
797 OpenURL_Impl( aFileName );
798 }
799 else
800 {
801 if ( nNewFilterFlags & AdjustFilterFlags::Changed )
803 }
804
805 return;
806 }
807 }
808 else if ( !( nNewFilterFlags & AdjustFilterFlags::NonEmpty ) )
809 {
810 // if applicable save URL
811 m_aPath = aFileName;
812 }
813 else
814 {
815 // if applicable filter again
816 if ( nNewFilterFlags & AdjustFilterFlags::Changed )
818 return;
819 }
820
821 INetURLObject aFileObj( aFileName );
822 if ( aFileObj.HasError() )
823 {
825 return;
826 }
827
828 switch (m_xImpl->m_eMode)
829 {
831 {
832 if ( ::utl::UCBContentHelper::Exists( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) )
833 {
834 OUString aMsg = FpsResId(STR_SVT_ALREADYEXISTOVERWRITE);
835 aMsg = aMsg.replaceFirst(
836 "$filename$",
838 );
839 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
840 VclMessageType::Question, VclButtonsType::YesNo, aMsg));
841 if (xBox->run() != RET_YES)
842 return;
843 }
844 else
845 {
846 OUString aCurPath;
847 if (osl::FileBase::getSystemPathFromFileURL(aFileName, aCurPath) == osl::FileBase::E_None)
848 {
849 // if content does not exist: at least its path must exist
850 INetURLObject aPathObj = aFileObj;
851 aPathObj.removeSegment();
853 if ( !bFolder )
854 {
856 return;
857 }
858 }
859 }
860 }
861 break;
862
864 {
865 // do an existence check herein, again
866
867 if ( INetProtocol::File == aFileObj.GetProtocol( ) )
868 {
869 bool bExists = m_aContent.is( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
870
871 if ( !bExists )
872 {
873 OUString sError(FpsResId(RID_FILEOPEN_NOTEXISTENTFILE));
874
875 OUString sInvalidFile( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ) );
876 if ( INetProtocol::File == aFileObj.GetProtocol() )
877 { // if it's a file URL, transform the URL into system notation
878 OUString sURL( sInvalidFile );
879 OUString sSystem;
880 osl_getSystemPathFromFileURL( sURL.pData, &sSystem.pData );
881 sInvalidFile = sSystem;
882 }
883 sError = sError.replaceFirst( "$name$", sInvalidFile );
884
885 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
886 VclMessageType::Warning, VclButtonsType::Ok, sError));
887 xBox->run();
888 return;
889 }
890 }
891 }
892 break;
893
894 default:
895 OSL_FAIL("SvtFileDialog, OpenHdl_Impl: invalid mode!");
896 }
897
898 m_xDialog->response(RET_OK);
899}
900
902{
903 m_xImpl->m_xEdFileName->EnableAutocomplete(bEnable);
904}
905
906IMPL_LINK_NOARG( SvtFileDialog, FilterSelectHdl_Impl, weld::ComboBox&, void )
907{
908 OUString sSelectedFilterDisplayName;
909 SvtFileDialogFilter_Impl* pSelectedFilter = m_xImpl->GetSelectedFilterEntry( sSelectedFilterDisplayName );
910 if ( !pSelectedFilter )
911 { // there is no current selection. This happens if for instance the user selects a group separator using
912 // the keyboard, and then presses enter: When the selection happens, we immediately deselect the entry,
913 // so in this situation there is no current selection.
914 restoreCurrentFilter( m_xImpl );
915 }
916 else
917 {
918 if ( ( pSelectedFilter != m_xImpl->GetCurFilter() )
919 || m_xImpl->m_xUserFilter
920 )
921 {
922 // Store the old filter for the auto extension handling
923 OUString sLastFilterExt = m_xImpl->GetCurFilter()->GetExtension();
924 m_xImpl->m_xUserFilter.reset();
925
926 // if applicable remove filter of the user
927 m_xImpl->SetCurFilter( pSelectedFilter, sSelectedFilterDisplayName );
928
929 // if applicable show extension
930 SetDefaultExt( pSelectedFilter->GetExtension() );
931 sal_Int32 nSepPos = GetDefaultExt().indexOf( FILEDIALOG_DEF_EXTSEP );
932
933 if ( nSepPos != -1 )
934 EraseDefaultExt( nSepPos );
935
936 // update the extension of the current file if necessary
937 lcl_autoUpdateFileExtension( this, sLastFilterExt );
938
939 // if the user is traveling fast through the filterbox
940 // do not filter instantly
941 // FilterSelectHdl_Impl should be started again at idle
942 m_xImpl->m_aFilterIdle.Start();
943 }
944 }
945}
946
947IMPL_LINK_NOARG(SvtFileDialog, FilterSelectTimerHdl_Impl, Timer*, void)
948{
949 // filter the view again
950 ExecuteFilter();
951}
952
953IMPL_LINK_NOARG( SvtFileDialog, FileNameGetFocusHdl_Impl, weld::Widget&, void )
954{
955 m_xFileView->SetNoSelection();
956}
957
958IMPL_LINK( SvtFileDialog, FileNameModifiedHdl_Impl, weld::ComboBox&, rComboBox, void )
959{
960 FileNameGetFocusHdl_Impl(rComboBox);
961}
962
963IMPL_LINK_NOARG(SvtFileDialog, URLBoxModifiedHdl_Impl, weld::ComboBox&, bool)
964{
965 OUString aPath = m_xImpl->m_xEdCurrentPath->GetURL();
966 OpenURL_Impl(aPath);
967 return true;
968}
969
970IMPL_LINK_NOARG( SvtFileDialog, ConnectToServerPressed_Hdl, weld::Button&, void )
971{
972 m_xFileView->EndInplaceEditing();
973
974 PlaceEditDialog aDlg(m_xDialog.get());
975 short aRetCode = aDlg.run();
976
977 switch (aRetCode) {
978 case RET_OK :
979 {
980 PlacePtr newPlace = aDlg.GetPlace();
981 m_xImpl->m_xPlaces->AppendPlace(newPlace);
982
983 break;
984 }
985 case RET_CANCEL :
986 default :
987 // Do Nothing
988 break;
989 }
990}
991
992IMPL_LINK_NOARG ( SvtFileDialog, AddPlacePressed_Hdl, weld::Button&, void )
993{
994 // Maybe open the PlacesDialog would have been a better idea
995 // there is an ux choice to make we did not make...
996 INetURLObject aURLObj( m_xFileView->GetViewURL() );
997 PlacePtr newPlace =
998 std::make_shared<Place>( aURLObj.GetLastName(INetURLObject::DecodeMechanism::WithCharset),
999 m_xFileView->GetViewURL(), true);
1000 m_xImpl->m_xPlaces->AppendPlace(newPlace);
1001}
1002
1003IMPL_LINK_NOARG ( SvtFileDialog, RemovePlacePressed_Hdl, weld::Button&, void )
1004{
1005 m_xImpl->m_xPlaces->RemoveSelectedPlace();
1006}
1007
1009(
1010 const OUString& rFilter,
1011 bool bMultiExt,/* TRUE - regard filter with several extensions
1012 FALSE - do not ...
1013 */
1014 bool& rFilterChanged
1015)
1016
1017/* [Description]
1018
1019 This method looks for the specified extension in the included filters.
1020*/
1021
1022{
1023 SvtFileDialogFilter_Impl* pFoundFilter = nullptr;
1024 SvtFileDialogFilterList_Impl& rList = m_xImpl->m_aFilter;
1025 sal_uInt16 nFilter = rList.size();
1026
1027 while ( nFilter-- )
1028 {
1029 SvtFileDialogFilter_Impl* pFilter = rList[ nFilter ].get();
1030 const OUString& rType = pFilter->GetType();
1031
1032 if ( bMultiExt )
1033 {
1034 sal_Int32 nIdx = 0;
1035 while ( !pFoundFilter && nIdx != -1 )
1036 {
1037 const OUString aSingleType = rType.getToken( 0, FILEDIALOG_DEF_EXTSEP, nIdx );
1038#ifdef UNX
1039 if ( aSingleType == rFilter )
1040#else
1041 if ( aSingleType.equalsIgnoreAsciiCase( rFilter ) )
1042#endif
1043 pFoundFilter = pFilter;
1044 }
1045 }
1046#ifdef UNX
1047 else if ( rType == rFilter )
1048#else
1049 else if ( rType.equalsIgnoreAsciiCase( rFilter ) )
1050#endif
1051 pFoundFilter = pFilter;
1052
1053 if ( pFoundFilter )
1054 {
1055 // activate filter
1056 rFilterChanged = m_xImpl->m_xUserFilter || ( m_xImpl->GetCurFilter() != pFilter );
1057
1058 createNewUserFilter( rFilter );
1059
1060 break;
1061 }
1062 }
1063 return pFoundFilter;
1064}
1065
1066
1068{
1069 executeAsync( AsyncPickerAction::eExecuteFilter, OUString(), getMostCurrentFilter(m_xImpl) );
1070}
1071
1072/* [Description]
1073
1074 OpenHandler for MultiSelection
1075*/
1077{
1078 SvtContentEntry* pEntry = m_xFileView->FirstSelected();
1079
1080 if (pEntry)
1081 m_aPath = pEntry->maURL;
1082
1083 m_xDialog->response(RET_OK);
1084}
1085
1086void SvtFileDialog::UpdateControls( const OUString& rURL )
1087{
1088 m_xImpl->m_xEdFileName->SetBaseURL( rURL );
1089
1090 INetURLObject aObj( rURL );
1091
1092 {
1093 OUString sText;
1094 SAL_WARN_IF( INetProtocol::NotValid == aObj.GetProtocol(), "fpicker.office", "SvtFileDialog::UpdateControls: Invalid URL!" );
1095
1096 if ( aObj.getSegmentCount() )
1097 {
1098 osl::FileBase::getSystemPathFromFileURL(rURL, sText);
1099 if ( !sText.isEmpty() )
1100 {
1101 // no Fsys path for server file system ( only UCB has mountpoints! )
1102 if ( INetProtocol::File != aObj.GetProtocol() )
1103 sText = rURL.copy( INetURLObject::GetScheme( aObj.GetProtocol() ).getLength() );
1104 }
1105
1106 if ( sText.isEmpty() && aObj.getSegmentCount() )
1107 sText = rURL;
1108 }
1109
1110 // path mode ?
1111 if ( FILEDLG_TYPE_PATHDLG == m_xImpl->m_eDlgType )
1112 // -> set new path in the edit field
1113 m_xImpl->m_xEdFileName->set_entry_text( sText );
1114
1115 // in the "current path" field, truncate the trailing slash
1116 if ( aObj.hasFinalSlash() )
1117 {
1118 aObj.removeFinalSlash();
1119 OUString sURL( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
1120 if (osl::FileBase::getSystemPathFromFileURL(sURL, sText) != osl::FileBase::E_None)
1121 sText = sURL;
1122 }
1123
1124 if ( sText.isEmpty() && !rURL.isEmpty() )
1125 // happens, for instance, for URLs which the INetURLObject does not know to belong to a hierarchical scheme
1126 sText = rURL;
1127 m_xImpl->m_xEdCurrentPath->set_entry_text(sText);
1128 }
1129
1130 m_aPath = rURL;
1131
1132 m_xImpl->m_xBtnUp->FillURLMenu();
1133
1134 if (m_pFileNotifier)
1136}
1137
1138IMPL_LINK( SvtFileDialog, SelectHdl_Impl, SvtFileView*, pBox, void )
1139{
1140 SvtContentEntry* pUserData = pBox->FirstSelected();
1141 if (pUserData)
1142 {
1143 INetURLObject aObj( pUserData->maURL );
1144 if ( FILEDLG_TYPE_PATHDLG == m_xImpl->m_eDlgType )
1145 {
1146 if ( aObj.GetProtocol() == INetProtocol::File )
1147 {
1148 if ( !pUserData->mbIsFolder )
1149 aObj.removeSegment();
1150 OUString aName = aObj.getFSysPath( static_cast<FSysStyle>(FSysStyle::Detect & ~FSysStyle::Vos) );
1151 m_xImpl->m_xEdFileName->set_entry_text( aName );
1152 m_xImpl->m_xEdFileName->select_entry_region(0, -1);
1153 m_aPath = pUserData->maURL;
1154 }
1155 else if ( !pUserData->mbIsFolder )
1156 {
1157 m_xImpl->m_xEdFileName->set_entry_text( pUserData->maURL );
1158 m_xImpl->m_xEdFileName->select_entry_region(0, -1);
1159 m_aPath = pUserData->maURL;
1160 }
1161 else
1162 m_xImpl->m_xEdFileName->set_entry_text( OUString() );
1163 }
1164 else
1165 {
1166 if ( !pUserData->mbIsFolder )
1167 {
1168 OUString aName = pBox->get_selected_text();
1169 m_xImpl->m_xEdFileName->set_entry_text( aName );
1170 m_xImpl->m_xEdFileName->select_entry_region(0, -1);
1171 m_aPath = pUserData->maURL;
1172 }
1173 }
1174 }
1175
1176 if ( m_xImpl->m_bMultiSelection && m_xFileView->GetSelectionCount() > 1 )
1177 {
1178 // clear the file edit for multiselection
1179 m_xImpl->m_xEdFileName->set_entry_text( OUString() );
1180 }
1181
1182 FileSelect();
1183}
1184
1186{
1187 m_xImpl->m_bDoubleClick = true;
1188 OpenHdl_Impl( nullptr );
1189 m_xImpl->m_bDoubleClick = false;
1190 return true;
1191}
1192
1193IMPL_LINK_NOARG(SvtFileDialog, EntrySelectHdl_Impl, weld::ComboBox&, void)
1194{
1195 FileSelect();
1196}
1197
1198IMPL_LINK( SvtFileDialog, OpenDoneHdl_Impl, SvtFileView*, pView, void )
1199{
1200 const OUString& sCurrentFolder( pView->GetViewURL() );
1201 // check if we can create new folders
1202 EnableControl( m_xImpl->m_xBtnNewFolder.get(), ContentCanMakeFolder( sCurrentFolder ) );
1203
1204 // check if we can travel one level up
1205 bool bCanTravelUp = ContentHasParentFolder( pView->GetViewURL() );
1206 if ( bCanTravelUp )
1207 {
1208 // additional check: the parent folder should not be prohibited
1209 INetURLObject aCurrentFolder( sCurrentFolder );
1210 SAL_WARN_IF( INetProtocol::NotValid == aCurrentFolder.GetProtocol(),
1211 "fpicker.office", "SvtFileDialog::OpenDoneHdl_Impl: invalid current URL!" );
1212
1213 aCurrentFolder.removeSegment();
1214 }
1215 EnableControl( m_xImpl->m_xBtnUp->getWidget(), bCanTravelUp );
1216}
1217
1218IMPL_LINK_NOARG(SvtFileDialog, AutoExtensionHdl_Impl, weld::Toggleable&, void)
1219{
1220 if (m_pFileNotifier)
1221 m_pFileNotifier->notify(CTRL_STATE_CHANGED, CHECKBOX_AUTOEXTENSION);
1222
1223 // update the extension of the current file if necessary
1224 lcl_autoUpdateFileExtension( this, m_xImpl->GetCurFilter()->GetExtension() );
1225}
1226
1227IMPL_LINK( SvtFileDialog, ClickHdl_Impl, weld::Toggleable&, rCheckBox, void )
1228{
1229 if (!m_pFileNotifier)
1230 return;
1231
1232 sal_Int16 nId = -1;
1233
1234 if ( &rCheckBox == m_xImpl->m_xCbOptions.get() )
1235 nId = CHECKBOX_FILTEROPTIONS;
1236 else if ( &rCheckBox == m_xCbSelection.get() )
1237 nId = CHECKBOX_SELECTION;
1238 else if ( &rCheckBox == m_xCbReadOnly.get() )
1239 nId = CHECKBOX_READONLY;
1240 else if ( &rCheckBox == m_xImpl->m_xCbPassword.get() )
1241 nId = CHECKBOX_PASSWORD;
1242 else if ( &rCheckBox == m_xImpl->m_xCbGPGEncrypt.get() )
1243 nId = CHECKBOX_GPGENCRYPTION;
1244 else if ( &rCheckBox == m_xCbLinkBox.get() )
1245 nId = CHECKBOX_LINK;
1246 else if ( &rCheckBox == m_xCbPreviewBox.get() )
1247 nId = CHECKBOX_PREVIEW;
1248
1249 if ( nId != -1 )
1250 m_pFileNotifier->notify( CTRL_STATE_CHANGED, nId );
1251}
1252
1253IMPL_LINK_NOARG(SvtFileDialog, PlayButtonHdl_Impl, weld::Button&, void)
1254{
1255 if (m_pFileNotifier)
1256 m_pFileNotifier->notify(CTRL_STATE_CHANGED, PUSHBUTTON_PLAY);
1257}
1258
1259namespace
1260{
1261
1262bool implIsInvalid( const OUString & rURL )
1263{
1264 SmartContent aContent( rURL );
1265 aContent.enableOwnInteractionHandler( ::svt::OFilePickerInteractionHandler::E_DOESNOTEXIST );
1266 aContent.isFolder(); // do this _before_ asking isInvalid! Otherwise result might be wrong.
1267 return aContent.isInvalid();
1268}
1269
1270}
1271
1272
1273OUString SvtFileDialog::implGetInitialURL( const OUString& _rPath, std::u16string_view _rFallback )
1274{
1275 // a URL parser for the fallback
1276 INetURLObject aURLParser;
1277
1278 // set the path
1279 bool bWasAbsolute = false;
1280 aURLParser = aURLParser.smartRel2Abs( _rPath, bWasAbsolute );
1281
1282 // is it a valid folder?
1284 bool bIsFolder = m_aContent.isFolder( ); // do this _before_ asking isInvalid!
1285 bool bIsInvalid = m_aContent.isInvalid();
1286
1287 if ( bIsInvalid && m_bHasFilename && !aURLParser.hasFinalSlash() )
1288 { // check if the parent folder exists
1289 INetURLObject aParent( aURLParser );
1290 aParent.removeSegment( );
1291 aParent.setFinalSlash( );
1292 bIsInvalid = implIsInvalid( aParent.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
1293 }
1294
1295 if ( bIsInvalid )
1296 {
1297 INetURLObject aFallback( _rFallback );
1298 bIsInvalid = implIsInvalid( aFallback.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
1299
1300 if ( !bIsInvalid )
1301 aURLParser = aFallback;
1302 }
1303
1304 if ( bIsInvalid )
1305 {
1306 INetURLObject aParent( aURLParser );
1307 while ( bIsInvalid && aParent.removeSegment() )
1308 {
1309 aParent.setFinalSlash( );
1310 bIsInvalid = implIsInvalid( aParent.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
1311 }
1312
1313 if ( !bIsInvalid )
1314 aURLParser = aParent;
1315 }
1316
1317 if ( !bIsInvalid && bIsFolder )
1318 {
1319 aURLParser.setFinalSlash();
1320 }
1322}
1323
1324
1326{
1327 if ( !PrepareExecute() )
1328 return 0;
1329
1330 // start the dialog
1331 m_bIsInExecute = true;
1332 short nResult = GenericDialogController::run();
1333 m_bIsInExecute = false;
1334
1335 SAL_WARN_IF( m_pCurrentAsyncAction.is(), "fpicker.office", "SvtFilePicker::run: still running an async action!" );
1336 // the dialog should not be cancellable while an async action is running - first, the action
1337 // needs to be cancelled
1338
1339 // remember last directory
1340 if ( RET_OK == nResult )
1341 {
1343 if ( aURL.GetProtocol() == INetProtocol::File )
1344 {
1345 // remember the selected directory only for file URLs not for virtual folders
1346 sal_Int32 nLevel = aURL.getSegmentCount();
1347 bool bDir = m_aContent.isFolder( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
1348 if ( nLevel > 1 && ( FILEDLG_TYPE_FILEDLG == m_xImpl->m_eDlgType || !bDir ) )
1349 aURL.removeSegment();
1350 }
1351 }
1352
1353 return nResult;
1354}
1355
1357{
1358 EnableUI( false );
1359 // the cancel button must be always enabled
1360 m_xImpl->m_xBtnCancel->set_sensitive(true);
1361 m_xImpl->m_xBtnCancel->grab_focus();
1362}
1363
1365{
1366 EnableUI( true );
1367 m_pCurrentAsyncAction = nullptr;
1368 if ( !m_bInExecuteAsync )
1369 m_xImpl->m_xEdFileName->grab_focus();
1370 // (if m_bInExecuteAsync is true, then the operation was finished within the minimum wait time,
1371 // and to the user, the operation appears to be synchronous)
1372}
1373
1375{
1376 m_xImpl->m_xPlaces->SetDelEnabled( enable );
1377}
1378
1379void SvtFileDialog::displayIOException( const OUString& _rURL, IOErrorCode _eCode )
1380{
1381 try
1382 {
1383 // create make a human-readable string from the URL
1384 OUString sDisplayPath;
1385 if (osl::FileBase::getSystemPathFromFileURL(_rURL, sDisplayPath)
1386 == osl::FileBase::E_None)
1387 {
1388 sDisplayPath = _rURL;
1389 }
1390
1391 // build an own exception which tells "access denied"
1392 InteractiveAugmentedIOException aException;
1393 aException.Arguments =
1394 { css::uno::Any(sDisplayPath),
1395 css::uno::Any(PropertyValue(
1396 "Uri",
1397 -1, aException.Arguments[ 0 ], PropertyState_DIRECT_VALUE
1398 )) };
1399 // (formerly, it was sufficient to put the URL first parameter. Nowadays,
1400 // the services expects the URL in a PropertyValue named "Uri" ...)
1401 aException.Code = _eCode;
1402 aException.Classification = InteractionClassification_ERROR;
1403
1404 // let and interaction handler handle this exception
1406 new ::comphelper::OInteractionRequest( Any( aException ) );
1407 pRequest->addContinuation( new ::comphelper::OInteractionAbort( ) );
1408
1409 Reference< XInteractionHandler2 > xHandler(
1410 InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr ) );
1411 xHandler->handle( pRequest );
1412 }
1413 catch( const Exception& )
1414 {
1415 TOOLS_WARN_EXCEPTION( "fpicker", "iodlg::displayIOException" );
1416 }
1417}
1418
1419void SvtFileDialog::EnableUI(bool bEnable)
1420{
1421 m_xDialog->set_sensitive(bEnable);
1422
1423 if (bEnable)
1424 {
1425 for (auto& rxControl : m_aDisabledControls)
1426 {
1427 rxControl->set_sensitive(false);
1428 }
1429 }
1430}
1431
1432void SvtFileDialog::EnableControl(weld::Widget* pControl, bool bEnable)
1433{
1434 if (!pControl)
1435 {
1436 SAL_WARN( "fpicker.office", "SvtFileDialog::EnableControl: invalid control!" );
1437 return;
1438 }
1439
1440 pControl->set_sensitive(bEnable);
1441
1442 if (bEnable)
1443 {
1444 auto aPos = m_aDisabledControls.find( pControl );
1445 if ( m_aDisabledControls.end() != aPos )
1446 m_aDisabledControls.erase( aPos );
1447 }
1448 else
1449 m_aDisabledControls.insert( pControl );
1450}
1451
1453{
1455 return false;
1456
1457 OUString aEnvValue;
1458 if ( getEnvironmentValue( "WorkDirMustContainRemovableMedia", aEnvValue ) && aEnvValue == "1" )
1459 {
1460 try
1461 {
1462 INetURLObject aStdDir( GetStandardDir() );
1463 ::ucbhelper::Content aCnt( aStdDir.GetMainURL(
1465 Reference< XCommandEnvironment >(),
1467 Sequence< OUString > aProps { "IsVolume", "IsRemoveable" };
1468
1469 Reference< XResultSet > xResultSet
1470 = aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_ONLY );
1471 if ( xResultSet.is() && !xResultSet->next() )
1472 {
1473 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
1474 VclMessageType::Warning, VclButtonsType::Ok,
1475 FpsResId(STR_SVT_NOREMOVABLEDEVICE)));
1476 xBox->run();
1477 return false;
1478 }
1479 }
1480 catch ( ContentCreationException const & )
1481 {
1482 }
1483 catch ( CommandAbortedException const & )
1484 {
1485 }
1486 }
1487
1488 if ( ( m_xImpl->m_nStyle & PickerFlags::SaveAs ) && m_bHasFilename )
1489 // when doing a save-as, we do not want the handler to handle "this file does not exist" messages
1490 // - finally we're going to save that file, aren't we?
1492 else
1494
1495 // possibly just a filename without a path
1496 OUString aFileNameOnly;
1497 if( !m_aPath.isEmpty() && (m_xImpl->m_eMode == FILEDLG_MODE_SAVE)
1498 && (m_aPath.indexOf(':') == -1)
1499 && (m_aPath.indexOf('\\') == -1)
1500 && (m_aPath.indexOf('/') == -1))
1501 {
1502 aFileNameOnly = m_aPath;
1503 m_aPath.clear();
1504 }
1505
1506 // no starting path specified?
1507 if ( m_aPath.isEmpty() )
1508 {
1509 // then use the standard directory
1510 m_aPath = lcl_ensureFinalSlash( m_xImpl->GetStandardDir() );
1511
1512 // attach given filename to path
1513 if ( !aFileNameOnly.isEmpty() )
1514 m_aPath += aFileNameOnly;
1515 }
1516
1517
1519
1520 if ( m_xImpl->m_nStyle & PickerFlags::SaveAs && !m_bHasFilename )
1521 // when doing a save-as, we do not want the handler to handle "this file does not exist" messages
1522 // - finally we're going to save that file, aren't we?
1524
1525 // if applicable show filter
1526 m_xImpl->InitFilterList();
1527
1528 // set up initial filter
1529 sal_uInt16 nFilterCount = GetFilterCount();
1530 OUString aAll = FpsResId( STR_FILTERNAME_ALL );
1531 bool bHasAll = m_xImpl->HasFilterListEntry( aAll );
1532 if ( m_xImpl->GetCurFilter() || nFilterCount == 1 || ( nFilterCount == 2 && bHasAll ) )
1533 {
1534 // if applicable set the only filter or the only filter that
1535 // does not refer to all files, as the current one
1536 if ( !m_xImpl->GetCurFilter() )
1537 {
1538 sal_uInt16 nPos = 0;
1539 if ( 2 == nFilterCount && bHasAll )
1540 {
1541 nPos = nFilterCount;
1542 while ( nPos-- )
1543 {
1544 if ( aAll != GetFilterName( nPos ) )
1545 break;
1546 }
1547 }
1548 SvtFileDialogFilter_Impl* pNewCurFilter = m_xImpl->m_aFilter[ nPos ].get();
1549 assert( pNewCurFilter && "SvtFileDialog::run: invalid filter pos!" );
1550 m_xImpl->SetCurFilter( pNewCurFilter, pNewCurFilter->GetName() );
1551 }
1552
1553 // adjust view
1554 m_xImpl->SelectFilterListEntry( m_xImpl->GetCurFilter()->GetName() );
1555 SetDefaultExt( m_xImpl->GetCurFilter()->GetExtension() );
1556 sal_Int32 nSepPos = GetDefaultExt().indexOf( FILEDIALOG_DEF_EXTSEP );
1557 if ( nSepPos != -1 )
1558 EraseDefaultExt( nSepPos );
1559 }
1560 else
1561 {
1562 // if applicable set respectively create filter for all files
1563 if ( !bHasAll )
1564 {
1566 m_xImpl->InsertFilterListEntry( pAllFilter );
1567 m_xImpl->SetCurFilter( pAllFilter, aAll );
1568 }
1569 m_xImpl->SelectFilterListEntry( aAll );
1570 }
1571
1572 // if applicable isolate filter
1573 OUString aFilter;
1574
1575 if ( !IsolateFilterFromPath_Impl( m_aPath, aFilter ) )
1576 return false;
1577
1578 AdjustFilterFlags nNewFilterFlags = adjustFilter( aFilter );
1579 if ( nNewFilterFlags & ( AdjustFilterFlags::NonEmpty | AdjustFilterFlags::UserFilter ) )
1580 {
1581 m_xImpl->m_xEdFileName->set_entry_text( aFilter );
1582 }
1583
1584 // create and show instance for set path
1585 INetURLObject aFolderURL( m_aPath );
1586 OUString aFileName( aFolderURL.getName( INetURLObject::LAST_SEGMENT, false ) );
1587 sal_Int32 nFileNameLen = aFileName.getLength();
1588 bool bFileToSelect = nFileNameLen != 0;
1589 if ( bFileToSelect && aFileName[ nFileNameLen - 1 ] != '/' )
1590 {
1591 OUString aDecodedName = aFolderURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset );
1592 m_xImpl->m_xEdFileName->set_entry_text( aDecodedName );
1593 aFolderURL.removeSegment();
1594 }
1595
1596 INetURLObject aObj = aFolderURL;
1597 if ( aObj.GetProtocol() == INetProtocol::File )
1598 {
1599 // set folder as current directory
1600 aObj.setFinalSlash();
1601 }
1602
1604
1605 // Somebody might want to enable some controls according to the current filter
1606 FilterSelect();
1607
1609
1610 // if applicable read and set size from ini
1611 InitSize();
1612
1613 return true;
1614}
1615
1617 const OUString& rURL, const OUString& rFilter )
1618{
1619 SAL_WARN_IF( m_pCurrentAsyncAction.is(), "fpicker.office", "SvtFileDialog::executeAsync: previous async action not yet finished!" );
1620
1621 m_pCurrentAsyncAction = new AsyncPickerAction( this, m_xFileView.get(), eAction );
1622
1623 bool bReallyAsync = true;
1624 m_aConfiguration.getNodeValue( OUString( "FillAsynchronously" ) ) >>= bReallyAsync;
1625
1626 sal_Int32 nMinTimeout = 0;
1627 m_aConfiguration.getNodeValue( OUString( "Timeout/Min" ) ) >>= nMinTimeout;
1628 sal_Int32 nMaxTimeout = 0;
1629 m_aConfiguration.getNodeValue( OUString( "Timeout/Max" ) ) >>= nMaxTimeout;
1630
1631 m_bInExecuteAsync = true;
1632 m_pCurrentAsyncAction->execute(rURL, rFilter, bReallyAsync ? nMinTimeout : -1, nMaxTimeout, GetDenyList());
1633 m_bInExecuteAsync = false;
1634}
1635
1636
1638{
1639 if (m_pFileNotifier)
1641}
1642
1643
1645{
1646 if (m_pFileNotifier)
1648 LISTBOX_FILTER );
1649}
1650
1651
1652/* [Description]
1653
1654 This method sets the path for the default button.
1655*/
1656void SvtFileDialog::SetStandardDir( const OUString& rStdDir )
1657{
1658 INetURLObject aObj( rStdDir );
1659 SAL_WARN_IF( aObj.GetProtocol() == INetProtocol::NotValid, "fpicker.office", "Invalid protocol!" );
1660 aObj.setFinalSlash();
1661 m_xImpl->SetStandardDir( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
1662}
1663
1664void SvtFileDialog::SetDenyList( const css::uno::Sequence< OUString >& rDenyList )
1665{
1666 m_xImpl->SetDenyList( rDenyList );
1667}
1668
1669
1670const css::uno::Sequence< OUString >& SvtFileDialog::GetDenyList() const
1671{
1672 return m_xImpl->GetDenyList();
1673}
1674
1675
1676/* [Description]
1677
1678 This method returns the standard path.
1679*/
1680const OUString& SvtFileDialog::GetStandardDir() const
1681{
1682 return m_xImpl->GetStandardDir();
1683}
1684
1685
1687{
1688 m_xFileView->EndInplaceEditing();
1689
1690 OUString sDummy;
1691 executeAsync( AsyncPickerAction::ePrevLevel, sDummy, sDummy );
1692}
1693
1694void SvtFileDialog::OpenURL_Impl( const OUString& _rURL )
1695{
1696 m_xFileView->EndInplaceEditing();
1697
1698 executeAsync( AsyncPickerAction::eOpenURL, _rURL, getMostCurrentFilter( m_xImpl ) );
1699}
1700
1701SvtFileDialogFilter_Impl* SvtFileDialog::implAddFilter( const OUString& rFilter, const OUString& _rType )
1702{
1703 SvtFileDialogFilter_Impl* pNewFilter = new SvtFileDialogFilter_Impl( rFilter, _rType );
1704 m_xImpl->m_aFilter.push_front( std::unique_ptr<SvtFileDialogFilter_Impl>( pNewFilter ) );
1705
1706 if ( !m_xImpl->GetCurFilter() )
1707 m_xImpl->SetCurFilter( pNewFilter, rFilter );
1708
1709 return pNewFilter;
1710}
1711
1712void SvtFileDialog::AddFilter( const OUString& rFilter, const OUString& _rType )
1713{
1714 SAL_WARN_IF( m_bIsInExecute, "fpicker.office", "SvtFileDialog::AddFilter: currently executing!" );
1715 implAddFilter ( rFilter, _rType );
1716}
1717
1718
1719void SvtFileDialog::AddFilterGroup( const OUString& rFilter, const Sequence< StringPair >& rFilters )
1720{
1721 SAL_WARN_IF( m_bIsInExecute, "fpicker.office", "SvtFileDialog::AddFilter: currently executing!" );
1722
1723 implAddFilter( rFilter, OUString() );
1724 const StringPair* pSubFilters = rFilters.getConstArray();
1725 const StringPair* pSubFiltersEnd = pSubFilters + rFilters.getLength();
1726 for ( ; pSubFilters != pSubFiltersEnd; ++pSubFilters )
1727 implAddFilter( pSubFilters->First, pSubFilters->Second );
1728}
1729
1730
1731void SvtFileDialog::SetCurFilter( const OUString& rFilter )
1732{
1733 SAL_WARN_IF( m_bIsInExecute, "fpicker.office", "SvtFileDialog::SetCurFilter: currently executing!" );
1734
1735 // look for corresponding filter
1736 sal_uInt16 nPos = m_xImpl->m_aFilter.size();
1737
1738 while ( nPos-- )
1739 {
1740 SvtFileDialogFilter_Impl* pFilter = m_xImpl->m_aFilter[ nPos ].get();
1741 if ( pFilter->GetName() == rFilter )
1742 {
1743 m_xImpl->SetCurFilter( pFilter, rFilter );
1744 break;
1745 }
1746 }
1747}
1748
1750{
1751 OUString aFilter;
1752
1753 const SvtFileDialogFilter_Impl* pCurrentFilter = m_xImpl->GetCurFilter();
1754 if ( pCurrentFilter )
1755 aFilter = pCurrentFilter->GetName();
1756
1757 return aFilter;
1758}
1759
1761{
1762 return GetCurFilter();
1763}
1764
1766{
1767 return m_xImpl->m_aFilter.size();
1768}
1769
1770const OUString& SvtFileDialog::GetFilterName( sal_uInt16 nPos ) const
1771{
1772 assert( nPos < GetFilterCount() && "invalid index" );
1773 return m_xImpl->m_aFilter[ nPos ]->GetName();
1774}
1775
1777{
1778 if (m_xImpl->m_aIniKey.isEmpty())
1779 return;
1780
1781 // initialize from config
1782 SvtViewOptions aDlgOpt( EViewType::Dialog, m_xImpl->m_aIniKey );
1783
1784 if ( aDlgOpt.Exists() )
1785 {
1786 m_xDialog->set_window_state(aDlgOpt.GetWindowState());
1787
1788 Any aUserData = aDlgOpt.GetUserItem( "UserData");
1789 OUString sCfgStr;
1790 if ( aUserData >>= sCfgStr )
1791 m_xFileView->SetConfigString( sCfgStr );
1792 }
1793}
1794
1795std::vector<OUString> SvtFileDialog::GetPathList() const
1796{
1797 std::vector<OUString> aList;
1798
1799 m_xFileView->selected_foreach([this, &aList](weld::TreeIter& rCurEntry){
1800 aList.push_back(m_xFileView->GetURL(rCurEntry));
1801 return false;
1802 });
1803
1804 if (aList.empty())
1805 {
1806 if ( !m_xImpl->m_xEdFileName->get_active_text().isEmpty() && m_bIsInExecute )
1807 aList.push_back(m_xImpl->m_xEdFileName->GetURL());
1808 else
1809 aList.push_back(m_aPath);
1810 }
1811
1812 return aList;
1813}
1814
1815bool SvtFileDialog::IsolateFilterFromPath_Impl( OUString& rPath, OUString& rFilter )
1816{
1817 OUString aReversePath = comphelper::string::reverseString(rPath);
1818 sal_Int32 nQuestionMarkPos = rPath.indexOf( '?' );
1819 sal_Int32 nWildCardPos = rPath.indexOf( FILEDIALOG_DEF_WILDCARD );
1820
1821 if ( nQuestionMarkPos != -1 )
1822 {
1823 // use question mark as wildcard only for files
1825
1826 if ( INetProtocol::NotValid != eProt && INetProtocol::File != eProt )
1827 nQuestionMarkPos = -1;
1828
1829 nWildCardPos = std::min( nWildCardPos, nQuestionMarkPos );
1830 }
1831
1832 rFilter.clear();
1833
1834 if ( nWildCardPos == -1 )
1835 return true;
1836
1837 sal_Int32 nPathTokenPos = aReversePath.indexOf( '/' );
1838
1839 if ( nPathTokenPos == -1 )
1840 {
1841 OUString aDelim(
1842#if defined(_WIN32)
1843 '\\'
1844#else
1845 '/'
1846#endif
1847 );
1848
1849 nPathTokenPos = aReversePath.indexOf( aDelim );
1850#if !defined( UNX )
1851 if ( nPathTokenPos == -1 )
1852 {
1853 nPathTokenPos = aReversePath.indexOf( ':' );
1854 }
1855#endif
1856 }
1857
1858 // check syntax
1859 if ( nPathTokenPos != -1 )
1860 {
1861 if ( nPathTokenPos < (rPath.getLength() - nWildCardPos - 1) )
1862 {
1864 return false;
1865 }
1866
1867 // cut off filter
1868 rFilter = aReversePath.copy( 0, nPathTokenPos );
1869 rFilter = comphelper::string::reverseString(rFilter);
1870
1871 // determine folder
1872 rPath = aReversePath.copy( nPathTokenPos );
1873 rPath = comphelper::string::reverseString(rPath);
1874 }
1875 else
1876 {
1877 rFilter = rPath;
1878 rPath.clear();
1879 }
1880
1881 return true;
1882}
1883
1884IMPL_LINK_NOARG(SvtFileDialog, SizeAllocHdl, const Size&, void)
1885{
1886 if (m_pFileNotifier)
1887 m_pFileNotifier->notify(DIALOG_SIZE_CHANGED, 0);
1888}
1889
1890weld::Widget* SvtFileDialog::getControl( sal_Int16 nControlId, bool bLabelControl ) const
1891{
1892 weld::Widget* pReturn = nullptr;
1893
1894 switch ( nControlId )
1895 {
1896 case CONTROL_FILEVIEW:
1897 pReturn = bLabelControl ? nullptr : m_xFileView->identifier();
1898 break;
1899
1900 case EDIT_FILEURL:
1901 pReturn = bLabelControl
1902 ? static_cast<weld::Widget*>(m_xImpl->m_xFtFileName.get())
1903 : static_cast<weld::Widget*>(m_xImpl->m_xEdFileName->getWidget());
1904 break;
1905
1906 case EDIT_FILEURL_LABEL:
1907 pReturn = m_xImpl->m_xFtFileName.get();
1908 break;
1909
1910 case CHECKBOX_AUTOEXTENSION:
1911 pReturn = m_xImpl->m_xCbAutoExtension.get();
1912 break;
1913
1914 case CHECKBOX_PASSWORD:
1915 pReturn = m_xImpl->m_xCbPassword.get();
1916 break;
1917
1918 case CHECKBOX_GPGENCRYPTION:
1919 pReturn = m_xImpl->m_xCbGPGEncrypt.get();
1920 break;
1921
1922 case CHECKBOX_FILTEROPTIONS:
1923 pReturn = m_xImpl->m_xCbOptions.get();
1924 break;
1925
1926 case CHECKBOX_READONLY:
1927 pReturn = m_xCbReadOnly.get();
1928 break;
1929
1930 case CHECKBOX_LINK:
1931 pReturn = m_xCbLinkBox.get();
1932 break;
1933
1934 case CHECKBOX_PREVIEW:
1935 pReturn = m_xCbPreviewBox.get();
1936 break;
1937
1938 case CHECKBOX_SELECTION:
1939 pReturn = m_xCbSelection.get();
1940 break;
1941
1942 case LISTBOX_FILTER:
1943 pReturn = bLabelControl ? m_xImpl->m_xFtFileType.get() : m_xImpl->GetFilterListControl();
1944 break;
1945
1946 case LISTBOX_FILTER_LABEL:
1947 pReturn = m_xImpl->m_xFtFileType.get();
1948 break;
1949
1951 pReturn = m_xImpl->m_xEdCurrentPath->getWidget();
1952 break;
1953
1954 case LISTBOX_VERSION:
1955 pReturn = bLabelControl
1956 ? static_cast<weld::Widget*>(m_xImpl->m_xSharedLabel.get())
1957 : static_cast<weld::Widget*>(m_xImpl->m_xSharedListBox.get());
1958 break;
1959
1960 case LISTBOX_TEMPLATE:
1961 pReturn = bLabelControl
1962 ? static_cast<weld::Widget*>(m_xImpl->m_xSharedLabel.get())
1963 : static_cast<weld::Widget*>(m_xImpl->m_xSharedListBox.get());
1964 break;
1965
1966 case LISTBOX_IMAGE_TEMPLATE:
1967 pReturn = bLabelControl
1968 ? static_cast<weld::Widget*>(m_xImpl->m_xSharedLabel.get())
1969 : static_cast<weld::Widget*>(m_xImpl->m_xSharedListBox.get());
1970 break;
1971
1972 case LISTBOX_IMAGE_ANCHOR:
1973 pReturn = bLabelControl
1974 ? static_cast<weld::Widget*>(m_xImpl->m_xSharedLabel.get())
1975 : static_cast<weld::Widget*>(m_xImpl->m_xSharedListBox.get());
1976 break;
1977
1978 case LISTBOX_VERSION_LABEL:
1979 pReturn = m_xImpl->m_xSharedLabel.get();
1980 break;
1981
1982 case LISTBOX_TEMPLATE_LABEL:
1983 pReturn = m_xImpl->m_xSharedLabel.get();
1984 break;
1985
1986 case LISTBOX_IMAGE_TEMPLATE_LABEL:
1987 pReturn = m_xImpl->m_xSharedLabel.get();
1988 break;
1989
1990 case LISTBOX_IMAGE_ANCHOR_LABEL:
1991 pReturn = m_xImpl->m_xSharedLabel.get();
1992 break;
1993
1994 case PUSHBUTTON_OK:
1995 pReturn = m_xImpl->m_xBtnFileOpen.get();
1996 break;
1997
1998 case PUSHBUTTON_CANCEL:
1999 pReturn = m_xImpl->m_xBtnCancel.get();
2000 break;
2001
2002 case PUSHBUTTON_PLAY:
2003 pReturn = m_xPbPlay.get();
2004 break;
2005
2006 case PUSHBUTTON_HELP:
2007 pReturn = m_xImpl->m_xBtnHelp.get();
2008 break;
2009
2011 pReturn = m_xImpl->m_xBtnUp->getWidget();
2012 break;
2013
2015 pReturn = m_xImpl->m_xBtnNewFolder.get();
2016 break;
2017
2018 case LISTBOX_FILTER_SELECTOR:
2019 // only exists on SalGtkFilePicker
2020 break;
2021
2022 default:
2023 SAL_WARN( "fpicker.office", "SvtFileDialog::getControl: invalid id!" );
2024 }
2025 return pReturn;
2026}
2027
2028void SvtFileDialog::enableControl(sal_Int16 nControlId, bool bEnable)
2029{
2030 weld::Widget* pControl = getControl(nControlId);
2031 if (pControl)
2032 EnableControl(pControl, bEnable);
2033 weld::Widget* pLabel = getControl(nControlId, true);
2034 if (pLabel)
2035 EnableControl(pLabel, bEnable);
2036}
2037
2039{
2040 // create the "insert as link" checkbox, if needed
2042 {
2043 m_xCbLinkBox->set_label( FpsResId( STR_SVT_FILEPICKER_INSERT_AS_LINK ) );
2044 m_xCbLinkBox->set_help_id( HID_FILEDLG_LINK_CB );
2045 m_xCbLinkBox->connect_toggled( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
2046 m_xCbLinkBox->show();
2047 }
2048
2049 // create the "show preview" checkbox ( and the preview window, too ), if needed
2051 {
2052 m_xImpl->m_aIniKey = "ImportGraphicDialog";
2053
2054 // "preview"
2055 m_xCbPreviewBox->set_label( FpsResId( STR_SVT_FILEPICKER_SHOW_PREVIEW ) );
2057 m_xCbPreviewBox->connect_toggled( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
2058 m_xCbPreviewBox->show();
2059
2060 // generate preview window just here
2061 m_aPreviewSize = Size(200, 300);
2062 m_xPrevBmp->set_size_request(m_aPreviewSize.Width(), m_aPreviewSize.Height());
2063 m_xPrevBmp->connect_size_allocate(LINK(this, SvtFileDialog, PreviewSizeAllocHdl));
2064 m_xPreviewFrame->show();
2065 m_xPrevBmp->set_accessible_name(FpsResId(STR_PREVIEW));
2066 }
2067
2069 {
2070 m_xImpl->m_xCbAutoExtension->set_label( FpsResId( STR_SVT_FILEPICKER_AUTO_EXTENSION ) );
2071 m_xImpl->m_xCbAutoExtension->set_active(true);
2072 m_xImpl->m_xCbAutoExtension->connect_toggled( LINK( this, SvtFileDialog, AutoExtensionHdl_Impl ) );
2073 m_xImpl->m_xCbAutoExtension->show();
2074 }
2075
2077 {
2078 m_xImpl->m_xCbOptions->set_label( FpsResId( STR_SVT_FILEPICKER_FILTER_OPTIONS ) );
2079 m_xImpl->m_xCbOptions->connect_toggled( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
2080 m_xImpl->m_xCbOptions->show();
2081 }
2082
2084 {
2085 m_xCbSelection->set_label( FpsResId( STR_SVT_FILEPICKER_SELECTION ) );
2086 m_xCbSelection->connect_toggled( LINK( this, SvtFileDialog, ClickHdl_Impl ) );
2087 m_xCbSelection->show();
2088 }
2089
2091 {
2092 m_xPbPlay->set_label( FpsResId( STR_SVT_FILEPICKER_PLAY ) );
2093 m_xPbPlay->set_help_id( HID_FILESAVE_DOPLAY );
2094 m_xPbPlay->connect_clicked( LINK( this, SvtFileDialog, PlayButtonHdl_Impl ) );
2095 m_xPbPlay->show();
2096 }
2097
2099 {
2100 m_xImpl->m_xSharedLabel->set_label( FpsResId( STR_SVT_FILEPICKER_VERSION ) );
2101 m_xImpl->m_xSharedLabel->show();
2102
2103 m_xImpl->m_xSharedListBox->set_help_id( HID_FILEOPEN_VERSION );
2104 m_xImpl->m_xSharedListBox->show();
2105 }
2107 {
2108 m_xImpl->m_xSharedLabel->set_label( FpsResId( STR_SVT_FILEPICKER_TEMPLATES ) );
2109 m_xImpl->m_xSharedLabel->show();
2110
2111 m_xImpl->m_xSharedListBox->set_help_id( HID_FILEOPEN_VERSION );
2112 m_xImpl->m_xSharedListBox->show();
2113 // This is strange. During the re-factoring during 96930, I discovered that this help id
2114 // is set in the "Templates mode". This was hidden in the previous implementation.
2115 // Shouldn't this be a more meaningful help id.
2116 }
2118 {
2119 m_xImpl->m_xSharedLabel->set_label( FpsResId( STR_SVT_FILEPICKER_IMAGE_TEMPLATE ) );
2120 m_xImpl->m_xSharedLabel->show();
2121
2122 m_xImpl->m_xSharedListBox->set_help_id( HID_FILEOPEN_IMAGE_TEMPLATE );
2123 m_xImpl->m_xSharedListBox->show();
2124 }
2126 {
2127 m_xImpl->m_xSharedLabel->set_label( FpsResId( STR_SVT_FILEPICKER_IMAGE_ANCHOR ) );
2128 m_xImpl->m_xSharedLabel->show();
2129
2130 m_xImpl->m_xSharedListBox->set_help_id( HID_FILEOPEN_IMAGE_ANCHOR );
2131 m_xImpl->m_xSharedListBox->show();
2132 }
2133
2134 m_xImpl->m_xPlaces.reset(new PlacesListBox(m_xBuilder->weld_tree_view("places"),
2135 m_xBuilder->weld_button("add"),
2136 m_xBuilder->weld_button("del"),
2137 this));
2138 m_xImpl->m_xPlaces->set_help_id("SVT_HID_FILESAVE_PLACES_LISTBOX");
2139 m_xImpl->m_xPlaces->SetAddHdl( LINK ( this, SvtFileDialog, AddPlacePressed_Hdl ) );
2140 m_xImpl->m_xPlaces->SetDelHdl( LINK ( this, SvtFileDialog, RemovePlacePressed_Hdl ) );
2141
2143}
2144
2145IMPL_LINK(SvtFileDialog, PreviewSizeAllocHdl, const Size&, rSize, void)
2146{
2147 m_aPreviewSize = rSize;
2148}
2149
2151{
2152 if (m_xPrevBmp)
2153 return m_aPreviewSize.Width();
2154 else
2155 return 0;
2156}
2157
2159{
2160 if (m_xPrevBmp)
2161 return m_aPreviewSize.Height();
2162 else
2163 return 0;
2164}
2165
2166void SvtFileDialog::setImage(const Any& rImage)
2167{
2168 if (!m_xPrevBmp || !m_xPreviewFrame->get_visible())
2169 return;
2170
2171 Sequence < sal_Int8 > aBmpSequence;
2172
2173 if ( rImage >>= aBmpSequence )
2174 {
2175 BitmapEx aBmp;
2176 SvMemoryStream aData( aBmpSequence.getArray(),
2177 aBmpSequence.getLength(),
2178 StreamMode::READ );
2179 ReadDIBBitmapEx(aBmp, aData);
2180
2181 m_xPrevBmp->set_image(Graphic(aBmp).GetXGraphic());
2182 }
2183 else
2184 {
2185 m_xPrevBmp->set_image(nullptr);
2186 }
2187}
2188
2190{
2191 OUString sReturn;
2192 if (m_xImpl && m_xImpl->m_xEdFileName)
2193 sReturn = m_xImpl->m_xEdFileName->get_active_text();
2194 return sReturn;
2195}
2196
2197void SvtFileDialog::setCurrentFileText( const OUString& _rText, bool m_bSelectAll )
2198{
2199 if (m_xImpl && m_xImpl->m_xEdFileName)
2200 {
2201 m_xImpl->m_xEdFileName->set_entry_text( _rText );
2202 if ( m_bSelectAll )
2203 m_xImpl->m_xEdFileName->select_entry_region(0, -1);
2204 }
2205}
2206
2208{
2209 return m_xImpl->m_xCbAutoExtension && m_xImpl->m_xCbAutoExtension->get_active();
2210}
2211
2213{
2214 if (m_xPreviewFrame)
2215 return m_xPreviewFrame->get_visible();
2216 else
2217 return false;
2218}
2219
2220bool SvtFileDialog::ContentHasParentFolder( const OUString& rURL )
2221{
2222 m_aContent.bindTo( rURL );
2223
2224 if ( m_aContent.isInvalid() )
2225 return false;
2226
2228}
2229
2230bool SvtFileDialog::ContentCanMakeFolder( const OUString& rURL )
2231{
2232 m_aContent.bindTo( rURL );
2233
2234 if ( m_aContent.isInvalid() )
2235 return false;
2236
2238}
2239
2240bool SvtFileDialog::ContentGetTitle( const OUString& rURL, OUString& rTitle )
2241{
2242 m_aContent.bindTo( rURL );
2243
2244 if ( m_aContent.isInvalid() )
2245 return false;
2246
2247 OUString sTitle;
2248 m_aContent.getTitle( sTitle );
2249 rTitle = sTitle;
2250
2251 return m_aContent.isValid();
2252}
2253
2255 std::u16string_view rFilterDefaultExtension,
2256 const OUString& rFilterExtensions)
2257{
2258 const OUString aType(rFilterExtensions.toAsciiLowerCase());
2259
2260 if ( aType == FILEDIALOG_FILTER_ALL )
2261 return;
2262
2263 const OUString aTemp(rFileName.toAsciiLowerCase());
2264 sal_Int32 nPos = 0;
2265
2266 do
2267 {
2268 if (nPos+1<aType.getLength() && aType[nPos]=='*') // take care of a leading *
2269 ++nPos;
2270 const std::u16string_view aExt(o3tl::getToken(aType, 0, FILEDIALOG_DEF_EXTSEP, nPos ));
2271 if (aExt.empty())
2272 continue;
2273 if (o3tl::ends_with(aTemp, aExt))
2274 return;
2275 }
2276 while (nPos>=0);
2277
2278 rFileName += OUString::Concat(".") + rFilterDefaultExtension;
2279}
2280
2282{
2283 PlacePtr pRootPlace = std::make_shared<Place>( FpsResId(STR_DEFAULT_DIRECTORY), GetStandardDir() );
2284 m_xImpl->m_xPlaces->AppendPlace( pRootPlace );
2285
2286 // Load from user settings
2287 Sequence< OUString > placesUrlsList(officecfg::Office::Common::Misc::FilePickerPlacesUrls::get());
2288 Sequence< OUString > placesNamesList(officecfg::Office::Common::Misc::FilePickerPlacesNames::get());
2289
2290 for(sal_Int32 nPlace = 0; nPlace < placesUrlsList.getLength() && nPlace < placesNamesList.getLength(); ++nPlace)
2291 {
2292 PlacePtr pPlace = std::make_shared<Place>(placesNamesList[nPlace], placesUrlsList[nPlace], true);
2293 m_xImpl->m_xPlaces->AppendPlace(pPlace);
2294 }
2295
2296 // Reset the placesList "updated" state
2297 m_xImpl->m_xPlaces->IsUpdated();
2298}
2299
2301 const OUString& rTitle, const OUString& rDefaultText)
2302 : GenericDialogController(_pParent, "fps/ui/foldernamedialog.ui", "FolderNameDialog")
2303 , m_xNameEdit(m_xBuilder->weld_entry("entry"))
2304 , m_xOKBtn(m_xBuilder->weld_button("ok"))
2305{
2306 m_xDialog->set_title(rTitle);
2307 m_xNameEdit->set_text(rDefaultText);
2308 m_xNameEdit->select_region(0, -1);
2309 m_xOKBtn->connect_clicked(LINK(this, QueryFolderNameDialog, OKHdl));
2310 m_xNameEdit->connect_changed(LINK(this, QueryFolderNameDialog, NameHdl));
2311};
2312
2314{
2315}
2316
2318{
2319 // trim the strings
2320 m_xNameEdit->set_text(comphelper::string::strip(m_xNameEdit->get_text(), ' '));
2321 m_xDialog->response(RET_OK);
2322}
2323
2325{
2326 // trim the strings
2327 OUString aName = comphelper::string::strip(m_xNameEdit->get_text(), ' ');
2328 m_xOKBtn->set_sensitive(!aName.isEmpty());
2329}
2330
2331/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 nControlId
std::shared_ptr< Place > PlacePtr
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static OUString GetScheme(INetProtocol eTheScheme)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeFinalSlash()
INetURLObject smartRel2Abs(OUString const &rTheRelURIRef, bool &rWasAbsolute, bool bIgnoreFragment=false, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, bool bRelativeNonURIs=false, FSysStyle eStyle=FSysStyle::Detect) const
bool HasError() const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
bool setFinalSlash()
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static INetProtocol CompareProtocolScheme(std::u16string_view aTheAbsURIRef)
sal_Int32 getSegmentCount(bool bIgnoreFinalSlash=true) const
bool hasFinalSlash() const
INetProtocol GetProtocol() const
OUString getFSysPath(FSysStyle eStyle, sal_Unicode *pDelimiter=nullptr) const
ListBox to handle Places.
QueryFolderNameDialog(weld::Window *_pParent, const OUString &rTitle, const OUString &rDefaultText)
Definition: iodlg.cxx:2300
OUString GetName() const
virtual ~QueryFolderNameDialog() override
Definition: iodlg.cxx:2313
std::unique_ptr< weld::Entry > m_xNameEdit
std::unique_ptr< weld::Button > m_xOKBtn
constexpr tools::Long Height() const
constexpr tools::Long Width() const
OUString GetExtension() const
Definition: iodlgimp.hxx:56
const OUString & GetType() const
Definition: iodlgimp.hxx:55
const OUString & GetName() const
Definition: iodlgimp.hxx:54
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
std::unique_ptr< weld::Container > m_xContainer
Definition: iodlg.hxx:63
static bool IsolateFilterFromPath_Impl(OUString &rPath, OUString &rFilter)
Definition: iodlg.cxx:1815
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
bool isAutoExtensionEnabled() const
Definition: iodlg.cxx:2207
virtual void enableControl(sal_Int16 _nControlId, bool _bEnable) override
Definition: iodlg.cxx:2028
void EnableAutocompletion(bool _bEnable=true) override
Definition: iodlg.cxx:901
SvtFileDialogFilter_Impl * implAddFilter(const OUString &_rFilter, const OUString &_rType)
Definition: iodlg.cxx:1701
bool getShowState() override
Definition: iodlg.cxx:2212
::svt::SmartContent m_aContent
Definition: iodlg.hxx:71
bool m_bHasFilename
Definition: iodlg.hxx:79
OUString m_aPath
Definition: iodlg.hxx:129
AdjustFilterFlags adjustFilter(const OUString &_rFilter)
Definition: iodlg.cxx:551
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
bool ContentGetTitle(const OUString &rURL, OUString &rTitle)
Definition: iodlg.cxx:2240
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
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
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
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
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
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
virtual ~SvtFileDialog() override
Definition: iodlg.cxx:464
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
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
static OUString ParseSmart(const OUString &aText, const OUString &aBaseURL)
css::uno::Any GetUserItem(const OUString &sName) const
void SetUserItem(const OUString &sName, const css::uno::Any &aValue)
void SetWindowState(const OUString &sState)
OUString GetWindowState() const
bool Exists() const
static std::shared_ptr< ConfigurationChanges > create()
virtual void notify(sal_Int16 nEventId, sal_Int16 nControlId)=0
::svt::OFilePickerInteractionHandler * getOwnInteractionHandler() const
return the internal used interaction handler object ... Because this pointer will be valid only,...
void getTitle(OUString &_rTitle)
retrieves the title of the content @precond the content is bound and not invalid
void enableDefaultInteractionHandler()
disable the specialized interaction handler and use the global UI interaction handler only.
void disableInteractionHandler()
disable internal used interaction handler object ...
bool hasParentFolder()
checks if the content has a parent folder @precond the content is bound and not invalid
void bindTo(const OUString &_rURL)
(re)creates the content for the given URL
void enableOwnInteractionHandler(::svt::OFilePickerInteractionHandler::EInterceptedInteractions eInterceptions)
create and set a specialized interaction handler at the internal used command environment.
bool canCreateFolder()
checks if sub folders below the content can be created @precond the content is bound and not invalid
InteractionHandlerType queryCurrentInteractionHandler() const
return the type of the internal used interaction handler object ...
bool isInvalid() const
checks if the content is valid
bool isValid() const
checks if the content is valid
bool is(const OUString &_rURL)
checks if the content is existent (it is if and only if it is a document or a folder)
bool isFolder(const OUString &_rURL)
binds to the given URL, checks whether or not it refers to a folder
css::uno::Reference< css::sdbc::XResultSet > createCursor(const css::uno::Sequence< OUString > &rPropertyNames, ResultSetInclude eMode=INCLUDE_FOLDERS_AND_DOCUMENTS)
css::uno::Any getNodeValue(const OUString &_rPath) const noexcept
virtual short run()
std::shared_ptr< weld::Dialog > m_xDialog
std::unique_ptr< weld::Builder > m_xBuilder
virtual void set_sensitive(bool sensitive)=0
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
bool VCL_DLLPUBLIC ReadDIBBitmapEx(BitmapEx &rTarget, SvStream &rIStm, bool bFileHeader=true, bool bMSOFormat=false)
URL aURL
#define ERRCODE_IO_GENERAL
#define ERRCODE_IO_NOTEXISTSPATH
#define ERRCODE_IO_NOTEXISTS
#define FILE_SELECTION_CHANGED
#define CTRL_STATE_CHANGED
constexpr OUStringLiteral FILEDIALOG_FILTER_ALL
#define DIALOG_SIZE_CHANGED
#define DIRECTORY_CHANGED
PickerFlags
OUString FpsResId(TranslateId aId)
constexpr OUStringLiteral HID_FILEOPEN_IMAGE_ANCHOR
constexpr OUStringLiteral HID_FILEDLG_PREVIEW_CB
constexpr OUStringLiteral HID_FILESAVE_TEMPLATE
constexpr OUStringLiteral HID_FILESAVE_AUTOEXTENSION
constexpr OUStringLiteral HID_FILEOPEN_READONLY
constexpr OUStringLiteral HID_FILESAVE_SELECTION
constexpr OUStringLiteral HID_FILESAVE_DIALOG
constexpr OUStringLiteral HID_FILEOPEN_LEVELUP
constexpr OUStringLiteral HID_FILESAVE_FILEVIEW
constexpr OUStringLiteral HID_FILESAVE_FILEURL
constexpr OUStringLiteral HID_FILESAVE_FILETYPE
constexpr OUStringLiteral HID_FILEDLG_LINK_CB
constexpr OUStringLiteral HID_FILESAVE_CUSTOMIZEFILTER
constexpr OUStringLiteral HID_FILEOPEN_VERSION
constexpr OUStringLiteral HID_FILESAVE_CREATEDIRECTORY
constexpr OUStringLiteral HID_FILEOPEN_IMAGE_TEMPLATE
constexpr OUStringLiteral HID_FILESAVE_SAVEWITHPASSWORD
constexpr OUStringLiteral HID_FILESAVE_DOPLAY
constexpr OUStringLiteral HID_FILEDLG_STANDARD
constexpr OUStringLiteral HID_FILESAVE_LEVELUP
constexpr OUStringLiteral HID_FILESAVE_DOSAVE
OUString aName
IMPL_LINK(SvtFileDialog, OpenClickHdl_Impl, weld::Button &, rVoid, void)
Definition: iodlg.cxx:596
IMPL_LINK_NOARG(SvtFileDialog, NewFolderHdl_Impl, weld::Button &, void)
Definition: iodlg.cxx:503
AdjustFilterFlags
Definition: iodlg.hxx:42
std::deque< std::unique_ptr< SvtFileDialogFilter_Impl > > SvtFileDialogFilterList_Impl
Definition: iodlgimp.hxx:61
@ FILEDLG_MODE_SAVE
Definition: iodlgimp.hxx:66
@ FILEDLG_MODE_OPEN
Definition: iodlgimp.hxx:65
#define FILEDIALOG_DEF_WILDCARD
Definition: iodlgimp.hxx:33
#define FILEDIALOG_DEF_EXTSEP
Definition: iodlgimp.hxx:32
@ FILEDLG_TYPE_PATHDLG
Definition: iodlgimp.hxx:72
@ FILEDLG_TYPE_FILEDLG
Definition: iodlgimp.hxx:71
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
constexpr OUStringLiteral aData
@ Exception
OString strip(const OString &rIn, char c)
OUString reverseString(std::u16string_view rStr)
Reference< XComponentContext > getProcessComponentContext()
int i
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
constexpr bool ends_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
sal_Int16 nId
#define ERRCODE_SFX_INVALIDSYNTAX
OUString maURL
Definition: fileview.hxx:178
INetProtocol
FSysStyle
RET_OK
RET_CANCEL
RET_YES