LCOV - code coverage report
Current view: top level - desktop/source/app - sofficemain.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 12 21 57.1 %
Date: 2015-06-13 12:38:46 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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 <osl/file.hxx>
      30             : #include <rtl/bootstrap.hxx>
      31             : #include <sal/log.hxx>
      32             : #include <tools/extendapplicationenvironment.hxx>
      33             : #include <vcl/svmain.hxx>
      34             : 
      35             : #include <com/sun/star/beans/NamedValue.hpp>
      36             : #include <com/sun/star/frame/Desktop.hpp>
      37             : #include <com/sun/star/frame/XComponentLoader.hpp>
      38             : #include <com/sun/star/frame/XStorable2.hpp>
      39             : #include <comphelper/storagehelper.hxx>
      40             : #include <cppuhelper/bootstrap.hxx>
      41             : #include <unotools/mediadescriptor.hxx>
      42             : 
      43             : 
      44             : #ifdef ANDROID
      45             : #  include <jni.h>
      46             : #  include <android/log.h>
      47             : #  include <salhelper/thread.hxx>
      48             : 
      49             : #  define LOGTAG "LibreOffice/sofficemain"
      50             : #  define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
      51             : #endif
      52             : 
      53         116 : extern "C" int DESKTOP_DLLPUBLIC soffice_main()
      54             : {
      55             : #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
      56             :     /* Run test for OpenGL support in own process to avoid crash with broken
      57             :      * OpenGL drivers. Start process as early as possible.
      58             :      */
      59         116 :     bool bSuccess = fire_glxtest_process();
      60             :     SAL_WARN_IF(!bSuccess, "desktop.opengl", "problems with glxtest");
      61             : #endif
      62             : 
      63             : #if defined ANDROID
      64             :     try {
      65             :         rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
      66             : #endif
      67         116 :     tools::extendApplicationEnvironment();
      68             : 
      69         116 :     desktop::Desktop aDesktop;
      70             :     // This string is used during initialization of the Gtk+ VCL module
      71         116 :     Application::SetAppName( OUString("soffice") );
      72             : #ifdef UNX
      73             :     // handle --version and --help already here, otherwise they would be handled
      74             :     // after VCL initialization that might fail if $DISPLAY is not set
      75         116 :     const desktop::CommandLineArgs& rCmdLineArgs = desktop::Desktop::GetCommandLineArgs();
      76         232 :     OUString aUnknown( rCmdLineArgs.GetUnknown() );
      77         116 :     if ( !aUnknown.isEmpty() )
      78             :     {
      79           0 :         desktop::Desktop::InitApplicationServiceManager();
      80           0 :         desktop::displayCmdlineHelp( aUnknown );
      81           0 :         return EXIT_FAILURE;
      82             :     }
      83         116 :     if ( rCmdLineArgs.IsHelp() )
      84             :     {
      85           0 :         desktop::Desktop::InitApplicationServiceManager();
      86           0 :         desktop::displayCmdlineHelp( OUString() );
      87           0 :         return EXIT_SUCCESS;
      88             :     }
      89         116 :     if ( rCmdLineArgs.IsVersion() )
      90             :     {
      91           0 :         desktop::Desktop::InitApplicationServiceManager();
      92           0 :         desktop::displayVersion();
      93           0 :         return EXIT_SUCCESS;
      94             :     }
      95             : #endif
      96         232 :     return SVMain();
      97             : #if defined ANDROID
      98             :     } catch (const ::com::sun::star::uno::Exception &e) {
      99             :         LOGI("Unhandled UNO exception: '%s'",
     100             :              OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
     101             :         throw; // to get exception type printed
     102             :     }
     103             : #endif
     104         348 : }
     105             : 
     106             : #if defined(ANDROID) || defined(IOS)
     107             : 
     108             : extern "C" void PtylTestEncryptionAndExport(const char *pathname)
     109             : {
     110             :     OUString sUri(pathname, strlen(pathname), RTL_TEXTENCODING_UTF8);
     111             :     sUri = "file://" + sUri;
     112             : 
     113             :     css::uno::Reference<css::frame::XComponentLoader> loader(css::frame::Desktop::create(cppu::defaultBootstrap_InitialComponentContext()), css::uno::UNO_QUERY);
     114             :     css::uno::Reference<css::lang::XComponent> component;
     115             :     component.set(loader->loadComponentFromURL(sUri, "_default", 0, {}));
     116             : 
     117             :     utl::MediaDescriptor media;
     118             :     media[utl::MediaDescriptor::PROP_FILTERNAME()] <<= OUString("MS Word 2007 XML");
     119             :     OUString password("myPassword");
     120             :     css::uno::Sequence<css::beans::NamedValue> encryptionData(1);
     121             :     encryptionData[0].Name = "OOXPassword";
     122             :     encryptionData[0].Value = css::uno::makeAny(password);
     123             :     media[utl::MediaDescriptor::PROP_ENCRYPTIONDATA()] <<= encryptionData;
     124             : 
     125             :     css::uno::Reference<css::frame::XModel> model(component, css::uno::UNO_QUERY);
     126             :     css::uno::Reference<css::frame::XStorable2> storable2(model, css::uno::UNO_QUERY);
     127             :     OUString saveAsUri(sUri + ".new.docx");
     128             :     SAL_INFO("desktop.app", "Trying to store as " << saveAsUri);
     129             :     OUString testPathName;
     130             :     osl::File::getSystemPathFromFileURL(saveAsUri+".txt", testPathName);
     131             :     storable2->storeToURL(saveAsUri, media.getAsConstPropertyValueList());
     132             : }
     133             : 
     134             : #endif
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11