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