lib

KoParagCounter.h
1/* This file is part of the KDE project
2 Copyright (C) 2001 Shaheed Haque <srhaque@iee.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 as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <tqstring.h>
21#include <koffice_export.h>
22class TQDomElement;
23class KoXmlWriter;
24class KoGenStyle;
25class KoTextParag;
26class KoTextFormat;
27class KoOasisContext;
28
29#ifndef koparagcounter_h
30#define koparagcounter_h
31
36class KOTEXT_EXPORT KoParagCounter
37{
38public:
40
43 void invalidate();
44
47 int number( const KoTextParag *paragraph );
51 TQString levelText( const KoTextParag *paragraph );
56 TQString text( const KoTextParag *paragraph );
57
62 int width( const KoTextParag *paragraph );
63
68 int bulletX();
69
71 void load( TQDomElement & element );
73 void save( TQDomElement & element );
83 void loadOasis( KoOasisContext& context, int restartNumbering, bool orderedList, bool heading, int level, bool loadingStyle = false );
85 void loadOasisListStyle( const TQDomElement& listStyle,
86 const TQDomElement& listStyleProperties,
87 const TQDomElement& listStyleTextProperties,
88 int restartNumbering,
89 bool orderedList, bool heading, int level, bool loadingStyle );
91 void saveOasis( KoGenStyle& listStyle, bool savingStyle = false ) const;
94 void saveOasisListLevel( KoXmlWriter& listLevelWriter, bool includeLevelAndProperties, bool savingStyle = false ) const;
95
96 bool operator==( const KoParagCounter & c2 ) const;
97 bool operator!=( const KoParagCounter & c2 ) const { return !(*this == c2); }
98
99 enum Numbering
100 {
101 NUM_NONE = 2, // Unnumbered. Equivalent to there being
102 // no counter structure associated with a
103 // paragraph.
104 NUM_LIST = 0, // Numbered as a list item.
105 NUM_CHAPTER = 1, // Numbered as a heading.
106 NUM_FOOTNOTE = 3 // Fixed text counter, set by the code. This is used by e.g. footnotes.
107 };
108 enum Style // always add to the end, the numeric values are part of the DTD
109 {
110 STYLE_NONE = 0,
111 STYLE_NUM = 1, STYLE_ALPHAB_L = 2, STYLE_ALPHAB_U = 3,
112 STYLE_ROM_NUM_L = 4, STYLE_ROM_NUM_U = 5, STYLE_CUSTOMBULLET = 6,
113 STYLE_CUSTOM = 7, STYLE_CIRCLEBULLET = 8, STYLE_SQUAREBULLET = 9,
114 STYLE_DISCBULLET = 10, STYLE_BOXBULLET = 11
115 };
116
119 Numbering numbering() const;
120 void setNumbering( Numbering n );
121
122 Style style() const;
123 void setStyle( Style s );
124
129 bool restartCounter() const;
130 void setRestartCounter( bool restart );
131
134 bool isBullet() const;
138 static bool isBullet( Style style );
139
143 unsigned int depth() const;
144 void setDepth( unsigned int d );
145
148 int displayLevels() const;
149 void setDisplayLevels( int l );
150
153 int startNumber() const;
154 void setStartNumber( int s );
155
158 TQString prefix() const;
159 void setPrefix( TQString p );
160 TQString suffix() const;
161 void setSuffix( TQString s );
162
165 TQChar customBulletCharacter() const;
166 void setCustomBulletCharacter( TQChar c );
167 TQString customBulletFont() const;
168 void setCustomBulletFont( TQString f );
169
172 TQString custom() const;
173 void setCustom( TQString c );
174
177 int alignment() const;
178 void setAlignment( int a );
179
184 static KoTextFormat* counterFormat( const KoTextParag *paragraph );
185
186 static TQString makeRomanNumber( int n );
187 static TQString makeAlphaUpperNumber( int n );
188 static TQString makeAlphaLowerNumber( int n );
189
190 static int fromRomanNumber( const TQString & );
191 static int fromAlphaUpperNumber( const TQString & );
192 static int fromAlphaLowerNumber( const TQString & );
193
194#ifndef NDEBUG
195 void printRTDebug( KoTextParag* parag );
196#endif
197
198private:
199
203 KoTextParag *parent( const KoTextParag *paragraph );
204
205 Numbering m_numbering:3; // Numbering (maximum value: 8)
206 bool m_restartCounter:1;
207 bool unused:4;
208 Style m_style:8; // Style
209 char m_displayLevels; // Number of levels to display (e.g. 3 => 1.2.1)
210 char m_depth;
211
212 short int m_startNumber;
213 TQChar m_customBulletChar;
214
215 TQString m_customBulletFont;
216 TQString m_custom;
217 TQString m_prefix;
218 TQString m_suffix;
219 int m_align;
220
221 class Private;
222 Private *d; // define operator= and copy ctor when using this!
223
233 struct
234 {
235 int number;
236 TQString text;
237 int width;
238 KoTextParag *parent;
239 KoTextFormat * counterFormat;
240 } m_cache;
241};
242
243#endif
A generic style, i.e.
Used during loading of Oasis format (and discarded at the end of the loading).
This is the structure associated with a paragraph (KoTextParag), to define the bullet or numbering of...
int width(const KoTextParag *paragraph)
Work out the width of the text required for this counter.
static KoTextFormat * counterFormat(const KoTextParag *paragraph)
Return the format to use for the counter.
int number(const KoTextParag *paragraph)
Return the current value of the counter as a number.
TQString text(const KoTextParag *paragraph)
Return the current value of the counter as a text.
Each character (KoTextStringChar) points to a KoTextFormat that defines the formatting of that charac...
A class for writing out XML (to any TQIODevice), with a special attention on performance.
Definition KoXmlWriter.h:37