00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef koparaglayout_h
00021 #define koparaglayout_h
00022
00023 #include <KoTabulator.h>
00024 #include <qdom.h>
00025
00026 #include <QByteArray>
00027 #include "KoBorder.h"
00028 #include <koffice_export.h>
00029 class KoSavingContext;
00030 class KoGenStyle;
00031 class KoParagCounter;
00032 class KoParagStyle;
00033 class KoOasisContext;
00034 class QColor;
00035
00041 class KOTEXT_EXPORT KoParagLayout
00042 {
00043 public:
00044 KoParagLayout();
00045 KoParagLayout( const KoParagLayout &layout ) { operator=( layout ); }
00046
00047 ~KoParagLayout();
00048
00051 enum { Alignment = 1,
00052 BulletNumber = 2,
00053 Margins = 4,
00054 LineSpacing = 8,
00055 Borders = 16,
00056 Tabulator = 32,
00057 PageBreaking = 64,
00058 BackgroundColor = 128,
00059
00060 All = Alignment | BulletNumber | Margins | LineSpacing |
00061 Borders | Tabulator | PageBreaking | BackgroundColor
00062 } Flags;
00063
00065 enum {
00066 BreakBetweenLines = 0,
00067 KeepLinesTogether = 1,
00068 HardFrameBreakBefore = 2,
00069 HardFrameBreakAfter = 4,
00070 KeepWithPrevious = 8,
00071 KeepWithNext = 16
00072 };
00073
00074
00076 double margins[5];
00088 enum SpacingType { LS_SINGLE = 0, LS_ONEANDHALF = -1, LS_DOUBLE = -2,
00089 LS_CUSTOM = -3, LS_AT_LEAST = -4, LS_MULTIPLE = -5, LS_FIXED = -6 };
00090 SpacingType lineSpacingType;
00091 double lineSpacingValue() const { return lineSpacing;}
00092 void setLineSpacingValue(double _value) { lineSpacing = _value;}
00093
00094 static QString* shadowCssCompat;
00095
00096 bool joinBorder:1;
00097 bool unused:7;
00098 char pageBreaking;
00099 char direction;
00101 char alignment;
00102 KoBorder leftBorder, rightBorder, topBorder, bottomBorder;
00103
00105
00111 QColor backgroundColor;
00112
00114 KoParagCounter* counter;
00115
00116 KoParagStyle* style;
00117
00118 bool hasBorder() const { return topBorder.penWidth() > 0
00119 || bottomBorder.penWidth() > 0
00120 || leftBorder.penWidth() > 0
00121 || rightBorder.penWidth() > 0; }
00122
00123 void setTabList( const KoTabulatorList & tabList ) { m_tabList = tabList; }
00124 const KoTabulatorList& tabList() const { return m_tabList; }
00125
00127
00132 void operator=( const KoParagLayout & );
00133
00135 int compare( const KoParagLayout & layout ) const;
00136
00140 void saveParagLayout( QDomElement & parentElem, int alignment ) const;
00141
00145 static void loadParagLayout( KoParagLayout& layout, const QDomElement& parentElem, int docVersion = 2 );
00146
00148 static void loadOasisParagLayout( KoParagLayout& layout, KoOasisContext& context );
00154 void saveOasis( KoGenStyle& gs, KoSavingContext& context, bool savingStyle ) const;
00155
00157 static Qt::AlignmentFlag loadOasisAlignment( const QByteArray& str );
00159 static QByteArray saveOasisAlignment( Qt::AlignmentFlag alignment );
00160
00161 private:
00162 static int getAttribute(const QDomElement &element, const char *attributeName, int defaultValue) {
00163 QString value = element.attribute( attributeName );
00164 return value.isNull() ? defaultValue : value.toInt();
00165 }
00166
00167 static double getAttribute(const QDomElement &element, const char *attributeName, double defaultValue) {
00168 QString value = element.attribute( attributeName );
00169 return value.isNull() ? defaultValue : value.toDouble();
00170 }
00171
00172 private:
00173 KoTabulatorList m_tabList;
00174 double lineSpacing;
00175 class Private;
00176 Private *d;
00177
00179 void initialise();
00180 };
00181
00182 #endif