LCOV - code coverage report
Current view: top level - desktop/source/splash - unxsplash.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 58 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 17 0.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 "unxsplash.hxx"
      21             : #include <stdio.h>
      22             : #include <osl/process.h>
      23             : #include <cppuhelper/implementationentry.hxx>
      24             : #include <cppuhelper/supportsservice.hxx>
      25             : #include <rtl/ustrbuf.hxx>
      26             : #include <rtl/math.hxx>
      27             : 
      28             : namespace desktop
      29             : {
      30           0 :     UnxSplashScreen::UnxSplashScreen( const Reference< uno::XComponentContext >& xCtx )
      31             :     : m_xCtx( xCtx ),
      32           0 :       m_pOutFd( NULL )
      33             : {
      34           0 : }
      35             : 
      36           0 : UnxSplashScreen::~UnxSplashScreen()
      37             : {
      38             : #if OSL_DEBUG_LEVEL > 1
      39             :     fprintf( stderr, "UnxSplashScreen::~UnxSplashScreen()\n" );
      40             : #endif
      41             : 
      42           0 :     if ( m_pOutFd )
      43             :     {
      44           0 :         fclose( m_pOutFd );
      45           0 :         m_pOutFd = NULL;
      46             :     }
      47           0 : }
      48             : 
      49           0 : void SAL_CALL UnxSplashScreen::start( const OUString& /*aText*/, sal_Int32 /*nRange*/ )
      50             :     throw ( RuntimeException, std::exception )
      51             : {
      52           0 : }
      53             : 
      54           0 : void SAL_CALL UnxSplashScreen::end()
      55             :     throw ( RuntimeException, std::exception )
      56             : {
      57             : #if OSL_DEBUG_LEVEL > 1
      58             :     fprintf( stderr, "UnxSplashScreen::end()\n" );
      59             : #endif
      60           0 :     if( !m_pOutFd )
      61           0 :         return;
      62             : 
      63           0 :     fprintf( m_pOutFd, "end\n" );
      64           0 :     fflush( m_pOutFd );
      65             : }
      66             : 
      67           0 : void SAL_CALL UnxSplashScreen::reset()
      68             :     throw ( RuntimeException, std::exception )
      69             : {
      70             : #if OSL_DEBUG_LEVEL > 1
      71             :     fprintf( stderr, "UnxSplashScreen::reset()\n" );
      72             : #endif
      73           0 :     if( !m_pOutFd )
      74           0 :         return;
      75             : 
      76           0 :     fprintf( m_pOutFd, "restart\n" );
      77           0 :     fflush( m_pOutFd );
      78             : }
      79             : 
      80           0 : void SAL_CALL UnxSplashScreen::setText( const OUString& /*aText*/ )
      81             :     throw ( RuntimeException, std::exception )
      82             : {
      83             :     // TODO?
      84           0 : }
      85             : 
      86           0 : void SAL_CALL UnxSplashScreen::setValue( sal_Int32 nValue )
      87             :     throw ( RuntimeException, std::exception )
      88             : {
      89           0 :     if ( m_pOutFd )
      90             :     {
      91           0 :         fprintf( m_pOutFd, "%" SAL_PRIdINT32 "%%\n", nValue );
      92           0 :         fflush( m_pOutFd );
      93             :     }
      94           0 : }
      95             : 
      96             : // XInitialize
      97             : void SAL_CALL
      98           0 : UnxSplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& )
      99             :     throw ( RuntimeException, std::exception )
     100             : {
     101           0 :     for ( sal_uInt32 i = 0; i < osl_getCommandArgCount(); i++ )
     102             :     {
     103           0 :         OUString aArg;
     104           0 :         osl_getCommandArg( i, &aArg.pData );
     105           0 :         OUString aNum;
     106           0 :         if ( aArg.startsWithIgnoreAsciiCase("--splash-pipe=", &aNum) )
     107             :         {
     108           0 :             int fd = aNum.toInt32();
     109           0 :             m_pOutFd = fdopen( fd, "w" );
     110             : #if OSL_DEBUG_LEVEL > 1
     111             :             fprintf( stderr, "Got argument '--splash-pipe=%d ('%s') (%p)\n",
     112             :                      fd, OUStringToOString( aNum, RTL_TEXTENCODING_UTF8 ).getStr(),
     113             :                      m_pOutFd );
     114             : #endif
     115             :         }
     116           0 :     }
     117           0 : }
     118             : 
     119           0 : OUString UnxSplashScreen::getImplementationName()
     120             :     throw (css::uno::RuntimeException, std::exception)
     121             : {
     122           0 :     return UnxSplash_getImplementationName();
     123             : }
     124             : 
     125           0 : sal_Bool UnxSplashScreen::supportsService(OUString const & ServiceName)
     126             :     throw (css::uno::RuntimeException, std::exception)
     127             : {
     128           0 :     return cppu::supportsService(this, ServiceName);
     129             : }
     130             : 
     131           0 : css::uno::Sequence<OUString> UnxSplashScreen::getSupportedServiceNames()
     132             :     throw (css::uno::RuntimeException, std::exception)
     133             : {
     134           0 :     return UnxSplash_getSupportedServiceNames();
     135             : }
     136             : 
     137             : }
     138             : 
     139             : using namespace desktop;
     140             : 
     141             : // get service instance...
     142           0 : static uno::Reference< uno::XInterface > m_xINSTANCE;
     143             : 
     144           0 : uno::Reference< uno::XInterface > UnxSplash_createInstance(const uno::Reference< uno::XComponentContext > & xCtx ) throw( uno::Exception )
     145             : {
     146           0 :     static osl::Mutex m_aMutex;
     147           0 :     if ( !m_xINSTANCE.is() )
     148             :     {
     149           0 :         osl::MutexGuard guard( m_aMutex );
     150           0 :         if ( !m_xINSTANCE.is() )
     151           0 :             m_xINSTANCE = static_cast<cppu::OWeakObject*>(new UnxSplashScreen( xCtx ));
     152             :     }
     153             : 
     154           0 :     return m_xINSTANCE;
     155             : }
     156             : 
     157           0 : OUString UnxSplash_getImplementationName()
     158             : {
     159           0 :     return OUString( "com.sun.star.office.comp.PipeSplashScreen" );
     160             : }
     161             : 
     162           0 : uno::Sequence< OUString > UnxSplash_getSupportedServiceNames() throw()
     163             : {
     164           0 :     const OUString aServiceName( "com.sun.star.office.PipeSplashScreen" );
     165           0 :     const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
     166           0 :     return aSeq;
     167           0 : }
     168             : 
     169             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11