xref: /aoo41x/main/sfx2/source/appl/appquit.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sfx2.hxx"
30 #include <basic/basmgr.hxx>
31 #include <basic/sbstar.hxx>
32 
33 #include <svl/svdde.hxx>
34 #ifndef _MSGBOX_HXX //autogen
35 #include <vcl/msgbox.hxx>
36 #endif
37 #include <svl/eitem.hxx>
38 
39 #include <unotools/saveopt.hxx>
40 #include <unotools/misccfg.hxx>
41 
42 #ifndef GCC
43 #endif
44 
45 #include "app.hrc"
46 #include <sfx2/app.hxx>
47 #include <sfx2/evntconf.hxx>
48 #include <sfx2/unoctitm.hxx>
49 #include "appdata.hxx"
50 #include <sfx2/viewsh.hxx>
51 #include <sfx2/dispatch.hxx>
52 #include <sfx2/printer.hxx>
53 #include "arrdecl.hxx"
54 #include "sfx2/sfxresid.hxx"
55 #include <sfx2/event.hxx>
56 #include <sfx2/mnumgr.hxx>
57 #include <sfx2/templdlg.hxx>
58 #include <sfx2/msgpool.hxx>
59 #include <sfx2/docfile.hxx>
60 #include "sfxtypes.hxx"
61 #include "sfxlocal.hrc"
62 #include <sfx2/fcontnr.hxx>
63 #include "nochaos.hxx"
64 #include <sfx2/appuno.hxx>
65 #include <sfx2/doctempl.hxx>
66 #include <sfx2/viewfrm.hxx>
67 #include <sfx2/objsh.hxx>
68 #include <sfx2/docfac.hxx>
69 #include "appbaslib.hxx"
70 #include <basic/basicmanagerrepository.hxx>
71 
72 using ::basic::BasicManagerRepository;
73 
74 //===================================================================
75 sal_Bool SfxApplication::QueryExit_Impl()
76 {
77 	sal_Bool bQuit = sal_True;
78 
79 	// will trotzdem noch jemand, den man nicht abschiessen kann, die App haben?
80     if ( !bQuit )
81 	{
82 		// nicht wirklich beenden, nur minimieren
83         InfoBox aInfoBox( NULL, SfxResId(MSG_CANT_QUIT) );
84 		aInfoBox.Execute();
85 		DBG_TRACE( "QueryExit => FALSE (in use)" );
86 		return sal_False;
87 	}
88 
89 	return sal_True;
90 }
91 
92 //-------------------------------------------------------------------------
93 
94 void SfxApplication::Deinitialize()
95 {
96     if ( pAppData_Impl->bDowning )
97         return;
98 
99 	StarBASIC::Stop();
100 
101 	// ggf. BASIC speichern
102     BasicManager* pBasMgr = BasicManagerRepository::getApplicationBasicManager( false );
103     if ( pBasMgr && pBasMgr->IsModified() )
104         SaveBasicManager();
105 
106     SaveBasicAndDialogContainer();
107 
108     pAppData_Impl->bDowning = sal_True; // wegen Timer aus DecAliveCount und QueryExit
109 
110     DELETEZ( pAppData_Impl->pTemplates );
111 
112     // By definition there shouldn't be any open view frames when we reach
113     // this method. Therefore this call makes no sense and is the source of
114     // some stack traces, which we don't understand.
115     // For more information see:
116     // #123501#
117 	//SetViewFrame(0);
118     pAppData_Impl->bDowning = sal_False;
119 	DBG_ASSERT( !SfxViewFrame::GetFirst(),
120 				"existing SfxViewFrame after Execute" );
121 	DBG_ASSERT( !SfxObjectShell::GetFirst(),
122 				"existing SfxObjectShell after Execute" );
123     pAppData_Impl->pAppDispat->Pop( *this, SFX_SHELL_POP_UNTIL );
124     pAppData_Impl->pAppDispat->Flush();
125     pAppData_Impl->bDowning = sal_True;
126     pAppData_Impl->pAppDispat->DoDeactivate_Impl( sal_True, NULL );
127 
128 	// call derived application-exit
129 	Exit();
130 
131     // Controller u."a. freigeben
132     // dabei sollten auch restliche Komponenten ( Beamer! ) verschwinden
133     BasicManagerRepository::resetApplicationBasicManager();
134     pAppData_Impl->pBasicManager->reset( NULL );
135         // this will also delete pBasMgr
136 
137     DBG_ASSERT( pAppData_Impl->pViewFrame == 0, "active foreign ViewFrame" );
138 
139     delete[] pAppData_Impl->pInterfaces, pAppData_Impl->pInterfaces = 0;
140 
141 	// free administration managers
142     DELETEZ(pAppData_Impl->pAppDispat);
143 	SfxResId::DeleteResMgr();
144     DELETEZ(pAppData_Impl->pOfaResMgr);
145 
146 	// ab hier d"urfen keine SvObjects mehr existieren
147     DELETEZ(pAppData_Impl->pMatcher);
148 
149     DELETEX(pAppData_Impl->pSlotPool);
150 	DELETEX(pAppData_Impl->pFactArr);
151 	DELETEX(pAppData_Impl->pInitLinkList);
152 
153     DELETEX(pAppData_Impl->pTbxCtrlFac);
154     DELETEX(pAppData_Impl->pStbCtrlFac);
155     DELETEX(pAppData_Impl->pMenuCtrlFac);
156     DELETEX(pAppData_Impl->pViewFrames);
157     DELETEX(pAppData_Impl->pViewShells);
158     DELETEX(pAppData_Impl->pObjShells);
159 
160     //TODO/CLEANTUP
161     //ReleaseArgs could be used instead!
162 /* This leak is intended !
163    Otherwise the TestTool cant use .uno:QuitApp ...
164    because every destructed ItemSet work's on an already
165    released pool pointer .-)
166 
167 	NoChaos::ReleaseItemPool();
168 */
169 	pAppData_Impl->pPool = NULL;
170     DELETEZ(pAppData_Impl->pBasicResMgr);
171     DELETEZ(pAppData_Impl->pSvtResMgr);
172 }
173