2004-06-25 11:39:32 +00:00
/*************************************************************************
2000-09-18 15:18:56 +00:00
*
2008-04-11 02:34:54 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
2000-09-18 15:18:56 +00:00
*
2010-02-12 15:01:35 +01:00
* Copyright 2000 , 2010 Oracle and / or its affiliates .
2000-09-18 15:18:56 +00:00
*
2008-04-11 02:34:54 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2000-09-18 15:18:56 +00:00
*
2008-04-11 02:34:54 +00:00
* This file is part of OpenOffice . org .
2000-09-18 15:18:56 +00:00
*
2008-04-11 02:34:54 +00:00
* OpenOffice . org is free software : you can redistribute it and / or modify
* it under the terms of the GNU Lesser General Public License version 3
* only , as published by the Free Software Foundation .
2000-09-18 15:18:56 +00:00
*
2008-04-11 02:34:54 +00:00
* OpenOffice . org is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Lesser General Public License version 3 for more details
* ( a copy is included in the LICENSE file that accompanied this code ) .
2000-09-18 15:18:56 +00:00
*
2008-04-11 02:34:54 +00:00
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice . org . If not , see
* < http : //www.openoffice.org/license.html>
* for a copy of the LGPLv3 License .
2000-09-18 15:18:56 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-09-17 08:34:18 +00:00
// MARKER(update_precomp.py): autogen include statement, do not remove
# include "precompiled_desktop.hxx"
2007-11-26 13:11:13 +00:00
# include <memory>
2001-09-25 10:25:35 +00:00
# include <unistd.h>
2000-09-18 15:18:56 +00:00
# include "app.hxx"
2001-07-16 11:55:47 +00:00
# include "desktop.hrc"
# include "appinit.hxx"
2003-03-25 12:52:54 +00:00
# include "officeipcthread.hxx"
2001-07-16 11:55:47 +00:00
# include "cmdlineargs.hxx"
# include "desktopresid.hxx"
2001-11-05 06:18:26 +00:00
# include "dispatchwatcher.hxx"
2002-10-21 08:05:48 +00:00
# include "configinit.hxx"
2002-09-30 15:01:32 +00:00
# include "lockfile.hxx"
2002-11-01 13:49:58 +00:00
# include "checkinstall.hxx"
2003-03-25 12:52:54 +00:00
# include "cmdlinehelp.hxx"
2003-11-07 13:51:04 +00:00
# include "userinstall.hxx"
2004-05-10 12:00:30 +00:00
# include "desktopcontext.hxx"
2004-11-26 13:49:05 +00:00
# include "exithelper.hxx"
2008-02-27 09:28:25 +00:00
# include "../migration/pages.hxx"
2005-07-07 12:19:39 +00:00
# include <svtools/javacontext.hxx>
2005-02-02 12:45:19 +00:00
# include <com/sun/star/frame/XSessionManagerListener.hpp>
2004-11-26 13:49:05 +00:00
# include <com/sun/star/frame/XSynchronousDispatch.hpp>
2004-07-23 10:20:30 +00:00
# include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
2007-07-18 08:03:37 +00:00
# include <com/sun/star/configuration/CorruptedConfigurationException.hpp>
2001-07-17 07:34:12 +00:00
# include <com/sun/star/frame/XStorable.hpp>
# include <com/sun/star/util/XModifiable.hpp>
2004-11-26 13:49:05 +00:00
# include <com/sun/star/util/XFlushable.hpp>
2001-07-17 07:34:12 +00:00
# include <com/sun/star/system/XSystemShellExecute.hpp>
# include <com/sun/star/system/SystemShellExecuteFlags.hpp>
2001-07-16 11:55:47 +00:00
# include <com/sun/star/beans/XPropertySet.hpp>
2000-09-18 15:18:56 +00:00
# include <com/sun/star/lang/XComponent.hpp>
2003-07-22 07:26:21 +00:00
# include <com/sun/star/uno/RuntimeException.hpp>
# include <com/sun/star/io/IOException.hpp>
# include <com/sun/star/lang/IllegalArgumentException.hpp>
2003-03-25 12:52:54 +00:00
# include <com/sun/star/lang/WrappedTargetException.hpp>
2001-07-16 11:55:47 +00:00
# include <com/sun/star/frame/XDesktop.hpp>
# include <com/sun/star/frame/XComponentLoader.hpp>
# include <com/sun/star/view/XPrintable.hpp>
2001-07-20 08:52:29 +00:00
# include <com/sun/star/lang/XInitialization.hpp>
2002-05-24 10:24:34 +00:00
# include <com/sun/star/frame/XFramesSupplier.hpp>
2001-07-16 11:55:47 +00:00
# include <com/sun/star/awt/XTopWindow.hpp>
2001-08-02 12:34:32 +00:00
# include <com/sun/star/util/XURLTransformer.hpp>
# include <com/sun/star/util/URL.hpp>
2005-10-19 11:20:09 +00:00
# include <com/sun/star/util/XCloseable.hpp>
2001-08-02 12:34:32 +00:00
# include <com/sun/star/frame/XDispatch.hpp>
# include <com/sun/star/frame/XDispatchProvider.hpp>
2002-10-21 08:05:48 +00:00
# include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
2008-02-12 16:27:59 +00:00
# include <com/sun/star/lang/XSingleServiceFactory.hpp>
2001-08-09 04:43:13 +00:00
# include <com/sun/star/configuration/MissingBootstrapFileException.hpp>
# include <com/sun/star/configuration/InvalidBootstrapFileException.hpp>
# include <com/sun/star/configuration/InstallationIncompleteException.hpp>
2003-04-17 12:32:52 +00:00
# include <com/sun/star/configuration/backend/BackendSetupException.hpp>
# include <com/sun/star/configuration/backend/BackendAccessException.hpp>
2001-11-21 15:31:29 +00:00
# include <com/sun/star/container/XEnumeration.hpp>
2001-11-21 13:57:13 +00:00
# include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
# include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
2001-12-05 12:33:54 +00:00
# include <com/sun/star/task/XJobExecutor.hpp>
2010-05-10 17:35:24 +02:00
# include <com/sun/star/task/XRestartManager.hpp>
2004-06-25 12:10:20 +00:00
# ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_
# include <com/sun/star/task/XJob.hpp>
# endif
2001-12-13 08:04:55 +00:00
# include <com/sun/star/beans/XPropertySet.hpp>
2003-05-22 07:51:28 +00:00
# include <com/sun/star/beans/NamedValue.hpp>
# include <com/sun/star/task/XJob.hpp>
2005-02-02 12:45:19 +00:00
# include <com/sun/star/document/XEventListener.hpp>
2005-10-19 11:20:09 +00:00
# include <com/sun/star/ui/XUIElementFactoryRegistration.hpp>
# include <com/sun/star/frame/XUIControllerRegistration.hpp>
2000-09-18 15:18:56 +00:00
2002-08-16 13:14:03 +00:00
# include <com/sun/star/java/XJavaVM.hpp>
2004-06-25 12:10:20 +00:00
# include <tools/testtoolloader.hxx>
2001-07-26 06:45:36 +00:00
# include <tools/solar.h>
2001-07-16 11:55:47 +00:00
# ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
# include <toolkit/unohlp.hxx>
# endif
# include <vos/security.hxx>
2001-08-01 11:16:42 +00:00
# include <vos/ref.hxx>
2000-10-23 07:26:10 +00:00
# include <comphelper/processfactory.hxx>
2010-05-10 17:35:24 +02:00
# include <comphelper/componentcontext.hxx>
2004-12-02 08:14:48 +00:00
# include <comphelper/configurationhelper.hxx>
2003-06-27 08:42:13 +00:00
# ifndef _UTL__HXX_
2000-11-30 07:47:40 +00:00
# include <unotools/configmgr.hxx>
# endif
2001-02-08 14:24:59 +00:00
# include <unotools/configitem.hxx>
2001-08-01 11:16:42 +00:00
# include <unotools/confignode.hxx>
2001-07-16 11:55:47 +00:00
# include <unotools/ucbhelper.hxx>
# include <tools/tempfile.hxx>
# include <tools/urlobj.hxx>
2009-10-06 07:38:24 +02:00
# include <unotools/moduleoptions.hxx>
2001-07-26 06:45:36 +00:00
# include <osl/module.h>
# include <osl/file.hxx>
2005-11-11 11:29:30 +00:00
# include <osl/signal.h>
2008-02-12 16:27:59 +00:00
# include <rtl/uuid.h>
2009-10-06 07:38:24 +02:00
# include <unotools/pathoptions.hxx>
2009-10-16 00:05:16 +02:00
# include <svl/languageoptions.hxx>
2009-10-06 07:38:24 +02:00
# include <unotools/internaloptions.hxx>
2002-10-21 04:36:19 +00:00
# include <svtools/miscopt.hxx>
2009-04-14 17:47:15 +00:00
# include <svtools/menuoptions.hxx>
2009-10-16 00:05:16 +02:00
# include <unotools/syslocaleoptions.hxx>
# include <unotools/syslocale.hxx>
# include <svl/folderrestriction.hxx>
2001-07-17 07:34:12 +00:00
# include <unotools/tempfile.hxx>
2001-07-10 04:29:45 +00:00
# include <rtl/logfile.hxx>
2001-08-07 10:25:00 +00:00
# include <rtl/ustrbuf.hxx>
2001-10-09 11:12:08 +00:00
# include <rtl/strbuf.hxx>
2001-11-21 13:57:13 +00:00
# include <rtl/bootstrap.hxx>
2004-06-25 16:30:04 +00:00
# include <rtl/instance.hxx>
2000-12-08 07:45:22 +00:00
# include <unotools/configmgr.hxx>
2003-06-27 08:42:13 +00:00
# include <vcl/help.hxx>
2000-12-12 13:20:07 +00:00
# include <vcl/msgbox.hxx>
2001-07-06 14:58:45 +00:00
# include <vcl/bitmap.hxx>
2001-08-01 11:16:42 +00:00
# include <vcl/stdtext.hxx>
2001-08-07 10:25:00 +00:00
# include <vcl/msgbox.hxx>
2001-07-06 14:58:45 +00:00
# include <sfx2/sfx.hrc>
2001-07-16 11:55:47 +00:00
# include <ucbhelper/contentbroker.hxx>
2001-07-24 09:24:30 +00:00
# include <unotools/bootstrap.hxx>
2010-05-10 17:35:24 +02:00
# include <cppuhelper/bootstrap.hxx>
2001-03-07 08:20:36 +00:00
2008-04-17 07:05:48 +00:00
# include "vos/process.hxx"
2004-02-03 19:03:09 +00:00
# include <svtools/fontsubstconfig.hxx>
# include <svtools/accessibilityoptions.hxx>
# include <svtools/apearcfg.hxx>
2009-10-16 00:05:16 +02:00
# include <unotools/misccfg.hxx>
2004-02-03 19:03:09 +00:00
# include <svtools/filter.hxx>
2009-10-06 07:38:24 +02:00
# include <unotools/regoptions.hxx>
2004-02-03 19:03:09 +00:00
2003-11-07 13:51:04 +00:00
# include "langselect.hxx"
2003-06-12 09:46:20 +00:00
# define DEFINE_CONST_UNICODE(CONSTASCII) UniString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII))
2003-06-27 08:42:13 +00:00
# define U2S(STRING) ::rtl::OUStringToOString(STRING, RTL_TEXTENCODING_UTF8)
2000-09-18 15:18:56 +00:00
2001-07-16 11:55:47 +00:00
using namespace vos ;
using namespace rtl ;
2003-07-22 07:26:21 +00:00
2003-08-18 14:31:06 +00:00
//Gives an ICE with MSVC6
//namespace css = ::com::sun::star;
2003-07-22 07:26:21 +00:00
2003-08-18 14:31:06 +00:00
using namespace : : com : : sun : : star : : uno ;
using namespace : : com : : sun : : star : : util ;
using namespace : : com : : sun : : star : : lang ;
using namespace : : com : : sun : : star : : beans ;
2003-03-25 12:52:54 +00:00
//using namespace ::com::sun::star::bridge;
2003-08-18 14:31:06 +00:00
using namespace : : com : : sun : : star : : frame ;
using namespace : : com : : sun : : star : : document ;
using namespace : : com : : sun : : star : : view ;
using namespace : : com : : sun : : star : : task ;
using namespace : : com : : sun : : star : : system ;
using namespace : : com : : sun : : star : : ui : : dialogs ;
using namespace : : com : : sun : : star : : container ;
2003-07-22 07:26:21 +00:00
2004-11-26 13:49:05 +00:00
namespace css = : : com : : sun : : star ;
2001-07-16 11:55:47 +00:00
2005-11-11 11:29:30 +00:00
ResMgr * desktop : : Desktop : : pResMgr = 0 ;
2001-07-16 11:55:47 +00:00
2002-11-01 13:49:58 +00:00
namespace desktop
{
static SalMainPipeExchangeSignalHandler * pSignalHandler = 0 ;
2005-11-11 11:29:30 +00:00
static sal_Bool _bCrashReporterEnabled = sal_True ;
2002-11-01 13:49:58 +00:00
2008-02-12 16:27:59 +00:00
static const : : rtl : : OUString CFG_PACKAGE_COMMON_HELP ( RTL_CONSTASCII_USTRINGPARAM ( " org.openoffice.Office.Common/Help " ) ) ;
static const : : rtl : : OUString CFG_PATH_REG ( RTL_CONSTASCII_USTRINGPARAM ( " Registration " ) ) ;
static const : : rtl : : OUString CFG_ENTRY_REGURL ( RTL_CONSTASCII_USTRINGPARAM ( " URL " ) ) ;
static const : : rtl : : OUString CFG_ENTRY_TEMPLATEREGURL ( RTL_CONSTASCII_USTRINGPARAM ( " TemplateURL " ) ) ;
2001-07-30 14:31:59 +00:00
// ----------------------------------------------------------------------------
2001-07-16 11:55:47 +00:00
ResMgr * Desktop : : GetDesktopResManager ( )
{
if ( ! Desktop : : pResMgr )
{
String aMgrName = String : : CreateFromAscii ( " dkt " ) ;
2003-03-25 12:52:54 +00:00
2002-04-10 04:49:49 +00:00
// Create desktop resource manager and bootstrap process
// was successful. Use default way to get language specific message.
if ( Application : : IsInExecute ( ) )
Desktop : : pResMgr = ResMgr : : CreateResMgr ( U2S ( aMgrName ) ) ;
if ( ! Desktop : : pResMgr )
{
// Use VCL to get the correct language specific message as we
// are in the bootstrap process and not able to get the installed
// language!!
2004-06-25 11:39:32 +00:00
/*
2002-04-10 04:49:49 +00:00
LanguageType aLanguageType = LANGUAGE_DONTKNOW ;
Desktop : : pResMgr = ResMgr : : SearchCreateResMgr ( U2S ( aMgrName ) , aLanguageType ) ;
2003-03-25 12:52:54 +00:00
AllSettings as = GetSettings ( ) ;
as . SetUILanguage ( aLanguageType ) ;
SetSettings ( as ) ;
2004-06-25 11:39:32 +00:00
*/
2005-03-11 10:01:09 +00:00
// LanguageSelection langselect;
2004-11-15 15:01:54 +00:00
OUString aUILocaleString = LanguageSelection : : getLanguageString ( ) ;
sal_Int32 nIndex = 0 ;
OUString aLanguage = aUILocaleString . getToken ( 0 , ' - ' , nIndex ) ;
OUString aCountry = aUILocaleString . getToken ( 0 , ' - ' , nIndex ) ;
OUString aVariant = aUILocaleString . getToken ( 0 , ' - ' , nIndex ) ;
: : com : : sun : : star : : lang : : Locale aLocale ( aLanguage , aCountry , aVariant ) ;
2004-06-25 12:54:05 +00:00
Desktop : : pResMgr = ResMgr : : SearchCreateResMgr ( U2S ( aMgrName ) , aLocale ) ;
AllSettings as = GetSettings ( ) ;
as . SetUILocale ( aLocale ) ;
SetSettings ( as ) ;
2002-04-10 04:49:49 +00:00
}
2001-07-16 11:55:47 +00:00
}
2002-04-10 04:49:49 +00:00
2001-07-16 11:55:47 +00:00
return Desktop : : pResMgr ;
}
2001-10-09 11:12:08 +00:00
// ----------------------------------------------------------------------------
2003-03-25 12:52:54 +00:00
// Get a message string securely. There is a fallback string if the resource
2001-10-09 11:12:08 +00:00
// is not available.
OUString Desktop : : GetMsgString ( USHORT nId , const OUString & aFaultBackMsg )
{
2006-10-12 13:03:59 +00:00
ResMgr * resMgr = GetDesktopResManager ( ) ;
if ( ! resMgr )
2001-10-09 11:12:08 +00:00
return aFaultBackMsg ;
else
2007-04-26 07:21:55 +00:00
return OUString ( String ( ResId ( nId , * resMgr ) ) ) ;
2001-10-09 11:12:08 +00:00
}
2001-07-16 11:55:47 +00:00
2002-10-21 08:05:48 +00:00
OUString MakeStartupErrorMessage ( OUString const & aErrorMessage )
{
2003-06-27 08:42:13 +00:00
OUStringBuffer aDiagnosticMessage ( 100 ) ;
2002-10-21 08:05:48 +00:00
ResMgr * pResMgr = Desktop : : GetDesktopResManager ( ) ;
if ( pResMgr )
2007-04-26 07:21:55 +00:00
aDiagnosticMessage . append ( OUString ( String ( ResId ( STR_BOOTSTRAP_ERR_CANNOT_START , * pResMgr ) ) ) ) ;
2002-10-21 08:05:48 +00:00
else
aDiagnosticMessage . appendAscii ( " The program cannot be started. " ) ;
aDiagnosticMessage . appendAscii ( " \n " ) ;
aDiagnosticMessage . append ( aErrorMessage ) ;
return aDiagnosticMessage . makeStringAndClear ( ) ;
}
2003-03-25 12:52:54 +00:00
OUString MakeStartupConfigAccessErrorMessage ( OUString const & aInternalErrMsg )
{
OUStringBuffer aDiagnosticMessage ( 200 ) ;
ResMgr * pResMgr = Desktop : : GetDesktopResManager ( ) ;
if ( pResMgr )
2007-04-26 07:21:55 +00:00
aDiagnosticMessage . append ( OUString ( String ( ResId ( STR_BOOTSTRAP_ERR_CFG_DATAACCESS , * pResMgr ) ) ) ) ;
2003-03-25 12:52:54 +00:00
else
aDiagnosticMessage . appendAscii ( " The program cannot be started. " ) ;
if ( aInternalErrMsg . getLength ( ) > 0 )
{
aDiagnosticMessage . appendAscii ( " \n \n " ) ;
if ( pResMgr )
2007-04-26 07:21:55 +00:00
aDiagnosticMessage . append ( OUString ( String ( ResId ( STR_INTERNAL_ERRMSG , * pResMgr ) ) ) ) ;
2003-03-25 12:52:54 +00:00
else
aDiagnosticMessage . appendAscii ( " The following internal error has occured: \n \n " ) ;
aDiagnosticMessage . append ( aInternalErrMsg ) ;
}
return aDiagnosticMessage . makeStringAndClear ( ) ;
}
2008-07-08 07:29:44 +00:00
//=============================================================================
// shows a simple error box with the given message ... but exits from these process !
//
// Fatal errors cant be solved by the process ... nor any recovery can help.
// Mostly the installation was damaged and must be repaired manually .. or by calling
// setup again.
//
// On the other side we must make sure that no further actions will be possible within
// the current office process ! No pipe requests, no menu/toolbar/shortuct actions
// are allowed. Otherwise we will force a "crash inside a crash".
//
// Thats why we have to use a special native message box here which does not use yield :-)
//=============================================================================
void FatalError ( const : : rtl : : OUString & sMessage )
2002-10-21 08:05:48 +00:00
{
2008-07-08 07:29:44 +00:00
: : rtl : : OUString sProductKey = : : utl : : Bootstrap : : getProductKey ( ) ;
if ( ! sProductKey . getLength ( ) )
2004-01-06 17:37:50 +00:00
{
: : vos : : OStartupInfo aInfo ;
2008-07-08 07:29:44 +00:00
aInfo . getExecutableFile ( sProductKey ) ;
2002-10-21 08:05:48 +00:00
2008-07-08 07:29:44 +00:00
: : sal_uInt32 nLastIndex = sProductKey . lastIndexOf ( ' / ' ) ;
if ( nLastIndex > 0 )
sProductKey = sProductKey . copy ( nLastIndex + 1 ) ;
2002-10-21 08:05:48 +00:00
}
2008-07-08 07:29:44 +00:00
: : rtl : : OUStringBuffer sTitle ( 128 ) ;
sTitle . append ( sProductKey ) ;
sTitle . appendAscii ( " - Fatal Error " ) ;
Application : : ShowNativeErrorBox ( sTitle . makeStringAndClear ( ) , sMessage ) ;
_exit ( ExitHelper : : E_FATAL_ERROR ) ;
2002-10-21 08:05:48 +00:00
}
2004-08-20 12:04:13 +00:00
static bool ShouldSuppressUI ( CommandLineArgs * pCmdLine )
{
return pCmdLine - > IsInvisible ( ) | |
pCmdLine - > IsHeadless ( ) | |
pCmdLine - > IsQuickstart ( ) ;
}
2002-11-01 13:49:58 +00:00
CommandLineArgs * Desktop : : GetCommandLineArgs ( )
2001-07-16 11:55:47 +00:00
{
2003-03-25 12:52:54 +00:00
static CommandLineArgs * pArgs = 0 ;
2001-07-16 11:55:47 +00:00
if ( ! pArgs )
{
: : osl : : MutexGuard aGuard ( : : osl : : Mutex : : getGlobalMutex ( ) ) ;
if ( ! pArgs )
2004-07-30 14:28:55 +00:00
{
2008-06-09 11:59:01 +00:00
pArgs = new CommandLineArgs ;
2004-07-30 14:28:55 +00:00
}
2001-07-16 11:55:47 +00:00
}
return pArgs ;
}
2000-09-18 15:18:56 +00:00
2002-10-21 08:05:48 +00:00
sal_Bool InitConfiguration ( )
2001-02-08 14:24:59 +00:00
{
2002-10-21 08:05:48 +00:00
RTL_LOGFILE_CONTEXT ( aLog , " desktop (jb99855) ::InitConfiguration " ) ;
2001-07-10 04:29:45 +00:00
2002-10-21 08:05:48 +00:00
Reference < XMultiServiceFactory > xProvider ( CreateApplicationConfigurationProvider ( ) ) ;
return xProvider . is ( ) ;
2001-02-08 14:24:59 +00:00
}
2004-06-25 16:30:04 +00:00
namespace
{
struct BrandName
: public rtl : : Static < String , BrandName > { } ;
struct Version
: public rtl : : Static < String , Version > { } ;
2006-12-19 17:35:35 +00:00
struct AboutBoxVersion
: public rtl : : Static < String , AboutBoxVersion > { } ;
2010-03-25 17:21:13 +01:00
struct OOOVendor
: public rtl : : Static < String , OOOVendor > { } ;
2004-06-25 16:30:04 +00:00
struct Extension
: public rtl : : Static < String , Extension > { } ;
2005-07-12 13:29:16 +00:00
struct XMLFileFormatName
: public rtl : : Static < String , XMLFileFormatName > { } ;
2004-06-25 16:30:04 +00:00
struct XMLFileFormatVersion
: public rtl : : Static < String , XMLFileFormatVersion > { } ;
2004-08-02 13:33:55 +00:00
struct WriterCompatibilityVersionOOo11
: public rtl : : Static < String , WriterCompatibilityVersionOOo11 > { } ;
2004-06-25 16:30:04 +00:00
}
2001-11-09 15:17:35 +00:00
2000-12-08 07:45:22 +00:00
void ReplaceStringHookProc ( UniString & rStr )
{
2001-01-23 10:56:12 +00:00
static int nAll = 0 , nPro = 0 ;
2005-05-13 12:04:56 +00:00
nAll + + ;
if ( rStr . SearchAscii ( " %PRODUCT " ) ! = STRING_NOTFOUND )
2000-12-08 07:45:22 +00:00
{
2005-05-13 12:04:56 +00:00
String & rBrandName = BrandName : : get ( ) ;
String & rVersion = Version : : get ( ) ;
2006-12-19 17:35:35 +00:00
String & rAboutBoxVersion = AboutBoxVersion : : get ( ) ;
2005-05-13 12:04:56 +00:00
String & rExtension = Extension : : get ( ) ;
2005-07-12 13:29:16 +00:00
String & rXMLFileFormatName = XMLFileFormatName : : get ( ) ;
2005-05-13 12:04:56 +00:00
String & rXMLFileFormatVersion = XMLFileFormatVersion : : get ( ) ;
2001-01-23 10:56:12 +00:00
2005-05-13 12:04:56 +00:00
if ( ! rBrandName . Len ( ) )
2001-11-09 15:17:35 +00:00
{
2005-05-13 12:04:56 +00:00
rtl : : OUString aTmp ;
Any aRet = : : utl : : ConfigManager : : GetDirectConfigProperty ( : : utl : : ConfigManager : : PRODUCTNAME ) ;
2001-11-09 15:17:35 +00:00
aRet > > = aTmp ;
2005-05-13 12:04:56 +00:00
rBrandName = aTmp ;
2004-08-02 13:33:55 +00:00
2005-07-12 13:29:16 +00:00
aRet = : : utl : : ConfigManager : : GetDirectConfigProperty ( : : utl : : ConfigManager : : PRODUCTXMLFILEFORMATNAME ) ;
aRet > > = aTmp ;
rXMLFileFormatName = aTmp ;
2005-05-13 12:04:56 +00:00
aRet = : : utl : : ConfigManager : : GetDirectConfigProperty ( : : utl : : ConfigManager : : PRODUCTXMLFILEFORMATVERSION ) ;
2004-08-02 13:33:55 +00:00
aRet > > = aTmp ;
2005-05-13 12:04:56 +00:00
rXMLFileFormatVersion = aTmp ;
aRet = : : utl : : ConfigManager : : GetDirectConfigProperty ( : : utl : : ConfigManager : : PRODUCTVERSION ) ;
aRet > > = aTmp ;
rVersion = aTmp ;
2006-12-19 17:35:35 +00:00
aRet = : : utl : : ConfigManager : : GetDirectConfigProperty ( : : utl : : ConfigManager : : ABOUTBOXPRODUCTVERSION ) ;
aRet > > = aTmp ;
rAboutBoxVersion = aTmp ;
2005-05-13 12:04:56 +00:00
if ( ! rExtension . Len ( ) )
{
aRet = : : utl : : ConfigManager : : GetDirectConfigProperty ( : : utl : : ConfigManager : : PRODUCTEXTENSION ) ;
aRet > > = aTmp ;
rExtension = aTmp ;
}
}
2000-12-08 07:45:22 +00:00
2001-01-23 10:56:12 +00:00
nPro + + ;
2004-06-25 16:30:04 +00:00
rStr . SearchAndReplaceAllAscii ( " %PRODUCTNAME " , rBrandName ) ;
rStr . SearchAndReplaceAllAscii ( " %PRODUCTVERSION " , rVersion ) ;
2006-12-19 17:35:35 +00:00
rStr . SearchAndReplaceAllAscii ( " %ABOUTBOXPRODUCTVERSION " , rAboutBoxVersion ) ;
2004-06-25 16:30:04 +00:00
rStr . SearchAndReplaceAllAscii ( " %PRODUCTEXTENSION " , rExtension ) ;
2005-07-12 13:29:16 +00:00
rStr . SearchAndReplaceAllAscii ( " %PRODUCTXMLFILEFORMATNAME " , rXMLFileFormatName ) ;
2004-06-25 16:30:04 +00:00
rStr . SearchAndReplaceAllAscii ( " %PRODUCTXMLFILEFORMATVERSION " , rXMLFileFormatVersion ) ;
2001-01-23 10:56:12 +00:00
}
2010-03-25 17:21:13 +01:00
if ( rStr . SearchAscii ( " %OOOVENDOR " ) ! = STRING_NOTFOUND )
{
String & rOOOVendor = OOOVendor : : get ( ) ;
if ( ! rOOOVendor . Len ( ) )
{
rtl : : OUString aTmp ;
Any aRet = : : utl : : ConfigManager : : GetDirectConfigProperty (
: : utl : : ConfigManager : : OOOVENDOR ) ;
aRet > > = aTmp ;
rOOOVendor = aTmp ;
}
rStr . SearchAndReplaceAllAscii ( " %OOOVENDOR " , rOOOVendor ) ;
}
2004-08-02 13:33:55 +00:00
if ( rStr . SearchAscii ( " %WRITERCOMPATIBILITYVERSIONOOO11 " ) ! = STRING_NOTFOUND )
2005-05-13 12:04:56 +00:00
{
String & rWriterCompatibilityVersionOOo11 = WriterCompatibilityVersionOOo11 : : get ( ) ;
if ( ! rWriterCompatibilityVersionOOo11 . Len ( ) )
{
rtl : : OUString aTmp ;
Any aRet = : : utl : : ConfigManager : : GetDirectConfigProperty (
: : utl : : ConfigManager : : WRITERCOMPATIBILITYVERSIONOOO11 ) ;
aRet > > = aTmp ;
rWriterCompatibilityVersionOOo11 = aTmp ;
}
2004-08-02 13:33:55 +00:00
rStr . SearchAndReplaceAllAscii ( " %WRITERCOMPATIBILITYVERSIONOOO11 " ,
2005-05-13 12:04:56 +00:00
rWriterCompatibilityVersionOOo11 ) ;
}
2000-12-08 07:45:22 +00:00
}
2003-03-25 12:52:54 +00:00
Desktop : : Desktop ( )
2006-10-12 13:03:59 +00:00
: m_bServicesRegistered ( false )
2003-03-25 12:52:54 +00:00
, m_aBootstrapError ( BE_OK )
, m_pLockfile ( NULL )
2000-09-18 15:18:56 +00:00
{
2001-08-07 10:25:00 +00:00
RTL_LOGFILE_TRACE ( " desktop (cd100003) ::Desktop::Desktop " ) ;
2001-07-16 11:55:47 +00:00
}
2002-11-01 13:49:58 +00:00
Desktop : : ~ Desktop ( )
{
}
2001-07-16 11:55:47 +00:00
void Desktop : : Init ( )
{
2001-08-07 10:25:00 +00:00
RTL_LOGFILE_CONTEXT ( aLog , " desktop (cd100003) ::Desktop::Init " ) ;
2005-10-24 17:33:51 +00:00
SetBootstrapStatus ( BS_OK ) ;
2001-07-24 09:24:30 +00:00
2003-03-25 12:52:54 +00:00
// create service factory...
2002-11-01 13:49:58 +00:00
Reference < XMultiServiceFactory > rSMgr = CreateApplicationServiceManager ( ) ;
2004-11-09 14:15:02 +00:00
if ( rSMgr . is ( ) )
{
: : comphelper : : setProcessServiceFactory ( rSMgr ) ;
}
else
2001-10-09 11:12:08 +00:00
{
SetBootstrapError ( BE_UNO_SERVICEMANAGER ) ;
}
2001-08-07 10:25:00 +00:00
2004-11-09 14:15:02 +00:00
if ( GetBootstrapError ( ) = = BE_OK )
{
// prepare language
if ( ! LanguageSelection : : prepareLanguage ( ) )
SetBootstrapError ( BE_LANGUAGE_MISSING ) ;
}
2001-07-16 11:55:47 +00:00
2004-11-09 14:15:02 +00:00
if ( GetBootstrapError ( ) = = BE_OK )
{
CommandLineArgs * pCmdLineArgs = GetCommandLineArgs ( ) ;
2003-03-25 12:52:54 +00:00
# ifdef UNX
2004-11-26 13:49:05 +00:00
// check whether we need to print cmdline help
if ( pCmdLineArgs - > IsHelp ( ) ) {
displayCmdlineHelp ( ) ;
2005-10-24 17:33:51 +00:00
SetBootstrapStatus ( BS_TERMINATE ) ;
2004-11-26 13:49:05 +00:00
}
2003-03-25 12:52:54 +00:00
# endif
2004-01-20 15:33:21 +00:00
// start ipc thread only for non-remote offices
2004-01-23 11:20:47 +00:00
RTL_LOGFILE_CONTEXT ( aLog2 , " desktop (cd100003) ::OfficeIPCThread::EnableOfficeIPCThread " ) ;
2004-01-20 15:33:21 +00:00
OfficeIPCThread : : Status aStatus = OfficeIPCThread : : EnableOfficeIPCThread ( ) ;
if ( aStatus = = OfficeIPCThread : : IPC_STATUS_BOOTSTRAP_ERROR )
{
SetBootstrapError ( BE_PATHINFO_MISSING ) ;
}
else if ( aStatus = = OfficeIPCThread : : IPC_STATUS_2ND_OFFICE )
{
// 2nd office startup should terminate after sending cmdlineargs through pipe
2005-10-24 17:33:51 +00:00
SetBootstrapStatus ( BS_TERMINATE ) ;
2004-01-20 15:33:21 +00:00
}
else if ( pCmdLineArgs - > IsHelp ( ) )
{
// disable IPC thread in an instance that is just showing a help message
OfficeIPCThread : : DisableOfficeIPCThread ( ) ;
}
pSignalHandler = new SalMainPipeExchangeSignalHandler ;
2004-11-09 14:15:02 +00:00
}
2001-07-16 11:55:47 +00:00
}
void Desktop : : DeInit ( )
{
2005-03-18 10:20:00 +00:00
RTL_LOGFILE_CONTEXT ( aLog , " desktop (cd100003) ::Desktop::DeInit " ) ;
2003-07-11 09:41:21 +00:00
try {
2005-03-18 10:20:00 +00:00
// instead of removing of the configManager just let it commit all the changes
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " <- store config items " ) ;
utl : : ConfigManager : : GetConfigManager ( ) - > StoreConfigItems ( ) ;
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " <- store config items " ) ;
2003-07-11 09:41:21 +00:00
// close splashscreen if it's still open
CloseSplashScreen ( ) ;
Reference < XMultiServiceFactory > xXMultiServiceFactory ( : : comphelper : : getProcessServiceFactory ( ) ) ;
DestroyApplicationServiceManager ( xXMultiServiceFactory ) ;
// nobody should get a destroyd service factory...
: : comphelper : : setProcessServiceFactory ( NULL ) ;
2003-03-25 12:52:54 +00:00
2003-07-11 09:41:21 +00:00
// clear lockfile
if ( m_pLockfile ! = NULL )
m_pLockfile - > clean ( ) ;
2001-07-16 11:55:47 +00:00
2004-01-06 17:37:50 +00:00
OfficeIPCThread : : DisableOfficeIPCThread ( ) ;
if ( pSignalHandler )
DELETEZ ( pSignalHandler ) ;
2003-11-07 13:51:04 +00:00
} catch ( RuntimeException & ) {
2003-07-11 09:41:21 +00:00
// someone threw an exception during shutdown
// this will leave some garbage behind..
2001-07-16 11:55:47 +00:00
}
2005-03-18 10:20:00 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " FINISHED WITH Destop::DeInit " ) ;
2001-07-16 11:55:47 +00:00
}
BOOL Desktop : : QueryExit ( )
{
2008-11-20 15:13:11 +00:00
try
{
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " <- store config items " ) ;
utl : : ConfigManager : : GetConfigManager ( ) - > StoreConfigItems ( ) ;
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " <- store config items " ) ;
}
catch ( RuntimeException & )
{
}
2001-12-13 08:04:55 +00:00
const sal_Char SUSPEND_QUICKSTARTVETO [ ] = " SuspendQuickstartVeto " ;
2001-11-27 17:15:20 +00:00
Reference < : : com : : sun : : star : : frame : : XDesktop >
xDesktop ( : : comphelper : : getProcessServiceFactory ( ) - > createInstance ( OUSTRING ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.frame.Desktop " ) ) ) ,
UNO_QUERY ) ;
2001-12-13 08:04:55 +00:00
Reference < : : com : : sun : : star : : beans : : XPropertySet > xPropertySet ( xDesktop , UNO_QUERY ) ;
if ( xPropertySet . is ( ) )
{
Any a ;
a < < = ( sal_Bool ) sal_True ;
xPropertySet - > setPropertyValue ( OUSTRING ( RTL_CONSTASCII_USTRINGPARAM ( SUSPEND_QUICKSTARTVETO ) ) , a ) ;
}
BOOL bExit = ( ! xDesktop . is ( ) | | xDesktop - > terminate ( ) ) ;
2005-03-29 13:59:14 +00:00
2001-12-13 08:04:55 +00:00
if ( ! bExit & & xPropertySet . is ( ) )
{
Any a ;
a < < = ( sal_Bool ) sal_False ;
xPropertySet - > setPropertyValue ( OUSTRING ( RTL_CONSTASCII_USTRINGPARAM ( SUSPEND_QUICKSTARTVETO ) ) , a ) ;
2008-11-20 15:13:11 +00:00
}
else
{
try
{
// it is no problem to call DisableOfficeIPCThread() more than once
// it also looks to be threadsafe
OfficeIPCThread : : DisableOfficeIPCThread ( ) ;
}
catch ( RuntimeException & )
{
}
2003-04-04 16:22:32 +00:00
if ( m_pLockfile ! = NULL ) m_pLockfile - > clean ( ) ;
2001-12-13 08:04:55 +00:00
}
return bExit ;
2001-07-16 11:55:47 +00:00
}
2001-08-09 04:43:13 +00:00
void Desktop : : HandleBootstrapPathErrors ( : : utl : : Bootstrap : : Status aBootstrapStatus , const OUString & aDiagnosticMessage )
2001-08-07 10:25:00 +00:00
{
2001-08-09 04:43:13 +00:00
if ( aBootstrapStatus ! = : : utl : : Bootstrap : : DATA_OK )
2001-08-07 10:25:00 +00:00
{
2001-08-09 15:03:22 +00:00
sal_Bool bWorkstationInstallation = sal_False ;
2003-06-27 08:42:13 +00:00
: : rtl : : OUString aBaseInstallURL ;
: : rtl : : OUString aUserInstallURL ;
: : rtl : : OUString aProductKey ;
: : rtl : : OUString aTemp ;
2001-08-09 15:03:22 +00:00
: : vos : : OStartupInfo aInfo ;
aInfo . getExecutableFile ( aProductKey ) ;
2003-06-27 08:42:13 +00:00
sal_uInt32 lastIndex = aProductKey . lastIndexOf ( ' / ' ) ;
2001-08-09 15:03:22 +00:00
if ( lastIndex > 0 )
aProductKey = aProductKey . copy ( lastIndex + 1 ) ;
2001-10-09 11:12:08 +00:00
aTemp = : : utl : : Bootstrap : : getProductKey ( aProductKey ) ;
if ( aTemp . getLength ( ) > 0 )
aProductKey = aTemp ;
2001-08-09 04:43:13 +00:00
: : utl : : Bootstrap : : PathStatus aBaseInstallStatus = : : utl : : Bootstrap : : locateBaseInstallation ( aBaseInstallURL ) ;
: : utl : : Bootstrap : : PathStatus aUserInstallStatus = : : utl : : Bootstrap : : locateUserInstallation ( aUserInstallURL ) ;
if ( ( aBaseInstallStatus = = : : utl : : Bootstrap : : PATH_EXISTS & &
2003-06-27 08:42:13 +00:00
aUserInstallStatus = = : : utl : : Bootstrap : : PATH_EXISTS ) )
2001-08-07 10:25:00 +00:00
{
2001-08-09 04:43:13 +00:00
if ( aBaseInstallURL ! = aUserInstallURL )
bWorkstationInstallation = sal_True ;
}
2001-08-07 10:25:00 +00:00
2004-01-06 17:37:50 +00:00
OUString aMessage ;
OUStringBuffer aBuffer ( 100 ) ;
aBuffer . append ( aDiagnosticMessage ) ;
2001-12-11 13:39:35 +00:00
2004-01-06 17:37:50 +00:00
aBuffer . appendAscii ( " \n " ) ;
2001-12-11 13:39:35 +00:00
2007-06-19 15:18:20 +00:00
ErrorBox aBootstrapFailedBox ( NULL , WB_OK , aMessage ) ;
aBootstrapFailedBox . SetText ( aProductKey ) ;
aBootstrapFailedBox . Execute ( ) ;
2001-08-09 04:43:13 +00:00
}
}
2001-10-09 11:12:08 +00:00
// Create a error message depending on bootstrap failure code and an optional file url
2003-06-27 08:42:13 +00:00
: : rtl : : OUString Desktop : : CreateErrorMsgString (
2001-10-09 11:12:08 +00:00
utl : : Bootstrap : : FailureCode nFailureCode ,
const : : rtl : : OUString & aFileURL )
{
OUString aMsg ;
OUString aFilePath ;
sal_Bool bFileInfo = sal_True ;
switch ( nFailureCode )
{
/// the shared installation directory could not be located
case : : utl : : Bootstrap : : MISSING_INSTALL_DIRECTORY :
{
aMsg = GetMsgString ( STR_BOOTSTRAP_ERR_PATH_INVALID ,
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " The installation path is not available. " ) ) ) ;
bFileInfo = sal_False ;
}
break ;
/// the bootstrap INI file could not be found or read
case : : utl : : Bootstrap : : MISSING_BOOTSTRAP_FILE :
{
aMsg = GetMsgString ( STR_BOOTSTRAP_ERR_FILE_MISSING ,
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " The configuration file \" $1 \" is missing. " ) ) ) ;
}
break ;
/// the bootstrap INI is missing a required entry
/// the bootstrap INI contains invalid data
case : : utl : : Bootstrap : : MISSING_BOOTSTRAP_FILE_ENTRY :
case : : utl : : Bootstrap : : INVALID_BOOTSTRAP_FILE_ENTRY :
{
aMsg = GetMsgString ( STR_BOOTSTRAP_ERR_FILE_CORRUPT ,
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " The configuration file \" $1 \" is corrupt. " ) ) ) ;
}
break ;
/// the version locator INI file could not be found or read
case : : utl : : Bootstrap : : MISSING_VERSION_FILE :
{
aMsg = GetMsgString ( STR_BOOTSTRAP_ERR_FILE_MISSING ,
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " The configuration file \" $1 \" is missing. " ) ) ) ;
}
break ;
/// the version locator INI has no entry for this version
case : : utl : : Bootstrap : : MISSING_VERSION_FILE_ENTRY :
{
aMsg = GetMsgString ( STR_BOOTSTRAP_ERR_NO_SUPPORT ,
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " The main configuration file \" $1 \" does not support the current version. " ) ) ) ;
}
break ;
/// the user installation directory does not exist
case : : utl : : Bootstrap : : MISSING_USER_DIRECTORY :
{
aMsg = GetMsgString ( STR_BOOTSTRAP_ERR_DIR_MISSING ,
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " The configuration directory \" $1 \" is missing. " ) ) ) ;
}
break ;
/// some bootstrap data was invalid in unexpected ways
case : : utl : : Bootstrap : : INVALID_BOOTSTRAP_DATA :
{
aMsg = GetMsgString ( STR_BOOTSTRAP_ERR_INTERNAL ,
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " An internal failure occurred. " ) ) ) ;
bFileInfo = sal_False ;
}
break ;
2006-10-12 13:03:59 +00:00
case : : utl : : Bootstrap : : INVALID_VERSION_FILE_ENTRY :
{
// This needs to be improved, see #i67575#:
aMsg = OUString (
RTL_CONSTASCII_USTRINGPARAM ( " Invalid version file entry " ) ) ;
bFileInfo = sal_False ;
}
break ;
case : : utl : : Bootstrap : : NO_FAILURE :
{
OSL_ASSERT ( false ) ;
}
break ;
2001-10-09 11:12:08 +00:00
}
if ( bFileInfo )
{
String aMsgString ( aMsg ) ;
osl : : File : : getSystemPathFromFileURL ( aFileURL , aFilePath ) ;
aMsgString . SearchAndReplaceAscii ( " $1 " , aFilePath ) ;
aMsg = aMsgString ;
}
2002-10-21 08:05:48 +00:00
return MakeStartupErrorMessage ( aMsg ) ;
2001-10-09 11:12:08 +00:00
}
2001-08-09 04:43:13 +00:00
void Desktop : : HandleBootstrapErrors ( BootstrapError aBootstrapError )
{
if ( aBootstrapError = = BE_PATHINFO_MISSING )
{
2001-10-09 11:12:08 +00:00
OUString aErrorMsg ;
OUString aBuffer ;
2003-06-27 08:42:13 +00:00
utl : : Bootstrap : : Status aBootstrapStatus ;
utl : : Bootstrap : : FailureCode nFailureCode ;
2001-08-09 04:43:13 +00:00
2001-10-09 11:12:08 +00:00
aBootstrapStatus = : : utl : : Bootstrap : : checkBootstrapStatus ( aBuffer , nFailureCode ) ;
2001-08-09 04:43:13 +00:00
if ( aBootstrapStatus ! = : : utl : : Bootstrap : : DATA_OK )
2001-10-09 11:12:08 +00:00
{
switch ( nFailureCode )
{
case : : utl : : Bootstrap : : MISSING_INSTALL_DIRECTORY :
case : : utl : : Bootstrap : : INVALID_BOOTSTRAP_DATA :
{
aErrorMsg = CreateErrorMsgString ( nFailureCode , OUString ( ) ) ;
}
break ;
/// the bootstrap INI file could not be found or read
/// the bootstrap INI is missing a required entry
/// the bootstrap INI contains invalid data
case : : utl : : Bootstrap : : MISSING_BOOTSTRAP_FILE_ENTRY :
case : : utl : : Bootstrap : : INVALID_BOOTSTRAP_FILE_ENTRY :
case : : utl : : Bootstrap : : MISSING_BOOTSTRAP_FILE :
{
OUString aBootstrapFileURL ;
utl : : Bootstrap : : locateBootstrapFile ( aBootstrapFileURL ) ;
aErrorMsg = CreateErrorMsgString ( nFailureCode , aBootstrapFileURL ) ;
}
break ;
/// the version locator INI file could not be found or read
/// the version locator INI has no entry for this version
/// the version locator INI entry is not a valid directory URL
case : : utl : : Bootstrap : : INVALID_VERSION_FILE_ENTRY :
case : : utl : : Bootstrap : : MISSING_VERSION_FILE_ENTRY :
case : : utl : : Bootstrap : : MISSING_VERSION_FILE :
{
OUString aVersionFileURL ;
utl : : Bootstrap : : locateVersionFile ( aVersionFileURL ) ;
aErrorMsg = CreateErrorMsgString ( nFailureCode , aVersionFileURL ) ;
}
break ;
/// the user installation directory does not exist
case : : utl : : Bootstrap : : MISSING_USER_DIRECTORY :
{
OUString aUserInstallationURL ;
utl : : Bootstrap : : locateUserInstallation ( aUserInstallationURL ) ;
aErrorMsg = CreateErrorMsgString ( nFailureCode , aUserInstallationURL ) ;
}
break ;
2006-10-12 13:03:59 +00:00
case : : utl : : Bootstrap : : NO_FAILURE :
{
OSL_ASSERT ( false ) ;
}
break ;
2001-10-09 11:12:08 +00:00
}
HandleBootstrapPathErrors ( aBootstrapStatus , aErrorMsg ) ;
}
2001-08-07 10:25:00 +00:00
}
2001-10-09 11:12:08 +00:00
else if ( aBootstrapError = = BE_UNO_SERVICEMANAGER | | aBootstrapError = = BE_UNO_SERVICE_CONFIG_MISSING )
2001-08-07 10:25:00 +00:00
{
// Uno service manager is not available. VCL needs a uno service manager to display a message box!!!
// Currently we are not able to display a message box with a service manager due to this limitations inside VCL.
2005-01-27 11:26:58 +00:00
// When UNO is not properly initialized, all kinds of things can fail
// and cause the process to crash (e.g., a call to GetMsgString may
// crash when somewhere deep within that call Any::operator <= is used
// with a PropertyValue, and no binary UNO type description for
// PropertyValue is available). To give the user a hint even if
// generating and displaying a message box below crashes, print a
// hard-coded message on stderr first:
fputs (
aBootstrapError = = BE_UNO_SERVICEMANAGER
? ( " The application cannot be started. " " \n "
" The component manager is not available. " " \n " )
// STR_BOOTSTRAP_ERR_CANNOT_START, STR_BOOTSTRAP_ERR_NO_SERVICE
: ( " The application cannot be started. " " \n "
" The configuration service is not available. " " \n " ) ,
// STR_BOOTSTRAP_ERR_CANNOT_START,
// STR_BOOTSTRAP_ERR_NO_CFG_SERVICE
stderr ) ;
2004-01-06 17:37:50 +00:00
// First sentence. We cannot bootstrap office further!
OUString aMessage ;
OUStringBuffer aDiagnosticMessage ( 100 ) ;
2001-10-09 11:12:08 +00:00
2004-01-06 17:37:50 +00:00
OUString aErrorMsg ;
2001-10-09 11:12:08 +00:00
2004-01-06 17:37:50 +00:00
if ( aBootstrapError = = BE_UNO_SERVICEMANAGER )
aErrorMsg = GetMsgString ( STR_BOOTSTRAP_ERR_NO_SERVICE ,
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " The service manager is not available. " ) ) ) ;
2001-08-07 10:25:00 +00:00
else
2004-01-06 17:37:50 +00:00
aErrorMsg = GetMsgString ( STR_BOOTSTRAP_ERR_NO_CFG_SERVICE ,
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " The configuration service is not available. " ) ) ) ;
2001-10-09 11:12:08 +00:00
2004-01-06 17:37:50 +00:00
aDiagnosticMessage . append ( aErrorMsg ) ;
aDiagnosticMessage . appendAscii ( " \n " ) ;
2001-10-09 11:12:08 +00:00
2004-01-06 17:37:50 +00:00
// Due to the fact the we haven't a backup applicat.rdb file anymore it is not possible to
// repair the installation with the setup executable besides the office executable. Now
// we have to ask the user to start the setup on CD/installation directory manually!!
OUString aStartSetupManually ( GetMsgString (
STR_ASK_START_SETUP_MANUALLY ,
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Start setup application to repair the installation from CD, or the folder containing the installation packages. " ) ) ) ) ;
2001-10-09 11:12:08 +00:00
2004-01-06 17:37:50 +00:00
aDiagnosticMessage . append ( aStartSetupManually ) ;
aMessage = MakeStartupErrorMessage ( aDiagnosticMessage . makeStringAndClear ( ) ) ;
2001-10-09 11:12:08 +00:00
2004-01-06 17:37:50 +00:00
FatalError ( aMessage ) ;
2001-08-07 10:25:00 +00:00
}
2003-11-07 13:51:04 +00:00
else if ( aBootstrapError = = BE_USERINSTALL_FAILED )
{
2004-11-09 14:15:02 +00:00
OUString aMessage ;
OUStringBuffer aDiagnosticMessage ( 100 ) ;
OUString aErrorMsg ;
aErrorMsg = GetMsgString ( STR_BOOTSTRAP_ERR_INTERNAL ,
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " User installation could not be completed " ) ) ) ;
aDiagnosticMessage . append ( aErrorMsg ) ;
aMessage = MakeStartupErrorMessage ( aDiagnosticMessage . makeStringAndClear ( ) ) ;
FatalError ( aMessage ) ;
2003-11-07 13:51:04 +00:00
}
2004-11-09 14:15:02 +00:00
else if ( aBootstrapError = = BE_LANGUAGE_MISSING )
{
OUString aMessage ;
OUStringBuffer aDiagnosticMessage ( 100 ) ;
OUString aErrorMsg ;
aErrorMsg = GetMsgString (
//@@@ FIXME: should use an own resource string => #i36213#
2007-07-10 14:24:16 +00:00
STR_BOOTSTRAP_ERR_LANGUAGE_MISSING ,
2004-11-09 14:15:02 +00:00
OUString ( RTL_CONSTASCII_USTRINGPARAM (
" Language could not be determined. " ) ) ) ;
aDiagnosticMessage . append ( aErrorMsg ) ;
aMessage = MakeStartupErrorMessage (
aDiagnosticMessage . makeStringAndClear ( ) ) ;
FatalError ( aMessage ) ;
2006-03-24 12:51:32 +00:00
}
else if ( ( aBootstrapError = = BE_USERINSTALL_NOTENOUGHDISKSPACE ) | |
( aBootstrapError = = BE_USERINSTALL_NOWRITEACCESS ) )
{
OUString aUserInstallationURL ;
OUString aUserInstallationPath ;
OUString aMessage ;
OUString aErrorMsg ;
OUStringBuffer aDiagnosticMessage ( 100 ) ;
utl : : Bootstrap : : locateUserInstallation ( aUserInstallationURL ) ;
if ( aBootstrapError = = BE_USERINSTALL_NOTENOUGHDISKSPACE )
aErrorMsg = GetMsgString (
STR_BOOSTRAP_ERR_NOTENOUGHDISKSPACE ,
OUString ( RTL_CONSTASCII_USTRINGPARAM (
" User installation could not be completed due to insufficient free disk space. " ) ) ) ;
else
aErrorMsg = GetMsgString (
STR_BOOSTRAP_ERR_NOACCESSRIGHTS ,
OUString ( RTL_CONSTASCII_USTRINGPARAM (
" User installation could not be processed due to missing access rights. " ) ) ) ;
osl : : File : : getSystemPathFromFileURL ( aUserInstallationURL , aUserInstallationPath ) ;
aDiagnosticMessage . append ( aErrorMsg ) ;
aDiagnosticMessage . append ( aUserInstallationPath ) ;
aMessage = MakeStartupErrorMessage (
aDiagnosticMessage . makeStringAndClear ( ) ) ;
FatalError ( aMessage ) ;
}
return ;
2001-08-07 10:25:00 +00:00
}
2005-11-11 11:29:30 +00:00
void Desktop : : retrieveCrashReporterState ( )
{
static const : : rtl : : OUString CFG_PACKAGE_RECOVERY = : : rtl : : OUString : : createFromAscii ( " org.openoffice.Office.Recovery/ " ) ;
static const : : rtl : : OUString CFG_PATH_CRASHREPORTER = : : rtl : : OUString : : createFromAscii ( " CrashReporter " ) ;
static const : : rtl : : OUString CFG_ENTRY_ENABLED = : : rtl : : OUString : : createFromAscii ( " Enabled " ) ;
css : : uno : : Reference < css : : lang : : XMultiServiceFactory > xSMGR = : : comphelper : : getProcessServiceFactory ( ) ;
sal_Bool bEnabled ( sal_True ) ;
if ( xSMGR . is ( ) )
{
css : : uno : : Any aVal = : : comphelper : : ConfigurationHelper : : readDirectKey (
xSMGR ,
CFG_PACKAGE_RECOVERY ,
CFG_PATH_CRASHREPORTER ,
CFG_ENTRY_ENABLED ,
: : comphelper : : ConfigurationHelper : : E_READONLY ) ;
aVal > > = bEnabled ;
}
_bCrashReporterEnabled = bEnabled ;
}
2009-12-03 10:37:54 +00:00
sal_Bool Desktop : : isUIOnSessionShutdownAllowed ( )
{
static const : : rtl : : OUString CFG_PACKAGE_RECOVERY = : : rtl : : OUString : : createFromAscii ( " org.openoffice.Office.Recovery/ " ) ;
static const : : rtl : : OUString CFG_PATH_SESSION = : : rtl : : OUString : : createFromAscii ( " SessionShutdown " ) ;
static const : : rtl : : OUString CFG_ENTRY_UIENABLED = : : rtl : : OUString : : createFromAscii ( " DocumentStoreUIEnabled " ) ;
css : : uno : : Reference < css : : lang : : XMultiServiceFactory > xSMGR = : : comphelper : : getProcessServiceFactory ( ) ;
sal_Bool bResult = sal_False ;
if ( xSMGR . is ( ) )
{
css : : uno : : Any aVal = : : comphelper : : ConfigurationHelper : : readDirectKey (
xSMGR ,
CFG_PACKAGE_RECOVERY ,
CFG_PATH_SESSION ,
CFG_ENTRY_UIENABLED ,
: : comphelper : : ConfigurationHelper : : E_READONLY ) ;
aVal > > = bResult ;
}
return bResult ;
}
2005-11-11 11:29:30 +00:00
//-----------------------------------------------
/** @short check if crash reporter feature is enabled or
disabled .
*/
sal_Bool Desktop : : isCrashReporterEnabled ( )
{
return _bCrashReporterEnabled ;
}
2004-11-26 13:49:05 +00:00
//-----------------------------------------------
/** @short check if recovery must be started or not.
@ param bCrashed [ boolean . . . out ! ]
the office crashed last times .
2005-04-18 13:43:08 +00:00
But may be there are no recovery data .
Usefull to trigger the error report tool without
showing the recovery UI .
2004-11-26 13:49:05 +00:00
2005-04-18 13:43:08 +00:00
@ param bRecoveryDataExists [ boolean . . . out ! ]
2004-11-26 13:49:05 +00:00
there exists some recovery data .
2005-04-18 13:43:08 +00:00
@ param bSessionDataExists [ boolean . . . out ! ]
there exists some session data .
Because the user may be logged out last time from it ' s
unix session . . .
2004-11-26 13:49:05 +00:00
*/
2005-04-18 13:43:08 +00:00
void impl_checkRecoveryState ( sal_Bool & bCrashed ,
sal_Bool & bRecoveryDataExists ,
sal_Bool & bSessionDataExists )
2004-11-26 13:49:05 +00:00
{
2005-11-11 11:29:30 +00:00
static const : : rtl : : OUString SERVICENAME_RECOVERYCORE = : : rtl : : OUString : : createFromAscii ( " com.sun.star.frame.AutoRecovery " ) ;
static const : : rtl : : OUString PROP_CRASHED = : : rtl : : OUString : : createFromAscii ( " Crashed " ) ;
static const : : rtl : : OUString PROP_EXISTSRECOVERY = : : rtl : : OUString : : createFromAscii ( " ExistsRecoveryData " ) ;
static const : : rtl : : OUString PROP_EXISTSSESSION = : : rtl : : OUString : : createFromAscii ( " ExistsSessionData " ) ;
static const : : rtl : : OUString CFG_PACKAGE_RECOVERY = : : rtl : : OUString : : createFromAscii ( " org.openoffice.Office.Recovery/ " ) ;
static const : : rtl : : OUString CFG_PATH_RECOVERYINFO = : : rtl : : OUString : : createFromAscii ( " RecoveryInfo " ) ;
2004-11-26 13:49:05 +00:00
2005-04-18 13:43:08 +00:00
bCrashed = sal_False ;
bRecoveryDataExists = sal_False ;
bSessionDataExists = sal_False ;
2004-11-26 13:49:05 +00:00
css : : uno : : Reference < css : : lang : : XMultiServiceFactory > xSMGR = : : comphelper : : getProcessServiceFactory ( ) ;
try
{
css : : uno : : Reference < css : : beans : : XPropertySet > xRecovery (
xSMGR - > createInstance ( SERVICENAME_RECOVERYCORE ) ,
css : : uno : : UNO_QUERY_THROW ) ;
2005-04-18 13:43:08 +00:00
xRecovery - > getPropertyValue ( PROP_CRASHED ) > > = bCrashed ;
xRecovery - > getPropertyValue ( PROP_EXISTSRECOVERY ) > > = bRecoveryDataExists ;
xRecovery - > getPropertyValue ( PROP_EXISTSSESSION ) > > = bSessionDataExists ;
2004-11-26 13:49:05 +00:00
}
catch ( const css : : uno : : Exception & ) { }
}
//-----------------------------------------------
/* @short start the recovery wizard.
@ param bEmergencySave
differs between EMERGENCY_SAVE and RECOVERY
*/
sal_Bool impl_callRecoveryUI ( sal_Bool bEmergencySave ,
2005-11-11 11:29:30 +00:00
sal_Bool bCrashed ,
sal_Bool bExistsRecoveryData )
2004-11-26 13:49:05 +00:00
{
static : : rtl : : OUString SERVICENAME_RECOVERYUI = : : rtl : : OUString : : createFromAscii ( " com.sun.star.comp.svx.RecoveryUI " ) ;
static : : rtl : : OUString SERVICENAME_URLPARSER = : : rtl : : OUString : : createFromAscii ( " com.sun.star.util.URLTransformer " ) ;
static : : rtl : : OUString COMMAND_EMERGENCYSAVE = : : rtl : : OUString : : createFromAscii ( " vnd.sun.star.autorecovery:/doEmergencySave " ) ;
static : : rtl : : OUString COMMAND_RECOVERY = : : rtl : : OUString : : createFromAscii ( " vnd.sun.star.autorecovery:/doAutoRecovery " ) ;
static : : rtl : : OUString COMMAND_CRASHREPORT = : : rtl : : OUString : : createFromAscii ( " vnd.sun.star.autorecovery:/doCrashReport " ) ;
css : : uno : : Reference < css : : lang : : XMultiServiceFactory > xSMGR = : : comphelper : : getProcessServiceFactory ( ) ;
css : : uno : : Reference < css : : frame : : XSynchronousDispatch > xRecoveryUI (
xSMGR - > createInstance ( SERVICENAME_RECOVERYUI ) ,
css : : uno : : UNO_QUERY_THROW ) ;
css : : uno : : Reference < css : : util : : XURLTransformer > xURLParser (
xSMGR - > createInstance ( SERVICENAME_URLPARSER ) ,
css : : uno : : UNO_QUERY_THROW ) ;
css : : util : : URL aURL ;
if ( bEmergencySave )
aURL . Complete = COMMAND_EMERGENCYSAVE ;
else
{
if ( bExistsRecoveryData )
aURL . Complete = COMMAND_RECOVERY ;
else
2005-11-11 11:29:30 +00:00
if ( bCrashed & & Desktop : : isCrashReporterEnabled ( ) )
2004-11-26 13:49:05 +00:00
aURL . Complete = COMMAND_CRASHREPORT ;
}
sal_Bool bRet = sal_False ;
2005-11-11 11:29:30 +00:00
if ( aURL . Complete . getLength ( ) > 0 )
{
xURLParser - > parseStrict ( aURL ) ;
css : : uno : : Any aRet = xRecoveryUI - > dispatchWithReturnValue ( aURL , css : : uno : : Sequence < css : : beans : : PropertyValue > ( ) ) ;
aRet > > = bRet ;
}
2004-11-26 13:49:05 +00:00
return bRet ;
}
2003-06-10 13:37:31 +00:00
/*
* Save all open documents so they will be reopened
* the next time the application ist started
*
* returns sal_True if at least one document could be saved . . .
*
*/
2001-07-17 07:34:12 +00:00
2003-07-22 07:26:21 +00:00
sal_Bool Desktop : : _bTasksSaved = sal_False ;
2006-10-12 13:03:59 +00:00
sal_Bool Desktop : : SaveTasks ( )
2003-06-10 13:37:31 +00:00
{
2004-11-26 13:49:05 +00:00
return impl_callRecoveryUI (
sal_True , // sal_True => force emergency save
sal_False , // 2. and 3. param not used if 1. = true!
sal_False ) ;
2003-06-10 13:37:31 +00:00
}
2008-12-15 07:56:35 +00:00
# ifdef MACOSX
static void DoRestart ( )
{
oslProcess process ;
oslProcessError error ;
OUString sExecutableFile ;
osl_getExecutableFile ( & sExecutableFile . pData ) ;
error = osl_executeProcess (
sExecutableFile . pData ,
NULL ,
0 ,
0 ,
NULL ,
NULL ,
NULL ,
0 ,
& process
) ;
}
# endif
2003-06-10 13:37:31 +00:00
USHORT Desktop : : Exception ( USHORT nError )
{
// protect against recursive calls
static BOOL bInException = FALSE ;
sal_uInt16 nOldMode = Application : : GetSystemWindowMode ( ) ;
Application : : SetSystemWindowMode ( nOldMode & ~ SYSTEMWINDOW_MODE_NOAUTOMODE ) ;
2004-01-06 17:37:50 +00:00
Application : : SetDefDialogParent ( NULL ) ;
2003-06-10 13:37:31 +00:00
if ( bInException )
{
String aDoubleExceptionString ;
Application : : Abort ( aDoubleExceptionString ) ;
2001-07-17 07:34:12 +00:00
}
2003-06-10 13:37:31 +00:00
bInException = TRUE ;
CommandLineArgs * pArgs = GetCommandLineArgs ( ) ;
2004-12-02 08:14:48 +00:00
// save all modified documents ... if it's allowed doing so.
2005-07-08 08:30:10 +00:00
sal_Bool bRestart = sal_False ;
sal_Bool bAllowRecoveryAndSessionManagement = (
2006-05-08 13:55:01 +00:00
( ! pArgs - > IsNoRestore ( ) ) & & // some use cases of office must work without recovery
( ! pArgs - > IsHeadless ( ) ) & &
( ! pArgs - > IsServer ( ) ) & &
( ( nError & EXC_MAJORTYPE ) ! = EXC_DISPLAY ) & & // recovery cant work without UI ... but UI layer seams to be the reason for this crash
( Application : : IsInExecute ( ) ) // crashes during startup and shutdown should be ignored (they indicates a corrupt installation ...)
2005-07-08 08:30:10 +00:00
) ;
2006-05-08 13:55:01 +00:00
if ( bAllowRecoveryAndSessionManagement )
2006-10-12 13:03:59 +00:00
bRestart = SaveTasks ( ) ;
2001-07-17 07:34:12 +00:00
// because there is no method to flush the condiguration data, we must dispose the ConfigManager
2004-11-26 13:49:05 +00:00
Reference < XFlushable > xCFGFlush ( : : utl : : ConfigManager : : GetConfigManager ( ) - > GetConfigurationProvider ( ) , UNO_QUERY ) ;
if ( xCFGFlush . is ( ) )
{
xCFGFlush - > flush ( ) ;
}
else
{
Reference < XComponent > xCFGDispose ( : : utl : : ConfigManager : : GetConfigManager ( ) - > GetConfigurationProvider ( ) , UNO_QUERY ) ;
if ( xCFGDispose . is ( ) )
xCFGDispose - > dispose ( ) ;
}
2001-07-17 07:34:12 +00:00
switch ( nError & EXC_MAJORTYPE )
{
case EXC_RSCNOTLOADED :
{
String aResExceptionString ;
Application : : Abort ( aResExceptionString ) ;
break ;
}
case EXC_SYSOBJNOTCREATED :
{
String aSysResExceptionString ;
Application : : Abort ( aSysResExceptionString ) ;
break ;
}
default :
{
2010-03-01 16:48:19 +01:00
if ( m_pLockfile ! = NULL ) {
m_pLockfile - > clean ( ) ;
2003-03-25 12:52:54 +00:00
}
2004-11-26 13:49:05 +00:00
if ( bRestart )
2001-07-17 07:34:12 +00:00
{
OfficeIPCThread : : DisableOfficeIPCThread ( ) ;
if ( pSignalHandler )
DELETEZ ( pSignalHandler ) ;
2008-12-15 07:56:35 +00:00
# ifdef MACOSX
DoRestart ( ) ;
# endif
2004-11-26 13:49:05 +00:00
_exit ( ExitHelper : : E_CRASH_WITH_RESTART ) ;
2001-08-27 07:03:26 +00:00
}
else
{
2010-03-01 16:48:19 +01:00
Application : : Abort ( String ( ) ) ;
2001-07-17 07:34:12 +00:00
}
break ;
}
}
2010-03-01 16:48:19 +01:00
OSL_ASSERT ( false ) ; // unreachable
2001-09-27 09:51:05 +00:00
return 0 ;
2001-07-16 11:55:47 +00:00
}
void Desktop : : AppEvent ( const ApplicationEvent & rAppEvent )
{
HandleAppEvent ( rAppEvent ) ;
2000-09-18 15:18:56 +00:00
}
void Desktop : : Main ( )
{
2001-08-07 10:25:00 +00:00
RTL_LOGFILE_CONTEXT ( aLog , " desktop (cd100003) ::Desktop::Main " ) ;
2004-09-17 12:07:23 +00:00
// Remember current context object
com : : sun : : star : : uno : : ContextLayer layer (
com : : sun : : star : : uno : : getCurrentContext ( ) ) ;
2004-11-09 14:15:02 +00:00
BootstrapError eError = GetBootstrapError ( ) ;
2005-03-18 09:41:15 +00:00
if ( eError ! = BE_OK )
2003-11-07 13:51:04 +00:00
{
2005-03-18 09:41:15 +00:00
HandleBootstrapErrors ( eError ) ;
return ;
}
2004-09-17 12:07:23 +00:00
2005-10-24 17:33:51 +00:00
BootstrapStatus eStatus = GetBootstrapStatus ( ) ;
if ( eStatus = = BS_TERMINATE ) {
return ;
}
2005-03-18 09:41:15 +00:00
// Detect desktop environment - need to do this as early as possible
com : : sun : : star : : uno : : setCurrentContext (
new DesktopContext ( com : : sun : : star : : uno : : getCurrentContext ( ) ) ) ;
2003-11-07 13:51:04 +00:00
2005-03-18 09:41:15 +00:00
CommandLineArgs * pCmdLineArgs = GetCommandLineArgs ( ) ;
2004-08-20 12:04:13 +00:00
2005-03-18 09:41:15 +00:00
// setup configuration error handling
ConfigurationErrorHandler aConfigErrHandler ;
if ( ! ShouldSuppressUI ( pCmdLineArgs ) )
aConfigErrHandler . activate ( ) ;
2005-09-30 09:27:37 +00:00
ResMgr : : SetReadStringHook ( ReplaceStringHookProc ) ;
2005-03-18 09:41:15 +00:00
// Startup screen
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " desktop (lo119109) Desktop::Main { OpenSplashScreen " ) ;
OpenSplashScreen ( ) ;
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " desktop (lo119109) Desktop::Main } OpenSplashScreen " ) ;
{
2004-07-23 10:20:30 +00:00
UserInstall : : UserInstallError instErr_fin = UserInstall : : finalize ( ) ;
2005-10-24 17:33:51 +00:00
if ( instErr_fin ! = UserInstall : : E_None )
2003-11-07 13:51:04 +00:00
{
2004-07-23 10:20:30 +00:00
OSL_ENSURE ( sal_False , " userinstall failed " ) ;
2006-03-24 12:51:32 +00:00
if ( instErr_fin = = UserInstall : : E_NoDiskSpace )
HandleBootstrapErrors ( BE_USERINSTALL_NOTENOUGHDISKSPACE ) ;
else if ( instErr_fin = = UserInstall : : E_NoWriteAccess )
HandleBootstrapErrors ( BE_USERINSTALL_NOWRITEACCESS ) ;
else
HandleBootstrapErrors ( BE_USERINSTALL_FAILED ) ;
2004-07-23 10:20:30 +00:00
return ;
2003-11-07 13:51:04 +00:00
}
// refresh path information
utl : : Bootstrap : : reloadData ( ) ;
2005-05-13 12:04:56 +00:00
SetSplashScreenProgress ( 25 ) ;
2003-11-07 13:51:04 +00:00
}
2001-07-10 04:29:45 +00:00
2004-07-23 10:20:30 +00:00
Reference < XMultiServiceFactory > xSMgr =
: : comphelper : : getProcessServiceFactory ( ) ;
2007-11-26 13:11:13 +00:00
std : : auto_ptr < SvtLanguageOptions > pLanguageOptions ;
std : : auto_ptr < SvtPathOptions > pPathOptions ;
2004-07-23 10:20:30 +00:00
2009-09-18 10:15:03 +00:00
Reference < css : : document : : XEventListener > xGlobalBroadcaster ;
2004-07-23 10:20:30 +00:00
try
{
RegisterServices ( xSMgr ) ;
2005-05-13 12:04:56 +00:00
//SetSplashScreenProgress(15);
2003-03-25 12:52:54 +00:00
# ifndef UNX
2004-07-23 10:20:30 +00:00
if ( pCmdLineArgs - > IsHelp ( ) ) {
displayCmdlineHelp ( ) ;
return ;
}
2003-03-25 12:52:54 +00:00
# endif
2004-07-23 10:20:30 +00:00
// check user installation directory for lockfile so we can be sure
// there is no other instance using our data files from a remote host
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " desktop (lo119109) Desktop::Main -> Lockfile " ) ;
m_pLockfile = new Lockfile ;
if ( ! pCmdLineArgs - > IsInvisible ( ) & & ! pCmdLineArgs - > IsNoLockcheck ( ) & & ! m_pLockfile - > check ( Lockfile_execWarning ) ) {
// Lockfile exists, and user clicked 'no'
return ;
}
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " desktop (lo119109) Desktop::Main <- Lockfile " ) ;
2002-08-16 13:14:03 +00:00
2004-07-23 10:20:30 +00:00
// check if accessibility is enabled but not working and allow to quit
2005-02-16 15:37:23 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " { GetEnableATToolSupport " ) ;
2004-07-23 10:20:30 +00:00
if ( Application : : GetSettings ( ) . GetMiscSettings ( ) . GetEnableATToolSupport ( ) )
{
BOOL bQuitApp ;
2003-04-11 17:02:32 +00:00
2004-07-23 10:20:30 +00:00
if ( ! InitAccessBridge ( true , bQuitApp ) )
if ( bQuitApp )
return ;
}
2005-02-16 15:37:23 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " } GetEnableATToolSupport " ) ;
2003-04-11 17:02:32 +00:00
2004-12-10 17:39:02 +00:00
// terminate if requested...
2004-07-23 10:20:30 +00:00
if ( pCmdLineArgs - > IsTerminateAfterInit ( ) ) return ;
2000-09-18 15:18:56 +00:00
2002-11-01 13:49:58 +00:00
2004-07-23 10:20:30 +00:00
// Read the common configuration items for optimization purpose
if ( ! InitializeConfiguration ( ) ) return ;
2002-11-01 13:49:58 +00:00
2005-05-13 12:04:56 +00:00
//SetSplashScreenProgress(20);
2002-11-01 13:49:58 +00:00
2005-11-11 11:29:30 +00:00
// set static variable to enabled/disable crash reporter
retrieveCrashReporterState ( ) ;
if ( ! isCrashReporterEnabled ( ) )
{
osl_setErrorReporting ( sal_False ) ;
// disable stack trace feature
}
2004-07-23 10:20:30 +00:00
// create title string
sal_Bool bCheckOk = sal_False ;
2004-07-26 14:13:19 +00:00
: : com : : sun : : star : : lang : : Locale aLocale ;
2004-07-23 10:20:30 +00:00
String aMgrName = String : : CreateFromAscii ( " iso " ) ;
2004-07-26 14:13:19 +00:00
ResMgr * pLabelResMgr = ResMgr : : SearchCreateResMgr ( U2S ( aMgrName ) , aLocale ) ;
2004-07-23 10:20:30 +00:00
if ( ! pLabelResMgr )
{
// no "iso" resource -> search for "ooo" resource
aMgrName = String : : CreateFromAscii ( " ooo " ) ;
2004-07-26 14:13:19 +00:00
pLabelResMgr = ResMgr : : SearchCreateResMgr ( U2S ( aMgrName ) , aLocale ) ;
2004-07-23 10:20:30 +00:00
}
2007-04-26 07:21:55 +00:00
String aTitle = pLabelResMgr ? String ( ResId ( RID_APPTITLE , * pLabelResMgr ) ) : String ( ) ;
2004-07-23 10:20:30 +00:00
delete pLabelResMgr ;
2009-10-26 15:10:09 +01:00
/*
// locale and UI locale in AppSettings are now retrieved from configuration or system directly via SvtSysLocale
// no reason to set while starting
2005-05-24 12:39:27 +00:00
// set UI language and locale
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " { set locale settings " ) ;
//LanguageSelection langselect;
OUString aUILocaleString = LanguageSelection : : getLanguageString ( ) ;
Locale aUILocale = LanguageSelection : : IsoStringToLocale ( aUILocaleString ) ;
2009-10-16 00:05:16 +02:00
LanguageType eLanguage = SvtSysLocale ( ) . GetLanguage ( ) ;
2005-05-24 12:39:27 +00:00
// #i39040#, do not call anything between GetSettings and SetSettings that might have
// a side effect on the settings (like, eg, SvtSysLocaleOptions().GetLocaleLanguageType(),
// which changes the MiscSettings !!! )
AllSettings aSettings ( Application : : GetSettings ( ) ) ;
aSettings . SetUILocale ( aUILocale ) ;
aSettings . SetLanguage ( eLanguage ) ;
Application : : SetSettings ( aSettings ) ;
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " } set locale settings " ) ;
2009-10-26 15:10:09 +01:00
*/
2005-05-24 12:39:27 +00:00
2004-07-23 10:20:30 +00:00
// Check for StarOffice/Suite specific extensions runs also with OpenOffice installation sets
OUString aTitleString ( aTitle ) ;
bCheckOk = CheckInstallation ( aTitleString ) ;
if ( ! bCheckOk )
return ;
else
aTitle = aTitleString ;
2003-03-25 12:52:54 +00:00
2009-07-10 14:03:42 +02:00
# ifdef DBG_UTIL
2004-07-23 10:20:30 +00:00
//include version ID in non product builds
: : rtl : : OUString aDefault ;
aTitle + = DEFINE_CONST_UNICODE ( " [ " ) ;
String aVerId ( utl : : Bootstrap : : getBuildIdData ( aDefault ) ) ;
aTitle + = aVerId ;
aTitle + = ' ] ' ;
# endif
2003-03-25 12:52:54 +00:00
2004-07-23 10:20:30 +00:00
SetDisplayName ( aTitle ) ;
2005-05-13 12:04:56 +00:00
// SetSplashScreenProgress(30);
2002-05-13 08:39:57 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " { create SvtPathOptions and SvtLanguageOptions " ) ;
2007-11-26 13:11:13 +00:00
pPathOptions . reset ( new SvtPathOptions ) ;
2005-05-13 12:04:56 +00:00
// SetSplashScreenProgress(40);
2006-01-27 15:20:05 +00:00
// pLanguageOptions = new SvtLanguageOptions(sal_True);
2005-05-13 12:04:56 +00:00
// SetSplashScreenProgress(45);
2002-05-13 08:39:57 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " } create SvtPathOptions and SvtLanguageOptions " ) ;
2001-07-16 11:55:47 +00:00
2003-09-29 13:56:09 +00:00
// Check special env variable #111015#
std : : vector < String > aUnrestrictedFolders ;
svt : : getUnrestrictedFolders ( aUnrestrictedFolders ) ;
if ( aUnrestrictedFolders . size ( ) > 0 )
{
// Set different working directory. The first entry is
// the new work path.
String aWorkPath = aUnrestrictedFolders [ 0 ] ;
SvtPathOptions ( ) . SetWorkPath ( aWorkPath ) ;
}
2004-06-25 12:10:20 +00:00
// create service for loadin SFX (still needed in startup)
2009-09-18 10:15:03 +00:00
xGlobalBroadcaster = Reference < css : : document : : XEventListener >
( xSMgr - > createInstance (
2004-06-25 12:10:20 +00:00
DEFINE_CONST_UNICODE ( " com.sun.star.frame.GlobalEventBroadcaster " ) ) , UNO_QUERY ) ;
// initialize test-tool library (if available)
2005-02-16 15:37:23 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " { tools::InitTestToolLib " ) ;
2004-06-25 12:10:20 +00:00
tools : : InitTestToolLib ( ) ;
2005-02-16 15:37:23 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " } tools::InitTestToolLib " ) ;
2004-06-25 12:10:20 +00:00
2010-04-20 07:59:05 +02:00
// Check if bundled or shared extensions were added /removed
// and process those extensions (has to be done before checking
// the extension dependencies!
SynchronizeExtensionRepositories ( ) ;
2009-08-06 09:32:55 +00:00
bool bAbort = CheckExtensionDependencies ( ) ;
if ( bAbort )
return ;
2008-09-26 14:32:08 +00:00
// First Start Wizard allowed ?
if ( ! pCmdLineArgs - > IsNoFirstStartWizard ( ) )
2005-03-11 10:01:09 +00:00
{
2008-09-26 14:32:08 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " { FirstStartWizard " ) ;
if ( IsFirstStartWizardNeeded ( ) )
2005-03-11 10:01:09 +00:00
{
2009-10-06 07:38:24 +02:00
: : utl : : RegOptions ( ) . removeReminder ( ) ; // remove patch registration reminder
2008-09-26 14:32:08 +00:00
Reference < XJob > xFirstStartJob ( xSMgr - > createInstance (
DEFINE_CONST_UNICODE ( " com.sun.star.comp.desktop.FirstStart " ) ) , UNO_QUERY ) ;
if ( xFirstStartJob . is ( ) )
2008-04-15 09:26:57 +00:00
{
2008-09-26 14:32:08 +00:00
sal_Bool bDone = sal_False ;
Sequence < NamedValue > lArgs ( 2 ) ;
lArgs [ 0 ] . Name = : : rtl : : OUString : : createFromAscii ( " LicenseNeedsAcceptance " ) ;
lArgs [ 0 ] . Value < < = LicenseNeedsAcceptance ( ) ;
lArgs [ 1 ] . Name = : : rtl : : OUString : : createFromAscii ( " LicensePath " ) ;
lArgs [ 1 ] . Value < < = GetLicensePath ( ) ;
xFirstStartJob - > execute ( lArgs ) > > = bDone ;
if ( ! bDone )
{
return ;
}
2005-03-11 10:01:09 +00:00
}
}
2008-09-26 14:32:08 +00:00
else if ( RegistrationPage : : hasReminderDateCome ( ) )
RegistrationPage : : executeSingleMode ( ) ;
2008-02-27 09:28:25 +00:00
2008-09-26 14:32:08 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " } FirstStartWizard " ) ;
}
2004-11-15 15:01:54 +00:00
2006-01-27 15:20:05 +00:00
// keep a language options instance...
2007-11-26 13:11:13 +00:00
pLanguageOptions . reset ( new SvtLanguageOptions ( sal_True ) ) ;
2006-01-27 15:20:05 +00:00
2005-02-02 12:45:19 +00:00
if ( xGlobalBroadcaster . is ( ) )
{
css : : document : : EventObject aEvent ;
aEvent . EventName = : : rtl : : OUString : : createFromAscii ( " OnStartApp " ) ;
xGlobalBroadcaster - > notifyEvent ( aEvent ) ;
}
2004-06-25 12:10:20 +00:00
SetSplashScreenProgress ( 50 ) ;
// Backing Component
2004-11-26 13:49:05 +00:00
sal_Bool bCrashed = sal_False ;
sal_Bool bExistsRecoveryData = sal_False ;
2005-04-18 13:43:08 +00:00
sal_Bool bExistsSessionData = sal_False ;
2005-02-16 15:37:23 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " { impl_checkRecoveryState " ) ;
2005-04-18 13:43:08 +00:00
impl_checkRecoveryState ( bCrashed , bExistsRecoveryData , bExistsSessionData ) ;
2005-02-16 15:37:23 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " } impl_checkRecoveryState " ) ;
2004-11-26 13:49:05 +00:00
if (
2005-02-16 15:37:23 +00:00
( pCmdLineArgs - > IsEmptyOrAcceptOnly ( ) ) & &
2004-11-26 13:49:05 +00:00
( SvtModuleOptions ( ) . IsModuleInstalled ( SvtModuleOptions : : E_SSTARTMODULE ) ) & &
2005-04-18 13:43:08 +00:00
( ! bExistsRecoveryData ) & &
2008-03-05 16:47:51 +00:00
( ! bExistsSessionData ) & &
( ! Application : : AnyInput ( INPUT_APPEVENT ) )
2004-11-26 13:49:05 +00:00
)
2003-04-24 12:35:03 +00:00
{
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " { create BackingComponent " ) ;
Reference < XFrame > xDesktopFrame ( xSMgr - > createInstance (
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.frame.Desktop " ) ) ) , UNO_QUERY ) ;
if ( xDesktopFrame . is ( ) )
{
2005-05-13 12:04:56 +00:00
// SetSplashScreenProgress(60);
2003-04-24 12:35:03 +00:00
Reference < XFrame > xBackingFrame ;
Reference < : : com : : sun : : star : : awt : : XWindow > xContainerWindow ;
xBackingFrame = xDesktopFrame - > findFrame ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " _blank " ) ) , 0 ) ;
if ( xBackingFrame . is ( ) )
xContainerWindow = xBackingFrame - > getContainerWindow ( ) ;
if ( xContainerWindow . is ( ) )
{
CWS-TOOLING: integrate CWS dba32j
2009-11-26 09:30:10 +0100 msc r277648 : #100000 fix urgent testscript error
2009-11-25 10:27:56 +0100 msc r277625 : #i100000 fix urgent testscript error
2009-11-17 22:16:46 +0100 fs r277544 : CWS-TOOLING: rebase CWS dba32j to branches/OOO320@277531 (milestone: OOO320:m5)
2009-11-17 14:26:47 +0100 fs r277535 : ooops, didn't mean to commit this uncommented line
2009-11-14 20:50:29 +0100 fs r277505 : add a --disable-pango switch to SM's configure options, and add a patch which makes certain code respect it (well, respect it better than currently, by not using some pango_x_* functions, which are not always available, even when pango itself is present)
2009-11-14 20:47:41 +0100 fs r277504 : spelling
2009-11-13 14:04:00 +0100 fs r277502 : #i100764# (commit approved by ab@openoffice.org): getModelFromBasic: do not start with the parent's parent when looking for ThisComponent, but walk up the anchestor chain, starting with the immediate parent
2009-11-13 11:04:15 +0100 fs r277496 : #i100764# better heuristics for determining whether or not to participate in the ThisComponent game
2009-11-13 11:02:30 +0100 fs r277495 : #i100764# set the WB_EXT_DOCUMENT style at the backing component's container window, when creating it without the TaskCreator (which would normally do this)
2009-11-11 13:49:11 +0100 fs r277452 : #i106816#
2009-11-11 13:48:53 +0100 fs r277451 : fix the CREATETARBAL target, which is expected to create the zips used as prebuilts. The *inc.zip missed the NSS files in case NSS was built externally
2009-11-11 12:15:34 +0100 fs r277449 : update ignore list
2009-11-11 12:09:23 +0100 fs r277448 : add a link to the Mozilla build tools download location
2009-11-11 12:07:16 +0100 fs r277447 : add a link to the Mozilla build tools download location
2009-11-06 16:23:12 +0100 fs r277393 : #i106643#
2009-11-03 23:20:29 +0100 fs r277328 : #i106574#
reverted the recent fix for issue #i105235#, and implemented a better one.
2009-11-02 12:59:48 +0100 fs r277294 : #i106550# errorOccured: also display the error when we're not in a nested form action - form actions are allowed to be triggered by other instances as well
2009-12-01 09:53:35 +00:00
// set the WB_EXT_DOCUMENT style. Normally, this is done by the TaskCreator service when a "_blank"
// frame/window is created. Since we do not use the TaskCreator here, we need to mimic its behavior,
// otherwise documents loaded into this frame will later on miss functionality depending on the style.
Window * pContainerWindow = VCLUnoHelper : : GetWindow ( xContainerWindow ) ;
OSL_ENSURE ( pContainerWindow , " Desktop::Main: no implementation access to the frame's container window! " ) ;
pContainerWindow - > SetExtendedStyle ( pContainerWindow - > GetExtendedStyle ( ) | WB_EXT_DOCUMENT ) ;
2005-05-13 12:04:56 +00:00
SetSplashScreenProgress ( 75 ) ;
2003-04-24 12:35:03 +00:00
Sequence < Any > lArgs ( 1 ) ;
lArgs [ 0 ] < < = xContainerWindow ;
Reference < XController > xBackingComp (
2004-02-25 17:16:12 +00:00
xSMgr - > createInstanceWithArguments ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.frame.StartModule " ) ) , lArgs ) ,
2003-04-24 12:35:03 +00:00
UNO_QUERY ) ;
2005-05-13 12:04:56 +00:00
// SetSplashScreenProgress(80);
2003-04-24 12:35:03 +00:00
if ( xBackingComp . is ( ) )
{
Reference < : : com : : sun : : star : : awt : : XWindow > xBackingWin ( xBackingComp , UNO_QUERY ) ;
// Attention: You MUST(!) call setComponent() before you call attachFrame().
// Because the backing component set the property "IsBackingMode" of the frame
// to true inside attachFrame(). But setComponent() reset this state everytimes ...
xBackingFrame - > setComponent ( xBackingWin , xBackingComp ) ;
2005-05-13 12:04:56 +00:00
SetSplashScreenProgress ( 100 ) ;
2003-04-24 12:35:03 +00:00
xBackingComp - > attachFrame ( xBackingFrame ) ;
2004-06-25 12:10:20 +00:00
CloseSplashScreen ( ) ;
2003-04-24 12:35:03 +00:00
xContainerWindow - > setVisible ( sal_True ) ;
}
}
}
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " } create BackingComponent " ) ;
}
2003-03-25 12:52:54 +00:00
}
catch ( com : : sun : : star : : lang : : WrappedTargetException & wte )
{
com : : sun : : star : : uno : : Exception te ;
wte . TargetException > > = te ;
FatalError ( MakeStartupConfigAccessErrorMessage ( wte . Message + te . Message ) ) ;
return ;
}
catch ( com : : sun : : star : : uno : : Exception & e )
{
FatalError ( MakeStartupErrorMessage ( e . Message ) ) ;
return ;
}
/*
catch ( . . . )
{
FatalError ( MakeStartupErrorMessage (
OUString : : createFromAscii (
" Unknown error during startup (Office wrapper service). \n Installation could be damaged. " ) ) ) ;
return ;
}
*/
2005-05-13 12:04:56 +00:00
// SetSplashScreenProgress(55);
2004-02-03 19:03:09 +00:00
SvtFontSubstConfig ( ) . Apply ( ) ;
SvtTabAppearanceCfg aAppearanceCfg ;
2009-01-21 15:28:14 +00:00
aAppearanceCfg . SetInitialized ( ) ;
2004-02-03 19:03:09 +00:00
aAppearanceCfg . SetApplicationDefaults ( this ) ;
SvtAccessibilityOptions aOptions ;
aOptions . SetVCLSettings ( ) ;
2005-05-13 12:04:56 +00:00
// SetSplashScreenProgress(60);
2004-02-03 19:03:09 +00:00
Application : : SetFilterHdl ( LINK ( this , Desktop , ImplInitFilterHdl ) ) ;
2003-03-25 12:52:54 +00:00
sal_Bool bTerminateRequested = sal_False ;
2002-10-21 04:36:19 +00:00
2003-03-25 12:52:54 +00:00
// Preload function depends on an initialized sfx application!
2005-05-13 12:04:56 +00:00
SetSplashScreenProgress ( 75 ) ;
2002-10-21 04:36:19 +00:00
2004-06-25 16:30:04 +00:00
sal_Bool bUseSystemFileDialog ( sal_True ) ;
2003-03-25 12:52:54 +00:00
if ( pCmdLineArgs - > IsHeadless ( ) )
{
// Ensure that we use not the system file dialogs as
// headless mode relies on Application::EnableHeadlessMode()
// which does only work for VCL dialogs!!
SvtMiscOptions aMiscOptions ;
bUseSystemFileDialog = aMiscOptions . UseSystemFileDialog ( ) ;
aMiscOptions . SetUseSystemFileDialog ( sal_False ) ;
}
2001-07-16 11:55:47 +00:00
2003-03-25 12:52:54 +00:00
// use system window dialogs
Application : : SetSystemWindowMode ( SYSTEMWINDOW_MODE_DIALOG ) ;
2001-07-16 11:55:47 +00:00
2005-05-13 12:04:56 +00:00
// SetSplashScreenProgress(80);
2001-07-16 11:55:47 +00:00
2010-01-13 17:16:16 +01:00
if ( ! bTerminateRequested & & ! pCmdLineArgs - > IsInvisible ( ) & &
! pCmdLineArgs - > IsNoQuickstart ( ) )
2003-03-25 12:52:54 +00:00
InitializeQuickstartMode ( xSMgr ) ;
2001-07-16 11:55:47 +00:00
2004-07-23 10:20:30 +00:00
RTL_LOGFILE_CONTEXT ( aLog2 , " desktop (cd100003) createInstance com.sun.star.frame.Desktop " ) ;
2004-01-06 17:37:50 +00:00
try
2003-03-25 12:52:54 +00:00
{
2004-01-06 17:37:50 +00:00
Reference < XDesktop > xDesktop ( xSMgr - > createInstance (
OUString ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.frame.Desktop " ) ) ) , UNO_QUERY ) ;
if ( xDesktop . is ( ) )
xDesktop - > addTerminateListener ( new OfficeIPCThreadController ) ;
SetSplashScreenProgress ( 100 ) ;
}
catch ( com : : sun : : star : : uno : : Exception & e )
{
FatalError ( MakeStartupErrorMessage ( e . Message ) ) ;
return ;
2003-03-25 12:52:54 +00:00
}
2004-01-06 17:37:50 +00:00
/*
catch ( . . . )
{
FatalError ( MakeStartupErrorMessage (
OUString : : createFromAscii (
" Unknown error during startup (TD/Desktop service). \n Installation could be damaged. " ) ) ) ;
return ;
}
*/
2001-07-16 11:55:47 +00:00
2003-03-25 12:52:54 +00:00
// Release solar mutex just before we wait for our client to connect
int nAcquireCount = 0 ;
: : vos : : IMutex & rMutex = Application : : GetSolarMutex ( ) ;
if ( rMutex . tryToAcquire ( ) )
nAcquireCount = Application : : ReleaseSolarMutex ( ) - 1 ;
2001-07-16 11:55:47 +00:00
2003-03-25 12:52:54 +00:00
// Post user event to startup first application component window
// We have to send this OpenClients message short before execute() to
// minimize the risk that this message overtakes type detection contruction!!
Application : : PostUserEvent ( LINK ( this , Desktop , OpenClients_Impl ) ) ;
2001-07-16 11:55:47 +00:00
2003-03-25 12:52:54 +00:00
// Post event to enable acceptors
Application : : PostUserEvent ( LINK ( this , Desktop , EnableAcceptors_Impl ) ) ;
2001-07-16 11:55:47 +00:00
2004-08-20 12:04:13 +00:00
// The configuration error handler currently is only for startup
aConfigErrHandler . deactivate ( ) ;
// Acquire solar mutex just before we enter our message loop
2003-03-25 12:52:54 +00:00
if ( nAcquireCount )
Application : : AcquireSolarMutex ( nAcquireCount ) ;
2001-07-16 11:55:47 +00:00
2003-03-25 12:52:54 +00:00
// call Application::Execute to process messages in vcl message loop
2005-04-22 10:28:35 +00:00
RTL_LOGFILE_PRODUCT_TRACE ( " PERFORMANCE - enter Application::Execute() " ) ;
2004-02-03 19:03:09 +00:00
2010-05-10 17:35:24 +02:00
Reference < : : com : : sun : : star : : task : : XRestartManager > xRestartManager ;
2004-07-23 10:20:30 +00:00
try
{
2004-11-09 13:04:03 +00:00
// The JavaContext contains an interaction handler which is used when
// the creation of a Java Virtual Machine fails
2006-10-12 13:03:59 +00:00
com : : sun : : star : : uno : : ContextLayer layer2 (
2005-07-07 12:19:39 +00:00
new svt : : JavaContext ( com : : sun : : star : : uno : : getCurrentContext ( ) ) ) ;
2004-11-09 13:04:03 +00:00
2010-05-10 17:35:24 +02:00
: : comphelper : : ComponentContext aContext ( xSMgr ) ;
xRestartManager . set ( aContext . getSingleton ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.task.OfficeRestartManager " ) ) ) , UNO_QUERY ) ;
if ( ! xRestartManager . is ( ) | | ! xRestartManager - > isRestartRequested ( sal_True ) )
Execute ( ) ;
2004-07-23 10:20:30 +00:00
}
catch ( const com : : sun : : star : : document : : CorruptedFilterConfigurationException & exFilterCfg )
{
2009-01-02 15:26:18 +00:00
OfficeIPCThread : : SetDowning ( ) ;
2004-07-23 10:20:30 +00:00
FatalError ( MakeStartupErrorMessage ( exFilterCfg . Message ) ) ;
2007-07-18 08:03:37 +00:00
}
catch ( const com : : sun : : star : : configuration : : CorruptedConfigurationException & exAnyCfg )
{
2009-01-02 15:26:18 +00:00
OfficeIPCThread : : SetDowning ( ) ;
2007-07-18 08:03:37 +00:00
FatalError ( MakeStartupErrorMessage ( exAnyCfg . Message ) ) ;
2004-07-23 10:20:30 +00:00
}
2002-10-21 04:36:19 +00:00
2010-05-10 17:35:24 +02:00
// check whether the shutdown is caused by restart
sal_Bool bRestartRequested = ( xRestartManager . is ( ) & & xRestartManager - > isRestartRequested ( sal_True ) ) ;
2009-09-18 10:15:03 +00:00
if ( xGlobalBroadcaster . is ( ) )
{
css : : document : : EventObject aEvent ;
aEvent . EventName = : : rtl : : OUString : : createFromAscii ( " OnCloseApp " ) ;
xGlobalBroadcaster - > notifyEvent ( aEvent ) ;
}
2004-02-03 19:03:09 +00:00
delete pResMgr ;
2003-03-25 12:52:54 +00:00
// Restore old value
if ( pCmdLineArgs - > IsHeadless ( ) )
SvtMiscOptions ( ) . SetUseSystemFileDialog ( bUseSystemFileDialog ) ;
2001-07-16 11:55:47 +00:00
2003-03-25 12:52:54 +00:00
// remove temp directory
RemoveTemporaryDirectory ( ) ;
2009-12-18 16:06:10 +01:00
// The acceptors in the AcceptorMap must be released (in DeregisterServices)
// with the solar mutex unlocked, to avoid deadlock:
nAcquireCount = Application : : ReleaseSolarMutex ( ) ;
2003-03-25 12:52:54 +00:00
DeregisterServices ( ) ;
2009-12-18 16:06:10 +01:00
Application : : AcquireSolarMutex ( nAcquireCount ) ;
2004-06-25 12:10:20 +00:00
tools : : DeInitTestToolLib ( ) ;
2007-11-26 13:11:13 +00:00
// be sure that path/language options gets destroyed before
// UCB is deinitialized
2003-03-25 12:52:54 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " -> dispose path/language options " ) ;
2007-11-26 13:11:13 +00:00
pLanguageOptions . reset ( 0 ) ;
pPathOptions . reset ( 0 ) ;
2003-03-25 12:52:54 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " <- dispose path/language options " ) ;
2000-11-30 07:47:40 +00:00
2003-03-25 12:52:54 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " -> deinit ucb " ) ;
2007-06-05 14:03:18 +00:00
: : ucbhelper : : ContentBroker : : deinitialize ( ) ;
2003-03-25 12:52:54 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " <- deinit ucb " ) ;
2001-06-26 12:35:41 +00:00
2003-03-25 12:52:54 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " FINISHED WITH Destop::Main " ) ;
2010-05-10 17:35:24 +02:00
if ( bRestartRequested )
{
# ifdef MACOSX
DoRestart ( ) ;
# endif
// wouldn't the solution be more clean if SalMain returns the exit code to the system?
_exit ( ExitHelper : : E_NORMAL_RESTART ) ;
}
2000-09-18 15:18:56 +00:00
}
2004-02-03 19:03:09 +00:00
IMPL_LINK ( Desktop , ImplInitFilterHdl , ConvertData * , pData )
{
return GraphicFilter : : GetGraphicFilter ( ) - > GetFilterCallback ( ) . Call ( pData ) ;
}
2002-11-01 13:49:58 +00:00
sal_Bool Desktop : : InitializeConfiguration ( )
2002-10-22 14:14:00 +00:00
{
2002-11-01 13:49:58 +00:00
sal_Bool bOk = sal_False ;
try
2002-10-22 14:14:00 +00:00
{
2002-11-01 13:49:58 +00:00
bOk = InitConfiguration ( ) ;
}
catch ( : : com : : sun : : star : : lang : : ServiceNotRegisteredException & )
{
this - > HandleBootstrapErrors ( Desktop : : BE_UNO_SERVICE_CONFIG_MISSING ) ;
}
catch ( : : com : : sun : : star : : configuration : : MissingBootstrapFileException & e )
{
OUString aMsg ( CreateErrorMsgString ( utl : : Bootstrap : : MISSING_BOOTSTRAP_FILE ,
e . BootstrapFileURL ) ) ;
HandleBootstrapPathErrors ( : : utl : : Bootstrap : : INVALID_USER_INSTALL , aMsg ) ;
}
catch ( : : com : : sun : : star : : configuration : : InvalidBootstrapFileException & e )
{
OUString aMsg ( CreateErrorMsgString ( utl : : Bootstrap : : INVALID_BOOTSTRAP_FILE_ENTRY ,
e . BootstrapFileURL ) ) ;
HandleBootstrapPathErrors ( : : utl : : Bootstrap : : INVALID_BASE_INSTALL , aMsg ) ;
}
catch ( : : com : : sun : : star : : configuration : : InstallationIncompleteException & )
{
OUString aVersionFileURL ;
OUString aMsg ;
utl : : Bootstrap : : PathStatus aPathStatus = utl : : Bootstrap : : locateVersionFile ( aVersionFileURL ) ;
if ( aPathStatus = = utl : : Bootstrap : : PATH_EXISTS )
aMsg = CreateErrorMsgString ( utl : : Bootstrap : : MISSING_VERSION_FILE_ENTRY , aVersionFileURL ) ;
else
aMsg = CreateErrorMsgString ( utl : : Bootstrap : : MISSING_VERSION_FILE , aVersionFileURL ) ;
2002-10-22 14:14:00 +00:00
2002-11-01 13:49:58 +00:00
HandleBootstrapPathErrors ( : : utl : : Bootstrap : : MISSING_USER_INSTALL , aMsg ) ;
}
2003-04-17 12:32:52 +00:00
catch ( com : : sun : : star : : configuration : : backend : : BackendAccessException & exception )
2002-11-01 13:49:58 +00:00
{
// [cm122549] It is assumed in this case that the message
// coming from InitConfiguration (in fact CreateApplicationConf...)
// is suitable for display directly.
2003-03-25 12:52:54 +00:00
FatalError ( MakeStartupErrorMessage ( exception . Message ) ) ;
2002-11-01 13:49:58 +00:00
}
2003-04-17 12:32:52 +00:00
catch ( com : : sun : : star : : configuration : : backend : : BackendSetupException & exception )
2002-11-01 13:49:58 +00:00
{
// [cm122549] It is assumed in this case that the message
// coming from InitConfiguration (in fact CreateApplicationConf...)
// is suitable for display directly.
2003-03-25 12:52:54 +00:00
FatalError ( MakeStartupErrorMessage ( exception . Message ) ) ;
2002-11-01 13:49:58 +00:00
}
catch ( : : com : : sun : : star : : configuration : : CannotLoadConfigurationException & )
{
OUString aMsg ( CreateErrorMsgString ( utl : : Bootstrap : : INVALID_BOOTSTRAP_DATA ,
OUString ( ) ) ) ;
HandleBootstrapPathErrors ( : : utl : : Bootstrap : : INVALID_BASE_INSTALL , aMsg ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
OUString aMsg ( CreateErrorMsgString ( utl : : Bootstrap : : INVALID_BOOTSTRAP_DATA ,
OUString ( ) ) ) ;
HandleBootstrapPathErrors ( : : utl : : Bootstrap : : INVALID_BASE_INSTALL , aMsg ) ;
}
2002-10-22 14:14:00 +00:00
2002-11-01 13:49:58 +00:00
return bOk ;
}
2002-10-22 14:14:00 +00:00
2002-11-01 13:49:58 +00:00
sal_Bool Desktop : : InitializeQuickstartMode ( Reference < XMultiServiceFactory > & rSMgr )
{
try
{
// the shutdown icon sits in the systray and allows the user to keep
// the office instance running for quicker restart
// this will only be activated if -quickstart was specified on cmdline
RTL_LOGFILE_CONTEXT ( aLog , " desktop (cd100003) createInstance com.sun.star.office.Quickstart " ) ;
2002-10-22 14:14:00 +00:00
2002-11-01 13:49:58 +00:00
sal_Bool bQuickstart = GetCommandLineArgs ( ) - > IsQuickstart ( ) ;
Sequence < Any > aSeq ( 1 ) ;
aSeq [ 0 ] < < = bQuickstart ;
2002-10-22 14:14:00 +00:00
2002-11-01 13:49:58 +00:00
// Try to instanciate quickstart service. This service is not mandatory, so
2009-10-13 17:06:46 +00:00
// do nothing if service is not available
// #i105753# the following if was invented for performance
// unfortunately this broke the QUARTZ behavior which is to always run
// in quickstart mode since Mac applications do not usually quit
// when the last document closes
# ifndef QUARTZ
2009-09-08 04:57:32 +00:00
if ( bQuickstart )
2009-10-13 17:06:46 +00:00
# endif
2009-09-08 04:57:32 +00:00
{
Reference < XComponent > xQuickstart ( rSMgr - > createInstanceWithArguments (
2002-11-01 13:49:58 +00:00
DEFINE_CONST_UNICODE ( " com.sun.star.office.Quickstart " ) , aSeq ) ,
UNO_QUERY ) ;
2009-09-08 04:57:32 +00:00
}
2002-11-01 13:49:58 +00:00
return sal_True ;
2002-10-22 14:14:00 +00:00
}
2002-11-01 13:49:58 +00:00
catch ( : : com : : sun : : star : : uno : : Exception & )
2002-10-22 14:14:00 +00:00
{
2002-11-01 13:49:58 +00:00
return sal_False ;
2002-10-22 14:14:00 +00:00
}
2002-11-01 13:49:58 +00:00
}
2006-10-12 13:03:59 +00:00
void Desktop : : SystemSettingsChanging ( AllSettings & rSettings , Window * )
2000-09-18 15:18:56 +00:00
{
2004-02-03 19:03:09 +00:00
if ( ! SvtTabAppearanceCfg : : IsInitialized ( ) )
return ;
# define DRAGFULL_OPTION_ALL \
( DRAGFULL_OPTION_WINDOWMOVE | DRAGFULL_OPTION_WINDOWSIZE \
| DRAGFULL_OPTION_OBJECTMOVE | DRAGFULL_OPTION_OBJECTSIZE \
| DRAGFULL_OPTION_DOCKING | DRAGFULL_OPTION_SPLIT \
| DRAGFULL_OPTION_SCROLL )
# define DRAGFULL_OPTION_NONE ((sal_uInt32)~DRAGFULL_OPTION_ALL)
StyleSettings hStyleSettings = rSettings . GetStyleSettings ( ) ;
MouseSettings hMouseSettings = rSettings . GetMouseSettings ( ) ;
sal_uInt32 nDragFullOptions = hStyleSettings . GetDragFullOptions ( ) ;
SvtTabAppearanceCfg aAppearanceCfg ;
sal_uInt16 nGet = aAppearanceCfg . GetDragMode ( ) ;
switch ( nGet )
{
case DragFullWindow :
nDragFullOptions | = DRAGFULL_OPTION_ALL ;
break ;
case DragFrame :
nDragFullOptions & = DRAGFULL_OPTION_NONE ;
break ;
case DragSystemDep :
default :
break ;
}
sal_uInt32 nFollow = hMouseSettings . GetFollow ( ) ;
hMouseSettings . SetFollow ( aAppearanceCfg . IsMenuMouseFollow ( ) ? ( nFollow | MOUSE_FOLLOW_MENU ) : ( nFollow & ~ MOUSE_FOLLOW_MENU ) ) ;
rSettings . SetMouseSettings ( hMouseSettings ) ;
2009-04-14 17:47:15 +00:00
BOOL bUseImagesInMenus = hStyleSettings . GetUseImagesInMenus ( ) ;
SvtMenuOptions aMenuOpt ;
nGet = aMenuOpt . GetMenuIconsState ( ) ;
switch ( nGet )
{
case 0 :
bUseImagesInMenus = FALSE ;
break ;
case 1 :
bUseImagesInMenus = TRUE ;
break ;
case 2 :
default :
break ;
}
hStyleSettings . SetUseImagesInMenus ( bUseImagesInMenus ) ;
2004-02-03 19:03:09 +00:00
sal_uInt16 nTabStyle = hStyleSettings . GetTabControlStyle ( ) ;
nTabStyle & = ~ STYLE_TABCONTROL_SINGLELINE ;
if ( aAppearanceCfg . IsSingleLineTabCtrl ( ) )
nTabStyle | = STYLE_TABCONTROL_SINGLELINE ;
nTabStyle & = ~ STYLE_TABCONTROL_COLOR ;
if ( aAppearanceCfg . IsColoredTabCtrl ( ) )
nTabStyle | = STYLE_TABCONTROL_COLOR ;
hStyleSettings . SetTabControlStyle ( nTabStyle ) ;
hStyleSettings . SetDragFullOptions ( nDragFullOptions ) ;
rSettings . SetStyleSettings ( hStyleSettings ) ;
2000-09-18 15:18:56 +00:00
}
2001-08-01 11:16:42 +00:00
// ========================================================================
2006-10-12 13:03:59 +00:00
IMPL_LINK ( Desktop , AsyncInitFirstRun , void * , EMPTYARG )
2001-08-01 11:16:42 +00:00
{
DoFirstRunInitializations ( ) ;
return 0L ;
}
// ========================================================================
2003-05-22 07:51:28 +00:00
2007-07-11 12:15:28 +00:00
class ExitTimer : public Timer
{
public :
ExitTimer ( )
{
SetTimeout ( 500 ) ;
Start ( ) ;
}
virtual void Timeout ( )
{
exit ( 42 ) ;
}
} ;
2006-10-12 13:03:59 +00:00
IMPL_LINK ( Desktop , OpenClients_Impl , void * , EMPTYARG )
2001-07-06 14:58:45 +00:00
{
2005-04-22 10:28:35 +00:00
RTL_LOGFILE_PRODUCT_CONTEXT ( aLog , " PERFORMANCE - DesktopOpenClients_Impl() " ) ;
2001-07-24 09:24:30 +00:00
2001-07-16 11:55:47 +00:00
OpenClients ( ) ;
2004-06-25 12:10:20 +00:00
2006-08-01 10:19:53 +00:00
OfficeIPCThread : : SetReady ( ) ;
2003-03-25 12:52:54 +00:00
// CloseStartupScreen();
2003-04-04 16:22:32 +00:00
CloseSplashScreen ( ) ;
2001-07-06 14:58:45 +00:00
2001-08-01 11:16:42 +00:00
CheckFirstRun ( ) ;
2004-03-09 10:07:00 +00:00
// allow ipc interaction
2005-05-20 06:48:31 +00:00
// OfficeIPCThread::SetReady();
2004-03-09 10:07:00 +00:00
2001-08-02 11:21:35 +00:00
EnableOleAutomation ( ) ;
2007-07-11 12:15:28 +00:00
if ( getenv ( " OOO_EXIT_POST_STARTUP " ) )
new ExitTimer ( ) ;
2001-07-06 14:58:45 +00:00
return 0 ;
}
2003-03-25 12:52:54 +00:00
// enable acceptos
2006-10-12 13:03:59 +00:00
IMPL_LINK ( Desktop , EnableAcceptors_Impl , void * , EMPTYARG )
2003-03-25 12:52:54 +00:00
{
enableAcceptors ( ) ;
return 0 ;
}
2001-08-02 11:21:35 +00:00
// Registers a COM class factory of the service manager with the windows operating system.
void Desktop : : EnableOleAutomation ( )
{
RTL_LOGFILE_CONTEXT ( aLog , " desktop (jl97489) ::Desktop::EnableOleAutomation " ) ;
# ifdef WNT
Reference < XMultiServiceFactory > xSMgr = comphelper : : getProcessServiceFactory ( ) ;
xSMgr - > createInstance ( DEFINE_CONST_UNICODE ( " com.sun.star.bridge.OleApplicationRegistration " ) ) ;
2003-04-04 18:11:50 +00:00
xSMgr - > createInstance ( DEFINE_CONST_UNICODE ( " com.sun.star.comp.ole.EmbedServer " ) ) ;
2004-01-20 15:33:21 +00:00
# endif
2001-08-02 11:21:35 +00:00
}
2001-07-06 14:58:45 +00:00
2003-05-22 07:51:28 +00:00
sal_Bool Desktop : : CheckOEM ( )
{
Reference < XMultiServiceFactory > rFactory = : : comphelper : : getProcessServiceFactory ( ) ;
Reference < XJob > rOemJob ( rFactory - > createInstance (
OUString : : createFromAscii ( " com.sun.star.office.OEMPreloadJob " ) ) ,
UNO_QUERY ) ;
Sequence < NamedValue > args ;
sal_Bool bResult = sal_False ;
if ( rOemJob . is ( ) ) {
Any aResult = rOemJob - > execute ( args ) ;
aResult > > = bResult ;
return bResult ;
} else {
return sal_True ;
}
}
2005-10-19 11:20:09 +00:00
void Desktop : : PreloadModuleData ( CommandLineArgs * pArgs )
{
Reference < XMultiServiceFactory > rFactory = : : comphelper : : getProcessServiceFactory ( ) ;
Sequence < com : : sun : : star : : beans : : PropertyValue > args ( 1 ) ;
args [ 0 ] . Name = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Hidden " ) ) ;
args [ 0 ] . Value < < = sal_True ;
Reference < XComponentLoader > xLoader ( : : comphelper : : getProcessServiceFactory ( ) - > createInstance (
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.frame.Desktop " ) ) ) , UNO_QUERY ) ;
if ( ! xLoader . is ( ) )
return ;
if ( pArgs - > IsWriter ( ) )
{
try
{
Reference < : : com : : sun : : star : : util : : XCloseable > xDoc ( xLoader - > loadComponentFromURL ( DEFINE_CONST_UNICODE ( " private:factory/swriter " ) ,
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " _blank " ) ) , 0 , args ) , UNO_QUERY_THROW ) ;
xDoc - > close ( sal_False ) ;
}
catch ( com : : sun : : star : : uno : : Exception & )
{
}
}
if ( pArgs - > IsCalc ( ) )
{
try
{
Reference < : : com : : sun : : star : : util : : XCloseable > xDoc ( xLoader - > loadComponentFromURL ( DEFINE_CONST_UNICODE ( " private:factory/scalc " ) ,
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " _blank " ) ) , 0 , args ) , UNO_QUERY_THROW ) ;
xDoc - > close ( sal_False ) ;
}
catch ( com : : sun : : star : : uno : : Exception & )
{
}
}
if ( pArgs - > IsDraw ( ) )
{
try
{
Reference < : : com : : sun : : star : : util : : XCloseable > xDoc ( xLoader - > loadComponentFromURL ( DEFINE_CONST_UNICODE ( " private:factory/sdraw " ) ,
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " _blank " ) ) , 0 , args ) , UNO_QUERY_THROW ) ;
xDoc - > close ( sal_False ) ;
}
catch ( com : : sun : : star : : uno : : Exception & )
{
}
}
if ( pArgs - > IsImpress ( ) )
{
try
{
Reference < : : com : : sun : : star : : util : : XCloseable > xDoc ( xLoader - > loadComponentFromURL ( DEFINE_CONST_UNICODE ( " private:factory/simpress " ) ,
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " _blank " ) ) , 0 , args ) , UNO_QUERY_THROW ) ;
xDoc - > close ( sal_False ) ;
}
catch ( com : : sun : : star : : uno : : Exception & )
{
}
}
}
void Desktop : : PreloadConfigurationData ( )
{
Reference < XMultiServiceFactory > rFactory = : : comphelper : : getProcessServiceFactory ( ) ;
Reference < XNameAccess > xNameAccess ( rFactory - > createInstance (
DEFINE_CONST_UNICODE ( " com.sun.star.frame.UICommandDescription " ) ) , UNO_QUERY ) ;
rtl : : OUString aWriterDoc ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.text.TextDocument " ) ) ;
rtl : : OUString aCalcDoc ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.sheet.SpreadsheetDocument " ) ) ;
rtl : : OUString aDrawDoc ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.drawing.DrawingDocument " ) ) ;
rtl : : OUString aImpressDoc ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.presentation.PresentationDocument " ) ) ;
// preload commands configuration
if ( xNameAccess . is ( ) )
{
Any a ;
Reference < XNameAccess > xCmdAccess ;
try
{
a = xNameAccess - > getByName ( aWriterDoc ) ;
a > > = xCmdAccess ;
if ( xCmdAccess . is ( ) )
{
xCmdAccess - > getByName ( DEFINE_CONST_UNICODE ( " .uno:BasicShapes " ) ) ;
xCmdAccess - > getByName ( DEFINE_CONST_UNICODE ( " .uno:EditGlossary " ) ) ;
}
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
try
{
a = xNameAccess - > getByName ( aCalcDoc ) ;
a > > = xCmdAccess ;
if ( xCmdAccess . is ( ) )
xCmdAccess - > getByName ( DEFINE_CONST_UNICODE ( " .uno:InsertObjectStarMath " ) ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
try
{
// draw and impress share the same configuration file (DrawImpressCommands.xcu)
a = xNameAccess - > getByName ( aDrawDoc ) ;
a > > = xCmdAccess ;
if ( xCmdAccess . is ( ) )
xCmdAccess - > getByName ( DEFINE_CONST_UNICODE ( " .uno:Polygon " ) ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
}
// preload window state configuration
xNameAccess = Reference < XNameAccess > ( rFactory - > createInstance (
DEFINE_CONST_UNICODE ( " com.sun.star.ui.WindowStateConfiguration " ) ) , UNO_QUERY ) ;
if ( xNameAccess . is ( ) )
{
Any a ;
Reference < XNameAccess > xWindowAccess ;
try
{
a = xNameAccess - > getByName ( aWriterDoc ) ;
a > > = xWindowAccess ;
if ( xWindowAccess . is ( ) )
xWindowAccess - > getByName ( DEFINE_CONST_UNICODE ( " private:resource/toolbar/standardbar " ) ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
try
{
a = xNameAccess - > getByName ( aCalcDoc ) ;
a > > = xWindowAccess ;
if ( xWindowAccess . is ( ) )
xWindowAccess - > getByName ( DEFINE_CONST_UNICODE ( " private:resource/toolbar/standardbar " ) ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
try
{
a = xNameAccess - > getByName ( aDrawDoc ) ;
a > > = xWindowAccess ;
if ( xWindowAccess . is ( ) )
xWindowAccess - > getByName ( DEFINE_CONST_UNICODE ( " private:resource/toolbar/standardbar " ) ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
try
{
a = xNameAccess - > getByName ( aImpressDoc ) ;
a > > = xWindowAccess ;
if ( xWindowAccess . is ( ) )
xWindowAccess - > getByName ( DEFINE_CONST_UNICODE ( " private:resource/toolbar/standardbar " ) ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
}
// preload user interface element factories
Sequence < Sequence < css : : beans : : PropertyValue > > aSeqSeqPropValue ;
Reference < : : com : : sun : : star : : ui : : XUIElementFactoryRegistration > xUIElementFactory (
rFactory - > createInstance (
DEFINE_CONST_UNICODE ( " com.sun.star.ui.UIElementFactoryManager " ) ) ,
UNO_QUERY ) ;
if ( xUIElementFactory . is ( ) )
{
try
{
aSeqSeqPropValue = xUIElementFactory - > getRegisteredFactories ( ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
}
// preload popup menu controller factories. As all controllers are in the same
// configuration file they also get preloaded!
Reference < : : com : : sun : : star : : frame : : XUIControllerRegistration > xPopupMenuControllerFactory (
rFactory - > createInstance (
DEFINE_CONST_UNICODE ( " com.sun.star.frame.PopupMenuControllerFactory " ) ) ,
UNO_QUERY ) ;
if ( xPopupMenuControllerFactory . is ( ) )
{
try
{
xPopupMenuControllerFactory - > hasController (
DEFINE_CONST_UNICODE ( " .uno:CharFontName " ) ,
OUString ( ) ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
}
// preload filter configuration
Sequence < OUString > aSeq ;
xNameAccess = Reference < XNameAccess > ( rFactory - > createInstance (
DEFINE_CONST_UNICODE ( " com.sun.star.document.FilterFactory " ) ) , UNO_QUERY ) ;
if ( xNameAccess . is ( ) )
{
try
{
aSeq = xNameAccess - > getElementNames ( ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
}
// preload type detection configuration
xNameAccess = Reference < XNameAccess > ( rFactory - > createInstance (
DEFINE_CONST_UNICODE ( " com.sun.star.document.TypeDetection " ) ) , UNO_QUERY ) ;
if ( xNameAccess . is ( ) )
{
try
{
aSeq = xNameAccess - > getElementNames ( ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
}
2008-01-29 15:29:54 +00:00
static const OUString sConfigSrvc ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.configuration.ConfigurationProvider " ) ) ;
static const OUString sAccessSrvc ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.configuration.ConfigurationAccess " ) ) ;
2005-10-19 11:20:09 +00:00
// get configuration provider
Reference < XMultiServiceFactory > xConfigProvider ;
xConfigProvider = Reference < XMultiServiceFactory > (
rFactory - > createInstance ( sConfigSrvc ) , UNO_QUERY ) ;
if ( xConfigProvider . is ( ) )
{
// preload writer configuration
Sequence < Any > theArgs ( 1 ) ;
theArgs [ 0 ] < < = OUString : : createFromAscii ( " org.openoffice.Office.Writer/MailMergeWizard " ) ;
try
{
xNameAccess = Reference < XNameAccess > (
xConfigProvider - > createInstanceWithArguments ( sAccessSrvc , theArgs ) , UNO_QUERY ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
// WriterWeb
theArgs [ 0 ] < < = OUString : : createFromAscii ( " org.openoffice.Office.WriterWeb/Content " ) ;
try
{
xNameAccess = Reference < XNameAccess > (
xConfigProvider - > createInstanceWithArguments ( sAccessSrvc , theArgs ) , UNO_QUERY ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
// preload compatibility
theArgs [ 0 ] < < = OUString : : createFromAscii ( " org.openoffice.Office.Compatibility/WriterCompatibilityVersion " ) ;
try
{
xNameAccess = Reference < XNameAccess > (
xConfigProvider - > createInstanceWithArguments ( sAccessSrvc , theArgs ) , UNO_QUERY ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
// preload calc configuration
theArgs [ 0 ] < < = OUString : : createFromAscii ( " org.openoffice.Office.Calc/Content " ) ;
try
{
xNameAccess = Reference < XNameAccess > (
xConfigProvider - > createInstanceWithArguments ( sAccessSrvc , theArgs ) , UNO_QUERY ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
// preload impress configuration
theArgs [ 0 ] < < = OUString : : createFromAscii ( " org.openoffice.Office.UI.Effects/UserInterface " ) ;
try
{
xNameAccess = Reference < XNameAccess > (
xConfigProvider - > createInstanceWithArguments ( sAccessSrvc , theArgs ) , UNO_QUERY ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
theArgs [ 0 ] < < = OUString : : createFromAscii ( " org.openoffice.Office.Impress/Layout " ) ;
try
{
xNameAccess = Reference < XNameAccess > (
xConfigProvider - > createInstanceWithArguments ( sAccessSrvc , theArgs ) , UNO_QUERY ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
// preload draw configuration
theArgs [ 0 ] < < = OUString : : createFromAscii ( " org.openoffice.Office.Draw/Layout " ) ;
try
{
xNameAccess = Reference < XNameAccess > (
xConfigProvider - > createInstanceWithArguments ( sAccessSrvc , theArgs ) , UNO_QUERY ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
// preload ui configuration
theArgs [ 0 ] < < = OUString : : createFromAscii ( " org.openoffice.Office.UI/FilterClassification " ) ;
try
{
xNameAccess = Reference < XNameAccess > (
xConfigProvider - > createInstanceWithArguments ( sAccessSrvc , theArgs ) , UNO_QUERY ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
// preload addons configuration
theArgs [ 0 ] < < = OUString : : createFromAscii ( " org.openoffice.Office.Addons/AddonUI " ) ;
try
{
xNameAccess = Reference < XNameAccess > (
xConfigProvider - > createInstanceWithArguments ( sAccessSrvc , theArgs ) , UNO_QUERY ) ;
}
catch ( : : com : : sun : : star : : uno : : Exception & )
{
}
}
}
2001-07-16 11:55:47 +00:00
void Desktop : : OpenClients ( )
{
2003-11-07 13:51:04 +00:00
2001-07-16 11:55:47 +00:00
// check if a document has been recovered - if there is one of if a document was loaded by cmdline, no default document
// should be created
Reference < XComponent > xFirst ;
BOOL bLoaded = FALSE ;
CommandLineArgs * pArgs = GetCommandLineArgs ( ) ;
SvtInternalOptions aInternalOptions ;
2003-05-22 07:51:28 +00:00
Reference < XMultiServiceFactory > rFactory = : : comphelper : : getProcessServiceFactory ( ) ;
2003-06-27 08:42:13 +00:00
if ( ! pArgs - > IsQuickstart ( ) ) {
sal_Bool bShowHelp = sal_False ;
: : rtl : : OUStringBuffer aHelpURLBuffer ;
if ( pArgs - > IsHelpWriter ( ) ) {
bShowHelp = sal_True ;
aHelpURLBuffer . appendAscii ( " vnd.sun.star.help://swriter/start " ) ;
} else if ( pArgs - > IsHelpCalc ( ) ) {
bShowHelp = sal_True ;
aHelpURLBuffer . appendAscii ( " vnd.sun.star.help://scalc/start " ) ;
} else if ( pArgs - > IsHelpDraw ( ) ) {
bShowHelp = sal_True ;
aHelpURLBuffer . appendAscii ( " vnd.sun.star.help://sdraw/start " ) ;
} else if ( pArgs - > IsHelpImpress ( ) ) {
bShowHelp = sal_True ;
aHelpURLBuffer . appendAscii ( " vnd.sun.star.help://simpress/start " ) ;
2004-08-02 13:39:04 +00:00
} else if ( pArgs - > IsHelpBase ( ) ) {
bShowHelp = sal_True ;
aHelpURLBuffer . appendAscii ( " vnd.sun.star.help://sdatabase/start " ) ;
2003-06-27 08:42:13 +00:00
} else if ( pArgs - > IsHelpBasic ( ) ) {
bShowHelp = sal_True ;
aHelpURLBuffer . appendAscii ( " vnd.sun.star.help://sbasic/start " ) ;
} else if ( pArgs - > IsHelpMath ( ) ) {
bShowHelp = sal_True ;
aHelpURLBuffer . appendAscii ( " vnd.sun.star.help://smath/start " ) ;
}
if ( bShowHelp ) {
Help * pHelp = Application : : GetHelp ( ) ;
Any aRet = : : utl : : ConfigManager : : GetDirectConfigProperty ( : : utl : : ConfigManager : : LOCALE ) ;
rtl : : OUString aTmp ;
aRet > > = aTmp ;
aHelpURLBuffer . appendAscii ( " ?Language= " ) ;
aHelpURLBuffer . append ( aTmp ) ;
# if defined UNX
aHelpURLBuffer . appendAscii ( " &System=UNX " ) ;
# elif defined WNT
aHelpURLBuffer . appendAscii ( " &System=WIN " ) ;
# elif defined MAC
aHelpURLBuffer . appendAscii ( " &System=MAC " ) ;
2007-09-20 14:35:29 +00:00
# elif defined OS2
aHelpURLBuffer . appendAscii ( " &System=OS2 " ) ;
2003-06-27 08:42:13 +00:00
# endif
pHelp - > Start ( aHelpURLBuffer . makeStringAndClear ( ) , NULL ) ;
return ;
}
}
2005-10-19 11:20:09 +00:00
else
{
OUString aIniName ;
: : vos : : OStartupInfo aInfo ;
aInfo . getExecutableFile ( aIniName ) ;
sal_uInt32 lastIndex = aIniName . lastIndexOf ( ' / ' ) ;
if ( lastIndex > 0 )
{
aIniName = aIniName . copy ( 0 , lastIndex + 1 ) ;
aIniName + = OUString ( RTL_CONSTASCII_USTRINGPARAM ( " perftune " ) ) ;
2007-09-20 14:35:29 +00:00
# if defined(WNT) || defined(OS2)
2005-10-19 11:20:09 +00:00
aIniName + = OUString ( RTL_CONSTASCII_USTRINGPARAM ( " .ini " ) ) ;
# else
aIniName + = OUString ( RTL_CONSTASCII_USTRINGPARAM ( " rc " ) ) ;
# endif
}
rtl : : Bootstrap aPerfTuneIniFile ( aIniName ) ;
OUString aDefault ( RTL_CONSTASCII_USTRINGPARAM ( " 0 " ) ) ;
OUString aPreloadData ;
aPerfTuneIniFile . getFrom ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " QuickstartPreloadConfiguration " ) ) , aPreloadData , aDefault ) ;
if ( aPreloadData . equalsAscii ( " 1 " ) )
{
if ( pArgs - > IsWriter ( ) | |
pArgs - > IsCalc ( ) | |
pArgs - > IsDraw ( ) | |
pArgs - > IsImpress ( ) )
{
PreloadModuleData ( pArgs ) ;
}
PreloadConfigurationData ( ) ;
}
}
2003-06-27 08:42:13 +00:00
2005-07-08 08:30:10 +00:00
// Disable AutoSave feature in case "-norestore" or a similare command line switch is set on the command line.
2004-12-02 08:14:48 +00:00
// The reason behind: AutoSave/EmergencySave/AutoRecovery share the same data.
// But the require that all documents, which are saved as backup should exists inside
// memory. May be this mechanism will be inconsistent if the configuration exists ...
2005-07-08 08:30:10 +00:00
// but no document inside memory corrspond to this data.
2004-12-02 08:14:48 +00:00
// Furter it's not acceptable to recover such documents without any UI. It can
// need some time, where the user wont see any results and wait for finishing the office startup ...
2005-07-08 08:30:10 +00:00
sal_Bool bAllowRecoveryAndSessionManagement = (
( ! pArgs - > IsNoRestore ( ) ) & &
( ! pArgs - > IsHeadless ( ) ) & &
( ! pArgs - > IsServer ( ) )
) ;
if ( ! bAllowRecoveryAndSessionManagement )
2004-12-02 08:14:48 +00:00
{
2005-07-08 08:30:10 +00:00
/*
2004-12-02 08:14:48 +00:00
: : comphelper : : ConfigurationHelper : : writeDirectKey (
: : comphelper : : getProcessServiceFactory ( ) ,
: : rtl : : OUString : : createFromAscii ( " org.openoffice.Office.Recovery " ) ,
: : rtl : : OUString : : createFromAscii ( " AutoSave " ) ,
: : rtl : : OUString : : createFromAscii ( " Enabled " ) ,
: : com : : sun : : star : : uno : : makeAny ( sal_False ) ,
: : comphelper : : ConfigurationHelper : : E_STANDARD ) ;
2005-07-08 08:30:10 +00:00
*/
try
{
Reference < XDispatch > xRecovery (
: : comphelper : : getProcessServiceFactory ( ) - > createInstance ( OUSTRING ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.frame.AutoRecovery " ) ) ) ,
: : com : : sun : : star : : uno : : UNO_QUERY_THROW ) ;
Reference < XURLTransformer > xParser (
: : comphelper : : getProcessServiceFactory ( ) - > createInstance ( OUSTRING ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.util.URLTransformer " ) ) ) ,
: : com : : sun : : star : : uno : : UNO_QUERY_THROW ) ;
css : : util : : URL aCmd ;
aCmd . Complete = : : rtl : : OUString : : createFromAscii ( " vnd.sun.star.autorecovery:/disableRecovery " ) ;
xParser - > parseStrict ( aCmd ) ;
xRecovery - > dispatch ( aCmd , css : : uno : : Sequence < css : : beans : : PropertyValue > ( ) ) ;
}
catch ( const css : : uno : : Exception & e )
{
OUString aMessage = OUString : : createFromAscii ( " Could not disable AutoRecovery. \n " )
+ e . Message ;
OSL_ENSURE ( sal_False , OUStringToOString ( aMessage , RTL_TEXTENCODING_ASCII_US ) . getStr ( ) ) ;
}
}
else
2001-07-16 11:55:47 +00:00
{
2004-11-26 13:49:05 +00:00
sal_Bool bCrashed = sal_False ;
sal_Bool bExistsRecoveryData = sal_False ;
2005-04-18 13:43:08 +00:00
sal_Bool bExistsSessionData = sal_False ;
impl_checkRecoveryState ( bCrashed , bExistsRecoveryData , bExistsSessionData ) ;
2007-07-11 12:15:28 +00:00
if ( ! getenv ( " OOO_DISABLE_RECOVERY " ) & &
2005-04-18 13:43:08 +00:00
( ! bLoaded ) & &
(
( bExistsRecoveryData ) | | // => crash with files => recovery
( bCrashed ) // => crash without files => error report
)
)
2001-07-16 11:55:47 +00:00
{
2005-04-18 13:43:08 +00:00
try
{
impl_callRecoveryUI (
sal_False , // false => force recovery instead of emergency save
bCrashed ,
bExistsRecoveryData ) ;
/* TODO we cant be shure, that at least one document could be recovered here successfully
So we set bLoaded = TRUE to supress opening of the default document .
But we should make it more safe . Otherwhise we have an office without an UI . . .
. . .
May be we can check the desktop if some documents are existing there .
*/
Reference < XFramesSupplier > xTasksSupplier (
: : comphelper : : getProcessServiceFactory ( ) - > createInstance ( OUSTRING ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.frame.Desktop " ) ) ) ,
: : com : : sun : : star : : uno : : UNO_QUERY_THROW ) ;
Reference < XElementAccess > xList ( xTasksSupplier - > getFrames ( ) , UNO_QUERY_THROW ) ;
if ( xList - > hasElements ( ) )
bLoaded = sal_True ;
}
catch ( const css : : uno : : Exception & e )
{
OUString aMessage = OUString : : createFromAscii ( " Error during recovery \n " )
+ e . Message ;
OSL_ENSURE ( sal_False , OUStringToOString ( aMessage , RTL_TEXTENCODING_ASCII_US ) . getStr ( ) ) ;
}
2001-07-16 11:55:47 +00:00
}
2005-04-18 13:43:08 +00:00
Reference < XInitialization > xSessionListener ;
2005-02-02 12:45:19 +00:00
try
{
2005-04-18 13:43:08 +00:00
xSessionListener = Reference < XInitialization > ( : : comphelper : : getProcessServiceFactory ( ) - > createInstance (
OUString : : createFromAscii ( " com.sun.star.frame.SessionListener " ) ) , UNO_QUERY_THROW ) ;
2009-12-03 10:37:54 +00:00
// specifies whether the UI-interaction on Session shutdown is allowed
sal_Bool bAllowUI = isUIOnSessionShutdownAllowed ( ) ;
css : : beans : : NamedValue aProperty ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " AllowUserInteractionOnQuit " ) ) ,
css : : uno : : makeAny ( bAllowUI ) ) ;
css : : uno : : Sequence < css : : uno : : Any > aArgs ( 1 ) ;
aArgs [ 0 ] < < = aProperty ;
xSessionListener - > initialize ( aArgs ) ;
2005-02-02 12:45:19 +00:00
}
2005-04-18 13:43:08 +00:00
catch ( const com : : sun : : star : : uno : : Exception & e )
2005-02-02 12:45:19 +00:00
{
2005-04-18 13:43:08 +00:00
OUString aMessage = OUString : : createFromAscii ( " Registration of session listener failed \n " )
2005-02-02 12:45:19 +00:00
+ e . Message ;
OSL_ENSURE ( sal_False , OUStringToOString ( aMessage , RTL_TEXTENCODING_ASCII_US ) . getStr ( ) ) ;
}
2005-03-29 13:59:14 +00:00
2005-04-18 13:43:08 +00:00
if (
( ! bLoaded ) & &
( bExistsSessionData )
)
{
// session management
try
{
Reference < XSessionManagerListener > r ( xSessionListener , UNO_QUERY_THROW ) ;
bLoaded = r - > doRestore ( ) ;
}
catch ( const com : : sun : : star : : uno : : Exception & e )
{
OUString aMessage = OUString : : createFromAscii ( " Error in session management \n " )
+ e . Message ;
OSL_ENSURE ( sal_False , OUStringToOString ( aMessage , RTL_TEXTENCODING_ASCII_US ) . getStr ( ) ) ;
}
}
2001-07-16 11:55:47 +00:00
}
2009-01-02 15:26:18 +00:00
OfficeIPCThread : : EnableRequests ( ) ;
2006-11-07 14:30:15 +00:00
sal_Bool bShutdown ( sal_False ) ;
2001-11-21 15:31:29 +00:00
if ( ! pArgs - > IsServer ( ) )
2001-07-16 11:55:47 +00:00
{
2008-06-09 11:59:01 +00:00
ProcessDocumentsRequest aRequest ( pArgs - > getCwdUrl ( ) ) ;
2003-07-10 13:41:29 +00:00
aRequest . pcProcessed = NULL ;
2002-02-26 07:16:22 +00:00
pArgs - > GetOpenList ( aRequest . aOpenList ) ;
2002-10-17 09:46:33 +00:00
pArgs - > GetViewList ( aRequest . aViewList ) ;
2003-05-16 13:20:54 +00:00
pArgs - > GetStartList ( aRequest . aStartList ) ;
2002-02-26 07:16:22 +00:00
pArgs - > GetPrintList ( aRequest . aPrintList ) ;
pArgs - > GetPrintToList ( aRequest . aPrintToList ) ;
pArgs - > GetPrinterName ( aRequest . aPrinterName ) ;
pArgs - > GetForceOpenList ( aRequest . aForceOpenList ) ;
pArgs - > GetForceNewList ( aRequest . aForceNewList ) ;
if ( aRequest . aOpenList . getLength ( ) > 0 | |
2002-10-17 09:46:33 +00:00
aRequest . aViewList . getLength ( ) > 0 | |
2003-05-16 13:20:54 +00:00
aRequest . aStartList . getLength ( ) > 0 | |
2002-02-26 07:16:22 +00:00
aRequest . aPrintList . getLength ( ) > 0 | |
aRequest . aForceOpenList . getLength ( ) > 0 | |
aRequest . aForceNewList . getLength ( ) > 0 | |
( aRequest . aPrintToList . getLength ( ) > 0 & & aRequest . aPrinterName . getLength ( ) > 0 ) )
2001-11-21 15:31:29 +00:00
{
bLoaded = sal_True ;
2002-02-26 07:16:22 +00:00
2005-02-21 16:19:17 +00:00
if ( pArgs - > HasModuleParam ( ) )
{
SvtModuleOptions aOpt ;
// Support command line parameters to start a module (as preselection)
if ( pArgs - > IsWriter ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SWRITER ) )
aRequest . aModule = aOpt . GetFactoryName ( SvtModuleOptions : : E_WRITER ) ;
else if ( pArgs - > IsCalc ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SCALC ) )
aRequest . aModule = aOpt . GetFactoryName ( SvtModuleOptions : : E_CALC ) ;
else if ( pArgs - > IsImpress ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SIMPRESS ) )
aRequest . aModule = aOpt . GetFactoryName ( SvtModuleOptions : : E_IMPRESS ) ;
else if ( pArgs - > IsDraw ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SDRAW ) )
aRequest . aModule = aOpt . GetFactoryName ( SvtModuleOptions : : E_DRAW ) ;
}
2006-03-22 08:48:18 +00:00
// check for printing disabled
if ( ( aRequest . aPrintList . getLength ( ) | | aRequest . aPrintToList . getLength ( ) )
& & Application : : GetSettings ( ) . GetMiscSettings ( ) . GetDisablePrinting ( ) )
{
aRequest . aPrintList = rtl : : OUString ( ) ;
aRequest . aPrintToList = rtl : : OUString ( ) ;
ResMgr * pDtResMgr = GetDesktopResManager ( ) ;
if ( pDtResMgr )
{
2007-04-26 07:21:55 +00:00
ErrorBox aBox ( NULL , ResId ( EBX_ERR_PRINTDISABLED , * pDtResMgr ) ) ;
2006-03-22 08:48:18 +00:00
aBox . Execute ( ) ;
}
}
2002-02-26 07:16:22 +00:00
// Process request
2006-11-07 14:30:15 +00:00
bShutdown = OfficeIPCThread : : ExecuteCmdLineRequests ( aRequest ) ;
2001-11-21 15:31:29 +00:00
}
2001-07-16 11:55:47 +00:00
}
2006-11-07 14:30:15 +00:00
// Don't do anything if we have successfully called terminate at desktop
if ( bShutdown )
return ;
2001-07-16 11:55:47 +00:00
// no default document if a document was loaded by recovery or by command line or if soffice is used as server
2006-11-07 13:54:44 +00:00
Reference < XFramesSupplier > xTasksSupplier (
: : comphelper : : getProcessServiceFactory ( ) - > createInstance ( OUSTRING ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.frame.Desktop " ) ) ) ,
: : com : : sun : : star : : uno : : UNO_QUERY_THROW ) ;
Reference < XElementAccess > xList ( xTasksSupplier - > getFrames ( ) , UNO_QUERY_THROW ) ;
if ( xList - > hasElements ( ) | | pArgs - > IsServer ( ) )
2001-07-16 11:55:47 +00:00
return ;
2008-03-05 16:47:51 +00:00
if ( pArgs - > IsQuickstart ( ) | | pArgs - > IsInvisible ( ) | | pArgs - > IsBean ( ) | | Application : : AnyInput ( INPUT_APPEVENT ) )
2003-04-24 12:35:03 +00:00
// soffice was started as tray icon ...
2001-07-16 11:55:47 +00:00
return ;
{
OpenDefault ( ) ;
}
}
void Desktop : : OpenDefault ( )
{
2003-04-24 12:35:03 +00:00
2001-08-07 10:25:00 +00:00
RTL_LOGFILE_CONTEXT ( aLog , " desktop (cd100003) ::Desktop::OpenDefault " ) ;
2001-07-24 09:24:30 +00:00
2003-06-27 08:42:13 +00:00
: : rtl : : OUString aName ;
2002-10-24 14:39:22 +00:00
SvtModuleOptions aOpt ;
CommandLineArgs * pArgs = GetCommandLineArgs ( ) ;
2003-03-25 12:52:54 +00:00
if ( pArgs - > IsNoDefault ( ) ) return ;
2002-10-24 14:39:22 +00:00
if ( pArgs - > HasModuleParam ( ) )
{
// Support new command line parameters to start a module
if ( pArgs - > IsWriter ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SWRITER ) )
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_WRITER ) ;
else if ( pArgs - > IsCalc ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SCALC ) )
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_CALC ) ;
else if ( pArgs - > IsImpress ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SIMPRESS ) )
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_IMPRESS ) ;
2004-08-02 13:39:04 +00:00
else if ( pArgs - > IsBase ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SDATABASE ) )
2005-03-10 16:16:36 +00:00
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_DATABASE ) ;
2002-10-24 14:39:22 +00:00
else if ( pArgs - > IsDraw ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SDRAW ) )
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_DRAW ) ;
else if ( pArgs - > IsMath ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SMATH ) )
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_MATH ) ;
else if ( pArgs - > IsGlobal ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SWRITER ) )
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_WRITERGLOBAL ) ;
else if ( pArgs - > IsWeb ( ) & & aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SWRITER ) )
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_WRITERWEB ) ;
}
2001-08-22 12:06:35 +00:00
if ( ! aName . getLength ( ) )
2001-07-16 11:55:47 +00:00
{
2002-10-24 14:39:22 +00:00
// Old way to create a default document
2001-08-22 12:06:35 +00:00
if ( aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SWRITER ) )
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_WRITER ) ;
else if ( aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SCALC ) )
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_CALC ) ;
else if ( aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SIMPRESS ) )
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_IMPRESS ) ;
2004-08-02 13:39:04 +00:00
else if ( aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SDATABASE ) )
2005-03-10 16:16:36 +00:00
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_DATABASE ) ;
2001-08-22 12:06:35 +00:00
else if ( aOpt . IsModuleInstalled ( SvtModuleOptions : : E_SDRAW ) )
aName = aOpt . GetFactoryEmptyDocumentURL ( SvtModuleOptions : : E_DRAW ) ;
2001-07-16 11:55:47 +00:00
else
return ;
}
2008-06-09 11:59:01 +00:00
ProcessDocumentsRequest aRequest ( pArgs - > getCwdUrl ( ) ) ;
2005-05-20 06:48:31 +00:00
aRequest . pcProcessed = NULL ;
aRequest . aOpenList = aName ;
OfficeIPCThread : : ExecuteCmdLineRequests ( aRequest ) ;
2001-07-16 11:55:47 +00:00
}
2008-06-09 11:59:01 +00:00
String GetURL_Impl (
const String & rName , boost : : optional < rtl : : OUString > const & cwdUrl )
2001-07-16 11:55:47 +00:00
{
2004-10-22 13:42:55 +00:00
// if rName is a vnd.sun.star.script URL do not attempt to parse it
// as INetURLObj does not handle handle there URLs
if ( rName . CompareToAscii ( " vnd.sun.star.script " , 19 ) = = COMPARE_EQUAL )
{
return rName ;
}
2005-03-11 10:01:09 +00:00
// dont touch file urls, those should already be in internal form
// they won't get better here (#112849#)
if ( rName . CompareToAscii ( " file: " , 5 ) = = COMPARE_EQUAL )
{
return rName ;
}
2005-01-21 16:35:22 +00:00
if ( rName . CompareToAscii ( " service: " , 8 ) = = COMPARE_EQUAL )
{
return rName ;
}
2001-09-26 08:45:06 +00:00
// Add path seperator to these directory and make given URL (rName) absolute by using of current working directory
// Attention: "setFianlSlash()" is neccessary for calling "smartRel2Abs()"!!!
// Otherwhise last part will be ignored and wrong result will be returned!!!
// "smartRel2Abs()" interpret given URL as file not as path. So he truncate last element to get the base path ...
// But if we add a seperator - he doesn't do it anymore.
2008-06-09 11:59:01 +00:00
INetURLObject aObj ;
if ( cwdUrl ) {
aObj . SetURL ( * cwdUrl ) ;
aObj . setFinalSlash ( ) ;
}
2001-09-26 08:45:06 +00:00
2003-06-16 10:38:09 +00:00
// Use the provided parameters for smartRel2Abs to support the usage of '%' in system paths.
// Otherwise this char won't get encoded and we are not able to load such files later,
// see #110156#
2001-07-16 11:55:47 +00:00
bool bWasAbsolute ;
2003-06-16 10:38:09 +00:00
INetURLObject aURL = aObj . smartRel2Abs ( rName , bWasAbsolute , false , INetURLObject : : WAS_ENCODED ,
RTL_TEXTENCODING_UTF8 , true ) ;
2001-09-26 08:45:06 +00:00
String aFileURL = aURL . GetMainURL ( INetURLObject : : NO_DECODE ) ;
2001-09-13 11:30:26 +00:00
: : osl : : FileStatus aStatus ( FileStatusMask_FileURL ) ;
: : osl : : DirectoryItem aItem ;
if ( : : osl : : FileBase : : E_None = = : : osl : : DirectoryItem : : get ( aFileURL , aItem ) & &
: : osl : : FileBase : : E_None = = aItem . getFileStatus ( aStatus ) )
aFileURL = aStatus . getFileURL ( ) ;
return aFileURL ;
2001-07-16 11:55:47 +00:00
}
void Desktop : : HandleAppEvent ( const ApplicationEvent & rAppEvent )
{
2005-03-11 10:01:09 +00:00
if ( rAppEvent . GetEvent ( ) = = " APPEAR " & & ! GetCommandLineArgs ( ) - > IsInvisible ( ) )
2001-07-16 11:55:47 +00:00
{
2006-11-07 13:54:44 +00:00
css : : uno : : Reference < css : : lang : : XMultiServiceFactory > xSMGR = : : comphelper : : getProcessServiceFactory ( ) ;
2001-07-16 11:55:47 +00:00
// find active task - the active task is always a visible task
2002-05-24 10:24:34 +00:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : frame : : XFramesSupplier >
2006-11-07 13:54:44 +00:00
xDesktop ( xSMGR - > createInstance ( OUSTRING ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.frame.Desktop " ) ) ) ,
2001-07-16 11:55:47 +00:00
: : com : : sun : : star : : uno : : UNO_QUERY ) ;
2002-05-24 10:24:34 +00:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : frame : : XFrame > xTask = xDesktop - > getActiveFrame ( ) ;
2001-07-16 11:55:47 +00:00
if ( ! xTask . is ( ) )
{
// get any task if there is no active one
2002-05-24 10:24:34 +00:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : container : : XIndexAccess > xList ( xDesktop - > getFrames ( ) , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
if ( xList - > getCount ( ) > 0 )
xList - > getByIndex ( 0 ) > > = xTask ;
2001-07-16 11:55:47 +00:00
}
if ( xTask . is ( ) )
{
Reference < com : : sun : : star : : awt : : XTopWindow > xTop ( xTask - > getContainerWindow ( ) , UNO_QUERY ) ;
xTop - > toFront ( ) ;
}
else
2006-11-07 13:54:44 +00:00
{
2001-07-16 11:55:47 +00:00
// no visible task that could be activated found
2006-11-07 13:54:44 +00:00
Reference < XFrame > xBackingFrame ;
Reference < : : com : : sun : : star : : awt : : XWindow > xContainerWindow ;
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : frame : : XFrame > xDesktopFrame ( xDesktop , UNO_QUERY ) ;
xBackingFrame = xDesktopFrame - > findFrame ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " _blank " ) ) , 0 ) ;
if ( xBackingFrame . is ( ) )
xContainerWindow = xBackingFrame - > getContainerWindow ( ) ;
if ( xContainerWindow . is ( ) )
{
Sequence < Any > lArgs ( 1 ) ;
lArgs [ 0 ] < < = xContainerWindow ;
Reference < XController > xBackingComp (
xSMGR - > createInstanceWithArguments ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.frame.StartModule " ) ) , lArgs ) ,
UNO_QUERY ) ;
if ( xBackingComp . is ( ) )
{
Reference < : : com : : sun : : star : : awt : : XWindow > xBackingWin ( xBackingComp , UNO_QUERY ) ;
// Attention: You MUST(!) call setComponent() before you call attachFrame().
// Because the backing component set the property "IsBackingMode" of the frame
// to true inside attachFrame(). But setComponent() reset this state everytimes ...
xBackingFrame - > setComponent ( xBackingWin , xBackingComp ) ;
xBackingComp - > attachFrame ( xBackingFrame ) ;
xContainerWindow - > setVisible ( sal_True ) ;
Window * pCompWindow = VCLUnoHelper : : GetWindow ( xBackingFrame - > getComponentWindow ( ) ) ;
if ( pCompWindow )
pCompWindow - > Update ( ) ;
}
}
}
2001-07-16 11:55:47 +00:00
}
2003-03-25 12:52:54 +00:00
else if ( rAppEvent . GetEvent ( ) = = " QUICKSTART " & & ! GetCommandLineArgs ( ) - > IsInvisible ( ) )
2001-07-20 08:52:29 +00:00
{
2002-07-10 05:57:45 +00:00
// If the office has been started the second time its command line arguments are sent through a pipe
// connection to the first office. We want to reuse the quickstart option for the first office.
// NOTICE: The quickstart service must be initialized inside the "main thread", so we use the
// application events to do this (they are executed inside main thread)!!!
// Don't start quickstart service if the user specified "-invisible" on the command line!
sal_Bool bQuickstart ( sal_True ) ;
Sequence < Any > aSeq ( 1 ) ;
aSeq [ 0 ] < < = bQuickstart ;
2001-07-20 08:52:29 +00:00
2002-07-10 05:57:45 +00:00
Reference < XInitialization > xQuickstart ( : : comphelper : : getProcessServiceFactory ( ) - > createInstance (
2003-03-25 12:52:54 +00:00
DEFINE_CONST_UNICODE ( " com.sun.star.office.Quickstart " ) ) ,
UNO_QUERY ) ;
2002-07-10 05:57:45 +00:00
if ( xQuickstart . is ( ) )
xQuickstart - > initialize ( aSeq ) ;
2001-07-20 08:52:29 +00:00
}
2003-03-25 12:52:54 +00:00
else if ( rAppEvent . GetEvent ( ) = = " ACCEPT " )
{
// every time an accept parameter is used we create an acceptor
// with the corresponding accept-string
OUString aAcceptString ( rAppEvent . GetData ( ) . GetBuffer ( ) ) ;
createAcceptor ( aAcceptString ) ;
}
else if ( rAppEvent . GetEvent ( ) = = " UNACCEPT " )
{
// try to remove corresponding acceptor
OUString aUnAcceptString ( rAppEvent . GetData ( ) . GetBuffer ( ) ) ;
destroyAcceptor ( aUnAcceptString ) ;
}
2003-06-10 13:37:31 +00:00
else if ( rAppEvent . GetEvent ( ) = = " SaveDocuments " )
{
2003-07-22 07:26:21 +00:00
Desktop : : _bTasksSaved = sal_False ;
2006-10-12 13:03:59 +00:00
Desktop : : _bTasksSaved = SaveTasks ( ) ;
2003-06-10 13:37:31 +00:00
}
2003-06-27 08:42:13 +00:00
else if ( rAppEvent . GetEvent ( ) = = " OPENHELPURL " )
{
// start help for a specific URL
OUString aHelpURL ( rAppEvent . GetData ( ) . GetBuffer ( ) ) ;
Help * pHelp = Application : : GetHelp ( ) ;
pHelp - > Start ( aHelpURL , NULL ) ;
}
2007-08-03 13:12:15 +00:00
else if ( rAppEvent . GetEvent ( ) = = APPEVENT_OPEN_STRING )
{
OUString aOpenURL ( rAppEvent . GetData ( ) . GetBuffer ( ) ) ;
CommandLineArgs * pCmdLine = GetCommandLineArgs ( ) ;
if ( ! pCmdLine - > IsInvisible ( ) & & ! pCmdLine - > IsTerminateAfterInit ( ) )
{
2008-06-09 11:59:01 +00:00
ProcessDocumentsRequest * pDocsRequest = new ProcessDocumentsRequest (
pCmdLine - > getCwdUrl ( ) ) ;
2007-08-03 13:12:15 +00:00
pDocsRequest - > aOpenList = aOpenURL ;
pDocsRequest - > pcProcessed = NULL ;
OfficeIPCThread : : ExecuteCmdLineRequests ( * pDocsRequest ) ;
delete pDocsRequest ;
}
}
else if ( rAppEvent . GetEvent ( ) = = APPEVENT_PRINT_STRING )
{
OUString aPrintURL ( rAppEvent . GetData ( ) . GetBuffer ( ) ) ;
CommandLineArgs * pCmdLine = GetCommandLineArgs ( ) ;
if ( ! pCmdLine - > IsInvisible ( ) & & ! pCmdLine - > IsTerminateAfterInit ( ) )
{
2008-06-09 11:59:01 +00:00
ProcessDocumentsRequest * pDocsRequest = new ProcessDocumentsRequest (
pCmdLine - > getCwdUrl ( ) ) ;
2007-08-03 13:12:15 +00:00
pDocsRequest - > aPrintList = aPrintURL ;
pDocsRequest - > pcProcessed = NULL ;
OfficeIPCThread : : ExecuteCmdLineRequests ( * pDocsRequest ) ;
delete pDocsRequest ;
}
}
2003-03-25 12:52:54 +00:00
# ifndef UNX
else if ( rAppEvent . GetEvent ( ) = = " HELP " )
{
// in non unix version allow showing of cmdline help window
displayCmdlineHelp ( ) ;
}
# endif
2008-03-05 16:47:51 +00:00
else if ( rAppEvent . GetEvent ( ) = = " SHOWDIALOG " )
{
// ignore all errors here. It's clicking a menu entry only ...
// The user will try it again, in case nothing happens .-)
try
{
css : : uno : : Reference < css : : lang : : XMultiServiceFactory > xSMGR = : : comphelper : : getProcessServiceFactory ( ) ;
com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : frame : : XDispatchProvider >
xDesktop ( xSMGR - > createInstance ( OUSTRING ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.frame.Desktop " ) ) ) ,
: : com : : sun : : star : : uno : : UNO_QUERY ) ;
// check provider ... we know it's weak reference only
if ( ! xDesktop . is ( ) )
return ;
css : : uno : : Reference < css : : util : : XURLTransformer > xParser ( xSMGR - > createInstance ( rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.util.URLTransformer " ) ) ) , css : : uno : : UNO_QUERY_THROW ) ;
css : : util : : URL aCommand ;
if ( rAppEvent . GetData ( ) . EqualsAscii ( " PREFERENCES " ) )
aCommand . Complete = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " .uno:OptionsTreeDialog " ) ) ;
else if ( rAppEvent . GetData ( ) . EqualsAscii ( " ABOUT " ) )
aCommand . Complete = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " .uno:About " ) ) ;
if ( aCommand . Complete . getLength ( ) )
{
xParser - > parseStrict ( aCommand ) ;
css : : uno : : Reference < css : : frame : : XDispatch > xDispatch = xDesktop - > queryDispatch ( aCommand , rtl : : OUString ( ) , 0 ) ;
if ( xDispatch . is ( ) )
xDispatch - > dispatch ( aCommand , css : : uno : : Sequence < css : : beans : : PropertyValue > ( ) ) ;
}
}
catch ( const css : : uno : : Exception & )
{ }
}
2001-07-16 11:55:47 +00:00
}
2003-04-04 16:22:32 +00:00
void Desktop : : OpenSplashScreen ( )
2001-07-06 14:58:45 +00:00
{
2006-07-26 08:14:33 +00:00
: : rtl : : OUString aTmpString ;
2001-07-24 09:24:30 +00:00
CommandLineArgs * pCmdLine = GetCommandLineArgs ( ) ;
2003-03-25 12:52:54 +00:00
sal_Bool bVisible = sal_False ;
2001-07-24 09:24:30 +00:00
// Show intro only if this is normal start (e.g. no server, no quickstart, no printing )
2004-01-06 17:37:50 +00:00
if ( ! pCmdLine - > IsInvisible ( ) & &
2001-07-24 09:24:30 +00:00
! pCmdLine - > IsQuickstart ( ) & &
! pCmdLine - > IsMinimized ( ) & &
2002-07-09 04:21:23 +00:00
! pCmdLine - > IsNoLogo ( ) & &
2001-07-30 14:31:59 +00:00
! pCmdLine - > IsTerminateAfterInit ( ) & &
2001-12-04 15:05:32 +00:00
! pCmdLine - > GetPrintList ( aTmpString ) & &
! pCmdLine - > GetPrintToList ( aTmpString ) )
2001-07-06 14:58:45 +00:00
{
2006-07-26 08:14:33 +00:00
// Determine application name from command line parameters
OUString aAppName ;
if ( pCmdLine - > IsWriter ( ) )
aAppName = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " writer " ) ) ;
else if ( pCmdLine - > IsCalc ( ) )
aAppName = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " calc " ) ) ;
else if ( pCmdLine - > IsDraw ( ) )
aAppName = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " draw " ) ) ;
else if ( pCmdLine - > IsImpress ( ) )
aAppName = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " impress " ) ) ;
else if ( pCmdLine - > IsBase ( ) )
aAppName = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " base " ) ) ;
else if ( pCmdLine - > IsGlobal ( ) )
aAppName = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " global " ) ) ;
else if ( pCmdLine - > IsMath ( ) )
aAppName = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " math " ) ) ;
else if ( pCmdLine - > IsWeb ( ) )
aAppName = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " web " ) ) ;
2003-03-25 12:52:54 +00:00
bVisible = sal_True ;
2006-07-26 08:14:33 +00:00
Sequence < Any > aSeq ( 2 ) ;
2003-04-04 16:22:32 +00:00
aSeq [ 0 ] < < = bVisible ;
2006-07-26 08:14:33 +00:00
aSeq [ 1 ] < < = aAppName ;
2003-04-04 16:22:32 +00:00
m_rSplashScreen = Reference < XStatusIndicator > (
comphelper : : getProcessServiceFactory ( ) - > createInstanceWithArguments (
OUString : : createFromAscii ( " com.sun.star.office.SplashScreen " ) ,
aSeq ) , UNO_QUERY ) ;
if ( m_rSplashScreen . is ( ) )
m_rSplashScreen - > start ( OUString : : createFromAscii ( " SplashScreen " ) , 100 ) ;
}
}
void Desktop : : SetSplashScreenProgress ( sal_Int32 iProgress )
{
if ( m_rSplashScreen . is ( ) )
{
m_rSplashScreen - > setValue ( iProgress ) ;
}
}
2010-04-20 07:59:05 +02:00
void Desktop : : SetSplashScreenText ( const : : rtl : : OUString & rText )
{
if ( m_rSplashScreen . is ( ) )
{
m_rSplashScreen - > setText ( rText ) ;
}
}
2003-04-04 16:22:32 +00:00
void Desktop : : CloseSplashScreen ( )
{
if ( m_rSplashScreen . is ( ) )
{
m_rSplashScreen - > end ( ) ;
m_rSplashScreen = NULL ;
2001-07-06 14:58:45 +00:00
}
}
2001-08-01 11:16:42 +00:00
// ========================================================================
void Desktop : : DoFirstRunInitializations ( )
{
2001-12-05 12:33:54 +00:00
try
{
Reference < XJobExecutor > xExecutor ( : : comphelper : : getProcessServiceFactory ( ) - > createInstance ( : : rtl : : OUString : : createFromAscii ( " com.sun.star.task.JobExecutor " ) ) , UNO_QUERY ) ;
if ( xExecutor . is ( ) )
xExecutor - > trigger ( : : rtl : : OUString : : createFromAscii ( " onFirstRunInitialization " ) ) ;
}
catch ( const : : com : : sun : : star : : uno : : Exception & )
{
OSL_ENSURE ( sal_False , " Desktop::DoFirstRunInitializations: caught an exception while trigger job executor ... " ) ;
2001-08-01 11:16:42 +00:00
}
}
// ========================================================================
void Desktop : : CheckFirstRun ( )
{
const : : rtl : : OUString sCommonMiscNodeName = : : rtl : : OUString : : createFromAscii ( " /org.openoffice.Office.Common/Misc " ) ;
const : : rtl : : OUString sFirstRunNodeName = : : rtl : : OUString : : createFromAscii ( " FirstRun " ) ;
// --------------------------------------------------------------------
// check if this is the first office start
// for this, open the Common/Misc node where this info is stored
: : utl : : OConfigurationTreeRoot aCommonMisc = : : utl : : OConfigurationTreeRoot : : createWithServiceFactory (
: : comphelper : : getProcessServiceFactory ( ) ,
sCommonMiscNodeName ,
2 ,
: : utl : : OConfigurationTreeRoot : : CM_UPDATABLE
) ;
// read the flag
OSL_ENSURE ( aCommonMisc . isValid ( ) , " Desktop::CheckFirstRun: could not open the config node needed! " ) ;
sal_Bool bIsFirstRun = sal_False ;
aCommonMisc . getNodeValue ( sFirstRunNodeName ) > > = bIsFirstRun ;
if ( ! bIsFirstRun )
// nothing to do ....
return ;
// --------------------------------------------------------------------
// it is the first run
2003-03-25 12:52:54 +00:00
// this has once been done using a vos timer. this could lead to problems when
// the timer would trigger when the app is already going down again, since VCL would
// no longer be available. Since the old handler would do a postUserEvent to the main
// thread anyway, we can use a vcl timer here to prevent the race contition (#107197#)
m_firstRunTimer . SetTimeout ( 3000 ) ; // 3 sec.
m_firstRunTimer . SetTimeoutHdl ( LINK ( this , Desktop , AsyncInitFirstRun ) ) ;
m_firstRunTimer . Start ( ) ;
2001-08-01 11:16:42 +00:00
// --------------------------------------------------------------------
// reset the config flag
// set the value
aCommonMisc . setNodeValue ( sFirstRunNodeName , makeAny ( ( sal_Bool ) sal_False ) ) ;
// commit the changes
aCommonMisc . commit ( ) ;
}
2002-11-01 13:49:58 +00:00
2003-03-25 12:52:54 +00:00
}