summaryrefslogtreecommitdiff
path: root/tools/source/zcodec/zcodec.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'tools/source/zcodec/zcodec.cxx')
-rw-r--r--tools/source/zcodec/zcodec.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index d6bce145a188..b5c645ac92e2 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -394,4 +394,30 @@ void ZCodec::UpdateCRC ( sal_uInt8* pSource, long nDatSize)
mnCRC = rtl_crc32( mnCRC, pSource, nDatSize );
}
+bool ZCodec::AttemptDecompression(SvStream& rIStm, SvStream& rOStm, bool updateCrc, bool gzLib)
+{
+ assert(meState == STATE_INIT);
+ sal_uLong nStreamPos = rIStm.Tell();
+ BeginCompression(ZCODEC_DEFAULT_COMPRESSION, updateCrc, gzLib);
+ InitDecompress(rIStm);
+ EndCompression();
+ if ( !mbStatus || rIStm.GetError() )
+ {
+ rIStm.Seek(nStreamPos);
+ return false;
+ }
+ rIStm.Seek(nStreamPos);
+ BeginCompression(ZCODEC_DEFAULT_COMPRESSION, updateCrc, gzLib);
+ Decompress(rIStm, rOStm);
+ EndCompression();
+ if( !mbStatus || rIStm.GetError() || rOStm.GetError() )
+ {
+ rIStm.Seek(nStreamPos);
+ return false;
+ }
+ rIStm.Seek(nStreamPos);
+ rOStm.Seek(0);
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */