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

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

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

Post 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?
Last edited by JulianR on Fri Oct 11, 2019 4:00 pm, edited 1 time in total.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

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

Post 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
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

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

Post by JulianR »

Thanks.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

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

Post 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

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.
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

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

Post by JulianR »

Looks promising, but I will need to dig deeper into that keyaccess object.Thanks.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
Post Reply