bump product version to 7.2.5.1
[LibreOffice.git] / ucb / source / ucp / cmis / std_outputstream.cxx
blobdeb70fb65f95c00136e50bc227bd1b10c745f35a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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"
18 using namespace std;
19 using namespace com::sun::star;
21 namespace cmis
23 StdOutputStream::StdOutputStream( boost::shared_ptr< ostream > const & pStream ) :
24 m_pStream( pStream )
28 StdOutputStream::~StdOutputStream()
30 if (m_pStream)
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 );
55 if (!m_pStream)
56 throw io::IOException( );
58 try
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 );
73 if (!m_pStream)
74 throw io::IOException( );
76 try
78 m_pStream->flush( );
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 );
91 if (!m_pStream)
92 throw io::IOException( );
94 m_pStream->setstate( ios_base::eofbit );
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */