xref: /aoo41x/main/sw/source/filter/inc/fltbase.hxx (revision 1d2dbeb0)
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 #ifndef __FLTBASE_HXX__
24 #define __FLTBASE_HXX__
25 
26 #include <tools/stream.hxx>
27 #include <tools/string.hxx>
28 
29 class SwFilterBase
30 {
31 protected:
32 	SvStream	*pIn;
33 	sal_Char	*pReadBuff;	//		Groessenangabe
34 	sal_Int32		nBytesLeft;	// noch zu lesende Bytes des aktuelle Records
35 
36 	CharSet		eQuellChar;	// Quell-Zeichensatz (interner Zeichensatz)
37 //	CharSet		eZielChar;	// Ziel-Zeichensatz
38 
39 	sal_uInt16		nTab;		// z.Zt. bearbeitete Tabelle
40 	sal_uInt16		nReadBuffSize;// temporaerer Lesepuffer mit
41 
42 	// ----------------------------------------------------------
43 	inline void ReadChar( char &rC );
44 	inline void ReadByte( sal_uInt8 &rN );
45 	inline void Read( short &rN );
46 	inline void ReadUnicode( sal_Unicode &rU );
47 	inline void Read( sal_uInt8 &rN0, sal_uInt16 &rN1, sal_uInt16 &rN2 );
48 	inline void Read( sal_uInt16 &rN );
49 	inline void Read( sal_uInt16 &rN1, sal_uInt16 &rN2 );
50 	inline void Read( sal_uInt16 &rN1, sal_uInt16 &rN2, sal_uInt16 &rN3, sal_uInt16 &rN4 );
51 	inline void Read( double &rF );
52 			void Read( String &rS );		// liest 0-terminierten C-String!
53 	inline void ClearBytesLeft( void );
54 };
55 
56 
ReadChar(char & rC)57 inline void SwFilterBase::ReadChar( char &rC )
58 	{
59 	*pIn >> rC;
60 	nBytesLeft--;
61 	}
62 
ReadByte(sal_uInt8 & rN)63 inline void SwFilterBase::ReadByte( sal_uInt8 &rN )
64 	{
65 	*pIn >> rN;
66 	nBytesLeft--;
67 	}
68 
ReadUnicode(sal_Unicode & rU)69 inline void SwFilterBase::ReadUnicode( sal_Unicode &rU )
70 {
71 	{
72 	sal_Char cC;
73 	*pIn >> cC;
74 	rU = ByteString::ConvertToUnicode(cC, eQuellChar);
75 	nBytesLeft--;
76 	}
77 }
78 
Read(short & rN)79 inline void SwFilterBase::Read( short &rN )
80 	{
81 	*pIn >> rN;
82 	nBytesLeft -= 2;
83 	}
84 
Read(sal_uInt8 & rN0,sal_uInt16 & rN1,sal_uInt16 & rN2)85 inline void SwFilterBase::Read( sal_uInt8 &rN0, sal_uInt16 &rN1, sal_uInt16 &rN2 )
86 	{
87 	*pIn >> rN0 >> rN1 >> rN2;
88 	nBytesLeft -= 5;
89 	}
90 
Read(sal_uInt16 & rN)91 inline void SwFilterBase::Read( sal_uInt16 &rN )
92 	{
93 	*pIn >> rN;
94 	nBytesLeft -= 2;
95 	}
96 
Read(sal_uInt16 & rN1,sal_uInt16 & rN2)97 inline void SwFilterBase::Read( sal_uInt16 &rN1, sal_uInt16 &rN2 )
98 	{
99 	*pIn >> rN1 >> rN2;
100 	nBytesLeft -= 4;
101 	}
102 
Read(sal_uInt16 & rN1,sal_uInt16 & rN2,sal_uInt16 & rN3,sal_uInt16 & rN4)103 inline void SwFilterBase::Read( sal_uInt16 &rN1, sal_uInt16 &rN2, sal_uInt16 &rN3, sal_uInt16 &rN4 )
104 	{
105 	*pIn >> rN1 >> rN2 >> rN3 >> rN4;
106 	nBytesLeft -= 8;
107 	}
108 
Read(double & rF)109 inline void SwFilterBase::Read( double &rF )
110 	{
111 	*pIn >> rF;
112 	nBytesLeft -= 8;
113 	}
114 
ClearBytesLeft(void)115 inline void SwFilterBase::ClearBytesLeft( void )
116 	{
117 	pIn->SeekRel( nBytesLeft );
118 	nBytesLeft = 0;
119 	}
120 
121 
122 #endif
123 
124