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 #ifndef _XUNBUFFERED_STREAM_HXX 28 #define _XUNBUFFERED_STREAM_HXX 29 30 #include <com/sun/star/io/XOutputStream.hpp> 31 #include <com/sun/star/lang/IllegalArgumentException.hpp> 32 #include <com/sun/star/io/XSeekable.hpp> 33 #include <com/sun/star/io/XInputStream.hpp> 34 #include <com/sun/star/io/XOutputStream.hpp> 35 #include <com/sun/star/xml/crypto/XCipherContext.hpp> 36 37 #include <cppuhelper/implbase1.hxx> 38 #include <rtl/ref.hxx> 39 #include <Inflater.hxx> 40 #include <ZipEntry.hxx> 41 #include <CRC32.hxx> 42 #include <mutexholder.hxx> 43 44 #define UNBUFF_STREAM_DATA 0 45 #define UNBUFF_STREAM_RAW 1 46 #define UNBUFF_STREAM_WRAPPEDRAW 2 47 48 class EncryptionData; 49 class XUnbufferedStream : public cppu::WeakImplHelper1 50 < 51 com::sun::star::io::XInputStream 52 > 53 { 54 protected: 55 SotMutexHolderRef maMutexHolder; 56 57 com::sun::star::uno::Reference < com::sun::star::io::XInputStream > mxZipStream; 58 com::sun::star::uno::Reference < com::sun::star::io::XSeekable > mxZipSeek; 59 com::sun::star::uno::Sequence < sal_Int8 > maCompBuffer, maHeader; 60 ZipEntry maEntry; 61 ::rtl::Reference< EncryptionData > mxData; 62 sal_Int32 mnBlockSize; 63 ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XCipherContext > m_xCipherContext; 64 Inflater maInflater; 65 sal_Bool mbRawStream, mbWrappedRaw, mbFinished; 66 sal_Int16 mnHeaderToRead; 67 sal_Int64 mnZipCurrent, mnZipEnd, mnZipSize, mnMyCurrent; 68 CRC32 maCRC; 69 sal_Bool mbCheckCRC; 70 71 public: 72 XUnbufferedStream( 73 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, 74 SotMutexHolderRef aMutexHolder, 75 ZipEntry & rEntry, 76 com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewZipStream, 77 const ::rtl::Reference< EncryptionData >& rData, 78 sal_Int8 nStreamMode, 79 sal_Bool bIsEncrypted, 80 const ::rtl::OUString& aMediaType, 81 sal_Bool bRecoveryMode ); 82 83 // allows to read package raw stream 84 XUnbufferedStream( 85 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, 86 const com::sun::star::uno::Reference < com::sun::star::io::XInputStream >& xRawStream, 87 const ::rtl::Reference< EncryptionData >& rData ); 88 89 90 virtual ~XUnbufferedStream(); 91 92 // XInputStream 93 virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) 94 throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 95 virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) 96 throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 97 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) 98 throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 99 virtual sal_Int32 SAL_CALL available( ) 100 throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 101 virtual void SAL_CALL closeInput( ) 102 throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 103 // XSeekable 104 /* 105 virtual void SAL_CALL seek( sal_Int64 location ) 106 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 107 virtual sal_Int64 SAL_CALL getPosition( ) 108 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 109 virtual sal_Int64 SAL_CALL getLength( ) 110 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 111 */ 112 }; 113 #endif 114