1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _LZWDECOM_HXX
25 #define _LZWDECOM_HXX
26 
27 #include <tools/stream.hxx>
28 
29 struct LZWTableEntry {
30 	sal_uInt16 nPrevCode;
31 	sal_uInt16 nDataCount;
32 	sal_uInt8 nData;
33 };
34 
35 class LZWDecompressor {
36 
37 public:
38 
39 	LZWDecompressor();
40 	~LZWDecompressor();
41 
42 	void StartDecompression(SvStream & rIStream);
43 
44 	sal_uLong Decompress(sal_uInt8 * pTarget, sal_uLong nMaxCount);
45 		// Liefert die Anzahl der geschriebenen Bytes, wenn < nMaxCount,
46 		// sind keine weiteren Daten zu entpacken, oder es ist ein
47 		// Fehler aufgetreten.
48 
49 private:
50 
51 	sal_uInt16 GetNextCode();
52 	void AddToTable(sal_uInt16 nPrevCode, sal_uInt16 nCodeFirstData);
53 	void DecompressSome();
54 
55 	SvStream * pIStream;
56 
57 	LZWTableEntry * pTable;
58 	sal_uInt16 nTableSize;
59 
60 	sal_Bool bEOIFound, bInvert, bFirst;
61 
62 	sal_uInt16 nOldCode;
63 
64 	sal_uInt8 * pOutBuf;
65 	sal_uInt8 * pOutBufData;
66 	sal_uInt16 nOutBufDataLen;
67 
68 	sal_uInt8 nInputBitsBuf;
69 	sal_uInt16 nInputBitsBufSize;
70 };
71 
72 
73 #endif
74 
75 
76