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/svmain.hxx>
37
38#if HAVE_FEATURE_BREAKPAD
40#endif
41
42#include <postwin.h>
43
44#ifdef ANDROID
45# include <jni.h>
46# include <android/log.h>
47# include <salhelper/thread.hxx>
48
49# define LOGTAG "LibreOffice/sofficemain"
50# define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
51#endif
52
54{
55 sal_detail_initialize(sal::detail::InitializeSoffice, nullptr);
56
57#if HAVE_FEATURE_BREAKPAD
58 CrashReporter::installExceptionHandler();
59#endif
60
61#if defined ANDROID
62 try {
63 rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
64#endif
66
67 desktop::Desktop aDesktop;
68 // This string is used during initialization of the Gtk+ VCL module
69 Application::SetAppName( "soffice" );
70
71 // handle --version and --help already here, otherwise they would be handled
72 // after VCL initialization that might fail if $DISPLAY is not set
74 const OUString& aUnknown( rCmdLineArgs.GetUnknown() );
75 if ( !aUnknown.isEmpty() )
76 {
79 return EXIT_FAILURE;
80 }
81 if ( rCmdLineArgs.IsHelp() )
82 {
84 desktop::displayCmdlineHelp( OUString() );
85 return EXIT_SUCCESS;
86 }
87 if ( rCmdLineArgs.IsVersion() )
88 {
91 return EXIT_SUCCESS;
92 }
93
94 return SVMain();
95#if defined ANDROID
96 } catch (const css::uno::Exception &e) {
97 LOGI("Unhandled UNO exception: '%s'",
98 OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
99 throw; // to get exception type printed
100 }
101#endif
102}
103
104/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define LOGI(...)
static void SetAppName(const OUString &rUniqueName)
const OUString & GetUnknown() const
Definition: cmdlineargs.hxx:96
static void InitApplicationServiceManager()
Definition: appinit.cxx:63
static CommandLineArgs & GetCommandLineArgs()
Definition: app.cxx:393
#define DESKTOP_DLLPUBLIC
Definition: dllapi.h:19
SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char **argv)
void displayVersion()
void displayCmdlineHelp(OUString const &unknown)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
void extendApplicationEnvironment()
int DESKTOP_DLLPUBLIC soffice_main()
Definition: sofficemain.cxx:53
VCL_DLLPUBLIC int SVMain()