Re: [api-dev] CloseVetoException has no effect

2006-07-28 Thread Christoph Lutz

Hi Mathias,

thanks for your explanation which made the things much clearer for me!

Best regards,
Christoph

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



Re: [api-dev] CloseVetoException has no effect

2006-07-26 Thread Mathias Bauer
Christoph Lutz wrote:

 Hi,
 
 I would like to veto the close-action (clicking on the x in a writer
 document) in such a form, that the document doesn't get closed until
 my program decides when it's time to close the document. This should
 be possible by throwing a CloseVetoException in the queryClosing(...)
 handler when getsOwnership==true, but it does not to work with my
 example code (below). The CloseVetoException I throw does not seem to
 prevent OOo from actually closing the document.
 
 Any Ideas what could be wrong with my example?

I think there is nothing wrong. You have registered as a CloseListener
at the document, the model. I assume that this has worked and the
model is still there, so it's not surprising that no notifyClosing was
called.

But that doesn't mean that you have prevented the view(s) on this model
from becoming closed, so the window can be closed as usual. If you want
to prevent the views from being closed you must register as a close
listener at the corresponding frames.

Best regards,
Mathias

-- 
Mathias Bauer - OpenOffice.org Application Framework Project Lead
Please reply to the list only, [EMAIL PROTECTED] is a spam sink.

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



[api-dev] CloseVetoException has no effect

2006-07-07 Thread Christoph Lutz

Hi,

I would like to veto the close-action (clicking on the x in a writer
document) in such a form, that the document doesn't get closed until
my program decides when it's time to close the document. This should
be possible by throwing a CloseVetoException in the queryClosing(...)
handler when getsOwnership==true, but it does not to work with my
example code (below). The CloseVetoException I throw does not seem to
prevent OOo from actually closing the document.

Any Ideas what could be wrong with my example?

How to reproduce:

1) Create a new writer-document

2) running my example code returns a System.out-message:
waiting for close - events

3) pressing the x-Button in the writer-document to try(!) to close
it returns a System.out-message:
queryClosing(). getsOwnership=true

4) the document gets closed by OOo, though I throw a
CloseVetoException in the case of getsOwnership==true!!!

5) Why dont I get informed via notifyClosing about the actual closing?

here the example-code:

import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.comp.helper.BootstrapException;
import com.sun.star.frame.XDesktop;
import com.sun.star.lang.EventObject;
import com.sun.star.lang.XComponent;
import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.util.CloseVetoException;
import com.sun.star.util.XCloseListener;
import com.sun.star.util.XCloseable;

public class CloseListenerTest implements XCloseListener {

   public static void main(String[] args) throws BootstrapException,
   Exception, InterruptedException {
   XComponentContext ctx = Bootstrap.bootstrap();
   Object desktop = ctx.getServiceManager().createInstanceWithContext(
   com.sun.star.frame.Desktop, ctx);
   XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
   XDesktop.class, desktop);
   XComponent compo = xDesktop.getCurrentComponent();
   XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(
   XCloseable.class, compo);
   CloseListenerTest ct = new CloseListenerTest();
   xCloseable.addCloseListener(ct);

   System.out.println(waiting for close - events);
   }

   public void queryClosing(EventObject event, boolean getsOwnership)
   throws CloseVetoException {
   System.out.println(queryClosing(). getsOwnership= + getsOwnership);
   if (getsOwnership) {
   throw new CloseVetoException();
   }
   }

   public void notifyClosing(EventObject event) {
   System.out.println(notifyClosing);
   XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(
   XCloseable.class, event.Source);
   if (xCloseable != null)
   xCloseable.removeCloseListener(this);
   }

   public void disposing(EventObject arg0) {
   System.out.println(disposing);
   }
}

best regards,
Christoph

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