23#include <osl/file.hxx>
25#include <ooo/vba/office/MsoFileDialogType.hpp>
27#include <com/sun/star/ui/dialogs/FilePicker.hpp>
28#include <com/sun/star/ui/dialogs/FolderPicker.hpp>
29#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
30#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
39 , m_bMultiSelectMode(false)
47 OUString sDefaultPath;
49 if( rName >>= sDefaultPath )
52 sal_Int32
eSuccess = osl::FileBase::getFileURLFromSystemPath(
53 sDefaultPath, sDefaultURL ) ;
54 if(
eSuccess == osl::FileBase::RC::E_INVAL )
86 std::vector<OUString> sSelectedPaths;
91 case office::MsoFileDialogType::msoFileDialogOpen:
94 case office::MsoFileDialogType::msoFileDialogSaveAs:
97 case office::MsoFileDialogType::msoFileDialogFilePicker:
99 uno::Reference<ui::dialogs::XFilePicker3> xFilePicker =
100 ui::dialogs::FilePicker::createWithMode(
101 mxContext, ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE );
106 if( xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK )
112 const uno::Sequence<OUString> aSelectedFiles = xFilePicker->getSelectedFiles();
113 for(
const auto& sURL : aSelectedFiles )
116 osl::FileBase::getSystemPathFromFileURL(sURL, sPath);
118 sSelectedPaths.push_back(sPath);
122 case office::MsoFileDialogType::msoFileDialogFolderPicker:
124 uno::Reference< ui::dialogs::XFolderPicker2 > xFolderPicker =
125 ui::dialogs::FolderPicker::create(
mxContext);
130 if( xFolderPicker->execute() != ui::dialogs::ExecutableDialogResults::OK )
136 OUString sURL = xFolderPicker->getDirectory();
141 osl::FileBase::getSystemPathFromFileURL(sURL, sPath);
143 sSelectedPaths.push_back(sPath);
149 throw uno::RuntimeException();
152 m_xItems = css::uno::Reference< ov::excel::XFileDialogSelectedItems >(
161 return "ScVbaFileDialog";
164uno::Sequence<OUString>
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual void SAL_CALL setInitialFileName(const css::uno::Any &rName) override
OUString m_sInitialFileName
virtual css::uno::Any SAL_CALL getInitialFileName() override
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual void SAL_CALL setAllowMultiSelect(const css::uno::Any &rAllowMultiSelect) override
virtual css::uno::Any SAL_CALL getTitle() override
css::uno::Reference< ov::excel::XFileDialogSelectedItems > m_xItems
virtual sal_Int32 SAL_CALL Show() override
ScVbaFileDialog(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const sal_Int32 nType)
virtual css::uno::Any SAL_CALL getAllowMultiSelect() override
virtual css::uno::Reference< ov::excel::XFileDialogSelectedItems > SAL_CALL getSelectedItems() override
virtual void SAL_CALL setTitle(const css::uno::Any &rTitle) override
virtual OUString getServiceImplName() override
Sequence< OUString > aServiceNames