|
List Info
Thread: prevent document closing
|
|
| prevent document closing |

|
2006-09-28 17:39:24 |
Hi,
How can I prevent a document from closing? I've figured out
how to do it
for the frame by adding a CloseListener and throwing a
CloseVetoException in queryClosing, but this does not seem
to work for
the internal document.
Adam
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| prevent document closing |

|
2006-09-29 12:00:18 |
Adam Patacchiola wrote:
> Hi,
>
> How can I prevent a document from closing? I've figured
out how to do it
> for the frame by adding a CloseListener and throwing a
> CloseVetoException in queryClosing, but this does not
seem to work for
> the internal document.
It works the same way. The document will not be closed
(=destroyed)
then. I assume that you also want to prevent the document
windows from
being closed. This is only possible by registering your
listener at the
corresponding frames.
Best regards,
Mathias
--
Mathias Bauer - OpenOffice.org Application Framework Project
Lead
Please reply to the list only, nospamforMBA gmx.de is
a spam sink.
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| prevent document closing |

|
2006-09-29 14:47:43 |
Can you tell me why this code doesn't work then:
public void someMethod() {
unoidl.com.sun.star.uno.XComponentContext
localContext =
uno.util.Bootstrap.bootstrap();
unoidl.com.sun.star.lang.XMultiServiceFactory
multiServiceFactory =
(unoidl.com.sun.star.lang.XMultiServiceFactory)
localContext.getServiceManager();
XComponentLoader componentLoader =
(XComponentLoader)multiServiceFactory.createInstance(
"com.sun.star.frame.Desktop");
//Create a new blank writer document using our
component
//enable macros
PropertyValue[] args = new PropertyValue[1];
args[0] = new PropertyValue();
args[0].Name = "MacroExecutionMode";
args[0].Value = new
Any(MacroExecMode.ALWAYS_EXECUTE_NO_WARN);
XComponent xComponent =
componentLoader.loadComponentFromURL(
"private:factory/swriter",
"_blank", 0,
args
);
//get the document frame
XFrame frame =
((unoidl.com.sun.star.text.XTextDocument)xComponent).getCurr
entController().getFrame();
//If i add the listener to the frame here, the
outer most
frame is prevented from closing, but the user can still
click the
internal document window's close button and the document
will close
which is not the behavior I want
/* XCloseBroadcaster xcb =
(XCloseBroadcaster)frame;
xcb.addCloseListener(new CloseListener());*/
//If i add the listener to the xcomponent, the
queryClosing
method is fired when either the internal document's close
button or the
frame's close button is clicked, but the document is not
prevented from
closing
XCloseBroadcaster xc =
(XCloseBroadcaster)xComponent;
xc.addCloseListener(new CloseListener());
}
public class CloseListener : XCloseListener {
public void
notifyClosing(unoidl.com.sun.star.lang.EventObject Source) {
}
public void
queryClosing(unoidl.com.sun.star.lang.EventObject Source,
bool
GetsOwnership) {
throw new CloseVetoException();
}
public void
disposing(unoidl.com.sun.star.lang.EventObject
Source) {
}
}
Mathias Bauer wrote:
> Adam Patacchiola wrote:
>
>
>> Hi,
>>
>> How can I prevent a document from closing? I've
figured out how to do it
>> for the frame by adding a CloseListener and
throwing a
>> CloseVetoException in queryClosing, but this does
not seem to work for
>> the internal document.
>>
>
> It works the same way. The document will not be closed
(=destroyed)
> then. I assume that you also want to prevent the
document windows from
> being closed. This is only possible by registering your
listener at the
> corresponding frames.
>
> Best regards,
> Mathias
>
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| prevent document closing |

|
2006-09-29 17:12:11 |
Adam Patacchiola wrote:
> //If i add the listener to the frame here,
the outer most
> frame is prevented from closing, but the user can still
click the
> internal document window's close button and the
document will close
> which is not the behavior I want
> /* XCloseBroadcaster xcb =
(XCloseBroadcaster)frame;
> xcb.addCloseListener(new
CloseListener());*/
Well, in fact the frame isn't closed, so there is no reason
to ask your
listener for permission. There is only one frame object
involved, this
object and its window are controlled by the
"outer" (big) closer. The
"inner" closer (the smaller one) does not control
a frame it removes the
component inside the frame from the frame. This feature was
introduced
for the last frame (window) of OOo because it allows users
to keep OOo
in memory without keeping their last document open.
> //If i add the listener to the xcomponent,
the queryClosing
> method is fired when either the internal document's
close button or the
> frame's close button is clicked, but the document is
not prevented from
> closing
> XCloseBroadcaster xc =
(XCloseBroadcaster)xComponent;
> xc.addCloseListener(new CloseListener());
No, it should be: usually closing the document window would
also close
the document (means: destroy it) but this shouldn't happen
if you
register your listener and veto against closing. Of course
you can't
prevent the window from being closed here - in fact you
can't do it at
all as I have to admit.
So here's what you should see in the listener you have
registered at the
document (component):
- you get a queryClosing
- if you throw a CloseVetoException you shouldn't get any
further calls
- if you don't object you should get a closing() as well as
a
disposing() notification.
Best regards,
Mathias
--
Mathias Bauer - OpenOffice.org Application Framework Project
Lead
Please reply to the list only, nospamforMBA gmx.de is
a spam sink.
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| prevent document closing |

|
2006-09-29 22:10:26 |
So how do I prevent the inner document window from being
closed?
Mathias Bauer wrote:
> Adam Patacchiola wrote:
>
>
>> //If i add the listener to the frame
here, the outer most
>> frame is prevented from closing, but the user can
still click the
>> internal document window's close button and the
document will close
>> which is not the behavior I want
>> /* XCloseBroadcaster xcb =
(XCloseBroadcaster)frame;
>> xcb.addCloseListener(new
CloseListener());*/
>>
>
> Well, in fact the frame isn't closed, so there is no
reason to ask your
> listener for permission. There is only one frame object
involved, this
> object and its window are controlled by the
"outer" (big) closer. The
> "inner" closer (the smaller one) does not
control a frame it removes the
> component inside the frame from the frame. This feature
was introduced
> for the last frame (window) of OOo because it allows
users to keep OOo
> in memory without keeping their last document open.
>
>
>> //If i add the listener to the
xcomponent, the queryClosing
>> method is fired when either the internal document's
close button or the
>> frame's close button is clicked, but the document
is not prevented from
>> closing
>> XCloseBroadcaster xc =
(XCloseBroadcaster)xComponent;
>> xc.addCloseListener(new
CloseListener());
>>
>
> No, it should be: usually closing the document window
would also close
> the document (means: destroy it) but this shouldn't
happen if you
> register your listener and veto against closing. Of
course you can't
> prevent the window from being closed here - in fact you
can't do it at
> all as I have to admit.
>
> So here's what you should see in the listener you have
registered at the
> document (component):
>
> - you get a queryClosing
> - if you throw a CloseVetoException you shouldn't get
any further calls
> - if you don't object you should get a closing() as
well as a
> disposing() notification.
>
> Best regards,
> Mathias
>
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| prevent document closing |

|
2006-09-30 17:20:18 |
Adam Patacchiola wrote:
> So how do I prevent the inner document window from
being closed?
As I wrote already:
>> Of course you can't prevent the window from being
closed here - in
>> fact you can't do it at all as I have to admit.
Sorry for the bad news.
Best regards,
Mathias
--
Mathias Bauer - OpenOffice.org Application Framework Project
Lead
Please reply to the list only, nospamforMBA gmx.de is
a spam sink.
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
[1-6]
|
|