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/bootstrap.hxx>
30 #include <tools/extendapplicationenvironment.hxx>
35 # include <android/log.h>
36 # include <salhelper/thread.hxx>
38 # define LOGTAG "LibreOffice/sofficemain"
39 # define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
43 #include <touch/touch.h>
48 extern "C" int DESKTOP_DLLPUBLIC
soffice_main()
52 rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
54 tools::extendApplicationEnvironment();
56 SAL_INFO("desktop.app", "PERFORMANCE - enter Main()" );
58 desktop::Desktop aDesktop
;
59 // This string is used during initialization of the Gtk+ VCL module
60 aDesktop
.SetAppName( OUString("soffice") );
62 // handle --version and --help already here, otherwise they would be handled
63 // after VCL initialization that might fail if $DISPLAY is not set
64 const desktop::CommandLineArgs
& rCmdLineArgs
= aDesktop
.GetCommandLineArgs();
65 OUString
aUnknown( rCmdLineArgs
.GetUnknown() );
66 if ( !aUnknown
.isEmpty() )
68 desktop::Desktop::InitApplicationServiceManager();
69 desktop::displayCmdlineHelp( aUnknown
);
72 if ( rCmdLineArgs
.IsHelp() )
74 desktop::Desktop::InitApplicationServiceManager();
75 desktop::displayCmdlineHelp( OUString() );
78 if ( rCmdLineArgs
.IsVersion() )
80 desktop::Desktop::InitApplicationServiceManager();
81 desktop::displayVersion();
87 } catch (const ::com::sun::star::uno::Exception
&e
) {
88 LOGI("Unhandled UNO exception: '%s'",
89 OUStringToOString(e
.Message
, RTL_TEXTENCODING_UTF8
).getStr());
90 throw; // to get exception type printed
95 #if defined(ANDROID) || defined(IOS)
98 extern "C" SAL_JNI_EXPORT
void JNICALL
99 Java_org_libreoffice_android_AppSupport_runMain(JNIEnv
* /* env */,
109 nRet
= soffice_main();
111 LOGI("soffice_main returned %d", nRet
);
113 } while (nRet
== EXITHELPER_NORMAL_RESTART
||
114 nRet
== EXITHELPER_CRASH_WITH_RESTART
); // pretend to re-start.
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */