xref: /trunk/main/sfx2/source/appl/appquit.cxx (revision 86e1cf34)
1d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5d119d52dSAndrew Rist  * distributed with this work for additional information
6d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10d119d52dSAndrew Rist  *
11d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12d119d52dSAndrew Rist  *
13d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17d119d52dSAndrew Rist  * specific language governing permissions and limitations
18d119d52dSAndrew Rist  * under the License.
19d119d52dSAndrew Rist  *
20d119d52dSAndrew Rist  *************************************************************/
21d119d52dSAndrew Rist 
22d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir #include <basic/basmgr.hxx>
27cdf0e10cSrcweir #include <basic/sbstar.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <svl/svdde.hxx>
30cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
31cdf0e10cSrcweir #include <vcl/msgbox.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #include <svl/eitem.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <unotools/saveopt.hxx>
36cdf0e10cSrcweir #include <unotools/misccfg.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #ifndef GCC
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "app.hrc"
42cdf0e10cSrcweir #include <sfx2/app.hxx>
43cdf0e10cSrcweir #include <sfx2/evntconf.hxx>
44cdf0e10cSrcweir #include <sfx2/unoctitm.hxx>
45cdf0e10cSrcweir #include "appdata.hxx"
46cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
47cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
48cdf0e10cSrcweir #include <sfx2/printer.hxx>
49cdf0e10cSrcweir #include "arrdecl.hxx"
50cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
51cdf0e10cSrcweir #include <sfx2/event.hxx>
52cdf0e10cSrcweir #include <sfx2/mnumgr.hxx>
53cdf0e10cSrcweir #include <sfx2/templdlg.hxx>
54cdf0e10cSrcweir #include <sfx2/msgpool.hxx>
55cdf0e10cSrcweir #include <sfx2/docfile.hxx>
56cdf0e10cSrcweir #include "sfxtypes.hxx"
57cdf0e10cSrcweir #include "sfxlocal.hrc"
58cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
59cdf0e10cSrcweir #include "nochaos.hxx"
60cdf0e10cSrcweir #include <sfx2/appuno.hxx>
61cdf0e10cSrcweir #include <sfx2/doctempl.hxx>
62cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
63cdf0e10cSrcweir #include <sfx2/objsh.hxx>
64cdf0e10cSrcweir #include <sfx2/docfac.hxx>
65cdf0e10cSrcweir #include "appbaslib.hxx"
66cdf0e10cSrcweir #include <basic/basicmanagerrepository.hxx>
67cdf0e10cSrcweir 
68cdf0e10cSrcweir using ::basic::BasicManagerRepository;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir //===================================================================
QueryExit_Impl()71cdf0e10cSrcweir sal_Bool SfxApplication::QueryExit_Impl()
72cdf0e10cSrcweir {
73cdf0e10cSrcweir 	sal_Bool bQuit = sal_True;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	// will trotzdem noch jemand, den man nicht abschiessen kann, die App haben?
76cdf0e10cSrcweir     if ( !bQuit )
77cdf0e10cSrcweir 	{
78cdf0e10cSrcweir 		// nicht wirklich beenden, nur minimieren
79cdf0e10cSrcweir         InfoBox aInfoBox( NULL, SfxResId(MSG_CANT_QUIT) );
80cdf0e10cSrcweir 		aInfoBox.Execute();
81cdf0e10cSrcweir 		DBG_TRACE( "QueryExit => FALSE (in use)" );
82cdf0e10cSrcweir 		return sal_False;
83cdf0e10cSrcweir 	}
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	return sal_True;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir //-------------------------------------------------------------------------
89cdf0e10cSrcweir 
Deinitialize()90cdf0e10cSrcweir void SfxApplication::Deinitialize()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir     if ( pAppData_Impl->bDowning )
93cdf0e10cSrcweir         return;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	StarBASIC::Stop();
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	// ggf. BASIC speichern
98cdf0e10cSrcweir     BasicManager* pBasMgr = BasicManagerRepository::getApplicationBasicManager( false );
99cdf0e10cSrcweir     if ( pBasMgr && pBasMgr->IsModified() )
100cdf0e10cSrcweir         SaveBasicManager();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     SaveBasicAndDialogContainer();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     pAppData_Impl->bDowning = sal_True; // wegen Timer aus DecAliveCount und QueryExit
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     DELETEZ( pAppData_Impl->pTemplates );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     // By definition there shouldn't be any open view frames when we reach
109cdf0e10cSrcweir     // this method. Therefore this call makes no sense and is the source of
110cdf0e10cSrcweir     // some stack traces, which we don't understand.
111cdf0e10cSrcweir     // For more information see:
112cdf0e10cSrcweir     // #123501#
113cdf0e10cSrcweir 	//SetViewFrame(0);
114cdf0e10cSrcweir     pAppData_Impl->bDowning = sal_False;
115cdf0e10cSrcweir 	DBG_ASSERT( !SfxViewFrame::GetFirst(),
116cdf0e10cSrcweir 				"existing SfxViewFrame after Execute" );
117cdf0e10cSrcweir 	DBG_ASSERT( !SfxObjectShell::GetFirst(),
118cdf0e10cSrcweir 				"existing SfxObjectShell after Execute" );
119cdf0e10cSrcweir     pAppData_Impl->pAppDispat->Pop( *this, SFX_SHELL_POP_UNTIL );
120cdf0e10cSrcweir     pAppData_Impl->pAppDispat->Flush();
121cdf0e10cSrcweir     pAppData_Impl->bDowning = sal_True;
122cdf0e10cSrcweir     pAppData_Impl->pAppDispat->DoDeactivate_Impl( sal_True, NULL );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	// call derived application-exit
125cdf0e10cSrcweir 	Exit();
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     // Controller u."a. freigeben
128cdf0e10cSrcweir     // dabei sollten auch restliche Komponenten ( Beamer! ) verschwinden
129cdf0e10cSrcweir     BasicManagerRepository::resetApplicationBasicManager();
130cdf0e10cSrcweir     pAppData_Impl->pBasicManager->reset( NULL );
131cdf0e10cSrcweir         // this will also delete pBasMgr
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     DBG_ASSERT( pAppData_Impl->pViewFrame == 0, "active foreign ViewFrame" );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     delete[] pAppData_Impl->pInterfaces, pAppData_Impl->pInterfaces = 0;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	// free administration managers
138cdf0e10cSrcweir     DELETEZ(pAppData_Impl->pAppDispat);
139cdf0e10cSrcweir 	SfxResId::DeleteResMgr();
140cdf0e10cSrcweir     DELETEZ(pAppData_Impl->pOfaResMgr);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	// ab hier d"urfen keine SvObjects mehr existieren
143cdf0e10cSrcweir     DELETEZ(pAppData_Impl->pMatcher);
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     DELETEX(pAppData_Impl->pSlotPool);
146cdf0e10cSrcweir 	DELETEX(pAppData_Impl->pFactArr);
147cdf0e10cSrcweir 	DELETEX(pAppData_Impl->pInitLinkList);
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     DELETEX(pAppData_Impl->pTbxCtrlFac);
150cdf0e10cSrcweir     DELETEX(pAppData_Impl->pStbCtrlFac);
151cdf0e10cSrcweir     DELETEX(pAppData_Impl->pMenuCtrlFac);
152cdf0e10cSrcweir     DELETEX(pAppData_Impl->pViewFrames);
153cdf0e10cSrcweir     DELETEX(pAppData_Impl->pViewShells);
154cdf0e10cSrcweir     DELETEX(pAppData_Impl->pObjShells);
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     //TODO/CLEANTUP
157cdf0e10cSrcweir     //ReleaseArgs could be used instead!
158cdf0e10cSrcweir /* This leak is intended !
159*86e1cf34SPedro Giffuni    Otherwise the TestTool can't use .uno:QuitApp ...
160cdf0e10cSrcweir    because every destructed ItemSet work's on an already
161cdf0e10cSrcweir    released pool pointer .-)
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	NoChaos::ReleaseItemPool();
164cdf0e10cSrcweir */
165cdf0e10cSrcweir 	pAppData_Impl->pPool = NULL;
166cdf0e10cSrcweir     DELETEZ(pAppData_Impl->pBasicResMgr);
167cdf0e10cSrcweir     DELETEZ(pAppData_Impl->pSvtResMgr);
168cdf0e10cSrcweir }
169