Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / sfx2 / source / appl / appquit.cxx
bloba4edf3af18b311997622c483bc3d8af0f60ebab2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <basic/basmgr.hxx>
30 #include <basic/sbstar.hxx>
32 #include <svl/svdde.hxx>
33 #include <vcl/msgbox.hxx>
34 #include <svl/eitem.hxx>
36 #include <unotools/saveopt.hxx>
37 #include <unotools/misccfg.hxx>
39 #include "app.hrc"
40 #include <sfx2/app.hxx>
41 #include <sfx2/evntconf.hxx>
42 #include <sfx2/unoctitm.hxx>
43 #include "appdata.hxx"
44 #include <sfx2/viewsh.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include <sfx2/printer.hxx>
47 #include "arrdecl.hxx"
48 #include "sfx2/sfxresid.hxx"
49 #include <sfx2/event.hxx>
50 #include <sfx2/mnumgr.hxx>
51 #include <sfx2/templdlg.hxx>
52 #include <sfx2/msgpool.hxx>
53 #include <sfx2/docfile.hxx>
54 #include "sfxtypes.hxx"
55 #include "sfxlocal.hrc"
56 #include <sfx2/fcontnr.hxx>
57 #include "nochaos.hxx"
58 #include <sfx2/appuno.hxx>
59 #include <sfx2/doctempl.hxx>
60 #include <sfx2/viewfrm.hxx>
61 #include <sfx2/objsh.hxx>
62 #include <sfx2/docfac.hxx>
63 #include "appbaslib.hxx"
64 #include <basic/basicmanagerrepository.hxx>
65 #include <svtools/svtresid.hxx>
67 using ::basic::BasicManagerRepository;
69 //===================================================================
70 sal_Bool SfxApplication::QueryExit_Impl()
72 sal_Bool bQuit = sal_True;
74 // Does some instance, that can not be shut down, still require the app?
75 if ( !bQuit )
77 // Not really exit, only minimize
78 InfoBox aInfoBox( NULL, SfxResId(MSG_CANT_QUIT) );
79 aInfoBox.Execute();
80 OSL_TRACE( "QueryExit => sal_False (in use)" );
81 return sal_False;
84 return sal_True;
87 //-------------------------------------------------------------------------
89 void SfxApplication::Deinitialize()
91 if ( pAppData_Impl->bDowning )
92 return;
94 #ifndef DISABLE_SCRIPTING
95 StarBASIC::Stop();
97 // Save BASIC if possible
98 BasicManager* pBasMgr = BasicManagerRepository::getApplicationBasicManager( false );
99 if ( pBasMgr && pBasMgr->IsModified() )
100 SaveBasicManager();
102 SaveBasicAndDialogContainer();
103 #endif
105 pAppData_Impl->bDowning = sal_True; // due to Timer from DecAliveCount and QueryExit
107 DELETEZ( pAppData_Impl->pTemplates );
109 // By definition there shouldn't be any open view frames when we reach
110 // this method. Therefore this call makes no sense and is the source of
111 // some stack traces, which we don't understand.
112 // For more information see:
113 pAppData_Impl->bDowning = sal_False;
114 DBG_ASSERT( !SfxViewFrame::GetFirst(),
115 "existing SfxViewFrame after Execute" );
116 DBG_ASSERT( !SfxObjectShell::GetFirst(),
117 "existing SfxObjectShell after Execute" );
118 pAppData_Impl->pAppDispat->Pop( *this, SFX_SHELL_POP_UNTIL );
119 pAppData_Impl->pAppDispat->Flush();
120 pAppData_Impl->bDowning = sal_True;
121 pAppData_Impl->pAppDispat->DoDeactivate_Impl( sal_True, NULL );
123 // call derived application-exit
124 Exit();
126 // Release Controller and others
127 // then the remaining components should alse disapear ( Beamer! )
129 #ifndef DISABLE_SCRIPTING
130 BasicManagerRepository::resetApplicationBasicManager();
131 pAppData_Impl->pBasicManager->reset( NULL );
132 // this will also delete pBasMgr
133 #endif
135 DBG_ASSERT( pAppData_Impl->pViewFrame == 0, "active foreign ViewFrame" );
137 delete[] pAppData_Impl->pInterfaces, pAppData_Impl->pInterfaces = 0;
139 // free administration managers
140 DELETEZ(pAppData_Impl->pAppDispat);
141 SfxResId::DeleteResMgr();
142 SvtResId::DeleteResMgr();
143 DELETEZ(pAppData_Impl->pOfaResMgr);
145 // from here no SvObjects have to exists
146 DELETEZ(pAppData_Impl->pMatcher);
148 DELETEX(pAppData_Impl->pSlotPool);
149 DELETEX(pAppData_Impl->pFactArr);
151 DELETEX(pAppData_Impl->pTbxCtrlFac);
152 DELETEX(pAppData_Impl->pStbCtrlFac);
153 DELETEX(pAppData_Impl->pMenuCtrlFac);
154 DELETEX(pAppData_Impl->pViewFrames);
155 DELETEX(pAppData_Impl->pViewShells);
156 DELETEX(pAppData_Impl->pObjShells);
158 //TODO/CLEANTUP
159 //ReleaseArgs could be used instead!
160 pAppData_Impl->pPool = NULL;
161 NoChaos::ReleaseItemPool();
163 DELETEZ(pAppData_Impl->pBasicResMgr);
164 DELETEZ(pAppData_Impl->pSvtResMgr);
166 delete pAppData_Impl->m_pSbxErrorHdl;
167 delete pAppData_Impl->m_pSoErrorHdl;
168 delete pAppData_Impl->m_pToolsErrorHdl;
169 #ifdef DBG_UTIL
170 delete pAppData_Impl->m_pSimpleErrorHdl;
171 #endif
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */