bump product version to 7.2.5.1
[LibreOffice.git] / ucb / source / ucp / gio / gio_outputstream.cxx
blob1f334f4df8d8a9a2eaa25c5d0c1f4e75373407ec
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <com/sun/star/io/NotConnectedException.hpp>
23 #include <cppuhelper/queryinterface.hxx>
25 #include "gio_outputstream.hxx"
26 #include "gio_content.hxx"
28 namespace gio
31 OutputStream::OutputStream(GFileOutputStream *pStream) : Seekable(G_SEEKABLE(pStream)), mpStream(pStream)
33 if (!mpStream)
34 throw css::io::NotConnectedException();
37 OutputStream::~OutputStream()
39 closeOutput();
42 void SAL_CALL OutputStream::writeBytes( const css::uno::Sequence< sal_Int8 >& rData )
44 if (!mpStream)
45 throw css::io::NotConnectedException();
47 GError *pError=nullptr;
48 if (!g_output_stream_write_all(G_OUTPUT_STREAM(mpStream), rData.getConstArray(), rData.getLength(), nullptr, nullptr, &pError))
49 convertToIOException(pError, static_cast< cppu::OWeakObject * >(this));
52 void SAL_CALL OutputStream::flush()
54 if (!mpStream)
55 throw css::io::NotConnectedException();
57 GError *pError=nullptr;
58 if (!g_output_stream_flush(G_OUTPUT_STREAM(mpStream), nullptr, &pError))
59 convertToIOException(pError, static_cast< cppu::OWeakObject * >(this));
62 void SAL_CALL OutputStream::closeOutput()
64 if (mpStream)
65 g_output_stream_close(G_OUTPUT_STREAM(mpStream), nullptr, nullptr);
68 css::uno::Any OutputStream::queryInterface( const css::uno::Type &type )
70 css::uno::Any aRet = ::cppu::queryInterface ( type,
71 static_cast< XOutputStream * >( this ) );
73 return aRet.hasValue() ? aRet : Seekable::queryInterface( type );
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */