lib Library API Documentation

koparagcounter.h

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., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #include <qstring.h>
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 );
00079     void loadOasis( KoOasisContext& context, int restartNumbering, bool orderedList, bool heading, int level, bool loadingStyle = false );
00081     void loadOasisListStyle( const QDomElement& listStyle,
00082                              const QDomElement& listStyleProperties,
00083                              int restartNumbering,
00084                              bool orderedList, bool heading, int level, bool loadingStyle );
00086     void saveOasis( KoGenStyle& listStyle, bool savingStyle = false ) const;
00089     void saveOasisListLevel( KoXmlWriter& listLevelWriter, bool includeLevelAndProperties, bool savingStyle = false ) const;
00090 
00091     bool operator==( const KoParagCounter & c2 ) const;
00092     bool operator!=( const KoParagCounter & c2 ) const { return !(*this == c2); }
00093 
00094     enum Numbering
00095     {
00096         NUM_NONE = 2,       // Unnumbered. Equivalent to there being
00097                             // no counter structure associated with a
00098                             // paragraph.
00099         NUM_LIST = 0,       // Numbered as a list item.
00100         NUM_CHAPTER = 1,    // Numbered as a heading.
00101         NUM_FOOTNOTE = 3   // Fixed text counter, set by the code. This is used by e.g. footnotes.
00102     };
00103     enum Style // always add to the end, the numeric values are part of the DTD
00104     {
00105         STYLE_NONE = 0,
00106         STYLE_NUM = 1, STYLE_ALPHAB_L = 2, STYLE_ALPHAB_U = 3,
00107         STYLE_ROM_NUM_L = 4, STYLE_ROM_NUM_U = 5, STYLE_CUSTOMBULLET = 6,
00108         STYLE_CUSTOM = 7, STYLE_CIRCLEBULLET = 8, STYLE_SQUAREBULLET = 9,
00109         STYLE_DISCBULLET = 10, STYLE_BOXBULLET = 11
00110     };
00111 
00114     Numbering numbering() const;
00115     void setNumbering( Numbering n );
00116 
00117     Style style() const;
00118     void setStyle( Style s );
00119 
00124     bool restartCounter() const;
00125     void setRestartCounter( bool restart );
00126 
00129     bool isBullet() const;
00133     static bool isBullet( Style style );
00134 
00138     unsigned int depth() const;
00139     void setDepth( unsigned int d );
00140 
00143     int displayLevels() const;
00144     void setDisplayLevels( int l );
00145 
00148     int startNumber() const;
00149     void setStartNumber( int s );
00150 
00153     QString prefix() const;
00154     void setPrefix( QString p );
00155     QString suffix() const;
00156     void setSuffix( QString s );
00157 
00160     QChar customBulletCharacter() const;
00161     void setCustomBulletCharacter( QChar c );
00162     QString customBulletFont() const;
00163     void setCustomBulletFont( QString f );
00164 
00167     QString custom() const;
00168     void setCustom( QString c );
00169 
00172     int alignment() const;
00173     void setAlignment( int a );
00174 
00179     static KoTextFormat* counterFormat( const KoTextParag *paragraph );
00180 
00181     static QString makeRomanNumber( int n );
00182     static QString makeAlphaUpperNumber( int n );
00183     static QString makeAlphaLowerNumber( int n );
00184 
00185     static int fromRomanNumber( const QString & );
00186     static int fromAlphaUpperNumber( const QString & );
00187     static int fromAlphaLowerNumber( const QString & );
00188 
00189 #ifndef NDEBUG
00190     void printRTDebug( KoTextParag* parag );
00191 #endif
00192 
00193 private:
00194 
00198     KoTextParag *parent( const KoTextParag *paragraph );
00199 
00200     Numbering m_numbering:3; // Numbering (maximum value: 8)
00201     bool m_restartCounter:1;
00202     bool unused:4;
00203     Style m_style:8;     // Style
00204     char m_displayLevels; // Number of levels to display (e.g. 3 => 1.2.1)
00205     char m_depth;
00206 
00207     short int m_startNumber;
00208     QChar m_customBulletChar;
00209 
00210     QString m_customBulletFont;
00211     QString m_custom;
00212     QString m_prefix;
00213     QString m_suffix;
00214     int m_align;
00215 
00216     class Private;
00217     Private *d; // define operator= and copy ctor when using this!
00218 
00228     struct
00229     {
00230         int number;
00231         QString text;
00232         int width;
00233         KoTextParag *parent;
00234         KoTextFormat * counterFormat;
00235     } m_cache;
00236 };
00237 
00238 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:02 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003