Clean up option processing
* Support --version on non-UNX, too. * Consistently show the first unknown option and the help blob in the presence of any unknown options. * There is no need to tunnel --help/--version past oosplash in the soffice script, as oosplash is prepared to treat them adequately (esp. not pass them over any pipe); this only added unnecessary variance to what spellings exactly are supported and how mixtures of --help, --version, and unknown options are handled. Change-Id: I617f2e727e2f0eafd34a2de3b85d441c6783ec4f
This commit is contained in:
@@ -158,21 +158,5 @@ if [ -n "$VALGRINDCHECK" -a -z "$VALGRIND" ] ; then
|
||||
exec &>valgrind.log
|
||||
fi
|
||||
|
||||
# do not pass the request for command line help to oosplash
|
||||
for arg in $@ ; do
|
||||
case "$arg" in
|
||||
-h | --h | --he | --hel | --help)
|
||||
"$sd_prog/soffice.bin" --help
|
||||
exit 0
|
||||
;;
|
||||
-V | --v | --ve | --ver | --vers | --versi | --versio | --version)
|
||||
"$sd_prog/soffice.bin" --version
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# oosplash does the rest: forcing pages in, javaldx etc. are
|
||||
exec $VALGRINDCHECK $STRACECHECK "$sd_prog/oosplash" "$@"
|
||||
|
@@ -634,7 +634,8 @@ void Desktop::Init()
|
||||
// 2nd office startup should terminate after sending cmdlineargs through pipe
|
||||
SetBootstrapStatus(BS_TERMINATE);
|
||||
}
|
||||
else if ( rCmdLineArgs.IsHelp() )
|
||||
else if ( !rCmdLineArgs.GetUnknown().isEmpty()
|
||||
|| rCmdLineArgs.IsHelp() || rCmdLineArgs.IsVersion() )
|
||||
{
|
||||
// disable IPC thread in an instance that is just showing a help message
|
||||
OfficeIPCThread::DisableOfficeIPCThread();
|
||||
@@ -1388,6 +1389,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;
|
||||
@@ -1431,14 +1448,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" );
|
||||
@@ -2696,10 +2705,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:
|
||||
{
|
||||
|
@@ -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=") &&
|
||||
//ignore additional legacy options that don't do anything anymore
|
||||
!oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("nocrashreport")))
|
||||
{
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
//ignore additional legacy options that don't do anything anymore
|
||||
!oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("nocrashreport")) &&
|
||||
m_unknown.isEmpty())
|
||||
{
|
||||
m_unknown = aArg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -624,7 +623,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;
|
||||
@@ -762,7 +760,7 @@ bool CommandLineArgs::IsVersion() const
|
||||
return m_version;
|
||||
}
|
||||
|
||||
bool CommandLineArgs::HasUnknown() const
|
||||
OUString CommandLineArgs::GetUnknown() const
|
||||
{
|
||||
return m_unknown;
|
||||
}
|
||||
|
@@ -93,9 +93,10 @@ class CommandLineArgs: private boost::noncopyable
|
||||
bool IsWeb() const;
|
||||
bool IsVersion() const;
|
||||
bool HasModuleParam() const;
|
||||
bool HasUnknown() const;
|
||||
bool WantsToLoadDocument() const;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
@@ -136,7 +136,7 @@ namespace desktop
|
||||
|
||||
rtl::OUString ReplaceStringHookProc(const rtl::OUString& rStr);
|
||||
|
||||
void displayCmdlineHelp()
|
||||
void displayCmdlineHelp(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",
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace desktop
|
||||
{
|
||||
void displayCmdlineHelp( void );
|
||||
void displayCmdlineHelp( OUString const & unknown );
|
||||
void displayVersion();
|
||||
#ifndef UNX
|
||||
class CmdlineHelpDialog : public ModalDialog
|
||||
|
@@ -703,192 +703,193 @@ void OfficeIPCThread::execute()
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef UNX
|
||||
if (aCmdLineArgs->HasUnknown() || aCmdLineArgs->IsVersion() || aCmdLineArgs->IsHelp())
|
||||
continue;
|
||||
#endif
|
||||
|
||||
const CommandLineArgs &rCurrentCmdLineArgs = Desktop::GetCommandLineArgs();
|
||||
|
||||
if ( aCmdLineArgs->IsQuickstart() )
|
||||
{
|
||||
// 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 );
|
||||
}
|
||||
|
||||
// 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 );
|
||||
}
|
||||
// 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);
|
||||
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() )
|
||||
OUString aUnknown( aCmdLineArgs->GetUnknown() );
|
||||
if ( !aUnknown.isEmpty() || aCmdLineArgs->IsHelp() )
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
ApplicationEvent* pAppEvent =
|
||||
new ApplicationEvent(ApplicationEvent::TYPE_HELP, aUnknown);
|
||||
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");
|
||||
}
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
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 if ( aCmdLineArgs->IsVersion() )
|
||||
{
|
||||
ApplicationEvent* pAppEvent =
|
||||
new ApplicationEvent(ApplicationEvent::TYPE_VERSION);
|
||||
ImplPostForeignAppEvent( pAppEvent );
|
||||
}
|
||||
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 );
|
||||
const CommandLineArgs &rCurrentCmdLineArgs = Desktop::GetCommandLineArgs();
|
||||
|
||||
if ( aCmdLineArgs->IsQuickstart() )
|
||||
{
|
||||
// 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 );
|
||||
}
|
||||
|
||||
// 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 );
|
||||
}
|
||||
// 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 );
|
||||
}
|
||||
|
||||
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() )
|
||||
{
|
||||
// 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 );
|
||||
}
|
||||
}
|
||||
|
||||
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...
|
||||
|
@@ -60,22 +60,25 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main()
|
||||
// handle --version and --help already here, otherwise they would be handled
|
||||
// after VCL initialization that might fail if $DISPLAY is not set
|
||||
const desktop::CommandLineArgs& rCmdLineArgs = aDesktop.GetCommandLineArgs();
|
||||
OUString aUnknown( rCmdLineArgs.GetUnknown() );
|
||||
if ( !aUnknown.isEmpty() )
|
||||
{
|
||||
desktop::Desktop::InitApplicationServiceManager();
|
||||
desktop::displayCmdlineHelp( aUnknown );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if ( rCmdLineArgs.IsHelp() )
|
||||
{
|
||||
desktop::Desktop::InitApplicationServiceManager();
|
||||
desktop::displayCmdlineHelp();
|
||||
desktop::displayCmdlineHelp( OUString() );
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
else if ( rCmdLineArgs.IsVersion() )
|
||||
if ( rCmdLineArgs.IsVersion() )
|
||||
{
|
||||
desktop::Desktop::InitApplicationServiceManager();
|
||||
desktop::displayVersion();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
else if ( rCmdLineArgs.HasUnknown() )
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
return SVMain();
|
||||
#if defined ANDROID
|
||||
|
@@ -48,30 +48,34 @@ static struct {
|
||||
unsigned int bInhibitSplash : 1;
|
||||
unsigned int bInhibitPagein : 1;
|
||||
unsigned int bInhibitJavaLdx : 1;
|
||||
unsigned int bInhibitPipe : 1;
|
||||
const char *pPageinType;
|
||||
} pArgDescr[] = {
|
||||
/* have a trailing argument */
|
||||
{ "pt", 1, 0, 0, 0, NULL },
|
||||
{ "display", 1, 0, 0, 0, NULL },
|
||||
{ "pt", 1, 0, 0, 0, 0, NULL },
|
||||
{ "display", 1, 0, 0, 0, 0, NULL },
|
||||
|
||||
/* no splash */
|
||||
{ "nologo", 0, 1, 0, 0, NULL },
|
||||
{ "headless", 0, 1, 0, 0, NULL },
|
||||
{ "invisible", 0, 1, 0, 0, NULL },
|
||||
{ "quickstart", 0, 1, 0, 0, NULL },
|
||||
{ "minimized", 0, 1, 0, 0, NULL },
|
||||
{ "nologo", 0, 1, 0, 0, 0, NULL },
|
||||
{ "headless", 0, 1, 0, 0, 0, NULL },
|
||||
{ "invisible", 0, 1, 0, 0, 0, NULL },
|
||||
{ "quickstart", 0, 1, 0, 0, 0, NULL },
|
||||
{ "minimized", 0, 1, 0, 0, 0, NULL },
|
||||
|
||||
/* pagein bits */
|
||||
{ "writer", 0, 0, 0, 0, "pagein-writer" },
|
||||
{ "calc", 0, 0, 0, 0, "pagein-calc" },
|
||||
{ "draw", 0, 0, 0, 0, "pagein-draw" },
|
||||
{ "impress", 0, 0, 0, 0, "pagein-impress" },
|
||||
{ "writer", 0, 0, 0, 0, 0, "pagein-writer" },
|
||||
{ "calc", 0, 0, 0, 0, 0, "pagein-calc" },
|
||||
{ "draw", 0, 0, 0, 0, 0, "pagein-draw" },
|
||||
{ "impress", 0, 0, 0, 0, 0, "pagein-impress" },
|
||||
|
||||
/* nothing much */
|
||||
{ "version", 0, 1, 1, 1, NULL },
|
||||
{ "help", 0, 1, 1, 1, NULL },
|
||||
{ "h", 0, 1, 1, 1, NULL },
|
||||
{ "?", 0, 1, 1, 1, NULL },
|
||||
/* Do not send --help/--version over the pipe, as their output shall go to
|
||||
the calling process's stdout (ideally, this would also happen in the
|
||||
presence of unknown options); also prevent splash/pagein/javaldx overhead
|
||||
(as these options will be processed early in soffice_main): */
|
||||
{ "version", 0, 1, 1, 1, 1, NULL },
|
||||
{ "help", 0, 1, 1, 1, 1, NULL },
|
||||
{ "h", 0, 1, 1, 1, 1, NULL },
|
||||
{ "?", 0, 1, 1, 1, 1, NULL },
|
||||
};
|
||||
|
||||
Args *args_parse (void)
|
||||
@@ -133,6 +137,7 @@ Args *args_parse (void)
|
||||
args->bInhibitSplash |= pArgDescr[j].bInhibitSplash;
|
||||
args->bInhibitPagein |= pArgDescr[j].bInhibitPagein;
|
||||
args->bInhibitJavaLdx |= pArgDescr[j].bInhibitJavaLdx;
|
||||
args->bInhibitPipe |= pArgDescr[j].bInhibitPipe;
|
||||
if (pArgDescr[j].pPageinType)
|
||||
args->pPageinType = pArgDescr[j].pPageinType;
|
||||
break;
|
||||
|
@@ -38,6 +38,7 @@ typedef struct {
|
||||
sal_Bool bInhibitSplash; // should we show a splash screen
|
||||
sal_Bool bInhibitPagein; // should we run pagein ?
|
||||
sal_Bool bInhibitJavaLdx; // should we run javaldx ?
|
||||
sal_Bool bInhibitPipe; // for --help and --version
|
||||
|
||||
sal_uInt32 nArgsEnv; // number of -env: style args
|
||||
sal_uInt32 nArgsTotal; // number of -env: as well as -writer style args
|
||||
|
@@ -831,21 +831,24 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
|
||||
if ( pUsePlugin && !strcmp(pUsePlugin, "svp") )
|
||||
args->bInhibitSplash = sal_True;
|
||||
|
||||
pPipePath = get_pipe_path( args->pAppPath );
|
||||
|
||||
if ( ( fd = connect_pipe( pPipePath ) ) >= 0 )
|
||||
if ( !args->bInhibitPipe )
|
||||
{
|
||||
rtl_uString *pCwdPath = NULL;
|
||||
osl_getProcessWorkingDir( &pCwdPath );
|
||||
pPipePath = get_pipe_path( args->pAppPath );
|
||||
|
||||
bSentArgs = send_args( fd, pCwdPath );
|
||||
if ( ( fd = connect_pipe( pPipePath ) ) >= 0 )
|
||||
{
|
||||
rtl_uString *pCwdPath = NULL;
|
||||
osl_getProcessWorkingDir( &pCwdPath );
|
||||
|
||||
close( fd );
|
||||
}
|
||||
bSentArgs = send_args( fd, pCwdPath );
|
||||
|
||||
close( fd );
|
||||
}
|
||||
#if OSL_DEBUG_LEVEL > 1
|
||||
else
|
||||
ustr_debug( "Failed to connect to pipe", pPipePath );
|
||||
else
|
||||
ustr_debug( "Failed to connect to pipe", pPipePath );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( !bSentArgs )
|
||||
{
|
||||
@@ -935,7 +938,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
rtl_uString_release( pPipePath );
|
||||
if ( pPipePath )
|
||||
rtl_uString_release( pPipePath );
|
||||
args_free (args);
|
||||
|
||||
return status;
|
||||
|
@@ -113,9 +113,9 @@ class VCL_DLLPUBLIC ApplicationEvent
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
TYPE_ACCEPT, TYPE_APPEAR, TYPE_HELP, TYPE_OPEN, TYPE_OPENHELPURL,
|
||||
TYPE_PRINT, TYPE_PRIVATE_DOSHUTDOWN, TYPE_QUICKSTART, TYPE_SHOWDIALOG,
|
||||
TYPE_UNACCEPT
|
||||
TYPE_ACCEPT, TYPE_APPEAR, TYPE_HELP, TYPE_VERSION, TYPE_OPEN,
|
||||
TYPE_OPENHELPURL, TYPE_PRINT, TYPE_PRIVATE_DOSHUTDOWN, TYPE_QUICKSTART,
|
||||
TYPE_SHOWDIALOG, TYPE_UNACCEPT
|
||||
};
|
||||
|
||||
ApplicationEvent() {}
|
||||
|
Reference in New Issue
Block a user