lib Library API Documentation

kostyle.h

00001 /* This file is part of the KDE project 00002 Copyright (C) 2001 David Faure <faure@kde.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 #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 00028 class KoStyle; 00029 00030 struct StyleChangeDef { 00031 StyleChangeDef() { 00032 paragLayoutChanged = -1; 00033 formatChanged = -1; 00034 } 00035 StyleChangeDef( int parag, int format) { 00036 paragLayoutChanged = parag; 00037 formatChanged = format; 00038 }; 00039 int paragLayoutChanged; 00040 int formatChanged; 00041 }; 00042 typedef QMap<KoStyle *, StyleChangeDef> StyleChangeDefMap; 00043 00044 class KoStyleCollection 00045 { 00046 public: 00047 KoStyleCollection(); 00048 ~KoStyleCollection(); 00049 const QPtrList<KoStyle> & styleList() const { return m_styleList; } 00050 00051 KoStyle* findStyle( const QString & name ); 00052 KoStyle* findStyleShortCut( const QString & _shortCut ); 00056 KoStyle* styleAt( int i ) { return m_styleList.at(i); } 00057 00058 KoStyle* addStyleTemplate( KoStyle *style ); 00059 00060 void removeStyleTemplate ( KoStyle *style ); 00061 00062 void updateStyleListOrder( const QStringList &list ); 00063 00064 private: 00065 QPtrList<KoStyle> m_styleList; 00066 QPtrList<KoStyle> m_deletedStyles; 00067 static int styleNumber; 00068 KoStyle *m_lastStyle; 00069 }; 00070 00071 class KoCharStyle 00072 { 00073 public: 00075 KoCharStyle( const QString & name ); 00076 00078 KoCharStyle( const KoCharStyle & rhs ) { *this = rhs; } 00079 00080 virtual ~KoCharStyle() {} 00081 00084 const KoTextFormat & format() const; 00085 KoTextFormat & format(); 00086 00087 void operator=( const KoCharStyle & ); 00088 00090 QString name() const { return m_name; } 00091 void setName( const QString & name ) { m_name = name; } 00093 QString translatedName() const; 00094 00095 QString shortCutName() const { 00096 return m_shortCut_name; 00097 } 00098 00099 void setShortCutName( const QString & _shortCut) { 00100 m_shortCut_name=_shortCut; 00101 } 00102 00103 protected: 00104 QString m_name; 00105 QString m_shortCut_name; 00106 KoTextFormat m_format; 00107 }; 00108 00113 class KoStyle : public KoCharStyle 00114 { 00115 public: 00117 KoStyle( const QString & name ); 00118 00120 KoStyle( const KoStyle & rhs ); 00121 00122 ~KoStyle() {} 00123 00124 void operator=( const KoStyle & ); 00125 00126 00127 const KoParagLayout & paragLayout() const; 00128 KoParagLayout & paragLayout(); 00129 00130 KoStyle *followingStyle() const { return m_followingStyle; } 00131 void setFollowingStyle( KoStyle *fst ) { m_followingStyle = fst; } 00132 00133 // Saves the name, layout, the following style and the outline bool. Not the format. 00134 void saveStyle( QDomElement & parentElem ); 00135 // Loads the name, layout and the outline bool. Not the "following style" nor the format. 00136 void loadStyle( QDomElement & parentElem, int docVersion = 2 ); 00137 00138 static int getAttribute(const QDomElement &element, const char *attributeName, int defaultValue) 00139 { 00140 QString value = element.attribute( attributeName ); 00141 return value.isNull() ? defaultValue : value.toInt(); 00142 } 00143 00144 static double getAttribute(const QDomElement &element, const char *attributeName, double defaultValue) 00145 { 00146 QString value = element.attribute( attributeName ); 00147 return value.isNull() ? defaultValue : value.toDouble(); 00148 } 00149 00150 KoStyle * parentStyle() const {return m_parentStyle;} 00151 void setParentStyle( KoStyle *_style){ m_parentStyle = _style;} 00152 00153 int inheritedParagLayoutFlag() const { return m_inheritedParagLayoutFlag; } 00154 int inheritedFormatFlag() const { return m_inheritedFormatFlag; } 00155 00156 void propagateChanges( int paragLayoutFlag, int formatFlag ); 00157 00158 // If true, paragraphs with this style will be included in the table of contents 00159 bool isOutline() const { return m_bOutline; } 00160 void setOutline( bool b ); 00161 00162 private: 00163 KoParagLayout m_paragLayout; 00164 KoStyle *m_followingStyle; 00165 KoStyle *m_parentStyle; 00166 int m_inheritedParagLayoutFlag; 00167 int m_inheritedFormatFlag; 00168 bool m_bOutline; 00169 }; 00170 00171 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 06:54:18 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003