Issue 90219 - Opening native file picker from Basic Makro (com.sun.star.ui.dialogs.FilePicker) does nothing
Summary: Opening native file picker from Basic Makro (com.sun.star.ui.dialogs.FilePick...
Status: CLOSED FIXED
Alias: None
Product: porting
Classification: Code
Component: MacOSX (show other issues)
Version: OOo 3.0 Beta
Hardware: Mac Mac OS X, all
: P4 Trivial with 2 votes (vote)
Target Milestone: 4.x
Assignee: florian
QA Contact: issues@porting
URL:
Keywords: aqua
Depends on:
Blocks:
 
Reported: 2008-06-01 16:40 UTC by Uwe Altmann
Modified: 2012-05-28 11:26 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Test case (11.33 KB, application/vnd.oasis.opendocument.text)
2009-01-15 23:23 UTC, florian
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Uwe Altmann 2008-06-01 16:40:22 UTC
...not even trows an exception.
Try using template changer extension on
http://extensions.services.openoffice.org/project/templatechanger. It adds a new
menu entry in Files - Templates calles "Assign new" which basically opens a file
picker to assign a new template to the documnet. On Mac OS X aqua nothing happens.
Choosing Tools - Options - General "Use OOo-Dialogs" brings everything to work
as expected.

Code from Main is:
	'Error handling for broken KDE-Filepicker implementation
	On Error Goto OpenOOoFilePicker
	
	' try to create the default FilePicker
	oFp = createunoservice("com.sun.star.ui.dialogs.FilePicker")
	Goto CreatedFilePicker

	' if we get an error - tryto open the OOo filepicker
	
OpenOOoFilePicker:
	On Error Goto 0
	bUseSystemFilePicker = ChangeSystemFileDialog (false)
	oFp = createunoservice("com.sun.star.ui.dialogs.FilePicker")
	ChangeSystemFileDialog (bUseSystemFilePicker)

this should swich to OOos File picker if no native File picker works.
But neither an exception nor an error message occurs there.
Comment 1 eric.bachard 2008-06-01 20:16:55 UTC
Indeed : nothing happens with my recent build ( Intel / 10.4 )

Issue confirmed
Comment 2 florian 2008-06-04 12:48:26 UTC
Since native aqua fp is my terrain, I'll take this one.
Comment 3 florian 2008-06-05 19:40:41 UTC
@andreschnabel:
OK, it's an error that the aqua implementation doesn't throw an exception.

But I also consider it an error that your extension doesn't properly initialize the file picker. You may 
consider changing the CreatedFilePicker label to start this way:
CreatedFilePicker:
	Dim initArgs(0)
	initArgs(0) = 0
	oFp.Initialize(initArgs)

to initialize the file picker as a simple file open dialog. For a list of possible values to supply to 
initArgs(0) see offuh/com/sun/star/ui/dialogs/TemplateDescription.hdl.

But I will also change the fpicker implementation to initialize with this value if no proper initialization is 
done by a calling component.
Comment 4 andreschnabel 2008-07-17 15:16:28 UTC
lower priority, as the problem does not occure if the dialog is correctly
initialized (as suggested by fheckl).

note: there is no exception thrown, as the dialog immidiately returns with "false" 
Comment 5 florian 2009-01-15 23:21:53 UTC
Fixed in cws aquafilepicker03. However I changed my mind and decided that if the dialog is not 
properly initialized from the outside, it might be better to throw an exception than to switch to a 
default mode (which might be the wrong type of dialog anyway).

The fix can be tested with the document I will attach next. It runs the following OOo Basic macro that 
would just do nothing without the patch:

Sub Main

Dim oFp
Dim initArgs(0)

	On Local Error Goto InitializeFilePicker
	
	' try to create the default FilePicker
	oFp = createunoservice("com.sun.star.ui.dialogs.FilePicker")
	Goto RunFilePicker
	
InitializeFilePicker:
	On Local Error Goto 0
	initArgs(0) = 0
	oFp.Initialize(initArgs)

RunFilePicker:
	oFp.execute

End Sub
Comment 6 florian 2009-01-15 23:23:14 UTC
Created attachment 59420 [details]
Test case
Comment 7 pierre13fr 2009-02-07 10:52:49 UTC
Whatever is the mind of fheckl, the behavior of this dialog should have been
consistent through various versions of oo (because some people rely on intuitive
behavior). Moreover, having default behavior as being a "standard open dialog"
is not so abnormal.
Anyway, it is now a fact (at least in oo 3.0.0 and 3.0.1 on windows platforms as
far as I experimented myself) that the initialization is mandatory. 
Well ok, but I suggest then that the IDL documentation clearly mention this.
And that the embedded "Macro- Tools - GetFileName" be corrected : because it
does not work anymore (curiously the correct initialization code has been
commented out ! probably by another man who changed also his mind).

Comment 8 Frank Schönheit 2009-03-15 21:39:48 UTC
I agree that the initialization should be optional only. For one,
http://api.openoffice.org/docs/common/ref/com/sun/star/ui/dialogs/FilePicker.html states
that even the complete interfaces is optional, which implies there might be
implementations which do not support it. Requiring *all* (existing and future)
clients to check for this particular interface, and use it if present, is
certainly a Bad Thing (TM).
Second, and this has been raised already: Requiring initialization breaks API
compatibility for existing code, and should not be done with a *very* good
justification, which I miss here :)
Comment 9 Frank Schönheit 2009-03-15 21:40:26 UTC
"should not be done with" should read "should not be done without", of course
Comment 10 florian 2009-03-17 23:09:04 UTC
OK, then let me quote from this same FilePicker service documentation 
(http://api.openoffice.org/docs/common/ref/com/sun/star/ui/dialogs/FilePicker.html):
::com::sun::star::lang::XInitialization -> "Implementers may omit this interface if the FileOpen dialog 
doesn't support custom templates. In this case a createInstance will create an ordinary FileOpen dialog 
with only the common FilePicker elements. The client has to provide one of the specified constants in 
TemplateDescription."

The aqua implementation does support custom templates and thus clients have to provide a template 
description initialization.

Is that justification enough?
Comment 11 Frank Schönheit 2009-03-18 08:40:34 UTC
Okay, you are right in that the service description can be read this way. (I
won't pick nits about the difference between "if" and "if and only if" here :)

However, you did not respond to the second item, which in fact is my bigger
concern: The change you did breaks (semantic) API compatibility. While that is
sometimes legitimate, it should have a really good justification, which I don't
see here. Defaulting to the file-open template shouldn't pose any problem, right?
Comment 12 florian 2009-03-18 09:23:10 UTC
Defaulting to the standard file open dialog is, of course, no problem, unless
maybe the caller intended the dialog to be a save dialog, but how should I know?

If you think that defaulting is better than throwing an exception in that case,
then please feel free to reopen the issue :)
As long as it's 'resolved' I won't change anything (and I won't reopen it myself).
Comment 13 Frank Schönheit 2009-03-18 10:33:38 UTC
If you agree that defaulting to file-open (as its done in the other OS'es
implementations) is reasonable, then maybe we can implement this in the course
of issue 100214 (which is what lead me here)?
Comment 14 stefan.baltzer 2010-01-14 13:24:07 UTC
Verified in OOO320_m9.
Comment 15 stefan.baltzer 2010-01-14 14:00:49 UTC
OK in OOO320_m8 and m9. Closed.