1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
21 #include <config_features.h>
23 #include <desktop/dllapi.h>
26 #include "cmdlineargs.hxx"
27 #include "cmdlinehelp.hxx"
29 // needed before sal/main.h to avoid redefinition of macros
32 #include <rtl/bootstrap.hxx>
33 #include <sal/log.hxx>
35 #include <tools/extendapplicationenvironment.hxx>
36 #include <vcl/svmain.hxx>
38 #if HAVE_FEATURE_BREAKPAD
39 #include <desktop/crashreport.hxx>
46 # include <android/log.h>
47 # include <salhelper/thread.hxx>
49 # define LOGTAG "LibreOffice/sofficemain"
50 # define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
53 extern "C" int DESKTOP_DLLPUBLIC
soffice_main()
55 sal_detail_initialize(sal::detail::InitializeSoffice
, nullptr);
57 #if HAVE_FEATURE_BREAKPAD
58 CrashReporter::installExceptionHandler();
63 rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
65 tools::extendApplicationEnvironment();
67 desktop::Desktop aDesktop
;
68 // This string is used during initialization of the Gtk+ VCL module
69 Application::SetAppName( "soffice" );
71 // handle --version and --help already here, otherwise they would be handled
72 // after VCL initialization that might fail if $DISPLAY is not set
73 const desktop::CommandLineArgs
& rCmdLineArgs
= desktop::Desktop::GetCommandLineArgs();
74 const OUString
& aUnknown( rCmdLineArgs
.GetUnknown() );
75 if ( !aUnknown
.isEmpty() )
77 desktop::Desktop::InitApplicationServiceManager();
78 desktop::displayCmdlineHelp( aUnknown
);
81 if ( rCmdLineArgs
.IsHelp() )
83 desktop::Desktop::InitApplicationServiceManager();
84 desktop::displayCmdlineHelp( OUString() );
87 if ( rCmdLineArgs
.IsVersion() )
89 desktop::Desktop::InitApplicationServiceManager();
90 desktop::displayVersion();
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
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */