summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/inc/app.hxx4
-rw-r--r--desktop/source/app/app.cxx42
-rw-r--r--desktop/source/app/sofficemain.cxx18
3 files changed, 45 insertions, 19 deletions
diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index b4683f4e9522..d3c5c7f9d641 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 4979407422a6..eebde7d342bf 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 793dd157f3ba..b964fd420c86 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();
}