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

Creating a macro - Writing a Script - Using the API

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

Postby JulianR » Fri Oct 11, 2019 11:42 am

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
JulianR
 
Posts: 25
Joined: Mon Mar 12, 2018 9:41 am

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

Postby hanya » Fri Oct 11, 2019 3:21 pm

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
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

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

Postby JulianR » Fri Oct 11, 2019 3:59 pm

Thanks.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
JulianR
 
Posts: 25
Joined: Mon Mar 12, 2018 9:41 am

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

Postby hubert lambert » Fri Oct 11, 2019 4:02 pm

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.
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hubert lambert
 
Posts: 132
Joined: Mon Jun 13, 2016 10:50 am

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

Postby JulianR » Fri Oct 11, 2019 4:16 pm

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
JulianR
 
Posts: 25
Joined: Mon Mar 12, 2018 9:41 am


Return to Macros and UNO API

Who is online

Users browsing this forum: MSN [Bot] and 9 guests