1
/*************************************************************************
3
* OpenOffice.org - a multi-platform office productivity suite
5
* $RCSfile: zcodec.hxx,v $
9
* last change: $Author: tuubaaku $ $Date: 2009/02/14 02:51:13 $
11
* The Contents of this file are made available subject to
12
* the terms of GNU Lesser General Public License Version 2.1.
15
* GNU Lesser General Public License Version 2.1
16
* =============================================
17
* Copyright 2005 by Sun Microsystems, Inc.
18
* 901 San Antonio Road, Palo Alto, CA 94303, USA
20
* This library is free software; you can redistribute it and/or
21
* modify it under the terms of the GNU Lesser General Public
22
* License version 2.1, as published by the Free Software Foundation.
24
* This library is distributed in the hope that it will be useful,
25
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27
* Lesser General Public License for more details.
29
* You should have received a copy of the GNU Lesser General Public
30
* License along with this library; if not, write to the Free Software
31
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34
************************************************************************/
39
//#ifndef INCLUDED_TOOLSDLLAPI_H
40
//#include "tools/toolsdllapi.h"
44
//#include <tools/solar.h>
47
#include "global.h" //for U8
48
#include <vector> //for std::vector
54
#define DEFAULT_IN_BUFSIZE (0x00008000UL)
55
#define DEFAULT_OUT_BUFSIZE (0x00008000UL)
57
#define MAX_MEM_USAGE 8
60
// memory requirement using compress:
61
// [ INBUFFER ] + [ OUTBUFFER ] + 128KB + 1 << (MEM_USAGE+9)
63
// memory requirement using decompress:
64
// [ INBUFFER ] + [ OUTBUFFER ] + 32KB
67
#define ZCODEC_NO_COMPRESSION (0x00000000UL)
68
#define ZCODEC_BEST_SPEED (0x00000001UL)
69
#define ZCODEC_DEFAULT_COMPRESSION (0x00000006UL)
70
#define ZCODEC_BEST_COMPRESSION (0x00000009UL)
72
#define ZCODEC_DEFAULT_STRATEGY (0x00000000UL)
73
#define ZCODEC_ZFILTERED (0x00000100UL)
74
#define ZCODEC_ZHUFFMAN_ONLY (0x00000200UL)
76
#define ZCODEC_UPDATE_CRC (0x00010000UL)
77
#define ZCODEC_GZ_LIB (0x00020000UL)
79
#define ZCODEC_PNG_DEFAULT ( ZCODEC_NO_COMPRESSION | ZCODEC_DEFAULT_STRATEGY | ZCODEC_UPDATE_CRC )
80
#define ZCODEC_DEFAULT ( ZCODEC_DEFAULT_COMPRESSION | ZCODEC_DEFAULT_STRATEGY )
86
//class OLEStreamReader;
87
//class OLEStreamWriter;
89
using namespace wvWare;
91
typedef unsigned long ULONG;
100
BOOL mbStatus; //status good or bad
101
BOOL mbFinish; //are we finished yet?
102
ULONG mnMemUsage; //total memory we can use?
103
OLEStreamReader* mpIStm; //in-stream
104
BYTE* mpInBuf; //in-buffer
105
ULONG mnInBufSize; //size of the in-buffer
106
ULONG mnInToRead; //how many bytes overall we still want to read
107
OLEStreamWriter* mpOStm; //out-stream
108
BYTE* mpOutBuf; //out-buffer
109
ULONG mnOutBufSize; //size of the out-buffer
112
ULONG mnCompressMethod;
115
void ImplInitBuf( BOOL nIOFlag );
116
void ImplWriteBack( std::vector<U8>* outBuffer );
119
ZCodec( ULONG nInBuf, ULONG nOutBuf, ULONG nMemUsage = MAX_MEM_USAGE );
123
virtual void BeginCompression( ULONG nCompressMethod = ZCODEC_DEFAULT );
124
virtual long EndCompression(std::vector<U8>* outBuffer);
125
BOOL IsFinished () const { return mbFinish; }
127
long Compress( OLEStreamReader& rIStm, OLEStreamWriter& rOStm );
128
long Decompress( OLEStreamReader& rIStm, std::vector<U8>* outBuffer );
130
//long Write( OLEStreamWriter& rOStm, const BYTE* pData, ULONG nSize );
131
//long Read( OLEStreamReader& rIStm, BYTE* pData, ULONG nSize );
132
//long ReadAsynchron( OLEStreamReader& rIStm, BYTE* pData, ULONG nSize );
134
void SetBreak( ULONG );
135
//ULONG GetBreak( void );
136
//void SetCRC( ULONG nCurrentCRC );
137
//ULONG UpdateCRC( ULONG nLatestCRC, ULONG nSource );
138
//ULONG UpdateCRC( ULONG nLatestCRC, BYTE* pSource, long nDatSize );
142
class GZCodec : public ZCodec
148
virtual void BeginCompression( ULONG nCompressMethod = ZCODEC_DEFAULT );
151
#endif // _ZCODEC_HXX