merge the formfield patch from ooo-build
[ooovba.git] / sw / inc / swgstr.hxx
blob8c16f5a26dd4b4255353578a9a9c0aa61b3430c9
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: swgstr.hxx,v $
10 * $Revision: 1.4 $
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 _SWGSTR_HXX
31 #define _SWGSTR_HXX
33 #include <tools/stream.hxx>
35 typedef long long3; // Zur Dokumentation: 3-byte-Longs
37 #define MAX_BEGIN 64 // Maximale Blockschachtelung
38 #define PASSWDLEN 16 // Maximale Passwortlaenge
40 // Neue Version mit SvStreams
42 // Passwort- und Codierungs-Funktionalitaet
44 class swcrypter {
45 protected:
46 sal_Char cPasswd[ PASSWDLEN ]; // Passwort-Puffer
47 BOOL bPasswd; // TRUE wenn mit Passwort
48 void encode( sal_Char*, USHORT ); // Puffer codieren/decodieren
49 public:
50 swcrypter();
51 BOOL setpasswd( const String& ); // Passwort setzen
52 void copypasswd( const sal_Char* ); // Passwort direkt setzen
53 const sal_Char* getpasswd() { return cPasswd; }
56 // Reader/Writer-Stream-Basisklasse mit Pufferverwaltung fuer Texte
57 // und Spezial-I/O fuer 3-Byte-Longs
59 class swstreambase : public swcrypter {
60 protected:
61 SvStream* pStrm; // eigentlicher Stream
62 sal_Char* pBuf; // Zwischenpuffer
63 USHORT nBuflen; // Laenge des Zwischenpuffers
64 short nLong; // Long-Laenge (3 oder 4)
65 BOOL bTempStrm; // TRUE: Stream loeschen
66 void checkbuf( USHORT ); // Testen der Pufferlaenge
68 swstreambase( SvStream& );
70 swstreambase( const swstreambase& );
71 int operator=( const swstreambase& );
72 public:
73 ~swstreambase();
74 SvStream& Strm() { return *pStrm; }
75 void clear(); // Puffer loeschen
77 // Zusatzfunktionen zur I/O von LONGs als 3-Byte-Zahlen
79 void long3() { nLong = 3; }
80 void long4() { nLong = 4; }
82 // Alias- und Hilfsfunktionen
84 void seek( long nPos ) { pStrm->Seek( nPos ); }
85 long tell() { return pStrm->Tell(); }
86 long filesize(); // Dateigroesse
88 void setbad();
89 int good() { return ( pStrm->GetError() == SVSTREAM_OK ); }
90 int operator!() { return ( pStrm->GetError() != SVSTREAM_OK ); }
91 int eof() { return pStrm->IsEof(); }
93 BYTE get();
94 void get( void* p, USHORT n ) { pStrm->Read( (sal_Char*) p, n ); }
96 inline swstreambase& operator>>( sal_Char& );
97 inline swstreambase& operator>>( BYTE& );
98 inline swstreambase& operator>>( short& );
99 inline swstreambase& operator>>( USHORT& );
100 swstreambase& operator>>( long& );
101 inline swstreambase& operator>>( ULONG& );
104 inline swstreambase& swstreambase::operator>>( sal_Char& c )
106 *pStrm >> c; return *this;
109 inline swstreambase& swstreambase::operator>>( BYTE& c )
111 *pStrm >> c; return *this;
114 inline swstreambase& swstreambase::operator>>( short& c )
116 *pStrm >> c; return *this;
119 inline swstreambase& swstreambase::operator>>( USHORT& c )
121 *pStrm >> c; return *this;
124 inline swstreambase& swstreambase::operator>>( ULONG& c )
126 return *this >> (long&) c;
129 class swistream : public swstreambase {
130 BYTE cType; // Record-Typ
131 ULONG nOffset; // Record-Offset-Portion
132 public:
133 swistream( SvStream& );
135 BYTE peek(); // 1 Byte testen
136 BYTE next(); // Blockstart
137 BYTE cur() { return cType; } // aktueller Block
138 BYTE skipnext(); // Record ueberspringen
139 void undonext(); // next() rueckgaengig machen
140 long getskip() { return nOffset; }
141 void skip( long = -1L ); // Block ueberspringen
142 sal_Char* text(); // Textstring lesen (nach BEGIN)
143 long size(); // aktuelle Record-Laenge
145 private:
146 swistream( const swistream& );
147 int operator=( const swistream& );
151 #endif