1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: app.hxx,v $
10 * $Revision: 1.37.14.1 $
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 #ifndef _DESKTOP_APP_HXX_
32 #define _DESKTOP_APP_HXX_
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <vcl/svapp.hxx>
38 #ifndef _VCL_TIMER_HXX_
39 #include <vcl/timer.hxx>
41 #include <tools/resmgr.hxx>
42 #include <unotools/bootstrap.hxx>
43 #include <com/sun/star/lang/XInitialization.hpp>
44 #include <com/sun/star/task/XStatusIndicator.hpp>
45 #include <com/sun/star/uno/Reference.h>
46 #include <osl/mutex.hxx>
48 using namespace com::sun::star::task
;
49 using namespace com::sun::star::uno
;
50 using namespace com::sun::star::lang
;
53 #define DESKTOP_SAVETASKS_MOD 0x1
54 #define DESKTOP_SAVETASKS_UNMOD 0x2
55 #define DESKTOP_SAVETASKS_ALL 0x3
60 /*--------------------------------------------------------------------
61 Description: Application-class
62 --------------------------------------------------------------------*/
63 class CommandLineArgs
;
65 class AcceptorMap
: public std::map
< OUString
, Reference
<XInitialization
> > {};
67 class Desktop
: public Application
69 friend class UserInstall
;
75 BE_UNO_SERVICEMANAGER
,
76 BE_UNO_SERVICE_CONFIG_MISSING
,
78 BE_USERINSTALL_FAILED
,
80 BE_USERINSTALL_NOTENOUGHDISKSPACE
,
81 BE_USERINSTALL_NOWRITEACCESS
93 virtual void InitFinished();
94 virtual void DeInit();
95 virtual BOOL
QueryExit();
96 virtual USHORT
Exception(USHORT nError
);
97 virtual void SystemSettingsChanging( AllSettings
& rSettings
, Window
* pFrame
);
98 virtual void AppEvent( const ApplicationEvent
& rAppEvent
);
100 DECL_LINK( OpenClients_Impl
, void* );
102 static void OpenClients();
103 static void OpenDefault();
105 DECL_LINK( EnableAcceptors_Impl
, void*);
107 static void HandleAppEvent( const ApplicationEvent
& rAppEvent
);
108 static ResMgr
* GetDesktopResManager();
109 static CommandLineArgs
* GetCommandLineArgs();
111 void HandleBootstrapErrors( BootstrapError
);
112 void SetBootstrapError( BootstrapError nError
)
114 if ( m_aBootstrapError
== BE_OK
)
115 m_aBootstrapError
= nError
;
117 BootstrapError
GetBootstrapError() const
119 return m_aBootstrapError
;
122 void SetBootstrapStatus( BootstrapStatus nStatus
)
124 m_aBootstrapStatus
= nStatus
;
126 BootstrapStatus
GetBootstrapStatus() const
128 return m_aBootstrapStatus
;
131 static sal_Bool
CheckOEM();
132 static sal_Bool
isCrashReporterEnabled();
134 // first-start (ever) & license relate methods
135 static rtl::OUString
GetLicensePath();
136 static sal_Bool
LicenseNeedsAcceptance();
137 static sal_Bool
IsFirstStartWizardNeeded();
138 static sal_Bool
CheckExtensionDependencies();
142 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> CreateApplicationServiceManager();
144 void RegisterServices( ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xSMgr
);
145 void DeregisterServices();
147 void DestroyApplicationServiceManager( ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xSMgr
);
149 void CreateTemporaryDirectory();
150 void RemoveTemporaryDirectory();
152 sal_Bool
InitializeInstallation( const rtl::OUString
& rAppFilename
);
153 sal_Bool
InitializeConfiguration();
154 sal_Bool
InitializeQuickstartMode( com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& rSMgr
);
156 void HandleBootstrapPathErrors( ::utl::Bootstrap::Status
, const ::rtl::OUString
& aMsg
);
157 void StartSetup( const ::rtl::OUString
& aParameters
);
159 // Get a resource message string securely e.g. if resource cannot be retrieved return aFaultBackMsg
160 ::rtl::OUString
GetMsgString( USHORT nId
, const ::rtl::OUString
& aFaultBackMsg
);
162 // Create a error message depending on bootstrap failure code and an optional file url
163 ::rtl::OUString
CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode
,
164 const ::rtl::OUString
& aFileURL
);
166 static void PreloadModuleData( CommandLineArgs
* );
167 static void PreloadConfigurationData();
169 Reference
<XStatusIndicator
> m_rSplashScreen
;
170 void OpenSplashScreen();
171 void SetSplashScreenProgress(sal_Int32
);
172 void CloseSplashScreen();
174 void EnableOleAutomation();
175 DECL_LINK( ImplInitFilterHdl
, ConvertData
* );
176 DECL_LINK( AsyncInitFirstRun
, void* );
177 /** checks if the office is run the first time
178 <p>If so, <method>DoFirstRunInitializations</method> is called (asynchronously and delayed) and the
179 respective flag in the configuration is reset.</p>
181 void CheckFirstRun( );
183 /// does initializations which are necessary for the first run of the office
184 void DoFirstRunInitializations();
186 static sal_Bool
SaveTasks();
187 static sal_Bool _bTasksSaved
;
189 static void retrieveCrashReporterState();
191 // on-demand acceptors
192 static void createAcceptor(const OUString
& aDescription
);
193 static void enableAcceptors();
194 static void destroyAcceptor(const OUString
& aDescription
);
196 sal_Bool m_bMinimized
;
197 sal_Bool m_bInvisible
;
198 bool m_bServicesRegistered
;
200 BootstrapError m_aBootstrapError
;
201 BootstrapStatus m_aBootstrapStatus
;
203 Lockfile
*m_pLockfile
;
204 Timer m_firstRunTimer
;
206 static ResMgr
* pResMgr
;
207 static sal_Bool bSuppressOpenDefault
;
212 #endif // _DESKTOP_APP_HXX_