Issue 110141 - FilePicker Dialog "setDisplayDirectory" ignored
Summary: FilePicker Dialog "setDisplayDirectory" ignored
Alias: None
Product: ui
Classification: Code
Component: code (show other issues)
Version: OOO320m12
Hardware: PC (x86_64) Windows 7
: P4 Trivial with 4 votes (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Keywords: regression
Depends on:
Reported: 2010-03-15 16:09 UTC by mogliii
Modified: 2015-07-29 19:25 UTC (History)
8 users (show)

See Also:
Latest Confirmation in: ---
Developer Difficulty: ---

test document (9.22 KB, application/vnd.oasis.opendocument.spreadsheet)
2011-03-22 14:38 UTC, daniel.rentz
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description mogliii 2010-03-15 16:09:35 UTC
Here is code that will open a filepicker. The code was adopted from

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( "" )
	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
Comment 1 eric.savary 2010-03-15 16:34:44 UTC
Reassigned to JSK
Comment 2 eberlein 2010-03-16 08:24:42 UTC
Comment 3 pb 2010-03-16 08:57:29 UTC
I suppose your used urls is the problem. It is not a valid url. Please try
"file:///C|" as the file url.
Comment 4 mogliii 2010-03-16 12:38:26 UTC
No difference.

I tried 
sFileURL = "file:///C|"
sFileURL = "file:///C:"
sFileURL = "file:///C:/"
sFileURL = "file:///C:\"

no change. Does not open c:, but a directory that I picked from some openoffice
macro before the last reboot.
Comment 5 hennerdrewes 2010-03-17 16:42:17 UTC
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. 
Comment 6 mogliii 2010-03-17 18:37:02 UTC
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
Comment 7 hennerdrewes 2010-03-17 19:09:46 UTC
@mogliii: First of all, yes.

You could use OOo file dialogs, then the behavior will be identical on all systems.
Comment 8 mogliii 2010-03-17 20:55:14 UTC
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?
Comment 9 eberlein 2010-03-22 14:19:18 UTC
REM from the tools library
oUserDataAccess = GetRegistryKeyContent("org.openoffice.Office.Common/Misc",true)
oUserDataAccess.ReplaceByName("UseSystemFileDialog", false)
Comment 10 daniel.rentz 2011-03-22 14:38:07 UTC
Created attachment 76169 [details]
test document
Comment 11 carsten.driesner 2011-03-23 13:15:09 UTC
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.
Comment 12 hans_werner67 2011-03-28 11:57:40 UTC
Assign to new default-assignee
Comment 13 Oliver Brinzing 2014-07-02 14:57:36 UTC
Comment 14 Oliver Brinzing 2014-07-03 06:18:00 UTC
it seems setting the directory works, if the filpicker is initialized:

REM  *****  BASIC  *****

Sub Main
    Dim dlg as Object

    dlg = CreateUnoService( "" )

    Dim Dialogtyp(0)
    DialogTyp(0) =

    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