news.gmane.org ha scritto:
Mathias Bauer ha scritto:
news.gmane.org wrote:

Hello,
I have a java application which intercepts events from an office bean using the GlobalEventBroadcaster interface.
[CUT]
My goal is to find at least the name of the file being loaded, or better a unique ID identifying the instance of the bean which generated the event.
Any idea?

Why don't you take the EventSource argument of your notification call?
It is a reference to the document for that the event is notified.

I'm already getting the EventObject using the code below, but I could not find the document name in the Properties.

Is there a may to get the document name?

Finally I did it. Here's the code, I hope it may be useful to someone:

//code by Alex Laudani (http://www.softmasters.net)
XComponentContext xRemoteContext = oBean.getOOoConnection().getComponentContext();
String st2[]=xRemoteContext.getServiceManager().getAvailableServiceNames();
System.out.println(st2);
Object xGlobalBroadCaster = xRemoteContext.getServiceManager().createInstanceWithContext(
"com.sun.star.frame.GlobalEventBroadcaster", xRemoteContext);
XEventBroadcaster xEventBroad = (XEventBroadcaster)UnoRuntime.queryInterface(XEventBroadcaster.class, xGlobalBroadCaster);
xEventBroad.addEventListener(new com.sun.star.document.XEventListener() {
        public void notifyEvent(com.sun.star.document.EventObject oEvent) {
//the control model which fired the event
System.out.println("Evento da : " + oEvent.Source + " " + oEvent.EventName); XModel oModel = (XModel)UnoRuntime.queryInterface(XModel.class,oEvent.Source);
                if (oModel!=null) {
                        System.out.println("Document URL is: " + 
oModel.getURL());
                }
        }
        public void disposing(com.sun.star.lang.EventObject e) {
            System.out.println("On Dispose");
        }
});

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to