package: Add possibility to disable deflating in a thread
Change-Id: I4d98b6f8b3315b731206700eb65f08463299dda3
This commit is contained in:
@@ -439,6 +439,20 @@ bool ZipPackageStream::ParsePackageRawStream()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void deflateZipEntry(ZipOutputEntry *pZipEntry,
|
||||||
|
const uno::Reference< io::XInputStream >& xInStream)
|
||||||
|
{
|
||||||
|
sal_Int32 nLength = 0;
|
||||||
|
uno::Sequence< sal_Int8 > aSeq(n_ConstBufferSize);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
nLength = xInStream->readBytes(aSeq, n_ConstBufferSize);
|
||||||
|
pZipEntry->write(aSeq, 0, nLength);
|
||||||
|
}
|
||||||
|
while (nLength == n_ConstBufferSize);
|
||||||
|
pZipEntry->closeEntry();
|
||||||
|
}
|
||||||
|
|
||||||
class DeflateThread: public comphelper::ThreadTask
|
class DeflateThread: public comphelper::ThreadTask
|
||||||
{
|
{
|
||||||
ZipOutputEntry *mpEntry;
|
ZipOutputEntry *mpEntry;
|
||||||
@@ -454,16 +468,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
virtual void doWork() SAL_OVERRIDE
|
virtual void doWork() SAL_OVERRIDE
|
||||||
{
|
{
|
||||||
sal_Int32 nLength = 0;
|
deflateZipEntry(mpEntry, mxInStream);
|
||||||
uno::Sequence< sal_Int8 > aSeq(n_ConstBufferSize);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
nLength = mxInStream->readBytes(aSeq, n_ConstBufferSize);
|
|
||||||
mpEntry->write(aSeq, 0, nLength);
|
|
||||||
}
|
|
||||||
while (nLength == n_ConstBufferSize);
|
|
||||||
mpEntry->closeEntry();
|
|
||||||
|
|
||||||
mxInStream.clear();
|
mxInStream.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -784,10 +789,22 @@ bool ZipPackageStream::saveChild(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bParallelDeflate = true;
|
bParallelDeflate = true;
|
||||||
|
if (bParallelDeflate)
|
||||||
|
{
|
||||||
// Start a new thread deflating this zip entry
|
// Start a new thread deflating this zip entry
|
||||||
ZipOutputEntry *pZipEntry = new ZipOutputEntry(m_xContext, *pTempEntry, this, bToBeEncrypted);
|
ZipOutputEntry *pZipEntry = new ZipOutputEntry(m_xContext, *pTempEntry, this, bToBeEncrypted);
|
||||||
rZipOut.addDeflatingThread( pZipEntry, new DeflateThread(pZipEntry, xStream) );
|
rZipOut.addDeflatingThread( pZipEntry, new DeflateThread(pZipEntry, xStream) );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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.rawCloseEntry(bToBeEncrypted);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch ( ZipException& )
|
catch ( ZipException& )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user