[Libreoffice-commits] .: desktop/inc desktop/source

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Jan 18 13:47:01 PST 2011


 desktop/inc/app.hxx                |    4 +++
 desktop/source/app/app.cxx         |   42 ++++++++++++++++++++-----------------
 desktop/source/app/sofficemain.cxx |   18 +++++++++++++++
 3 files changed, 45 insertions(+), 19 deletions(-)

New commits:
commit 1996d06c53d70b912f516b6d191bf23f0440155d
Author: Lubos Lunak <l.lunak at suse.cz>
Date:   Tue Jan 18 16:46:26 2011 -0500

    Make --help and --version work even without $DISPLAY.
    
    Signed-off-by: Kohei Yoshida <kyoshida at novell.com>

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index ee30123..14aff69 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -137,6 +137,10 @@ class Desktop : public Application
         void                    SetSplashScreenText( const ::rtl::OUString& rText );
         void                    SetSplashScreenProgress( sal_Int32 );
 
+#ifdef UNX
+        void EarlyCommandLineArgsPrepare();
+#endif
+
     private:
         // Bootstrap methods
         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > CreateApplicationServiceManager();
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 89c8e2a..d41df1c 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -671,14 +671,17 @@ void Desktop::Init()
     }
     
     // create service factory...
-    Reference < XMultiServiceFactory > rSMgr = CreateApplicationServiceManager();
-    if( rSMgr.is() )
+    if( !::comphelper::getProcessServiceFactory().is()) // may be set from Desktop::EarlyCommandLineArgsPrepare()
     {
-        ::comphelper::setProcessServiceFactory( rSMgr );
-    }
-    else
-    {
-        SetBootstrapError( BE_UNO_SERVICEMANAGER );
+        Reference < XMultiServiceFactory > rSMgr = CreateApplicationServiceManager();
+        if( rSMgr.is() )
+        {
+            ::comphelper::setProcessServiceFactory( rSMgr );
+        }
+        else
+        {
+            SetBootstrapError( BE_UNO_SERVICEMANAGER );
+        }
     }
 
     if ( GetBootstrapError() == BE_OK )
@@ -696,18 +699,6 @@ void Desktop::Init()
     if ( GetBootstrapError() == BE_OK )
     {
         CommandLineArgs* pCmdLineArgs = GetCommandLineArgs();
-#ifdef UNX
-    //  check whether we need to print cmdline help
-    if ( pCmdLineArgs->IsHelp() ) {
-        displayCmdlineHelp();
-        SetBootstrapStatus(BS_TERMINATE);
-    }
-    else if ( pCmdLineArgs->IsVersion() )
-    {
-        displayVersion();
-        SetBootstrapStatus(BS_TERMINATE);
-    }
-#endif
         // start ipc thread only for non-remote offices
         RTL_LOGFILE_CONTEXT( aLog2, "desktop (cd100003) ::OfficeIPCThread::EnableOfficeIPCThread" );
         OfficeIPCThread::Status aStatus = OfficeIPCThread::EnableOfficeIPCThread();
@@ -736,6 +727,19 @@ void Desktop::InitFinished()
     CloseSplashScreen();
 }
 
+#ifdef UNX
+// GetCommandLineArgs() requires this code to work, otherwise it will abort, and
+// on Unix command line args needs to be checked before Desktop::Init()
+void Desktop::EarlyCommandLineArgsPrepare()
+{
+    Reference < XMultiServiceFactory > rSMgr = CreateApplicationServiceManager();
+    if( rSMgr.is() )
+    {
+        ::comphelper::setProcessServiceFactory( rSMgr );
+    }
+}
+#endif
+
 void Desktop::DeInit()
 {
     RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::DeInit" );
diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx
index 3d4a803..a5dfe38 100644
--- a/desktop/source/app/sofficemain.cxx
+++ b/desktop/source/app/sofficemain.cxx
@@ -30,6 +30,8 @@
 #include "precompiled_desktop.hxx"
 
 #include "app.hxx"
+#include "cmdlineargs.hxx"
+#include "cmdlinehelp.hxx"
 
 #include <rtl/logfile.hxx>
 #include <tools/extendapplicationenvironment.hxx>
@@ -47,6 +49,22 @@ extern "C" int soffice_main()
     desktop::Desktop aDesktop;
     // This string is used during initialization of the Gtk+ VCL module
     aDesktop.SetAppName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("soffice")) );
+#ifdef UNX
+    // handle --version and --help already here, otherwise they would be handled
+    // after VCL initialization that might fail if $DISPLAY is not set
+    aDesktop.EarlyCommandLineArgsPrepare();
+    desktop::CommandLineArgs* pCmdLineArgs = aDesktop.GetCommandLineArgs();
+    if ( pCmdLineArgs->IsHelp() )
+    {
+        desktop::displayCmdlineHelp();
+        return EXIT_SUCCESS;
+    }
+    else if ( pCmdLineArgs->IsVersion() )
+    {
+        desktop::displayVersion();
+        return EXIT_SUCCESS;
+    }
+#endif
     return SVMain();
 }
 


More information about the Libreoffice-commits mailing list