OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

FileControl and directories

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
jody
General User
General User


Joined: 30 Mar 2010
Posts: 13

PostPosted: Sat Apr 03, 2010 12:10 am    Post subject: FileControl and directories Reply with quote

Hi
I have built a dialog containing a FileControl element, which i intend to use for the selection of a directory. However, if i click on the "open" button when a directory is selected, this directory will open. I.e. there is no way to actually select a directory.

In the documentation i saw an example using
com.sun.star.ui.dialogs.FilePicker
but its description in the api pages gave me no indication if or how i could use it to select a directory.

I tried to look for a "DirectoryControl" or "DirControl" in the api pages but couldn't find anything.


Is there a property of FIleControl i can set such that i can choose a directory instead of opening it?
Or is there some UNO object that can do this?

Thank You
jody
Back to top
View user's profile Send private message
Voobase
OOo Advocate
OOo Advocate


Joined: 21 Nov 2007
Posts: 400
Location: Australia

PostPosted: Mon Apr 05, 2010 1:48 am    Post subject: Reply with quote

Hi there,

Would you use Folder picker instead?

To use the Open Office Folder Picker...
Code:
oFolderPicker = createUnoService( "com.sun.star.ui.dialogs.OfficeFolderPicker" )

To use the Folder Picker as selected in your Open Office General Options...
Code:
oFolderPicker = createUnoService( "com.sun.star.ui.dialogs.FolderPicker" )

To use the system Folder Picker...
Code:
oFolderPicker = createUnoService( "com.sun.star.ui.dialogs.SystemFolderPicker" )


Here is a function which I use, taken from here... http://www.oooforum.org/forum/viewtopic.phtml?t=9797

Code:
Function PickFolderSpecific( StartURL ) as string
   oFolderPickerDlg = createUnoService( "com.sun.star.ui.dialogs.OfficeFolderPicker" )
'   oFolderPickerDlg = createUnoService( "com.sun.star.ui.dialogs.FolderPicker" )
'   oFolderPickerDlg = createUnoService( "com.sun.star.ui.dialogs.SystemFolderPicker" )
   If Len( StartURL ) > 0 Then
      oFolderPickerDlg.setDisplayDirectory( ConvertToURL( StartURL ) )  Rem... Broken. Does not work with system folder picker.
   End If

   oFolderPickerDlg.execute()
   
   cPickedFolder = oFolderPickerDlg.getDirectory()
   
      PickFolderSpecific = ConvertFromURL( cPickedFolder )

End Function


Note... I could not get the Start URL bit to work with a SystemFolderPicker on my Vista Machine using oOO 3.1.1 Likewise goes for SystemFilePicker, where it was also not possible to use the SetDefaultName property. Phps bug. Not sure if its been reported yet.

Also look at this link for some library tools which get the Directory or File name from a URL...
http://www.oooforum.org/forum/viewtopic.phtml?t=13924

Cheers

Voo
Back to top
View user's profile Send private message
jody
General User
General User


Joined: 30 Mar 2010
Posts: 13

PostPosted: Mon Apr 05, 2010 6:58 am    Post subject: Reply with quote

Tanhk You, voo

The FolderPickerwas just what i needed!
I now built a text-control together with a button
that starts the FolderPicker dialog, with the initial
directory set to the value in the text control.
When OK is pressed, the current directory
from the FolderPicker is written to the text control.

Thanks!
Jody
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group