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 
23 #include <desktop/dllapi.h>
24 
25 #include <app.hxx>
26 #include "cmdlineargs.hxx"
27 #include "cmdlinehelp.hxx"
28 
29 // needed before sal/main.h to avoid redefinition of macros
30 #include <prewin.h>
31 
32 #include <rtl/bootstrap.hxx>
33 #include <sal/log.hxx>
34 #include <sal/main.h>
36 #include <vcl/glxtestprocess.hxx>
37 #include <vcl/svmain.hxx>
38 
39 #if HAVE_FEATURE_BREAKPAD
40 #include <desktop/crashreport.hxx>
41 #endif
42 
43 #include <postwin.h>
44 
45 #ifdef ANDROID
46 # include <jni.h>
47 # include <android/log.h>
48 # include <salhelper/thread.hxx>
49 
50 # define LOGTAG "LibreOffice/sofficemain"
51 # define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
52 #endif
53 
55 {
56  sal_detail_initialize(sal::detail::InitializeSoffice, nullptr);
57 
58 #if HAVE_FEATURE_BREAKPAD
59  CrashReporter::installExceptionHandler();
60 #endif
61 
62  bool bSuccess = fire_glxtest_process();
63  SAL_WARN_IF(!bSuccess, "desktop.opengl", "problems with glxtest");
64 
65 #if defined ANDROID
66  try {
67  rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
68 #endif
70 
71  desktop::Desktop aDesktop;
72  // This string is used during initialization of the Gtk+ VCL module
73  Application::SetAppName( "soffice" );
74 
75  // handle --version and --help already here, otherwise they would be handled
76  // after VCL initialization that might fail if $DISPLAY is not set
78  const OUString& aUnknown( rCmdLineArgs.GetUnknown() );
79  if ( !aUnknown.isEmpty() )
80  {
82  desktop::displayCmdlineHelp( aUnknown );
83  return EXIT_FAILURE;
84  }
85  if ( rCmdLineArgs.IsHelp() )
86  {
88  desktop::displayCmdlineHelp( OUString() );
89  return EXIT_SUCCESS;
90  }
91  if ( rCmdLineArgs.IsVersion() )
92  {
95  return EXIT_SUCCESS;
96  }
97 
98  return SVMain();
99 #if defined ANDROID
100  } catch (const css::uno::Exception &e) {
101  LOGI("Unhandled UNO exception: '%s'",
102  OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
103  throw; // to get exception type printed
104  }
105 #endif
106 }
107 
108 /* 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:65
const OUString & GetUnknown() const
Definition: cmdlineargs.hxx:99
bool fire_glxtest_process()
static CommandLineArgs & GetCommandLineArgs()
Definition: app.cxx:389
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:54
void extendApplicationEnvironment()