Bug 70843 - Other: XFilePicker's setDisplayDirectory and setDefaultName do not work
Summary: Other: XFilePicker's setDisplayDirectory and setDefaultName do not work
Status: RESOLVED DUPLICATE of bug 43021
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: BSA
Keywords:
Depends on:
Blocks: Macro-UNOAPI
  Show dependency treegraph
 
Reported: 2013-10-24 15:49 UTC by Ariel David Moya Sequeira
Modified: 2019-11-21 19:05 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ariel David Moya Sequeira 2013-10-24 15:49:28 UTC
Problem description: 

When a file picker is created using the following code, the directory and filename are not set when the file picker is shown. This happens only in Windows; in Ubuntu 12.10 (using LibreOffice 3.6 from APT) it works as expected.

Steps to reproduce:
1. Create a new extension which shows a file picker using the code mentioned above.
2. Install the extension in LibreOffice in Windows.
2. Run LibreOffice in Windows.
3. Open an LibreOffice-compatible document.
4. Run the extension.

Current behavior:
The file picker doesn't start where the opened document is saved nor the filename of the document is set as default filename.

Expected behavior:
The default directory and filename of the file picker is the same as the opened document.
Operating System: Windows 7
Version: Inherited From OOo
Comment 1 Ariel David Moya Sequeira 2013-10-24 16:15:04 UTC
The code in Java is as follows. Here, "originalUrl" is the URL taken from the currently open document; "Environment" is just a helper class to retrieve some information about the opened document.

Object oFilePicker = component_factory.createInstanceWithContext("com.sun.star.ui.dialogs.FilePicker", Environment.getContext());
XFilePicker xFilePicker = (XFilePicker) UnoRuntime.queryInterface(XFilePicker.class, oFilePicker);

xFilePicker.setMultiSelectionMode(false);
if (originalUrl == null) {
	xFilePicker.setDisplayDirectory(Environment.getHomeDir());
	xFilePicker.setDefaultName("");
}
else {
	int idx = originalUrl.lastIndexOf('/');
	if (idx >= 0) {
		xFilePicker.setDisplayDirectory(originalUrl.substring(0, idx));
		xFilePicker.setDefaultName(originalUrl.substring(idx+1));
	}
}
Comment 2 Ariel David Moya Sequeira 2013-10-24 20:35:45 UTC
According to https://issues.apache.org/ooo/show_bug.cgi?id=123544, it's a problem with system dialogs. A solution can be found in the link provided above.
Comment 3 Owen Genat (retired) 2014-07-22 02:16:02 UTC
(In reply to comment #2)
> According to https://issues.apache.org/ooo/show_bug.cgi?id=123544, it's a
> problem with system dialogs. A solution can be found in the link provided
> above.

Comments in the AOO bug confirm this issue. Status set to NEW. There is also a possible solution posted:

https://issues.apache.org/ooo/show_bug.cgi?id=123544#c18

If this can be confirmed to work we may be able to RESOLVE this bug.
Comment 4 Cor Nouws 2015-07-15 15:27:29 UTC
I just happen to work with 4.4.5.1 on Ubuntu 32 bits.

LibreOffice internal dialog does not display the name that is set.
The system dialog does.

The dialog is initialized, as suggested here https://bz.apache.org/ooo/show_bug.cgi?id=123544#c18

I've seen it working in other versions.. Hmm
Comment 5 Regina Henschel 2015-09-03 17:19:01 UTC
Likely same as bug #43021.
Comment 6 QA Administrators 2017-01-03 19:35:17 UTC Comment hidden (obsolete)
Comment 7 Xisco Faulí 2017-06-11 15:23:13 UTC
*** Bug 95722 has been marked as a duplicate of this bug. ***
Comment 8 QA Administrators 2018-06-12 02:33:15 UTC Comment hidden (obsolete)
Comment 9 Buovjaga 2019-08-11 11:14:15 UTC
Let's assume this is bug 43021

*** This bug has been marked as a duplicate of bug 43021 ***