I'm using the UNO API, since the OOoBean does not work on Macs. I'm successfully bootstrapping OpenOffice from my Java application, successfully inserting text and manipulating the document from my Java application, and have even successfully inserted my own top level menu to the right of the OpenOffice "Help" menu. I have also successfully registered an XEventListener to the "xEventBroad" (XEventBroadcaster) in the code snippet below. The method "public void notifyEvent(com.sun.star.document.EventObject e1) " is successfully passing me "OnSave", "OnPrint", "OnModifyChanged", etc., events.
I cannot, however, figure out how to register an XEventListener or XMenuListener to any menu so that my Java application can listen for the "public void select(MenuEvent e)". I simply want to know what menu item was selected. I've googled for hours, and have found code snippets that would supposedly do this for me, but none of them are complete, and they don't reference what version of OO they work with. I'm apparently missing a key chunk of code that registers listeners on the right "component".
Can anybody please point me to a reference that shows exactly how to do this in OpenOffice 3.1.0? Or even OO 2? I'd prefer a Java example, but will gladly take anything that shows, from the initial bootstrap, what I need to do. The code doesn't need to be documented - I can figure it out if I can just see a working example.
Thank you so much if you can help me!
Here is a code snippet of the one listener I'm successfully able to register:
Code: Select all
("_context" is a valid XComponentContext returned from bootstrapping; "el" is an implementation of XEventListener)
Object xGlobalBroadCaster = null;
try
{
xGlobalBroadCaster = _context.getServiceManager().createInstanceWithContext(
"com.sun.star.frame.GlobalEventBroadcaster",
_context);
}
catch(Exception e2)
{
e2.printStackTrace();
}
XEventBroadcaster xEventBroad = (XEventBroadcaster) UnoRuntime.queryInterface(XEventBroadcaster.class, xGlobalBroadCaster);
xEventBroad.addEventListener(el);