1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: gio_outputstream.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <rtl/memory.h>
32 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
33 #include <ucbhelper/cancelcommandexecution.hxx>
36 #include "gio_outputstream.hxx"
37 #include "gio_content.hxx"
39 using namespace com::sun::star
;
44 OutputStream::OutputStream(GFileOutputStream
*pStream
) : Seekable(G_SEEKABLE(pStream
)), mpStream(pStream
)
47 throw io::NotConnectedException();
50 OutputStream::~OutputStream( void )
55 void SAL_CALL
OutputStream::writeBytes( const com::sun::star::uno::Sequence
< sal_Int8
>& rData
)
56 throw( io::NotConnectedException
, io::BufferSizeExceededException
,
57 io::IOException
, uno::RuntimeException
)
60 throw io::NotConnectedException();
63 if (!g_output_stream_write_all(G_OUTPUT_STREAM(mpStream
), rData
.getConstArray(), rData
.getLength(), NULL
, NULL
, &pError
))
64 convertToException(pError
, static_cast< cppu::OWeakObject
* >(this));
67 void SAL_CALL
OutputStream::flush( void )
68 throw( io::NotConnectedException
, io::BufferSizeExceededException
,
69 io::IOException
, uno::RuntimeException
)
72 throw io::NotConnectedException();
75 if (!g_output_stream_flush(G_OUTPUT_STREAM(mpStream
), NULL
, &pError
))
76 convertToException(pError
, static_cast< cppu::OWeakObject
* >(this));
79 void SAL_CALL
OutputStream::closeOutput( void )
80 throw( io::NotConnectedException
, io::IOException
,
81 uno::RuntimeException
)
84 g_output_stream_close(G_OUTPUT_STREAM(mpStream
), NULL
, NULL
);
87 uno::Any
OutputStream::queryInterface( const uno::Type
&type
) throw( uno::RuntimeException
)
89 uno::Any aRet
= ::cppu::queryInterface ( type
,
90 static_cast< XOutputStream
* >( this ) );
92 return aRet
.hasValue() ? aRet
: Seekable::queryInterface( type
);