Bug 162357 - Menu created in Calc application by ScriptForge collapsed after insert OLE object
Summary: Menu created in Calc application by ScriptForge collapsed after insert OLE ob...
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
24.2.5.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: ScriptForge
  Show dependency treegraph
 
Reported: 2024-08-05 13:39 UTC by Igor Gaidyshev
Modified: 2024-08-08 16:53 UTC (History)
2 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 Igor Gaidyshev 2024-08-05 13:39:17 UTC
Description:
Menu created in the Calc application by ScriptForge in Basic module collapsed after insert into document any OLE object (Formula) or Chart

Steps to Reproduce:
1. Create menu by ScriptForge
2. Insert chart into document

Actual Results:
Menu is collapsed

Expected Results:
Menu should stay


Reproducible: Always


User Profile Reset: No

Additional Info:
The menu can be restored by re-running the macro that created it
Comment 1 Rafael Lima 2024-08-05 20:47:51 UTC
According to the documentation in [1]:

When OLE objects such as Math formulas or Calc charts are edited from within a document, LibreOffice reconfigures the menubar according to the object. When this happens, the menus created with the Menu service are removed and are not be restored after editing the OLE object.

[1] https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_menu.html

Unfortunately the menu created by the Menu service is not persistent after opening and closing an OLE object.

@JPL is there any room for improvement here?
Comment 2 Jean-Pierre Ledure 2024-08-06 12:38:43 UTC
There is no solution, indeed, within ScriptForge. After creation and configuration, a menu is disposed. It is kept nowhere for occasional restores.

There is a mean to not create a menu twice: precede each CreateMenu() with a RemoveMenu(). The latter simply returns True (the menu existed) or False (the menu was not found) and does not complain when not found.

In the future we can imagine a kind of
    doc.MenuExists(menuname)
method if there is a real pain.

In the meantime I recommend the NOTABUG status. I let you the final decision, Rafael.
Comment 3 Rafael Lima 2024-08-06 13:19:13 UTC
This can be marked as NAB indeed, since there's nothing broken.

Let's just wait and see the OP's opinion.
Comment 4 Rafael Lima 2024-08-06 13:37:45 UTC
As a workaround, the OP could try to associate the macro that creates the menu with the OnFocus document event. When the OLE object window is closed, the original document gets back the focus and triggers the OnFocus event.
Comment 5 Igor Gaidyshev 2024-08-06 14:12:57 UTC
I made a temporary workaround with no ScriptForge. You can see the details at https://sourceforge.net/projects/criterial/
Comment 6 Rafael Lima 2024-08-06 17:52:11 UTC
(In reply to Igor Gaidyshev from comment #5)
> I made a temporary workaround with no ScriptForge. You can see the details
> at https://sourceforge.net/projects/criterial/

This is great work!

I took a look at your code, and you should pack it as an extension. When you do it as an extension, you can define which menu entries to be created, so there's no need for user intervention to install the files and create the menu entries.

See the following links to learn more:

https://wiki.documentfoundation.org/Development/Create_a_Hello_World_LibreOffice_extension

https://wiki.documentfoundation.org/Development/Extension_Development

And for a very detailed documentation:

https://wiki.documentfoundation.org/Documentation/DevGuide/Extensions

I'm closing this as NAB.
Comment 7 Igor Gaidyshev 2024-08-08 16:53:23 UTC
Thanks for your advice and attention. To hide the complexity for users, the application now includes scripts for fully automatic installation and removal of the application for Linux/UNUX and Windows, respectively.