1 /* This file is part of the wvWare 2 project
2    Copyright (C) 2002-2003 Werner Trobin <trobin@kde.org>
3 
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public
6    License version 2 as published by the Free Software Foundation.
7 
8    This library is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11    Library General Public License for more details.
12 
13    You should have received a copy of the GNU Library General Public License
14    along with this library; see the file COPYING.LIB.  If not, write to
15    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16    Boston, MA 02111-1307, USA.
17 */
18 
19 #ifndef FIELDS_H
20 #define FIELDS_H
21 
22 #include "parser.h"
23 
24 namespace wvWare
25 {
26     namespace Word97
27     {
28         struct FIB;
29     }
30     template<class T> class PLCF;
31     class OLEStreamReader;
32 
33     struct FLD
34     {
35         FLD();
36         FLD( OLEStreamReader* stream, bool preservePos = false );
37         FLD( const U8* ptr );
38 
39         bool read( OLEStreamReader* stream, bool preservePos = false );
40         bool readPtr( const U8* ptr );
41 
42         void clear();
43 
44         // Data
45         U8 ch;
46         union
47         {
48             U8 flt;
49             struct
50             {
51                 U8 fDiffer:1;
52                 U8 fZomieEmbed:1;
53                 U8 fResultDirty:1;
54                 U8 fResultEdited:1;
55                 U8 fLocked:1;
56                 U8 fPrivateResult:1;
57                 U8 fNested:1;
58                 U8 fHasSep:1;
59             } flags;
60         };
61 
62         // Size of the structure (needed for the PLCF template)
63         static const unsigned int sizeOf;
64     };
65 
66     bool operator==( const FLD &lhs, const FLD &rhs );
67     bool operator!=( const FLD &lhs, const FLD &rhs );
68 
69 
70     class Fields
71     {
72     public:
73         Fields( OLEStreamReader* tableStream, const Word97::FIB& fib );
74         ~Fields();
75 
76         const FLD* fldForCP( Parser::SubDocument subDocument, U32 cp ) const;
77 
78     private:
79         Fields( const Fields& rhs );
80         Fields& operator=( const Fields& rhs );
81 
82         void read( U32 fc, U32 lcb, OLEStreamReader* tableStream, PLCF<FLD>** plcf );
83         void sanityCheck( const OLEStreamReader* tableStream, U32 nextFC, U32 lcb ) const;
84         const FLD* fldForCP( const PLCF<FLD>* plcf, U32 cp ) const;
85 
86         PLCF<FLD>* m_main;
87         PLCF<FLD>* m_header;
88         PLCF<FLD>* m_footnote;
89         PLCF<FLD>* m_annotation;
90         PLCF<FLD>* m_endnote;
91         PLCF<FLD>* m_textbox;
92         PLCF<FLD>* m_headerTextbox;
93     };
94 
95 } // namespace wvWare
96 
97 #endif // FIELDS_H
98