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

Joined: 26 Oct 2003 Posts: 6
|
Posted: Fri Dec 17, 2004 9:37 am Post subject: Close document but not main window/application? |
|
|
How can I close a document (Writer/Otherwise) such that if it is the last open document the whole application does *not* close.
Each of the following always closes the application if it is the last document
document.close( false )
document.close( true )
document.dispose()
Where Document can be ThisComponent or a Frame object.
Perhaps all I need is the proper name to send to the dispatched for the "File|Close" command, since this does what I want. ".uni:Close" doesn't exist... _________________
Shiva In Exile Ambient World Music
--
edA-qa mort-ora-y
dis-Emi-A
Trostlos Records |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Sun Dec 19, 2004 9:00 pm Post subject: |
|
|
No idea (I don't have time to look for the dispatch sorry).
But as a workaround how about creating a dummy frame (you don't need to load a document into it) that is invisible, now if you close all documents OpenOffice doesn't terminate cause the dummy frame still exists.
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
SirK General User

Joined: 13 Oct 2004 Posts: 10 Location: Omaha, NE
|
Posted: Tue Dec 21, 2004 8:08 am Post subject: |
|
|
I use, (This is Java code by the way):
| Code: | static XComponent xDrawDoc = null;
xDrawDoc = Helper.createDocument(xServiceFactory,"private:factory/simpress", "_blank", 0, pPropValues);
xDrawDoc.dispose(); |
And that doesn't close the open office "Server" if you will. I start Open Office using the command line arguments of: | Code: | | soffice -invisible "-accept=socket,host=localhost,port=8100;urp;" |
-K |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Tue Dec 21, 2004 8:19 am Post subject: |
|
|
SirK, your example uses the very strongly discouraged method .dispose() on a document.
It has been said before that in any case .dispose() should be avoided.
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
SirK General User

Joined: 13 Oct 2004 Posts: 10 Location: Omaha, NE
|
Posted: Tue Dec 21, 2004 8:42 am Post subject: |
|
|
| Is there a post somewhere that explains exactly why that is discouraged? |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3532 Location: Hamburg, Germany
|
Posted: Tue Dec 21, 2004 11:32 am Post subject: Re: Close document but not main window/application? |
|
|
| mortoray wrote: | | How can I close a document (Writer/Otherwise) such that if it is the last open document the whole application does *not* close. |
I do it in Java this way (xComponent is my writer document):
| Code: | // close document
XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, xComponent);
try
{
xCloseable.close(true);
}
catch (CloseVetoException e)
{
System.out.println("Error closing document: "+e.getMessage(),e);
}
|
For me it works.
With kind regards
hol.sten |
|
| Back to top |
|
 |
|