42#include <fpicker/strings.hrc>
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>
66#include <osl/file.hxx>
69#include <com/sun/star/task/InteractionHandler.hpp>
70#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
72#include <osl/process.h>
75#include <officecfg/Office/Common.hxx>
92using namespace ExtendedFilePickerElementIds;
93using namespace CommonFilePickerElementIds;
94using namespace InternalFilePickerElementIds;
100 OUString getMostCurrentFilter( std::unique_ptr<SvtExpFileDlg_Impl>
const & pImpl )
102 assert( pImpl &&
"invalid impl pointer" );
106 pFilter = pImpl->GetCurFilter();
114 void restoreCurrentFilter( std::unique_ptr<SvtExpFileDlg_Impl>
const & pImpl )
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)!" );
119 pImpl->SelectFilterListEntry( pImpl->GetCurFilterDisplayName() );
122 OUString sSelectedDisplayName;
123 DBG_ASSERT( ( pImpl->GetSelectedFilterEntry( sSelectedDisplayName ) == pImpl->GetCurFilter() )
124 && ( sSelectedDisplayName == pImpl->GetCurFilterDisplayName() ),
125 "restoreCurrentFilter: inconsistence!" );
130 OUString GetFsysExtension_Impl( std::u16string_view rFile,
const OUString& rLastFilterExt )
132 size_t nDotPos = rFile.rfind(
'.' );
133 if ( nDotPos != std::u16string_view::npos )
135 if ( !rLastFilterExt.isEmpty() )
138 return rLastFilterExt;
141 return OUString(rFile.substr( nDotPos ));
147 void SetFsysExtension_Impl( OUString& rFile, std::u16string_view rExtension )
149 const sal_Int32 nDotPos{ rFile.lastIndexOf(
'.') };
152 if (!rExtension.empty())
153 rFile = OUString::Concat(rFile.subView(0, nDotPos)) + rExtension;
155 rFile = rFile.copy(0, nDotPos-1);
159 else if (!rExtension.empty())
160 rFile += OUString::Concat(
".") + rExtension;
164 void lcl_autoUpdateFileExtension(
SvtFileDialog* _pDialog,
const OUString& _rLastFilterExt )
172 OUString aExt = GetFsysExtension_Impl( aNewFile, _rLastFilterExt );
175 if ( aExt.isEmpty() )
180 bool bRealExtensions =
true;
181 if ( -1 != aExt.indexOf(
'/' ) )
182 bRealExtensions =
false;
183 else if ( -1 != aExt.indexOf(
'\\' ) )
184 bRealExtensions =
false;
192 if ( INetProtocol::NotValid ==
aURL.GetProtocol() )
195 if ( osl::FileBase::getFileURLFromSystemPath( aNewFile, sURL )
196 == osl::FileBase::E_None )
199 if ( INetProtocol::File ==
aURL.GetProtocol() )
205 catch(
const css::uno::Exception& )
207 SAL_INFO(
"fpicker.office",
"Exception in lcl_autoUpdateFileExtension" );
212 if ( bRealExtensions )
214 SetFsysExtension_Impl( aNewFile, _pDialog->
GetDefaultExt() );
220 bool lcl_getHomeDirectory(
const OUString& _rForURL, OUString& _rHomeDir )
229 Reference< XContentProvider > xProvider(
230 UniversalContentBroker::create(
232 queryContentProvider( _rForURL ) );
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() )
238 Reference< XPropertySetInfo > xPropInfo = xProviderProps->getPropertySetInfo();
239 static constexpr OUStringLiteral sHomeDirPropertyName( u
"HomeDirectory" );
240 if ( !xPropInfo.is() || xPropInfo->hasPropertyByName( sHomeDirPropertyName ) )
242 OUString sHomeDirectory;
243 xProviderProps->getPropertyValue( sHomeDirPropertyName ) >>= sHomeDirectory;
244 _rHomeDir = sHomeDirectory;
248 catch(
const Exception& )
252 return !_rHomeDir.isEmpty();
256 OUString lcl_ensureFinalSlash( std::u16string_view _rDir )
259 aWorkPathObj.setFinalSlash();
267 bool getEnvironmentValue(
const char* _pAsciiEnvName, OUString& _rValue )
270 OUString sEnvName = OUString::createFromAscii( _pAsciiEnvName );
271 osl_getEnvironment( sEnvName.pData, &_rValue.pData );
272 return !_rValue.isEmpty();
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)
288 , m_nPickerFlags(nStyle)
289 , m_bIsInExecute(false)
290 , m_bInExecuteAsync(false)
291 , m_bHasFilename(false)
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);
339 m_xImpl->m_xEdFileName->SetOnlyDirectories( bIsFolderPicker );
343 m_xImpl->m_xEdFileName->SetNoURLSelection( bSaveMode );
346 m_xImpl->m_bMultiSelection =
true;
368 m_xImpl->m_xCbPassword->set_label(
FpsResId( STR_SVT_FILEPICKER_PASSWORD ) );
370 m_xImpl->m_xCbPassword->show();
372 m_xImpl->m_xCbGPGEncrypt->show();
376 m_xImpl->m_aIniKey =
"FileDialog";
386 pResId = STR_EXPLORERFILE_SAVE;
387 pButtonResId = STR_EXPLORERFILE_BUTTONSAVE;
393 pResId = STR_PATHSELECT;
394 pButtonResId = STR_BUTTONSELECT;
404 m_xImpl->m_xFtFileType->hide();
405 m_xImpl->GetFilterListControl()->hide();
423 m_xImpl->m_aFilterIdle.SetPriority(TaskPriority::LOWEST);
454 ::comphelper::getProcessComponentContext(),
455 "/org.openoffice.Office.UI/FilePicker"
459 SizeAllocHdl(
Size());
461 m_xImpl->m_xEdFileName->grab_focus();
466 if (!
m_xImpl->m_aIniKey.isEmpty())
471 OUString sUserData =
m_xFileView->GetConfigString();
479 if (!
m_xImpl->m_xPlaces->IsUpdated())
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);
488 for (
auto const& place : aPlaces)
490 if(place->IsEditable()) {
491 placesUrlsListRange[
i] = place->GetUrl();
492 placesNamesListRange[
i] = place->GetName();
498 officecfg::Office::Common::Misc::FilePickerPlacesUrls::set(placesUrlsList, batch);
499 officecfg::Office::Common::Misc::FilePickerPlacesNames::set(placesNamesList, batch);
505 m_xFileView->EndInplaceEditing();
507 SmartContent aContent( m_xFileView->GetViewURL( ) );
509 aContent.getTitle( aTitle );
511 bool bHandled =
false;
517 OUString aUrl = aContent.createFolder(aDlg.
GetName());
518 if ( !aUrl.isEmpty( ) )
520 m_xFileView->CreatedFolder(aUrl, aDlg.
GetName());
544 if (
m_xImpl->GetCurFilter( ) )
555 const bool bNonEmpty = !rFilter.isEmpty();
560 bool bFilterChanged =
true;
569 if ( bFilterChanged )
585 if ( m_pCurrentAsyncAction.is() )
587 m_pCurrentAsyncAction->cancel();
588 onAsyncOperationFinished();
598 OpenHdl_Impl(&rVoid);
603 OpenHdl_Impl(&rVoid);
624 if ( aFileName.isEmpty() )
633 if ( aFileName.isEmpty() )
636 if ( !
m_xImpl->m_xEdFileName->get_active_text().isEmpty() )
638 OUString aText =
m_xImpl->m_xEdFileName->get_active_text();
643 if ( ( aText.getLength() == 2 && aText ==
".." ) ||
644 ( aText.getLength() == 3 && ( aText ==
"..\\" || aText ==
"../" ) ) )
650 if ( ( 1 == aText.getLength() ) && (
'~' == aText[0] ) )
653 if ( lcl_getHomeDirectory(
m_xFileView->GetViewURL(), aFileName ) )
655 m_xImpl->m_xEdFileName->set_entry_text( OUString() );
657 if ( aFileName.isEmpty() )
661 aFileName =
m_xImpl->m_xEdFileName->GetURL();
664 else if ( pVoid ==
m_xImpl->m_xBtnFileOpen.get() )
670 if ( aFileName.isEmpty() && pVoid ==
m_xImpl->m_xEdFileName.get() &&
m_xImpl->m_xUserFilter )
672 m_xImpl->m_xUserFilter.reset();
676 sal_Int32 nLen = aFileName.getLength();
682 aFileName =
m_xImpl->m_xEdCurrentPath->get_active_text();
683 nLen = aFileName.getLength();
691 m_xImpl->m_xEdFileName->select_entry_region(0, nLen);
703 m_xImpl->m_xEdFileName->set_entry_text( aFilter );
704 m_xImpl->m_xEdFileName->select_entry_region(0, -1);
709 if ( ( aFileObject.
GetProtocol() == INetProtocol::NotValid ) && !aFileName.isEmpty() )
712 if ( !sCompleted.isEmpty() )
713 aFileName = sCompleted;
718 bool bIsFolder =
false;
727 if ( !aFileName.isEmpty() )
732 SmartContent::InteractionHandlerType eInterActionHandlerType
734 if ( ( eInterActionHandlerType == SmartContent::IHT_NONE ) ||
735 ( eInterActionHandlerType == SmartContent::IHT_DEFAULT ) )
737 OFilePickerInteractionHandler::E_NOINTERCEPTION );
743 OFilePickerInteractionHandler* pHandler
746 OSL_ENSURE( pHandler,
"Got no Interaction Handler!!!" );
748 if ( pHandler->wasAccessDenied() )
754 if ( !pHandler->wasUsed() )
761 if ( eInterActionHandlerType == SmartContent::IHT_NONE )
763 else if ( eInterActionHandlerType == SmartContent::IHT_DEFAULT )
769 &&
m_xImpl->m_xCbAutoExtension->get_active()
782 m_xImpl->GetCurFilter()->GetType());
786 !
m_xImpl->m_bDoubleClick && pVoid !=
m_xImpl->m_xEdFileName.get();
834 OUString aMsg =
FpsResId(STR_SVT_ALREADYEXISTOVERWRITE);
835 aMsg = aMsg.replaceFirst(
840 VclMessageType::Question, VclButtonsType::YesNo, aMsg));
847 if (osl::FileBase::getSystemPathFromFileURL(aFileName, aCurPath) == osl::FileBase::E_None)
867 if ( INetProtocol::File == aFileObj.
GetProtocol( ) )
873 OUString sError(
FpsResId(RID_FILEOPEN_NOTEXISTENTFILE));
876 if ( INetProtocol::File == aFileObj.
GetProtocol() )
878 OUString sURL( sInvalidFile );
880 osl_getSystemPathFromFileURL( sURL.pData, &sSystem.pData );
881 sInvalidFile = sSystem;
883 sError = sError.replaceFirst(
"$name$", sInvalidFile );
886 VclMessageType::Warning, VclButtonsType::Ok, sError));
895 OSL_FAIL(
"SvtFileDialog, OpenHdl_Impl: invalid mode!");
903 m_xImpl->m_xEdFileName->EnableAutocomplete(bEnable);
908 OUString sSelectedFilterDisplayName;
910 if ( !pSelectedFilter )
914 restoreCurrentFilter( m_xImpl );
918 if ( ( pSelectedFilter != m_xImpl->GetCurFilter() )
919 || m_xImpl->m_xUserFilter
923 OUString sLastFilterExt = m_xImpl->GetCurFilter()->GetExtension();
924 m_xImpl->m_xUserFilter.reset();
927 m_xImpl->SetCurFilter( pSelectedFilter, sSelectedFilterDisplayName );
934 EraseDefaultExt( nSepPos );
937 lcl_autoUpdateFileExtension(
this, sLastFilterExt );
942 m_xImpl->m_aFilterIdle.Start();
955 m_xFileView->SetNoSelection();
960 FileNameGetFocusHdl_Impl(rComboBox);
965 OUString aPath = m_xImpl->m_xEdCurrentPath->GetURL();
972 m_xFileView->EndInplaceEditing();
975 short aRetCode = aDlg.run();
980 PlacePtr newPlace = aDlg.GetPlace();
981 m_xImpl->m_xPlaces->AppendPlace(newPlace);
999 m_xFileView->GetViewURL(),
true);
1000 m_xImpl->m_xPlaces->AppendPlace(newPlace);
1005 m_xImpl->m_xPlaces->RemoveSelectedPlace();
1010 const OUString& rFilter,
1014 bool& rFilterChanged
1025 sal_uInt16 nFilter = rList.size();
1030 const OUString& rType = pFilter->
GetType();
1035 while ( !pFoundFilter && nIdx != -1 )
1039 if ( aSingleType == rFilter )
1041 if ( aSingleType.equalsIgnoreAsciiCase( rFilter ) )
1043 pFoundFilter = pFilter;
1047 else if ( rType == rFilter )
1049 else if ( rType.equalsIgnoreAsciiCase( rFilter ) )
1051 pFoundFilter = pFilter;
1056 rFilterChanged =
m_xImpl->m_xUserFilter || (
m_xImpl->GetCurFilter() != pFilter );
1063 return pFoundFilter;
1069 executeAsync( AsyncPickerAction::eExecuteFilter, OUString(), getMostCurrentFilter(
m_xImpl) );
1088 m_xImpl->m_xEdFileName->SetBaseURL( rURL );
1094 SAL_WARN_IF( INetProtocol::NotValid == aObj.
GetProtocol(),
"fpicker.office",
"SvtFileDialog::UpdateControls: Invalid URL!" );
1098 osl::FileBase::getSystemPathFromFileURL(rURL, sText);
1099 if ( !sText.isEmpty() )
1113 m_xImpl->m_xEdFileName->set_entry_text( sText );
1120 if (osl::FileBase::getSystemPathFromFileURL(sURL, sText) != osl::FileBase::E_None)
1124 if ( sText.isEmpty() && !rURL.isEmpty() )
1127 m_xImpl->m_xEdCurrentPath->set_entry_text(sText);
1132 m_xImpl->m_xBtnUp->FillURLMenu();
1151 m_xImpl->m_xEdFileName->set_entry_text(
aName );
1152 m_xImpl->m_xEdFileName->select_entry_region(0, -1);
1153 m_aPath = pUserData->
maURL;
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;
1162 m_xImpl->m_xEdFileName->set_entry_text( OUString() );
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;
1176 if ( m_xImpl->m_bMultiSelection && m_xFileView->GetSelectionCount() > 1 )
1179 m_xImpl->m_xEdFileName->set_entry_text( OUString() );
1187 m_xImpl->m_bDoubleClick =
true;
1188 OpenHdl_Impl(
nullptr );
1189 m_xImpl->m_bDoubleClick =
false;
1200 const OUString& sCurrentFolder( pView->GetViewURL() );
1202 EnableControl( m_xImpl->m_xBtnNewFolder.get(), ContentCanMakeFolder( sCurrentFolder ) );
1205 bool bCanTravelUp = ContentHasParentFolder( pView->GetViewURL() );
1211 "fpicker.office",
"SvtFileDialog::OpenDoneHdl_Impl: invalid current URL!" );
1215 EnableControl( m_xImpl->m_xBtnUp->getWidget(), bCanTravelUp );
1220 if (m_pFileNotifier)
1224 lcl_autoUpdateFileExtension(
this, m_xImpl->GetCurFilter()->GetExtension() );
1229 if (!m_pFileNotifier)
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;
1255 if (m_pFileNotifier)
1262bool implIsInvalid(
const OUString & rURL )
1264 SmartContent aContent( rURL );
1266 aContent.isFolder();
1267 return aContent.isInvalid();
1279 bool bWasAbsolute =
false;
1280 aURLParser = aURLParser.
smartRel2Abs( _rPath, bWasAbsolute );
1301 aURLParser = aFallback;
1314 aURLParser = aParent;
1317 if ( !bIsInvalid && bIsFolder )
1332 short nResult = GenericDialogController::run();
1343 if (
aURL.GetProtocol() == INetProtocol::File )
1346 sal_Int32 nLevel =
aURL.getSegmentCount();
1349 aURL.removeSegment();
1360 m_xImpl->m_xBtnCancel->set_sensitive(
true);
1361 m_xImpl->m_xBtnCancel->grab_focus();
1369 m_xImpl->m_xEdFileName->grab_focus();
1376 m_xImpl->m_xPlaces->SetDelEnabled( enable );
1384 OUString sDisplayPath;
1385 if (osl::FileBase::getSystemPathFromFileURL(_rURL, sDisplayPath)
1386 == osl::FileBase::E_None)
1388 sDisplayPath = _rURL;
1392 InteractiveAugmentedIOException aException;
1393 aException.Arguments =
1394 { css::uno::Any(sDisplayPath),
1395 css::uno::Any(PropertyValue(
1397 -1, aException.Arguments[ 0 ], PropertyState_DIRECT_VALUE
1401 aException.Code = _eCode;
1402 aException.Classification = InteractionClassification_ERROR;
1406 new ::comphelper::OInteractionRequest(
Any( aException ) );
1407 pRequest->addContinuation( new ::comphelper::OInteractionAbort( ) );
1409 Reference< XInteractionHandler2 > xHandler(
1410 InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(),
nullptr ) );
1411 xHandler->handle( pRequest );
1427 rxControl->set_sensitive(
false);
1436 SAL_WARN(
"fpicker.office",
"SvtFileDialog::EnableControl: invalid control!" );
1458 if ( getEnvironmentValue(
"WorkDirMustContainRemovableMedia", aEnvValue ) && aEnvValue ==
"1" )
1465 Reference< XCommandEnvironment >(),
1467 Sequence< OUString > aProps {
"IsVolume",
"IsRemoveable" };
1469 Reference< XResultSet > xResultSet
1470 = aCnt.
createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_ONLY );
1471 if ( xResultSet.is() && !xResultSet->next() )
1474 VclMessageType::Warning, VclButtonsType::Ok,
1475 FpsResId(STR_SVT_NOREMOVABLEDEVICE)));
1480 catch ( ContentCreationException
const & )
1483 catch ( CommandAbortedException
const & )
1496 OUString aFileNameOnly;
1498 && (
m_aPath.indexOf(
':') == -1)
1499 && (
m_aPath.indexOf(
'\\') == -1)
1500 && (
m_aPath.indexOf(
'/') == -1))
1513 if ( !aFileNameOnly.isEmpty() )
1530 OUString aAll =
FpsResId( STR_FILTERNAME_ALL );
1531 bool bHasAll =
m_xImpl->HasFilterListEntry( aAll );
1532 if (
m_xImpl->GetCurFilter() || nFilterCount == 1 || ( nFilterCount == 2 && bHasAll ) )
1536 if ( !
m_xImpl->GetCurFilter() )
1538 sal_uInt16
nPos = 0;
1539 if ( 2 == nFilterCount && bHasAll )
1541 nPos = nFilterCount;
1549 assert( pNewCurFilter &&
"SvtFileDialog::run: invalid filter pos!" );
1550 m_xImpl->SetCurFilter( pNewCurFilter, pNewCurFilter->
GetName() );
1554 m_xImpl->SelectFilterListEntry(
m_xImpl->GetCurFilter()->GetName() );
1557 if ( nSepPos != -1 )
1566 m_xImpl->InsertFilterListEntry( pAllFilter );
1567 m_xImpl->SetCurFilter( pAllFilter, aAll );
1569 m_xImpl->SelectFilterListEntry( aAll );
1581 m_xImpl->m_xEdFileName->set_entry_text( aFilter );
1587 sal_Int32 nFileNameLen = aFileName.getLength();
1588 bool bFileToSelect = nFileNameLen != 0;
1589 if ( bFileToSelect && aFileName[ nFileNameLen - 1 ] !=
'/' )
1592 m_xImpl->m_xEdFileName->set_entry_text( aDecodedName );
1617 const OUString& rURL,
const OUString& rFilter )
1623 bool bReallyAsync =
true;
1626 sal_Int32 nMinTimeout = 0;
1628 sal_Int32 nMaxTimeout = 0;
1666 m_xImpl->SetDenyList( rDenyList );
1672 return m_xImpl->GetDenyList();
1682 return m_xImpl->GetStandardDir();
1691 executeAsync( AsyncPickerAction::ePrevLevel, sDummy, sDummy );
1704 m_xImpl->m_aFilter.push_front( std::unique_ptr<SvtFileDialogFilter_Impl>( pNewFilter ) );
1706 if ( !
m_xImpl->GetCurFilter() )
1707 m_xImpl->SetCurFilter( pNewFilter, rFilter );
1724 const StringPair* pSubFilters = rFilters.getConstArray();
1725 const StringPair* pSubFiltersEnd = pSubFilters + rFilters.getLength();
1726 for ( ; pSubFilters != pSubFiltersEnd; ++pSubFilters )
1741 if ( pFilter->
GetName() == rFilter )
1743 m_xImpl->SetCurFilter( pFilter, rFilter );
1754 if ( pCurrentFilter )
1755 aFilter = pCurrentFilter->
GetName();
1767 return m_xImpl->m_aFilter.size();
1778 if (
m_xImpl->m_aIniKey.isEmpty())
1790 if ( aUserData >>= sCfgStr )
1797 std::vector<OUString> aList;
1807 aList.push_back(
m_xImpl->m_xEdFileName->GetURL());
1818 sal_Int32 nQuestionMarkPos = rPath.indexOf(
'?' );
1821 if ( nQuestionMarkPos != -1 )
1826 if ( INetProtocol::NotValid != eProt && INetProtocol::File != eProt )
1827 nQuestionMarkPos = -1;
1829 nWildCardPos = std::min( nWildCardPos, nQuestionMarkPos );
1834 if ( nWildCardPos == -1 )
1837 sal_Int32 nPathTokenPos = aReversePath.indexOf(
'/' );
1839 if ( nPathTokenPos == -1 )
1849 nPathTokenPos = aReversePath.indexOf( aDelim );
1851 if ( nPathTokenPos == -1 )
1853 nPathTokenPos = aReversePath.indexOf(
':' );
1859 if ( nPathTokenPos != -1 )
1861 if ( nPathTokenPos < (rPath.getLength() - nWildCardPos - 1) )
1868 rFilter = aReversePath.copy( 0, nPathTokenPos );
1872 rPath = aReversePath.copy( nPathTokenPos );
1886 if (m_pFileNotifier)
1896 case CONTROL_FILEVIEW:
1897 pReturn = bLabelControl ? nullptr :
m_xFileView->identifier();
1901 pReturn = bLabelControl
1906 case EDIT_FILEURL_LABEL:
1907 pReturn =
m_xImpl->m_xFtFileName.get();
1910 case CHECKBOX_AUTOEXTENSION:
1911 pReturn =
m_xImpl->m_xCbAutoExtension.get();
1914 case CHECKBOX_PASSWORD:
1915 pReturn =
m_xImpl->m_xCbPassword.get();
1918 case CHECKBOX_GPGENCRYPTION:
1919 pReturn =
m_xImpl->m_xCbGPGEncrypt.get();
1922 case CHECKBOX_FILTEROPTIONS:
1923 pReturn =
m_xImpl->m_xCbOptions.get();
1926 case CHECKBOX_READONLY:
1934 case CHECKBOX_PREVIEW:
1938 case CHECKBOX_SELECTION:
1942 case LISTBOX_FILTER:
1943 pReturn = bLabelControl ?
m_xImpl->m_xFtFileType.get() :
m_xImpl->GetFilterListControl();
1946 case LISTBOX_FILTER_LABEL:
1947 pReturn =
m_xImpl->m_xFtFileType.get();
1951 pReturn =
m_xImpl->m_xEdCurrentPath->getWidget();
1954 case LISTBOX_VERSION:
1955 pReturn = bLabelControl
1960 case LISTBOX_TEMPLATE:
1961 pReturn = bLabelControl
1966 case LISTBOX_IMAGE_TEMPLATE:
1967 pReturn = bLabelControl
1972 case LISTBOX_IMAGE_ANCHOR:
1973 pReturn = bLabelControl
1978 case LISTBOX_VERSION_LABEL:
1979 pReturn =
m_xImpl->m_xSharedLabel.get();
1982 case LISTBOX_TEMPLATE_LABEL:
1983 pReturn =
m_xImpl->m_xSharedLabel.get();
1986 case LISTBOX_IMAGE_TEMPLATE_LABEL:
1987 pReturn =
m_xImpl->m_xSharedLabel.get();
1990 case LISTBOX_IMAGE_ANCHOR_LABEL:
1991 pReturn =
m_xImpl->m_xSharedLabel.get();
1995 pReturn =
m_xImpl->m_xBtnFileOpen.get();
1998 case PUSHBUTTON_CANCEL:
1999 pReturn =
m_xImpl->m_xBtnCancel.get();
2002 case PUSHBUTTON_PLAY:
2007 pReturn =
m_xImpl->m_xBtnHelp.get();
2011 pReturn =
m_xImpl->m_xBtnUp->getWidget();
2015 pReturn =
m_xImpl->m_xBtnNewFolder.get();
2018 case LISTBOX_FILTER_SELECTOR:
2023 SAL_WARN(
"fpicker.office",
"SvtFileDialog::getControl: invalid id!" );
2052 m_xImpl->m_aIniKey =
"ImportGraphicDialog";
2070 m_xImpl->m_xCbAutoExtension->set_label(
FpsResId( STR_SVT_FILEPICKER_AUTO_EXTENSION ) );
2071 m_xImpl->m_xCbAutoExtension->set_active(
true);
2073 m_xImpl->m_xCbAutoExtension->show();
2078 m_xImpl->m_xCbOptions->set_label(
FpsResId( STR_SVT_FILEPICKER_FILTER_OPTIONS ) );
2080 m_xImpl->m_xCbOptions->show();
2100 m_xImpl->m_xSharedLabel->set_label(
FpsResId( STR_SVT_FILEPICKER_VERSION ) );
2101 m_xImpl->m_xSharedLabel->show();
2104 m_xImpl->m_xSharedListBox->show();
2108 m_xImpl->m_xSharedLabel->set_label(
FpsResId( STR_SVT_FILEPICKER_TEMPLATES ) );
2109 m_xImpl->m_xSharedLabel->show();
2112 m_xImpl->m_xSharedListBox->show();
2119 m_xImpl->m_xSharedLabel->set_label(
FpsResId( STR_SVT_FILEPICKER_IMAGE_TEMPLATE ) );
2120 m_xImpl->m_xSharedLabel->show();
2123 m_xImpl->m_xSharedListBox->show();
2127 m_xImpl->m_xSharedLabel->set_label(
FpsResId( STR_SVT_FILEPICKER_IMAGE_ANCHOR ) );
2128 m_xImpl->m_xSharedLabel->show();
2131 m_xImpl->m_xSharedListBox->show();
2138 m_xImpl->m_xPlaces->set_help_id(
"SVT_HID_FILESAVE_PLACES_LISTBOX");
2147 m_aPreviewSize = rSize;
2171 Sequence < sal_Int8 > aBmpSequence;
2173 if ( rImage >>= aBmpSequence )
2177 aBmpSequence.getLength(),
2193 sReturn =
m_xImpl->m_xEdFileName->get_active_text();
2201 m_xImpl->m_xEdFileName->set_entry_text( _rText );
2203 m_xImpl->m_xEdFileName->select_entry_region(0, -1);
2209 return m_xImpl->m_xCbAutoExtension &&
m_xImpl->m_xCbAutoExtension->get_active();
2255 std::u16string_view rFilterDefaultExtension,
2256 const OUString& rFilterExtensions)
2258 const OUString aType(rFilterExtensions.toAsciiLowerCase());
2263 const OUString aTemp(rFileName.toAsciiLowerCase());
2268 if (
nPos+1<aType.getLength() && aType[
nPos]==
'*')
2278 rFileName += OUString::Concat(
".") + rFilterDefaultExtension;
2284 m_xImpl->m_xPlaces->AppendPlace( pRootPlace );
2287 Sequence< OUString > placesUrlsList(officecfg::Office::Common::Misc::FilePickerPlacesUrls::get());
2288 Sequence< OUString > placesNamesList(officecfg::Office::Common::Misc::FilePickerPlacesNames::get());
2290 for(sal_Int32 nPlace = 0; nPlace < placesUrlsList.getLength() && nPlace < placesNamesList.getLength(); ++nPlace)
2292 PlacePtr pPlace = std::make_shared<Place>(placesNamesList[nPlace], placesUrlsList[nPlace],
true);
2293 m_xImpl->m_xPlaces->AppendPlace(pPlace);
2297 m_xImpl->m_xPlaces->IsUpdated();
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"))
2328 m_xOKBtn->set_sensitive(!
aName.isEmpty());
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
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 removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
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.
constexpr tools::Long Height() const
constexpr tools::Long Width() const
OUString GetExtension() const
const OUString & GetType() const
const OUString & GetName() const
sal_uInt16 GetFilterCount() const
std::unique_ptr< SvtExpFileDlg_Impl > m_xImpl
void SetDenyList(const css::uno::Sequence< OUString > &rDenyList) override
void EraseDefaultExt(sal_Int32 _nIndex=0)
std::unique_ptr< weld::Container > m_xContainer
static bool IsolateFilterFromPath_Impl(OUString &rPath, OUString &rFilter)
void EnableControl(weld::Widget *pControl, bool bEnable)
enables or disables a control
void OpenMultiSelection_Impl()
static void displayIOException(const OUString &_rURL, css::ucb::IOErrorCode _eCode)
bool isAutoExtensionEnabled() const
virtual void enableControl(sal_Int16 _nControlId, bool _bEnable) override
void EnableAutocompletion(bool _bEnable=true) override
SvtFileDialogFilter_Impl * implAddFilter(const OUString &_rFilter, const OUString &_rType)
bool getShowState() override
::svt::SmartContent m_aContent
AdjustFilterFlags adjustFilter(const OUString &_rFilter)
bool ContentCanMakeFolder(const OUString &rURL)
SvtFileDialogFilter_Impl * FindFilter_Impl(const OUString &_rFilter, bool _bMultiExt, bool &_rFilterChanged)
find a filter with the given wildcard
std::unique_ptr< SvtFileView > m_xFileView
std::unique_ptr< weld::CheckButton > m_xCbPreviewBox
void SetDefaultExt(const OUString &rExt)
void onAsyncOperationFinished() override
std::unique_ptr< weld::CheckButton > m_xCbSelection
virtual short run() override
std::unique_ptr< weld::Button > m_xPbPlay
void onAsyncOperationStarted() override
std::vector< OUString > GetPathList() const override
bool ContentGetTitle(const OUString &rURL, OUString &rTitle)
OUString getCurrentFileText() const override
void EnableUI(bool _bEnable)
enables or disables the complete UI of the file picker, with only offering a cancel button
static void appendDefaultExtension(OUString &_rFileName, std::u16string_view _rFilterDefaultExtension, const OUString &_rFilterExtensions)
helper function to check and append the default filter extension if necessary.
void setImage(const css::uno::Any &rImage) override
void OpenURL_Impl(const OUString &rURL)
const OUString & GetStandardDir() const override
const OUString & GetDefaultExt() const
void executeAsync(::svt::AsyncPickerAction::Action _eAction, const OUString &_rURL, const OUString &_rFilter)
executes a certain FileView action asynchronously
void SetCurFilter(const OUString &rFilter) override
void OpenHdl_Impl(void const *pVoid)
OUString GetCurFilter() const override
::svt::IFilePickerListener * m_pFileNotifier
std::unique_ptr< weld::Widget > m_xPreviewFrame
OUString implGetInitialURL(const OUString &_rPath, std::u16string_view _rFallback)
void FilterSelect() override
void createNewUserFilter(const OUString &_rNewFilter)
updates m_xUserFilter with a new filter
void AddFilter(const OUString &rFilter, const OUString &rType) override
void SetStandardDir(const OUString &rStdDir) override
sal_Int32 getAvailableWidth() override
std::unique_ptr< weld::CheckButton > m_xCbReadOnly
::rtl::Reference< ::svt::AsyncPickerAction > m_pCurrentAsyncAction
void setCurrentFileText(const OUString &_rText, bool _bSelectAll=false) override
virtual bool PrepareExecute() override
PickerFlags m_nPickerFlags
bool ContentHasParentFolder(const OUString &rURL)
SvtFileDialog(weld::Window *pParent, PickerFlags nBits)
sal_Int32 getAvailableHeight() override
const OUString & GetFilterName(sal_uInt16 nPos) const
void AddFilterGroup(const OUString &_rFilter, const css::uno::Sequence< css::beans::StringPair > &rFilters) override
virtual OUString getCurFilter() const override
virtual weld::Widget * getControl(sal_Int16 nControlId, bool bLabelControl=false) const override
virtual ~SvtFileDialog() override
void RemovablePlaceSelected(bool enable=true)
const css::uno::Sequence< OUString > & GetDenyList() const override
std::unique_ptr< weld::Image > m_xPrevBmp
void UpdateControls(const OUString &rURL) override
bool ContentIsFolder(const OUString &rURL) override
::std::set< weld::Widget * > m_aDisabledControls
::utl::OConfigurationNode m_aConfiguration
std::unique_ptr< weld::CheckButton > m_xCbLinkBox
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
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
std::shared_ptr< weld::Dialog > m_xDialog
std::unique_ptr< weld::Builder > m_xBuilder
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#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
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
IMPL_LINK(SvtFileDialog, OpenClickHdl_Impl, weld::Button &, rVoid, void)
IMPL_LINK_NOARG(SvtFileDialog, NewFolderHdl_Impl, weld::Button &, void)
std::deque< std::unique_ptr< SvtFileDialogFilter_Impl > > SvtFileDialogFilterList_Impl
#define FILEDIALOG_DEF_WILDCARD
#define FILEDIALOG_DEF_EXTSEP
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
constexpr OUStringLiteral aData
OString strip(const OString &rIn, char c)
OUString reverseString(std::u16string_view rStr)
Reference< XComponentContext > getProcessComponentContext()
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)
const sal_Int16 TOOLBOXBUTTON_NEW_FOLDER
const sal_Int16 FIXEDTEXT_CURRENTFOLDER
const sal_Int16 PUSHBUTTON_HELP
const sal_Int16 TOOLBOXBUTTON_LEVEL_UP
#define ERRCODE_SFX_INVALIDSYNTAX