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"
22 #include "desktopdllapi.h"
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>
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__))
45 extern "C" int DESKTOP_DLLPUBLIC
soffice_main()
49 rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
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") );
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
);
69 if ( rCmdLineArgs
.IsHelp() )
71 desktop::Desktop::InitApplicationServiceManager();
72 desktop::displayCmdlineHelp( OUString() );
75 if ( rCmdLineArgs
.IsVersion() )
77 desktop::Desktop::InitApplicationServiceManager();
78 desktop::displayVersion();
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
92 #if defined(ANDROID) || defined(IOS)
95 extern "C" SAL_JNI_EXPORT
void JNICALL
96 Java_org_libreoffice_android_AppSupport_runMain(JNIEnv
* /* env */,
106 nRet
= soffice_main();
108 LOGI("soffice_main returned %d", nRet
);
110 } while (nRet
== EXITHELPER_NORMAL_RESTART
||
111 nRet
== EXITHELPER_CRASH_WITH_RESTART
); // pretend to re-start.
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */