bump product version to 4.1.6.2
[LibreOffice.git] / desktop / source / app / sofficemain.cxx
blob44de16e3816ed2161ffb781432dd0b1f191b88bb
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"
22 #include "desktopdllapi.h"
24 #include "app.hxx"
25 #include "exithelper.h"
26 #include "cmdlineargs.hxx"
27 #include "cmdlinehelp.hxx"
29 #include <rtl/logfile.hxx>
30 #include <rtl/bootstrap.hxx>
31 #include <tools/extendapplicationenvironment.hxx>
34 #ifdef ANDROID
35 # include <jni.h>
36 # include <android/log.h>
37 # include <salhelper/thread.hxx>
39 # define LOGTAG "LibreOffice/sofficemain"
40 # define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
41 #endif
43 int SVMain();
45 extern "C" int DESKTOP_DLLPUBLIC soffice_main()
47 #if defined ANDROID
48 try {
49 rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
50 #endif
51 tools::extendApplicationEnvironment();
53 RTL_LOGFILE_PRODUCT_TRACE( "PERFORMANCE - enter Main()" );
55 desktop::Desktop aDesktop;
56 // This string is used during initialization of the Gtk+ VCL module
57 aDesktop.SetAppName( OUString("soffice") );
58 #ifdef UNX
59 // handle --version and --help already here, otherwise they would be handled
60 // after VCL initialization that might fail if $DISPLAY is not set
61 const desktop::CommandLineArgs& rCmdLineArgs = aDesktop.GetCommandLineArgs();
62 OUString aUnknown( rCmdLineArgs.GetUnknown() );
63 if ( !aUnknown.isEmpty() )
65 desktop::Desktop::InitApplicationServiceManager();
66 desktop::displayCmdlineHelp( aUnknown );
67 return EXIT_FAILURE;
69 if ( rCmdLineArgs.IsHelp() )
71 desktop::Desktop::InitApplicationServiceManager();
72 desktop::displayCmdlineHelp( OUString() );
73 return EXIT_SUCCESS;
75 if ( rCmdLineArgs.IsVersion() )
77 desktop::Desktop::InitApplicationServiceManager();
78 desktop::displayVersion();
79 return EXIT_SUCCESS;
81 #endif
82 return SVMain();
83 #if defined ANDROID
84 } catch (const ::com::sun::star::uno::Exception &e) {
85 LOGI("Unhandled UNO exception: '%s'",
86 OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
87 throw; // to get exception type printed
89 #endif
92 #if defined(ANDROID) || defined(IOS)
94 #ifdef ANDROID
95 extern "C" SAL_JNI_EXPORT void JNICALL
96 Java_org_libreoffice_android_AppSupport_runMain(JNIEnv* /* env */,
97 jobject /* clazz */)
98 #else
99 extern "C"
100 void
101 lo_runMain()
102 #endif
104 int nRet;
105 do {
106 nRet = soffice_main();
107 #ifdef ANDROID
108 LOGI("soffice_main returned %d", nRet);
109 #endif
110 } while (nRet == EXITHELPER_NORMAL_RESTART ||
111 nRet == EXITHELPER_CRASH_WITH_RESTART); // pretend to re-start.
115 #endif
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */