Apache OpenOffice (AOO) Bugzilla – Issue 110141
FilePicker Dialog "setDisplayDirectory" ignored
Last modified: 2015-07-29 19:25:21 UTC
Here is code that will open a filepicker. The code was adopted from http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Basic/File_Control. When running this macro (Windows 7, 64), the file picker should open with the directory "C:" as root, but instead it shows a previously used directory. On WinXP 32bit it shows the expected bahavior. =========== code ====== Sub OpenFileDialog() REM file dialog oFilePicker = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" ) REM set filter oFilePicker.AppendFilter( "All files (*.*)", "*.*" ) sFileURL = "c:" REM set display directory oFilePicker.setDisplayDirectory( sFileURL ) REM execute file dialog If oFilePicker.execute() Then sFiles = oFilePicker.getFiles() sFileURL = sFiles(0) msgbox sFileURL End If End Sub =========================
Reassigned to JSK
.
I suppose your used urls is the problem. It is not a valid url. Please try "file:///C|" as the file url.
No difference. I tried sFileURL = "file:///C|" and sFileURL = "file:///C:" and sFileURL = "file:///C:/" and sFileURL = "file:///C:\" no change. Does not open c:, but a directory that I picked from some openoffice macro before the last reboot.
The described problem is specific to the Vista and Windows 7 file picker. Indeed, the file picker remembers its last accessed file location, which is a feature of the file picker, provided by the OS. While this is desirable in many cases, it doesn't behave as expected in the described context. Unfortunately, the XFilePicker interface doesn't provide more flexible means to set the display path. There should be a way to set a suggested default path and another way to forcibly set the display path.
So do I understand it right that: - the FilePicker.setDisplayDirectory() code in StarBasic will behave differently, depending on whether WinXP or Win7 - at this point the user has no influence on the above
@mogliii: First of all, yes. You could use OOo file dialogs, then the behavior will be identical on all systems.
Could you give a bit more information about "OOo file dialogs" I was not aware there are different ways of getting a file picker? Can you give a minimal code example?
REM from the tools library oUserDataAccess = GetRegistryKeyContent("org.openoffice.Office.Common/Misc",true) oUserDataAccess.ReplaceByName("UseSystemFileDialog", false) oUserDataAccess.CommitChanges()
Created attachment 76169 [details] test document
cd: hennerdrewes correctly described the situation. Without an adapted API (force to set directory) there is no way to implement setDisplayDirectory() correctly. OOo and developers of 3rd party extensions use the same call but it should behave different. Without additional argument that's impossible. Due to the fact that we don't want to do enhancements in the fix regression phase I want to set the issue to P4/regression. There is a short way for users to select the directory that was set via setDisplayDirectory. The Vista/7 file picker adds a short-cut topmost on the left side. I think this is a good workaround.
Assign to new default-assignee
it seems setting the directory works, if the filpicker is initialized: REM ***** BASIC ***** OPTION EXPLICIT Sub Main Dim dlg as Object dlg = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" ) Dim Dialogtyp(0) DialogTyp(0) = com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION dlg.initialize(DialogTyp()) dlg.Title = "Test" ' dlg.DisplayDirectory = "file:///c:/users" dlg.DisplayDirectory = "file:///c:/" ' this will crash aoo401: ' dlg.DefaultName = "xxx" If dlg.Execute = 1 Then MsgBox dlg.SelectedFiles(0) End Sub see issue "Issue 123544 - XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows" for details