Kaydet (Commit) 485fcd4f authored tarafından Tamas Bunth's avatar Tamas Bunth Kaydeden (comit) Tamás Bunth

oovbaapi: Use default path for FileDialog

Change-Id: If7af0fc52b8684cca77fd3e85e15ef429801d6dd
Reviewed-on: https://gerrit.libreoffice.org/41542Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTamás Bunth <btomi96@gmail.com>
üst 51e610e5
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment