diff options
Diffstat (limited to 'desktop/source/app')
-rw-r--r-- | desktop/source/app/app.cxx | 174 | ||||
-rw-r--r-- | desktop/source/app/appinit.cxx | 9 | ||||
-rw-r--r-- | desktop/source/app/cmdlineargs.cxx | 18 | ||||
-rw-r--r-- | desktop/source/app/cmdlineargs.hxx | 6 | ||||
-rw-r--r-- | desktop/source/app/cmdlinehelp.cxx | 7 | ||||
-rw-r--r-- | desktop/source/app/cmdlinehelp.hxx | 2 | ||||
-rw-r--r-- | desktop/source/app/desktop.hrc | 1 | ||||
-rw-r--r-- | desktop/source/app/desktop.src | 5 | ||||
-rw-r--r-- | desktop/source/app/officeipcthread.cxx | 329 | ||||
-rwxr-xr-x | desktop/source/app/sofficemain.cxx | 40 |
10 files changed, 291 insertions, 300 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 5fb653b5484d..001eac7bee07 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 + { + InitApplicationServiceManager(); + } + 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,14 +619,15 @@ 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 ) { // 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(); @@ -636,29 +643,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 +857,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 +939,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 +959,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 +1381,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; } @@ -1403,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; @@ -1423,11 +1433,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 @@ -1445,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" ); @@ -1805,9 +1808,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 ) { @@ -2714,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/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<XMultiServiceFactory> sm; #ifdef ANDROID rtl::OUString aUnoRc( OUString( "file:///assets/program/unorc" ) ); - return Reference<XMultiServiceFactory>( + sm.set( cppu::defaultBootstrap_InitialComponentContext( aUnoRc )->getServiceManager(), UNO_QUERY_THROW); #else - return Reference<XMultiServiceFactory>( + 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/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/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/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 a9501eda85ee..37b9c924d067 100755 --- a/desktop/source/app/sofficemain.cxx +++ b/desktop/source/app/sofficemain.cxx @@ -38,21 +38,14 @@ #include <rtl/bootstrap.hxx> #include <tools/extendapplicationenvironment.hxx> -#if defined WNT -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#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 @@ -67,38 +60,31 @@ 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::ensureProcessServiceFactory(); - desktop::displayCmdlineHelp(); + desktop::Desktop::InitApplicationServiceManager(); + desktop::displayCmdlineHelp( rtl::OUString() ); return EXIT_SUCCESS; } - else if ( rCmdLineArgs.IsVersion() ) + if ( rCmdLineArgs.IsVersion() ) { - desktop::Desktop::ensureProcessServiceFactory(); + desktop::Desktop::InitApplicationServiceManager(); desktop::displayVersion(); return EXIT_SUCCESS; } - else if ( rCmdLineArgs.HasUnknown() ) - { - return EXIT_FAILURE; - } #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 |