summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-05-21 12:20:59 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-05-21 15:30:16 +0200
commit200d530f473566d7d7aa30f848bc28a72247d674 (patch)
tree642dcb6cbfa123faeeb32c1514bbcae5edb96f5e
parent5e82dc511ea266776a06c9da62c41e873b2cbafc (diff)
Split ZCodec::BeginCompression param into its 3 independent components
Change-Id: I275abafe81c8bb617c70646244b14f6cecc33854
-rw-r--r--include/tools/zcodec.hxx23
-rw-r--r--svx/source/xml/xmlgrhlp.cxx2
-rw-r--r--tools/source/zcodec/zcodec.cxx22
-rw-r--r--vcl/source/gdi/pngread.cxx2
-rw-r--r--vcl/source/gdi/pngwrite.cxx2
-rw-r--r--vcl/unx/generic/printer/ppdparser.cxx2
6 files changed, 27 insertions, 26 deletions
diff --git a/include/tools/zcodec.hxx b/include/tools/zcodec.hxx
index 456cdd7f9a58..93da186929c8 100644
--- a/include/tools/zcodec.hxx
+++ b/include/tools/zcodec.hxx
@@ -22,15 +22,10 @@
#include <tools/toolsdllapi.h>
-#define ZCODEC_NO_COMPRESSION (0x00000000UL)
-#define ZCODEC_BEST_SPEED (0x00000001UL)
-#define ZCODEC_DEFAULT_COMPRESSION (0x00000006UL)
-#define ZCODEC_BEST_COMPRESSION (0x00000009UL)
-
-#define ZCODEC_UPDATE_CRC (0x00010000UL)
-#define ZCODEC_GZ_LIB (0x00020000UL)
-
-#define ZCODEC_PNG_DEFAULT ( ZCODEC_NO_COMPRESSION | ZCODEC_UPDATE_CRC )
+#define ZCODEC_NO_COMPRESSION 0
+#define ZCODEC_BEST_SPEED 1
+#define ZCODEC_DEFAULT_COMPRESSION 6
+#define ZCODEC_BEST_COMPRESSION 9
class SvStream;
@@ -49,7 +44,9 @@ private:
sal_uIntPtr mnOutBufSize;
sal_uIntPtr mnCRC;
- sal_uIntPtr mnCompressMethod;
+ int mnCompressLevel;
+ bool mbUpdateCrc;
+ bool mbGzLib;
void* mpsC_Stream;
void ImplInitBuf( bool nIOFlag );
@@ -59,7 +56,7 @@ public:
ZCodec( sal_uIntPtr nInBuf = 0x8000UL, sal_uIntPtr nOutBuf = 0x8000UL );
virtual ~ZCodec();
- virtual void BeginCompression( sal_uIntPtr nCompressMethod = ZCODEC_DEFAULT_COMPRESSION );
+ virtual void BeginCompression( int nCompressLevel = ZCODEC_DEFAULT_COMPRESSION, bool updateCrc = false, bool gzLib = false );
virtual long EndCompression();
bool IsFinished () const { return mbFinish; }
@@ -82,9 +79,9 @@ class GZCodec : public ZCodec
public:
GZCodec(){};
virtual ~GZCodec(){};
- virtual void BeginCompression( sal_uIntPtr nCompressMethod = ZCODEC_DEFAULT_COMPRESSION ) SAL_OVERRIDE
+ virtual void BeginCompression( int nCompressLevel = ZCODEC_DEFAULT_COMPRESSION, bool updateCrc = false, bool gzLib = true ) SAL_OVERRIDE
{
- ZCodec::BeginCompression( nCompressMethod | ZCODEC_GZ_LIB );
+ ZCodec::BeginCompression( nCompressLevel, updateCrc, gzLib );
};
};
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 8d73719b84c5..27cc02faa33b 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -314,7 +314,7 @@ const GraphicObject& SvXMLGraphicOutputStream::GetGraphicObject()
{
SvMemoryStream* pDest = new SvMemoryStream;
ZCodec aZCodec( 0x8000, 0x8000 );
- aZCodec.BeginCompression(ZCODEC_GZ_LIB);
+ aZCodec.BeginCompression(ZCODEC_DEFAULT_COMPRESSION, false, true);
mpOStm->Seek( 0 );
aZCodec.Decompress( *mpOStm, *pDest );
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index 49d4f12d2037..a672e7669a1a 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -49,7 +49,9 @@ ZCodec::ZCodec( sal_uIntPtr nInBufSize, sal_uIntPtr nOutBufSize )
, mpOutBuf(NULL)
, mnOutBufSize(nOutBufSize)
, mnCRC(0)
- , mnCompressMethod(0)
+ , mnCompressLevel(0)
+ , mbUpdateCrc(false)
+ , mbGzLib(false)
{
mpsC_Stream = new z_stream;
}
@@ -59,7 +61,7 @@ ZCodec::~ZCodec()
delete (z_stream*) mpsC_Stream;
}
-void ZCodec::BeginCompression( sal_uIntPtr nCompressMethod )
+void ZCodec::BeginCompression( int nCompressLevel, bool updateCrc, bool gzLib )
{
mbInit = 0;
mbStatus = true;
@@ -68,7 +70,9 @@ void ZCodec::BeginCompression( sal_uIntPtr nCompressMethod )
mnInToRead = 0xffffffff;
mpInBuf = mpOutBuf = NULL;
PZSTREAM->total_out = PZSTREAM->total_in = 0;
- mnCompressMethod = nCompressMethod;
+ mnCompressLevel = nCompressLevel;
+ mbUpdateCrc = updateCrc;
+ mbGzLib = gzLib;
PZSTREAM->zalloc = ( alloc_func )0;
PZSTREAM->zfree = ( free_func )0;
PZSTREAM->opaque = ( voidpf )0;
@@ -154,7 +158,7 @@ long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm )
PZSTREAM->avail_in = mpIStm->Read( PZSTREAM->next_in = mpInBuf, nInToRead );
mnInToRead -= nInToRead;
- if ( mnCompressMethod & ZCODEC_UPDATE_CRC )
+ if ( mbUpdateCrc )
mnCRC = UpdateCRC( mnCRC, mpInBuf, nInToRead );
}
@@ -223,7 +227,7 @@ long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize )
PZSTREAM->next_in = mpInBuf, nInToRead);
mnInToRead -= nInToRead;
- if ( mnCompressMethod & ZCODEC_UPDATE_CRC )
+ if ( mbUpdateCrc )
mnCRC = UpdateCRC( mnCRC, mpInBuf, nInToRead );
}
@@ -277,7 +281,7 @@ long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize
PZSTREAM->next_in = mpInBuf, nInToRead);
mnInToRead -= nInToRead;
- if ( mnCompressMethod & ZCODEC_UPDATE_CRC )
+ if ( mbUpdateCrc )
mnCRC = UpdateCRC( mnCRC, mpInBuf, nInToRead );
}
@@ -304,7 +308,7 @@ void ZCodec::ImplWriteBack()
if ( nAvail )
{
- if ( mbInit & 2 && ( mnCompressMethod & ZCODEC_UPDATE_CRC ) )
+ if ( mbInit & 2 && mbUpdateCrc )
mnCRC = UpdateCRC( mnCRC, mpOutBuf, nAvail );
mpOStm->Write( PZSTREAM->next_out = mpOutBuf, nAvail );
PZSTREAM->avail_out = mnOutBufSize;
@@ -338,7 +342,7 @@ void ZCodec::ImplInitBuf ( bool nIOFlag )
if ( nIOFlag )
{
mbInit = 1;
- if ( mbStatus && ( mnCompressMethod & ZCODEC_GZ_LIB ) )
+ if ( mbStatus && mbGzLib )
{
sal_uInt8 n1, n2, j, nMethod, nFlags;
for ( int i = 0; i < 2; i++ ) // gz - magic number
@@ -395,7 +399,7 @@ void ZCodec::ImplInitBuf ( bool nIOFlag )
{
mbInit = 3;
- mbStatus = ( deflateInit2_( PZSTREAM, mnCompressMethod & 0xff, Z_DEFLATED,
+ mbStatus = ( deflateInit2_( PZSTREAM, mnCompressLevel, Z_DEFLATED,
MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY,
ZLIB_VERSION, sizeof( z_stream ) ) >= 0 );
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 8a05013c28b4..cae7b38e4bc0 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -900,7 +900,7 @@ void PNGReaderImpl::ImplReadIDAT()
if ( !mbzCodecInUse )
{
mbzCodecInUse = true;
- mpZCodec->BeginCompression( ZCODEC_PNG_DEFAULT );
+ mpZCodec->BeginCompression( ZCODEC_NO_COMPRESSION, true );
}
mpZCodec->SetBreak( mnChunkLen );
SvMemoryStream aIStrm( &(*maDataIter), mnChunkLen, STREAM_READ );
diff --git a/vcl/source/gdi/pngwrite.cxx b/vcl/source/gdi/pngwrite.cxx
index c4e950987922..9057a48221f6 100644
--- a/vcl/source/gdi/pngwrite.cxx
+++ b/vcl/source/gdi/pngwrite.cxx
@@ -386,7 +386,7 @@ void PNGWriterImpl::ImplWriteIDAT ()
mpCurrentScan = new sal_uInt8[ mnDeflateInSize ];
ImplClearFirstScanline();
}
- mpZCodec->BeginCompression( ZCODEC_PNG_DEFAULT + mnCompLevel );
+ mpZCodec->BeginCompression( mnCompLevel, true );
mpZCodec->SetCRC( mnCRC );
SvMemoryStream aOStm;
if ( mnInterlaced == 0 )
diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx
index fd1d0dc6547b..606fd550da97 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -322,7 +322,7 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
// so let's try to decompress the stream
mpMemStream = new SvMemoryStream( 4096, 4096 );
ZCodec aCodec;
- aCodec.BeginCompression( ZCODEC_DEFAULT_COMPRESSION | ZCODEC_GZ_LIB );
+ aCodec.BeginCompression( ZCODEC_DEFAULT_COMPRESSION, false, true );
long nComp = aCodec.Decompress( *mpFileStream, *mpMemStream );
aCodec.EndCompression();
if( nComp < 0 )