00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <QString>
00021 #include <koffice_export.h>
00022 class QDomElement;
00023 class KoXmlWriter;
00024 class KoGenStyle;
00025 class KoTextParag;
00026 class KoTextFormat;
00027 class KoOasisContext;
00028
00029 #ifndef koparagcounter_h
00030 #define koparagcounter_h
00031
00036 class KOTEXT_EXPORT KoParagCounter
00037 {
00038 public:
00039 KoParagCounter();
00040
00043 void invalidate();
00044
00047 int number( const KoTextParag *paragraph );
00051 QString levelText( const KoTextParag *paragraph );
00056 QString text( const KoTextParag *paragraph );
00057
00062 int width( const KoTextParag *paragraph );
00063
00068 int bulletX();
00069
00071 void load( QDomElement & element );
00073 void save( QDomElement & element );
00083 void loadOasis( KoOasisContext& context, int restartNumbering, bool orderedList, bool heading, int level, bool loadingStyle = false );
00085 void loadOasisListStyle( const QDomElement& listStyle,
00086 const QDomElement& listStyleProperties,
00087 const QDomElement& listStyleTextProperties,
00088 int restartNumbering,
00089 bool orderedList, bool heading, int level, bool loadingStyle );
00091 void saveOasis( KoGenStyle& listStyle, bool savingStyle = false ) const;
00094 void saveOasisListLevel( KoXmlWriter& listLevelWriter, bool includeLevelAndProperties, bool savingStyle = false ) const;
00095
00096 bool operator==( const KoParagCounter & c2 ) const;
00097 bool operator!=( const KoParagCounter & c2 ) const { return !(*this == c2); }
00098
00099 enum Numbering
00100 {
00101 NUM_NONE = 2,
00102
00103
00104 NUM_LIST = 0,
00105 NUM_CHAPTER = 1,
00106 NUM_FOOTNOTE = 3
00107 };
00108 enum Style
00109 {
00110 STYLE_NONE = 0,
00111 STYLE_NUM = 1, STYLE_ALPHAB_L = 2, STYLE_ALPHAB_U = 3,
00112 STYLE_ROM_NUM_L = 4, STYLE_ROM_NUM_U = 5, STYLE_CUSTOMBULLET = 6,
00113 STYLE_CUSTOM = 7, STYLE_CIRCLEBULLET = 8, STYLE_SQUAREBULLET = 9,
00114 STYLE_DISCBULLET = 10, STYLE_BOXBULLET = 11
00115 };
00116
00119 Numbering numbering() const;
00120 void setNumbering( Numbering n );
00121
00122 Style style() const;
00123 void setStyle( Style s );
00124
00129 bool restartCounter() const;
00130 void setRestartCounter( bool restart );
00131
00134 bool isBullet() const;
00138 static bool isBullet( Style style );
00139
00143 unsigned int depth() const;
00144 void setDepth( unsigned int d );
00145
00148 int displayLevels() const;
00149 void setDisplayLevels( int l );
00150
00153 int startNumber() const;
00154 void setStartNumber( int s );
00155
00158 QString prefix() const;
00159 void setPrefix( const QString & p );
00160 QString suffix() const;
00161 void setSuffix( const QString & s );
00162
00165 QChar customBulletCharacter() const;
00166 void setCustomBulletCharacter( QChar c );
00167 QString customBulletFont() const;
00168 void setCustomBulletFont( const QString & f );
00169
00172 QString custom() const;
00173 void setCustom( const QString & c );
00174
00177 int alignment() const;
00178 void setAlignment( int a );
00179
00184 static KoTextFormat* counterFormat( const KoTextParag *paragraph );
00185
00186 static QString makeRomanNumber( int n );
00187 static QString makeAlphaUpperNumber( int n );
00188 static QString makeAlphaLowerNumber( int n );
00189
00190 static int fromRomanNumber( const QString & );
00191 static int fromAlphaUpperNumber( const QString & );
00192 static int fromAlphaLowerNumber( const QString & );
00193
00194 #ifndef NDEBUG
00195 void printRTDebug( KoTextParag* parag );
00196 #endif
00197
00198 private:
00199
00203 KoTextParag *parent( const KoTextParag *paragraph );
00204
00205 Numbering m_numbering:3;
00206 bool m_restartCounter:1;
00207 bool unused:4;
00208 Style m_style:8;
00209 char m_displayLevels;
00210 char m_depth;
00211
00212 short int m_startNumber;
00213 QChar m_customBulletChar;
00214
00215 QString m_customBulletFont;
00216 QString m_custom;
00217 QString m_prefix;
00218 QString m_suffix;
00219 int m_align;
00220
00221 class Private;
00222 Private *d;
00223
00233 struct
00234 {
00235 int number;
00236 QString text;
00237 int width;
00238 KoTextParag *parent;
00239 KoTextFormat * counterFormat;
00240 } m_cache;
00241 };
00242
00243 #endif