| View previous topic :: View next topic |
| Author |
Message |
satabau General User

Joined: 12 Mar 2012 Posts: 34
|
Posted: Thu May 24, 2012 8:59 am Post subject: [Solved] How to prevent file closing |
|
|
Hi, while my program is running I need , if the user wants to close the file and clicks on the "X", to show something and tell him that he can't close the file.
I've made this:
| Code: |
public class MyDocumentEventListener implements XDocumentEventListener {
public void documentEventOccured(DocumentEvent ev){}
public void disposing(com.sun.star.lang.EventObject ev){}
}
|
and
| Code: | | xSpreadsheetComponent.addEventListener(new MyDocumentEventListener()); |
but I have no idea how to PREVENT the closing. With method "disposing" I only have the information that the user is closing.
I tried another way but I have the same problem:
| Code: | public class EventListener implements com.sun.star.document.XEventListener{
public void notifyEvent(com.sun.star.document.EventObject arg0){System.out.println("NOTIFYEVENT");}
public void disposing(com.sun.star.lang.EventObject arg0){System.out.println("disposing");}
} |
and
| Code: |
XMultiServiceFactory xFactory=null;
try{ xFactory = getMultiServiceFactory(xRemoteContext);
XEventBroadcaster xEventBroadcaster =(XEventBroadcaster) UnoRuntime.queryInterface(XEventBroadcaster.class, xSpreadsheetComponent);
XEventListener xEventListener = new EventListener();
xEventBroadcaster.addEventListener(xEventListener);
}catch(Exception e){e.printStackTrace();} |
Can you help me?
Thank you |
|
| Back to top |
|
 |
satabau General User

Joined: 12 Mar 2012 Posts: 34
|
Posted: Fri May 25, 2012 4:42 am Post subject: |
|
|
I write my solution. Hope this can help someone
| Code: |
XDesktop xDesktop = (XDesktop)UnoRuntime.queryInterface(XDesktop.class, desktop);
XTerminateListener terminateListener = new MyTerminateListener ();
xDesktop.addTerminateListener (terminateListener); |
and
| Code: |
public class MyTerminateListener implements XTerminateListener{
public void notifyTermination(EventObject arg){}
public void queryTermination(EventObject arg) throws TerminationVetoException
{
throw new TerminationVetoException();
}
public void disposing(EventObject arg){}
} |
|
|
| Back to top |
|
 |
|