Files
libreoffice/desktop/source/app/cmdlineargs.cxx

993 lines
36 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2001-07-16 11:55:47 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2001-07-16 11:55:47 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2001-07-16 11:55:47 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2001-07-16 11:55:47 +00:00
*
* This file is part of OpenOffice.org.
2001-07-16 11:55:47 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2001-07-16 11:55:47 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2001-07-16 11:55:47 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2001-07-16 11:55:47 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_desktop.hxx"
2001-07-16 11:55:47 +00:00
#include <cmdlineargs.hxx>
#include <vcl/svapp.hxx>
#include <rtl/uri.hxx>
#include <rtl/ustring.hxx>
#include "rtl/process.h"
#include <comphelper/processfactory.hxx>
#include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include "tools/getprocessworkingdir.hxx"
#include <svl/documentlockfile.hxx>
using namespace rtl;
using namespace com::sun::star::lang;
using namespace com::sun::star::uri;
using namespace com::sun::star::uno;
2001-07-16 11:55:47 +00:00
namespace desktop
{
namespace {
class ExtCommandLineSupplier: public CommandLineArgs::Supplier {
public:
explicit ExtCommandLineSupplier():
m_count(rtl_getAppCommandArgCount()),
m_index(0)
{
rtl::OUString url;
2010-12-16 09:42:43 +00:00
if (tools::getProcessWorkingDir(url)) {
m_cwdUrl.reset(url);
}
}
virtual ~ExtCommandLineSupplier() {}
virtual boost::optional< rtl::OUString > getCwdUrl() { return m_cwdUrl; }
virtual bool next(rtl::OUString * argument) {
OSL_ASSERT(argument != NULL);
if (m_index < m_count) {
CWS-TOOLING: integrate CWS sb102 2008-12-11 16:18:12 +0100 sb r265332 : #i95065# cleanup, to make Windows linking work 2008-12-11 16:16:03 +0100 sb r265331 : #i95065# missing SAL_DLLPUBLIC_EXPORT 2008-12-09 17:40:28 +0100 sb r265122 : #i94469# move CJK specific configuration data to brand layer 2008-12-09 16:09:08 +0100 sb r265112 : #i96959# use PTHREAD_MUTEX_RECURSIVE on all platforms 2008-12-09 15:54:31 +0100 sb r265110 : #i95065# do not derive apphelper::LifeTimeGuard from osl::ResettableMutexGuard to avoid problems with VISIBILITY_HIDDEN=TRUE on MSC 2008-12-09 15:40:51 +0100 sb r265104 : #i95065# add VISIBILITY_HIDDEN=TRUE to connectivity/source/drivers/mozab 2008-12-09 15:36:21 +0100 sb r265102 : #i95501# updated SDK_HOME 2008-12-09 15:31:46 +0100 sb r265099 : typo (temppath vs. tmppath) 2008-12-08 11:48:08 +0100 sb r264979 : #i95065# removed spurious ExplicitCategoriesProvider.obj (ExplicitCategoriesProvider.cxx is not in this directory) 2008-12-07 19:41:07 +0100 sb r264960 : #i96994# erroneously doubled backslash caused visibility feature to be disabled for all GCC versions on Mac OS X 2008-12-06 23:54:49 +0100 sb r264948 : changes from trunk that CWS-TOOLING's rebase to DEV300:m37 (r264891) had missed, as files had been moved around on this CWS 2008-12-05 20:29:23 +0100 sb r264919 : #i85508# versions of flex apparently differ in whether input() resp. yyinput() returns zero or EOF upon end of file 2008-12-05 15:37:23 +0100 sb r264908 : #i95315# removed obsolete jut 2008-12-05 15:34:59 +0100 sb r264907 : #i95531# removed empty obsolete directories 2008-12-05 10:09:23 +0100 sb r264891 : CWS-TOOLING: rebase CWS sb102 to trunk@264807 (milestone: DEV300:m37) 2008-12-04 14:50:20 +0100 sb r264845 : #i95065# introduced VISIBILITY_HIDDEN makefile flag to reduce duplications; made additional libraries use VISIBILITY_HIDDEN=TRUE to avoid warnings with recent GCC 4 versions (had to split certain code directories to make changes that would otherwise erroneously affect multiple libraries built in the same makefile); changed connectivity::ORefVector to no longer derive from std::vector, as that caused problems with the MSC implementation of VISIBILITY_HIDDEN=TRUE; replaced uses of JNIEXPORT with SAL_DLLPUBLIC_EXPORT, as the former does not expand to visibility attributes on some platforms where the latter does 2008-12-03 11:29:38 +0100 sb r264759 : #i94583# remove unnecessary (and wrong) assertion check for rtl_getAppCommandArg return value (which is guaranteed to return osl_Process_E_None or not return at all) 2008-12-02 17:18:31 +0100 sb r264724 : #i96809# silenced GCC 4.3.2 warning 2008-12-02 13:29:34 +0100 sb r264695 : #i96797# make get_tmp_dir fail less often 2008-11-28 17:19:24 +0100 sb r264566 : #i95691# inadvertently missing from -c 264564 2008-11-28 17:07:50 +0100 sb r264564 : #i95691# only structs of exactly 1, 2, 4, or 8 bytes are returned through registers 2008-11-25 13:28:08 +0100 sb r264291 : #i96427# support for SAL_EXCEPTION_DLLPUBLIC_EXPORT (patch by np) 2008-11-21 14:45:22 +0100 sb r264140 : #i95428# added SAL_EXCEPTION_DLLPUBLIC_EXPORT and SAL_EXCEPTION_DLLPRIVATE 2008-11-19 13:19:37 +0100 sb r263984 : #i95525# removed erroneous application/octet-stream svn:mime-type properties
2008-12-30 13:32:01 +00:00
rtl_getAppCommandArg(m_index++, &argument->pData);
return true;
} else {
return false;
}
}
private:
boost::optional< rtl::OUString > m_cwdUrl;
sal_uInt32 m_count;
sal_uInt32 m_index;
};
}
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 &) {}
CommandLineArgs::Supplier::Exception::~Exception() {}
CommandLineArgs::Supplier::Exception &
CommandLineArgs::Supplier::Exception::operator =(Exception const &)
{ return *this; }
CommandLineArgs::Supplier::~Supplier() {}
// intialize class with command line parameters from process environment
CommandLineArgs::CommandLineArgs()
2001-07-16 11:55:47 +00:00
{
ResetParamValues();
ExtCommandLineSupplier s;
ParseCommandLine_Impl( s );
2001-07-16 11:55:47 +00:00
}
CommandLineArgs::CommandLineArgs( Supplier& supplier )
{
ResetParamValues();
ParseCommandLine_Impl( supplier );
}
// ----------------------------------------------------------------------------
2001-07-16 11:55:47 +00:00
void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
2001-07-16 11:55:47 +00:00
{
m_cwdUrl = supplier.getCwdUrl();
Reference<XMultiServiceFactory> xMS(comphelper::getProcessServiceFactory(), UNO_QUERY);
OSL_ENSURE(xMS.is(), "CommandLineArgs: no ProcessServiceFactory.");
Reference< XExternalUriReferenceTranslator > xTranslator(
xMS->createInstance(
2010-11-08 15:14:32 +00:00
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.uri.ExternalUriReferenceTranslator"))),
UNO_QUERY);
// parse command line arguments
sal_Bool bPrintEvent = sal_False;
sal_Bool bOpenEvent = sal_True;
sal_Bool bViewEvent = sal_False;
sal_Bool bStartEvent = sal_False;
sal_Bool bPrintToEvent = sal_False;
sal_Bool bPrinterName = sal_False;
sal_Bool bForceOpenEvent = sal_False;
sal_Bool bForceNewEvent = sal_False;
sal_Bool bDisplaySpec = sal_False;
sal_Bool bConversionEvent= sal_False;
sal_Bool bConversionParamsEvent= sal_False;
sal_Bool bBatchPrintEvent= sal_False;
sal_Bool bBatchPrinterNameEvent= sal_False;
sal_Bool bConversionOutEvent = sal_False;
m_eArgumentCount = NONE;
for (;;)
{
::rtl::OUString aArg;
if ( !supplier.next( &aArg ) )
{
break;
}
// convert file URLs to internal form #112849#
2010-12-13 22:54:24 +09:00
if (aArg.indexOfAsciiL(RTL_CONSTASCII_STRINGPARAM("file:"))==0 &&
xTranslator.is())
{
OUString tmp(xTranslator->translateToInternal(aArg));
if (tmp.getLength() > 0)
aArg = tmp;
}
if ( aArg.getLength() > 0 )
{
m_eArgumentCount = m_eArgumentCount == NONE ? ONE : MANY;
if ( !InterpretCommandLineParameter( aArg ))
{
2010-12-13 22:54:24 +09:00
if ( aArg.toChar() == '-' )
{
// handle this argument as an option
2010-12-13 22:54:24 +09:00
if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-n")))
{
2002-02-26 07:18:25 +00:00
// force new documents based on the following documents
bForceNewEvent = sal_True;
bOpenEvent = sal_False;
bForceOpenEvent = sal_False;
bPrintToEvent = sal_False;
bPrintEvent = sal_False;
bViewEvent = sal_False;
bStartEvent = sal_False;
bDisplaySpec = sal_False;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-o")))
2002-02-26 07:18:25 +00:00
{
// force open documents regards if they are templates or not
bForceOpenEvent = sal_True;
bOpenEvent = sal_False;
bForceNewEvent = sal_False;
bPrintToEvent = sal_False;
bPrintEvent = sal_False;
bViewEvent = sal_False;
bStartEvent = sal_False;
bDisplaySpec = sal_False;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-pt")))
{
2002-02-26 07:18:25 +00:00
// Print to special printer
bPrintToEvent = sal_True;
bPrinterName = sal_True;
bPrintEvent = sal_False;
bOpenEvent = sal_False;
bForceNewEvent = sal_False;
bViewEvent = sal_False;
bStartEvent = sal_False;
bDisplaySpec = sal_False;
bForceOpenEvent = sal_False;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-p")))
2002-02-26 07:18:25 +00:00
{
// Print to default printer
bPrintEvent = sal_True;
bPrintToEvent = sal_False;
bOpenEvent = sal_False;
bForceNewEvent = sal_False;
bForceOpenEvent = sal_False;
bViewEvent = sal_False;
bStartEvent = sal_False;
bDisplaySpec = sal_False;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-view")))
{
// open in viewmode
bOpenEvent = sal_False;
bPrintEvent = sal_False;
bPrintToEvent = sal_False;
bForceNewEvent = sal_False;
bForceOpenEvent = sal_False;
bViewEvent = sal_True;
bStartEvent = sal_False;
bDisplaySpec = sal_False;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-show")))
{
// open in viewmode
bOpenEvent = sal_False;
bViewEvent = sal_False;
bStartEvent = sal_True;
bPrintEvent = sal_False;
bPrintToEvent = sal_False;
bForceNewEvent = sal_False;
bForceOpenEvent = sal_False;
bDisplaySpec = sal_False;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-display")))
{
// set display
bOpenEvent = sal_False;
bPrintEvent = sal_False;
bForceOpenEvent = sal_False;
bPrintToEvent = sal_False;
bForceNewEvent = sal_False;
bViewEvent = sal_False;
bStartEvent = sal_False;
bDisplaySpec = sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-language")))
{
bOpenEvent = sal_False;
bPrintEvent = sal_False;
bForceOpenEvent = sal_False;
bPrintToEvent = sal_False;
bForceNewEvent = sal_False;
bViewEvent = sal_False;
bStartEvent = sal_False;
bDisplaySpec = sal_False;
}
#ifdef MACOSX
/* #i84053# ignore -psn on Mac
Platform dependent #ifdef here is ugly, however this is currently
the only platform dependent parameter. Should more appear
we should find a better solution
*/
2010-12-13 22:54:24 +09:00
else if ( aArg.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("-psn")))
{
// finder argument from MacOSX
bOpenEvent = sal_False;
bPrintEvent = sal_False;
bForceOpenEvent = sal_False;
bPrintToEvent = sal_False;
bForceNewEvent = sal_False;
bViewEvent = sal_False;
bStartEvent = sal_False;
bDisplaySpec = sal_False;
}
#endif
2010-12-13 22:54:24 +09:00
else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-convert-to")))
{
bOpenEvent = sal_False;
bConversionEvent = sal_True;
bConversionParamsEvent = sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-print-to-file")))
{
bOpenEvent = sal_False;
bBatchPrintEvent = sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-printer-name")) &&
bBatchPrintEvent )
{
bBatchPrinterNameEvent = sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-outdir")) &&
(bConversionEvent || bBatchPrintEvent) )
{
bConversionOutEvent = sal_True;
}
}
else
{
if ( bPrinterName && bPrintToEvent )
{
// first argument after "-pt" this must be the printer name
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_PRINTERNAME, aArg );
bPrinterName = sal_False;
}
else if ( bConversionParamsEvent && bConversionEvent )
{
// first argument must be the the params
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONPARAMS, aArg );
bConversionParamsEvent = sal_False;
}
else if ( bBatchPrinterNameEvent && bBatchPrintEvent )
{
// first argument is the printer name
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_PRINTERNAME, aArg );
bBatchPrinterNameEvent = sal_False;
}
else if ( (bConversionEvent || bBatchPrintEvent) && bConversionOutEvent )
{
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONOUT, aArg );
bConversionOutEvent = sal_False;
}
else
{
if( bOpenEvent || bViewEvent || bForceNewEvent || bForceOpenEvent )
{
2010-12-13 22:54:24 +09:00
if( aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("::ODMA")) )
{
2010-12-13 22:54:24 +09:00
::rtl::OUString sArg(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.odma:/"));
sArg += aArg;
aArg = sArg;
}
}
// handle this argument as a filename
if ( bOpenEvent )
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_OPENLIST, aArg );
else if ( bViewEvent )
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_VIEWLIST, aArg );
else if ( bStartEvent )
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_STARTLIST, aArg );
else if ( bPrintEvent )
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_PRINTLIST, aArg );
2002-02-26 07:18:25 +00:00
else if ( bPrintToEvent )
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_PRINTTOLIST, aArg );
2002-02-26 07:18:25 +00:00
else if ( bForceNewEvent )
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_FORCENEWLIST, aArg );
2002-02-26 07:18:25 +00:00
else if ( bForceOpenEvent )
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_FORCEOPENLIST, aArg );
else if ( bDisplaySpec ){
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_DISPLAY, aArg );
bDisplaySpec = sal_False; // only one display, not a list
bOpenEvent = sal_True; // set back to standard
}
else if ( bConversionEvent || bBatchPrintEvent )
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONLIST, aArg );
}
}
}
}
}
}
void CommandLineArgs::AddStringListParam_Impl( StringParam eParam, const rtl::OUString& aParam )
{
OSL_ASSERT( eParam >= 0 && eParam < CMD_STRINGPARAM_COUNT );
if ( m_aStrParams[eParam].getLength() )
m_aStrParams[eParam] += ::rtl::OUString::valueOf( (sal_Unicode)APPEVENT_PARAM_DELIMITER );
m_aStrParams[eParam] += aParam;
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 )
{
if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-minimized" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_MINIMIZED, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-invisible" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_INVISIBLE, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-norestore" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_NORESTORE, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nodefault" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_NODEFAULT, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-bean" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_BEAN, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-plugin" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_PLUGIN, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-server" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_SERVER, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-headless" )) == sal_True )
{
// Headless means also invisibile, so set this parameter to true!
SetBoolParam_Impl( CMD_BOOLPARAM_HEADLESS, sal_True );
SetBoolParam_Impl( CMD_BOOLPARAM_INVISIBLE, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-quickstart" )) == sal_True )
{
#if defined(ENABLE_QUICKSTART_APPLET)
SetBoolParam_Impl( CMD_BOOLPARAM_QUICKSTART, sal_True );
#endif
SetBoolParam_Impl( CMD_BOOLPARAM_NOQUICKSTART, sal_False );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-quickstart=no" )))
{
SetBoolParam_Impl( CMD_BOOLPARAM_NOQUICKSTART, sal_True );
SetBoolParam_Impl( CMD_BOOLPARAM_QUICKSTART, sal_False );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-terminate_after_init" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_TERMINATEAFTERINIT, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nofirststartwizard" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_NOFIRSTSTARTWIZARD, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nologo" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_NOLOGO, sal_True );
return sal_True;
}
2002-10-24 12:15:14 +00:00
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nolockcheck" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_NOLOCKCHECK, sal_True );
// Workaround for automated testing
::svt::DocumentLockFile::AllowInteraction( sal_False );
2002-10-24 12:15:14 +00:00
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-help" ))
|| aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-h" ))
|| aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-?" )))
{
SetBoolParam_Impl( CMD_BOOLPARAM_HELP, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpwriter" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_HELPWRITER, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpcalc" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_HELPCALC, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpdraw" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_HELPDRAW, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpimpress" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_HELPIMPRESS, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpbase" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_HELPBASE, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpbasic" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_HELPBASIC, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpmath" )) == sal_True )
{
SetBoolParam_Impl( CMD_BOOLPARAM_HELPMATH, sal_True );
return sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-splash-pipe=")) )
{
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_SPLASHPIPE, aArg.copy(RTL_CONSTASCII_LENGTH("-splash-pipe=")) );
return sal_True;
}
#ifdef MACOSX
/* #i84053# ignore -psn on Mac
Platform dependent #ifdef here is ugly, however this is currently
the only platform dependent parameter. Should more appear
we should find a better solution
*/
else if ( aArg.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("-psn")) )
{
SetBoolParam_Impl( CMD_BOOLPARAM_PSN, sal_True );
return sal_True;
}
#endif
2010-12-13 22:54:24 +09:00
else if ( aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-infilter=")))
{
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_INFILTER, aArg.copy(RTL_CONSTASCII_LENGTH("-infilter=")) );
return sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-accept=")))
{
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_ACCEPT, aArg.copy(RTL_CONSTASCII_LENGTH("-accept=")) );
return sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-unaccept=")))
{
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_UNACCEPT, aArg.copy(RTL_CONSTASCII_LENGTH("-unaccept=")) );
return sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-portal,")))
{
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_PORTAL, aArg.copy(RTL_CONSTASCII_LENGTH("-portal,")) );
return sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-userid")))
{
2010-12-13 22:54:24 +09:00
if ( aArg.getLength() > RTL_CONSTASCII_LENGTH("-userid")+1 )
{
AddStringListParam_Impl(
CMD_STRINGPARAM_USERDIR,
2010-12-13 22:54:24 +09:00
::rtl::Uri::decode( aArg.copy(RTL_CONSTASCII_LENGTH("-userid")+1),
rtl_UriDecodeWithCharset,
RTL_TEXTENCODING_UTF8 ) );
}
return sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-clientdisplay=")))
{
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_CLIENTDISPLAY, aArg.copy(RTL_CONSTASCII_LENGTH("-clientdisplay=")) );
return sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-version=")))
{
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_VERSION, aArg.copy(RTL_CONSTASCII_LENGTH("-version=")) );
return sal_True;
}
2010-12-13 22:54:24 +09:00
else if ( aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-language=")))
{
2010-12-13 22:54:24 +09:00
AddStringListParam_Impl( CMD_STRINGPARAM_LANGUAGE, aArg.copy(RTL_CONSTASCII_LENGTH("-language=")) );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-writer" )) == sal_True )
{
sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_WRITER );
if ( !bAlreadySet )
SetBoolParam_Impl( CMD_BOOLPARAM_WRITER, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-calc" )) == sal_True )
{
sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_CALC );
if ( !bAlreadySet )
SetBoolParam_Impl( CMD_BOOLPARAM_CALC, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-draw" )) == sal_True )
{
sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_DRAW );
if ( !bAlreadySet )
SetBoolParam_Impl( CMD_BOOLPARAM_DRAW, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-impress" )) == sal_True )
{
sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_IMPRESS );
if ( !bAlreadySet )
SetBoolParam_Impl( CMD_BOOLPARAM_IMPRESS, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-base" )) == sal_True )
{
sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_BASE );
if ( !bAlreadySet )
SetBoolParam_Impl( CMD_BOOLPARAM_BASE, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-global" )) == sal_True )
{
sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_GLOBAL );
if ( !bAlreadySet )
SetBoolParam_Impl( CMD_BOOLPARAM_GLOBAL, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-math" )) == sal_True )
{
sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_MATH );
if ( !bAlreadySet )
SetBoolParam_Impl( CMD_BOOLPARAM_MATH, sal_True );
return sal_True;
}
else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-web" )) == sal_True )
{
sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_WEB );
if ( !bAlreadySet )
SetBoolParam_Impl( CMD_BOOLPARAM_WEB, sal_True );
return sal_True;
}
return sal_False;
}
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;
}
void CommandLineArgs::ResetParamValues()
{
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;
}
void CommandLineArgs::SetBoolParam( BoolParam eParam, sal_Bool bNewValue )
{
osl::MutexGuard aMutexGuard( m_aMutex );
OSL_ASSERT( ( eParam >= 0 && eParam < CMD_BOOLPARAM_COUNT ) );
m_aBoolParams[eParam] = bNewValue;
}
const rtl::OUString& CommandLineArgs::GetStringParam( StringParam eParam ) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
OSL_ASSERT( ( eParam >= 0 && eParam < CMD_STRINGPARAM_COUNT ) );
return m_aStrParams[eParam];
}
sal_Bool CommandLineArgs::IsMinimized() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_MINIMIZED ];
}
sal_Bool CommandLineArgs::IsInvisible() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_INVISIBLE ];
}
sal_Bool CommandLineArgs::IsNoRestore() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_NORESTORE ];
}
sal_Bool CommandLineArgs::IsNoDefault() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_NODEFAULT ];
}
sal_Bool CommandLineArgs::IsBean() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_BEAN ];
}
sal_Bool CommandLineArgs::IsServer() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_SERVER ];
}
sal_Bool CommandLineArgs::IsHeadless() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_HEADLESS ];
}
sal_Bool CommandLineArgs::IsQuickstart() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_QUICKSTART ];
}
sal_Bool CommandLineArgs::IsNoQuickstart() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_NOQUICKSTART ];
}
sal_Bool CommandLineArgs::IsTerminateAfterInit() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_TERMINATEAFTERINIT ];
}
sal_Bool CommandLineArgs::IsNoLogo() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_NOLOGO ];
}
2002-10-24 12:15:14 +00:00
sal_Bool CommandLineArgs::IsNoLockcheck() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_NOLOCKCHECK ];
}
sal_Bool CommandLineArgs::IsHelp() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_HELP ];
}
sal_Bool CommandLineArgs::IsHelpWriter() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_HELPWRITER ];
}
sal_Bool CommandLineArgs::IsHelpCalc() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_HELPCALC ];
}
sal_Bool CommandLineArgs::IsHelpDraw() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_HELPDRAW ];
}
sal_Bool CommandLineArgs::IsHelpImpress() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_HELPIMPRESS ];
}
sal_Bool CommandLineArgs::IsHelpBase() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_HELPBASE ];
}
sal_Bool CommandLineArgs::IsHelpMath() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_HELPMATH ];
}
sal_Bool CommandLineArgs::IsHelpBasic() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_HELPBASIC ];
}
sal_Bool CommandLineArgs::IsWriter() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_WRITER ];
}
sal_Bool CommandLineArgs::IsCalc() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_CALC ];
}
sal_Bool CommandLineArgs::IsDraw() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_DRAW ];
}
sal_Bool CommandLineArgs::IsImpress() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_IMPRESS ];
}
sal_Bool CommandLineArgs::IsBase() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_BASE ];
}
sal_Bool CommandLineArgs::IsGlobal() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_GLOBAL ];
}
sal_Bool CommandLineArgs::IsMath() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_MATH ];
}
sal_Bool CommandLineArgs::IsWeb() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_aBoolParams[ CMD_BOOLPARAM_WEB ];
}
sal_Bool CommandLineArgs::HasModuleParam() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_COUNT );
}
sal_Bool CommandLineArgs::GetPortalConnectString( ::rtl::OUString& rPara ) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_PORTAL ];
return m_aStrSetParams[ CMD_STRINGPARAM_PORTAL ];
}
sal_Bool CommandLineArgs::GetAcceptString( ::rtl::OUString& rPara ) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_ACCEPT ];
return m_aStrSetParams[ CMD_STRINGPARAM_ACCEPT ];
}
sal_Bool CommandLineArgs::GetUnAcceptString( ::rtl::OUString& rPara ) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_UNACCEPT ];
return m_aStrSetParams[ CMD_STRINGPARAM_UNACCEPT ];
}
sal_Bool CommandLineArgs::GetOpenList( ::rtl::OUString& rPara) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_OPENLIST ];
return m_aStrSetParams[ CMD_STRINGPARAM_OPENLIST ];
}
sal_Bool CommandLineArgs::GetViewList( ::rtl::OUString& rPara) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_VIEWLIST ];
return m_aStrSetParams[ CMD_STRINGPARAM_VIEWLIST ];
}
sal_Bool CommandLineArgs::GetStartList( ::rtl::OUString& rPara) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_STARTLIST ];
return m_aStrSetParams[ CMD_STRINGPARAM_STARTLIST ];
}
sal_Bool CommandLineArgs::GetForceOpenList( ::rtl::OUString& rPara) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_FORCEOPENLIST ];
return m_aStrSetParams[ CMD_STRINGPARAM_FORCEOPENLIST ];
}
sal_Bool CommandLineArgs::GetForceNewList( ::rtl::OUString& rPara) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_FORCENEWLIST ];
return m_aStrSetParams[ CMD_STRINGPARAM_FORCENEWLIST ];
}
sal_Bool CommandLineArgs::GetPrintList( ::rtl::OUString& rPara) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTLIST ];
return m_aStrSetParams[ CMD_STRINGPARAM_PRINTLIST ];
}
sal_Bool CommandLineArgs::GetPrintToList( ::rtl::OUString& rPara ) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTTOLIST ];
return m_aStrSetParams[ CMD_STRINGPARAM_PRINTTOLIST ];
}
sal_Bool CommandLineArgs::GetPrinterName( ::rtl::OUString& rPara ) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTERNAME ];
return m_aStrSetParams[ CMD_STRINGPARAM_PRINTERNAME ];
}
sal_Bool CommandLineArgs::GetLanguage( ::rtl::OUString& rPara ) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_LANGUAGE ];
return m_aStrSetParams[ CMD_STRINGPARAM_LANGUAGE ];
}
sal_Bool CommandLineArgs::GetInFilter( ::rtl::OUString& rPara ) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_INFILTER ];
return m_aStrSetParams[ CMD_STRINGPARAM_INFILTER ];
}
sal_Bool CommandLineArgs::GetConversionList( ::rtl::OUString& rPara ) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONLIST ];
return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONLIST ];
}
sal_Bool CommandLineArgs::GetConversionParams( ::rtl::OUString& rPara ) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONPARAMS ];
return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONPARAMS ];
}
sal_Bool CommandLineArgs::GetConversionOut( ::rtl::OUString& rPara ) const
{
osl::MutexGuard aMutexGuard( m_aMutex );
rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONOUT ];
return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONOUT ];
}
sal_Bool CommandLineArgs::IsEmpty() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_eArgumentCount == NONE;
}
sal_Bool CommandLineArgs::IsEmptyOrAcceptOnly() const
{
osl::MutexGuard aMutexGuard( m_aMutex );
return m_eArgumentCount == NONE ||
( ( m_eArgumentCount == ONE ) && ( m_aStrParams[ CMD_STRINGPARAM_SPLASHPIPE ].getLength() )) ||
( ( m_eArgumentCount == ONE ) && ( m_aStrParams[ CMD_STRINGPARAM_ACCEPT ].getLength() )) ||
( ( m_eArgumentCount == ONE ) && m_aBoolParams[ CMD_BOOLPARAM_PSN ] );
}
2001-07-16 11:55:47 +00:00
} // namespace desktop
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */