From 25aa9f30489801b2ed51395d7dad20ec0a2b0473 Mon Sep 17 00:00:00 2001 From: Damjan Jovanovic Date: Wed, 25 Nov 2015 18:49:36 +0000 Subject: Resolves: #i96720# FilePicker: setDefaultName... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setDefaultDirectory "broken" Display the proposed filename even when the URL specified for the file picker directory is invalid. As the Win32 file picker sadly allows both paths and URLs for directories, users try paths on other more restrictive platforms, and since the file picker there shows neither the directory nor the file, they wrongly conclude both are broken. Patch by: me (cherry picked from commit 42d181e761c9903bfe5dd71334cadacebd1d0dc8) Change-Id: I3f99937b667d7fe5198f6445ccd4d0e22d48c7c7 Reviewed-on: https://gerrit.libreoffice.org/28426 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- fpicker/source/office/OfficeFilePicker.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'fpicker') diff --git a/fpicker/source/office/OfficeFilePicker.cxx b/fpicker/source/office/OfficeFilePicker.cxx index cdf83c2cdc1a..269e666453b1 100644 --- a/fpicker/source/office/OfficeFilePicker.cxx +++ b/fpicker/source/office/OfficeFilePicker.cxx @@ -140,18 +140,28 @@ void SvtFilePicker::prepareExecute() // --**-- doesn't match the spec yet if ( !m_aDisplayDirectory.isEmpty() || !m_aDefaultName.isEmpty() ) { + bool isFileSet = false; if ( !m_aDisplayDirectory.isEmpty() ) { - INetURLObject aPath( m_aDisplayDirectory ); + INetURLObject aPath; + INetURLObject givenPath( m_aDisplayDirectory ); + if (!givenPath.HasError()) + aPath = givenPath; + else + { + INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() ); + aPath = aStdDirObj; + } if ( !m_aDefaultName.isEmpty() ) { aPath.insertName( m_aDefaultName ); getDialog()->SetHasFilename( true ); } getDialog()->SetPath( aPath.GetMainURL( INetURLObject::NO_DECODE ) ); + isFileSet = true; } - else if ( !m_aDefaultName.isEmpty() ) + if ( !isFileSet && !m_aDefaultName.isEmpty() ) { getDialog()->SetPath( m_aDefaultName ); getDialog()->SetHasFilename( true ); -- cgit