diff options
Diffstat (limited to 'desktop/source/app/app.cxx')
-rw-r--r-- | desktop/source/app/app.cxx | 236 |
1 files changed, 128 insertions, 108 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index a026a1ede209..0e529e071427 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -24,9 +24,11 @@ #include <config_java.h> #include <config_folders.h> #include <config_extensions.h> +#include <config_wasm_strip.h> #include <sal/config.h> +#include <cstdlib> #include <iostream> #include <string_view> @@ -46,8 +48,6 @@ #include <framework/desktop.hxx> #include <i18nlangtag/languagetag.hxx> #include <o3tl/char16_t2wchar_t.hxx> -#include <svl/languageoptions.hxx> -#include <svl/cjkoptions.hxx> #include <svl/ctloptions.hxx> #include <svtools/javacontext.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -60,7 +60,6 @@ #include <com/sun/star/system/SystemShellExecuteFlags.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/StartModule.hpp> -#include <com/sun/star/view/XPrintable.hpp> #include <com/sun/star/awt/XTopWindow.hpp> #include <com/sun/star/util/URLTransformer.hpp> #include <com/sun/star/util/XURLTransformer.hpp> @@ -82,6 +81,7 @@ #include <desktop/exithelper.h> #include <sal/log.hxx> #include <toolkit/helper/vclunohelper.hxx> +#include <comphelper/lok.hxx> #include <comphelper/configuration.hxx> #include <comphelper/fileurl.hxx> #include <comphelper/threadpool.hxx> @@ -101,10 +101,11 @@ #include <osl/process.h> #include <rtl/byteseq.hxx> #include <unotools/pathoptions.hxx> +#if !ENABLE_WASM_STRIP_PINGUSER #include <unotools/VersionConfig.hxx> +#endif #include <rtl/bootstrap.hxx> #include <vcl/test/GraphicsRenderTests.hxx> -#include <vcl/glxtestprocess.hxx> #include <vcl/help.hxx> #include <vcl/weld.hxx> #include <vcl/settings.hxx> @@ -117,7 +118,7 @@ #include <basic/sbstar.hxx> #include <desktop/crashreport.hxx> #include <tools/urlobj.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <svtools/fontsubstconfig.hxx> #include <svtools/accessibilityoptions.hxx> #include <svtools/apearcfg.hxx> @@ -126,6 +127,10 @@ #include "langselect.hxx" #include <salhelper/thread.hxx> +#if HAVE_FEATURE_UPDATE_MAR +#include <tools/time.hxx> +#endif + #if defined MACOSX #include <errno.h> #include <sys/wait.h> @@ -154,7 +159,6 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; 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; @@ -285,12 +289,11 @@ bool shouldLaunchQuickstart() bool bQuickstart = Desktop::GetCommandLineArgs().IsQuickstart(); if (!bQuickstart) { - const SfxPoolItem* pItem=nullptr; SfxItemSetFixed<SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER> aQLSet(SfxGetpApp()->GetPool()); - SfxGetpApp()->GetOptions(aQLSet); - SfxItemState eState = aQLSet.GetItemState(SID_ATTR_QUICKLAUNCHER, false, &pItem); - if (SfxItemState::SET == eState) - bQuickstart = static_cast<const SfxBoolItem*>(pItem)->GetValue(); + SfxApplication::GetOptions(aQLSet); + const SfxBoolItem* pLauncherItem = aQLSet.GetItemIfSet(SID_ATTR_QUICKLAUNCHER, false); + if (pLauncherItem) + bQuickstart = pLauncherItem->GetValue(); } return bQuickstart; } @@ -339,15 +342,21 @@ void RemoveIconCacheDirectory() namespace { +#if !defined(EMSCRIPTEN) void runGraphicsRenderTests() { - if (!utl::isProductVersionUpgraded(false)) + if (comphelper::LibreOfficeKit::isActive()) + return; +#if !ENABLE_WASM_STRIP_PINGUSER + if (!utl::isProductVersionUpgraded()) { return; } +#endif GraphicsRenderTests TestObject; TestObject.run(); } +#endif OUString MakeStartupErrorMessage(std::u16string_view aErrorMessage) @@ -454,7 +463,8 @@ void Desktop::Init() } catch (css::uno::Exception & e) { - SetBootstrapError( BE_UNO_SERVICEMANAGER, e.Message ); + HandleBootstrapErrors( BE_UNO_SERVICEMANAGER, e.Message ); + std::abort(); } // Check whether safe mode is enabled @@ -471,37 +481,41 @@ void Desktop::Init() // the UserConfiguration directory comphelper::BackupFileHelper::reactOnSafeMode(Application::IsSafeModeEnabled()); - if ( m_aBootstrapError == BE_OK ) + // tdf117100: do not try to re-install extensions after the requested restart + if (officecfg::Setup::Office::OfficeRestartInProgress::get()) { - try - { - if (!langselect::prepareLocale()) - { - SetBootstrapError( BE_LANGUAGE_MISSING, OUString() ); - } - } - catch (css::uno::Exception & e) + if (!officecfg::Office::Common::Misc::FirstRun::get()) + GetCommandLineArgs().RemoveFilesFromOpenListEndingWith(".oxt"); + } + + try + { + if (!langselect::prepareLocale()) { - SetBootstrapError( BE_OFFICECONFIG_BROKEN, e.Message ); + SetBootstrapError( BE_LANGUAGE_MISSING, OUString() ); } + } + catch (css::uno::Exception & e) + { + SetBootstrapError( BE_OFFICECONFIG_BROKEN, e.Message ); + } - // test code for ProfileSafeMode to allow testing the fail - // of loading the office configuration initially. To use, - // either set to true and compile, or set a breakpoint - // in debugger and change the local bool - static bool bTryHardOfficeconfigBroken(false); // loplugin:constvars:ignore + // test code for ProfileSafeMode to allow testing the fail + // of loading the office configuration initially. To use, + // either set to true and compile, or set a breakpoint + // in debugger and change the local bool + static bool bTryHardOfficeconfigBroken(false); // loplugin:constvars:ignore - if (bTryHardOfficeconfigBroken) - { - SetBootstrapError(BE_OFFICECONFIG_BROKEN, OUString()); - } + if (bTryHardOfficeconfigBroken) + { + SetBootstrapError(BE_OFFICECONFIG_BROKEN, OUString()); } // start ipc thread only for non-remote offices RequestHandler::Status aStatus = RequestHandler::Enable(true); if ( aStatus == RequestHandler::IPC_STATUS_PIPE_ERROR ) { -#if defined ANDROID +#if defined(ANDROID) || defined(EMSCRIPTEN) // Ignore crack pipe errors on Android #else // Keep using this oddly named BE_PATHINFO_MISSING value @@ -520,6 +534,10 @@ void Desktop::Init() else if ( aStatus == RequestHandler::IPC_STATUS_2ND_OFFICE ) { // 2nd office startup should terminate after sending cmdlineargs through pipe + if (rCmdLineArgs.IsTextCat() || rCmdLineArgs.IsScriptCat()) + { + HandleBootstrapErrors( BE_2NDOFFICE_WITHCAT, OUString() ); + } SetBootstrapStatus(BS_TERMINATE); } else if ( !rCmdLineArgs.GetUnknown().isEmpty() @@ -574,7 +592,7 @@ bool Desktop::QueryExit() { } - static constexpr OUStringLiteral SUSPEND_QUICKSTARTVETO = u"SuspendQuickstartVeto"; + static constexpr OUString SUSPEND_QUICKSTARTVETO = u"SuspendQuickstartVeto"_ustr; Reference< XDesktop2 > xDesktop = css::frame::Desktop::create( ::comphelper::getProcessComponentContext() ); Reference< XPropertySet > xPropertySet(xDesktop, UNO_QUERY_THROW); @@ -586,7 +604,7 @@ bool Desktop::QueryExit() { xPropertySet->setPropertyValue( SUSPEND_QUICKSTARTVETO, Any(false) ); } - else if (!Application::IsEventTestingModeEnabled()) + else { FlushConfiguration(); try @@ -877,6 +895,11 @@ void Desktop::HandleBootstrapErrors( FatalError(MakeStartupErrorMessage(aDiagnosticMessage)); } + else if ( aBootstrapError == BE_2NDOFFICE_WITHCAT ) + { + OUString aDiagnosticMessage = DpResId(STR_BOOTSTRAP_ERR_2NDOFFICE_WITHCAT); + FatalError(MakeStartupErrorMessage(aDiagnosticMessage)); + } } @@ -969,6 +992,7 @@ struct RefClearGuard @param bEmergencySave differs between EMERGENCY_SAVE and RECOVERY */ +#if !ENABLE_WASM_STRIP_RECOVERYUI bool impl_callRecoveryUI(bool bEmergencySave , bool bExistsRecoveryData) { @@ -1000,6 +1024,7 @@ bool impl_callRecoveryUI(bool bEmergencySave , aRet >>= bRet; return bRet; } +#endif bool impl_bringToFrontRecoveryUI() { @@ -1106,7 +1131,7 @@ bool isTimeForUpdateCheck() sal_uInt64 nLastUpdate = officecfg::Office::Update::Update::LastUpdateTime::get(); sal_uInt64 nNow = tools::Time::GetSystemTicks(); - sal_uInt64 n7DayInMS = 1000 * 60 * 60 * 12 * 1; // 12 hours in ms + sal_uInt64 n7DayInMS = 1000 * 60 * 60 * 24 * 7; // 7 days in ms if (nNow - n7DayInMS >= nLastUpdate) return true; @@ -1148,9 +1173,11 @@ void Desktop::Exception(ExceptionCategory nCategory) // Save all open documents so they will be reopened // the next time the application is started // returns true if at least one document could be saved... +#if !ENABLE_WASM_STRIP_RECOVERYUI bRestart = impl_callRecoveryUI( true , // force emergency save false); +#endif } FlushConfiguration(); @@ -1164,8 +1191,10 @@ void Desktop::Exception(ExceptionCategory nCategory) osl_removeSignalHandler( pSignalHandler ); restartOnMac(false); +#if !ENABLE_WASM_STRIP_SPLASH if ( m_rSplashScreen.is() ) m_rSplashScreen->reset(); +#endif _exit( EXITHELPER_CRASH_WITH_RESTART ); } @@ -1218,14 +1247,12 @@ struct ExecuteGlobals { Reference < css::document::XDocumentEventListener > xGlobalBroadcaster; bool bRestartRequested; - bool bUseSystemFileDialog; std::unique_ptr<SvtCTLOptions> pCTLLanguageOptions; std::unique_ptr<SvtPathOptions> pPathOptions; rtl::Reference< JVMloadThread > xJVMloadThread; ExecuteGlobals() : bRestartRequested( false ) - , bUseSystemFileDialog( true ) {} }; @@ -1268,14 +1295,16 @@ int Desktop::Main() Translate::SetReadStringHook(ReplaceStringHookProc); // Startup screen +#if !ENABLE_WASM_STRIP_SPLASH OpenSplashScreen(); +#endif SetSplashScreenProgress(10); userinstall::Status inst_fin = userinstall::finalize(); if (inst_fin != userinstall::EXISTED && inst_fin != userinstall::CREATED) { - SAL_WARN( "desktop.app", "userinstall failed"); + SAL_WARN( "desktop.app", "userinstall failed: " << inst_fin); if ( inst_fin == userinstall::ERROR_NO_SPACE ) HandleBootstrapErrors( BE_USERINSTALL_NOTENOUGHDISKSPACE, OUString() ); @@ -1295,11 +1324,11 @@ int Desktop::Main() Reference< XDesktop2 > xDesktop; - RegisterServices(xContext); + RegisterServices(); SetSplashScreenProgress(25); -#if HAVE_FEATURE_DESKTOP +#if HAVE_FEATURE_DESKTOP && !defined(EMSCRIPTEN) // check user installation directory for lockfile so we can be sure // there is no other instance using our data files from a remote host @@ -1332,6 +1361,22 @@ int Desktop::Main() if ( !InitializeConfiguration() ) return EXIT_FAILURE; + SetSplashScreenProgress(30); + + // create title string + OUString aTitle(ReplaceStringHookProc(RID_APPTITLE)); +#ifdef DBG_UTIL + //include buildid in non product builds + aTitle += " [" + utl::Bootstrap::getBuildIdData("development") + "]"; +#endif + + SetDisplayName( aTitle ); + SetSplashScreenProgress(35); + pExecGlobals->pPathOptions.reset( new SvtPathOptions); + SetSplashScreenProgress(40); + + xDesktop = css::frame::Desktop::create( xContext ); + #if HAVE_FEATURE_UPDATE_MAR const char* pUpdaterTestEnable = std::getenv("LIBO_UPDATER_TEST_ENABLE"); if (pUpdaterTestEnable || officecfg::Office::Update::Update::Enabled::get()) @@ -1395,7 +1440,10 @@ int Desktop::Main() CloseSplashScreen(); bool bSuccess = update(); if (bSuccess) + { + xDesktop->terminate(); return EXIT_SUCCESS; + } } else if (isTimeForUpdateCheck() || pForcedUpdateCheck) { @@ -1410,22 +1458,6 @@ int Desktop::Main() } #endif - SetSplashScreenProgress(30); - - // create title string - OUString aTitle(ReplaceStringHookProc(RID_APPTITLE)); -#ifdef DBG_UTIL - //include buildid in non product builds - aTitle += " [" + utl::Bootstrap::getBuildIdData("development") + "]"; -#endif - - SetDisplayName( aTitle ); - SetSplashScreenProgress(35); - pExecGlobals->pPathOptions.reset( new SvtPathOptions); - SetSplashScreenProgress(40); - - xDesktop = css::frame::Desktop::create( xContext ); - // create service for loading SFX (still needed in startup) pExecGlobals->xGlobalBroadcaster = Reference < css::document::XDocumentEventListener > ( css::frame::theGlobalEventBroadcaster::get(xContext), UNO_SET_THROW ); @@ -1500,18 +1532,6 @@ int Desktop::Main() } } - if ( rCmdLineArgs.IsHeadless() || rCmdLineArgs.IsEventTesting() ) - { - // Ensure that we use not the system file dialogs as - // headless mode relies on Application::EnableHeadlessMode() - // which does only work for VCL dialogs!! - pExecGlobals->bUseSystemFileDialog = officecfg::Office::Common::Misc::UseSystemFileDialog::get(); - std::shared_ptr< comphelper::ConfigurationChanges > xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::UseSystemFileDialog::set( false, xChanges ); - xChanges->commit(); - } - pExecGlobals->bRestartRequested = xRestartManager->isRestartRequested(true); if ( !pExecGlobals->bRestartRequested ) { @@ -1529,11 +1549,9 @@ int Desktop::Main() svtools::ApplyFontSubstitutionsToVcl(); - SvtTabAppearanceCfg aAppearanceCfg; SvtTabAppearanceCfg::SetInitialized(); - aAppearanceCfg.SetApplicationDefaults( this ); - SvtAccessibilityOptions aOptions; - aOptions.SetVCLSettings(); + SvtTabAppearanceCfg::SetApplicationDefaults( this ); + SvtAccessibilityOptions::SetVCLSettings(); SetSplashScreenProgress(60); if ( !pExecGlobals->bRestartRequested ) @@ -1561,26 +1579,22 @@ int Desktop::Main() CheckOpenCLCompute(xDesktop); #endif +#if !defined(EMSCRIPTEN) //Running the VCL graphics rendering tests - runGraphicsRenderTests(); - - // Reap the process started by fire_glxtest_process(). - reap_glxtest_process(); - - // Release solar mutex just before we wait for our client to connect + const char * pDisplay = std::getenv("DISPLAY"); + if (!pDisplay || pDisplay[0] == ':') { - SolarMutexReleaser aReleaser; - - // 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 construction!! - Application::PostUserEvent( LINK( this, Desktop, OpenClients_Impl ) ); + runGraphicsRenderTests(); + } +#endif - // Post event to enable acceptors - Application::PostUserEvent( LINK( this, Desktop, EnableAcceptors_Impl) ); + // 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 construction!! + Application::PostUserEvent( LINK( this, Desktop, OpenClients_Impl ) ); - // Acquire solar mutex just before we enter our message loop - } + // Post event to enable acceptors + Application::PostUserEvent( LINK( this, Desktop, EnableAcceptors_Impl) ); // call Application::Execute to process messages in vcl message loop #if HAVE_FEATURE_JAVA @@ -1631,16 +1645,7 @@ int Desktop::doShutdown() if ( pExecGlobals->bRestartRequested ) SetRestartState(); - // Restore old value const CommandLineArgs& rCmdLineArgs = GetCommandLineArgs(); - if ( rCmdLineArgs.IsHeadless() || rCmdLineArgs.IsEventTesting() ) - { - std::shared_ptr< comphelper::ConfigurationChanges > xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::UseSystemFileDialog::set( pExecGlobals->bUseSystemFileDialog, xChanges ); - xChanges->commit(); - } - OUString pidfileName = rCmdLineArgs.GetPidfileName(); if ( !pidfileName.isEmpty() ) { @@ -1711,8 +1716,10 @@ int Desktop::doShutdown() if ( bRR ) { restartOnMac(true); +#if !ENABLE_WASM_STRIP_SPLASH if ( m_rSplashScreen.is() ) m_rSplashScreen->reset(); +#endif return EXITHELPER_NORMAL_RESTART; } @@ -1843,23 +1850,23 @@ void Desktop::OverrideSystemSettings( AllSettings& rSettings ) DragFullOptions nDragFullOptions = hStyleSettings.GetDragFullOptions(); - SvtTabAppearanceCfg aAppearanceCfg; - DragMode nDragMode = aAppearanceCfg.GetDragMode(); + sal_uInt16 nDragMode = officecfg::Office::Common::View::Window::Drag::get(); switch ( nDragMode ) { - case DragMode::FullWindow: + case 0: //FullWindow: nDragFullOptions |= DragFullOptions::All; break; - case DragMode::Frame: + case 1: // Frame: nDragFullOptions &= ~DragFullOptions::All; break; - case DragMode::SystemDep: + case 2: // SystemDep default: break; } MouseFollowFlags nFollow = hMouseSettings.GetFollow(); - hMouseSettings.SetFollow( aAppearanceCfg.IsMenuMouseFollow() ? (nFollow|MouseFollowFlags::Menu) : (nFollow&~MouseFollowFlags::Menu)); + bool bMenuFollowMouse = officecfg::Office::Common::View::Menu::FollowMouse::get(); + hMouseSettings.SetFollow( bMenuFollowMouse ? (nFollow|MouseFollowFlags::Menu) : (nFollow&~MouseFollowFlags::Menu)); rSettings.SetMouseSettings(hMouseSettings); bool bMenuIcons = officecfg::Office::Common::View::Menu::ShowIconsInMenues::get(); @@ -2008,11 +2015,13 @@ void Desktop::OpenClients() } else { - bool bCrashed = false; bool bExistsRecoveryData = false; +#if !ENABLE_WASM_STRIP_RECOVERYUI + bool bCrashed = false; bool bExistsSessionData = false; bool const bDisableRecovery = getenv("OOO_DISABLE_RECOVERY") != nullptr + || IsOnSystemEventLoop() || !officecfg::Office::Recovery::RecoveryInfo::Enabled::get(); impl_checkRecoveryState(bCrashed, bExistsRecoveryData, bExistsSessionData); @@ -2035,6 +2044,7 @@ void Desktop::OpenClients() TOOLS_WARN_EXCEPTION( "desktop.app", "Error during recovery"); } } +#endif Reference< XSessionManagerListener2 > xSessionListener; try @@ -2393,6 +2403,7 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent ) } } +#if !ENABLE_WASM_STRIP_SPLASH void Desktop::OpenSplashScreen() { const CommandLineArgs &rCmdLine = GetCommandLineArgs(); @@ -2432,9 +2443,7 @@ void Desktop::OpenSplashScreen() if ( rCmdLine.HasSplashPipe() ) aSplashService = "com.sun.star.office.PipeSplashScreen"; - Sequence< Any > aSeq( 2 ); - aSeq[0] <<= true; // bVisible - aSeq[1] <<= aAppName; + Sequence< Any > aSeq{ Any(true) /* bVisible */, Any(aAppName) }; css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); m_rSplashScreen.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aSplashService, aSeq, xContext), @@ -2444,31 +2453,42 @@ void Desktop::OpenSplashScreen() m_rSplashScreen->start("SplashScreen", 100); } +#endif void Desktop::SetSplashScreenProgress(sal_Int32 iProgress) { +#if ENABLE_WASM_STRIP_SPLASH + (void) iProgress; +#else if(m_rSplashScreen.is()) { m_rSplashScreen->setValue(iProgress); } +#endif } void Desktop::SetSplashScreenText( const OUString& rText ) { +#if ENABLE_WASM_STRIP_SPLASH + (void) rText; +#else if( m_rSplashScreen.is() ) { m_rSplashScreen->setText( rText ); } +#endif } void Desktop::CloseSplashScreen() { +#if !ENABLE_WASM_STRIP_SPLASH if(m_rSplashScreen.is()) { SolarMutexGuard ensureSolarMutex; m_rSplashScreen->end(); m_rSplashScreen = nullptr; } +#endif } |