merge the formfield patch from ooo-build
[ooovba.git] / xmlhelp / source / cxxhelp / inc / util / Decompressor.hxx
blob19ec1e726f1fdd1dee437d9aa0c210c819b502ea
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Decompressor.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _XMLSEARCH_UTIL_DECOMPRESSOR_HXX_
31 #define _XMLSEARCH_UTIL_DECOMPRESSOR_HXX_
33 #ifndef INCLUDED_STL_VECTOR
34 #include <vector>
35 #define INCLUDED_STL_VECTOR
36 #endif
37 #include <excep/XmlSearchExceptions.hxx>
38 #include <util/RandomAccessStream.hxx>
41 namespace xmlsearch {
43 namespace util {
46 class CompressorIterator;
49 class Decompressor
51 public:
53 Decompressor()
54 : toRead_( 0 ),
55 path_( 0 )
59 virtual ~Decompressor() { }
61 virtual sal_Int32 getNextByte() = 0;
63 virtual void initReading()
65 toRead_ = 0;
68 private:
70 static const sal_Int32 BitsInByte;
71 static const sal_Int32 NBits;
73 sal_Int32 readByte_, toRead_, path_;
79 class StreamDecompressor
80 : public Decompressor
82 public:
84 StreamDecompressor( RandomAccessStream* in )
85 : in_( in )
89 ~StreamDecompressor() { }
92 virtual sal_Int32 getNextByte();
94 private:
96 RandomAccessStream* in_;
102 class ByteArrayDecompressor
103 : public Decompressor
105 public:
107 ByteArrayDecompressor( sal_Int32 arrayL,sal_Int8* array,sal_Int32 index )
109 initReading(array,arrayL,index);
113 ~ByteArrayDecompressor() { }
115 sal_Int32 bytesRead()
117 return index_ - index0_;
121 sal_Int32 getNextByte() throw( xmlsearch::excep::XmlSearchException )
123 if( arrayL_ <= index_ )
124 throw xmlsearch::excep::XmlSearchException(
125 rtl::OUString::createFromAscii( "ByteArrayDecompressor->getNextByte()" ) );
126 return array_[index_++] & 0xFF;
130 private:
132 sal_Int32 arrayL_;
133 sal_Int8 *array_;
135 sal_Int32 index_,index0_;
137 using xmlsearch::util::Decompressor::initReading;
138 void initReading( sal_Int8* array,sal_Int32 arrayL,sal_Int32 index )
140 arrayL_ = arrayL;
141 array_ = array;
142 index_ = index0_ = index;
143 Decompressor::initReading();
154 #endif