update dev300-m58
[ooovba.git] / sfx2 / source / appl / appmain.cxx
blobd0e1e40f0d54d043d28f7c3b193d9a649bca6fce
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: appmain.cxx,v $
10 * $Revision: 1.36 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
34 //#define TF_NEWDESKTOP
36 #define _SDINTERN_HXX
38 #include <stdio.h>
39 #include <tools/urlobj.hxx>
40 #include <svtools/cstitem.hxx>
41 #include <tools/config.hxx>
42 #include <svtools/ehdl.hxx>
43 #include <svtools/startoptions.hxx>
44 #include <svtools/itempool.hxx>
45 #include <svtools/urihelper.hxx>
46 #include <svtools/helpopt.hxx>
47 #include <vos/process.hxx>
48 #include <framework/sfxhelperfunctions.hxx>
49 #include <rtl/ustring.hxx>
50 #include <com/sun/star/uno/Exception.hpp>
51 #include <com/sun/star/uno/RuntimeException.hpp>
52 #include <com/sun/star/uno/Reference.hxx>
54 #include "sfxtypes.hxx"
55 #include "appdata.hxx"
56 #include <sfx2/docfac.hxx>
57 #include <sfx2/app.hxx>
58 #include "arrdecl.hxx"
59 #include <sfx2/dispatch.hxx>
60 #include "sfxresid.hxx"
61 #include <sfx2/fcontnr.hxx>
62 #include <sfx2/viewsh.hxx>
63 #include "intro.hxx"
64 #include <sfx2/msgpool.hxx>
65 #include <sfx2/mnumgr.hxx>
66 #include <sfx2/appuno.hxx>
67 #include "app.hrc"
68 #include <sfx2/docfile.hxx>
69 #include "workwin.hxx"
71 #ifdef UNX
72 #define stricmp(a,b) strcmp(a,b)
73 #endif
76 //===================================================================
78 DBG_NAME(SfxAppMainNewMenu)
79 DBG_NAME(SfxAppMainBmkMenu)
80 DBG_NAME(SfxAppMainWizMenu)
81 DBG_NAME(SfxAppMainOLEReg)
82 DBG_NAME(SfxAppMainCHAOSReg)
84 //===================================================================
86 #define SFX_TEMPNAMEBASE_DIR "soffice.tmp"
87 #define SFX_KEY_TEMPNAMEBASE "Temp-Dir"
89 //===================================================================
91 #ifdef TF_POOLABLE
92 static SfxItemInfo __READONLY_DATA aItemInfos[] =
94 { 0, 0 }
96 #endif
98 //===================================================================
100 typedef Link* LinkPtr;
101 SV_DECL_PTRARR(SfxInitLinkList, LinkPtr, 4, 4)
103 TYPEINIT2(SfxApplication,SfxShell,SfxBroadcaster);
105 //--------------------------------------------------------------------
106 void SfxApplication::Init
110 /* [Beschreibung]
112 Diese virtuelle Methode wird vom SFx aus Application:a:Main() gerufen,
113 bevor Execute() ausgef"uhrt wird und
114 - das Intro bereits angezeigt ist,
115 - das Applikationsfenster exisitiert, aber noch hidden ist,
116 - die Bindings bereits existieren (Controller sind anmeldbar),
117 - der Ini- und Config-Manager bereits existiert,
118 - die Standard-Controller bereits exisitieren,
119 - die SFx-Shells ihre Interfaces bereits registriert haben.
121 [Querverweise]
122 <SfxApplication::Exit()>
123 <SfxApplication::OpenClients()>
126 #ifdef DDE_AVAILABLE
127 #ifdef PRODUCT
128 InitializeDde();
129 #else
130 if( !InitializeDde() )
132 ByteString aStr( "Kein DDE-Service moeglich. Fehler: " );
133 if( GetDdeService() )
134 aStr += GetDdeService()->GetError();
135 else
136 aStr += '?';
137 DBG_ASSERT( sal_False, aStr.GetBuffer() )
139 #endif
140 #endif
143 //--------------------------------------------------------------------
145 void SfxApplication::Exit()
147 /* [Beschreibung]
149 Diese virtuelle Methode wird vom SFx aus Application::Main() gerufen,
150 nachdem Execute() beendet ist und
151 - die Konfiguration (SfxConfigManager) bereits gespeichert wurde,
152 - die Fensterpostionen etc. in den SfxIniManager geschrieben wurden,
153 - das Applikationsfenster noch existiert, aber hidden ist
154 - s"amtliche Dokumente und deren Views bereits geschlossen sind.
155 - Dispatcher, Bindings etc. bereits zerst"ort sind
157 [Querverweise]
158 <SfxApplication::Init(int,char*[])>
164 //---------------------------------------------------------------------------
166 void SfxApplication::PreInit( )
170 //---------------------------------------------------------------------------
171 bool SfxApplication::InitLabelResMgr( const char* _pLabelPrefix, bool _bException )
173 bool bRet = false;
174 // Label-DLL mit diversen Resourcen fuer OEM-Ver. etc. (Intro, Titel, About)
175 DBG_ASSERT( _pLabelPrefix, "Wrong initialisation!" );
176 if ( _pLabelPrefix )
178 // versuchen, die Label-DLL zu erzeugen
179 pAppData_Impl->pLabelResMgr = CreateResManager( _pLabelPrefix );
181 // keine separate Label-DLL vorhanden?
182 if ( !pAppData_Impl->pLabelResMgr )
184 if ( _bException )
186 // maybe corrupted installation
187 throw (::com::sun::star::uno::RuntimeException(
188 ::rtl::OUString::createFromAscii("iso resource could not be loaded by SfxApplication"),
189 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >()));
192 else
193 bRet = true;
196 return bRet;
199 void SfxApplication::Main( )
203 //-------------------------------------------------------------------------
205 SfxFilterMatcher& SfxApplication::GetFilterMatcher()
207 if( !pAppData_Impl->pMatcher )
209 pAppData_Impl->pMatcher = new SfxFilterMatcher();
210 URIHelper::SetMaybeFileHdl( STATIC_LINK(
211 pAppData_Impl->pMatcher, SfxFilterMatcher, MaybeFileHdl_Impl ) );
213 return *pAppData_Impl->pMatcher;