1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SELFTERMINATEFILESTREAM_HXX_ 25 #define _SELFTERMINATEFILESTREAM_HXX_ 26 27 #include <com/sun/star/io/XInputStream.hpp> 28 #include <com/sun/star/io/XSeekable.hpp> 29 #include <com/sun/star/ucb/XSimpleFileAccess.hpp> 30 #include <cppuhelper/implbase2.hxx> 31 32 struct OWriteStream_Impl; 33 34 class OSelfTerminateFileStream : public cppu::WeakImplHelper2< ::com::sun::star::io::XInputStream, 35 ::com::sun::star::io::XSeekable > 36 { 37 protected: 38 ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > m_xFileAccess; 39 40 ::rtl::OUString m_aURL; 41 42 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > m_xInputStream; 43 ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable > m_xSeekable; 44 45 public: 46 OSelfTerminateFileStream( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory, const ::rtl::OUString& aURL ); 47 48 virtual ~OSelfTerminateFileStream(); 49 50 void CloseStreamDeleteFile(); 51 52 // XInputStream 53 virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) 54 throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 55 virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) 56 throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 57 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) 58 throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 59 virtual sal_Int32 SAL_CALL available() 60 throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 61 virtual void SAL_CALL closeInput() 62 throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 63 64 //XSeekable 65 virtual void SAL_CALL seek( sal_Int64 location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 66 virtual sal_Int64 SAL_CALL getPosition() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 67 virtual sal_Int64 SAL_CALL getLength() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 68 69 }; 70 71 #endif 72 73