update credits
[LibreOffice.git] / include / tools / zcodec.hxx
blob185cb1d9ecb06bae3abeeaf73dad97acb95478f4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef _ZCODEC_HXX
21 #define _ZCODEC_HXX
23 #include "tools/toolsdllapi.h"
24 #include <tools/solar.h>
26 // Defines
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 )
53 class SvStream;
55 class TOOLS_DLLPUBLIC ZCodec
57 private:
58 sal_uIntPtr mbInit;
59 sal_Bool mbStatus;
60 sal_Bool mbFinish;
61 sal_uIntPtr mnMemUsage;
62 SvStream* mpIStm;
63 sal_uInt8* mpInBuf;
64 sal_uIntPtr mnInBufSize;
65 sal_uIntPtr mnInToRead;
66 SvStream* mpOStm;
67 sal_uInt8* mpOutBuf;
68 sal_uIntPtr mnOutBufSize;
70 sal_uIntPtr mnCRC;
71 sal_uIntPtr mnCompressMethod;
72 void* mpsC_Stream;
74 void ImplInitBuf( sal_Bool nIOFlag );
75 void ImplWriteBack( void );
77 public:
78 ZCodec( sal_uIntPtr nInBuf, sal_uIntPtr nOutBuf, sal_uIntPtr nMemUsage = MAX_MEM_USAGE );
79 ZCodec( void );
80 virtual ~ZCodec();
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 );
97 sal_uIntPtr GetCRC();
100 class GZCodec : public ZCodec
102 public:
103 GZCodec(){};
104 ~GZCodec(){};
105 virtual void BeginCompression( sal_uIntPtr nCompressMethod = ZCODEC_DEFAULT );
108 #endif
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */