Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / desktop / source / app / sofficemain.cxx
blob0b02155f59fbc0e8f9b785c7d8fac7ce0a50ab42
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
25 #include <app.hxx>
26 #include "cmdlineargs.hxx"
27 #include "cmdlinehelp.hxx"
29 // needed before sal/main.h to avoid redefinition of macros
30 #include <prewin.h>
32 #include <rtl/bootstrap.hxx>
33 #include <sal/log.hxx>
34 #include <sal/main.h>
35 #include <tools/extendapplicationenvironment.hxx>
36 #include <vcl/svmain.hxx>
38 #if HAVE_FEATURE_BREAKPAD
39 #include <desktop/crashreport.hxx>
40 #endif
42 #include <postwin.h>
44 #ifdef ANDROID
45 # include <jni.h>
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__))
51 #endif
53 extern "C" int DESKTOP_DLLPUBLIC soffice_main()
55 sal_detail_initialize(sal::detail::InitializeSoffice, nullptr);
57 #if HAVE_FEATURE_BREAKPAD
58 CrashReporter::installExceptionHandler();
59 #endif
61 #if defined ANDROID
62 try {
63 rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
64 #endif
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 );
79 return EXIT_FAILURE;
81 if ( rCmdLineArgs.IsHelp() )
83 desktop::Desktop::InitApplicationServiceManager();
84 desktop::displayCmdlineHelp( OUString() );
85 return EXIT_SUCCESS;
87 if ( rCmdLineArgs.IsVersion() )
89 desktop::Desktop::InitApplicationServiceManager();
90 desktop::displayVersion();
91 return EXIT_SUCCESS;
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
101 #endif
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */