Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "sal/config.h"
21 :
22 : #include "desktopdllapi.h"
23 :
24 : #include "app.hxx"
25 : #include "exithelper.h"
26 : #include "cmdlineargs.hxx"
27 : #include "cmdlinehelp.hxx"
28 :
29 : #include <rtl/bootstrap.hxx>
30 : #include <tools/extendapplicationenvironment.hxx>
31 :
32 :
33 : #ifdef ANDROID
34 : # include <jni.h>
35 : # include <android/log.h>
36 : # include <salhelper/thread.hxx>
37 :
38 : # define LOGTAG "LibreOffice/sofficemain"
39 : # define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
40 : #endif
41 :
42 : #ifdef IOS
43 : #include <touch/touch.h>
44 : #endif
45 :
46 : int SVMain();
47 :
48 1 : extern "C" int DESKTOP_DLLPUBLIC soffice_main()
49 : {
50 : #if defined ANDROID
51 : try {
52 : rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
53 : #endif
54 1 : tools::extendApplicationEnvironment();
55 :
56 : SAL_INFO("desktop.app", "PERFORMANCE - enter Main()" );
57 :
58 1 : desktop::Desktop aDesktop;
59 : // This string is used during initialization of the Gtk+ VCL module
60 1 : aDesktop.SetAppName( OUString("soffice") );
61 : #ifdef UNX
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 1 : const desktop::CommandLineArgs& rCmdLineArgs = aDesktop.GetCommandLineArgs();
65 2 : OUString aUnknown( rCmdLineArgs.GetUnknown() );
66 1 : if ( !aUnknown.isEmpty() )
67 : {
68 0 : desktop::Desktop::InitApplicationServiceManager();
69 0 : desktop::displayCmdlineHelp( aUnknown );
70 0 : return EXIT_FAILURE;
71 : }
72 1 : if ( rCmdLineArgs.IsHelp() )
73 : {
74 0 : desktop::Desktop::InitApplicationServiceManager();
75 0 : desktop::displayCmdlineHelp( OUString() );
76 0 : return EXIT_SUCCESS;
77 : }
78 1 : if ( rCmdLineArgs.IsVersion() )
79 : {
80 0 : desktop::Desktop::InitApplicationServiceManager();
81 0 : desktop::displayVersion();
82 0 : return EXIT_SUCCESS;
83 : }
84 : #endif
85 2 : return SVMain();
86 : #if defined ANDROID
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
91 : }
92 : #endif
93 : }
94 :
95 : #if defined(ANDROID) || defined(IOS)
96 :
97 : #ifdef ANDROID
98 : extern "C" SAL_JNI_EXPORT void JNICALL
99 : Java_org_libreoffice_android_AppSupport_runMain(JNIEnv* /* env */,
100 : jobject /* clazz */)
101 : #else
102 : extern "C"
103 : void
104 : touch_lo_runMain()
105 : #endif
106 : {
107 : int nRet;
108 : do {
109 : nRet = soffice_main();
110 : #ifdef ANDROID
111 : LOGI("soffice_main returned %d", nRet);
112 : #endif
113 : } while (nRet == EXITHELPER_NORMAL_RESTART ||
114 : nRet == EXITHELPER_CRASH_WITH_RESTART); // pretend to re-start.
115 :
116 : }
117 :
118 : #endif
119 :
120 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|