1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include "tools/toolsdllapi.h"
24 #include <tools/solar.h>
28 #define DEFAULT_IN_BUFSIZE (0x00008000UL)
29 #define DEFAULT_OUT_BUFSIZE (0x00008000UL)
31 #define MAX_MEM_USAGE 8
33 // memory requirement using compress:
34 // [ INBUFFER ] + [ OUTBUFFER ] + 128KB + 1 << (MEM_USAGE+9)
35 // memory requirement using decompress:
36 // [ INBUFFER ] + [ OUTBUFFER ] + 32KB
38 #define ZCODEC_NO_COMPRESSION (0x00000000UL)
39 #define ZCODEC_BEST_SPEED (0x00000001UL)
40 #define ZCODEC_DEFAULT_COMPRESSION (0x00000006UL)
41 #define ZCODEC_BEST_COMPRESSION (0x00000009UL)
43 #define ZCODEC_DEFAULT_STRATEGY (0x00000000UL)
44 #define ZCODEC_ZFILTERED (0x00000100UL)
45 #define ZCODEC_ZHUFFMAN_ONLY (0x00000200UL)
47 #define ZCODEC_UPDATE_CRC (0x00010000UL)
48 #define ZCODEC_GZ_LIB (0x00020000UL)
50 #define ZCODEC_PNG_DEFAULT ( ZCODEC_NO_COMPRESSION | ZCODEC_DEFAULT_STRATEGY | ZCODEC_UPDATE_CRC )
51 #define ZCODEC_DEFAULT ( ZCODEC_DEFAULT_COMPRESSION | ZCODEC_DEFAULT_STRATEGY )
55 class TOOLS_DLLPUBLIC ZCodec
61 sal_uIntPtr mnMemUsage
;
64 sal_uIntPtr mnInBufSize
;
65 sal_uIntPtr mnInToRead
;
68 sal_uIntPtr mnOutBufSize
;
71 sal_uIntPtr mnCompressMethod
;
74 void ImplInitBuf( sal_Bool nIOFlag
);
75 void ImplWriteBack( void );
78 ZCodec( sal_uIntPtr nInBuf
, sal_uIntPtr nOutBuf
, sal_uIntPtr nMemUsage
= MAX_MEM_USAGE
);
82 virtual void BeginCompression( sal_uIntPtr nCompressMethod
= ZCODEC_DEFAULT
);
83 virtual long EndCompression();
84 sal_Bool
IsFinished () const { return mbFinish
; }
86 long Compress( SvStream
& rIStm
, SvStream
& rOStm
);
87 long Decompress( SvStream
& rIStm
, SvStream
& rOStm
);
89 long Write( SvStream
& rOStm
, const sal_uInt8
* pData
, sal_uIntPtr nSize
);
90 long Read( SvStream
& rIStm
, sal_uInt8
* pData
, sal_uIntPtr nSize
);
91 long ReadAsynchron( SvStream
& rIStm
, sal_uInt8
* pData
, sal_uIntPtr nSize
);
93 void SetBreak( sal_uIntPtr
);
94 sal_uIntPtr
GetBreak( void );
95 void SetCRC( sal_uIntPtr nCurrentCRC
);
96 sal_uIntPtr
UpdateCRC( sal_uIntPtr nLatestCRC
, sal_uInt8
* pSource
, long nDatSize
);
100 class GZCodec
: public ZCodec
105 virtual void BeginCompression( sal_uIntPtr nCompressMethod
= ZCODEC_DEFAULT
);
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */