Bug 109093 - Macro using com.sun.star.ui.dialogs.FilePicker (save as) stops working and presents "open" window
Summary: Macro using com.sun.star.ui.dialogs.FilePicker (save as) stops working and pr...
Status: CLOSED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.2.7.2 release
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisectRequest, regression
Depends on:
Blocks:
 
Reported: 2017-07-13 11:14 UTC by Knut Wenzig
Modified: 2017-08-21 08:58 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot. "Öffnen" is german and translates to "open" (46.92 KB, image/png)
2017-07-13 11:14 UTC, Knut Wenzig
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Knut Wenzig 2017-07-13 11:14:14 UTC
Created attachment 134608 [details]
Screenshot. "Öffnen" is german and translates to "open"

The macro below saves a table as csv (with defined settings). It worked in 5.2.6.2 but in 5.2.7.2 it opens an "open"-Window (instead of save as) and does not save the file.

Sub DDICSVsave
dim aUrl(), s$
Dim Arg()
dim fileProps(1) as new com.sun.star.beans.PropertyValue
fileProps(0).Name = "FilterName"
fileProps(0).Value = "Text - txt - csv (StarCalc)"
fileProps(1).Name = "FilterOptions"
fileProps(1).Value = "44,34,76,1,,0,false,true,true,false"
oDlg = createUnoService("com.sun.star.ui.dialogs.FilePicker")
oDlg.setMultiSelectionMode(false)
oDlg.initialize(array(1)) ' Speichern unter
oDlg.execute
aUrl = oDlg.getFiles()
thisComponent.storeAsURL(aURL(0), fileProps())
End Sub
Comment 1 Xisco Faulí 2017-07-14 09:22:36 UTC Comment hidden (obsolete)
Comment 2 Knut Wenzig 2017-07-26 06:51:16 UTC
This Version is also affected.

Version: 5.3.4.2
Build-ID: f82d347ccc0be322489bf7da61d7e4ad13fe2ff3
CPU-Threads: 4; BS-Version: Windows 6.1; UI-Render: Standard; Layout-Engine: neu; 
Gebietsschema: de-DE (de_DE); Calc: group
Comment 3 Buovjaga 2017-08-20 15:40:00 UTC
I repro on Win, but not on Linux.
I tried to bibisect, but the 5.4 repository kept crashing, oldest or latest commits.
5.3 repository did not crash and did not show the problem.

Win 10
Version: 6.0.0.0.alpha0+ (x64)
Build ID: b9f85538e65882238de80ab36c864bc0082ad7f4
CPU threads: 4; OS: Windows 6.19; UI render: default; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2017-08-20_01:44:43
Locale: fi-FI (fi_FI); Calc: group
Comment 4 Regina Henschel 2017-08-20 19:16:03 UTC
You need to initialize first, before calling setMultiSelectionMode.
Initialize with  com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_SIMPLE

Together this is:

Sub DDICSVsave
dim aUrl(), s$
dim oDlg as variant
dim fileProps(1) as new com.sun.star.beans.PropertyValue
fileProps(0).Name = "FilterName"
fileProps(0).Value = "Text - txt - csv (StarCalc)"
fileProps(1).Name = "FilterOptions"
fileProps(1).Value = "44,34,76,1,,0,false,true,true,false"
oDlg = createUnoService("com.sun.star.ui.dialogs.FilePicker")
dim listAny(0) as variant
listAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_SIMPLE
oDlg.initialize(listAny()) ' Speichern unter
oDlg.setMultiSelectionMode(false)
oDlg.execute
aUrl = oDlg.getFiles()
thisComponent.storeAsURL(aURL(0), fileProps())
End Sub
Comment 5 Buovjaga 2017-08-21 06:08:21 UTC
Thanks, Regina. Closing.
Comment 6 Knut Wenzig 2017-08-21 08:11:51 UTC
I tried the suggested solution. It works with 5.4.0.3.

Great!

Thanks a lot, Regina!