Skip to content

Commit

Permalink
#i96720# FilePicker: setDefaultName, setDefaultDirectory "broken"
Browse files Browse the repository at this point in the history
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

git-svn-id: https://svn.apache.org/repos/asf/openoffice/trunk@1716508 13f79535-47bb-0310-9956-ffa450edef68
(cherry picked from commit 1aa1f6e)
  • Loading branch information
Damjan Jovanovic authored and Pilot-Pirx committed Oct 14, 2023
1 parent ac8bb0a commit de4f303
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions main/fpicker/source/office/OfficeFilePicker.cxx
Expand Up @@ -171,19 +171,29 @@ void SvtFilePicker::prepareExecute()
// --**-- doesn't match the spec yet
if ( m_aDisplayDirectory.getLength() > 0 || m_aDefaultName.getLength() > 0 )
{
sal_Bool isFileSet = sal_False;
if ( m_aDisplayDirectory.getLength() > 0 )
{

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.getLength() > 0 )
{
aPath.insertName( m_aDefaultName );
getDialog()->SetHasFilename( true );
}
String sPath = aPath.GetMainURL( INetURLObject::NO_DECODE );
getDialog()->SetPath( aPath.GetMainURL( INetURLObject::NO_DECODE ) );
getDialog()->SetPath( sPath );
isFileSet = sal_True;
}
else if ( m_aDefaultName.getLength() > 0 )
if ( !isFileSet && m_aDefaultName.getLength() > 0 )
{
getDialog()->SetPath( m_aDefaultName );
getDialog()->SetHasFilename( true );
Expand Down

0 comments on commit de4f303

Please sign in to comment.