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
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
00134
void saveStyle(
QDomElement & parentElem );
00135
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
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