OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Close document but not main window/application?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
mortoray
General User
General User


Joined: 26 Oct 2003
Posts: 6

PostPosted: Fri Dec 17, 2004 9:37 am    Post subject: Close document but not main window/application? Reply with quote

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
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Sun Dec 19, 2004 9:00 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
SirK
General User
General User


Joined: 13 Oct 2004
Posts: 10
Location: Omaha, NE

PostPosted: Tue Dec 21, 2004 8:08 am    Post subject: Reply with quote

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
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Tue Dec 21, 2004 8:19 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
SirK
General User
General User


Joined: 13 Oct 2004
Posts: 10
Location: Omaha, NE

PostPosted: Tue Dec 21, 2004 8:42 am    Post subject: Reply with quote

Is there a post somewhere that explains exactly why that is discouraged?
Back to top
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Tue Dec 21, 2004 11:32 am    Post subject: Re: Close document but not main window/application? Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group