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 <sal/config.h>
12 #include <com/sun/star/io/IOException.hpp>
13 #include <sal/log.hxx>
14 #include <cppuhelper/queryinterface.hxx>
16 #include "std_outputstream.hxx"
19 using namespace com::sun::star
;
23 StdOutputStream::StdOutputStream( boost::shared_ptr
< ostream
> const & pStream
) :
28 StdOutputStream::~StdOutputStream()
31 m_pStream
->setstate( ios::eofbit
);
34 uno::Any SAL_CALL
StdOutputStream::queryInterface( const uno::Type
& rType
)
36 uno::Any aRet
= ::cppu::queryInterface( rType
, static_cast< XOutputStream
* >( this ) );
38 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
41 void SAL_CALL
StdOutputStream::acquire( ) noexcept
43 OWeakObject::acquire();
46 void SAL_CALL
StdOutputStream::release( ) noexcept
48 OWeakObject::release();
51 void SAL_CALL
StdOutputStream::writeBytes ( const uno::Sequence
< sal_Int8
>& aData
)
53 osl::MutexGuard
aGuard( m_aMutex
);
56 throw io::IOException( );
60 m_pStream
->write( reinterpret_cast< const char* >( aData
.getConstArray( ) ), aData
.getLength( ) );
62 catch ( const ios_base::failure
& e
)
64 SAL_INFO( "ucb.ucp.cmis", "Exception caught when calling write: " << e
.what() );
65 throw io::IOException( );
69 void SAL_CALL
StdOutputStream::flush ( )
71 osl::MutexGuard
aGuard( m_aMutex
);
74 throw io::IOException( );
80 catch ( const ios_base::failure
& e
)
82 SAL_INFO( "ucb.ucp.cmis", "Exception caught when calling flush: " << e
.what() );
83 throw io::IOException( );
87 void SAL_CALL
StdOutputStream::closeOutput ( )
89 osl::MutexGuard
aGuard( m_aMutex
);
92 throw io::IOException( );
94 m_pStream
->setstate( ios_base::eofbit
);
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */