merge the formfield patch from ooo-build
[ooovba.git] / ucb / source / ucp / gio / gio_outputstream.cxx
blob3bb20f5db5a23455eb634e3dacb4b9de36531da5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: gio_outputstream.cxx,v $
10 * $Revision: 1.2 $
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>
34 #include <string.h>
36 #include "gio_outputstream.hxx"
37 #include "gio_content.hxx"
39 using namespace com::sun::star;
41 namespace gio
44 OutputStream::OutputStream(GFileOutputStream *pStream) : Seekable(G_SEEKABLE(pStream)), mpStream(pStream)
46 if (!mpStream)
47 throw io::NotConnectedException();
50 OutputStream::~OutputStream( void )
52 closeOutput();
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)
59 if (!mpStream)
60 throw io::NotConnectedException();
62 GError *pError=NULL;
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 )
71 if (!mpStream)
72 throw io::NotConnectedException();
74 GError *pError=NULL;
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 )
83 if (mpStream)
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 );