1
/* This file is part of the wvWare 2 project
2
Copyright (C) 2001-2003 Werner Trobin <trobin@kde.org>
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.
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.
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., 51 Franklin Street, Fifth Floor,
16
Boston, MA 02111-1307, USA.
22
#include "word97_generated.h"
23
#include "wv2_export.h"
28
class OLEStreamReader;
29
class OLEStreamWriter;
35
* STyle Definition (STD)
40
* Creates an empty STD structure and sets the defaults
44
* Simply calls read(...)
46
STD( U16 baseSize, U16 totalSize, OLEStreamReader* stream, bool preservePos = false );
48
* Attention: This struct allocates memory on the heap
50
STD( const STD& rhs );
53
STD& operator=( const STD& rhs );
56
* This method reads the STD structure from the stream.
57
* If preservePos is true we push/pop the position of
58
* the stream to save the state. If it's false the state
59
* of stream will be changed!
61
bool read( U16 baseSize, U16 totalSize, OLEStreamReader* stream, bool preservePos = false );
66
bool write( U16 baseSize, OLEStreamWriter* stream, bool preservePos = false ) const;
69
* Set all the fields to the inital value (default is 0)
75
* invariant style identifier
80
* spare field for any temporary use, always reset back to zero!
85
* PHEs of all text with this style are wrong
90
* UPEs have been generated
95
* std has been mass-copied; if unused at save time, style should be deleted
110
* # of UPXs (and UPEs)
120
* offset to end of upx's, start of upe's
125
* auto redefine style when appropriate
140
* sub-names are separated by chDelimStyle
146
// Internal, for bookkeeping
150
void clearInternal();
151
void readStyleName( U16 baseSize, OLEStreamReader* stream );
154
bool operator==( const STD& lhs, const STD& rhs );
155
bool operator!=( const STD& lhs, const STD& rhs );
157
} // namespace Word97
161
class ParagraphProperties;
162
class ListInfoProvider;
164
// The structure to hold the UPE for character styles.
167
UPECHPX() : istd( 0 ), cb( 0 ), grpprl( 0 ) {}
168
~UPECHPX() { delete [] grpprl; }
175
UPECHPX( const UPECHPX& rhs );
176
UPECHPX& operator=( const UPECHPX& rhs );
180
* This class represents one single style.
182
// It would maybe be worth to optimize the construction a bit, like creating
183
// the PAP and the CHP on copying from the base style, and not before (TODO)
184
class WV2_EXPORT Style
187
enum StyleType { sgcUnknown = 0, sgcPara = 1, sgcChp = 2 };
189
Style( U16 baseSize, OLEStreamReader* tableStream, U16* ftc );
193
* The stylesheet can have "empty" slots
195
bool isEmpty() const { return m_isEmpty; }
197
* Did we already unwrap the style?
199
bool isWrapped() const { return m_isWrapped; }
202
* Unwrap the style and create a valid PAP/CHP
204
void unwrapStyle( const StyleSheet& stylesheet, WordVersion version );
207
* Get the (unique?) sti of that style
212
* Get the type of the style (paragraph/character style)
214
StyleType type() const;
219
UString name() const;
222
* Id of following style
224
U16 followingStyle() const;
227
* For paragraph styles only
229
const ParagraphProperties& paragraphProperties() const;
231
* For paragraph styles only
233
const Word97::CHP& chp() const;
235
* For character styles only
237
const UPECHPX& upechpx() const;
240
Style( const Style& rhs );
241
Style& operator=( const Style& rhs );
243
// This helper method merges two CHPX structures to one
244
// (needed for character styles)
245
void mergeUpechpx( const Style* parentStyle, WordVersion version );
253
mutable ParagraphProperties *m_properties; // "mutable" in case someone goes mad
254
mutable Word97::CHP *m_chp; // with the styles. We have to create a default style
255
mutable UPECHPX *m_upechpx; // to avoid crashes and still have to keep ownership!
260
* This class holds all the styles this Word document
261
* defines. You can query styles by ID (sti) or index (istd)
263
class WV2_EXPORT StyleSheet
266
StyleSheet( OLEStreamReader* tableStream, U32 fcStshf, U32 lcbStshf );
270
* Return the number of styles.
272
unsigned int size() const;
273
const Style* styleByIndex( U16 istd ) const;
275
const Style* styleByID( U16 sti ) const;
277
U16 indexByID( U16 sti, bool& ok ) const;
280
StyleSheet( const StyleSheet& rhs );
281
StyleSheet& operator=( const StyleSheet& rhs );
283
Word97::STSHI m_stsh;
284
std::vector<Style*> m_styles;
287
} // namespace wvWare