Hi Rony,

Rony G. Flatscher wrote (14-6-2008 16:07)

not sure whether this is the correct group, if not please advise which one would be the correct one.

This is the right one.

Platform is Windows XP SP 3.

The "FolderPicker" service interface "XFolderPicker" has a method "setDisplayDirectory()" which is supposed to do the following according to the docs: "Sets the root directory that the FolderPicker should display. It is not specified which root directory the FolderPicker chooses if the specified root directory doesn't exist. "

However, this does not work at all. Tried all variations (system file path, URL, with and without trailing slash, feeding the directory path exactly like the service returns it).

Actually, using "setDisplayDirectory()" works, as a "getDisplayDirectory()" thereafter will return the set directory. However, the dialog does not pick that directory but displays the root.

It should work. Try this one any does for me (mind that lines might have been broken in the mail):

Function MyFilePicker( cFolder, cFileName, bOpen, sTitle$)as string
        ' bOpen gives choise between FileOpen and FileSave
        Dim oFilePickerDlg, sFilePickerArgs, oUcb
        Dim sFilesPicked() as String
        
        oFilePickerDlg = createUnoService( "com.sun.star.ui.dialogs.FilePicker" 
)
        If bOpen then
sFilePickerArgs = Array( com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE )
        Else
sFilePickerArgs = Array( com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION_PASSWORD )
        End If
        With oFilePickerDlg
                .setTitle(sTitle)
                .Initialize ( sFilePickerArgs() )
                .SetDisplayDirectory (cFolder)
                .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
        oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
        If Len( cFolder ) > 0 Then
                If oUcb.Exists(cFolder) Then
                        oFilePickerDlg.setDisplayDirectory( ConvertToURL( 
cFolder ) )
                End If
        End If
        If Len( cFileName ) > 0 Then
                oFilePickerDlg.setDefaultName( cFileName )
        End If

        If oFilePickerDlg.execute() > 0 then
                sFilesPicked() = oFilePickerDlg.getFiles()
                MyFilePicker = sFilesPicked(0)
        End If
End Function

[...]
P.S.: The FilePicker works (including preselecting a directory), but for the purpose of the application only a directory should be picked, not a file (the directory could be empty!).

For that purpose, you could use the following:

Function PickMyFolderName (sDocPath$, sFileName$, sTitle$) as String
        Dim oFolderPickerDlg

oFolderPickerDlg = createUnoService( "com.sun.star.ui.dialogs.FolderPicker" )
        oFolderPickerDlg.setTitle(sTitle)       
If Len(sDocPath) > 0 Then oFolderPickerDlg.SetDisplayDirectory (ConvertToURL(sDocPath))

        If oFolderPickerDlg.execute() > 0 Then
                PickMyFolderName = oFolderPickerDlg.getDirectory
        End If
End Function

HTH,
Cor
--
"The Year of 3" -2008- "Het jaar van 3"

Cor Nouws - Arnhem - Netherlands
  > marketing contact - http://nl.OpenOffice.org
  > Zeker van OpenOffice.org ? www.nouenoff.nl


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to