Created attachment 195160 [details] Error reported by CreateMenu The issue involves the Document service's CreateMenu method and the "before" parameter. As described in the help: before: The name (as a string) or position (as an integer starting at 1) of an existing menu before which the new menu will be placed. If no value is defined for this argument, the menu will be created at the last position in the menu bar. Well, inserting an integer generates an execution error as in the attached image. Form of this parameter is important when the macro is to be executed in different language versions of the installed LibreOffice application.
Can you provide a sample code where the bug happens?
Indeed, the following macro results in the reported error message: Sub MenuMacro GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") oDoc = CreateScriptService("Document", ThisComponent) oMenu = oDoc.CreateMenu("My Menu", Before := 3) With oMenu oMenu.AddItem("Item A") oMenu.AddItem("Item B") End With End Sub As per documentation, it should work. Changing the CreateMenu call to: oMenu = oDoc.CreateMenu("My Menu", Before := "Insert") Makes it work. @JPL what is your opinion?
I confirm the bug. The validity check of the Before argument is too strict. Line 573 in the SF_Document module (library SFDocuments) If Not ScriptForge.SF_Utils._Validate(Before, "Before", V_STRING) Then GoTo Finally must contain: If Not ScriptForge.SF_Utils._Validate(Before, "Before", Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally I will prepare a patch. NB: a manual change in the Basic install file can be a temporary workaround. Thanks for reporting the bug.
Jean-Pierre Ledure committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/b2b29283c21640d02b12c031963dbd50a646552c ScriptForge (Document) tdf#161946 Fix CreateMenu() / Before It will be available in 25.2.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-24-8": https://git.libreoffice.org/core/commit/42e3bb7cde89db579d5a42a18b7a7a93c6aad059 ScriptForge (Document) tdf#161946 Fix CreateMenu() / Before It will be available in 24.8.0.2. 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-24-2": https://git.libreoffice.org/core/commit/161a6e1b2f946ee8f756874d240da738668ccbba ScriptForge (Document) tdf#161946 Fix CreateMenu() / Before It will be available in 24.2.6. 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-24-2-5": https://git.libreoffice.org/core/commit/647e35f54a9c41d6840bf191fcc97de56c6578a8 ScriptForge (Document) tdf#161946 Fix CreateMenu() / Before It will be available in 24.2.5. 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.