Created attachment 186304 [details] error message generated by ScriptForge.SF_FileSystem.pickfile() This code evinces the error:- sub pickafile() f = ScriptForge.SF_FileSystem.pickfile() print(f) End Sub
Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided. (Please note that the attachment will be public, remove any sensitive information before attaching it. See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)
I can reproduce this issue in "gtk3" and "gen". The first call works fine, but if you run it a second time, we get an error. Running the macro in kf5 works fine. If anyone else wants to test, do not forget to load the ScriptForge library first. For that, use the following: sub pickafile() GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") f = ScriptForge.SF_FileSystem.pickfile() print(f) End Sub
Xisco asks for a sample document. I tried to attach PickAFile.ods but this message appears "The content type ods file is invalid. Valid types must be of the form foo/bar where foo is one of application, audio, image, message, model, multipart, text, video and bar must not contain any special characters (such as "=", "?", ...)." and I don't understand what is required to submit a sample document
(In reply to gellid from comment #3) > Xisco asks for a sample document. I was already able to reproduce the problem. So no need of an attachment for now.
I confirm the error under Linux Mint: Version: 7.5.2.2 (X86_64) / LibreOffice Community Build ID: 50(Build:2) CPU threads: 12; OS: Linux 5.4; UI render: default; VCL: gtk3 Locale: fr-BE (fr_BE.UTF-8); UI: fr-FR Ubuntu package version: 4:7.5.2~rc2-0ubuntu0.20.04.1~lo1 Calc: threaded in next code: sub pickafile() GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") f = ScriptForge.SF_FileSystem.pickfile() print(f) g = ScriptForge.SF_FileSystem.pickfile() print(g) End Sub on line: g = ScriptForge.SF_FileSystem.pickfile() The execution is normal under Windows: Version: 7.5.2.2 (X86_64) / LibreOffice Community Build ID: 53bb9681a964705cf672590721dbc85eb4d0c3a2 CPU threads: 6; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win Locale: en-US (en_BE); UI: en-US Calc: threaded
The root cause is: when running next Basic code: Sub pickafile() a = CreateUnoService("com.sun.star.ui.dialogs.FilePicker") a.appendFilter("*.*", "*.*") a.appendFilter("*.*", "*.*") End Sub the error occurs on the 2nd occurrence of line: a.appendFilter("*.*", "*.*") in the same graphical environments as described above: gen, gtk3: error kf5, win: no error The error does not happen in next code: Sub pickafile2() a = CreateUnoService("com.sun.star.ui.dialogs.FilePicker") a.appendFilter("*.*", "*.*") a = CreateUnoService("com.sun.star.ui.dialogs.FilePicker") a.appendFilter("*.*", "*.*") End Sub
Possible workarounds are: (1) in the user script, insert a statement, like in next code: sub pickafile() GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") Set _SF_.FilePicker = Nothing f = ScriptForge.SF_FileSystem.pickfile() print(f) End Sub (2) in the sources of ScriptForge, force next re-execution where appropriate: ... = CreateScriptService("com.sun.star.ui.dialogs.FilePicker") WHAT SHOULD BE DONE ? (1) is an immediate solution to help the user (2) does not solve the root cause but avoids error in the ScriptForge context Please recommendation is requested here. If implementation of (2) is requested, current bug report may be assigned to myself.
Reading https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1ui_1_1dialogs_1_1XFilterManager.html#ae6c608a77c755b24972d5d8abbddc1d4 it appears that an exception is raised on appendFilter() when a filter with the specified title already exists (even if not all contexts implement that exception). => The correction of the bug should be done in the ScriptForge code.
Jean-Pierre Ledure committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/9c60996fc2a536803d016d6f60f879f8a1e49a54 ScriptForge - (SF_FileSystem) tdf#154462 2nd call of PickFile() fails It will be available in 7.6.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Jean-Pierre Ledure committed a patch related to this issue. It has been pushed to "libreoffice-7-5": https://git.libreoffice.org/core/commit/ffbe4d480802a351a13ec70777e68e37c3c019eb ScriptForge (SF_FileSystem) tdf#154462 2nd call of PickFile() fails It will be available in 7.5.3. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Fixed and verified with Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: a4af5432753408c4eea8a8d56c2f48202160c5fe CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: kf5 (cairo+xcb) Locale: pt-BR (pt_BR.UTF-8); UI: en-US Calc: CL threaded