Apache OpenOffice (AOO) Bugzilla – Issue 79211
FilePicker doesn't show name if no other file of same type exists on the location
Last modified: 2013-08-07 15:31:14 UTC
FilePicker doesn't show name if no other file of same type exists on the start location. 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( "com.sun.star.ui.dialogs.FilePicker" ) sFilePickerArgs = Array(com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION_PASSWORD ) 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)" ) .SetValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_AUTOEXTENSION, 0, true) .SetValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_PASSWORD, 0, false) End With If oFilePickerDlg.execute() > 0 Then sFilesPicked() = oFilePickerDlg.getFiles() PickMyFileName= sFilesPicked(0) End If End Function
TM->JSK: please have a look, thanks
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.
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
setting closed
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??
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.
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. Workaround: 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.