lib

KoParagLayout.h
1/* This file is part of the KDE project
2 Copyright (C) 2001 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef koparaglayout_h
21#define koparaglayout_h
22
23#include <KoRuler.h> // for KoTabulatorList
24#include <tqdom.h>
25#include "KoBorder.h"
26#include <koffice_export.h>
27class KoSavingContext;
28class KoGenStyle;
29class KoParagCounter;
30class KoParagStyle;
31class KoOasisContext;
32class TQColor;
33
39class KOTEXT_EXPORT KoParagLayout
40{
41public:
43 KoParagLayout( const KoParagLayout &layout ) { operator=( layout ); }
44
46
49 enum { Alignment = 1,
50 BulletNumber = 2, // TODO: we can use Counter now :)
51 Margins = 4,
52 LineSpacing = 8,
53 Borders = 16,
54 Tabulator = 32,
55 PageBreaking = 64,
56 BackgroundColor = 128,
57 /* Style is maybe missing */
58 All = Alignment | BulletNumber | Margins | LineSpacing |
59 Borders | Tabulator | PageBreaking | BackgroundColor
60 } Flags;
61
63 enum {
64 BreakBetweenLines = 0, // default
65 KeepLinesTogether = 1,
66 HardFrameBreakBefore = 2, // incompatible with KeepWithPrevious
67 HardFrameBreakAfter = 4, // incompatible with KeepWithNext
68 KeepWithPrevious = 8, // incompatible with HardFrameBreakBefore
69 KeepWithNext = 16 // incompatible with HardFrameBreakAfter
70 };
71
72 // This class is used as a struct, which explains the public vars :)
74 double margins[5];
86 enum SpacingType { LS_SINGLE = 0, LS_ONEANDHALF = -1, LS_DOUBLE = -2,
87 LS_CUSTOM = -3, LS_AT_LEAST = -4, LS_MULTIPLE = -5, LS_FIXED = -6 };
88 SpacingType lineSpacingType;
89 double lineSpacingValue() const { return lineSpacing;}
90 void setLineSpacingValue(double _value) { lineSpacing = _value;}
91
92 static TQString* shadowCssCompat; // used for compat with koffice-1.2 when loading
93
94 bool joinBorder:1;
95 bool unused:7; // for future use
96 char pageBreaking; // Page breaking flags
97 char direction; // TQChar::Direction
99 char alignment; // TQt::AlignmentFlags
100 KoBorder leftBorder, rightBorder, topBorder, bottomBorder;
101
103
110
113
114 KoParagStyle* style;
115
116 bool hasBorder() const { return topBorder.penWidth() > 0
117 || bottomBorder.penWidth() > 0
118 || leftBorder.penWidth() > 0
119 || rightBorder.penWidth() > 0; }
120
121 void setTabList( const KoTabulatorList & tabList ) { m_tabList = tabList; }
122 const KoTabulatorList& tabList() const { return m_tabList; }
123
125
130 void operator=( const KoParagLayout & );
131
133 int compare( const KoParagLayout & layout ) const;
134
138 void saveParagLayout( TQDomElement & parentElem, int alignment ) const;
139
143 static void loadParagLayout( KoParagLayout& layout, const TQDomElement& parentElem, int docVersion = 2 );
144
146 static void loadOasisParagLayout( KoParagLayout& layout, KoOasisContext& context );
152 void saveOasis( KoGenStyle& gs, KoSavingContext& context, bool savingStyle ) const;
153
155 static TQt::AlignmentFlags loadOasisAlignment( const TQCString& str );
157 static TQCString saveOasisAlignment( TQt::AlignmentFlags alignment );
158
159private:
160 static int getAttribute(const TQDomElement &element, const char *attributeName, int defaultValue) {
161 TQString value = element.attribute( attributeName );
162 return value.isNull() ? defaultValue : value.toInt();
163 }
164
165 static double getAttribute(const TQDomElement &element, const char *attributeName, double defaultValue) {
166 TQString value = element.attribute( attributeName );
167 return value.isNull() ? defaultValue : value.toDouble();
168 }
169
170private:
171 KoTabulatorList m_tabList;
172 double lineSpacing;
173 class Private;
174 Private *d;
175
177 void initialise();
178};
179
180#endif
This class represents a border - for anything, like paragraph, or frame.
Definition KoBorder.h:34
A generic style, i.e.
Used during loading of Oasis format (and discarded at the end of the loading).
This is the structure associated with a paragraph (KoTextParag), to define the bullet or numbering of...
This class holds the paragraph-specific formatting information It's separated from KoTextParag so tha...
SpacingType
Line spacing values Assuming h is the height of the biggest char in the line, and v is the linespacin...
TQColor backgroundColor
The background color of the paragraph.
KoParagCounter * counter
can be 0 if no counter set
char alignment
Alignment flag (AlignAuto/AlignLeft/AlignRight/AlignJustify)
A paragraph style is a combination of a character style and paragraph-layout attributes,...
Used during saving to Oasis format (and discarded at the end of the saving).