F:/KPlato/koffice/libs/kotext/KoParagCounter.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Shaheed Haque <srhaque@iee.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
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,       // Unnumbered. Equivalent to there being
00102                             // no counter structure associated with a
00103                             // paragraph.
00104         NUM_LIST = 0,       // Numbered as a list item.
00105         NUM_CHAPTER = 1,    // Numbered as a heading.
00106         NUM_FOOTNOTE = 3   // Fixed text counter, set by the code. This is used by e.g. footnotes.
00107     };
00108     enum Style // always add to the end, the numeric values are part of the DTD
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; // Numbering (maximum value: 8)
00206     bool m_restartCounter:1;
00207     bool unused:4;
00208     Style m_style:8;     // Style
00209     char m_displayLevels; // Number of levels to display (e.g. 3 => 1.2.1)
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; // define operator= and copy ctor when using this!
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

Généré le Wed Nov 22 23:41:08 2006 pour KPlato par  doxygen 1.5.1-p1