Page 1 of 1

[Solved] Addon - Manipulation of Menu added with addons.xcu

PostPosted: Fri Oct 11, 2019 11:42 am
by JulianR
Hi!

I have been working on an extension and I wanted to add my own menu entry to Calc, while I can do this with addons.xcu file, I can't later find that menu entry with service com.sun.star.ui.ModuleUIConfigurationManagerSupplier. I can mess with every default menu entry (like with say File/New), add my own menu and entries, but I can't find the entry, that was added with addons.xcu.

Anyone knows if it is possible access those entries with some other UNO service? And If it is possible to manipulate them at runtime?

Re: Addon - Manipulation of Menubar added with addons.xcu

PostPosted: Fri Oct 11, 2019 3:21 pm
by hanya
Not possible to edit the menu added by addons.xcu at runtime.
I have used to add a menu by addons.xcu with popup menu controller which can be edit while at runtime, see: https://github.com/hanya/BookmarksMenu

Re: Addon - Manipulation of Menubar added with addons.xcu

PostPosted: Fri Oct 11, 2019 3:59 pm
by JulianR
Thanks.

Re: Addon - Manipulation of Menubar added with addons.xcu

PostPosted: Fri Oct 11, 2019 4:02 pm
by hubert lambert
Hi,

A menu added by configuration file is merge in the global configuration registry. Some changes can be made by directly accessing the later.
A simple example in basic, that modifies the item name in the menu bar:
Code: Select all   Expand viewCollapse view
sub accessCustomMenuItem
    globalscope.BasicLibraries.loadLibrary("Tools")
    key = "org.openoffice.Office.Addons/AddonUI/OfficeMenuBar/"
    menuID = "name.of.custom.menu"    '--> adapt here with the real name of the menu as defined in addons.xcu file
    keyaccess = getRegistryKeyContent(key + menuID, True)
    keyaccess.replaceByName("Title", "NEW NAME")
    keyaccess.commitChanges()
    keyaccess.dispose()
    ' Update the current frame if needed.
    ' You may also need to update other active frames
    wait 100  ' this is sometimes needed before update, don't know why
    layouter = stardesktop.ActiveFrame.LayoutManager
    layouter.getElement("private:resource/menubar/menubar").updateSettings()
end sub
[tested on LibreOffice only]

Regards.

Re: [SOLVED] Addon - Manipulation of Menu added with addons.

PostPosted: Fri Oct 11, 2019 4:16 pm
by JulianR
Looks promising, but I will need to dig deeper into that keyaccess object.Thanks.