1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_package.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/packages/zip/ZipConstants.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/packages/zip/ZipIOException.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/CipherID.hpp> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <XUnbufferedStream.hxx> 36*cdf0e10cSrcweir #include <EncryptionData.hxx> 37*cdf0e10cSrcweir #include <PackageConstants.hxx> 38*cdf0e10cSrcweir #include <ZipFile.hxx> 39*cdf0e10cSrcweir #include <EncryptedDataHeader.hxx> 40*cdf0e10cSrcweir #include <algorithm> 41*cdf0e10cSrcweir #include <string.h> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <osl/mutex.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #if 0 46*cdf0e10cSrcweir // for debugging purposes here 47*cdf0e10cSrcweir #include <com/sun/star/ucb/XSimpleFileAccess.hpp> 48*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 49*cdf0e10cSrcweir using namespace ::com::sun::star; 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir using namespace ::com::sun::star; 53*cdf0e10cSrcweir using namespace com::sun::star::packages::zip::ZipConstants; 54*cdf0e10cSrcweir using namespace com::sun::star::io; 55*cdf0e10cSrcweir using namespace com::sun::star::uno; 56*cdf0e10cSrcweir using com::sun::star::lang::IllegalArgumentException; 57*cdf0e10cSrcweir using com::sun::star::packages::zip::ZipIOException; 58*cdf0e10cSrcweir using ::rtl::OUString; 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir XUnbufferedStream::XUnbufferedStream( 61*cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& xFactory, 62*cdf0e10cSrcweir SotMutexHolderRef aMutexHolder, 63*cdf0e10cSrcweir ZipEntry & rEntry, 64*cdf0e10cSrcweir Reference < XInputStream > xNewZipStream, 65*cdf0e10cSrcweir const ::rtl::Reference< EncryptionData >& rData, 66*cdf0e10cSrcweir sal_Int8 nStreamMode, 67*cdf0e10cSrcweir sal_Bool bIsEncrypted, 68*cdf0e10cSrcweir const ::rtl::OUString& aMediaType, 69*cdf0e10cSrcweir sal_Bool bRecoveryMode ) 70*cdf0e10cSrcweir : maMutexHolder( aMutexHolder.Is() ? aMutexHolder : SotMutexHolderRef( new SotMutexHolder ) ) 71*cdf0e10cSrcweir , mxZipStream ( xNewZipStream ) 72*cdf0e10cSrcweir , mxZipSeek ( xNewZipStream, UNO_QUERY ) 73*cdf0e10cSrcweir , maEntry ( rEntry ) 74*cdf0e10cSrcweir , mxData ( rData ) 75*cdf0e10cSrcweir , mnBlockSize( 1 ) 76*cdf0e10cSrcweir , maInflater ( sal_True ) 77*cdf0e10cSrcweir , mbRawStream ( nStreamMode == UNBUFF_STREAM_RAW || nStreamMode == UNBUFF_STREAM_WRAPPEDRAW ) 78*cdf0e10cSrcweir , mbWrappedRaw ( nStreamMode == UNBUFF_STREAM_WRAPPEDRAW ) 79*cdf0e10cSrcweir , mbFinished ( sal_False ) 80*cdf0e10cSrcweir , mnHeaderToRead ( 0 ) 81*cdf0e10cSrcweir , mnZipCurrent ( 0 ) 82*cdf0e10cSrcweir , mnZipEnd ( 0 ) 83*cdf0e10cSrcweir , mnZipSize ( 0 ) 84*cdf0e10cSrcweir , mnMyCurrent ( 0 ) 85*cdf0e10cSrcweir , mbCheckCRC( !bRecoveryMode ) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir mnZipCurrent = maEntry.nOffset; 88*cdf0e10cSrcweir if ( mbRawStream ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir mnZipSize = maEntry.nMethod == DEFLATED ? maEntry.nCompressedSize : maEntry.nSize; 91*cdf0e10cSrcweir mnZipEnd = maEntry.nOffset + mnZipSize; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir else 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir mnZipSize = maEntry.nSize; 96*cdf0e10cSrcweir mnZipEnd = maEntry.nMethod == DEFLATED ? maEntry.nOffset + maEntry.nCompressedSize : maEntry.nOffset + maEntry.nSize; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir sal_Bool bHaveEncryptData = ( rData.is() && rData->m_aSalt.getLength() && rData->m_aInitVector.getLength() && rData->m_nIterationCount != 0 ) ? sal_True : sal_False; 99*cdf0e10cSrcweir sal_Bool bMustDecrypt = ( nStreamMode == UNBUFF_STREAM_DATA && bHaveEncryptData && bIsEncrypted ) ? sal_True : sal_False; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir if ( bMustDecrypt ) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir m_xCipherContext = ZipFile::StaticGetCipher( xFactory, rData, false ); 104*cdf0e10cSrcweir mnBlockSize = ( rData->m_nEncAlg == xml::crypto::CipherID::AES_CBC_W3C_PADDING ? 16 : 1 ); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir if ( bHaveEncryptData && mbWrappedRaw && bIsEncrypted ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir // if we have the data needed to decrypt it, but didn't want it decrypted (or 110*cdf0e10cSrcweir // we couldn't decrypt it due to wrong password), then we prepend this 111*cdf0e10cSrcweir // data to the stream 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir // Make a buffer big enough to hold both the header and the data itself 114*cdf0e10cSrcweir maHeader.realloc ( n_ConstHeaderSize + 115*cdf0e10cSrcweir rData->m_aInitVector.getLength() + 116*cdf0e10cSrcweir rData->m_aSalt.getLength() + 117*cdf0e10cSrcweir rData->m_aDigest.getLength() + 118*cdf0e10cSrcweir aMediaType.getLength() * sizeof( sal_Unicode ) ); 119*cdf0e10cSrcweir sal_Int8 * pHeader = maHeader.getArray(); 120*cdf0e10cSrcweir ZipFile::StaticFillHeader( rData, rEntry.nSize, aMediaType, pHeader ); 121*cdf0e10cSrcweir mnHeaderToRead = static_cast < sal_Int16 > ( maHeader.getLength() ); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // allows to read package raw stream 126*cdf0e10cSrcweir XUnbufferedStream::XUnbufferedStream( 127*cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& /*xFactory*/, 128*cdf0e10cSrcweir const Reference < XInputStream >& xRawStream, 129*cdf0e10cSrcweir const ::rtl::Reference< EncryptionData >& rData ) 130*cdf0e10cSrcweir : maMutexHolder( new SotMutexHolder ) 131*cdf0e10cSrcweir , mxZipStream ( xRawStream ) 132*cdf0e10cSrcweir , mxZipSeek ( xRawStream, UNO_QUERY ) 133*cdf0e10cSrcweir , mxData ( rData ) 134*cdf0e10cSrcweir , mnBlockSize( 1 ) 135*cdf0e10cSrcweir , maInflater ( sal_True ) 136*cdf0e10cSrcweir , mbRawStream ( sal_False ) 137*cdf0e10cSrcweir , mbWrappedRaw ( sal_False ) 138*cdf0e10cSrcweir , mbFinished ( sal_False ) 139*cdf0e10cSrcweir , mnHeaderToRead ( 0 ) 140*cdf0e10cSrcweir , mnZipCurrent ( 0 ) 141*cdf0e10cSrcweir , mnZipEnd ( 0 ) 142*cdf0e10cSrcweir , mnZipSize ( 0 ) 143*cdf0e10cSrcweir , mnMyCurrent ( 0 ) 144*cdf0e10cSrcweir , mbCheckCRC( sal_False ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir // for this scenario maEntry is not set !!! 147*cdf0e10cSrcweir OSL_ENSURE( mxZipSeek.is(), "The stream must be seekable!\n" ); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir // skip raw header, it must be already parsed to rData 150*cdf0e10cSrcweir mnZipCurrent = n_ConstHeaderSize + rData->m_aInitVector.getLength() + 151*cdf0e10cSrcweir rData->m_aSalt.getLength() + rData->m_aDigest.getLength(); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir try { 154*cdf0e10cSrcweir if ( mxZipSeek.is() ) 155*cdf0e10cSrcweir mnZipSize = mxZipSeek->getLength(); 156*cdf0e10cSrcweir } catch( Exception& ) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir // in case of problem the size will stay set to 0 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir mnZipEnd = mnZipCurrent + mnZipSize; 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir // the raw data will not be decrypted, no need for the cipher 164*cdf0e10cSrcweir // m_xCipherContext = ZipFile::StaticGetCipher( xFactory, rData, false ); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir XUnbufferedStream::~XUnbufferedStream() 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) 172*cdf0e10cSrcweir throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutexHolder->GetMutex() ); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir sal_Int32 nRequestedBytes = nBytesToRead; 177*cdf0e10cSrcweir OSL_ENSURE( !mnHeaderToRead || mbWrappedRaw, "Only encrypted raw stream can be provided with header!" ); 178*cdf0e10cSrcweir if ( mnMyCurrent + nRequestedBytes > mnZipSize + maHeader.getLength() ) 179*cdf0e10cSrcweir nRequestedBytes = static_cast < sal_Int32 > ( mnZipSize + maHeader.getLength() - mnMyCurrent ); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir sal_Int32 nRead = 0, nLastRead = 0, nTotal = 0; 182*cdf0e10cSrcweir aData.realloc ( nRequestedBytes ); 183*cdf0e10cSrcweir if ( nRequestedBytes ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir if ( mbRawStream ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir sal_Int64 nDiff = mnZipEnd - mnZipCurrent; 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir if ( mbWrappedRaw && mnHeaderToRead ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir sal_Int16 nHeadRead = static_cast< sal_Int16 >(( nRequestedBytes > mnHeaderToRead ? 192*cdf0e10cSrcweir mnHeaderToRead : nRequestedBytes )); 193*cdf0e10cSrcweir rtl_copyMemory ( aData.getArray(), maHeader.getConstArray() + maHeader.getLength() - mnHeaderToRead, nHeadRead ); 194*cdf0e10cSrcweir mnHeaderToRead = mnHeaderToRead - nHeadRead; 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir if ( nHeadRead < nRequestedBytes ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir sal_Int32 nToRead = nRequestedBytes - nHeadRead; 199*cdf0e10cSrcweir nToRead = ( nDiff < nToRead ) ? sal::static_int_cast< sal_Int32 >( nDiff ) : nToRead; 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir Sequence< sal_Int8 > aPureData( nToRead ); 202*cdf0e10cSrcweir mxZipSeek->seek ( mnZipCurrent ); 203*cdf0e10cSrcweir nRead = mxZipStream->readBytes ( aPureData, nToRead ); 204*cdf0e10cSrcweir mnZipCurrent += nRead; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir aPureData.realloc( nRead ); 207*cdf0e10cSrcweir if ( mbCheckCRC ) 208*cdf0e10cSrcweir maCRC.update( aPureData ); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir aData.realloc( nHeadRead + nRead ); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir sal_Int8* pPureBuffer = aPureData.getArray(); 213*cdf0e10cSrcweir sal_Int8* pBuffer = aData.getArray(); 214*cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < nRead; nInd++ ) 215*cdf0e10cSrcweir pBuffer[ nHeadRead + nInd ] = pPureBuffer[ nInd ]; 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir nRead += nHeadRead; 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir else 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir mxZipSeek->seek ( mnZipCurrent ); 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir nRead = mxZipStream->readBytes ( 225*cdf0e10cSrcweir aData, 226*cdf0e10cSrcweir static_cast < sal_Int32 > ( nDiff < nRequestedBytes ? nDiff : nRequestedBytes ) ); 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir mnZipCurrent += nRead; 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir aData.realloc( nRead ); 231*cdf0e10cSrcweir if ( mbWrappedRaw && mbCheckCRC ) 232*cdf0e10cSrcweir maCRC.update( aData ); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir else 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir while ( 0 == ( nLastRead = maInflater.doInflateSegment( aData, nRead, aData.getLength() - nRead ) ) || 238*cdf0e10cSrcweir ( nRead + nLastRead != nRequestedBytes && mnZipCurrent < mnZipEnd ) ) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir nRead += nLastRead; 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir if ( nRead > nRequestedBytes ) 243*cdf0e10cSrcweir throw RuntimeException( 244*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "Should not be possible to read more then requested!" ) ), 245*cdf0e10cSrcweir Reference< XInterface >() ); 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir if ( maInflater.finished() || maInflater.getLastInflateError() ) 248*cdf0e10cSrcweir throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "The stream seems to be broken!" ) ), 249*cdf0e10cSrcweir Reference< XInterface >() ); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir if ( maInflater.needsDictionary() ) 252*cdf0e10cSrcweir throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "Dictionaries are not supported!" ) ), 253*cdf0e10cSrcweir Reference< XInterface >() ); 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir sal_Int32 nDiff = static_cast< sal_Int32 >( mnZipEnd - mnZipCurrent ); 256*cdf0e10cSrcweir if ( nDiff > 0 ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir mxZipSeek->seek ( mnZipCurrent ); 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir sal_Int32 nToRead = std::max( nRequestedBytes, static_cast< sal_Int32 >( 8192 ) ); 261*cdf0e10cSrcweir if ( mnBlockSize > 1 ) 262*cdf0e10cSrcweir nToRead = nToRead + mnBlockSize - nToRead % mnBlockSize; 263*cdf0e10cSrcweir nToRead = std::min( nDiff, nToRead ); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir sal_Int32 nZipRead = mxZipStream->readBytes( maCompBuffer, nToRead ); 266*cdf0e10cSrcweir if ( nZipRead < nToRead ) 267*cdf0e10cSrcweir throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "No expected data!" ) ), 268*cdf0e10cSrcweir Reference< XInterface >() ); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir mnZipCurrent += nZipRead; 271*cdf0e10cSrcweir // maCompBuffer now has the data, check if we need to decrypt 272*cdf0e10cSrcweir // before passing to the Inflater 273*cdf0e10cSrcweir if ( m_xCipherContext.is() ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir if ( mbCheckCRC ) 276*cdf0e10cSrcweir maCRC.update( maCompBuffer ); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir maCompBuffer = m_xCipherContext->convertWithCipherContext( maCompBuffer ); 279*cdf0e10cSrcweir if ( mnZipCurrent == mnZipEnd ) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir uno::Sequence< sal_Int8 > aSuffix = m_xCipherContext->finalizeCipherContextAndDispose(); 282*cdf0e10cSrcweir if ( aSuffix.getLength() ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir sal_Int32 nOldLen = maCompBuffer.getLength(); 285*cdf0e10cSrcweir maCompBuffer.realloc( nOldLen + aSuffix.getLength() ); 286*cdf0e10cSrcweir rtl_copyMemory( maCompBuffer.getArray() + nOldLen, aSuffix.getConstArray(), aSuffix.getLength() ); 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir maInflater.setInput ( maCompBuffer ); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir else 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "The stream seems to be broken!" ) ), 295*cdf0e10cSrcweir Reference< XInterface >() ); 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir mnMyCurrent += nRead + nLastRead; 301*cdf0e10cSrcweir nTotal = nRead + nLastRead; 302*cdf0e10cSrcweir if ( nTotal < nRequestedBytes) 303*cdf0e10cSrcweir aData.realloc ( nTotal ); 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir if ( mbCheckCRC && ( !mbRawStream || mbWrappedRaw ) ) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir if ( !m_xCipherContext.is() && !mbWrappedRaw ) 308*cdf0e10cSrcweir maCRC.update( aData ); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir #if 0 311*cdf0e10cSrcweir // for debugging purposes here 312*cdf0e10cSrcweir if ( mbWrappedRaw ) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir if ( 0 ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); 317*cdf0e10cSrcweir uno::Reference< ucb::XSimpleFileAccess > xAccess( xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), uno::UNO_QUERY ); 318*cdf0e10cSrcweir uno::Reference< io::XOutputStream > xOut = xAccess->openFileWrite( ::rtl::OUString::createFromAscii( "file:///d:/777/Encrypted/picture" ) ); 319*cdf0e10cSrcweir xOut->writeBytes( aData ); 320*cdf0e10cSrcweir xOut->closeOutput(); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir #endif 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir if ( mnZipSize + maHeader.getLength() == mnMyCurrent && maCRC.getValue() != maEntry.nCrc ) 326*cdf0e10cSrcweir throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "The stream seems to be broken!" ) ), 327*cdf0e10cSrcweir Reference< XInterface >() ); 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir return nTotal; 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir sal_Int32 SAL_CALL XUnbufferedStream::readSomeBytes( Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) 335*cdf0e10cSrcweir throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir return readBytes ( aData, nMaxBytesToRead ); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir void SAL_CALL XUnbufferedStream::skipBytes( sal_Int32 nBytesToSkip ) 340*cdf0e10cSrcweir throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir if ( nBytesToSkip ) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir Sequence < sal_Int8 > aSequence ( nBytesToSkip ); 345*cdf0e10cSrcweir readBytes ( aSequence, nBytesToSkip ); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir sal_Int32 SAL_CALL XUnbufferedStream::available( ) 350*cdf0e10cSrcweir throw( NotConnectedException, IOException, RuntimeException) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir return static_cast < sal_Int32 > ( mnZipSize - mnMyCurrent ); 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir void SAL_CALL XUnbufferedStream::closeInput( ) 356*cdf0e10cSrcweir throw( NotConnectedException, IOException, RuntimeException) 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir /* 360*cdf0e10cSrcweir void SAL_CALL XUnbufferedStream::seek( sal_Int64 location ) 361*cdf0e10cSrcweir throw( IllegalArgumentException, IOException, RuntimeException) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir sal_Int64 SAL_CALL XUnbufferedStream::getPosition( ) 365*cdf0e10cSrcweir throw(IOException, RuntimeException) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir return mnMyCurrent; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir sal_Int64 SAL_CALL XUnbufferedStream::getLength( ) 370*cdf0e10cSrcweir throw(IOException, RuntimeException) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir return mnZipSize; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir */ 375