26#include <com/sun/star/lang/XInitialization.hpp>
27#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
28#include <com/sun/star/ui/dialogs/ControlActions.hpp>
29#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
30#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
31#include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp>
32#include <com/sun/star/ui/dialogs/FolderPicker.hpp>
33#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
34#include <com/sun/star/ui/dialogs/XControlInformation.hpp>
35#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
36#include <com/sun/star/ui/dialogs/XFilePreview.hpp>
37#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
38#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
39#include <com/sun/star/lang/XServiceInfo.hpp>
40#include <com/sun/star/lang/XSingleServiceFactory.hpp>
41#include <com/sun/star/lang/XMultiServiceFactory.hpp>
42#include <com/sun/star/beans/PropertyValue.hpp>
43#include <com/sun/star/beans/NamedValue.hpp>
44#include <com/sun/star/beans/XPropertySet.hpp>
45#include <com/sun/star/embed/ElementModes.hpp>
46#include <com/sun/star/container/XEnumeration.hpp>
47#include <com/sun/star/container/XContainerQuery.hpp>
48#include <com/sun/star/container/XNameAccess.hpp>
49#include <com/sun/star/container/XNameContainer.hpp>
50#include <com/sun/star/task/InteractionHandler.hpp>
51#include <com/sun/star/task/XInteractionRequest.hpp>
52#include <com/sun/star/util/RevisionTag.hpp>
63#include <osl/file.hxx>
64#include <osl/security.hxx>
87#include <sfx2/sfxsids.hrc>
90#include <sfx2/strings.hrc>
95#include <officecfg/Office/Common.hxx>
106using namespace ::com::sun::star::ui::dialogs::TemplateDescription;
109using namespace ::
cppu;
120 bool lclSupportsOOXMLEncryption(std::u16string_view aFilterName)
122 return aFilterName ==
u"Calc MS Excel 2007 XML"
123 || aFilterName ==
u"MS Word 2007 XML"
124 || aFilterName ==
u"Impress MS PowerPoint 2007 XML"
125 || aFilterName ==
u"Impress MS PowerPoint 2007 XML AutoPlay"
126 || aFilterName ==
u"Calc Office Open XML"
127 || aFilterName ==
u"Impress Office Open XML"
128 || aFilterName ==
u"Impress Office Open XML AutoPlay"
129 || aFilterName ==
u"Office Open XML Text";
135 static constexpr OUStringLiteral aSD_EXPORT_IDENTIFIER(
u"SdExportLastFilter");
136 static constexpr OUStringLiteral aSI_EXPORT_IDENTIFIER(
u"SiExportLastFilter");
137 static constexpr OUStringLiteral aSW_EXPORT_IDENTIFIER(
u"SwExportLastFilter");
207 TimeOutHdl_Impl(
nullptr );
216 switch (
aEvent.ElementId )
218 case ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION :
222 case ExtendedFilePickerElementIds::CHECKBOX_PASSWORD :
226 case ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS :
230 case ExtendedFilePickerElementIds::CHECKBOX_READONLY :
234 case ExtendedFilePickerElementIds::CHECKBOX_LINK :
238 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW :
242 case ExtendedFilePickerElementIds::PUSHBUTTON_PLAY :
246 case ExtendedFilePickerElementIds::LISTBOX_VERSION_LABEL :
247 case ExtendedFilePickerElementIds::LISTBOX_VERSION :
251 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE_LABEL :
252 case ExtendedFilePickerElementIds::LISTBOX_TEMPLATE :
256 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE_LABEL :
257 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE :
261 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_ANCHOR_LABEL :
262 case ExtendedFilePickerElementIds::LISTBOX_IMAGE_ANCHOR :
266 case ExtendedFilePickerElementIds::CHECKBOX_SELECTION :
271 SAL_WARN(
"sfx.dialog",
"invalid element id" );
283 switch (
aEvent.ElementId )
285 case CommonFilePickerElementIds::LISTBOX_FILTER:
294 case ExtendedFilePickerElementIds::CHECKBOX_PREVIEW:
303 TimeOutHdl_Impl(
nullptr );
318 mxFileDlg->removeFilePickerListener(
this );
320 ::comphelper::disposeComponent(
mxFileDlg );
327 OUString aFilterName;
331 aFilterName =
mxFileDlg->getCurrentFilter();
346 OUString aLastFilter;
347 if( aDlgOpt.
GetUserItem( _rContextIdentifier ) >>= aLastFilter )
364 if (
mpMatcher && !aFilterName.isEmpty() )
374 uno::Reference < XFilePickerControlAccess > xCtrlAccess(
mxFileDlg, UNO_QUERY );
375 if ( xCtrlAccess.is() )
379 xCtrlAccess->enableControl( _nExtendedControlId, _bEnable );
382 catch(
const IllegalArgumentException& )
392 bool bResult =
false;
398 Sequence < PropertyValue > aProps;
400 if ( aAny >>= aProps )
402 OUString aServiceName;
403 for(
const auto& rProp : std::as_const(aProps) )
405 if( rProp.Name ==
"UIComponent" )
407 rProp.Value >>= aServiceName;
408 if( !aServiceName.isEmpty() )
428 case FILEOPEN_SIMPLE:
429 case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
431 case FILEOPEN_LINK_PLAY:
432 case FILEOPEN_READONLY_VERSION:
433 case FILEOPEN_LINK_PREVIEW:
434 case FILEOPEN_PREVIEW:
447 ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS,
454 uno::Reference < XFilePickerControlAccess > xCtrlAccess(
mxFileDlg, UNO_QUERY );
455 if ( !xCtrlAccess.is() )
458 OUString sOldLabel( xCtrlAccess->getLabel( CommonFilePickerElementIds::PUSHBUTTON_OK ) );
464 sal_Int32
nIndex = sOldLabel.indexOf(
"..." );
466 nIndex = sOldLabel.getLength();
475 if ( sOldLabel != sLabel )
479 xCtrlAccess->setLabel( CommonFilePickerElementIds::PUSHBUTTON_OK, sLabel );
481 catch(
const IllegalArgumentException& )
494 bool bSelectionBoxFound =
false;
495 uno::Reference< XControlInformation > xCtrlInfo(
mxFileDlg, UNO_QUERY );
496 if ( xCtrlInfo.is() )
498 Sequence< OUString > aCtrlList = xCtrlInfo->getSupportedControls();
502 if ( bSelectionBoxFound )
506 ExtendedFilePickerElementIds::CHECKBOX_SELECTION,
507 (
mbSelectionEnabled && pFilter && ( pFilter->GetFilterFlags() & SfxFilterFlags::SUPPORTSSELECTION ) ) );
508 uno::Reference< XFilePickerControlAccess > xCtrlAccess(
mxFileDlg, UNO_QUERY );
509 xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0,
Any(
mbSelection ) );
522 ExtendedFilePickerElementIds::CHECKBOX_PASSWORD,
523 pCurrentFilter && ( pCurrentFilter->GetFilterFlags() & SfxFilterFlags::ENCRYPTION )
531 uno::Reference< XFilePickerControlAccess > xCtrlAccess(
mxFileDlg, UNO_QUERY );
533 xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0,
Any(
true ) );
538 uno::Reference< XFilePickerControlAccess > xCtrlAccess(
mxFileDlg, UNO_QUERY );
540 xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0,
Any(
true ) );
545 uno::Reference< XFilePickerControlAccess > xCtrlAccess(
mxFileDlg, UNO_QUERY );
546 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0 );
547 bool bPassWord =
false;
549 xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0,
Any(
false ) );
558 uno::Reference< XFilePickerControlAccess > xCtrlAccess(
mxFileDlg, UNO_QUERY );
561 if ( !xCtrlAccess.is() )
566 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0 );
567 bool bShowPreview =
false;
569 if ( aValue >>= bShowPreview )
575 uno::Reference< XFilePreview > xFilePreview(
mxFileDlg, UNO_QUERY );
576 if ( xFilePreview.is() )
579 if ( _bUpdatePreviewWindow )
580 TimeOutHdl_Impl(
nullptr );
592 Sequence < OUString > aPathSeq =
mxFileDlg->getFiles();
594 if ( aPathSeq.getLength() == 1 )
598 if ( ( aObj.
GetProtocol() == INetProtocol::File ) &&
605 embed::ElementModes::READ );
607 DBG_ASSERT( xStorage.is(),
"The method must return the storage or throw exception!" );
608 if ( !xStorage.is() )
609 throw uno::RuntimeException();
613 aEntries.realloc( xVersions.getLength() + 1 );
616 std::transform(xVersions.begin(), xVersions.end(), std::next(
aEntries.getArray()),
617 [](
const util::RevisionTag& rVersion) -> OUString { return rVersion.Identifier; });
619 catch(
const uno::Exception& )
625 uno::Reference < XFilePickerControlAccess > xDlg(
mxFileDlg, UNO_QUERY );
630 xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
631 ControlActions::DELETE_ITEMS, aValue );
633 catch(
const IllegalArgumentException& ){}
641 xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
642 ControlActions::ADD_ITEMS, aValue );
645 aPos <<= sal_Int32(0);
646 xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
647 ControlActions::SET_SELECT_ITEM, aPos );
649 catch(
const IllegalArgumentException& ){}
660 uno::Reference < XFilePreview > xFilePicker( mxFileDlg, UNO_QUERY );
662 if ( ! xFilePicker.is() )
665 Sequence < OUString > aPathSeq = mxFileDlg->getFiles();
667 if ( mbShowPreview && ( aPathSeq.getLength() == 1 ) )
669 OUString
aURL = aPathSeq[0];
685 sal_Int32 nOutWidth = xFilePicker->getAvailableWidth();
686 sal_Int32 nOutHeight = xFilePicker->getAvailableHeight();
690 double nXRatio =
static_cast<double>(nOutWidth) / nBmpWidth;
691 double nYRatio =
static_cast<double>(nOutHeight) / nBmpHeight;
693 if ( nXRatio < nYRatio )
694 aBmp.
Scale( nXRatio, nXRatio );
696 aBmp.
Scale( nYRatio, nYRatio );
699 aBmp.
Convert( BmpConversion::N24Bit );
706 const Sequence < sal_Int8 >
aBuffer(
708 aData.GetEndOfData() );
719 xFilePicker->setImage( FilePreviewImageFormats::BITMAP, aAny );
721 catch(
const IllegalArgumentException& )
738 sal_uInt16 nFilter = !aCurFilter.isEmpty() &&
mpGraphicFilter->GetImportFormatCount()
759 nRet =
mpGraphicFilter->ImportGraphic( rGraphic, rURL, *pStream, nFilter,
nullptr, nFilterImportFlags );
761 nRet =
mpGraphicFilter->ImportGraphic( rGraphic, aURLObj, nFilter,
nullptr, nFilterImportFlags );
765 nRet =
mpGraphicFilter->ImportGraphic( rGraphic, aURLObj, nFilter,
nullptr, nFilterImportFlags );
778 Sequence<OUString> aPathSeq =
mxFileDlg->getFiles();
780 if (aPathSeq.getLength() == 1)
785 if (!aPath.isEmpty())
797 uno::Reference< XServiceInfo > xSI( _rxFP, UNO_QUERY );
800 return xSI->supportsService(
"com.sun.star.ui.dialogs.SystemFilePicker" );
810bool lcl_isAsyncFilePicker(
const uno::Reference< XExecutableDialog >& _rxFP )
814 uno::Reference<XAsynchronousExecutableDialog> xSI(_rxFP, UNO_QUERY);
817 catch(
const Exception& )
831 case FILEOPEN_SIMPLE:
832 case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
833 case FILEOPEN_LINK_PREVIEW_IMAGE_ANCHOR:
835 case FILEOPEN_LINK_PLAY:
836 case FILEOPEN_READONLY_VERSION:
837 case FILEOPEN_LINK_PREVIEW:
838 case FILEOPEN_PREVIEW:
840 case FILESAVE_SIMPLE:
841 case FILESAVE_AUTOEXTENSION_PASSWORD:
842 case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS:
843 case FILESAVE_AUTOEXTENSION_SELECTION:
844 case FILESAVE_AUTOEXTENSION_TEMPLATE:
845 case FILESAVE_AUTOEXTENSION:
859 return css::uno::Reference<css::awt::XWindow>();
864 sal_Int16 nDialogType,
869 const css::uno::Sequence< OUString >& rDenyList
871 :maPreviewIdle(
"sfx2 FileDialogHelper_Impl maPreviewIdle")
872 ,m_nDialogType ( nDialogType )
875 const char* pServiceName=
nullptr;
880 pServiceName =
"com.sun.star.ui.dialogs.OfficeFilePicker";
883 pServiceName =
"com.sun.star.ui.dialogs.RemoteFilePicker";
886 pServiceName =
"com.sun.star.ui.dialogs.FilePicker";
890 OUString aService = OUString::createFromAscii( pServiceName );
892 uno::Reference< XMultiServiceFactory >
xFactory( ::comphelper::getProcessServiceFactory() );
935 uno::Reference< XInitialization > xInit(
mxFileDlg, UNO_QUERY );
945 sal_Int16 nTemplateDescription = TemplateDescription::FILEOPEN_SIMPLE;
949 case FILEOPEN_SIMPLE:
950 nTemplateDescription = TemplateDescription::FILEOPEN_SIMPLE;
953 case FILESAVE_SIMPLE:
954 nTemplateDescription = TemplateDescription::FILESAVE_SIMPLE;
958 case FILESAVE_AUTOEXTENSION_PASSWORD:
959 nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD;
965 case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS:
966 nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS;
973 xFactory->createInstance(
"com.sun.star.document.FilterFactory" ),
981 case FILESAVE_AUTOEXTENSION_SELECTION:
982 nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_SELECTION;
989 xFactory->createInstance(
"com.sun.star.document.FilterFactory" ),
994 case FILESAVE_AUTOEXTENSION_TEMPLATE:
995 nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE;
1000 case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
1001 nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE;
1005 case FILEOPEN_LINK_PREVIEW_IMAGE_ANCHOR:
1006 nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_ANCHOR;
1011 nTemplateDescription = TemplateDescription::FILEOPEN_PLAY;
1014 case FILEOPEN_LINK_PLAY:
1015 nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PLAY;
1018 case FILEOPEN_READONLY_VERSION:
1019 nTemplateDescription = TemplateDescription::FILEOPEN_READONLY_VERSION;
1023 case FILEOPEN_LINK_PREVIEW:
1024 nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW;
1028 case FILESAVE_AUTOEXTENSION:
1029 nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION;
1034 case FILEOPEN_PREVIEW:
1035 nTemplateDescription = TemplateDescription::FILEOPEN_PREVIEW;
1040 SAL_WARN(
"sfx.dialog",
"FileDialogHelper::ctor with unknown type" );
1052 Sequence < Any > aInitArguments(!xWindow.is() ? 3 : 4);
1053 auto pInitArguments = aInitArguments.getArray();
1062 pInitArguments[0] <<= nTemplateDescription;
1064 pInitArguments[1] <<= xWindow;
1068 pInitArguments[0] <<= NamedValue(
1069 "TemplateDescription",
1070 Any( nTemplateDescription )
1073 pInitArguments[1] <<= NamedValue(
1078 pInitArguments[2] <<= NamedValue(
1085 pInitArguments[3] <<= NamedValue(
"ParentWindow",
Any(xWindow));
1090 xInit->initialize( aInitArguments );
1094 OSL_FAIL(
"FileDialogHelper_Impl::FileDialogHelper_Impl: could not initialize the picker!" );
1101 mxFileDlg->setMultiSelectionMode(
true );
1113 css::uno::Reference < XFilePickerControlAccess > xCtrlAccess(
mxFileDlg, UNO_QUERY_THROW );
1114 xCtrlAccess->enableControl( ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR,
true );
1140 uno::Reference < XFilePickerControlAccess > xExtDlg(
mxFileDlg, UNO_QUERY );
1145 xExtDlg->setLabel( CommonFilePickerElementIds::PUSHBUTTON_OK,
1146 SfxResId( STR_SFX_EXPLORERFILE_BUTTONINSERT ) );
1148 catch(
const IllegalArgumentException& ){}
1153 mxFileDlg->addFilePickerListener(
this );
1156css::uno::Reference<css::ui::dialogs::XFolderPicker2>
createFolderPicker(
const css::uno::Reference<css::uno::XComponentContext>& rContext,
weld::Window* pPreferredParent)
1158 auto xRet = css::ui::dialogs::FolderPicker::create(rContext);
1164 uno::Reference< XInitialization > xInit(xRet, UNO_QUERY);
1167 Sequence<Any> aInitArguments{
Any(sal_Int32(0)),
Any(pPreferredParent->
GetXWindow()) };
1171 xInit->initialize(aInitArguments);
1175 OSL_FAIL(
"createFolderPicker: could not initialize the picker!" );
1197 ::comphelper::disposeComponent(
mxFileDlg );
1202 DBG_ASSERT( _pControlId && _pHelpId,
"FileDialogHelper_Impl::setControlHelpIds: invalid array pointers!" );
1203 if ( !_pControlId || !_pHelpId )
1211 uno::Reference< XFilePickerControlAccess > xControlAccess(
mxFileDlg, UNO_QUERY );
1212 if ( xControlAccess.is() )
1214 while ( *_pControlId )
1216 DBG_ASSERT(
INetURLObject( OStringToOUString( *_pHelpId, RTL_TEXTENCODING_UTF8 ) ).GetProtocol() == INetProtocol::NotValid,
"Wrong HelpId!" );
1217 OUString
sId = sHelpIdPrefix +
1218 OUString( *_pHelpId, strlen( *_pHelpId ), RTL_TEXTENCODING_UTF8 );
1219 xControlAccess->setValue( *_pControlId, ControlActions::SET_HELP_URL,
Any(
sId ) );
1221 ++_pControlId; ++_pHelpId;
1227 TOOLS_WARN_EXCEPTION(
"sfx.dialog",
"FileDialogHelper_Impl::setControlHelpIds: caught an exception while setting the help ids!" );
1233 mnPostUserEventId =
nullptr;
1234 enablePasswordBox(
true );
1235 updateFilterOptionsBox( );
1236 updateSelectionBox( );
1247#if !(defined(MACOSX) && defined(MACOSX)) && !defined(_WIN32)
1265 if ( ExecutableDialogResults::CANCEL != _nResult )
1284 bool bAutoExtChecked =
false;
1286 uno::Reference < XFilePickerControlAccess > xControlAccess(
mxFileDlg, UNO_QUERY );
1287 if ( xControlAccess.is()
1288 && ( xControlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0 )
1293 if ( bAutoExtChecked )
1303 OSL_FAIL(
"FileDialogHelper_Impl::implInitializeFileName: could not ask for the auto-extension current-value!" );
1311 sal_Int16 nRet = ExecutableDialogResults::CANCEL;
1350 uno::Reference< XAsynchronousExecutableDialog > xAsyncDlg(
mxFileDlg, UNO_QUERY );
1351 if ( xAsyncDlg.is() )
1352 xAsyncDlg->startExecuteModal(
this );
1365 uno::Reference< XFilePicker3 > xPickNew(xPicker, UNO_QUERY);
1368 Sequence< OUString > lFiles = xPickNew->getSelectedFiles();
1375 uno::Reference< XFilePicker3 > xPickOld(xPicker, UNO_QUERY_THROW);
1376 Sequence< OUString > lFiles = xPickOld->getFiles();
1377 ::sal_Int32 nFiles = lFiles.getLength();
1380 rpURLList.push_back(lFiles[0]);
1382 else if ( nFiles > 1 )
1387 for (::sal_Int32
i = 1;
i < nFiles;
i++)
1403 std::optional<SfxAllItemSet>& rpSet,
1410 uno::Reference< XFilePickerControlAccess > xCtrlAccess(
mxFileDlg, UNO_QUERY );
1419 const SfxBoolItem* pPassItem = SfxItemSet::GetItem<SfxBoolItem>(&*rpSet, SID_PASSWORDINTERACTION,
false);
1423 const SfxUnoAnyItem* pPassToModifyItem = SfxItemSet::GetItem<SfxUnoAnyItem>(&*rpSet, SID_MODIFYPASSWORDINFO,
false);
1427 const SfxBoolItem* pSelectItem = SfxItemSet::GetItem<SfxBoolItem>(&*rpSet, SID_SELECTION,
false);
1434 rpSet->ClearItem( SID_PASSWORDINTERACTION );
1435 if (rpSet->HasItem( SID_PASSWORD ))
1439 rpSet->ClearItem( SID_PASSWORD );
1440 rpSet->ClearItem( SID_ENCRYPTIONDATA );
1442 rpSet->ClearItem( SID_RECOMMENDREADONLY );
1443 rpSet->ClearItem( SID_MODIFYPASSWORDINFO );
1465 rpSet->ClearItem( SID_SELECTION );
1471 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0 );
1472 bool bSelection =
false;
1473 if ( aValue >>= bSelection )
1474 rpSet->Put(
SfxBoolItem( SID_SELECTION, bSelection ) );
1476 catch(
const IllegalArgumentException& )
1478 TOOLS_WARN_EXCEPTION(
"sfx.dialog",
"FileDialogHelper_Impl::execute: caught an IllegalArgumentException!" );
1485 rpSet->Put(
SfxBoolItem( SID_DOC_READONLY,
true ) );
1488 if ( ( FILEOPEN_READONLY_VERSION ==
m_nDialogType ) && xCtrlAccess.is() )
1492 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_READONLY, 0 );
1497 catch(
const IllegalArgumentException& )
1499 TOOLS_WARN_EXCEPTION(
"sfx.dialog",
"FileDialogHelper_Impl::execute: caught an IllegalArgumentException!" );
1507 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
1508 ControlActions::GET_SELECTED_ITEM_INDEX );
1514 catch(
const IllegalArgumentException& ){}
1524 if ( rpURLList.empty() )
1532 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0 );
1533 bool bPassWord =
false;
1534 if ( ( aValue >>= bPassWord ) && bPassWord )
1537 OUString aDocName(rpURLList[0]);
1543 catch(
const IllegalArgumentException& ){}
1550 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_GPGENCRYPTION, 0 );
1552 if ( ( aValue >>= bGpg ) && bGpg )
1554 uno::Sequence< beans::NamedValue > aEncryptionData;
1563 catch(
const IllegalArgumentException& )
1566 VclMessageType::Warning, VclButtonsType::Ok,
1567 SfxResId(RID_SVXSTR_GPG_ENCRYPT_FAILURE)));
1572 if ( aEncryptionData.hasElements() )
1576 catch(
const IllegalArgumentException& ){}
1595 if ( ExecutableDialogResults::CANCEL == nRet )
1608 aPath =
mxFileDlg->getDisplayDirectory();
1610 if ( aPath.isEmpty() )
1620 if( aFilter.isEmpty() )
1630 if ( _rFilter.isEmpty() )
1635 std::shared_ptr<const SfxFilter> pFilter =
1637 _rFilter = pFilter ? pFilter->GetFilterName() : OUString();
1664 osl::FileBase::RC e = osl::FileBase::getSystemPathFromFileURL(
1666 if (e != osl::FileBase::E_None) {
1669 "getSystemPathFromFileURL("
1675 if (!sysPathU.convertToString(
1676 &sysPathC, osl_getThreadTextEncoding(),
1677 (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
1678 | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
1682 "convertToString(" << sysPathU <<
") failed for encoding "
1683 << +osl_getThreadTextEncoding());
1686 struct stat aFileStat;
1687 if (stat(sysPathC.getStr(), &aFileStat) == -1) {
1688 SAL_WARN(
"sfx.dialog",
"stat(" << sysPathC <<
") failed with errno " << errno);
1691 if ((aFileStat.st_mode & (S_IRWXO | S_IRWXG | S_IRWXU)) == S_IRUSR) {
1702 if ( _rPath.isEmpty() )
1714 catch(
const IllegalArgumentException& )
1731 catch(
const IllegalArgumentException& )
1740 DBG_ASSERT( rFilter.indexOf(
':') == -1,
"Old filter name used!");
1758 catch(
const IllegalArgumentException& ){}
1782 if ( rFactory.isEmpty() )
1794 uno::Reference< XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
1795 uno::Reference< XContainerQuery > xFilterCont(
1796 xSMGR->createInstance(
"com.sun.star.document.FilterFactory"),
1798 if ( ! xFilterCont.is() )
1806 "getSortedFilterList()"
1810 OUString::number(
static_cast<sal_Int32
>(
m_nMustFlags)) +
1812 OUString::number(
static_cast<sal_Int32
>(
m_nDontFlags));
1814 uno::Reference< XEnumeration > xResult;
1817 xResult = xFilterCont->createSubSetEnumerationByQuery(sQuery);
1819 catch(
const uno::Exception& )
1821 SAL_WARN(
"sfx.dialog",
"Could not get filters from the configuration!" );
1827 OUString sFirstFilter;
1841 const OUString& rExtension )
1848 mxFileDlg->appendFilter( rFilterName, rExtension );
1853 catch(
const IllegalArgumentException& )
1855 SAL_WARN(
"sfx.dialog",
"Could not append Filter" << rFilterName );
1869 OUString aExtensions;
1877 if ( sWildcard.isEmpty() )
1879 if ( aExtensions.indexOf( sWildcard ) == -1 )
1881 if ( !aExtensions.isEmpty() )
1883 aExtensions += sWildcard;
1889 if ( aExtensions.getLength() > 240 )
1899 OUString aAllFilterName =
SfxResId(STR_SFX_IMPORT_ALL_IMAGES);
1901 mxFileDlg->appendFilter( aAllFilterName, aExtensions );
1906 OUString aAllFilesName =
SfxResId( STR_SFX_FILTERNAME_ALL );
1914 catch(
const IllegalArgumentException& )
1916 SAL_WARN(
"sfx.dialog",
"Could not append Filter" );
1928 if ( sWildcard.isEmpty() )
1930 if ( aExt.indexOf( sWildcard ) == -1 )
1932 if ( !aExt.isEmpty() )
1942 catch(
const IllegalArgumentException& )
1944 SAL_WARN(
"sfx.dialog",
"Could not append Filter" );
1955 sal_Int32 nLen = rOrigStr.getLength();
1957 sal_Int32 nFirstChar = 0;
1958 sal_Int32
i = nFirstChar;
1965 if ( *pStr == cTok )
1983 rOrigStr = rOrigStr.replaceAt( nFirstChar,
i-nFirstChar, rStr );
1988void SaveLastDirectory(OUString
const& sContext, OUString
const& sDirectory)
1990 if (sContext.isEmpty())
1993 std::shared_ptr<comphelper::ConfigurationChanges> batch(
1995 Reference<container::XNameContainer>
set(
1996 officecfg::Office::Common::Misc::FilePickerLastDirectory::get(batch));
2002 v =
set->getByName(sContext);
2005 catch (container::NoSuchElementException&)
2011 Reference<XPropertySet> el(
v.get<Reference<XPropertySet>>(), UNO_SET_THROW);
2012 el->setPropertyValue(
"LastPath",
Any(sDirectory));
2016 Reference<XPropertySet> el(
2017 (Reference<lang::XSingleServiceFactory>(set, UNO_QUERY_THROW)->
createInstance()),
2019 el->setPropertyValue(
"LastPath",
Any(sDirectory));
2021 set->insertByName(sContext, v2);
2029 uno::Reference < XFilePickerControlAccess > xDlg(
mxFileDlg, UNO_QUERY );
2041 aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0 );
2042 bool bValue =
false;
2045 SetToken( aUserData, 1,
' ', OUString::number(
static_cast<sal_Int32
>(bValue) ) );
2054 SetToken( aUserData, 3,
' ', aFilter );
2058 catch(
const IllegalArgumentException& ){}
2062 bool bWriteConfig =
false;
2070 if ( aUserItem >>= aTemp )
2078 aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0 );
2079 bool bAutoExt =
true;
2080 aValue >>= bAutoExt;
2081 SetToken( aUserData, 0,
' ', OUString::number(
static_cast<sal_Int32
>(bAutoExt) ) );
2082 bWriteConfig =
true;
2084 catch(
const IllegalArgumentException& ){}
2092 SetToken( aUserData, 1,
' ', aPath );
2093 bWriteConfig =
true;
2101 aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0 );
2102 bool bSelection =
true;
2103 aValue >>= bSelection;
2106 SetToken( aUserData, 2,
' ', OUString::number(
static_cast<sal_Int32
>(bSelection) ) );
2107 bWriteConfig =
true;
2109 catch(
const IllegalArgumentException& ){}
2129 const sal_Int32 _nFallbackToken)
2136 Reference<XNameAccess>
set(officecfg::Office::Common::Misc::FilePickerLastDirectory::get());
2140 v =
set->getByName(sContext);
2141 Reference<XPropertySet> el(
v.get<Reference<XPropertySet>>(), UNO_SET_THROW);
2142 sPath = el->getPropertyValue(
"LastPath").get<OUString>();
2144 catch (NoSuchElementException&)
2154 if ( sPath.isEmpty() )
2158 bool bValid =
false;
2159 if ( !sPath.isEmpty() )
2161 OUString sPathCheck( sPath );
2162 if ( sPathCheck[ sPathCheck.getLength() - 1 ] !=
'/' )
2181 uno::Reference < XFilePickerControlAccess > xDlg(
mxFileDlg, UNO_QUERY );
2196 if ( aUserItem >>= aTemp )
2200 if ( !aUserData.isEmpty() )
2207 xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aValue );
2211 aValue <<= bShowPreview;
2212 xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, aValue );
2219 OUString aFilter = aUserData.getToken( 3,
' ' );
2227 catch(
const IllegalArgumentException& ){}
2242 if ( aUserItem >>= aTemp )
2246 if ( aUserData.isEmpty() )
2255 aValue <<= static_cast<bool>(nFlag);
2258 xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue );
2260 catch(
const IllegalArgumentException& ){}
2266 aValue <<= static_cast<bool>(nFlag);
2269 xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0, aValue );
2271 catch(
const IllegalArgumentException& ){}
2288 catch(
const IllegalArgumentException& )
2298 mxFileDlg->setDisplayDirectory( aWorkFolder );
2302 TOOLS_WARN_EXCEPTION(
"sfx.dialog",
"FileDialogHelper_Impl::setDefaultValues: caught an exception while setting the display directory!" );
2313 const OUString& rFilterWithExtension )
2315 maFilters.emplace_back( rFilter, rFilterWithExtension );
2324 if (
filter.Second == rFilterWithExtension)
2338 if (
filter.First == rFilter )
2359 sal_Int16 nDialogType,
2361 const OUString& rFact,
2375 sal_Int16 nDialogType,
2377 const OUString& rFact,
2381 const OUString& rStandardDir,
2382 const css::uno::Sequence< OUString >& rDenyList,
2385 mpImpl( new
FileDialogHelper_Impl( this, nDialogType, nFlags, nDialog, pPreferredParent, rStandardDir, rDenyList ) )
2399 sal_Int16 nDialogType,
2401 const OUString& aFilterUIName,
2402 std::u16string_view aExtName,
2403 const OUString& rStandardDir,
2404 const css::uno::Sequence< OUString >& rDenyList,
2411 if ( aExtName.find(
'*' ) != 0 )
2413 if ( !aExtName.empty() && aExtName.find(
'.' ) != 0 )
2438 mpImpl->setControlHelpIds( _pControlId, _pHelpId );
2443 mpImpl->SetContext( _eNewContext );
2452 return "AcceleratorConfig";
2454 return "AutoRedact";
2456 return "BaseDataSource";
2458 return "BaseSaveAs";
2460 return "BasicExportDialog";
2462 return "BasicExportPackage";
2464 return "BasicExportSource";
2466 return "BasicImportDialog";
2468 return "BasicImportSource";
2470 return "BasicInsertLib";
2472 return "BulletsAddImage";
2474 return "CalcDataProvider";
2476 return "CalcDataStream";
2478 return "CalcExport";
2480 return "CalcSaveAs";
2482 return "CalcXMLSource";
2484 return "ExportImage";
2486 return "ExtensionManager";
2488 return "FormsAddInstance";
2490 return "FormsInsertImage";
2492 return "LinkClientOLE";
2494 return "LinkClientFile";
2496 return "DrawImpressInsertFile";
2498 return "DrawImpressOpenSound";
2500 return "DrawExport";
2502 return "DrawSaveAs";
2504 return "IconImport";
2506 return "ImpressClickAction";
2508 return "ImpressExport";
2510 return "ImpressPhotoDialog";
2512 return "ImpressSaveAs";
2518 return "InsertImage";
2522 return "InsertMedia";
2524 return "JavaClassPath";
2526 return "ReportInsertImage";
2528 return "ScreenshotAnnotation";
2530 return "SignatureLine";
2532 return "TemplateImport";
2534 return "WriterCreateAddressList";
2536 return "WriterExport";
2538 return "WriterImportAutotext";
2540 return "WriterInsertHyperlink";
2542 return "WriterInsertImage";
2544 return "WriterInsertScript";
2546 return "WriterLoadTemplate";
2548 return "WriterMailMerge";
2550 return "WriterMailMergeSaveAs";
2552 return "WriterNewHTMLGlobalDoc";
2554 return "WriterRegisterDataSource";
2556 return "WriterSaveAs";
2558 return "WriterSaveHTML";
2560 return "XMLFilterSettings";
2569 m_nError = mpImpl->execute();
2570 m_aDialogClosedLink.Call(
this );
2575 std::optional<SfxAllItemSet>& rpSet,
2577 const OUString& rDirPath )
2580 return mpImpl->execute( rpURLList, rpSet, rFilter );
2586 return mpImpl->execute();
2593 std::vector<OUString> rURLList;
2594 nRet =
mpImpl->execute(rURLList, rpSet, rFilter);
2602 if (!
mpImpl->isAsyncFilePicker())
2605 mpImpl->implStartExecute();
2619 mpImpl->getRealFilter( sFilter );
2625 if (
mpImpl->mxFileDlg.is() )
2626 mpImpl->mxFileDlg->setTitle( rNewTitle );
2633 if ( !
mpImpl->mlLastURLs.empty())
2634 return mpImpl->mlLastURLs[0];
2636 if (
mpImpl->mxFileDlg.is() )
2638 Sequence < OUString > aPathSeq =
mpImpl->mxFileDlg->getFiles();
2640 if ( aPathSeq.getLength() == 1 )
2642 aPath = aPathSeq[0];
2651 if ( !
mpImpl->mlLastURLs.empty())
2654 if (
mpImpl->mxFileDlg.is() )
2655 return mpImpl->mxFileDlg->getFiles();
2658 Sequence < OUString > aEmpty;
2666 uno::Sequence< OUString > aResultSeq;
2667 if (
mpImpl->mxFileDlg.is())
2669 aResultSeq =
mpImpl->mxFileDlg->getSelectedFiles();
2674 uno::Reference< XFilePicker > xPickOld(
mpImpl->mxFileDlg, UNO_QUERY_THROW);
2675 Sequence< OUString > lFiles = xPickOld->getFiles();
2676 ::sal_Int32 nFiles = lFiles.getLength();
2679 aResultSeq = Sequence< OUString >( nFiles-1 );
2680 auto pResultSeq = aResultSeq.getArray();
2685 for (::sal_Int32
i = 1;
i < nFiles;
i++)
2696 aResultSeq = lFiles;
2704 return mpImpl->getPath();
2709 return mpImpl->getFilter();
2714 return mpImpl->getGraphic( rGraphic );
2722 rPath, uno::Reference< ucb::XCommandEnvironment > (),
2738 if ( _rPath.isEmpty() )
2752 if ( nIsFolder == 0 ||
2755 mpImpl->setFileName( sFileName );
2756 mpImpl->displayFolder( sPath );
2762 if ( sFolder.isEmpty() )
2765 osl::Security aSecurity;
2766 aSecurity.getHomeDir( sFolder );
2768 mpImpl->displayFolder( sFolder );
2774 mpImpl->displayFolder( _rURL );
2779 mpImpl->setFileName( _rFileName );
2783 const OUString& rExtension )
2785 mpImpl->addFilter( rFilterName, rExtension );
2790 OUString sFilter( rFilter );
2791 if (
mpImpl->isShowFilterExtensionEnabled() )
2792 sFilter =
mpImpl->getFilterWithExtension( rFilter );
2793 mpImpl->setFilter( sFilter );
2798 return mpImpl->mxFileDlg;
2804 mpImpl->handleFileSelectionChanged();
2809 mpImpl->handleDirectoryChanged();
2824 mpImpl->handleDialogSizeChanged();
2834 sal_Int16 nDialogType,
2836 std::vector<OUString>& rpURLList,
2838 std::optional<SfxAllItemSet>& rpSet,
2839 const OUString* pPath,
2841 const OUString& rStandardDir,
2842 const css::uno::Sequence< OUString >& rDenyList )
2845 std::unique_ptr<FileDialogHelper> pDialog;
2850 pDialog.reset(
new FileDialogHelper(nDialogType, nFlags,
SfxResId(STR_SFX_FILTERNAME_PDF),
u"pdf", rStandardDir, rDenyList, pParent));
2852 pDialog.reset(
new FileDialogHelper(nDialogType, nFlags, OUString(), nDialog, SfxFilterFlags::NONE, SfxFilterFlags::NONE, rStandardDir, rDenyList, pParent));
2858 nRet = pDialog->Execute(rpURLList, rpSet, rFilter, aPath);
2859 DBG_ASSERT( rFilter.indexOf(
": ") == -1,
"Old filter name used!");
2866bool IsMSType(
const std::shared_ptr<const SfxFilter>& pCurrentFilter)
2870 return !pCurrentFilter->IsOwnFormat();
2873bool IsOOXML(
const std::shared_ptr<const SfxFilter>& pCurrentFilter)
2876 return IsMSType(pCurrentFilter) && lclSupportsOOXMLEncryption( pCurrentFilter->GetFilterName());
2880 const OUString& rPasswordToOpen, std::u16string_view rPasswordToModify,
2881 bool bAllowPasswordReset)
2883 const bool bMSType =
IsMSType(pCurrentFilter);
2884 const bool bOOXML =
IsOOXML(pCurrentFilter);
2886 if ( rPasswordToOpen.getLength() )
2888 css::uno::Sequence< css::beans::NamedValue > aEncryptionData;
2895 aHashData[ OUString(
"OOXPassword" ) ] <<= rPasswordToOpen;
2896 aHashData[ OUString(
"CryptoType" ) ] <<= OUString(
"Standard" );
2904 if ( aEncryptionKey.hasElements() )
2907 aHashData[ OUString(
"STD97EncryptionKey" ) ] <<= aEncryptionKey;
2908 aHashData[ OUString(
"STD97UniqueID" ) ] <<= aUniqueID;
2925 rPasswordToOpen)))));
2927 else if (bAllowPasswordReset)
2931 if (pSet->
HasItem(SID_ENCRYPTIONDATA))
2932 pSet->
ClearItem(SID_MODIFYPASSWORDINFO);
2933 if (pSet->
HasItem(SID_ENCRYPTIONDATA))
2943 uno::Sequence<beans::PropertyValue> aModifyPasswordInfo
2946 if (aModifyPasswordInfo.hasElements() && pSet)
2955 pCurrentFilter->GetServiceName() ==
"com.sun.star.text.TextDocument");
2963 if ( aModifyPasswordInfo.hasElements() && pSet)
2973 uno::Reference<task::XInteractionHandler2> xInteractionHandler = task::InteractionHandler::createWithParent(::comphelper::getProcessComponentContext(), rParent);
2975 ::comphelper::DocPasswordRequestType::MS :
2980 const bool bMSType =
IsMSType(pCurrentFilter);
2982 uno::Reference< css::task::XInteractionRequest > rRequest( pPasswordRequest );
2985 xInteractionHandler->handle( rRequest );
2986 if (!pPasswordRequest->isPassword() || bMSType)
2990 OString
const utf8Pwd(
OUStringToOString(pPasswordRequest->getPassword(), RTL_TEXTENCODING_UTF8));
2991 OString
const utf8Ptm(
OUStringToOString(pPasswordRequest->getPasswordToModify(), RTL_TEXTENCODING_UTF8));
2992 if (!(52 <= utf8Pwd.getLength() && utf8Pwd.getLength() <= 55
2994 && (52 > utf8Ptm.getLength() || utf8Ptm.getLength() > 55))
2999 VclButtonsType::Ok,
SfxResId(STR_PASSWORD_LEN)));
3000 xBox->set_secondary_text(
SfxResId(STR_PASSWORD_WARNING));
3004 if ( !pPasswordRequest->isPassword() )
3007 const auto result =
SetPassword(pCurrentFilter, pSet, pPasswordRequest->getPassword(), pPasswordRequest->getPasswordToModify());
3017 OUString sRet = rSource.replaceAll(
" ",
"%20" );
3023 OUString sRet = rSource.replaceAll(
"%20",
" " );
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
SfxApplication * SfxGetpApp()
constexpr OUStringLiteral sStandardDir
const sal_uInt16 nVersion
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
bool Convert(BmpConversion eConversion)
const Size & GetSizePixel() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
virtual OUString GetHelpText(const OUString &aHelpURL, const weld::Widget *pWidget)
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
void SetSmartProtocol(INetProtocol eTheSmartScheme)
bool removeExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
bool SetSmartURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool insertName(std::u16string_view rTheName, bool bAppendFinalSlash=false, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
bool setName(std::u16string_view rTheName, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
INetProtocol GetProtocol() const
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
virtual void Start(bool bStartTimer=true) override
SfxFilterMatcher & GetFilterMatcher()
SAL_DLLPRIVATE void SetLastDir_Impl(const OUString &)
SAL_DLLPRIVATE const OUString & GetLastDir_Impl() const
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
std::shared_ptr< const SfxFilter > GetFilter4UIName(std::u16string_view rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
static sal_uInt32 CreatePasswordToModifyHash(std::u16string_view aPasswd, bool bWriter)
const css::uno::Sequence< css::util::RevisionTag > & GetVersionList(bool _bNoReload=false)
static OUString GetServiceNameFromFactory(const OUString &rFact)
SfxItemPool & GetPool() const
Each Subclass of SfxShell must reference a pool.
const css::uno::Any & GetValue() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const OUString & GetWorkPath() const
css::uno::Any GetUserItem(const OUString &sName) const
void SetUserItem(const OUString &sName, const css::uno::Any &aValue)
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
void ClearInvokeHandler()
static std::shared_ptr< ConfigurationChanges > create()
static css::uno::Sequence< sal_Int8 > GenerateRandomByteSequence(sal_Int32 nLength)
static css::uno::Sequence< css::beans::PropertyValue > GenerateNewModifyPasswordInfoOOXML(std::u16string_view aPassword)
static css::uno::Sequence< css::beans::PropertyValue > GenerateNewModifyPasswordInfo(std::u16string_view aPassword)
static css::uno::Sequence< sal_Int8 > GenerateStd97Key(std::u16string_view aPassword, const css::uno::Sequence< sal_Int8 > &aDocId)
static css::uno::Sequence< css::beans::NamedValue > CreateGpgPackageEncryptionData()
static css::uno::Sequence< css::beans::NamedValue > CreatePackageEncryptionData(std::u16string_view aPassword)
static css::uno::Reference< css::embed::XStorage > GetStorageFromURL(const OUString &aURL, sal_Int32 nStorageMode, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
css::uno::Sequence< css::beans::NamedValue > getAsConstNamedValueList() const
virtual void SAL_CALL dialogSizeChanged() override
bool mbSelectionFltrEnabled
void updateExportButton()
virtual void SAL_CALL controlStateChanged(const css::ui::dialogs::FilePickerEvent &aEvent) override
SfxFilterFlags m_nMustFlags
weld::Window * mpFrameWeld
void createMatcher(const OUString &rFactory)
void updatePreviewState(bool _bUpdatePreviewWindow)
css::uno::Reference< css::awt::XWindow > GetFrameInterface()
OUString getFilterWithExtension(std::u16string_view rFilter) const
void displayFolder(const OUString &rPath)
sets the directory which should be browsed
FileDialogHelper::Context meContext
std::unique_ptr< GraphicFilter > mpGraphicFilter
virtual void SAL_CALL directoryChanged(const css::ui::dialogs::FilePickerEvent &aEvent) override
bool isShowFilterExtensionEnabled() const
bool m_bHaveFilterOptions
void handleDialogSizeChanged()
void handleDirectoryChanged()
void addFilterPair(const OUString &rFilter, const OUString &rFilterWithExtension)
ErrCode getGraphic(const OUString &rURL, Graphic &rGraphic) const
void getRealFilter(OUString &_rFilter) const
::std::vector< OUString > mlLastURLs
void setFileName(const OUString &_rFile)
void SetContext(FileDialogHelper::Context _eNewContext)
void implInitializeFileName()
void addFilters(const OUString &rFactory, SfxFilterFlags nMust, SfxFilterFlags nDont)
void addFilter(const OUString &rFilterName, const OUString &rExtension)
OUString getCurrentFilterUIName() const
void setControlHelpIds(const sal_Int16 *_pControlId, const char **_pHelpId)
void updateSelectionBox()
void implGetAndCacheFiles(const css::uno::Reference< XInterface > &xPicker, std::vector< OUString > &rpURLList)
OUString getInitPath(std::u16string_view _rFallback, const sal_Int32 _nFallbackToken)
sal_Int16 implDoExecute()
css::uno::Reference< css::container::XNameAccess > mxFilterCFG
virtual void SAL_CALL dialogClosed(const css::ui::dialogs::DialogClosedEvent &_rEvent) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void LoadLastUsedFilter(const OUString &_rContextIdentifier)
void handleControlStateChanged(const css::ui::dialogs::FilePickerEvent &aEvent)
SfxFilterMatcher * mpMatcher
std::vector< css::beans::StringPair > maFilters
bool updateExtendedControl(sal_Int16 _nExtendedControlId, bool _bEnable)
void handleFileSelectionChanged()
FileDialogHelper_Impl(FileDialogHelper *_pAntiImpl, const sal_Int16 nDialogType, FileDialogFlags nFlags, sal_Int16 nDialog, weld::Window *pFrameWeld, const OUString &sStandardDir=OUString(), const css::uno::Sequence< OUString > &rDenyList=css::uno::Sequence< OUString >())
css::uno::Reference< css::ui::dialogs::XFilePicker3 > mxFileDlg
void postExecute(sal_Int16 _nResult)
OUString getFilter() const
virtual void SAL_CALL fileSelectionChanged(const css::ui::dialogs::FilePickerEvent &aEvent) override
FileDialogHelper * mpAntiImpl
virtual OUString SAL_CALL helpRequested(const css::ui::dialogs::FilePickerEvent &aEvent) override
void SaveLastUsedFilter()
SfxFilterFlags m_nDontFlags
void enablePasswordBox(bool bInit)
void updateFilterOptionsBox()
OUString getFilterName(std::u16string_view rFilterWithExtension) const
ImplSVEvent * mnPostUserEventId
virtual ~FileDialogHelper_Impl() override
bool isInOpenMode() const
std::shared_ptr< const SfxFilter > getCurrentSfxFilter()
bool CheckFilterOptionsCapability(const std::shared_ptr< const SfxFilter > &_pFilter)
static OUString handleHelpRequested(const css::ui::dialogs::FilePickerEvent &aEvent)
void setFilter(const OUString &rFilter)
const short m_nDialogType
void SetControlHelpIds(const sal_Int16 *_pControlId, const char **_pHelpId)
sets help ids for the controls in the dialog
void AddFilter(const OUString &rFilterName, const OUString &rExtension)
@ WriterCreateAddressList
@ WriterRegisterDataSource
void StartExecuteModal(const Link< FileDialogHelper *, void > &rEndDialogHdl)
void SetDisplayDirectory(const OUString &rPath)
sets an initial display directory/file name
sal_Int16 GetDialogType() const
void CreateMatcher(const OUString &rName)
const css::uno::Reference< css::ui::dialogs::XFilePicker3 > & GetFilePicker() const
OUString GetRealFilter() const
void DialogClosed(const css::ui::dialogs::DialogClosedEvent &_rEvent)
static OUString HelpRequested(const css::ui::dialogs::FilePickerEvent &aEvent)
bool IsPasswordEnabled() const
rtl::Reference< FileDialogHelper_Impl > mpImpl
static OUString contextToString(Context context)
void SetDisplayFolder(const OUString &_rURL)
sets a new folder whose content is to be displayed in the file picker
void SetTitle(const OUString &rNewTitle)
css::uno::Sequence< OUString > GetSelectedFiles() const
Provides the selected files with full path information.
OUString GetCurrentFilter() const
css::uno::Sequence< OUString > GetMPath() const
virtual ~FileDialogHelper()
void SetFileName(const OUString &_rFileName)
sets an initial file name to display
virtual void ControlStateChanged(const css::ui::dialogs::FilePickerEvent &aEvent)
void SetCurrentFilter(const OUString &rFilter)
void SetContext(Context _eNewContext)
sets the context of the dialog and trigger necessary actions e.g.
ErrCode GetGraphic(Graphic &rGraphic) const
void FileSelectionChanged()
Link< FileDialogHelper *, void > m_aDialogClosedLink
FileDialogHelper(sal_Int16 nDialogType, FileDialogFlags nFlags, weld::Window *pPreferredParent)
OUString GetDisplayDirectory() const
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SFX_FILTER_NOTINSTALLED
ScXMLEditAttributeMap::Entry const aEntries[]
#define ERRCODE_IO_GENERAL
#define ERRCODE_IO_NOTSUPPORTED
#define ERRCODE_IO_NOTAFILE
Reference< XSingleServiceFactory > xFactory
constexpr OUStringLiteral IMPGRF_CONFIGNAME
constexpr OUStringLiteral USERITEM_NAME
constexpr OUStringLiteral IODLG_CONFIGNAME
#define SFX2_IMPL_DIALOG_CONFIG
constexpr OUStringLiteral FILEDIALOG_FILTER_ALL
#define SFX2_IMPL_DIALOG_SYSTEM
@ InsertMerge
Special insertion ("Compare" caption)
@ SignPDF
Sign existing PDF.
#define SFX2_IMPL_DIALOG_OOO
#define SFX2_IMPL_DIALOG_REMOTE
#define GRFILTER_FORMAT_DONTKNOW
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_FILEDLG_LINK_CB
constexpr OUStringLiteral HID_FILESAVE_CUSTOMIZEFILTER
constexpr OUStringLiteral HID_FILEOPEN_VERSION
constexpr OUStringLiteral HID_FILEOPEN_IMAGE_TEMPLATE
constexpr OUStringLiteral HID_FILESAVE_SAVEWITHPASSWORD
constexpr OUStringLiteral HID_FILESAVE_DOPLAY
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
@ DocWarnRecommendPassword
bool IsOptionSet(EOption eOption)
void set(css::uno::UnoInterfaceReference const &value)
sal_Int32 getTokenCount(std::string_view rIn, char cTok)
COMPHELPER_DLLPUBLIC bool isFileUrl(std::u16string_view url)
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
DstType sequenceToContainer(const css::uno::Sequence< SrcType > &i_Sequence)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Reference< XComponentContext > getProcessComponentContext()
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
IMPL_LINK_NOARG(SvDDELinkEditDialog, EditHdl_Impl, weld::Entry &, void)
OUString addExtension(const OUString &_rDisplayText, const OUString &_rExtension, bool _bForOpen, FileDialogHelper_Impl &_rFileDlgImpl)
adds the given extension to the display text.
static open_or_save_t lcl_OpenOrSave(sal_Int16 const nDialogType)
bool IsMSType(const std::shared_ptr< const SfxFilter > &pCurrentFilter)
static bool lcl_isSystemFilePicker(const uno::Reference< XExecutableDialog > &_rxFP)
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Window *pPreferredParent)
void appendFiltersForOpen(TSortedFilterList &_rFilterMatcher, const Reference< XFilterManager > &_rxFilterManager, OUString &_rFirstNonEmpty, FileDialogHelper_Impl &_rFileDlgImpl)
static std::optional< OUString > GetLastFilterConfigId(FileDialogHelper::Context _eContext)
static OUString EncodeSpaces_Impl(const OUString &rSource)
static void SetToken(OUString &rOrigStr, sal_Int32 nToken, sal_Unicode cTok, std::u16string_view rStr)
static int impl_isFolder(const OUString &rPath)
constexpr OUStringLiteral GRF_CONFIG_STR
bool IsOOXML(const std::shared_ptr< const SfxFilter > &pCurrentFilter)
void appendExportFilters(TSortedFilterList &_rFilterMatcher, const Reference< XFilterManager > &_rxFilterManager, OUString &_rFirstNonEmpty, FileDialogHelper_Impl &_rFileDlgImpl)
ErrCode SetPassword(const std::shared_ptr< const SfxFilter > &pCurrentFilter, SfxItemSet *pSet, const OUString &rPasswordToOpen, std::u16string_view rPasswordToModify, bool bAllowPasswordReset)
ErrCode RequestPassword(const std::shared_ptr< const SfxFilter > &pCurrentFilter, OUString const &aURL, SfxItemSet *pSet, const css::uno::Reference< css::awt::XWindow > &rParent)
constexpr OUStringLiteral STD_CONFIG_STR
static OUString DecodeSpaces_Impl(const OUString &rSource)
ErrCode FileOpenDialog_Impl(weld::Window *pParent, sal_Int16 nDialogType, FileDialogFlags nFlags, std::vector< OUString > &rpURLList, OUString &rFilter, std::optional< SfxAllItemSet > &rpSet, const OUString *pPath, sal_Int16 nDialog, const OUString &rStandardDir, const css::uno::Sequence< OUString > &rDenyList)
void appendFiltersForSave(TSortedFilterList &_rFilterMatcher, const Reference< XFilterManager > &_rxFilterManager, OUString &_rFirstNonEmpty, FileDialogHelper_Impl &_rFileDlgImpl, std::u16string_view _rFactory)
UNOTOOLS_DLLPUBLIC bool IsDocument(OUString const &url)
UNOTOOLS_DLLPUBLIC css::uno::Reference< css::ucb::XCommandEnvironment > getDefaultCommandEnvironment()
UNOTOOLS_DLLPUBLIC bool IsFolder(OUString const &url)
UNOTOOLS_DLLPUBLIC SvtSaveOptions::ODFSaneDefaultVersion GetODFSaneDefaultVersion()
OUString SfxResId(TranslateId aId)
constexpr OUStringLiteral INET_HID_SCHEME
std::unique_ptr< char[]> aBuffer