diff options
author | Tamas Bunth <tamas.bunth@collabora.co.uk> | 2017-08-24 23:24:11 +0200 |
---|---|---|
committer | Tamás Bunth <btomi96@gmail.com> | 2017-08-25 10:36:28 +0200 |
commit | 485fcd4f367ebdf5a7494976424e64c7c68ff450 (patch) | |
tree | 764302209b944a03228169f4206917508958e516 /sc | |
parent | 51e610e584e09ecdec4cbc5c7c550bc806d7ee1c (diff) |
oovbaapi: Use default path for FileDialog
Change-Id: If7af0fc52b8684cca77fd3e85e15ef429801d6dd
Reviewed-on: https://gerrit.libreoffice.org/41542
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Bunth <btomi96@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/vba/vbafiledialog.cxx | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/sc/source/ui/vba/vbafiledialog.cxx b/sc/source/ui/vba/vbafiledialog.cxx index f9a95cebdb87..0a3a7d33cfa9 100644 --- a/sc/source/ui/vba/vbafiledialog.cxx +++ b/sc/source/ui/vba/vbafiledialog.cxx @@ -43,7 +43,18 @@ ScVbaFileDialog::getInitialFileName() { return uno::makeAny( m_sInitialFileName void ScVbaFileDialog::setInitialFileName( const css::uno::Any& rName ) { - rName >>= m_sInitialFileName; + OUString sDefaultPath; + OUString sDefaultURL; + + if( rName >>= sDefaultPath ) + { + sal_Int32 eSuccess = osl::FileBase::getFileURLFromSystemPath( + sDefaultPath, sDefaultURL ) ; + if( eSuccess == osl::FileBase::RC::E_INVAL ) + m_sInitialFileName = sDefaultPath; // the user may gave it in URL form + else + m_sInitialFileName = sDefaultURL; + } } css::uno::Any ScVbaFileDialog::getTitle() { return uno::makeAny( m_sTitle ); } @@ -78,9 +89,10 @@ sal_Int32 ScVbaFileDialog::Show() ui::dialogs::FilePicker::createWithMode( mxContext, ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE ); - // TODO set initial directory + if( !m_sInitialFileName.isEmpty() ) + xFilePicker->setDisplayDirectory( m_sInitialFileName ); - if( xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK) + if( xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK ) { nRet = 0; // cancel pressed break; @@ -100,9 +112,10 @@ sal_Int32 ScVbaFileDialog::Show() uno::Reference< ui::dialogs::XFolderPicker2 > xFolderPicker = ui::dialogs::FolderPicker::create(mxContext); - // TODO set initial directory + if( !m_sInitialFileName.isEmpty() ) + xFolderPicker->setDisplayDirectory( m_sInitialFileName ); - if( xFolderPicker->execute() != ui::dialogs::ExecutableDialogResults::OK) + if( xFolderPicker->execute() != ui::dialogs::ExecutableDialogResults::OK ) { nRet = 0; // cancel pressed break; |