GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / desktop / source / app / sofficemain.cxx
blob7678e5b47ead9d20cd9260968ce5412a998c3a44
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/bootstrap.hxx>
30 #include <tools/extendapplicationenvironment.hxx>
33 #ifdef ANDROID
34 # include <jni.h>
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__))
40 #endif
42 #ifdef IOS
43 #include <touch/touch.h>
44 #endif
46 int SVMain();
48 extern "C" int DESKTOP_DLLPUBLIC soffice_main()
50 #if defined ANDROID
51 try {
52 rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
53 #endif
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") );
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 const desktop::CommandLineArgs& rCmdLineArgs = aDesktop.GetCommandLineArgs();
65 OUString aUnknown( rCmdLineArgs.GetUnknown() );
66 if ( !aUnknown.isEmpty() )
68 desktop::Desktop::InitApplicationServiceManager();
69 desktop::displayCmdlineHelp( aUnknown );
70 return EXIT_FAILURE;
72 if ( rCmdLineArgs.IsHelp() )
74 desktop::Desktop::InitApplicationServiceManager();
75 desktop::displayCmdlineHelp( OUString() );
76 return EXIT_SUCCESS;
78 if ( rCmdLineArgs.IsVersion() )
80 desktop::Desktop::InitApplicationServiceManager();
81 desktop::displayVersion();
82 return EXIT_SUCCESS;
84 #endif
85 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
92 #endif
95 #if defined(ANDROID) || defined(IOS)
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
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.
118 #endif
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */