LCOV - code coverage report
Current view: top level - libreoffice/ucbhelper/source/provider - std_outputstream.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 40 0.0 %
Date: 2012-12-27 Functions: 0 9 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             : 
      10             : #include "ucbhelper/std_outputstream.hxx"
      11             : 
      12             : using namespace std;
      13             : using namespace com::sun::star;
      14             : 
      15             : namespace ucbhelper
      16             : {
      17           0 :     StdOutputStream::StdOutputStream( boost::shared_ptr< ostream > pStream ) :
      18           0 :         m_pStream( pStream )
      19             :     {
      20           0 :     }
      21             : 
      22           0 :     StdOutputStream::~StdOutputStream()
      23             :     {
      24           0 :         if ( m_pStream.get( ) )
      25           0 :             m_pStream->setstate( ios::eofbit );
      26           0 :     }
      27             : 
      28           0 :     uno::Any SAL_CALL StdOutputStream::queryInterface( const uno::Type& rType ) throw ( uno::RuntimeException )
      29             :     {
      30           0 :         uno::Any aRet = ::cppu::queryInterface( rType, ( static_cast< XOutputStream* >( this ) ) );
      31             : 
      32           0 :         return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
      33             :     }
      34             : 
      35           0 :     void SAL_CALL StdOutputStream::acquire( ) throw( )
      36             :     {
      37           0 :         OWeakObject::acquire();
      38           0 :     }
      39             : 
      40           0 :     void SAL_CALL StdOutputStream::release( ) throw( )
      41             :     {
      42           0 :         OWeakObject::release();
      43           0 :     }
      44             : 
      45           0 :     void SAL_CALL StdOutputStream::writeBytes ( const uno::Sequence< sal_Int8 >& aData )
      46             :         throw ( io::NotConnectedException, io::BufferSizeExceededException,
      47             :                 io::IOException, uno::RuntimeException )
      48             :     {
      49           0 :         osl::MutexGuard aGuard( m_aMutex );
      50             : 
      51           0 :         if ( !m_pStream.get() )
      52           0 :             throw io::IOException( );
      53             : 
      54             :         try
      55             :         {
      56           0 :             m_pStream->write( reinterpret_cast< const char* >( aData.getConstArray( ) ), aData.getLength( ) );
      57             :         }
      58           0 :         catch ( const ios_base::failure& e )
      59             :         {
      60             :             SAL_INFO( "ucbhelper", "Exception caught when calling write: " << e.what() );
      61           0 :             throw io::IOException( );
      62           0 :         }
      63           0 :     }
      64             : 
      65           0 :     void SAL_CALL StdOutputStream::flush ( )
      66             :         throw ( io::NotConnectedException, io::BufferSizeExceededException,
      67             :                 io::IOException, uno::RuntimeException )
      68             :     {
      69           0 :         osl::MutexGuard aGuard( m_aMutex );
      70             : 
      71           0 :         if ( !m_pStream.get() )
      72           0 :             throw io::IOException( );
      73             : 
      74             :         try
      75             :         {
      76           0 :             m_pStream->flush( );
      77             :         }
      78           0 :         catch ( const ios_base::failure& e )
      79             :         {
      80             :             SAL_INFO( "ucbhelper", "Exception caught when calling flush: " << e.what() );
      81           0 :             throw io::IOException( );
      82           0 :         }
      83           0 :     }
      84             : 
      85           0 :     void SAL_CALL StdOutputStream::closeOutput ( )
      86             :         throw ( io::NotConnectedException, io::BufferSizeExceededException,
      87             :                 io::IOException, uno::RuntimeException )
      88             :     {
      89           0 :         osl::MutexGuard aGuard( m_aMutex );
      90             : 
      91           0 :         if ( !m_pStream.get() )
      92           0 :             throw io::IOException( );
      93             : 
      94           0 :         m_pStream->setstate( ios_base::eofbit );
      95           0 :     }
      96             : }
      97             : 
      98             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10