summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-10-27 14:26:54 +0100
committerMatúš Kukan <matus.kukan@collabora.com>2014-11-17 10:49:23 +0100
commit7088166a67d1270f93ac15bccbc89343b2271fa5 (patch)
tree355b3ae6b9a4b27eb185290c8ac4351a4364cd55
parenta42aa52acbbff738a00299de172ca85cb001d840 (diff)
Simplify input parameters to just take the sequence
Change-Id: Ic2538ca8b0f7261064e1dfbf3884dd452003c797
-rw-r--r--filter/source/xsltfilter/OleHandler.cxx2
-rw-r--r--include/package/Deflater.hxx1
-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, 35 deletions
diff --git a/filter/source/xsltfilter/OleHandler.cxx b/filter/source/xsltfilter/OleHandler.cxx
index edd0678fb01e..14ef6bd052fc 100644
--- a/filter/source/xsltfilter/OleHandler.cxx
+++ b/filter/source/xsltfilter/OleHandler.cxx
@@ -197,7 +197,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 bd6d815f270d..d2be24743d67 100644
--- a/include/package/Deflater.hxx
+++ b/include/package/Deflater.hxx
@@ -46,6 +46,7 @@ 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 );
bool SAL_CALL needsInput( );
void SAL_CALL finish( );
bool SAL_CALL finished( ) { return bFinished;}
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 4e8e4ff150be..acf6dc4e1855 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 a76362ff268a..42628d72195b 100644
--- a/package/source/zipapi/Deflater.cxx
+++ b/package/source/zipapi/Deflater.cxx
@@ -92,13 +92,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();
}
bool SAL_CALL Deflater::needsInput( )
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 fcfe35f82070..902816ebe711 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -71,10 +71,10 @@ void ZipOutputStream::addDeflatingThread( ZipOutputEntry *pEntry, comphelper::Th
m_aEntries.push_back(pEntry);
}
-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 )
@@ -100,8 +100,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 80d4d4fd179e..2e64af8d92b1 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -983,7 +983,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;
@@ -999,7 +999,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 )
@@ -1043,10 +1043,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();
}
@@ -1098,10 +1097,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 d5e0d62641c6..90f0df8e4da8 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);
}
}