summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/source/xsltfilter/OleHandler.cxx2
-rw-r--r--include/package/Deflater.hxx2
-rw-r--r--package/inc/CRC32.hxx2
-rw-r--r--package/inc/ZipOutputEntry.hxx2
-rw-r--r--package/inc/ZipOutputStream.hxx2
-rw-r--r--package/source/zipapi/CRC32.cxx7
-rw-r--r--package/source/zipapi/Deflater.cxx8
-rw-r--r--package/source/zipapi/ZipFile.cxx4
-rw-r--r--package/source/zipapi/ZipOutputEntry.cxx6
-rw-r--r--package/source/zipapi/ZipOutputStream.cxx7
-rw-r--r--package/source/zippackage/ZipPackage.cxx14
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx18
12 files changed, 38 insertions, 36 deletions
diff --git a/filter/source/xsltfilter/OleHandler.cxx b/filter/source/xsltfilter/OleHandler.cxx
index 151517405652..f1a7ea0b07e8 100644
--- a/filter/source/xsltfilter/OleHandler.cxx
+++ b/filter/source/xsltfilter/OleHandler.cxx
@@ -198,7 +198,7 @@ namespace XSLT
// Compress the bytes
Sequence<sal_Int8> output(oledata.getLength());
boost::scoped_ptr< ::ZipUtils::Deflater> compresser(new ::ZipUtils::Deflater((sal_Int32) 3, false));
- compresser->setInputSegment(oledata, 0, oledata.getLength());
+ compresser->setInputSegment(oledata);
compresser->finish();
int compressedDataLength = compresser->doDeflateSegment(output, 0, oledata.getLength());
compresser.reset();
diff --git a/include/package/Deflater.hxx b/include/package/Deflater.hxx
index ad73f280ceee..665407d17877 100644
--- a/include/package/Deflater.hxx
+++ b/include/package/Deflater.hxx
@@ -46,7 +46,7 @@ protected:
public:
~Deflater();
Deflater(sal_Int32 nSetLevel, bool bNowrap);
- void SAL_CALL setInputSegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength );
+ void SAL_CALL setInputSegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer );
void SAL_CALL setLevel( sal_Int32 nNewLevel );
bool SAL_CALL needsInput( );
void SAL_CALL finish( );
diff --git a/package/inc/CRC32.hxx b/package/inc/CRC32.hxx
index daaf4b53a53f..cfc66c457804 100644
--- a/package/inc/CRC32.hxx
+++ b/package/inc/CRC32.hxx
@@ -35,7 +35,7 @@ public:
sal_Int64 SAL_CALL updateStream (::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > & xStream)
throw(::com::sun::star::uno::RuntimeException);
- void SAL_CALL updateSegment(const ::com::sun::star::uno::Sequence< sal_Int8 > &b, sal_Int32 off, sal_Int32 len)
+ void SAL_CALL updateSegment(const ::com::sun::star::uno::Sequence< sal_Int8 > &b, sal_Int32 len)
throw(::com::sun::star::uno::RuntimeException);
void SAL_CALL update(const ::com::sun::star::uno::Sequence< sal_Int8 > &b)
throw(::com::sun::star::uno::RuntimeException);
diff --git a/package/inc/ZipOutputEntry.hxx b/package/inc/ZipOutputEntry.hxx
index 9e396ce4dc7b..26ebb1548b56 100644
--- a/package/inc/ZipOutputEntry.hxx
+++ b/package/inc/ZipOutputEntry.hxx
@@ -59,7 +59,7 @@ public:
bool isEncrypt() { return m_bEncryptCurrentEntry; }
void closeEntry();
- void write(const css::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength);
+ void write(const css::uno::Sequence< sal_Int8 >& rBuffer);
private:
void doDeflate();
diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx
index ddc921d9b084..54638d5577fe 100644
--- a/package/inc/ZipOutputStream.hxx
+++ b/package/inc/ZipOutputStream.hxx
@@ -50,7 +50,7 @@ public:
void writeLOC( ZipEntry *pEntry, bool bEncrypt = false )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- void rawWrite( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ void rawWrite( const css::uno::Sequence< sal_Int8 >& rBuffer )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
void rawCloseEntry( bool bEncrypt = false )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
diff --git a/package/source/zipapi/CRC32.cxx b/package/source/zipapi/CRC32.cxx
index 6aee4d514136..39b4f4cccbdc 100644
--- a/package/source/zipapi/CRC32.cxx
+++ b/package/source/zipapi/CRC32.cxx
@@ -47,11 +47,10 @@ sal_Int32 SAL_CALL CRC32::getValue()
}
/** Update CRC32 with specified sequence of bytes
*/
-void SAL_CALL CRC32::updateSegment(const Sequence< sal_Int8 > &b,
- sal_Int32 off, sal_Int32 len)
+void SAL_CALL CRC32::updateSegment(const Sequence< sal_Int8 > &b, sal_Int32 len)
throw(RuntimeException)
{
- nCRC = rtl_crc32(nCRC, b.getConstArray()+off, len );
+ nCRC = rtl_crc32(nCRC, b.getConstArray(), len );
}
/** Update CRC32 with specified sequence of bytes
*/
@@ -70,7 +69,7 @@ sal_Int64 SAL_CALL CRC32::updateStream( Reference < XInputStream > & xStream )
do
{
nLength = xStream->readBytes ( aSeq, n_ConstBufferSize );
- updateSegment ( aSeq, 0, nLength );
+ updateSegment ( aSeq, nLength );
nTotal += nLength;
}
while ( nLength == n_ConstBufferSize );
diff --git a/package/source/zipapi/Deflater.cxx b/package/source/zipapi/Deflater.cxx
index 96d43fc980b3..a19d181b3b0f 100644
--- a/package/source/zipapi/Deflater.cxx
+++ b/package/source/zipapi/Deflater.cxx
@@ -126,13 +126,11 @@ sal_Int32 Deflater::doDeflateBytes (uno::Sequence < sal_Int8 > &rBuffer, sal_Int
}
}
-void SAL_CALL Deflater::setInputSegment( const uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+void SAL_CALL Deflater::setInputSegment( const uno::Sequence< sal_Int8 >& rBuffer )
{
- OSL_ASSERT( !(nNewOffset < 0 || nNewLength < 0 || nNewOffset + nNewLength > rBuffer.getLength()));
-
sInBuffer = rBuffer;
- nOffset = nNewOffset;
- nLength = nNewLength;
+ nOffset = 0;
+ nLength = rBuffer.getLength();
}
void SAL_CALL Deflater::setLevel( sal_Int32 nNewLevel )
{
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 839a1c4ea623..1fd536ff6046 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -1073,7 +1073,7 @@ sal_Int32 ZipFile::getCRC( sal_Int64 nOffset, sal_Int64 nSize )
++ind)
{
sal_Int64 nLen = ::std::min(nBlockSize, nSize - ind * nBlockSize);
- aCRC.updateSegment(aBuffer, 0, static_cast<sal_Int32>(nLen));
+ aCRC.updateSegment(aBuffer, static_cast<sal_Int32>(nLen));
}
return aCRC.getValue();
@@ -1102,7 +1102,7 @@ void ZipFile::getSizeAndCRC( sal_Int64 nOffset, sal_Int64 nCompressedSize, sal_I
do
{
nLastInflated = aInflaterLocal.doInflateSegment( aData, 0, nBlockSize );
- aCRC.updateSegment( aData, 0, nLastInflated );
+ aCRC.updateSegment( aData, nLastInflated );
nInBlock += nLastInflated;
} while( !aInflater.finished() && nLastInflated );
diff --git a/package/source/zipapi/ZipOutputEntry.cxx b/package/source/zipapi/ZipOutputEntry.cxx
index a5fbe25eef61..54600d5964e6 100644
--- a/package/source/zipapi/ZipOutputEntry.cxx
+++ b/package/source/zipapi/ZipOutputEntry.cxx
@@ -118,15 +118,15 @@ void ZipOutputEntry::closeEntry()
}
}
-void ZipOutputEntry::write( const Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+void ZipOutputEntry::write( const Sequence< sal_Int8 >& rBuffer )
{
if (!m_aDeflater.finished())
{
- m_aDeflater.setInputSegment(rBuffer, nNewOffset, nNewLength);
+ m_aDeflater.setInputSegment(rBuffer);
while (!m_aDeflater.needsInput())
doDeflate();
if (!m_bEncryptCurrentEntry)
- m_aCRC.updateSegment(rBuffer, nNewOffset, nNewLength);
+ m_aCRC.updateSegment(rBuffer, rBuffer.getLength());
}
}
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index c191b34079b1..c91b351e1760 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -71,10 +71,10 @@ void ZipOutputStream::addDeflatingThread( ZipOutputEntry *pEntry, osl::Thread *p
pThread->create();
}
-void ZipOutputStream::rawWrite( Sequence< sal_Int8 >& rBuffer, sal_Int32 /*nNewOffset*/, sal_Int32 nNewLength )
+void ZipOutputStream::rawWrite( const Sequence< sal_Int8 >& rBuffer )
throw(IOException, RuntimeException)
{
- m_aChucker.WriteBytes( Sequence< sal_Int8 >(rBuffer.getConstArray(), nNewLength) );
+ m_aChucker.WriteBytes( rBuffer );
}
void ZipOutputStream::rawCloseEntry( bool bEncrypt )
@@ -105,8 +105,7 @@ void ZipOutputStream::finish()
for (size_t i = 0; i < m_aEntries.size(); i++)
{
writeLOC(m_aEntries[i]->getZipEntry(), m_aEntries[i]->isEncrypt());
- uno::Sequence< sal_Int8 > aCompressedData = m_aEntries[i]->getData();
- rawWrite(aCompressedData, 0, aCompressedData.getLength());
+ rawWrite(m_aEntries[i]->getData());
rawCloseEntry(m_aEntries[i]->isEncrypt());
m_aEntries[i]->getZipPackageStream()->successfullyWritten(m_aEntries[i]->getZipEntry());
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index bc697040f61d..432fe54324f6 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -970,7 +970,7 @@ void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut )
ZipEntry * pEntry = new ZipEntry;
sal_Int32 nBufferLength = m_pRootFolder->GetMediaType().getLength();
OString sMediaType = OUStringToOString( m_pRootFolder->GetMediaType(), RTL_TEXTENCODING_ASCII_US );
- uno::Sequence< sal_Int8 > aType( ( sal_Int8* )sMediaType.getStr(),
+ const uno::Sequence< sal_Int8 > aType( ( sal_Int8* )sMediaType.getStr(),
nBufferLength );
pEntry->sPath = sMime;
@@ -986,7 +986,7 @@ void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut )
{
ZipOutputStream::setEntry(pEntry);
aZipOut.writeLOC(pEntry);
- aZipOut.rawWrite(aType, 0, nBufferLength);
+ aZipOut.rawWrite(aType);
aZipOut.rawCloseEntry();
}
catch ( const ::com::sun::star::io::IOException & r )
@@ -1030,10 +1030,9 @@ void ZipPackage::WriteManifest( ZipOutputStream& aZipOut, const vector< uno::Seq
ZipOutputStream::setEntry(pEntry);
aZipOut.writeLOC(pEntry);
ZipOutputEntry aZipEntry(m_xContext, *pEntry, NULL);
- aZipEntry.write(pBuffer->getSequence(), 0, nBufferLength);
+ aZipEntry.write(pBuffer->getSequence());
aZipEntry.closeEntry();
- uno::Sequence< sal_Int8 > aCompressedData = aZipEntry.getData();
- aZipOut.rawWrite(aCompressedData, 0, aCompressedData.getLength());
+ aZipOut.rawWrite(aZipEntry.getData());
aZipOut.rawCloseEntry();
}
@@ -1085,10 +1084,9 @@ void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const vector< uno:
ZipOutputStream::setEntry(pEntry);
aZipOut.writeLOC(pEntry);
ZipOutputEntry aZipEntry(m_xContext, *pEntry, NULL);
- aZipEntry.write(pBuffer->getSequence(), 0, nBufferLength);
+ aZipEntry.write(pBuffer->getSequence());
aZipEntry.closeEntry();
- uno::Sequence< sal_Int8 > aCompressedData = aZipEntry.getData();
- aZipOut.rawWrite(aCompressedData, 0, aCompressedData.getLength());
+ aZipOut.rawWrite(aZipEntry.getData());
aZipOut.rawCloseEntry();
}
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 94d18eae8f2f..396b05221601 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -447,7 +447,10 @@ static void deflateZipEntry(ZipOutputEntry *pZipEntry,
do
{
nLength = xInStream->readBytes(aSeq, n_ConstBufferSize);
- pZipEntry->write(aSeq, 0, nLength);
+ if (nLength != n_ConstBufferSize)
+ aSeq.realloc(nLength);
+
+ pZipEntry->write(aSeq);
}
while (nLength == n_ConstBufferSize);
pZipEntry->closeEntry();
@@ -722,7 +725,10 @@ bool ZipPackageStream::saveChild(
do
{
nLength = xStream->readBytes( aSeq, n_ConstBufferSize );
- rZipOut.rawWrite(aSeq, 0, nLength);
+ if (nLength != n_ConstBufferSize)
+ aSeq.realloc(nLength);
+
+ rZipOut.rawWrite(aSeq);
}
while ( nLength == n_ConstBufferSize );
@@ -781,7 +787,10 @@ bool ZipPackageStream::saveChild(
do
{
nLength = xStream->readBytes(aSeq, n_ConstBufferSize);
- rZipOut.rawWrite(aSeq, 0, nLength);
+ if (nLength != n_ConstBufferSize)
+ aSeq.realloc(nLength);
+
+ rZipOut.rawWrite(aSeq);
}
while ( nLength == n_ConstBufferSize );
rZipOut.rawCloseEntry(bToBeEncrypted);
@@ -800,8 +809,7 @@ bool ZipPackageStream::saveChild(
rZipOut.writeLOC(pTempEntry, bToBeEncrypted);
ZipOutputEntry aZipEntry(m_xContext, *pTempEntry, this, bToBeEncrypted);
deflateZipEntry(&aZipEntry, xStream);
- uno::Sequence< sal_Int8 > aCompressedData = aZipEntry.getData();
- rZipOut.rawWrite(aCompressedData, 0, aCompressedData.getLength());
+ rZipOut.rawWrite(aZipEntry.getData());
rZipOut.rawCloseEntry(bToBeEncrypted);
}
}