LibreOffice Module desktop (master)  1
sofficemain.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <sal/config.h>
21 #include <config_features.h>
22 #include <config_version.h>
23 #include <config_folders.h>
24 
25 #include <desktop/dllapi.h>
26 
27 #include <app.hxx>
28 #include "cmdlineargs.hxx"
29 #include "cmdlinehelp.hxx"
30 
31 // needed before sal/main.h to avoid redefinition of macros
32 #include <prewin.h>
33 
34 #include <desktop/exithelper.h>
35 #include <osl/file.hxx>
36 #include <rtl/bootstrap.hxx>
37 #include <sal/log.hxx>
38 #include <sal/main.h>
40 #include <vcl/glxtestprocess.hxx>
41 #include <vcl/svmain.hxx>
42 
43 #include <com/sun/star/beans/NamedValue.hpp>
44 #include <cppuhelper/bootstrap.hxx>
46 
47 #if HAVE_FEATURE_BREAKPAD
48 #include <desktop/crashreport.hxx>
49 #endif
50 
51 #include <postwin.h>
52 
53 #ifdef ANDROID
54 # include <jni.h>
55 # include <android/log.h>
56 # include <salhelper/thread.hxx>
57 
58 # define LOGTAG "LibreOffice/sofficemain"
59 # define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
60 #endif
61 
63 {
64  sal_detail_initialize(sal::detail::InitializeSoffice, nullptr);
65 
66 #if HAVE_FEATURE_BREAKPAD
67  CrashReporter::installExceptionHandler();
68 #endif
69 
70 #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && HAVE_FEATURE_UI && HAVE_FEATURE_OPENGL
71  /* Run test for OpenGL support in own process to avoid crash with broken
72  * OpenGL drivers. Start process as early as possible.
73  * In non-headless mode, the process will be reaped in X11OpenGLDeviceInfo::GetData
74  * (vcl/opengl/x11/X11DeviceInfo.cxx). In headless mode, the process will be reaped late in
75  * Desktop::Main (desktop/source/app/app.cxx), in a code block that needs to be covered by the
76  * same #if condition as this code block.
77  */
78  bool bSuccess = fire_glxtest_process();
79  SAL_WARN_IF(!bSuccess, "desktop.opengl", "problems with glxtest");
80 #endif
81 
82 #if defined ANDROID
83  try {
84  rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
85 #endif
87 
88  desktop::Desktop aDesktop;
89  // This string is used during initialization of the Gtk+ VCL module
90  Application::SetAppName( "soffice" );
91 
92  // handle --version and --help already here, otherwise they would be handled
93  // after VCL initialization that might fail if $DISPLAY is not set
95  const OUString& aUnknown( rCmdLineArgs.GetUnknown() );
96  if ( !aUnknown.isEmpty() )
97  {
99  desktop::displayCmdlineHelp( aUnknown );
100  return EXIT_FAILURE;
101  }
102  if ( rCmdLineArgs.IsHelp() )
103  {
105  desktop::displayCmdlineHelp( OUString() );
106  return EXIT_SUCCESS;
107  }
108  if ( rCmdLineArgs.IsVersion() )
109  {
112  return EXIT_SUCCESS;
113  }
114 
115  return SVMain();
116 #if defined ANDROID
117  } catch (const css::uno::Exception &e) {
118  LOGI("Unhandled UNO exception: '%s'",
119  OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
120  throw; // to get exception type printed
121  }
122 #endif
123 }
124 
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void displayCmdlineHelp(OUString const &unknown)
#define DESKTOP_DLLPUBLIC
Definition: dllapi.h:19
int SVMain()
static void SetAppName(const OUString &rUniqueName)
void displayVersion()
static void InitApplicationServiceManager()
Definition: appinit.cxx:76
const OUString & GetUnknown() const
Definition: cmdlineargs.hxx:99
bool fire_glxtest_process()
static CommandLineArgs & GetCommandLineArgs()
Definition: app.cxx:395
OString OUStringToOString(const OUString &str, ConnectionSettings const *settings)
SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char **argv)
#define SAL_WARN_IF(condition, area, stream)
int DESKTOP_DLLPUBLIC soffice_main()
Definition: sofficemain.cxx:62
void extendApplicationEnvironment()