Branch libreoffice-5-0-4
[LibreOffice.git] / sfx2 / source / appl / appquit.cxx
blob641392b008fc4a94172c011b79ca12ee86588dc6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <config_features.h>
22 #include <basic/basmgr.hxx>
23 #include <basic/sbstar.hxx>
25 #include <svl/svdde.hxx>
26 #include <vcl/layout.hxx>
27 #include <svl/eitem.hxx>
29 #include <unotools/saveopt.hxx>
30 #include <unotools/misccfg.hxx>
32 #include "app.hrc"
33 #include <sfx2/app.hxx>
34 #include <sfx2/evntconf.hxx>
35 #include <sfx2/unoctitm.hxx>
36 #include "appdata.hxx"
37 #include <sfx2/viewsh.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include <sfx2/printer.hxx>
40 #include "arrdecl.hxx"
41 #include <sfx2/sfxresid.hxx>
42 #include <sfx2/event.hxx>
43 #include <sfx2/mnumgr.hxx>
44 #include <sfx2/templdlg.hxx>
45 #include <sfx2/msgpool.hxx>
46 #include <sfx2/docfile.hxx>
47 #include "sfxtypes.hxx"
48 #include "sfxlocal.hrc"
49 #include <sfx2/fcontnr.hxx>
50 #include "nochaos.hxx"
51 #include <sfx2/doctempl.hxx>
52 #include <sfx2/viewfrm.hxx>
53 #include <sfx2/objsh.hxx>
54 #include <sfx2/docfac.hxx>
55 #include "appbaslib.hxx"
56 #include "childwinimpl.hxx"
57 #include <ctrlfactoryimpl.hxx>
58 #include <shellimpl.hxx>
59 #include <basic/basicmanagerrepository.hxx>
60 #include <svtools/svtresid.hxx>
62 using ::basic::BasicManagerRepository;
64 void SfxApplication::Deinitialize()
66 if ( pAppData_Impl->bDowning )
67 return;
69 #if HAVE_FEATURE_SCRIPTING
70 StarBASIC::Stop();
72 SaveBasicAndDialogContainer();
73 #endif
75 pAppData_Impl->bDowning = true; // due to Timer from DecAliveCount and QueryExit
77 DELETEZ( pAppData_Impl->pTemplates );
79 // By definition there shouldn't be any open view frames when we reach
80 // this method. Therefore this call makes no sense and is the source of
81 // some stack traces, which we don't understand.
82 // For more information see:
83 pAppData_Impl->bDowning = false;
84 DBG_ASSERT( !SfxViewFrame::GetFirst(),
85 "existing SfxViewFrame after Execute" );
86 DBG_ASSERT( !SfxObjectShell::GetFirst(),
87 "existing SfxObjectShell after Execute" );
88 pAppData_Impl->pAppDispat->Pop( *this, SfxDispatcherPopFlags::POP_UNTIL );
89 pAppData_Impl->pAppDispat->Flush();
90 pAppData_Impl->bDowning = true;
91 pAppData_Impl->pAppDispat->DoDeactivate_Impl( true, NULL );
93 // Release Controller and others
94 // then the remaining components should also disappear ( Beamer! )
96 #if HAVE_FEATURE_SCRIPTING
97 BasicManagerRepository::resetApplicationBasicManager();
98 pAppData_Impl->pBasicManager->reset( NULL );
99 // this will also delete pBasMgr
100 #endif
102 DBG_ASSERT( pAppData_Impl->pViewFrame == 0, "active foreign ViewFrame" );
104 delete[] pAppData_Impl->pInterfaces, pAppData_Impl->pInterfaces = 0;
106 // free administration managers
107 DELETEZ(pAppData_Impl->pAppDispat);
108 SfxResId::DeleteResMgr();
109 SvtResId::DeleteResMgr();
111 // from here no SvObjects have to exists
112 DELETEZ(pAppData_Impl->pMatcher);
114 DELETEX(SfxSlotPool, pAppData_Impl->pSlotPool);
115 DELETEX(SfxChildWinFactArr_Impl, pAppData_Impl->pFactArr);
117 DELETEX(SfxTbxCtrlFactArr_Impl, pAppData_Impl->pTbxCtrlFac);
118 DELETEX(SfxStbCtrlFactArr_Impl, pAppData_Impl->pStbCtrlFac);
119 DELETEX(SfxMenuCtrlFactArr_Impl, pAppData_Impl->pMenuCtrlFac);
120 DELETEX(SfxViewFrameArr_Impl, pAppData_Impl->pViewFrames);
121 DELETEX(SfxViewShellArr_Impl, pAppData_Impl->pViewShells);
122 DELETEX(SfxObjectShellArr_Impl, pAppData_Impl->pObjShells);
124 //TODO/CLEANTUP
125 //ReleaseArgs could be used instead!
126 pAppData_Impl->pPool = NULL;
127 NoChaos::ReleaseItemPool();
129 #if HAVE_FEATURE_SCRIPTING
130 DELETEZ(pAppData_Impl->pBasicResMgr);
131 #endif
132 DELETEZ(pAppData_Impl->pSvtResMgr);
134 #if HAVE_FEATURE_SCRIPTING
135 delete pAppData_Impl->m_pSbxErrorHdl;
136 #endif
137 delete pAppData_Impl->m_pSoErrorHdl;
138 delete pAppData_Impl->m_pToolsErrorHdl;
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */