Issue 79211

Summary: FilePicker doesn't show name if no other file of same type exists on the location
Product: General Reporter: cno
Component: uiAssignee: AOO issues mailing list <issues>
Status: CONFIRMED --- QA Contact:
Severity: Trivial    
Priority: P3 CC: issues, mark.nienberg
Version: OOo 2.2.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---

Description cno 2007-07-04 13:54:41 UTC
FilePicker doesn't show name if no other file of same type exists on the start

It's already a long time that my attention is cathed by the fact that
File|Export as PDF doesn't show a default name, if it is the first export to a
certain folder.

Now I've experienced the same in basic code.
Little code below.
sFileName  isn't displayed, if there is an folder where for the first time a
document of that type is saved.

Since I guess those two are related, I set the component to framework, not API.
Pls correct if I'm wrong.

' = = = code to reproduce bug
Sub Main
' For testing:
' choose sPath so that no other file of .odt exists in folder

	Dim sName$, sPath$
	sName = ""
	sPath = ""
	PickMyFileName (sName , sPath )
End Sub

Function PickMyFileName (sDocPath$, sFileName$) as String
	Dim oFilePickerDlg
	Dim sFilePickerArgs
	Dim sFilesPicked () as String

	oFilePickerDlg = createUnoService( "" )
	sFilePickerArgs =
Array( )
	With oFilePickerDlg
		.Initialize ( sFilePickerArgs() )
		If Len(sDocPath) > 0 Then .SetDisplayDirectory (ConvertToURL(sDocPath))
		If Len(sFileName) > 0 Then .SetDefaultName (sFileName)
		.AppendFilter( "All files (*.*)", "*.*" )
		.AppendFilter( "OpenDocument Text (.odt)", "*.odt" )
		.SetCurrentFilter( "OpenDocument Text (.odt)" )
0, true)   
0, false)
	End With
   If oFilePickerDlg.execute() > 0 Then
      sFilesPicked() = oFilePickerDlg.getFiles()
      PickMyFileName= sFilesPicked(0)
   End If
End Function
Comment 1 thorsten.martens 2007-07-05 08:03:52 UTC
TM->JSK: please have a look, thanks
Comment 2 cno 2007-07-23 15:04:04 UTC
Thanks to help from Fernand:
When using the OOo-dialogs (Tools|Options|General) the problem doesn't exist.
Nor with PDF's nor with other files.
Comment 3 cno 2007-12-03 19:54:07 UTC
Pls mind: the arguments in calling PickMyFileName (sName , sPath ) have to be
the other way round. (This in the Sub Main of the code to reproduce the bug.)

Now the good news: the magical OOo-code has been repaired.
In 2.3.1RC1, I can't reproduce.
I first noticed when exporting a first PDF to a directory.

Anyone an idea which cws?

-> set to fixed
Comment 4 joerg.skottke 2008-05-30 11:41:25 UTC
setting closed
Comment 5 cno 2008-05-30 16:57:00 UTC
Hi jsk,
Sorry I have to reopen.
Does not work OK in 3.0 Beta.
Maybe it was ok in 2.3.1 because of the work on file extensions in the save
dialog, that has been reverted in the mean time??
Comment 6 joerg.skottke 2008-06-17 13:39:13 UTC
Ok, might still be a problem but the deadline has slipped now for 3.0 i'm afraid.
Setting later target.

However, i do not really see this as a bug. We do not provide any default name
in the normal file save dialog either.

Back to TM, please ignore the API stuff for now.
Comment 7 nienberg 2009-12-03 02:00:43 UTC
The problem (or a similar one) still exists in 3.1.1.

The filepicker will ignore the "SetDefaultName" if the folder does not contain
any files.  If the folder contains at least one file (of any type) then the
filepicker will correctly display the default name.

Before displaying the filepicker, test to see if the directory contains any
files.  If not, create a dummy file in there, then execute the filepicker. 
After the user submits the dialog, delete the dummy file.