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

Generated by: LCOV version 1.10