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

Generated by: LCOV version 1.10