From 4efbd87e31e7488dfcdd1d07ff979f1f59b8b1f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 6 Mar 2012 15:49:20 +0000 Subject: [PATCH] Resolves: rhbz#800272 complain about unknown command-line options --- desktop/source/app/cmdlineargs.cxx | 17 ++++++++++++++++- desktop/source/app/cmdlineargs.hxx | 2 ++ desktop/source/app/officeipcthread.cxx | 6 ++++++ desktop/source/app/sofficemain.cxx | 4 ++++ 4 files changed, 28 insertions(+), 1 deletions(-) diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index 6a5d58a..5ae86ab 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -304,6 +304,15 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) { bConversionOutEvent = true; } +#if defined UNX + else + { + printf("Unknown option %s\n", + rtl::OUStringToOString(aArg, osl_getThreadTextEncoding()).getStr()); + printf("Run 'soffice --help' to see a full list of available command line options.\n"); + SetBoolParam_Impl( CMD_BOOLPARAM_UNKNOWN, sal_True ); + } +#endif } else { @@ -640,7 +649,7 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& if (bDeprecated) { - rtl::OString sArg(rtl::OUStringToOString(aArg, RTL_TEXTENCODING_UTF8)); + 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; @@ -851,6 +860,12 @@ sal_Bool CommandLineArgs::IsVersion() const return m_aBoolParams[ CMD_BOOLPARAM_VERSION ]; } +sal_Bool CommandLineArgs::HasUnknown() const +{ + osl::MutexGuard aMutexGuard( m_aMutex ); + return m_aBoolParams[ CMD_BOOLPARAM_UNKNOWN ]; +} + sal_Bool CommandLineArgs::HasModuleParam() const { osl::MutexGuard aMutexGuard( m_aMutex ); diff --git a/desktop/source/app/cmdlineargs.hxx b/desktop/source/app/cmdlineargs.hxx index f79efea..29b2f46 100644 --- a/desktop/source/app/cmdlineargs.hxx +++ b/desktop/source/app/cmdlineargs.hxx @@ -71,6 +71,7 @@ class CommandLineArgs CMD_BOOLPARAM_HELPBASE, CMD_BOOLPARAM_PSN, CMD_BOOLPARAM_VERSION, + CMD_BOOLPARAM_UNKNOWN, CMD_BOOLPARAM_COUNT // must be last element! }; @@ -162,6 +163,7 @@ class CommandLineArgs sal_Bool IsWeb() const; sal_Bool IsVersion() const; sal_Bool HasModuleParam() const; + sal_Bool HasUnknown() const; sal_Bool WantsToLoadDocument() const; // Access to string parameters diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index b2c6566..4306a67 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -709,6 +709,12 @@ void OfficeIPCThread::execute() #endif continue; } + +#ifdef UNX + if (aCmdLineArgs->HasUnknown() || aCmdLineArgs->IsVersion() || aCmdLineArgs->IsHelp()) + continue; +#endif + const CommandLineArgs &rCurrentCmdLineArgs = Desktop::GetCommandLineArgs(); if ( aCmdLineArgs->IsQuickstart() ) diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx index 76562a3..ed22834 100644 --- a/desktop/source/app/sofficemain.cxx +++ b/desktop/source/app/sofficemain.cxx @@ -63,6 +63,10 @@ desktop::displayVersion(); return EXIT_SUCCESS; } + else if ( rCmdLineArgs.HasUnknown() ) + { + return EXIT_FAILURE; + } #endif return SVMain(); } -- 1.7.7.6