1*f319bb99SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f319bb99SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f319bb99SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f319bb99SAndrew Rist * distributed with this work for additional information 6*f319bb99SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f319bb99SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f319bb99SAndrew Rist * "License"); you may not use this file except in compliance 9*f319bb99SAndrew Rist * with the License. You may obtain a copy of the License at 10*f319bb99SAndrew Rist * 11*f319bb99SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f319bb99SAndrew Rist * 13*f319bb99SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f319bb99SAndrew Rist * software distributed under the License is distributed on an 15*f319bb99SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f319bb99SAndrew Rist * KIND, either express or implied. See the License for the 17*f319bb99SAndrew Rist * specific language governing permissions and limitations 18*f319bb99SAndrew Rist * under the License. 19*f319bb99SAndrew Rist * 20*f319bb99SAndrew Rist *************************************************************/ 21*f319bb99SAndrew Rist 22*f319bb99SAndrew Rist 23cdf0e10cSrcweir #ifndef _XUNBUFFERED_STREAM_HXX 24cdf0e10cSrcweir #define _XUNBUFFERED_STREAM_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 27cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp> 28cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp> 29cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 30cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 31cdf0e10cSrcweir #include <com/sun/star/xml/crypto/XCipherContext.hpp> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 34cdf0e10cSrcweir #include <rtl/ref.hxx> 35cdf0e10cSrcweir #include <Inflater.hxx> 36cdf0e10cSrcweir #include <ZipEntry.hxx> 37cdf0e10cSrcweir #include <CRC32.hxx> 38cdf0e10cSrcweir #include <mutexholder.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #define UNBUFF_STREAM_DATA 0 41cdf0e10cSrcweir #define UNBUFF_STREAM_RAW 1 42cdf0e10cSrcweir #define UNBUFF_STREAM_WRAPPEDRAW 2 43cdf0e10cSrcweir 44cdf0e10cSrcweir class EncryptionData; 45cdf0e10cSrcweir class XUnbufferedStream : public cppu::WeakImplHelper1 46cdf0e10cSrcweir < 47cdf0e10cSrcweir com::sun::star::io::XInputStream 48cdf0e10cSrcweir > 49cdf0e10cSrcweir { 50cdf0e10cSrcweir protected: 51cdf0e10cSrcweir SotMutexHolderRef maMutexHolder; 52cdf0e10cSrcweir 53cdf0e10cSrcweir com::sun::star::uno::Reference < com::sun::star::io::XInputStream > mxZipStream; 54cdf0e10cSrcweir com::sun::star::uno::Reference < com::sun::star::io::XSeekable > mxZipSeek; 55cdf0e10cSrcweir com::sun::star::uno::Sequence < sal_Int8 > maCompBuffer, maHeader; 56cdf0e10cSrcweir ZipEntry maEntry; 57cdf0e10cSrcweir ::rtl::Reference< EncryptionData > mxData; 58cdf0e10cSrcweir sal_Int32 mnBlockSize; 59cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XCipherContext > m_xCipherContext; 60cdf0e10cSrcweir Inflater maInflater; 61cdf0e10cSrcweir sal_Bool mbRawStream, mbWrappedRaw, mbFinished; 62cdf0e10cSrcweir sal_Int16 mnHeaderToRead; 63cdf0e10cSrcweir sal_Int64 mnZipCurrent, mnZipEnd, mnZipSize, mnMyCurrent; 64cdf0e10cSrcweir CRC32 maCRC; 65cdf0e10cSrcweir sal_Bool mbCheckCRC; 66cdf0e10cSrcweir 67cdf0e10cSrcweir public: 68cdf0e10cSrcweir XUnbufferedStream( 69cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, 70cdf0e10cSrcweir SotMutexHolderRef aMutexHolder, 71cdf0e10cSrcweir ZipEntry & rEntry, 72cdf0e10cSrcweir com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewZipStream, 73cdf0e10cSrcweir const ::rtl::Reference< EncryptionData >& rData, 74cdf0e10cSrcweir sal_Int8 nStreamMode, 75cdf0e10cSrcweir sal_Bool bIsEncrypted, 76cdf0e10cSrcweir const ::rtl::OUString& aMediaType, 77cdf0e10cSrcweir sal_Bool bRecoveryMode ); 78cdf0e10cSrcweir 79cdf0e10cSrcweir // allows to read package raw stream 80cdf0e10cSrcweir XUnbufferedStream( 81cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, 82cdf0e10cSrcweir const com::sun::star::uno::Reference < com::sun::star::io::XInputStream >& xRawStream, 83cdf0e10cSrcweir const ::rtl::Reference< EncryptionData >& rData ); 84cdf0e10cSrcweir 85cdf0e10cSrcweir 86cdf0e10cSrcweir virtual ~XUnbufferedStream(); 87cdf0e10cSrcweir 88cdf0e10cSrcweir // XInputStream 89cdf0e10cSrcweir virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) 90cdf0e10cSrcweir throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 91cdf0e10cSrcweir virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) 92cdf0e10cSrcweir throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 93cdf0e10cSrcweir virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) 94cdf0e10cSrcweir throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 95cdf0e10cSrcweir virtual sal_Int32 SAL_CALL available( ) 96cdf0e10cSrcweir throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 97cdf0e10cSrcweir virtual void SAL_CALL closeInput( ) 98cdf0e10cSrcweir throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 99cdf0e10cSrcweir // XSeekable 100cdf0e10cSrcweir /* 101cdf0e10cSrcweir virtual void SAL_CALL seek( sal_Int64 location ) 102cdf0e10cSrcweir throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 103cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getPosition( ) 104cdf0e10cSrcweir throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 105cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getLength( ) 106cdf0e10cSrcweir throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 107cdf0e10cSrcweir */ 108cdf0e10cSrcweir }; 109cdf0e10cSrcweir #endif 110