From 98acef27d06dfa63274ec4ce0ec934fc52e5a15d Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 18 Sep 2012 12:40:57 +0200 Subject: Don't access broken service mgr during bootstrap failure ...so that displaying a (non-translated) error box upon BE_UNO_SERVICEMANAGER works after all. Augment the error text with an exception message where appropriate. This allows to revert fdfb7a3c4b3a89b73ab5546b9620348bc4984d8f "Related fdo#51252: Report uncaught exceptions with MessageBox on Windows" as that was to catch and display failures from instantiating the service mgr. (cherry picked from commit cccc6bcfa095121c91e8bbc396f5bcf7e95424b9) Change-Id: I049a38e95342634796eb0e940e2ee8e55193c9d3 Reviewed-on: https://gerrit.libreoffice.org/654 Reviewed-by: Michael Stahl Tested-by: Michael Stahl --- desktop/inc/app.hxx | 19 +++-- desktop/source/app/app.cxx | 139 ++++++++++++++++++------------------- desktop/source/app/desktop.hrc | 1 - desktop/source/app/desktop.src | 5 -- desktop/source/app/sofficemain.cxx | 21 +----- 5 files changed, 77 insertions(+), 108 deletions(-) (limited to 'desktop') diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index c830b02506fd..8805c57ca951 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -107,15 +107,16 @@ class Desktop : public Application static ResMgr* GetDesktopResManager(); static CommandLineArgs& GetCommandLineArgs(); - void HandleBootstrapErrors( BootstrapError ); - void SetBootstrapError( BootstrapError nError ) + void HandleBootstrapErrors( + BootstrapError nError, rtl::OUString const & aMessage ); + void SetBootstrapError( + BootstrapError nError, rtl::OUString const & aMessage ) { if ( m_aBootstrapError == BE_OK ) + { m_aBootstrapError = nError; - } - BootstrapError GetBootstrapError() const - { - return m_aBootstrapError; + m_aBootstrapErrorMessage = aMessage; + } } void SetBootstrapStatus( BootstrapStatus nStatus ) @@ -139,8 +140,6 @@ class Desktop : public Application void SetSplashScreenText( const ::rtl::OUString& rText ); void SetSplashScreenProgress( sal_Int32 ); - static void ensureProcessServiceFactory(); - private: // Bootstrap methods static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > CreateApplicationServiceManager(); @@ -163,9 +162,6 @@ class Desktop : public Application void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const ::rtl::OUString& aMsg ); void StartSetup( const ::rtl::OUString& aParameters ); - // Get a resource message string securely e.g. if resource cannot be retrieved return aFaultBackMsg - ::rtl::OUString GetMsgString( sal_uInt16 nId, const ::rtl::OUString& aFaultBackMsg ); - // Create a error message depending on bootstrap failure code and an optional file url ::rtl::OUString CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode, const ::rtl::OUString& aFileURL ); @@ -207,6 +203,7 @@ class Desktop : public Application bool m_bServicesRegistered; sal_uInt16 m_nAppEvents; BootstrapError m_aBootstrapError; + rtl::OUString m_aBootstrapErrorMessage; BootstrapStatus m_aBootstrapStatus; std::auto_ptr< Lockfile > m_pLockfile; diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 5fb653b5484d..ea350ca6fe1d 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -373,28 +373,34 @@ ResMgr* Desktop::GetDesktopResManager() return Desktop::pResMgr; } +namespace { + // ---------------------------------------------------------------------------- // Get a message string securely. There is a fallback string if the resource // is not available. -OUString Desktop::GetMsgString( sal_uInt16 nId, const OUString& aFaultBackMsg ) +OUString GetMsgString( + sal_uInt16 nId, const OUString& aFaultBackMsg, + bool bAlwaysUseFaultBackMsg = false ) { - ResMgr* resMgr = GetDesktopResManager(); - if ( !resMgr ) - return aFaultBackMsg; - else - return OUString( String( ResId( nId, *resMgr ))); + if ( !bAlwaysUseFaultBackMsg ) + { + ResMgr* resMgr = Desktop::GetDesktopResManager(); + if ( resMgr ) + return OUString( String( ResId( nId, *resMgr ))); + } + return aFaultBackMsg; } -OUString MakeStartupErrorMessage(OUString const & aErrorMessage) +OUString MakeStartupErrorMessage( + OUString const & aErrorMessage, bool bAlwaysUseFaultBackMsg = false ) { OUStringBuffer aDiagnosticMessage( 100 ); - ResMgr* pResMgr = Desktop::GetDesktopResManager(); - if ( pResMgr ) - aDiagnosticMessage.append( OUString(String(ResId(STR_BOOTSTRAP_ERR_CANNOT_START, *pResMgr))) ); - else - aDiagnosticMessage.appendAscii( "The program cannot be started." ); + aDiagnosticMessage.append( + GetMsgString( + STR_BOOTSTRAP_ERR_CANNOT_START, "The program cannot be started.", + bAlwaysUseFaultBackMsg ) ); aDiagnosticMessage.appendAscii( "\n" ); @@ -463,9 +469,8 @@ static bool ShouldSuppressUI(const CommandLineArgs& rCmdLine) rCmdLine.IsQuickstart(); } -namespace -{ - struct theCommandLineArgs : public rtl::Static< CommandLineArgs, theCommandLineArgs > {}; +struct theCommandLineArgs : public rtl::Static< CommandLineArgs, theCommandLineArgs > {}; + } CommandLineArgs& Desktop::GetCommandLineArgs() @@ -583,29 +588,30 @@ void Desktop::Init() // We need to have service factory before going further, but see fdo#37195. // Doing this will mmap common.rdb, making it not overwritable on windows, // so this can't happen before the synchronization above. Lets rework this - // so that the above is called *from* ensureProcessServiceFactory or + // so that the above is called *from* CreateApplicationServiceManager or // something to enforce this gotcha - ensureProcessServiceFactory(); - - if( !::comphelper::getProcessServiceFactory().is()) + try + { + comphelper::setProcessServiceFactory(CreateApplicationServiceManager()); + } + catch (css::uno::Exception & e) { - OSL_FAIL("Service factory should have been crated in soffice_main()."); - SetBootstrapError( BE_UNO_SERVICEMANAGER ); + SetBootstrapError( BE_UNO_SERVICEMANAGER, e.Message ); } - if ( GetBootstrapError() == BE_OK ) + if ( m_aBootstrapError == BE_OK ) { // prepare language if ( !LanguageSelection::prepareLanguage() ) { if ( LanguageSelection::getStatus() == LanguageSelection::LS_STATUS_CANNOT_DETERMINE_LANGUAGE ) - SetBootstrapError( BE_LANGUAGE_MISSING ); + SetBootstrapError( BE_LANGUAGE_MISSING, OUString() ); else - SetBootstrapError( BE_OFFICECONFIG_BROKEN ); + SetBootstrapError( BE_OFFICECONFIG_BROKEN, OUString() ); } } - if ( GetBootstrapError() == BE_OK ) + if ( m_aBootstrapError == BE_OK ) { const CommandLineArgs& rCmdLineArgs = GetCommandLineArgs(); // start ipc thread only for non-remote offices @@ -613,7 +619,7 @@ void Desktop::Init() OfficeIPCThread::Status aStatus = OfficeIPCThread::EnableOfficeIPCThread(); if ( aStatus == OfficeIPCThread::IPC_STATUS_BOOTSTRAP_ERROR ) { - SetBootstrapError( BE_PATHINFO_MISSING ); + SetBootstrapError( BE_PATHINFO_MISSING, OUString() ); } else if ( aStatus == OfficeIPCThread::IPC_STATUS_2ND_OFFICE ) { @@ -636,29 +642,6 @@ void Desktop::InitFinished() CloseSplashScreen(); } -// GetCommandLineArgs() requires this code to work, otherwise it will abort, and -// on Unix command line args needs to be checked before Desktop::Init() -void Desktop::ensureProcessServiceFactory() -{ - if (!comphelper::getProcessServiceFactory().is()) - { - try - { - comphelper::setProcessServiceFactory( - CreateApplicationServiceManager()); - } - catch (const css::uno::Exception& e) - { - // Application::ShowNativeErrorBox would only work after InitVCL, so - // all we can realistically do here is hope the user can see stderr: - std::cerr << "UNO Exception: " << e.Message << std::endl; - // Let exceptions escape and tear down the process, it is completely - // broken anyway: - throw; - } - } -} - void Desktop::DeInit() { RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::DeInit" ); @@ -873,7 +856,8 @@ void Desktop::HandleBootstrapPathErrors( ::utl::Bootstrap::Status aBootstrapStat return MakeStartupErrorMessage( aMsg ); } -void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError ) +void Desktop::HandleBootstrapErrors( + BootstrapError aBootstrapError, OUString const & aErrorMessage ) { if ( aBootstrapError == BE_PATHINFO_MISSING ) { @@ -954,16 +938,18 @@ void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError ) // 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); + std::cerr + << "The application cannot be started.\n" + // STR_BOOTSTRAP_ERR_CANNOT_START + << (aBootstrapError == BE_UNO_SERVICEMANAGER + ? "The component manager is not available.\n" + // STR_BOOTSTRAP_ERR_NO_SERVICE + : "The configuration service is not available.\n"); + // STR_BOOTSTRAP_ERR_NO_CFG_SERVICE + if ( !aErrorMessage.isEmpty() ) + { + std::cerr << "(\"" << aErrorMessage << "\")\n"; + } // First sentence. We cannot bootstrap office further! OUString aMessage; @@ -972,24 +958,32 @@ void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError ) OUString aErrorMsg; if ( aBootstrapError == BE_UNO_SERVICEMANAGER ) - aErrorMsg = GetMsgString( STR_BOOTSTRAP_ERR_NO_SERVICE, - OUString( "The service manager is not available." ) ); + aErrorMsg = "The service manager is not available."; else aErrorMsg = GetMsgString( STR_BOOTSTRAP_ERR_NO_CFG_SERVICE, OUString( "The configuration service is not available." ) ); aDiagnosticMessage.append( aErrorMsg ); aDiagnosticMessage.appendAscii( "\n" ); + if ( !aErrorMessage.isEmpty() ) + { + aDiagnosticMessage.appendAscii( "(\"" ); + aDiagnosticMessage.append( aErrorMessage ); + aDiagnosticMessage.appendAscii( "\")\n" ); + } // 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( "Start setup application to repair the installation from CD, or the folder containing the installation packages." ) )); + OUString( "Start setup application to repair the installation from CD, or the folder containing the installation packages." ), + aBootstrapError == BE_UNO_SERVICEMANAGER ) ); aDiagnosticMessage.append( aStartSetupManually ); - aMessage = MakeStartupErrorMessage( aDiagnosticMessage.makeStringAndClear() ); + aMessage = MakeStartupErrorMessage( + aDiagnosticMessage.makeStringAndClear(), + aBootstrapError == BE_UNO_SERVICEMANAGER ); FatalError( aMessage); } @@ -1386,10 +1380,9 @@ int Desktop::Main() com::sun::star::uno::ContextLayer layer( com::sun::star::uno::getCurrentContext() ); - BootstrapError eError = GetBootstrapError(); - if ( eError != BE_OK ) + if ( m_aBootstrapError != BE_OK ) { - HandleBootstrapErrors( eError ); + HandleBootstrapErrors( m_aBootstrapError, m_aBootstrapErrorMessage ); return EXIT_FAILURE; } @@ -1423,11 +1416,12 @@ int Desktop::Main() { OSL_FAIL("userinstall failed"); if ( inst_fin == UserInstall::E_NoDiskSpace ) - HandleBootstrapErrors( BE_USERINSTALL_NOTENOUGHDISKSPACE ); + HandleBootstrapErrors( + BE_USERINSTALL_NOTENOUGHDISKSPACE, OUString() ); else if ( inst_fin == UserInstall::E_NoWriteAccess ) - HandleBootstrapErrors( BE_USERINSTALL_NOWRITEACCESS ); + HandleBootstrapErrors( BE_USERINSTALL_NOWRITEACCESS, OUString() ); else - HandleBootstrapErrors( BE_USERINSTALL_FAILED ); + HandleBootstrapErrors( BE_USERINSTALL_FAILED, OUString() ); return EXIT_FAILURE; } // refresh path information @@ -1805,9 +1799,10 @@ bool Desktop::InitializeConfiguration() comphelper::getProcessComponentContext() ); return true; } - catch( const ::com::sun::star::lang::ServiceNotRegisteredException& ) + catch( ::com::sun::star::lang::ServiceNotRegisteredException & e ) { - this->HandleBootstrapErrors( Desktop::BE_UNO_SERVICE_CONFIG_MISSING ); + this->HandleBootstrapErrors( + Desktop::BE_UNO_SERVICE_CONFIG_MISSING, e.Message ); } catch( const ::com::sun::star::configuration::MissingBootstrapFileException& e ) { diff --git a/desktop/source/app/desktop.hrc b/desktop/source/app/desktop.hrc index 9c68d7b9fd2d..83aa711aaaca 100644 --- a/desktop/source/app/desktop.hrc +++ b/desktop/source/app/desktop.hrc @@ -67,7 +67,6 @@ #define STR_BOOTSTRAP_ERR_NO_SUPPORT (RID_DESKTOP_STRING_START+107) #define STR_BOOTSTRAP_ERR_LANGUAGE_MISSING (RID_DESKTOP_STRING_START+108) -#define STR_BOOTSTRAP_ERR_NO_SERVICE (RID_DESKTOP_STRING_START+120) #define STR_BOOTSTRAP_ERR_NO_CFG_SERVICE (RID_DESKTOP_STRING_START+121) #define STR_BOOTSTRAP_ERR_CFG_DATAACCESS (RID_DESKTOP_STRING_START+122) #define STR_BOOTSTRAP_ERR_NO_PATHSET_SERVICE (RID_DESKTOP_STRING_START+123) diff --git a/desktop/source/app/desktop.src b/desktop/source/app/desktop.src index 0b6bc3f3c803..913f88ba92ed 100644 --- a/desktop/source/app/desktop.src +++ b/desktop/source/app/desktop.src @@ -88,11 +88,6 @@ String STR_BOOTSTRAP_ERR_LANGUAGE_MISSING Text [ en-US ] = "The user interface language cannot be determined."; }; -String STR_BOOTSTRAP_ERR_NO_SERVICE -{ - Text [ en-US ] = "The component manager is not available."; -}; - String STR_BOOTSTRAP_ERR_NO_CFG_SERVICE { Text [ en-US ] = "The configuration service is not available."; diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx index a0fba044922e..e867601df0ee 100755 --- a/desktop/source/app/sofficemain.cxx +++ b/desktop/source/app/sofficemain.cxx @@ -38,21 +38,14 @@ #include #include -#if defined WNT -#define WIN32_LEAN_AND_MEAN -#include -#endif - int SVMain(); // -=-= main() -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= extern "C" int DESKTOP_DLLPUBLIC soffice_main() { -#if defined ANDROID || defined WNT +#if defined ANDROID try { -#endif -#if defined(ANDROID) rtl::Bootstrap::setIniFilename( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///assets/program/lofficerc"))); #endif @@ -83,20 +76,10 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main() } #endif return SVMain(); -#if defined ANDROID || defined WNT - } catch (const ::com::sun::star::uno::Exception &e) { #if defined ANDROID + } catch (const ::com::sun::star::uno::Exception &e) { fprintf (stderr, "Not handled UNO exception at main: '%s'\n", rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); -#elif defined WNT - MessageBoxW( - 0, - reinterpret_cast< LPCWSTR >( - rtl::OUString("Unhandled exception:\n" + e.Message).getStr()), - reinterpret_cast< LPCWSTR >(rtl::OUString("Fatal Error").getStr()), - (MB_OK | MB_ICONERROR | MB_DEFBUTTON1 | MB_TASKMODAL - | MB_SETFOREGROUND | MB_TOPMOST)); -#endif throw; // to get exception type printed } #endif -- cgit v1.2.3 From 3752aca388adaf633e21a47576c770d73bf7e8d3 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 21 Sep 2012 13:33:37 +0200 Subject: Properly check cmdline args in oosplash ...so that e.g. --headless (starting with a "h") is not also mistaken as -h and disables pagein and javaldx. Change-Id: I8a7b2b0373d96ec586975e07e17e7eabe201dcd0 (cherry picked from commit b247950eeeb2ea2345633ee018fbe2c55c1942c0) Reviewed-on: https://gerrit.libreoffice.org/666 Reviewed-by: Michael Meeks Tested-by: Michael Meeks --- desktop/unx/source/args.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'desktop') diff --git a/desktop/unx/source/args.c b/desktop/unx/source/args.c index 0952911b5763..0e01123cb242 100644 --- a/desktop/unx/source/args.c +++ b/desktop/unx/source/args.c @@ -126,14 +126,16 @@ Args *args_parse (void) } for ( j = 0; j < SAL_N_ELEMENTS (pArgDescr); ++j ) { - if (!rtl_ustr_indexOfAscii_WithLength - (arg, length, pArgDescr[j].name, strlen (pArgDescr[j].name))) { - + if (rtl_ustr_ascii_compare_WithLength( + arg, length, pArgDescr[j].name) + == 0) + { args->bInhibitSplash |= pArgDescr[j].bInhibitSplash; args->bInhibitPagein |= pArgDescr[j].bInhibitPagein; args->bInhibitJavaLdx |= pArgDescr[j].bInhibitJavaLdx; if (pArgDescr[j].pPageinType) args->pPageinType = pArgDescr[j].pPageinType; + break; } } } -- cgit v1.2.3 From 3223ae5224ee17a501f251ba88ea3e4debb18e07 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 24 Sep 2012 17:41:51 +0200 Subject: fdo#54385: Displaying help/version early on UNX requires service manager This regression was introduced with 6c6358a6822d3562b9b8c7668a7d60d6c644dfe8 "Related fdo#53006: Do not instantiate service manager too early." Change-Id: If22ea3ac6474188bf0792246620e5c705a813445 (cherry picked from commit 2f14e2e67c58fe6948501d57a38cd0d2ad84dfff) Reviewed-on: https://gerrit.libreoffice.org/694 Reviewed-by: Miklos Vajna Tested-by: Miklos Vajna --- desktop/inc/app.hxx | 6 +++--- desktop/source/app/app.cxx | 2 +- desktop/source/app/appinit.cxx | 9 +++++---- desktop/source/app/sofficemain.cxx | 2 ++ 4 files changed, 11 insertions(+), 8 deletions(-) (limited to 'desktop') diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 8805c57ca951..ecfd0143baf8 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -140,11 +140,11 @@ class Desktop : public Application void SetSplashScreenText( const ::rtl::OUString& rText ); void SetSplashScreenProgress( sal_Int32 ); - private: // Bootstrap methods - static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > CreateApplicationServiceManager(); - // returns a non-null reference or throws an exception + static void InitApplicationServiceManager(); + // throws an exception upon failure + private: void RegisterServices(); void DeregisterServices(); diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index ea350ca6fe1d..a5177dd88ff1 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -592,7 +592,7 @@ void Desktop::Init() // something to enforce this gotcha try { - comphelper::setProcessServiceFactory(CreateApplicationServiceManager()); + InitApplicationServiceManager(); } catch (css::uno::Exception & e) { diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index 4b33cb29fa6d..7a32d13c19f2 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -163,20 +163,21 @@ static bool configureUcb() return ret; } -Reference< XMultiServiceFactory > Desktop::CreateApplicationServiceManager() +void Desktop::InitApplicationServiceManager() { RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::createApplicationServiceManager" ); - + Reference sm; #ifdef ANDROID rtl::OUString aUnoRc( OUString( "file:///assets/program/unorc" ) ); - return Reference( + sm.set( cppu::defaultBootstrap_InitialComponentContext( aUnoRc )->getServiceManager(), UNO_QUERY_THROW); #else - return Reference( + sm.set( cppu::defaultBootstrap_InitialComponentContext()->getServiceManager(), UNO_QUERY_THROW); #endif + comphelper::setProcessServiceFactory(sm); } void Desktop::DestroyApplicationServiceManager( Reference< XMultiServiceFactory >& xSMgr ) diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx index e867601df0ee..9463b51c9fb1 100755 --- a/desktop/source/app/sofficemain.cxx +++ b/desktop/source/app/sofficemain.cxx @@ -62,11 +62,13 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main() const desktop::CommandLineArgs& rCmdLineArgs = aDesktop.GetCommandLineArgs(); if ( rCmdLineArgs.IsHelp() ) { + desktop::Desktop::InitApplicationServiceManager(); desktop::displayCmdlineHelp(); return EXIT_SUCCESS; } else if ( rCmdLineArgs.IsVersion() ) { + desktop::Desktop::InitApplicationServiceManager(); desktop::displayVersion(); return EXIT_SUCCESS; } -- cgit v1.2.3 From 81a441c695f01bb67fcf41120d5843660d7531fc Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 25 Sep 2012 10:15:15 +0200 Subject: Clean up option processing * Support --version on non-UNX, too. * Consistently show the first unknown option and the help blob in the presence of any unknown options. * There is no need to tunnel --help/--version past oosplash in the soffice script, as oosplash is prepared to treat them adequately (esp. not pass them over any pipe); this only added unnecessary variance to what spellings exactly are supported and how mixtures of --help, --version, and unknown options are handled. (cherry picked from commit f4a4ba9ac1b58b4726825400e1edd1bf47d4080a) Change-Id: I617f2e727e2f0eafd34a2de3b85d441c6783ec4f Reviewed-on: https://gerrit.libreoffice.org/700 Reviewed-by: Noel Power Tested-by: Noel Power --- desktop/scripts/soffice.sh | 16 -- desktop/source/app/app.cxx | 35 ++-- desktop/source/app/cmdlineargs.cxx | 18 +- desktop/source/app/cmdlineargs.hxx | 6 +- desktop/source/app/cmdlinehelp.cxx | 7 +- desktop/source/app/cmdlinehelp.hxx | 2 +- desktop/source/app/officeipcthread.cxx | 329 +++++++++++++++++---------------- desktop/source/app/sofficemain.cxx | 15 +- desktop/unx/source/args.c | 39 ++-- desktop/unx/source/args.h | 1 + desktop/unx/source/start.c | 26 +-- vcl/inc/vcl/svapp.hxx | 6 +- 12 files changed, 256 insertions(+), 244 deletions(-) (limited to 'desktop') diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh index 97a2be913f13..f35bebb158f1 100755 --- a/desktop/scripts/soffice.sh +++ b/desktop/scripts/soffice.sh @@ -158,21 +158,5 @@ if [ -n "$VALGRINDCHECK" -a -z "$VALGRIND" ] ; then exec &>valgrind.log fi -# do not pass the request for command line help to oosplash -for arg in $@ ; do - case "$arg" in - -h | --h | --he | --hel | --help) - "$sd_prog/soffice.bin" --help - exit 0 - ;; - -V | --v | --ve | --ver | --vers | --versi | --versio | --version) - "$sd_prog/soffice.bin" --version - exit 0 - ;; - *) - ;; - esac -done - # oosplash does the rest: forcing pages in, javaldx etc. are exec $VALGRINDCHECK $STRACECHECK "$sd_prog/oosplash" "$@" diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index a5177dd88ff1..001eac7bee07 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -626,7 +626,8 @@ void Desktop::Init() // 2nd office startup should terminate after sending cmdlineargs through pipe SetBootstrapStatus(BS_TERMINATE); } - else if ( rCmdLineArgs.IsHelp() ) + else if ( !rCmdLineArgs.GetUnknown().isEmpty() + || rCmdLineArgs.IsHelp() || rCmdLineArgs.IsVersion() ) { // disable IPC thread in an instance that is just showing a help message OfficeIPCThread::DisableOfficeIPCThread(); @@ -1396,6 +1397,22 @@ int Desktop::Main() new DesktopContext( com::sun::star::uno::getCurrentContext() ) ); CommandLineArgs& rCmdLineArgs = GetCommandLineArgs(); + OUString aUnknown( rCmdLineArgs.GetUnknown() ); + if ( !aUnknown.isEmpty() ) + { + displayCmdlineHelp( aUnknown ); + return EXIT_FAILURE; + } + if ( rCmdLineArgs.IsHelp() ) + { + displayCmdlineHelp( OUString() ); + return EXIT_SUCCESS; + } + if ( rCmdLineArgs.IsVersion() ) + { + displayVersion(); + return EXIT_SUCCESS; + } // setup configuration error handling ConfigurationErrorHandler aConfigErrHandler; @@ -1439,14 +1456,6 @@ int Desktop::Main() SetSplashScreenProgress(25); -#ifndef UNX - if ( rCmdLineArgs.IsHelp() ) - { - displayCmdlineHelp(); - return EXIT_SUCCESS; - } -#endif - // 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" ); @@ -2709,10 +2718,10 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent ) } break; case ApplicationEvent::TYPE_HELP: -#ifndef UNX - // in non unix version allow showing of cmdline help window - displayCmdlineHelp(); -#endif + displayCmdlineHelp(rAppEvent.GetData()); + break; + case ApplicationEvent::TYPE_VERSION: + displayVersion(); break; case ApplicationEvent::TYPE_OPEN: { diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index 473dfd69d309..51bdad0ba857 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -287,26 +287,25 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) { bConversionOutEvent = true; } -#if defined UNX else // because it's impossible to filter these options that // are handled in the soffice shell script with the // primitive tools that /bin/sh offers, ignore them here - if (!oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("backtrace")) && + if ( +#if defined UNX + !oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("backtrace")) && !oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("strace")) && !oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("valgrind")) && // for X Session Management, handled in // vcl/unx/generic/app/sm.cxx: !oArg.match("session=") && +#endif //ignore additional legacy options that don't do anything anymore - !oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("nocrashreport"))) + !oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("nocrashreport")) && + m_unknown.isEmpty()) { - fprintf(stderr, "Unknown option %s\n", - rtl::OUStringToOString(aArg, osl_getThreadTextEncoding()).getStr()); - fprintf(stderr, "Run 'soffice --help' to see a full list of available command line options.\n"); - m_unknown = true; + m_unknown = aArg; } -#endif } else { @@ -623,7 +622,6 @@ void CommandLineArgs::InitParamValues() m_helpbase = false; m_psn = false; m_version = false; - m_unknown = false; m_splashpipe = false; m_bEmpty = true; m_bDocumentArgs = false; @@ -761,7 +759,7 @@ bool CommandLineArgs::IsVersion() const return m_version; } -bool CommandLineArgs::HasUnknown() const +OUString CommandLineArgs::GetUnknown() const { return m_unknown; } diff --git a/desktop/source/app/cmdlineargs.hxx b/desktop/source/app/cmdlineargs.hxx index c6286d2ba895..995176346463 100644 --- a/desktop/source/app/cmdlineargs.hxx +++ b/desktop/source/app/cmdlineargs.hxx @@ -93,9 +93,10 @@ class CommandLineArgs: private boost::noncopyable bool IsWeb() const; bool IsVersion() const; bool HasModuleParam() const; - bool HasUnknown() const; bool WantsToLoadDocument() const; + rtl::OUString GetUnknown() const; + // Access to string parameters bool HasSplashPipe() const; std::vector< rtl::OUString > const & GetAccept() const; @@ -153,9 +154,10 @@ class CommandLineArgs: private boost::noncopyable bool m_helpbase; bool m_psn; bool m_version; - bool m_unknown; bool m_splashpipe; + rtl::OUString m_unknown; + bool m_bEmpty; // No Args at all bool m_bDocumentArgs; // A document creation/open/load arg is used std::vector< rtl::OUString > m_accept; diff --git a/desktop/source/app/cmdlinehelp.cxx b/desktop/source/app/cmdlinehelp.cxx index d09b5012f0ba..79741de80969 100644 --- a/desktop/source/app/cmdlinehelp.cxx +++ b/desktop/source/app/cmdlinehelp.cxx @@ -136,7 +136,7 @@ namespace desktop rtl::OUString ReplaceStringHookProc(const rtl::OUString& rStr); - void displayCmdlineHelp() + void displayCmdlineHelp(rtl::OUString const & unknown) { // if you put variables in other chunks don't forget to call the replace routines // for those chunks... @@ -147,6 +147,11 @@ namespace desktop String aHelpMessage_bottom(aCmdLineHelp_bottom, RTL_TEXTENCODING_ASCII_US); aHelpMessage_version = ReplaceStringHookProc(aHelpMessage_version); aHelpMessage_head.SearchAndReplaceAscii( "%CMDNAME", String( "soffice", RTL_TEXTENCODING_ASCII_US) ); + if (!unknown.isEmpty()) + { + aHelpMessage_head = "Unknown option: " + unknown + "\n\n" + + aHelpMessage_head; + } #ifdef UNX // on unix use console for output fprintf(stdout, "%s%s", diff --git a/desktop/source/app/cmdlinehelp.hxx b/desktop/source/app/cmdlinehelp.hxx index 5c92512ea1e9..fbf520af7521 100644 --- a/desktop/source/app/cmdlinehelp.hxx +++ b/desktop/source/app/cmdlinehelp.hxx @@ -5,7 +5,7 @@ namespace desktop { - void displayCmdlineHelp( void ); + void displayCmdlineHelp( rtl::OUString const & unknown ); void displayVersion(); #ifndef UNX class CmdlineHelpDialog : public ModalDialog diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index e99eb1d20eac..b9ede23532d9 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -700,192 +700,193 @@ void OfficeIPCThread::execute() continue; } -#ifdef UNX - if (aCmdLineArgs->HasUnknown() || aCmdLineArgs->IsVersion() || aCmdLineArgs->IsHelp()) - continue; -#endif - - const CommandLineArgs &rCurrentCmdLineArgs = Desktop::GetCommandLineArgs(); + sal_Bool bDocRequestSent = sal_False; - if ( aCmdLineArgs->IsQuickstart() ) + OUString aUnknown( aCmdLineArgs->GetUnknown() ); + if ( !aUnknown.isEmpty() || aCmdLineArgs->IsHelp() ) { - // we have to use application event, because we have to start quickstart service in main thread!! ApplicationEvent* pAppEvent = - new ApplicationEvent(ApplicationEvent::TYPE_QUICKSTART); + new ApplicationEvent(ApplicationEvent::TYPE_HELP, aUnknown); ImplPostForeignAppEvent( pAppEvent ); } - - // handle request for acceptor - std::vector< rtl::OUString > const & accept = aCmdLineArgs-> - GetAccept(); - for (std::vector< rtl::OUString >::const_iterator i(accept.begin()); - i != accept.end(); ++i) + else if ( aCmdLineArgs->IsVersion() ) { - ApplicationEvent* pAppEvent = new ApplicationEvent( - ApplicationEvent::TYPE_ACCEPT, *i); - ImplPostForeignAppEvent( pAppEvent ); - } - // handle acceptor removal - std::vector< rtl::OUString > const & unaccept = aCmdLineArgs-> - GetUnaccept(); - for (std::vector< rtl::OUString >::const_iterator i( - unaccept.begin()); - i != unaccept.end(); ++i) - { - ApplicationEvent* pAppEvent = new ApplicationEvent( - ApplicationEvent::TYPE_UNACCEPT, *i); - ImplPostForeignAppEvent( pAppEvent ); - } - -#ifndef UNX - // only in non-unix version, we need to handle a -help request - // in a running instance in order to display the command line help - if ( aCmdLineArgs->IsHelp() ) { ApplicationEvent* pAppEvent = - new ApplicationEvent(ApplicationEvent::TYPE_HELP); + new ApplicationEvent(ApplicationEvent::TYPE_VERSION); ImplPostForeignAppEvent( pAppEvent ); } -#endif - - sal_Bool bDocRequestSent = sal_False; - ProcessDocumentsRequest* pRequest = new ProcessDocumentsRequest( - aCmdLineArgs->getCwdUrl()); - cProcessed.reset(); - pRequest->pcProcessed = &cProcessed; - - // Print requests are not dependent on the --invisible cmdline argument as they are - // loaded with the "hidden" flag! So they are always checked. - pRequest->aPrintList = aCmdLineArgs->GetPrintList(); - bDocRequestSent |= !pRequest->aPrintList.empty(); - pRequest->aPrintToList = aCmdLineArgs->GetPrintToList(); - pRequest->aPrinterName = aCmdLineArgs->GetPrinterName(); - bDocRequestSent |= !( pRequest->aPrintToList.empty() || pRequest->aPrinterName.isEmpty() ); - - if ( !rCurrentCmdLineArgs.IsInvisible() ) + else { - // Read cmdline args that can open/create documents. As they would open a window - // they are only allowed if the "--invisible" is currently not used! - pRequest->aOpenList = aCmdLineArgs->GetOpenList(); - bDocRequestSent |= !pRequest->aOpenList.empty(); - pRequest->aViewList = aCmdLineArgs->GetViewList(); - bDocRequestSent |= !pRequest->aViewList.empty(); - pRequest->aStartList = aCmdLineArgs->GetStartList(); - bDocRequestSent |= !pRequest->aStartList.empty(); - pRequest->aForceOpenList = aCmdLineArgs->GetForceOpenList(); - bDocRequestSent |= !pRequest->aForceOpenList.empty(); - pRequest->aForceNewList = aCmdLineArgs->GetForceNewList(); - bDocRequestSent |= !pRequest->aForceNewList.empty(); - - // Special command line args to create an empty document for a given module - - // #i18338# (lo) - // we only do this if no document was specified on the command line, - // since this would be inconsistent with the the behaviour of - // the first process, see OpenClients() (call to OpenDefault()) in app.cxx - if ( aCmdLineArgs->HasModuleParam() && (!bDocRequestSent) ) + const CommandLineArgs &rCurrentCmdLineArgs = Desktop::GetCommandLineArgs(); + + if ( aCmdLineArgs->IsQuickstart() ) { - SvtModuleOptions aOpt; - SvtModuleOptions::EFactory eFactory = SvtModuleOptions::E_WRITER; - if ( aCmdLineArgs->IsWriter() ) - eFactory = SvtModuleOptions::E_WRITER; - else if ( aCmdLineArgs->IsCalc() ) - eFactory = SvtModuleOptions::E_CALC; - else if ( aCmdLineArgs->IsDraw() ) - eFactory = SvtModuleOptions::E_DRAW; - else if ( aCmdLineArgs->IsImpress() ) - eFactory = SvtModuleOptions::E_IMPRESS; - else if ( aCmdLineArgs->IsBase() ) - eFactory = SvtModuleOptions::E_DATABASE; - else if ( aCmdLineArgs->IsMath() ) - eFactory = SvtModuleOptions::E_MATH; - else if ( aCmdLineArgs->IsGlobal() ) - eFactory = SvtModuleOptions::E_WRITERGLOBAL; - else if ( aCmdLineArgs->IsWeb() ) - eFactory = SvtModuleOptions::E_WRITERWEB; - - if ( !pRequest->aOpenList.empty() ) - pRequest->aModule = aOpt.GetFactoryName( eFactory ); - else - pRequest->aOpenList.push_back( aOpt.GetFactoryEmptyDocumentURL( eFactory ) ); - bDocRequestSent = sal_True; + // we have to use application event, because we have to start quickstart service in main thread!! + ApplicationEvent* pAppEvent = + new ApplicationEvent(ApplicationEvent::TYPE_QUICKSTART); + ImplPostForeignAppEvent( pAppEvent ); } - } - if ( !aCmdLineArgs->IsQuickstart() ) { - sal_Bool bShowHelp = sal_False; - rtl::OUStringBuffer aHelpURLBuffer; - if (aCmdLineArgs->IsHelpWriter()) { - bShowHelp = sal_True; - aHelpURLBuffer.appendAscii("vnd.sun.star.help://swriter/start"); - } else if (aCmdLineArgs->IsHelpCalc()) { - bShowHelp = sal_True; - aHelpURLBuffer.appendAscii("vnd.sun.star.help://scalc/start"); - } else if (aCmdLineArgs->IsHelpDraw()) { - bShowHelp = sal_True; - aHelpURLBuffer.appendAscii("vnd.sun.star.help://sdraw/start"); - } else if (aCmdLineArgs->IsHelpImpress()) { - bShowHelp = sal_True; - aHelpURLBuffer.appendAscii("vnd.sun.star.help://simpress/start"); - } else if (aCmdLineArgs->IsHelpBase()) { - bShowHelp = sal_True; - aHelpURLBuffer.appendAscii("vnd.sun.star.help://sdatabase/start"); - } else if (aCmdLineArgs->IsHelpBasic()) { - bShowHelp = sal_True; - aHelpURLBuffer.appendAscii("vnd.sun.star.help://sbasic/start"); - } else if (aCmdLineArgs->IsHelpMath()) { - bShowHelp = sal_True; - aHelpURLBuffer.appendAscii("vnd.sun.star.help://smath/start"); + // handle request for acceptor + std::vector< rtl::OUString > const & accept = aCmdLineArgs-> + GetAccept(); + for (std::vector< rtl::OUString >::const_iterator i(accept.begin()); + i != accept.end(); ++i) + { + ApplicationEvent* pAppEvent = new ApplicationEvent( + ApplicationEvent::TYPE_ACCEPT, *i); + ImplPostForeignAppEvent( pAppEvent ); } - if (bShowHelp) { - aHelpURLBuffer.appendAscii("?Language="); - aHelpURLBuffer.append(utl::ConfigManager::getLocale()); -#if defined UNX - aHelpURLBuffer.appendAscii("&System=UNX"); -#elif defined WNT - aHelpURLBuffer.appendAscii("&System=WIN"); -#endif + // handle acceptor removal + std::vector< rtl::OUString > const & unaccept = aCmdLineArgs-> + GetUnaccept(); + for (std::vector< rtl::OUString >::const_iterator i( + unaccept.begin()); + i != unaccept.end(); ++i) + { ApplicationEvent* pAppEvent = new ApplicationEvent( - ApplicationEvent::TYPE_OPENHELPURL, - aHelpURLBuffer.makeStringAndClear()); + ApplicationEvent::TYPE_UNACCEPT, *i); ImplPostForeignAppEvent( pAppEvent ); } - } - if ( bDocRequestSent ) - { - // Send requests to dispatch watcher if we have at least one. The receiver - // is responsible to delete the request after processing it. - if ( aCmdLineArgs->HasModuleParam() ) + ProcessDocumentsRequest* pRequest = new ProcessDocumentsRequest( + aCmdLineArgs->getCwdUrl()); + cProcessed.reset(); + pRequest->pcProcessed = &cProcessed; + + // Print requests are not dependent on the --invisible cmdline argument as they are + // loaded with the "hidden" flag! So they are always checked. + pRequest->aPrintList = aCmdLineArgs->GetPrintList(); + bDocRequestSent |= !pRequest->aPrintList.empty(); + pRequest->aPrintToList = aCmdLineArgs->GetPrintToList(); + pRequest->aPrinterName = aCmdLineArgs->GetPrinterName(); + bDocRequestSent |= !( pRequest->aPrintToList.empty() || pRequest->aPrinterName.isEmpty() ); + + if ( !rCurrentCmdLineArgs.IsInvisible() ) { - SvtModuleOptions aOpt; - - // Support command line parameters to start a module (as preselection) - if ( aCmdLineArgs->IsWriter() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) ) - pRequest->aModule = aOpt.GetFactoryName( SvtModuleOptions::E_WRITER ); - else if ( aCmdLineArgs->IsCalc() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) ) - pRequest->aModule = aOpt.GetFactoryName( SvtModuleOptions::E_CALC ); - else if ( aCmdLineArgs->IsImpress() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) ) - pRequest->aModule= aOpt.GetFactoryName( SvtModuleOptions::E_IMPRESS ); - else if ( aCmdLineArgs->IsDraw() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) ) - pRequest->aModule= aOpt.GetFactoryName( SvtModuleOptions::E_DRAW ); + // Read cmdline args that can open/create documents. As they would open a window + // they are only allowed if the "--invisible" is currently not used! + pRequest->aOpenList = aCmdLineArgs->GetOpenList(); + bDocRequestSent |= !pRequest->aOpenList.empty(); + pRequest->aViewList = aCmdLineArgs->GetViewList(); + bDocRequestSent |= !pRequest->aViewList.empty(); + pRequest->aStartList = aCmdLineArgs->GetStartList(); + bDocRequestSent |= !pRequest->aStartList.empty(); + pRequest->aForceOpenList = aCmdLineArgs->GetForceOpenList(); + bDocRequestSent |= !pRequest->aForceOpenList.empty(); + pRequest->aForceNewList = aCmdLineArgs->GetForceNewList(); + bDocRequestSent |= !pRequest->aForceNewList.empty(); + + // Special command line args to create an empty document for a given module + + // #i18338# (lo) + // we only do this if no document was specified on the command line, + // since this would be inconsistent with the the behaviour of + // the first process, see OpenClients() (call to OpenDefault()) in app.cxx + if ( aCmdLineArgs->HasModuleParam() && (!bDocRequestSent) ) + { + SvtModuleOptions aOpt; + SvtModuleOptions::EFactory eFactory = SvtModuleOptions::E_WRITER; + if ( aCmdLineArgs->IsWriter() ) + eFactory = SvtModuleOptions::E_WRITER; + else if ( aCmdLineArgs->IsCalc() ) + eFactory = SvtModuleOptions::E_CALC; + else if ( aCmdLineArgs->IsDraw() ) + eFactory = SvtModuleOptions::E_DRAW; + else if ( aCmdLineArgs->IsImpress() ) + eFactory = SvtModuleOptions::E_IMPRESS; + else if ( aCmdLineArgs->IsBase() ) + eFactory = SvtModuleOptions::E_DATABASE; + else if ( aCmdLineArgs->IsMath() ) + eFactory = SvtModuleOptions::E_MATH; + else if ( aCmdLineArgs->IsGlobal() ) + eFactory = SvtModuleOptions::E_WRITERGLOBAL; + else if ( aCmdLineArgs->IsWeb() ) + eFactory = SvtModuleOptions::E_WRITERWEB; + + if ( !pRequest->aOpenList.empty() ) + pRequest->aModule = aOpt.GetFactoryName( eFactory ); + else + pRequest->aOpenList.push_back( aOpt.GetFactoryEmptyDocumentURL( eFactory ) ); + bDocRequestSent = sal_True; + } } + if ( !aCmdLineArgs->IsQuickstart() ) { + sal_Bool bShowHelp = sal_False; + rtl::OUStringBuffer aHelpURLBuffer; + if (aCmdLineArgs->IsHelpWriter()) { + bShowHelp = sal_True; + aHelpURLBuffer.appendAscii("vnd.sun.star.help://swriter/start"); + } else if (aCmdLineArgs->IsHelpCalc()) { + bShowHelp = sal_True; + aHelpURLBuffer.appendAscii("vnd.sun.star.help://scalc/start"); + } else if (aCmdLineArgs->IsHelpDraw()) { + bShowHelp = sal_True; + aHelpURLBuffer.appendAscii("vnd.sun.star.help://sdraw/start"); + } else if (aCmdLineArgs->IsHelpImpress()) { + bShowHelp = sal_True; + aHelpURLBuffer.appendAscii("vnd.sun.star.help://simpress/start"); + } else if (aCmdLineArgs->IsHelpBase()) { + bShowHelp = sal_True; + aHelpURLBuffer.appendAscii("vnd.sun.star.help://sdatabase/start"); + } else if (aCmdLineArgs->IsHelpBasic()) { + bShowHelp = sal_True; + aHelpURLBuffer.appendAscii("vnd.sun.star.help://sbasic/start"); + } else if (aCmdLineArgs->IsHelpMath()) { + bShowHelp = sal_True; + aHelpURLBuffer.appendAscii("vnd.sun.star.help://smath/start"); + } + if (bShowHelp) { + aHelpURLBuffer.appendAscii("?Language="); + aHelpURLBuffer.append(utl::ConfigManager::getLocale()); +#if defined UNX + aHelpURLBuffer.appendAscii("&System=UNX"); +#elif defined WNT + aHelpURLBuffer.appendAscii("&System=WIN"); +#endif + ApplicationEvent* pAppEvent = new ApplicationEvent( + ApplicationEvent::TYPE_OPENHELPURL, + aHelpURLBuffer.makeStringAndClear()); + ImplPostForeignAppEvent( pAppEvent ); + } + } - ImplPostProcessDocumentsEvent( pRequest ); - } - else - { - // delete not used request again - delete pRequest; - pRequest = NULL; - } - if (aArguments.equalsL(sc_aShowSequence, sc_nShSeqLength) || - aCmdLineArgs->IsEmpty()) - { - // no document was sent, just bring Office to front - ApplicationEvent* pAppEvent = - new ApplicationEvent(ApplicationEvent::TYPE_APPEAR); - ImplPostForeignAppEvent( pAppEvent ); + if ( bDocRequestSent ) + { + // Send requests to dispatch watcher if we have at least one. The receiver + // is responsible to delete the request after processing it. + if ( aCmdLineArgs->HasModuleParam() ) + { + SvtModuleOptions aOpt; + + // Support command line parameters to start a module (as preselection) + if ( aCmdLineArgs->IsWriter() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) ) + pRequest->aModule = aOpt.GetFactoryName( SvtModuleOptions::E_WRITER ); + else if ( aCmdLineArgs->IsCalc() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) ) + pRequest->aModule = aOpt.GetFactoryName( SvtModuleOptions::E_CALC ); + else if ( aCmdLineArgs->IsImpress() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) ) + pRequest->aModule= aOpt.GetFactoryName( SvtModuleOptions::E_IMPRESS ); + else if ( aCmdLineArgs->IsDraw() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) ) + pRequest->aModule= aOpt.GetFactoryName( SvtModuleOptions::E_DRAW ); + } + + ImplPostProcessDocumentsEvent( pRequest ); + } + else + { + // delete not used request again + delete pRequest; + pRequest = NULL; + } + if (aArguments.equalsL(sc_aShowSequence, sc_nShSeqLength) || + aCmdLineArgs->IsEmpty()) + { + // no document was sent, just bring Office to front + ApplicationEvent* pAppEvent = + new ApplicationEvent(ApplicationEvent::TYPE_APPEAR); + ImplPostForeignAppEvent( pAppEvent ); + } } // we don't need the mutex any longer... diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx index 9463b51c9fb1..37b9c924d067 100755 --- a/desktop/source/app/sofficemain.cxx +++ b/desktop/source/app/sofficemain.cxx @@ -60,22 +60,25 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main() // handle --version and --help already here, otherwise they would be handled // after VCL initialization that might fail if $DISPLAY is not set const desktop::CommandLineArgs& rCmdLineArgs = aDesktop.GetCommandLineArgs(); + rtl::OUString aUnknown( rCmdLineArgs.GetUnknown() ); + if ( !aUnknown.isEmpty() ) + { + desktop::Desktop::InitApplicationServiceManager(); + desktop::displayCmdlineHelp( aUnknown ); + return EXIT_FAILURE; + } if ( rCmdLineArgs.IsHelp() ) { desktop::Desktop::InitApplicationServiceManager(); - desktop::displayCmdlineHelp(); + desktop::displayCmdlineHelp( rtl::OUString() ); return EXIT_SUCCESS; } - else if ( rCmdLineArgs.IsVersion() ) + if ( rCmdLineArgs.IsVersion() ) { desktop::Desktop::InitApplicationServiceManager(); desktop::displayVersion(); return EXIT_SUCCESS; } - else if ( rCmdLineArgs.HasUnknown() ) - { - return EXIT_FAILURE; - } #endif return SVMain(); #if defined ANDROID diff --git a/desktop/unx/source/args.c b/desktop/unx/source/args.c index 0e01123cb242..e08d119397de 100644 --- a/desktop/unx/source/args.c +++ b/desktop/unx/source/args.c @@ -48,30 +48,34 @@ static struct { unsigned int bInhibitSplash : 1; unsigned int bInhibitPagein : 1; unsigned int bInhibitJavaLdx : 1; + unsigned int bInhibitPipe : 1; const char *pPageinType; } pArgDescr[] = { /* have a trailing argument */ - { "pt", 1, 0, 0, 0, NULL }, - { "display", 1, 0, 0, 0, NULL }, + { "pt", 1, 0, 0, 0, 0, NULL }, + { "display", 1, 0, 0, 0, 0, NULL }, /* no splash */ - { "nologo", 0, 1, 0, 0, NULL }, - { "headless", 0, 1, 0, 0, NULL }, - { "invisible", 0, 1, 0, 0, NULL }, - { "quickstart", 0, 1, 0, 0, NULL }, - { "minimized", 0, 1, 0, 0, NULL }, + { "nologo", 0, 1, 0, 0, 0, NULL }, + { "headless", 0, 1, 0, 0, 0, NULL }, + { "invisible", 0, 1, 0, 0, 0, NULL }, + { "quickstart", 0, 1, 0, 0, 0, NULL }, + { "minimized", 0, 1, 0, 0, 0, NULL }, /* pagein bits */ - { "writer", 0, 0, 0, 0, "pagein-writer" }, - { "calc", 0, 0, 0, 0, "pagein-calc" }, - { "draw", 0, 0, 0, 0, "pagein-draw" }, - { "impress", 0, 0, 0, 0, "pagein-impress" }, - - /* nothing much */ - { "version", 0, 1, 1, 1, NULL }, - { "help", 0, 1, 1, 1, NULL }, - { "h", 0, 1, 1, 1, NULL }, - { "?", 0, 1, 1, 1, NULL }, + { "writer", 0, 0, 0, 0, 0, "pagein-writer" }, + { "calc", 0, 0, 0, 0, 0, "pagein-calc" }, + { "draw", 0, 0, 0, 0, 0, "pagein-draw" }, + { "impress", 0, 0, 0, 0, 0, "pagein-impress" }, + + /* Do not send --help/--version over the pipe, as their output shall go to + the calling process's stdout (ideally, this would also happen in the + presence of unknown options); also prevent splash/pagein/javaldx overhead + (as these options will be processed early in soffice_main): */ + { "version", 0, 1, 1, 1, 1, NULL }, + { "help", 0, 1, 1, 1, 1, NULL }, + { "h", 0, 1, 1, 1, 1, NULL }, + { "?", 0, 1, 1, 1, 1, NULL }, }; Args *args_parse (void) @@ -133,6 +137,7 @@ Args *args_parse (void) args->bInhibitSplash |= pArgDescr[j].bInhibitSplash; args->bInhibitPagein |= pArgDescr[j].bInhibitPagein; args->bInhibitJavaLdx |= pArgDescr[j].bInhibitJavaLdx; + args->bInhibitPipe |= pArgDescr[j].bInhibitPipe; if (pArgDescr[j].pPageinType) args->pPageinType = pArgDescr[j].pPageinType; break; diff --git a/desktop/unx/source/args.h b/desktop/unx/source/args.h index 4a0cb55ffcde..9176badbda2a 100644 --- a/desktop/unx/source/args.h +++ b/desktop/unx/source/args.h @@ -38,6 +38,7 @@ typedef struct { sal_Bool bInhibitSplash; // should we show a splash screen sal_Bool bInhibitPagein; // should we run pagein ? sal_Bool bInhibitJavaLdx; // should we run javaldx ? + sal_Bool bInhibitPipe; // for --help and --version sal_uInt32 nArgsEnv; // number of -env: style args sal_uInt32 nArgsTotal; // number of -env: as well as -writer style args diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c index 8fe4774ef504..c6a8c2b826ed 100644 --- a/desktop/unx/source/start.c +++ b/desktop/unx/source/start.c @@ -831,21 +831,24 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) if ( pUsePlugin && !strcmp(pUsePlugin, "svp") ) args->bInhibitSplash = sal_True; - pPipePath = get_pipe_path( args->pAppPath ); - - if ( ( fd = connect_pipe( pPipePath ) ) >= 0 ) + if ( !args->bInhibitPipe ) { - rtl_uString *pCwdPath = NULL; - osl_getProcessWorkingDir( &pCwdPath ); + pPipePath = get_pipe_path( args->pAppPath ); + + if ( ( fd = connect_pipe( pPipePath ) ) >= 0 ) + { + rtl_uString *pCwdPath = NULL; + osl_getProcessWorkingDir( &pCwdPath ); - bSentArgs = send_args( fd, pCwdPath ); + bSentArgs = send_args( fd, pCwdPath ); - close( fd ); - } + close( fd ); + } #if OSL_DEBUG_LEVEL > 1 - else - ustr_debug( "Failed to connect to pipe", pPipePath ); + else + ustr_debug( "Failed to connect to pipe", pPipePath ); #endif + } if ( !bSentArgs ) { @@ -935,7 +938,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) } /* cleanup */ - rtl_uString_release( pPipePath ); + if ( pPipePath ) + rtl_uString_release( pPipePath ); args_free (args); return status; diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx index af766f4a9762..9e1d88d9cbf0 100644 --- a/vcl/inc/vcl/svapp.hxx +++ b/vcl/inc/vcl/svapp.hxx @@ -111,9 +111,9 @@ class VCL_DLLPUBLIC ApplicationEvent { public: enum Type { - TYPE_ACCEPT, TYPE_APPEAR, TYPE_HELP, TYPE_OPEN, TYPE_OPENHELPURL, - TYPE_PRINT, TYPE_PRIVATE_DOSHUTDOWN, TYPE_QUICKSTART, TYPE_SHOWDIALOG, - TYPE_UNACCEPT + TYPE_ACCEPT, TYPE_APPEAR, TYPE_HELP, TYPE_VERSION, TYPE_OPEN, + TYPE_OPENHELPURL, TYPE_PRINT, TYPE_PRIVATE_DOSHUTDOWN, TYPE_QUICKSTART, + TYPE_SHOWDIALOG, TYPE_UNACCEPT }; ApplicationEvent() {} -- cgit v1.2.3 From 71b584680e4527283ccc4fa14169bc7d28d32344 Mon Sep 17 00:00:00 2001 From: Ivan Timofeev Date: Sat, 29 Sep 2012 20:03:12 +0400 Subject: fdo#52268: splash: change color and position of messages Change-Id: If6c607fc9f0be1f7a71eda8d555399451938c5fc Signed-off-by: Jan Holesovsky --- config_host.mk.in | 2 ++ configure.in | 22 ++++++++++++++++ desktop/source/splash/splash.cxx | 46 +++++++++++++++++++++++++++++++-- scp2/source/ooo/common_brand.scp | 18 +++++++++++++ solenv/bin/modules/installer/ziplist.pm | 2 ++ 5 files changed, 88 insertions(+), 2 deletions(-) (limited to 'desktop') diff --git a/config_host.mk.in b/config_host.mk.in index 96635db978f0..4fb80d1f8679 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -413,6 +413,8 @@ export PRODUCTNAME=@PRODUCTNAME@ export PRODUCTVERSION=@PRODUCTVERSION@ export PROGRESSBARCOLOR=@PROGRESSBARCOLOR@ export PROGRESSFRAMECOLOR=@PROGRESSFRAMECOLOR@ +export PROGRESSTEXTCOLOR=@PROGRESSTEXTCOLOR@ +export PROGRESSTEXTBASELINE=@PROGRESSTEXTBASELINE@ export PROGRESSPOSITION=@PROGRESSPOSITION@ export PROGRESSSIZE=@PROGRESSSIZE@ export PROEXT=@PROEXT@ diff --git a/configure.in b/configure.in index 11e20a033254..651963a95442 100644 --- a/configure.in +++ b/configure.in @@ -11310,6 +11310,28 @@ else fi AC_SUBST(PROGRESSFRAMECOLOR) +AC_MSG_CHECKING([for custom 'intro' progress text color]) +PROGRESSTEXTCOLOR= +if test -z "$with_intro_progressbar_text_color"; then + PROGRESSTEXTCOLOR="255,255,255" + AC_MSG_RESULT([none]) +else + PROGRESSTEXTCOLOR="$with_intro_progressbar_text_color" + AC_MSG_RESULT([$PROGRESSTEXTCOLOR]) +fi +AC_SUBST(PROGRESSTEXTCOLOR) + +AC_MSG_CHECKING([for custom 'intro' progress text baseline]) +PROGRESSTEXTBASELINE= +if test -z "$with_intro_progressbar_text_baseline"; then + PROGRESSTEXTBASELINE="287" + AC_MSG_RESULT([none]) +else + PROGRESSTEXTBASELINE="$with_intro_progressbar_text_baseline" + AC_MSG_RESULT([$PROGRESSTEXTBASELINE]) +fi +AC_SUBST(PROGRESSTEXTBASELINE) + AC_MSG_CHECKING([for alternative branding images directory]) INTRO_BITMAP= ABOUT_BACKGROUND_SVG= diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index 0ef211a3cbeb..6678aa82c23c 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -88,6 +88,7 @@ private: BitmapEx _aIntroBmp; Color _cProgressFrameColor; Color _cProgressBarColor; + Color _cProgressTextColor; bool _bNativeProgress; OUString _sAppName; OUString _sProgressText; @@ -103,7 +104,7 @@ private: sal_Bool _bFullScreenSplash; sal_Bool _bProgressEnd; long _height, _width, _tlx, _tly, _barwidth; - long _barheight, _barspace; + long _barheight, _barspace, _textBaseline; double _fXPos, _fYPos; double _fWidth, _fHeight; const long _xoffset, _yoffset; @@ -132,6 +133,7 @@ SplashScreen::SplashScreen() , _vdev(*((IntroWindow*)this)) , _cProgressFrameColor(sal::static_int_cast< ColorData >(NOT_LOADED)) , _cProgressBarColor(sal::static_int_cast< ColorData >(NOT_LOADED)) + , _cProgressTextColor(sal::static_int_cast< ColorData >(NOT_LOADED)) , _bNativeProgress(true) , _iMax(100) , _iProgress(0) @@ -146,6 +148,7 @@ SplashScreen::SplashScreen() , _barwidth(NOT_LOADED) , _barheight(NOT_LOADED) , _barspace(2) + , _textBaseline(NOT_LOADED) , _fXPos(-1.0) , _fYPos(-1.0) , _fWidth(-1.0) @@ -299,6 +302,9 @@ SplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::sta } } + if ( NOT_LOADED == _textBaseline ) + _textBaseline = _height; + if ( sal::static_int_cast< ColorData >(NOT_LOADED) == _cProgressFrameColor.GetColor() ) _cProgressFrameColor = Color( COL_LIGHTGRAY ); @@ -313,6 +319,10 @@ SplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::sta _cProgressBarColor = Color( COL_BLUE ); } + if ( sal::static_int_cast< ColorData >(NOT_LOADED) == + _cProgressTextColor.GetColor() ) + _cProgressTextColor = Color( COL_BLACK ); + Application::AddEventListener( LINK( this, SplashScreen, AppEventListenerHdl ) ); @@ -365,6 +375,10 @@ void SplashScreen::loadConfig() OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressFrameColor" ) ) ); OUString sProgressBarColor = implReadBootstrapKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressBarColor" ) ) ); + OUString sProgressTextColor = implReadBootstrapKey( + OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressTextColor" ) ) ); + OUString sProgressTextBaseline = implReadBootstrapKey( + OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressTextBaseline" ) ) ); OUString sSize = implReadBootstrapKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressSize" ) ) ); OUString sPosition = implReadBootstrapKey( @@ -420,6 +434,29 @@ void SplashScreen::loadConfig() } } + if ( !sProgressTextColor.isEmpty() ) + { + sal_uInt8 nRed = 0; + sal_Int32 idx = 0; + sal_Int32 temp = sProgressTextColor.getToken( 0, ',', idx ).toInt32(); + if ( idx != -1 ) + { + nRed = static_cast< sal_uInt8 >( temp ); + temp = sProgressTextColor.getToken( 0, ',', idx ).toInt32(); + } + if ( idx != -1 ) + { + sal_uInt8 nGreen = static_cast< sal_uInt8 >( temp ); + sal_uInt8 nBlue = static_cast< sal_uInt8 >( sProgressTextColor.getToken( 0, ',', idx ).toInt32() ); + _cProgressTextColor = Color( nRed, nGreen, nBlue ); + } + } + + if ( !sProgressTextBaseline.isEmpty() ) + { + _textBaseline = sProgressTextBaseline.toInt32(); + } + if( !sNativeProgress.isEmpty() ) { _bNativeProgress = sNativeProgress.toBoolean(); @@ -610,7 +647,12 @@ void SplashScreen::Paint( const Rectangle&) _vdev.SetFillColor( _cProgressBarColor ); _vdev.SetLineColor(); _vdev.DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace)); - _vdev.DrawText( Rectangle(_tlx, _tly+_barheight+5, _tlx+_barwidth, _tly+_barheight+5+20), _sProgressText, TEXT_DRAW_CENTER ); + Font aFont; + aFont.SetSize(Size(0, 12)); + aFont.SetAlign(ALIGN_BASELINE); + _vdev.SetFont(aFont); + _vdev.SetTextColor(_cProgressTextColor); + _vdev.DrawText(Point(_tlx, _textBaseline), _sProgressText); } DrawOutDev(Point(), GetOutputSizePixel(), Point(), _vdev.GetOutputSizePixel(), _vdev ); } diff --git a/scp2/source/ooo/common_brand.scp b/scp2/source/ooo/common_brand.scp index c2ce2c2b41f4..997a142695d4 100644 --- a/scp2/source/ooo/common_brand.scp +++ b/scp2/source/ooo/common_brand.scp @@ -934,6 +934,24 @@ ProfileItem gid_Brand_Profileitem_Soffice_NativeProgress_So Value = "${NATIVEPROGRESS}"; End +ProfileItem gid_Brand_Profileitem_Soffice_ProgressTextColor_So + ProfileID = gid_Brand_Profile_Soffice_Ini; + ModuleID = gid_Module_Root_Brand; + Section = "Bootstrap"; + Order = 7; + Key = "ProgressTextColor"; + Value = "${PROGRESSTEXTCOLOR}"; +End + +ProfileItem gid_Brand_Profileitem_Soffice_ProgressTextBaseline_So + ProfileID = gid_Brand_Profile_Soffice_Ini; + ModuleID = gid_Module_Root_Brand; + Section = "Bootstrap"; + Order = 8; + Key = "ProgressTextBaseline"; + Value = "${PROGRESSTEXTBASELINE}"; +End + ProfileItem gid_Brand_Profileitem_Soffice_Hideeula ProfileID = gid_Brand_Profile_Soffice_Ini; ModuleID = gid_Module_Root_Brand; diff --git a/solenv/bin/modules/installer/ziplist.pm b/solenv/bin/modules/installer/ziplist.pm index 95b56389fd47..651469b1e46f 100644 --- a/solenv/bin/modules/installer/ziplist.pm +++ b/solenv/bin/modules/installer/ziplist.pm @@ -755,6 +755,8 @@ sub overwrite_branding $variableshashref->{'PROGRESSSIZE'} = $ENV{'PROGRESSSIZE'} , if( defined $ENV{'PROGRESSSIZE'} && $ENV{'PROGRESSSIZE'} ne "" ); $variableshashref->{'PROGRESSPOSITION'} = $ENV{'PROGRESSPOSITION'} , if( defined $ENV{'PROGRESSPOSITION'} && $ENV{'PROGRESSPOSITION'} ne "" ); $variableshashref->{'PROGRESSFRAMECOLOR'} = $ENV{'PROGRESSFRAMECOLOR'} , if( defined $ENV{'PROGRESSFRAMECOLOR'} && $ENV{'PROGRESSFRAMECOLOR'} ne "" ); + $variableshashref->{'PROGRESSTEXTCOLOR'} = $ENV{'PROGRESSTEXTCOLOR'} , if( defined $ENV{'PROGRESSTEXTCOLOR'} && $ENV{'PROGRESSTEXTCOLOR'} ne "" ); + $variableshashref->{'PROGRESSTEXTBASELINE'} = $ENV{'PROGRESSTEXTBASELINE'} , if( defined $ENV{'PROGRESSTEXTBASELINE'} && $ENV{'PROGRESSTEXTBASELINE'} ne "" ); } ########################################################### -- cgit v1.2.3 From c3064a250a912cb9b02419981a3f6a0b55899f2b Mon Sep 17 00:00:00 2001 From: Ivan Timofeev Date: Tue, 2 Oct 2012 20:53:27 +0400 Subject: splash screen: fix RTL mode Change-Id: I6a00cba8fda11351ed5340f21678c330ce028a2d Signed-off-by: Jan Holesovsky --- desktop/source/splash/splash.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'desktop') diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index 6678aa82c23c..48510b19172c 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -157,6 +157,7 @@ SplashScreen::SplashScreen() , _yoffset(18) { loadConfig(); + _vdev.EnableRTL(IsRTLEnabled()); } SplashScreen::~SplashScreen() -- cgit v1.2.3