diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-05-02 16:41:06 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-05-02 16:55:29 +0200 |
commit | 5c22a03320f20ae9ac2c3c16025e7c5e3a7915d5 (patch) | |
tree | 9a163219cb9c32b8f945ce9ad71219b06f62aa90 /desktop | |
parent | 9911ee515dd3d1e077dbf9c1fb4fd5c42a3c49b6 (diff) |
Cleaned up CommandLineArgs
* Support for dead arguments has been removed.
** Especially, dead UCB_CONFIGURATION_KEY1/2_xxx values have also been removed,
and code initializing UCB has been simplified accordingly.
* For the sake of simplicity, behaviour has been changed slightly. For example,
passing both --calc --writer now always lets --writer win (whereas in the past
the one mentioned first, i.e., --calc in this example, would win).
Change-Id: Id40a19b9ef96db0d439cadd96ba491bf640d28fb
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/inc/app.hxx | 2 | ||||
-rw-r--r-- | desktop/source/app/app.cxx | 141 | ||||
-rw-r--r-- | desktop/source/app/appinit.cxx | 44 | ||||
-rw-r--r-- | desktop/source/app/cmdlineargs.cxx | 488 | ||||
-rw-r--r-- | desktop/source/app/cmdlineargs.hxx | 241 | ||||
-rw-r--r-- | desktop/source/app/langselect.cxx | 2 | ||||
-rw-r--r-- | desktop/source/app/officeipcthread.cxx | 68 | ||||
-rw-r--r-- | desktop/source/app/officeipcthread.hxx | 22 |
8 files changed, 405 insertions, 603 deletions
diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 28b2c63d965a..0dfa7ca82ed2 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -148,7 +148,7 @@ class Desktop : public Application static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > CreateApplicationServiceManager(); // returns a non-null reference or throws an exception - void RegisterServices( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMgr ); + void RegisterServices(); void DeregisterServices(); void DestroyApplicationServiceManager( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMgr ); diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 95894ae9a5aa..b24f94fa18c0 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1340,7 +1340,6 @@ sal_uInt16 Desktop::Exception(sal_uInt16 nError) sal_Bool bAllowRecoveryAndSessionManagement = ( ( !rArgs.IsNoRestore() ) && // some use cases of office must work without recovery ( !rArgs.IsHeadless() ) && - ( !rArgs.IsServer() ) && (( nError & EXC_MAJORTYPE ) != EXC_DISPLAY ) && // recovery cant work without UI ... but UI layer seams to be the reason for this crash ( Application::IsInExecute() ) // crashes during startup and shutdown should be ignored (they indicates a corrupt installation ...) ); @@ -1498,7 +1497,7 @@ int Desktop::Main() Reference< ::com::sun::star::task::XRestartManager > xRestartManager; try { - RegisterServices( xSMgr ); + RegisterServices(); SetSplashScreenProgress(25); @@ -2452,8 +2451,7 @@ void Desktop::OpenClients() // need some time, where the user wont see any results and wait for finishing the office startup ... sal_Bool bAllowRecoveryAndSessionManagement = ( ( !rArgs.IsNoRestore() ) && - ( !rArgs.IsHeadless() ) && - ( !rArgs.IsServer() ) + ( !rArgs.IsHeadless() ) ); if ( ! bAllowRecoveryAndSessionManagement ) @@ -2568,80 +2566,76 @@ void Desktop::OpenClients() OfficeIPCThread::EnableRequests(); - sal_Bool bShutdown( sal_False ); - if ( !rArgs.IsServer() ) - { - ProcessDocumentsRequest aRequest(rArgs.getCwdUrl()); - aRequest.pcProcessed = NULL; - - rArgs.GetOpenList( aRequest.aOpenList ); - rArgs.GetViewList( aRequest.aViewList ); - rArgs.GetStartList( aRequest.aStartList ); - rArgs.GetPrintList( aRequest.aPrintList ); - rArgs.GetPrintToList( aRequest.aPrintToList ); - rArgs.GetPrinterName( aRequest.aPrinterName ); - rArgs.GetForceOpenList( aRequest.aForceOpenList ); - rArgs.GetForceNewList( aRequest.aForceNewList ); - rArgs.GetConversionList( aRequest.aConversionList ); - rArgs.GetConversionParams( aRequest.aConversionParams ); - rArgs.GetConversionOut( aRequest.aConversionOut ); - rArgs.GetInFilter( aRequest.aInFilter ); - - if ( !aRequest.aOpenList.isEmpty() || - !aRequest.aViewList.isEmpty() || - !aRequest.aStartList.isEmpty() || - !aRequest.aPrintList.isEmpty() || - !aRequest.aForceOpenList.isEmpty() || - !aRequest.aForceNewList.isEmpty() || - ( !aRequest.aPrintToList.isEmpty() && !aRequest.aPrinterName.isEmpty() ) || - !aRequest.aConversionList.isEmpty() ) - { - bLoaded = sal_True; - - if ( rArgs.HasModuleParam() ) - { - SvtModuleOptions aOpt; - - // Support command line parameters to start a module (as preselection) - if ( rArgs.IsWriter() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) ) - aRequest.aModule = aOpt.GetFactoryName( SvtModuleOptions::E_WRITER ); - else if ( rArgs.IsCalc() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) ) - aRequest.aModule = aOpt.GetFactoryName( SvtModuleOptions::E_CALC ); - else if ( rArgs.IsImpress() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) ) - aRequest.aModule= aOpt.GetFactoryName( SvtModuleOptions::E_IMPRESS ); - else if ( rArgs.IsDraw() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) ) - aRequest.aModule= aOpt.GetFactoryName( SvtModuleOptions::E_DRAW ); - } + ProcessDocumentsRequest aRequest(rArgs.getCwdUrl()); + aRequest.pcProcessed = NULL; - // check for printing disabled - if( ( !(aRequest.aPrintList.isEmpty() && aRequest.aPrintToList.isEmpty()) ) - && Application::GetSettings().GetMiscSettings().GetDisablePrinting() ) + aRequest.aOpenList = rArgs.GetOpenList(); + aRequest.aViewList = rArgs.GetViewList(); + aRequest.aStartList = rArgs.GetStartList(); + aRequest.aPrintList = rArgs.GetPrintList(); + aRequest.aPrintToList = rArgs.GetPrintToList(); + aRequest.aPrinterName = rArgs.GetPrinterName(); + aRequest.aForceOpenList = rArgs.GetForceOpenList(); + aRequest.aForceNewList = rArgs.GetForceNewList(); + aRequest.aConversionList = rArgs.GetConversionList(); + aRequest.aConversionParams = rArgs.GetConversionParams(); + aRequest.aConversionOut = rArgs.GetConversionOut(); + aRequest.aInFilter = rArgs.GetInFilter(); + + if ( !aRequest.aOpenList.empty() || + !aRequest.aViewList.empty() || + !aRequest.aStartList.empty() || + !aRequest.aPrintList.empty() || + !aRequest.aForceOpenList.empty() || + !aRequest.aForceNewList.empty() || + ( !aRequest.aPrintToList.empty() && !aRequest.aPrinterName.isEmpty() ) || + !aRequest.aConversionList.empty() ) + { + bLoaded = sal_True; + + if ( rArgs.HasModuleParam() ) + { + SvtModuleOptions aOpt; + + // Support command line parameters to start a module (as preselection) + if ( rArgs.IsWriter() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) ) + aRequest.aModule = aOpt.GetFactoryName( SvtModuleOptions::E_WRITER ); + else if ( rArgs.IsCalc() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) ) + aRequest.aModule = aOpt.GetFactoryName( SvtModuleOptions::E_CALC ); + else if ( rArgs.IsImpress() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) ) + aRequest.aModule= aOpt.GetFactoryName( SvtModuleOptions::E_IMPRESS ); + else if ( rArgs.IsDraw() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) ) + aRequest.aModule= aOpt.GetFactoryName( SvtModuleOptions::E_DRAW ); + } + + // check for printing disabled + if( ( !(aRequest.aPrintList.empty() && aRequest.aPrintToList.empty()) ) + && Application::GetSettings().GetMiscSettings().GetDisablePrinting() ) + { + aRequest.aPrintList.clear(); + aRequest.aPrintToList.clear(); + ResMgr* pDtResMgr = GetDesktopResManager(); + if( pDtResMgr ) { - aRequest.aPrintList = rtl::OUString(); - aRequest.aPrintToList = rtl::OUString(); - ResMgr* pDtResMgr = GetDesktopResManager(); - if( pDtResMgr ) - { - ErrorBox aBox( NULL, ResId( EBX_ERR_PRINTDISABLED, *pDtResMgr ) ); - aBox.Execute(); - } + ErrorBox aBox( NULL, ResId( EBX_ERR_PRINTDISABLED, *pDtResMgr ) ); + aBox.Execute(); } + } - // Process request - bShutdown = OfficeIPCThread::ExecuteCmdLineRequests( aRequest ); + // Process request + if ( OfficeIPCThread::ExecuteCmdLineRequests( aRequest ) ) + { + // Don't do anything if we have successfully called terminate at desktop: + return; } } - // Don't do anything if we have successfully called terminate at desktop - if ( bShutdown ) - return; - // no default document if a document was loaded by recovery or by command line or if soffice is used as server Reference< XFramesSupplier > xTasksSupplier( ::comphelper::getProcessServiceFactory()->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ), ::com::sun::star::uno::UNO_QUERY_THROW ); Reference< XElementAccess > xList( xTasksSupplier->getFrames(), UNO_QUERY_THROW ); - if ( xList->hasElements() || rArgs.IsServer() ) + if ( xList->hasElements() ) return; if ( rArgs.IsQuickstart() || rArgs.IsInvisible() || Application::AnyInput( VCL_INPUT_APPEVENT ) ) @@ -2702,7 +2696,7 @@ void Desktop::OpenDefault() ProcessDocumentsRequest aRequest(rArgs.getCwdUrl()); aRequest.pcProcessed = NULL; - aRequest.aOpenList = aName; + aRequest.aOpenList.push_back(aName); OfficeIPCThread::ExecuteCmdLineRequests( aRequest ); } @@ -2836,7 +2830,7 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent ) { ProcessDocumentsRequest* pDocsRequest = new ProcessDocumentsRequest( rCmdLine.getCwdUrl()); - pDocsRequest->aOpenList = rAppEvent.GetData(); + pDocsRequest->aOpenList.push_back(rAppEvent.GetData()); pDocsRequest->pcProcessed = NULL; OfficeIPCThread::ExecuteCmdLineRequests( *pDocsRequest ); @@ -2855,7 +2849,7 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent ) { ProcessDocumentsRequest* pDocsRequest = new ProcessDocumentsRequest( rCmdLine.getCwdUrl()); - pDocsRequest->aPrintList = rAppEvent.GetData(); + pDocsRequest->aPrintList.push_back(rAppEvent.GetData()); pDocsRequest->pcProcessed = NULL; OfficeIPCThread::ExecuteCmdLineRequests( *pDocsRequest ); @@ -2935,7 +2929,6 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent ) void Desktop::OpenSplashScreen() { - ::rtl::OUString aTmpString; const CommandLineArgs &rCmdLine = GetCommandLineArgs(); sal_Bool bVisible = sal_False; // Show intro only if this is normal start (e.g. no server, no quickstart, no printing ) @@ -2945,9 +2938,9 @@ void Desktop::OpenSplashScreen() !rCmdLine.IsMinimized() && !rCmdLine.IsNoLogo() && !rCmdLine.IsTerminateAfterInit() && - !rCmdLine.GetPrintList( aTmpString ) && - !rCmdLine.GetPrintToList( aTmpString ) && - !rCmdLine.GetConversionList( aTmpString )) + rCmdLine.GetPrintList().empty() && + rCmdLine.GetPrintToList().empty() && + rCmdLine.GetConversionList().empty() ) { // Determine application name from command line parameters OUString aAppName; @@ -2970,7 +2963,7 @@ void Desktop::OpenSplashScreen() // Which splash to use OUString aSplashService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.SplashScreen" )); - if ( !rCmdLine.GetSplashPipe().isEmpty() ) + if ( rCmdLine.HasSplashPipe() ) aSplashService = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.office.PipeSplashScreen")); bVisible = sal_True; diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index 4dfb785277a6..6741f04b0eb3 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -42,7 +42,6 @@ #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/ucb/XContentProviderManager.hpp> #include <com/sun/star/ucb/XContentProviderFactory.hpp> #include <uno/current_context.hxx> @@ -85,7 +84,7 @@ namespace desktop // ----------------------------------------------------------------------------- -static bool configureUcb(bool bServer, rtl::OUString const & rPortalConnect) +static bool configureUcb() { RTL_LOGFILE_CONTEXT( aLog, "desktop (sb93797) ::configureUcb" ); Reference< XMultiServiceFactory > @@ -100,22 +99,12 @@ static bool configureUcb(bool bServer, rtl::OUString const & rPortalConnect) osl::Security().getUserIdent(aPipe); rtl::OUStringBuffer aPortal; - if (!rPortalConnect.isEmpty()) - { - aPortal.append(sal_Unicode(',')); - aPortal.append(rPortalConnect); - } - Sequence< Any > aArgs(6); + Sequence< Any > aArgs(2); aArgs[0] - <<= bServer ? rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UCB_CONFIGURATION_KEY1_SERVER)) : - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UCB_CONFIGURATION_KEY1_LOCAL)); + <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UCB_CONFIGURATION_KEY1_LOCAL)); aArgs[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UCB_CONFIGURATION_KEY2_OFFICE)); - aArgs[2] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PIPE")); - aArgs[3] <<= aPipe; - aArgs[4] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PORTAL")); - aArgs[5] <<= aPortal.makeStringAndClear(); bool ret = ::ucbhelper::ContentBroker::initialize( xServiceFactory, aArgs ) != false; @@ -210,7 +199,7 @@ void Desktop::DestroyApplicationServiceManager( Reference< XMultiServiceFactory } } -void Desktop::RegisterServices( Reference< XMultiServiceFactory >& xSMgr ) +void Desktop::RegisterServices() { if( !m_bServicesRegistered ) { @@ -241,30 +230,7 @@ void Desktop::RegisterServices( Reference< XMultiServiceFactory >& xSMgr ) createAcceptor(*i); } - // improves parallel processing on Sun ONE Webtop - // servicemanager up -> copy user installation - if ( rCmdLine.IsServer() ) - { - // Check some mandatory environment states if "-server" is possible. Otherwise ignore - // this parameter. - Reference< com::sun::star::container::XContentEnumerationAccess > rContent( xSMgr , UNO_QUERY ); - if( rContent.is() ) - { - OUString sPortalService = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.portal.InstallUser" ) ); - Reference < com::sun::star::container::XEnumeration > rEnum = rContent->createContentEnumeration( sPortalService ); - if ( !rEnum.is() ) - { - // Reset server parameter so it is ignored in the furthermore startup process - rCmdLine.ClearServer(); - } - } - } - - ::rtl::OUString aPortalConnect; - bool bServer = (bool)rCmdLine.IsServer(); - - rCmdLine.GetPortalConnectString( aPortalConnect ); - if ( !configureUcb( bServer, aPortalConnect ) ) + if ( !configureUcb() ) { OSL_FAIL( "Can't configure UCB" ); throw com::sun::star::uno::Exception(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RegisterServices, configureUcb")), NULL); diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index 9ffac20d9ee0..a1ce3e58e844 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -86,23 +86,6 @@ private: } -static CommandLineArgs::BoolParam aModuleGroupDefinition[] = -{ - CommandLineArgs::CMD_BOOLPARAM_WRITER, - CommandLineArgs::CMD_BOOLPARAM_CALC, - CommandLineArgs::CMD_BOOLPARAM_DRAW, - CommandLineArgs::CMD_BOOLPARAM_IMPRESS, - CommandLineArgs::CMD_BOOLPARAM_GLOBAL, - CommandLineArgs::CMD_BOOLPARAM_MATH, - CommandLineArgs::CMD_BOOLPARAM_WEB, - CommandLineArgs::CMD_BOOLPARAM_BASE -}; - -CommandLineArgs::GroupDefinition CommandLineArgs::m_pGroupDefinitions[ CommandLineArgs::CMD_GRPID_COUNT ] = -{ - { 8, aModuleGroupDefinition } -}; - CommandLineArgs::Supplier::Exception::Exception() {} CommandLineArgs::Supplier::Exception::Exception(Exception const &) {} @@ -160,8 +143,6 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) bool bBatchPrinterNameEvent(false); bool bConversionOutEvent(false); - m_eArgumentCount = NONE; - for (;;) { ::rtl::OUString aArg; @@ -180,7 +161,7 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) if ( !aArg.isEmpty() ) { - m_eArgumentCount = m_eArgumentCount == NONE ? ONE : MANY; + m_bEmpty = false; ::rtl::OUString oArg; if ( !InterpretCommandLineParameter( aArg, oArg )) { @@ -318,7 +299,7 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) 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"); - SetBoolParam_Impl( CMD_BOOLPARAM_UNKNOWN, sal_True ); + m_unknown = true; } #endif } @@ -327,24 +308,24 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) if ( bPrinterName && bPrintToEvent ) { // first argument after "-pt" this must be the printer name - AddStringListParam_Impl( CMD_STRINGPARAM_PRINTERNAME, aArg ); + m_printername = aArg; bPrinterName = false; } else if ( bConversionParamsEvent && bConversionEvent ) { // first argument must be the the params - AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONPARAMS, aArg ); + m_conversionparams = aArg; bConversionParamsEvent = false; } else if ( bBatchPrinterNameEvent && bBatchPrintEvent ) { // first argument is the printer name - AddStringListParam_Impl( CMD_STRINGPARAM_PRINTERNAME, aArg ); + m_printername = aArg; bBatchPrinterNameEvent = false; } else if ( (bConversionEvent || bBatchPrintEvent) && bConversionOutEvent ) { - AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONOUT, aArg ); + m_conversionout = aArg; bConversionOutEvent = false; } else @@ -361,47 +342,46 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) // handle this argument as a filename if ( bOpenEvent ) { - AddStringListParam_Impl( CMD_STRINGPARAM_OPENLIST, aArg ); + m_openlist.push_back(aArg); bOpenDoc = true; } else if ( bViewEvent ) { - AddStringListParam_Impl( CMD_STRINGPARAM_VIEWLIST, aArg ); + m_viewlist.push_back(aArg); bOpenDoc = true; } else if ( bStartEvent ) { - AddStringListParam_Impl( CMD_STRINGPARAM_STARTLIST, aArg ); + m_startlist.push_back(aArg); bOpenDoc = true; } else if ( bPrintEvent ) { - AddStringListParam_Impl( CMD_STRINGPARAM_PRINTLIST, aArg ); + m_printlist.push_back(aArg); bOpenDoc = true; } else if ( bPrintToEvent ) { - AddStringListParam_Impl( CMD_STRINGPARAM_PRINTTOLIST, aArg ); + m_printtolist.push_back(aArg); bOpenDoc = true; } else if ( bForceNewEvent ) { - AddStringListParam_Impl( CMD_STRINGPARAM_FORCENEWLIST, aArg ); + m_forcenewlist.push_back(aArg); bOpenDoc = true; } else if ( bForceOpenEvent ) { - AddStringListParam_Impl( CMD_STRINGPARAM_FORCEOPENLIST, aArg ); + m_forceopenlist.push_back(aArg); bOpenDoc = true; } else if ( bDisplaySpec ) { - AddStringListParam_Impl( CMD_STRINGPARAM_DISPLAY, aArg ); bDisplaySpec = false; // only one display, not a lsit bOpenEvent = true; // set back to standard } else if ( bConversionEvent || bBatchPrintEvent ) - AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONLIST, aArg ); + m_conversionlist.push_back(aArg); } } } @@ -412,24 +392,7 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) m_bDocumentArgs = true; } -void CommandLineArgs::AddStringListParam_Impl( StringParam eParam, const rtl::OUString& aParam ) -{ - OSL_ASSERT( eParam >= 0 && eParam < CMD_STRINGPARAM_COUNT ); - ::rtl::OUStringBuffer aParamBuf(m_aStrParams[eParam]); - if ( aParamBuf.getLength() ) - aParamBuf.append('\n'); - aParamBuf.append(aParam); - m_aStrParams[eParam] = aParamBuf.makeStringAndClear(); - m_aStrSetParams[eParam] = sal_True; -} - -void CommandLineArgs::SetBoolParam_Impl( BoolParam eParam, sal_Bool bValue ) -{ - OSL_ASSERT( eParam >= 0 && eParam < CMD_BOOLPARAM_COUNT ); - m_aBoolParams[eParam] = bValue; -} - -sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& aArg, ::rtl::OUString& oArg ) +bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& aArg, ::rtl::OUString& oArg ) { bool bDeprecated = false; if (aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("--"))) @@ -444,106 +407,102 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& } else { - return sal_False; + return false; } - if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "minimized" )) == sal_True ) + if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "minimized" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_MINIMIZED, sal_True ); + m_minimized = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "invisible" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "invisible" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_INVISIBLE, sal_True ); + m_invisible = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "norestore" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "norestore" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_NORESTORE, sal_True ); + m_norestore = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nodefault" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nodefault" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_NODEFAULT, sal_True ); + m_nodefault = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "server" )) == sal_True ) - { - m_server = true; - } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "headless" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "headless" )) ) { // Headless means also invisibile, so set this parameter to true! - SetBoolParam_Impl( CMD_BOOLPARAM_HEADLESS, sal_True ); - SetBoolParam_Impl( CMD_BOOLPARAM_INVISIBLE, sal_True ); + m_headless = true; + m_invisible = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "quickstart" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "quickstart" )) ) { #if defined(ENABLE_QUICKSTART_APPLET) - SetBoolParam_Impl( CMD_BOOLPARAM_QUICKSTART, sal_True ); + m_quickstart = true; #endif - SetBoolParam_Impl( CMD_BOOLPARAM_NOQUICKSTART, sal_False ); + m_noquickstart = false; } else if ( oArg == "quickstart=no" ) { - SetBoolParam_Impl( CMD_BOOLPARAM_NOQUICKSTART, sal_True ); - SetBoolParam_Impl( CMD_BOOLPARAM_QUICKSTART, sal_False ); + m_noquickstart = true; + m_quickstart = false; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "terminate_after_init" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "terminate_after_init" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_TERMINATEAFTERINIT, sal_True ); + m_terminateafterinit = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nofirststartwizard" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nofirststartwizard" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_NOFIRSTSTARTWIZARD, sal_True ); + m_nofirststartwizard = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nologo" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nologo" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_NOLOGO, sal_True ); + m_nologo = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nolockcheck" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nolockcheck" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_NOLOCKCHECK, sal_True ); + m_nolockcheck = true; // Workaround for automated testing - ::svt::DocumentLockFile::AllowInteraction( sal_False ); + ::svt::DocumentLockFile::AllowInteraction( false ); } else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "help" )) || aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-h" )) || aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-?" ))) { - SetBoolParam_Impl( CMD_BOOLPARAM_HELP, sal_True ); + m_help = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpwriter" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpwriter" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_HELPWRITER, sal_True ); + m_helpwriter = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpcalc" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpcalc" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_HELPCALC, sal_True ); + m_helpcalc = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpdraw" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpdraw" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_HELPDRAW, sal_True ); + m_helpdraw = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpimpress" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpimpress" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_HELPIMPRESS, sal_True ); + m_helpimpress = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpbase" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpbase" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_HELPBASE, sal_True ); + m_helpbase = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpbasic" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpbasic" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_HELPBASIC, sal_True ); + m_helpbasic = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpmath" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpmath" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_HELPMATH, sal_True ); + m_helpmath = true; } - else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "version" )) == sal_True ) + else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "version" )) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_VERSION, sal_True ); + m_version = true; } else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("splash-pipe=")) ) { - AddStringListParam_Impl( CMD_STRINGPARAM_SPLASHPIPE, oArg.copy(RTL_CONSTASCII_LENGTH("splash-pipe=")) ); + m_splashpipe = true; } #ifdef MACOSX /* #i84053# ignore -psn on Mac @@ -553,13 +512,13 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& */ else if ( aArg.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("-psn")) ) { - SetBoolParam_Impl( CMD_BOOLPARAM_PSN, sal_True ); - return sal_True; + m_psn = true; + return true; } #endif else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("infilter="))) { - AddStringListParam_Impl( CMD_STRINGPARAM_INFILTER, oArg.copy(RTL_CONSTASCII_LENGTH("infilter=")) ); + m_infilter.push_back(oArg.copy(RTL_CONSTASCII_LENGTH("infilter="))); } else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("accept="))) { @@ -569,288 +528,244 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& { m_unaccept.push_back(oArg.copy(RTL_CONSTASCII_LENGTH("unaccept="))); } - else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("portal,"))) - { - AddStringListParam_Impl( CMD_STRINGPARAM_PORTAL, oArg.copy(RTL_CONSTASCII_LENGTH("portal,")) ); - } - else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("userid"))) - { - if ( oArg.getLength() > RTL_CONSTASCII_LENGTH("userid")+1 ) - { - AddStringListParam_Impl( - CMD_STRINGPARAM_USERDIR, - ::rtl::Uri::decode( oArg.copy(RTL_CONSTASCII_LENGTH("userid")+1), - rtl_UriDecodeWithCharset, - RTL_TEXTENCODING_UTF8 ) ); - } - } - else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("clientdisplay="))) - { - AddStringListParam_Impl( CMD_STRINGPARAM_CLIENTDISPLAY, oArg.copy(RTL_CONSTASCII_LENGTH("clientdisplay=")) ); - } - else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("version="))) - { - AddStringListParam_Impl( CMD_STRINGPARAM_VERSION, oArg.copy(RTL_CONSTASCII_LENGTH("version=")) ); - } else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("language="))) { - AddStringListParam_Impl( CMD_STRINGPARAM_LANGUAGE, oArg.copy(RTL_CONSTASCII_LENGTH("language=")) ); + m_language = oArg.copy(RTL_CONSTASCII_LENGTH("language=")); } else if ( oArg == "writer" ) { - sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_WRITER ); - if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_WRITER, sal_True ); + m_writer = true; m_bDocumentArgs = true; } else if ( oArg == "calc" ) { - sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_CALC ); - if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_CALC, sal_True ); + m_calc = true; m_bDocumentArgs = true; } else if ( oArg == "draw" ) { - sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_DRAW ); - if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_DRAW, sal_True ); + m_draw = true; m_bDocumentArgs = true; } else if ( oArg == "impress" ) { - sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_IMPRESS ); - if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_IMPRESS, sal_True ); + m_impress = true; m_bDocumentArgs = true; } else if ( oArg == "base" ) { - sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_BASE ); - if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_BASE, sal_True ); + m_base = true; m_bDocumentArgs = true; } else if ( oArg == "global" ) { - sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_GLOBAL ); - if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_GLOBAL, sal_True ); + m_global = true; m_bDocumentArgs = true; } else if ( oArg == "math" ) { - sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_MATH ); - if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_MATH, sal_True ); + m_math = true; m_bDocumentArgs = true; } else if ( oArg == "web" ) { - sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_WEB ); - if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_WEB, sal_True ); + m_web = true; m_bDocumentArgs = true; } else - return sal_False; + return false; if (bDeprecated) { rtl::OString sArg(rtl::OUStringToOString(aArg, osl_getThreadTextEncoding())); fprintf(stderr, "Warning: %s is deprecated. Use -%s instead.\n", sArg.getStr(), sArg.getStr()); } - return sal_True; -} - -sal_Bool CommandLineArgs::CheckGroupMembers( GroupParamId nGroupId, BoolParam nExcludeMember ) const -{ - // Check if at least one bool param out of a group is set. An exclude member can be provided. - for ( int i = 0; i < m_pGroupDefinitions[nGroupId].nCount; i++ ) - { - BoolParam nParam = m_pGroupDefinitions[nGroupId].pGroupMembers[i]; - if ( nParam != nExcludeMember && m_aBoolParams[nParam] ) - return sal_True; - } - - return sal_False; + return true; } void CommandLineArgs::InitParamValues() { - int i; - for ( i = 0; i < CMD_BOOLPARAM_COUNT; i++ ) - m_aBoolParams[i] = sal_False; - for ( i = 0; i < CMD_STRINGPARAM_COUNT; i++ ) - m_aStrSetParams[i] = sal_False; - m_eArgumentCount = NONE; + m_minimized = false; + m_invisible = false; + m_norestore = false; + m_headless = false; + m_quickstart = false; + m_noquickstart = false; + m_terminateafterinit = false; + m_nofirststartwizard = false; + m_nologo = false; + m_nolockcheck = false; + m_nodefault = false; + m_help = false; + m_writer = false; + m_calc = false; + m_draw = false; + m_impress = false; + m_global = false; + m_math = false; + m_web = false; + m_base = false; + m_helpwriter = false; + m_helpcalc = false; + m_helpdraw = false; + m_helpbasic = false; + m_helpmath = false; + m_helpimpress = false; + m_helpbase = false; + m_psn = false; + m_version = false; + m_unknown = false; + m_splashpipe = false; + m_bEmpty = true; m_bDocumentArgs = false; - m_server = false; } -void CommandLineArgs::ClearServer() +bool CommandLineArgs::IsMinimized() const { - osl::MutexGuard aMutexGuard( m_aMutex ); - m_server = false; + return m_minimized; } -sal_Bool CommandLineArgs::IsMinimized() const +bool CommandLineArgs::IsInvisible() const { - return m_aBoolParams[ CMD_BOOLPARAM_MINIMIZED ]; + return m_invisible; } -sal_Bool CommandLineArgs::IsInvisible() const +bool CommandLineArgs::IsNoRestore() const { - return m_aBoolParams[ CMD_BOOLPARAM_INVISIBLE ]; + return m_norestore; } -sal_Bool CommandLineArgs::IsNoRestore() const +bool CommandLineArgs::IsNoDefault() const { - return m_aBoolParams[ CMD_BOOLPARAM_NORESTORE ]; + return m_nodefault; } -sal_Bool CommandLineArgs::IsNoDefault() const +bool CommandLineArgs::IsHeadless() const { - return m_aBoolParams[ CMD_BOOLPARAM_NODEFAULT ]; + return m_headless; } -sal_Bool CommandLineArgs::IsServer() const +bool CommandLineArgs::IsQuickstart() const { - osl::MutexGuard aMutexGuard( m_aMutex ); - return m_server; + return m_quickstart; } -sal_Bool CommandLineArgs::IsHeadless() const +bool CommandLineArgs::IsNoQuickstart() const { - return m_aBoolParams[ CMD_BOOLPARAM_HEADLESS ]; + return m_noquickstart; } -sal_Bool CommandLineArgs::IsQuickstart() const +bool CommandLineArgs::IsTerminateAfterInit() const { - return m_aBoolParams[ CMD_BOOLPARAM_QUICKSTART ]; + return m_terminateafterinit; } -sal_Bool CommandLineArgs::IsNoQuickstart() const +bool CommandLineArgs::IsNoLogo() const { - return m_aBoolParams[ CMD_BOOLPARAM_NOQUICKSTART ]; + return m_nologo; } -sal_Bool CommandLineArgs::IsTerminateAfterInit() const +bool CommandLineArgs::IsNoLockcheck() const { - return m_aBoolParams[ CMD_BOOLPARAM_TERMINATEAFTERINIT ]; + return m_nolockcheck; } -sal_Bool CommandLineArgs::IsNoLogo() const +bool CommandLineArgs::IsHelp() const { - return m_aBoolParams[ CMD_BOOLPARAM_NOLOGO ]; + return m_help; } - -sal_Bool CommandLineArgs::IsNoLockcheck() const +bool CommandLineArgs::IsHelpWriter() const { - return m_aBoolParams[ CMD_BOOLPARAM_NOLOCKCHECK ]; + return m_helpwriter; } -sal_Bool CommandLineArgs::IsHelp() const -{ - return m_aBoolParams[ CMD_BOOLPARAM_HELP ]; -} -sal_Bool CommandLineArgs::IsHelpWriter() const +bool CommandLineArgs::IsHelpCalc() const { - return m_aBoolParams[ CMD_BOOLPARAM_HELPWRITER ]; + return m_helpcalc; } -sal_Bool CommandLineArgs::IsHelpCalc() const +bool CommandLineArgs::IsHelpDraw() const { - return m_aBoolParams[ CMD_BOOLPARAM_HELPCALC ]; + return m_helpdraw; } -sal_Bool CommandLineArgs::IsHelpDraw() const +bool CommandLineArgs::IsHelpImpress() const { - return m_aBoolParams[ CMD_BOOLPARAM_HELPDRAW ]; + return m_helpimpress; } -sal_Bool CommandLineArgs::IsHelpImpress() const +bool CommandLineArgs::IsHelpBase() const { - return m_aBoolParams[ CMD_BOOLPARAM_HELPIMPRESS ]; + return m_helpbase; } - -sal_Bool CommandLineArgs::IsHelpBase() const +bool CommandLineArgs::IsHelpMath() const { - return m_aBoolParams[ CMD_BOOLPARAM_HELPBASE ]; + return m_helpmath; } -sal_Bool CommandLineArgs::IsHelpMath() const -{ - return m_aBoolParams[ CMD_BOOLPARAM_HELPMATH ]; -} -sal_Bool CommandLineArgs::IsHelpBasic() const -{ - return m_aBoolParams[ CMD_BOOLPARAM_HELPBASIC ]; -} - -sal_Bool CommandLineArgs::IsWriter() const +bool CommandLineArgs::IsHelpBasic() const { - return m_aBoolParams[ CMD_BOOLPARAM_WRITER ]; + return m_helpbasic; } -sal_Bool CommandLineArgs::IsCalc() const +bool CommandLineArgs::IsWriter() const { - return m_aBoolParams[ CMD_BOOLPARAM_CALC ]; + return m_writer; } -sal_Bool CommandLineArgs::IsDraw() const +bool CommandLineArgs::IsCalc() const { - return m_aBoolParams[ CMD_BOOLPARAM_DRAW ]; + return m_calc; } -sal_Bool CommandLineArgs::IsImpress() const +bool CommandLineArgs::IsDraw() const { - return m_aBoolParams[ CMD_BOOLPARAM_IMPRESS ]; + return m_draw; } -sal_Bool CommandLineArgs::IsBase() const +bool CommandLineArgs::IsImpress() const { - return m_aBoolParams[ CMD_BOOLPARAM_BASE ]; + return m_impress; } -sal_Bool CommandLineArgs::IsGlobal() const +bool CommandLineArgs::IsBase() const { - return m_aBoolParams[ CMD_BOOLPARAM_GLOBAL ]; + return m_base; } -sal_Bool CommandLineArgs::IsMath() const +bool CommandLineArgs::IsGlobal() const { - return m_aBoolParams[ CMD_BOOLPARAM_MATH ]; + return m_global; } -sal_Bool CommandLineArgs::IsWeb() const +bool CommandLineArgs::IsMath() const { - return m_aBoolParams[ CMD_BOOLPARAM_WEB ]; + return m_math; } -sal_Bool CommandLineArgs::IsVersion() const +bool CommandLineArgs::IsWeb() const { - return m_aBoolParams[ CMD_BOOLPARAM_VERSION ]; + return m_web; } -sal_Bool CommandLineArgs::HasUnknown() const +bool CommandLineArgs::IsVersion() const { - return m_aBoolParams[ CMD_BOOLPARAM_UNKNOWN ]; + return m_version; } -sal_Bool CommandLineArgs::HasModuleParam() const +bool CommandLineArgs::HasUnknown() const { - return CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_COUNT ); + return m_unknown; } -sal_Bool CommandLineArgs::GetPortalConnectString( ::rtl::OUString& rPara ) const +bool CommandLineArgs::HasModuleParam() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_PORTAL ]; - return m_aStrSetParams[ CMD_STRINGPARAM_PORTAL ]; + return m_writer || m_calc || m_draw || m_impress || m_global || m_math + || m_web || m_base; } -rtl::OUString CommandLineArgs::GetSplashPipe() const +bool CommandLineArgs::HasSplashPipe() const { - return m_aStrParams[CMD_STRINGPARAM_SPLASHPIPE]; + return m_splashpipe; } std::vector< rtl::OUString > const & CommandLineArgs::GetAccept() const @@ -863,89 +778,76 @@ std::vector< rtl::OUString > const & CommandLineArgs::GetUnaccept() const return m_unaccept; } -sal_Bool CommandLineArgs::GetOpenList( ::rtl::OUString& rPara) const +std::vector< rtl::OUString > const & CommandLineArgs::GetOpenList() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_OPENLIST ]; - return m_aStrSetParams[ CMD_STRINGPARAM_OPENLIST ]; + return m_openlist; } -sal_Bool CommandLineArgs::GetViewList( ::rtl::OUString& rPara) const +std::vector< rtl::OUString > const & CommandLineArgs::GetViewList() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_VIEWLIST ]; - return m_aStrSetParams[ CMD_STRINGPARAM_VIEWLIST ]; + return m_viewlist; } -sal_Bool CommandLineArgs::GetStartList( ::rtl::OUString& rPara) const +std::vector< rtl::OUString > const & CommandLineArgs::GetStartList() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_STARTLIST ]; - return m_aStrSetParams[ CMD_STRINGPARAM_STARTLIST ]; + return m_startlist; } -sal_Bool CommandLineArgs::GetForceOpenList( ::rtl::OUString& rPara) const +std::vector< rtl::OUString > const & CommandLineArgs::GetForceOpenList() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_FORCEOPENLIST ]; - return m_aStrSetParams[ CMD_STRINGPARAM_FORCEOPENLIST ]; + return m_forceopenlist; } -sal_Bool CommandLineArgs::GetForceNewList( ::rtl::OUString& rPara) const +std::vector< rtl::OUString > const & CommandLineArgs::GetForceNewList() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_FORCENEWLIST ]; - return m_aStrSetParams[ CMD_STRINGPARAM_FORCENEWLIST ]; + return m_forcenewlist; } -sal_Bool CommandLineArgs::GetPrintList( ::rtl::OUString& rPara) const +std::vector< rtl::OUString > const & CommandLineArgs::GetPrintList() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTLIST ]; - return m_aStrSetParams[ CMD_STRINGPARAM_PRINTLIST ]; + return m_printlist; } -sal_Bool CommandLineArgs::GetPrintToList( ::rtl::OUString& rPara ) const +std::vector< rtl::OUString > const & CommandLineArgs::GetPrintToList() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTTOLIST ]; - return m_aStrSetParams[ CMD_STRINGPARAM_PRINTTOLIST ]; + return m_printtolist; } -sal_Bool CommandLineArgs::GetPrinterName( ::rtl::OUString& rPara ) const +rtl::OUString CommandLineArgs::GetPrinterName() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTERNAME ]; - return m_aStrSetParams[ CMD_STRINGPARAM_PRINTERNAME ]; + return m_printername; } -sal_Bool CommandLineArgs::GetLanguage( ::rtl::OUString& rPara ) const +rtl::OUString CommandLineArgs::GetLanguage() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_LANGUAGE ]; - return m_aStrSetParams[ CMD_STRINGPARAM_LANGUAGE ]; + return m_language; } -sal_Bool CommandLineArgs::GetInFilter( ::rtl::OUString& rPara ) const +std::vector< rtl::OUString > const & CommandLineArgs::GetInFilter() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_INFILTER ]; - return m_aStrSetParams[ CMD_STRINGPARAM_INFILTER ]; + return m_infilter; } -sal_Bool CommandLineArgs::GetConversionList( ::rtl::OUString& rPara ) const +std::vector< rtl::OUString > const & CommandLineArgs::GetConversionList() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONLIST ]; - return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONLIST ]; + return m_conversionlist; } -sal_Bool CommandLineArgs::GetConversionParams( ::rtl::OUString& rPara ) const +rtl::OUString CommandLineArgs::GetConversionParams() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONPARAMS ]; - return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONPARAMS ]; + return m_conversionparams; } -sal_Bool CommandLineArgs::GetConversionOut( ::rtl::OUString& rPara ) const +rtl::OUString CommandLineArgs::GetConversionOut() const { - rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONOUT ]; - return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONOUT ]; + return m_conversionout; } -sal_Bool CommandLineArgs::IsEmpty() const +bool CommandLineArgs::IsEmpty() const { - return m_eArgumentCount == NONE; + return m_bEmpty; } -sal_Bool CommandLineArgs::WantsToLoadDocument() const +bool CommandLineArgs::WantsToLoadDocument() const { return m_bDocumentArgs; } diff --git a/desktop/source/app/cmdlineargs.hxx b/desktop/source/app/cmdlineargs.hxx index a1eebd989c91..4cd19d961051 100644 --- a/desktop/source/app/cmdlineargs.hxx +++ b/desktop/source/app/cmdlineargs.hxx @@ -34,80 +34,15 @@ #include <vector> #include <rtl/ustring.hxx> -#include <osl/mutex.hxx> +#include "boost/noncopyable.hpp" #include "boost/optional.hpp" namespace desktop { -class CommandLineArgs +class CommandLineArgs: private boost::noncopyable { public: - enum BoolParam // must be zero based! - { - CMD_BOOLPARAM_MINIMIZED = 0, - CMD_BOOLPARAM_INVISIBLE, - CMD_BOOLPARAM_NORESTORE, - CMD_BOOLPARAM_HEADLESS, - CMD_BOOLPARAM_QUICKSTART, - CMD_BOOLPARAM_NOQUICKSTART, - CMD_BOOLPARAM_TERMINATEAFTERINIT, - CMD_BOOLPARAM_NOFIRSTSTARTWIZARD, - CMD_BOOLPARAM_NOLOGO, - CMD_BOOLPARAM_NOLOCKCHECK, - CMD_BOOLPARAM_NODEFAULT, - CMD_BOOLPARAM_HELP, - CMD_BOOLPARAM_WRITER, - CMD_BOOLPARAM_CALC, - CMD_BOOLPARAM_DRAW, - CMD_BOOLPARAM_IMPRESS, - CMD_BOOLPARAM_GLOBAL, - CMD_BOOLPARAM_MATH, - CMD_BOOLPARAM_WEB, - CMD_BOOLPARAM_BASE, - CMD_BOOLPARAM_HELPWRITER, - CMD_BOOLPARAM_HELPCALC, - CMD_BOOLPARAM_HELPDRAW, - CMD_BOOLPARAM_HELPBASIC, - CMD_BOOLPARAM_HELPMATH, - CMD_BOOLPARAM_HELPIMPRESS, - CMD_BOOLPARAM_HELPBASE, - CMD_BOOLPARAM_PSN, - CMD_BOOLPARAM_VERSION, - CMD_BOOLPARAM_UNKNOWN, - CMD_BOOLPARAM_COUNT // must be last element! - }; - - enum StringParam // must be zero based! - { - CMD_STRINGPARAM_PORTAL = 0, - CMD_STRINGPARAM_SPLASHPIPE, - CMD_STRINGPARAM_USERDIR, - CMD_STRINGPARAM_CLIENTDISPLAY, - CMD_STRINGPARAM_OPENLIST, - CMD_STRINGPARAM_VIEWLIST, - CMD_STRINGPARAM_STARTLIST, - CMD_STRINGPARAM_FORCEOPENLIST, - CMD_STRINGPARAM_FORCENEWLIST, - CMD_STRINGPARAM_PRINTLIST, - CMD_STRINGPARAM_VERSION, - CMD_STRINGPARAM_PRINTTOLIST, - CMD_STRINGPARAM_PRINTERNAME, - CMD_STRINGPARAM_CONVERSIONLIST, - CMD_STRINGPARAM_CONVERSIONPARAMS, - CMD_STRINGPARAM_CONVERSIONOUT, - CMD_STRINGPARAM_INFILTER, - CMD_STRINGPARAM_DISPLAY, - CMD_STRINGPARAM_LANGUAGE, - CMD_STRINGPARAM_COUNT // must be last element! - }; - - enum GroupParamId - { - CMD_GRPID_MODULE = 0, - CMD_GRPID_COUNT - }; - struct Supplier { // Thrown from constructors and next: @@ -129,99 +64,115 @@ class CommandLineArgs boost::optional< rtl::OUString > getCwdUrl() const { return m_cwdUrl; } - void ClearServer(); - // Access to bool parameters - sal_Bool IsMinimized() const; - sal_Bool IsInvisible() const; - sal_Bool IsNoRestore() const; - sal_Bool IsNoDefault() const; - sal_Bool IsServer() const; - sal_Bool IsHeadless() const; - sal_Bool IsQuickstart() const; - sal_Bool IsNoQuickstart() const; - sal_Bool IsTerminateAfterInit() const; - sal_Bool IsNoLogo() const; - sal_Bool IsNoLockcheck() const; - sal_Bool IsHelp() const; - sal_Bool IsHelpWriter() const; - sal_Bool IsHelpCalc() const; - sal_Bool IsHelpDraw() const; - sal_Bool IsHelpImpress() const; - sal_Bool IsHelpBase() const; - sal_Bool IsHelpMath() const; - sal_Bool IsHelpBasic() const; - sal_Bool IsWriter() const; - sal_Bool IsCalc() const; - sal_Bool IsDraw() const; - sal_Bool IsImpress() const; - sal_Bool IsBase() const; - sal_Bool IsGlobal() const; - sal_Bool IsMath() const; - sal_Bool IsWeb() const; - sal_Bool IsVersion() const; - sal_Bool HasModuleParam() const; - sal_Bool HasUnknown() const; - sal_Bool WantsToLoadDocument() const; + bool IsMinimized() const; + bool IsInvisible() const; + bool IsNoRestore() const; + bool IsNoDefault() const; + bool IsHeadless() const; + bool IsQuickstart() const; + bool IsNoQuickstart() const; + bool IsTerminateAfterInit() const; + bool IsNoLogo() const; + bool IsNoLockcheck() const; + bool IsHelp() const; + bool IsHelpWriter() const; + bool IsHelpCalc() const; + bool IsHelpDraw() const; + bool IsHelpImpress() const; + bool IsHelpBase() const; + bool IsHelpMath() const; + bool IsHelpBasic() const; + bool IsWriter() const; + bool IsCalc() const; + bool IsDraw() const; + bool IsImpress() const; + bool IsBase() const; + bool IsGlobal() const; + bool IsMath() const; + bool IsWeb() const; + bool IsVersion() const; + bool HasModuleParam() const; + bool HasUnknown() const; + bool WantsToLoadDocument() const; // Access to string parameters - sal_Bool GetPortalConnectString( ::rtl::OUString& rPara) const; - rtl::OUString GetSplashPipe() const; + bool HasSplashPipe() const; std::vector< rtl::OUString > const & GetAccept() const; std::vector< rtl::OUString > const & GetUnaccept() const; - sal_Bool GetOpenList( ::rtl::OUString& rPara) const; - sal_Bool GetViewList( ::rtl::OUString& rPara) const; - sal_Bool GetStartList( ::rtl::OUString& rPara) const; - sal_Bool GetForceOpenList( ::rtl::OUString& rPara) const; - sal_Bool GetForceNewList( ::rtl::OUString& rPara) const; - sal_Bool GetPrintList( ::rtl::OUString& rPara) const; - sal_Bool GetPrintToList( ::rtl::OUString& rPara ) const; - sal_Bool GetPrinterName( ::rtl::OUString& rPara ) const; - sal_Bool GetLanguage( ::rtl::OUString& rPara ) const; - sal_Bool GetInFilter( ::rtl::OUString& rPara ) const; - sal_Bool GetConversionList( ::rtl::OUString& rPara ) const; - sal_Bool GetConversionParams( ::rtl::OUString& rPara ) const; - sal_Bool GetConversionOut( ::rtl::OUString& rPara ) const; + std::vector< rtl::OUString > const & GetOpenList() const; + std::vector< rtl::OUString > const & GetViewList() const; + std::vector< rtl::OUString > const & GetStartList() const; + std::vector< rtl::OUString > const & GetForceOpenList() const; + std::vector< rtl::OUString > const & GetForceNewList() const; + std::vector< rtl::OUString > const & GetPrintList() const; + std::vector< rtl::OUString > const & GetPrintToList() const; + rtl::OUString GetPrinterName() const; + rtl::OUString GetLanguage() const; + std::vector< rtl::OUString > const & GetInFilter() const; + std::vector< rtl::OUString > const & GetConversionList() const; + rtl::OUString GetConversionParams() const; + rtl::OUString GetConversionOut() const; // Special analyzed states (does not match directly to a command line parameter!) - sal_Bool IsPrinting() const; - sal_Bool IsEmpty() const; + bool IsEmpty() const; private: - enum Count { NONE, ONE, MANY }; - - struct GroupDefinition - { - sal_Int32 nCount; - BoolParam* pGroupMembers; - }; - - // no copy and operator= - CommandLineArgs( const CommandLineArgs& ); - CommandLineArgs operator=( const CommandLineArgs& ); - - sal_Bool InterpretCommandLineParameter( const ::rtl::OUString&, ::rtl::OUString& ); + bool InterpretCommandLineParameter( const ::rtl::OUString&, ::rtl::OUString& ); void ParseCommandLine_Impl( Supplier& supplier ); void InitParamValues(); - sal_Bool CheckGroupMembers( GroupParamId nGroup, BoolParam nExcludeMember ) const; - - void AddStringListParam_Impl( StringParam eParam, const rtl::OUString& aParam ); - void SetBoolParam_Impl( BoolParam eParam, sal_Bool bValue ); boost::optional< rtl::OUString > m_cwdUrl; - sal_Bool m_aBoolParams[ CMD_BOOLPARAM_COUNT ]; // Stores boolean parameters - rtl::OUString m_aStrParams[ CMD_STRINGPARAM_COUNT ]; // Stores string parameters - sal_Bool m_aStrSetParams[ CMD_STRINGPARAM_COUNT ]; // Stores if string parameters are provided on cmdline - Count m_eArgumentCount; // Number of Args - bool m_bDocumentArgs; // A document creation/open/load arg is used + + bool m_minimized; + bool m_invisible; + bool m_norestore; + bool m_headless; + bool m_quickstart; + bool m_noquickstart; + bool m_terminateafterinit; + bool m_nofirststartwizard; + bool m_nologo; + bool m_nolockcheck; + bool m_nodefault; + bool m_help; + bool m_writer; + bool m_calc; + bool m_draw; + bool m_impress; + bool m_global; + bool m_math; + bool m_web; + bool m_base; + bool m_helpwriter; + bool m_helpcalc; + bool m_helpdraw; + bool m_helpbasic; + bool m_helpmath; + bool m_helpimpress; + bool m_helpbase; + bool m_psn; + bool m_version; + bool m_unknown; + bool m_splashpipe; + + bool m_bEmpty; // No Args at all + bool m_bDocumentArgs; // A document creation/open/load arg is used std::vector< rtl::OUString > m_accept; std::vector< rtl::OUString > m_unaccept; - - mutable ::osl::Mutex m_aMutex; - bool m_server; - - // static definition for groups where only one member can be true - static GroupDefinition m_pGroupDefinitions[ CMD_GRPID_COUNT ]; + std::vector< rtl::OUString > m_openlist; + std::vector< rtl::OUString > m_viewlist; + std::vector< rtl::OUString > m_startlist; + std::vector< rtl::OUString > m_forceopenlist; + std::vector< rtl::OUString > m_forcenewlist; + std::vector< rtl::OUString > m_printlist; + std::vector< rtl::OUString > m_printtolist; + rtl::OUString m_printername; + std::vector< rtl::OUString > m_conversionlist; + rtl::OUString m_conversionparams; + rtl::OUString m_conversionout; + std::vector< rtl::OUString > m_infilter; + rtl::OUString m_language; }; } diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx index 10a462c76ff1..b74643479b94 100644 --- a/desktop/source/app/langselect.cxx +++ b/desktop/source/app/langselect.cxx @@ -172,7 +172,7 @@ bool LanguageSelection::prepareLanguage() OUString aEmpty; const CommandLineArgs& rCmdLineArgs = Desktop::GetCommandLineArgs(); - rCmdLineArgs.GetLanguage(aLocaleString); + aLocaleString = rCmdLineArgs.GetLanguage(); if (isInstalledLanguage(aLocaleString, sal_False)) { bCmdLanguage = true; diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index f246034aaf91..6d67d8055344 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -628,15 +628,6 @@ OfficeIPCThread::~OfficeIPCThread() pGlobalOfficeIPCThread.clear(); } -static void AddURLToStringList( const rtl::OUString& aURL, rtl::OUString& aStringList ) -{ - ::rtl::OUStringBuffer aStringListBuf(aStringList); - if ( aStringListBuf.getLength() ) - aStringListBuf.append('\n'); - aStringListBuf.append(aURL); - aStringList = aStringListBuf.makeStringAndClear(); -} - void OfficeIPCThread::SetReady( rtl::Reference< OfficeIPCThread > const & pThread) { @@ -764,19 +755,26 @@ void OfficeIPCThread::execute() // Print requests are not dependent on the --invisible cmdline argument as they are // loaded with the "hidden" flag! So they are always checked. - bDocRequestSent |= aCmdLineArgs->GetPrintList( pRequest->aPrintList ); - bDocRequestSent |= ( aCmdLineArgs->GetPrintToList( pRequest->aPrintToList ) && - aCmdLineArgs->GetPrinterName( pRequest->aPrinterName ) ); + 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() ) { // 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! - bDocRequestSent |= aCmdLineArgs->GetOpenList( pRequest->aOpenList ); - bDocRequestSent |= aCmdLineArgs->GetViewList( pRequest->aViewList ); - bDocRequestSent |= aCmdLineArgs->GetStartList( pRequest->aStartList ); - bDocRequestSent |= aCmdLineArgs->GetForceOpenList( pRequest->aForceOpenList ); - bDocRequestSent |= aCmdLineArgs->GetForceNewList( pRequest->aForceNewList ); + 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 @@ -805,10 +803,10 @@ void OfficeIPCThread::execute() else if ( aCmdLineArgs->IsWeb() ) eFactory = SvtModuleOptions::E_WRITERWEB; - if ( !pRequest->aOpenList.isEmpty() ) + if ( !pRequest->aOpenList.empty() ) pRequest->aModule = aOpt.GetFactoryName( eFactory ); else - AddURLToStringList( aOpt.GetFactoryEmptyDocumentURL( eFactory ), pRequest->aOpenList ); + pRequest->aOpenList.push_back( aOpt.GetFactoryEmptyDocumentURL( eFactory ) ); bDocRequestSent = sal_True; } } @@ -917,29 +915,23 @@ void OfficeIPCThread::execute() static void AddToDispatchList( DispatchWatcher::DispatchList& rDispatchList, boost::optional< rtl::OUString > const & cwdUrl, - const OUString& aRequestList, + std::vector< rtl::OUString > const & aRequestList, DispatchWatcher::RequestType nType, const OUString& aParam, const OUString& aFactory ) { - if ( !aRequestList.isEmpty() ) + for (std::vector< rtl::OUString >::const_iterator i(aRequestList.begin()); + i != aRequestList.end(); ++i) { - sal_Int32 nIndex = 0; - do - { - OUString aToken = aRequestList.getToken( 0, '\n', nIndex ); - if ( !aToken.isEmpty() ) - rDispatchList.push_back( - DispatchWatcher::DispatchRequest( nType, aToken, cwdUrl, aParam, aFactory )); - } - while ( nIndex >= 0 ); + rDispatchList.push_back( + DispatchWatcher::DispatchRequest( nType, *i, cwdUrl, aParam, aFactory )); } } static void AddConversionsToDispatchList( DispatchWatcher::DispatchList& rDispatchList, boost::optional< rtl::OUString > const & cwdUrl, - const OUString& rRequestList, + std::vector< rtl::OUString > const & rRequestList, const OUString& rParam, const OUString& rPrinterName, const OUString& rFactory, @@ -977,17 +969,11 @@ static void AddConversionsToDispatchList( aParam += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ";" )) + aPWD; } - if ( !rRequestList.isEmpty() ) + for (std::vector< rtl::OUString >::const_iterator i(rRequestList.begin()); + i != rRequestList.end(); ++i) { - sal_Int32 nIndex = 0; - do - { - OUString aToken = rRequestList.getToken( 0, '\n', nIndex ); - if ( !aToken.isEmpty() ) - rDispatchList.push_back( - DispatchWatcher::DispatchRequest( nType, aToken, cwdUrl, aParam, rFactory )); - } - while ( nIndex >= 0 ); + rDispatchList.push_back( + DispatchWatcher::DispatchRequest( nType, *i, cwdUrl, aParam, rFactory )); } } diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx index 8dfda8303965..f60a134add53 100644 --- a/desktop/source/app/officeipcthread.hxx +++ b/desktop/source/app/officeipcthread.hxx @@ -29,6 +29,10 @@ #ifndef _DESKTOP_OFFICEIPCTHREAD_HXX_ #define _DESKTOP_OFFICEIPCTHREAD_HXX_ +#include "sal/config.h" + +#include <vector> + #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/frame/XTerminateListener.hpp> #include <osl/pipe.hxx> @@ -55,18 +59,18 @@ struct ProcessDocumentsRequest boost::optional< ::rtl::OUString > aCwdUrl; ::rtl::OUString aModule; - ::rtl::OUString aOpenList; // Documents that should be opened in the default way - ::rtl::OUString aViewList; // Documents that should be opened in viewmode - ::rtl::OUString aStartList; // Documents/Presentations that should be started - ::rtl::OUString aPrintList; // Documents that should be printed on default printer - ::rtl::OUString aForceOpenList; // Documents that should be forced to open for editing (even templates) - ::rtl::OUString aForceNewList; // Documents that should be forced to create a new document + std::vector< rtl::OUString > aOpenList; // Documents that should be opened in the default way + std::vector< rtl::OUString > aViewList; // Documents that should be opened in viewmode + std::vector< rtl::OUString > aStartList; // Documents/Presentations that should be started + std::vector< rtl::OUString > aPrintList; // Documents that should be printed on default printer + std::vector< rtl::OUString > aForceOpenList; // Documents that should be forced to open for editing (even templates) + std::vector< rtl::OUString > aForceNewList; // Documents that should be forced to create a new document ::rtl::OUString aPrinterName; // The printer name that should be used for printing - ::rtl::OUString aPrintToList; // Documents that should be printed on the given printer - ::rtl::OUString aConversionList; + std::vector< rtl::OUString > aPrintToList; // Documents that should be printed on the given printer + std::vector< rtl::OUString > aConversionList; ::rtl::OUString aConversionParams; ::rtl::OUString aConversionOut; - ::rtl::OUString aInFilter; + std::vector< rtl::OUString > aInFilter; ::osl::Condition *pcProcessed; // pointer condition to be set when the request has been processed }; |