kostyle.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef kostyle_h
00021 #define kostyle_h
00022
00023 #include "kotextformat.h"
00024 #include "koparaglayout.h"
00025 #include <qdom.h>
00026 #include <qptrlist.h>
00027 #include <qvaluevector.h>
00028
00029 class KoGenStyles;
00030 class KoParagStyle;
00031 class KoOasisContext;
00032 class KoSavingContext;
00033
00034 struct KoStyleChangeDef {
00035 KoStyleChangeDef() {
00036 paragLayoutChanged = -1;
00037 formatChanged = -1;
00038 }
00039 KoStyleChangeDef( int parag, int format) {
00040 paragLayoutChanged = parag;
00041 formatChanged = format;
00042 };
00043 int paragLayoutChanged;
00044 int formatChanged;
00045 };
00046 typedef QMap<KoParagStyle *, KoStyleChangeDef> KoStyleChangeDefMap;
00047
00048 class KOTEXT_EXPORT KoStyleCollection
00049 {
00050 public:
00051 KoStyleCollection();
00052 ~KoStyleCollection();
00053
00054 const QPtrList<KoParagStyle> & styleList() const { return m_styleList; }
00055 QStringList translatedStyleNames() const;
00056
00060 KoParagStyle* findStyle( const QString & name ) const;
00064 KoParagStyle* findTranslatedStyle( const QString & name ) const;
00065
00066 KoParagStyle* findStyleShortCut( const QString & _shortCut ) const;
00070 KoParagStyle* styleAt( int i ) { return m_styleList.at(i); }
00071
00072
00073 KoParagStyle* addStyleTemplate( KoParagStyle *style );
00074
00075 void removeStyleTemplate ( KoParagStyle *style );
00076
00078 void importStyles( const QPtrList<KoParagStyle>& styleList );
00079
00081 void updateStyleListOrder( const QStringList &list );
00082
00083 void loadOasisStyleTemplates( KoOasisContext& context );
00084
00088 QMap<KoParagStyle*, QString> saveOasis( KoGenStyles& styles, int styleType, KoSavingContext& context ) const;
00089
00091 void saveOasisOutlineStyles( KoXmlWriter& writer ) const;
00092
00094 QValueVector<KoParagStyle *> outlineStyles() const;
00095
00097 KoParagStyle* outlineStyleForLevel( int level ) const;
00098
00100 KoParagStyle* numberedStyleForLevel( int level ) const;
00101
00106 KoParagStyle* defaultStyle() const;
00107
00108 QString generateUniqueName() const;
00109
00111 void clear();
00112
00113 #ifndef NDEBUG
00114 void printDebug() const;
00115 #endif
00116
00117 private:
00118 QPtrList<KoParagStyle> m_styleList;
00119 QPtrList<KoParagStyle> m_deletedStyles;
00120 static int styleNumber;
00121 mutable KoParagStyle *m_lastStyle;
00122 };
00123
00128 class KOTEXT_EXPORT KoCharStyle
00129 {
00130 public:
00132 KoCharStyle( const QString & name );
00133
00135 KoCharStyle( const KoCharStyle & rhs ) { *this = rhs; }
00136
00137 virtual ~KoCharStyle() {}
00138
00141 const KoTextFormat & format() const;
00142 KoTextFormat & format();
00143
00145 QString name() const { return m_name; }
00146 void setInternalName( const QString & name ) { m_name = name; }
00148 QString displayName() const;
00149 void setDisplayName( const QString& name );
00150
00151 QString shortCutName() const {
00152 return m_shortCutName;
00153 }
00154
00155 void setShortCutName( const QString & shortCut) {
00156 m_shortCutName = shortCut;
00157 }
00158
00159 protected:
00160 QString m_name;
00161 QString m_shortCutName;
00162 QString m_displayName;
00163 KoTextFormat m_format;
00164 };
00165
00170 class KOTEXT_EXPORT KoParagStyle : public KoCharStyle
00171 {
00172 public:
00174 KoParagStyle( const QString & name );
00175
00177 KoParagStyle( const KoParagStyle & rhs );
00178
00179 ~KoParagStyle();
00180
00181 void operator=( const KoParagStyle & );
00182
00183
00184 const KoParagLayout & paragLayout() const;
00185 KoParagLayout & paragLayout();
00186
00187 KoParagStyle *followingStyle() const { return m_followingStyle; }
00188 void setFollowingStyle( KoParagStyle *fst );
00189
00192 void saveStyle( QDomElement & parentElem );
00195 void loadStyle( QDomElement & parentElem, int docVersion = 2 );
00196
00198 void loadStyle( QDomElement & styleElem, KoOasisContext& context );
00201 QString saveStyle( KoGenStyles& genStyles, int styleType, const QString& parentStyleName, KoSavingContext& context ) const;
00202
00203 KoParagStyle * parentStyle() const {return m_parentStyle;}
00204 void setParentStyle( KoParagStyle *_style){ m_parentStyle = _style;}
00205
00206 int inheritedParagLayoutFlag() const { return m_inheritedParagLayoutFlag; }
00207 int inheritedFormatFlag() const { return m_inheritedFormatFlag; }
00208
00209 void propagateChanges( int paragLayoutFlag, int formatFlag );
00210
00211
00212 bool isOutline() const { return m_bOutline; }
00213 void setOutline( bool b );
00214
00215 private:
00216 KoParagLayout m_paragLayout;
00217 KoParagStyle *m_followingStyle;
00218 KoParagStyle *m_parentStyle;
00219 int m_inheritedParagLayoutFlag;
00220 int m_inheritedFormatFlag;
00221 bool m_bOutline;
00222 };
00223
00224 #endif
This file is part of the documentation for lib Library Version 1.4.2.