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