1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #include "ucbhelper/std_outputstream.hxx"
13 using namespace com::sun::star
;
17 StdOutputStream::StdOutputStream( boost::shared_ptr
< ostream
> pStream
) :
22 StdOutputStream::~StdOutputStream()
24 if ( m_pStream
.get( ) )
25 m_pStream
->setstate( ios::eofbit
);
28 uno::Any SAL_CALL
StdOutputStream::queryInterface( const uno::Type
& rType
) throw ( uno::RuntimeException
)
30 uno::Any aRet
= ::cppu::queryInterface( rType
, ( static_cast< XOutputStream
* >( this ) ) );
32 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
35 void SAL_CALL
StdOutputStream::acquire( ) throw( )
37 OWeakObject::acquire();
40 void SAL_CALL
StdOutputStream::release( ) throw( )
42 OWeakObject::release();
45 void SAL_CALL
StdOutputStream::writeBytes ( const uno::Sequence
< sal_Int8
>& aData
)
46 throw ( io::NotConnectedException
, io::BufferSizeExceededException
,
47 io::IOException
, uno::RuntimeException
)
49 osl::MutexGuard
aGuard( m_aMutex
);
51 if ( !m_pStream
.get() )
52 throw io::IOException( );
56 m_pStream
->write( reinterpret_cast< const char* >( aData
.getConstArray( ) ), aData
.getLength( ) );
58 catch ( const ios_base::failure
& e
)
60 SAL_INFO( "ucbhelper", "Exception caught when calling write: " << e
.what() );
61 throw io::IOException( );
65 void SAL_CALL
StdOutputStream::flush ( )
66 throw ( io::NotConnectedException
, io::BufferSizeExceededException
,
67 io::IOException
, uno::RuntimeException
)
69 osl::MutexGuard
aGuard( m_aMutex
);
71 if ( !m_pStream
.get() )
72 throw io::IOException( );
78 catch ( const ios_base::failure
& e
)
80 SAL_INFO( "ucbhelper", "Exception caught when calling flush: " << e
.what() );
81 throw io::IOException( );
85 void SAL_CALL
StdOutputStream::closeOutput ( )
86 throw ( io::NotConnectedException
, io::BufferSizeExceededException
,
87 io::IOException
, uno::RuntimeException
)
89 osl::MutexGuard
aGuard( m_aMutex
);
91 if ( !m_pStream
.get() )
92 throw io::IOException( );
94 m_pStream
->setstate( ios_base::eofbit
);
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */