1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
/* This file is part of the KDE project
Copyright (C) 2001 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef koparaglayout_h
#define koparaglayout_h
#include <KoRuler.h> // for KoTabulatorList
#include <tqdom.h>
#include "KoBorder.h"
#include <koffice_export.h>
class KoSavingContext;
class KoGenStyle;
class KoParagCounter;
class KoParagStyle;
class KoOasisContext;
class TQColor;
/**
* This class holds the paragraph-specific formatting information
* It's separated from KoTextParag so that it can be copied in
* the undo/redo history, and in KoParagStyle.
*/
class KOTEXT_EXPORT KoParagLayout
{
public:
KoParagLayout();
KoParagLayout( const KoParagLayout &tqlayout ) { operator=( tqlayout ); }
~KoParagLayout();
/** This enum is used to mark parts of a KoParagLayout as changed
* (i.e. when changing them in the dialog/stylist) */
enum { Alignment = 1,
BulletNumber = 2, // TODO: we can use Counter now :)
Margins = 4,
LineSpacing = 8,
Borders = 16,
Tabulator = 32,
PageBreaking = 64,
BackgroundColor = 128,
/* Style is maybe missing */
All = Alignment | BulletNumber | Margins | LineSpacing |
Borders | Tabulator | PageBreaking | BackgroundColor
} Flags;
/** Page breaking flags */
enum {
BreakBetweenLines = 0, // default
KeepLinesTogether = 1,
HardFrameBreakBefore = 2, // incompatible with KeepWithPrevious
HardFrameBreakAfter = 4, // incompatible with KeepWithNext
KeepWithPrevious = 8, // incompatible with HardFrameBreakBefore
KeepWithNext = 16 // incompatible with HardFrameBreakAfter
};
// This class is used as a struct, which explains the public vars :)
/** left, right, top, bottom, firstLineSpacing - in pt */
double margins[5];
/**
* Line spacing values
* Assuming h is the height of the biggest char in the line,
* and v is the linespacing value, the total line height is:
*
* Single: h
* 1.5/2/multiple: v*h
* Custom (aka "line distance"): h + v
* At least: >= v
* Fixed: v
*/
enum SpacingType { LS_SINGLE = 0, LS_ONEANDHALF = -1, LS_DOUBLE = -2,
LS_CUSTOM = -3, LS_AT_LEAST = -4, LS_MULTIPLE = -5, LS_FIXED = -6 };
SpacingType lineSpacingType;
double lineSpacingValue() const { return lineSpacing;}
void setLineSpacingValue(double _value) { lineSpacing = _value;}
static TQString* shadowCssCompat; // used for compat with koffice-1.2 when loading
bool joinBorder:1;
bool unused:7; // for future use
char pageBreaking; // Page breaking flags
char direction; // TQChar::Direction
/// Alignment flag (AlignAuto/AlignLeft/AlignRight/AlignJustify)
char alignment; // TQt::AlignmentFlags
KoBorder leftBorder, rightBorder, topBorder, bottomBorder;
/// The background color of the paragraph
/**
* The background color is used for text that has no background color set,
* and for parts of the paragraph that are not covered by text.
* In theory anyway: the background colour isn't used in rendering text
* yet, but it's nice to preserve the value.
*/
TQColor backgroundColor;
/** can be 0 if no counter set */
KoParagCounter* counter;
KoParagStyle* style;
bool hasBorder() const { return topBorder.penWidth() > 0
|| bottomBorder.penWidth() > 0
|| leftBorder.penWidth() > 0
|| rightBorder.penWidth() > 0; }
void setTabList( const KoTabulatorList & tabList ) { m_tabList = tabList; }
const KoTabulatorList& tabList() const { return m_tabList; }
//! Assignment operator for KoParagLayout
/** Copy a paragraph tqlayout.
*
* If you're modifying this, you might also need to modify
* KoTextParag::setParagLayout
*/
void operator=( const KoParagLayout & );
/** Return a set of flags showing the differences between this and 'tqlayout' */
int compare( const KoParagLayout & tqlayout ) const;
/** Save this parag tqlayout to XML.
* This format is used by KWord for paragraphs, and by KPresenter+KWord for styles.
*/
void saveParagLayout( TQDomElement & parentElem, int alignment ) const;
/** Load this parag tqlayout from XML.
* This format is used by KWord for paragraphs, and by KPresenter+KWord for styles.
*/
static void loadParagLayout( KoParagLayout& tqlayout, const TQDomElement& parentElem, int docVersion = 2 );
/// Load this parag tqlayout from Oasis XML
static void loadOasisParagLayout( KoParagLayout& tqlayout, KoOasisContext& context );
/// Save this parag tqlayout to Oasis XML
/// @param savingStyle true if this is saved as part of a user style,
/// false when saving a paragraph
/// @param gs the style where all the properties will be saved to
/// @param context the current context
void saveOasis( KoGenStyle& gs, KoSavingContext& context, bool savingStyle ) const;
/// Convert an alignment string into an alignment flag (load)
static TQt::AlignmentFlags loadOasisAlignment( const TQCString& str );
/// Convert an alignment flag into an alignment string (save)
static TQCString saveOasisAlignment( TQt::AlignmentFlags alignment );
private:
static int getAttribute(const TQDomElement &element, const char *attributeName, int defaultValue) {
TQString value = element.attribute( attributeName );
return value.isNull() ? defaultValue : value.toInt();
}
static double getAttribute(const TQDomElement &element, const char *attributeName, double defaultValue) {
TQString value = element.attribute( attributeName );
return value.isNull() ? defaultValue : value.toDouble();
}
private:
KoTabulatorList m_tabList;
double lineSpacing;
class Private;
Private *d;
/** Common setup. */
void initialise();
};
#endif
|