1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <cppuhelper/weak.hxx> 29 #include <osl/mutex.hxx> 30 #include <com/sun/star/io/XInputStream.hpp> 31 #include <com/sun/star/io/XSeekable.hpp> 32 33 34 namespace chelp { 35 36 class BufferedInputStream 37 : public cppu::OWeakObject, 38 public com::sun::star::io::XInputStream, 39 public com::sun::star::io::XSeekable 40 { 41 private: 42 43 sal_Int32 m_nBufferLocation; 44 sal_Int32 m_nBufferSize; 45 sal_Int8 *m_pBuffer; 46 osl::Mutex m_aMutex; 47 48 public: 49 50 BufferedInputStream( 51 const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream); 52 53 ~BufferedInputStream(); 54 55 virtual com::sun::star::uno::Any SAL_CALL 56 queryInterface( const com::sun::star::uno::Type& rType ) 57 throw( com::sun::star::uno::RuntimeException ); 58 59 virtual void SAL_CALL acquire( void ) throw(); 60 61 virtual void SAL_CALL release( void ) throw(); 62 63 64 virtual sal_Int32 SAL_CALL readBytes( com::sun::star::uno::Sequence< sal_Int8 >& aData, 65 sal_Int32 nBytesToRead ) 66 throw( com::sun::star::io::NotConnectedException, 67 com::sun::star::io::BufferSizeExceededException, 68 com::sun::star::io::IOException, 69 com::sun::star::uno::RuntimeException ); 70 71 virtual sal_Int32 SAL_CALL readSomeBytes( com::sun::star::uno::Sequence< sal_Int8 >& aData, 72 sal_Int32 nMaxBytesToRead ) 73 throw( com::sun::star::io::NotConnectedException, 74 com::sun::star::io::BufferSizeExceededException, 75 com::sun::star::io::IOException, 76 com::sun::star::uno::RuntimeException ); 77 78 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) 79 throw( com::sun::star::io::NotConnectedException, 80 com::sun::star::io::BufferSizeExceededException, 81 com::sun::star::io::IOException, 82 com::sun::star::uno::RuntimeException ); 83 84 virtual sal_Int32 SAL_CALL available( void ) 85 throw( com::sun::star::io::NotConnectedException, 86 com::sun::star::io::IOException, 87 com::sun::star::uno::RuntimeException ); 88 89 virtual void SAL_CALL closeInput( void ) 90 throw( com::sun::star::io::NotConnectedException, 91 com::sun::star::io::IOException, 92 com::sun::star::uno::RuntimeException ); 93 94 virtual void SAL_CALL seek( sal_Int64 location ) 95 throw( com::sun::star::lang::IllegalArgumentException, 96 com::sun::star::io::IOException, 97 com::sun::star::uno::RuntimeException ); 98 99 virtual sal_Int64 SAL_CALL getPosition( void ) 100 throw( com::sun::star::io::IOException, 101 com::sun::star::uno::RuntimeException ); 102 103 virtual sal_Int64 SAL_CALL getLength( void ) 104 throw( com::sun::star::io::IOException, 105 com::sun::star::uno::RuntimeException ); 106 }; 107 108 109 extern com::sun::star::uno::Reference<com::sun::star::io::XInputStream> 110 turnToSeekable( 111 const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream); 112 113 } 114