Subversion Repositories Scribus

Rev

Rev 22635 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
364 Franz 7
/***************************************************************************
8
 *   Copyright (C) 2004 by Riku Leino                                      *
1184 tsoots 9
 *   tsoots@gmail.com                                                      *
364 Franz 10
 *                                                                         *
11
 *   This program is free software; you can redistribute it and/or modify  *
12
 *   it under the terms of the GNU General Public License as published by  *
13
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 *   (at your option) any later version.                                   *
15
 *                                                                         *
16
 *   This program is distributed in the hope that it will be useful,       *
17
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
18
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
19
 *   GNU General Public License for more details.                          *
20
 *                                                                         *
21
 *   You should have received a copy of the GNU General Public License     *
22
 *   along with this program; if not, write to the                         *
23
 *   Free Software Foundation, Inc.,                                       *
18122 mrdocs 24
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
364 Franz 25
 ***************************************************************************/
26
 
27
#include "gtparagraphstyle.h"
2714 craig 28
#include "scribusstructs.h"
364 Franz 29
 
22635 craig 30
gtParagraphStyle::gtParagraphStyle(const QString& name) :
31
        gtStyle(name)
364 Franz 32
{
33
        init();
34
}
35
 
36
gtParagraphStyle::gtParagraphStyle(const gtParagraphStyle& p) : gtStyle(p)
37
{
10111 jghali 38
        defaultStyle    = false;
364 Franz 39
        lineSpacing     = p.lineSpacing;
40
        alignment       = p.alignment;
41
        indent          = p.indent;
42
        firstLineIndent = p.firstLineIndent;
43
        spaceAbove      = p.spaceAbove;
44
        spaceBelow      = p.spaceBelow;
45
        dropCap         = p.dropCap;
18047 craig 46
        m_bullet          = p.m_bullet;
47
        m_bulletStr       = p.m_bulletStr;
364 Franz 48
        dropCapHeight   = p.dropCapHeight;
18047 craig 49
        m_numeration      = p.m_numeration;
50
        m_numFormat       = p.m_numFormat;
51
        m_numLevel        = p.m_numLevel;
52
        m_numStart        = p.m_numStart;
53
        m_numPrefix       = p.m_numPrefix;
54
        m_numSuffix       = p.m_numSuffix;
364 Franz 55
        adjToBaseline   = p.adjToBaseline;
411 Franz 56
        autoLineSpacing = p.autoLineSpacing;
57
        isVisible       = p.isVisible;
12895 jghali 58
        flags           = p.flags;
364 Franz 59
}
60
 
61
gtParagraphStyle::gtParagraphStyle(const gtStyle& s) : gtStyle(s)
62
{
63
        init();
64
}
65
 
66
void gtParagraphStyle::init()
67
{
10111 jghali 68
        defaultStyle    = false;
364 Franz 69
        lineSpacing     = 15;
70
        alignment       = LEFT;
71
        indent          = 0;
72
        firstLineIndent = 0;
73
        spaceAbove      = 0;
74
        spaceBelow      = 0;
75
        dropCap         = false;
76
        dropCapHeight   = 2;
18047 craig 77
        m_bullet          = false;
78
        m_bulletStr       = QString(QChar(0x2022));
79
        m_numeration      = false;
80
        m_numFormat       = 0;
81
        m_numLevel        = 0;
82
        m_numStart        = 1;
20388 craig 83
        m_numPrefix.clear();
84
        m_numSuffix.clear();
364 Franz 85
        adjToBaseline   = false;
411 Franz 86
        autoLineSpacing = false;
87
        isVisible       = true;
12895 jghali 88
        flags           = 0;
364 Franz 89
}
90
 
23840 jghali 91
QString gtParagraphStyle::target() const
364 Franz 92
{
93
        return QString("paragraph");
94
}
95
 
23840 jghali 96
int gtParagraphStyle::getFlags() const
12895 jghali 97
{
98
        return flags;
99
}
100
 
23840 jghali 101
bool gtParagraphStyle::isDefaultStyle() const
10111 jghali 102
{
103
        return defaultStyle;
104
}
105
 
106
void gtParagraphStyle::setDefaultStyle(bool defStyle)
107
{
108
        defaultStyle = defStyle;
109
}
110
 
23840 jghali 111
double gtParagraphStyle::getLineSpacing() const
364 Franz 112
{
113
        return lineSpacing;
114
}
115
 
116
void gtParagraphStyle::setLineSpacing(double newLineSpacing)
117
{
118
        lineSpacing = newLineSpacing;
12895 jghali 119
        flags |= lineSpacingWasSet;
364 Franz 120
}
121
 
23840 jghali 122
bool gtParagraphStyle::getAutoLineSpacing() const
411 Franz 123
{
124
        return autoLineSpacing;
125
}
126
 
127
void gtParagraphStyle::setAutoLineSpacing(bool newALS)
128
{
129
        autoLineSpacing = newALS;
12895 jghali 130
        flags |= autoLineSpacingWasSet;
411 Franz 131
}
132
 
23840 jghali 133
int gtParagraphStyle::getAlignment() const
364 Franz 134
{
135
        return alignment;
136
}
137
 
138
void gtParagraphStyle::setAlignment(Alignment newAlignment)
139
{
140
        alignment = newAlignment;
12895 jghali 141
        flags |= alignmentWasSet;
364 Franz 142
}
143
 
144
void gtParagraphStyle::setAlignment(int newAlignment)
145
{
146
        if ((newAlignment > -1) && (newAlignment < AlignmentMAX))
12895 jghali 147
        {
364 Franz 148
                alignment = newAlignment;
12895 jghali 149
                flags |= alignmentWasSet;
150
        }
364 Franz 151
}
152
 
23840 jghali 153
double gtParagraphStyle::getIndent() const
364 Franz 154
{
155
        return indent;
156
}
157
 
158
void gtParagraphStyle::setIndent(double newIndent)
159
{
160
        indent = newIndent;
12895 jghali 161
        flags |= indentWasSet;
364 Franz 162
}
163
 
23840 jghali 164
double gtParagraphStyle::getFirstLineIndent() const
364 Franz 165
{
166
        return firstLineIndent;
167
}
168
 
169
void gtParagraphStyle::setFirstLineIndent(double newFirstLineIndent)
170
{
171
        firstLineIndent = newFirstLineIndent;
12895 jghali 172
        flags |= firstIndentWasSet;
364 Franz 173
}
174
 
23840 jghali 175
double gtParagraphStyle::getSpaceAbove() const
364 Franz 176
{
177
        return spaceAbove;
178
}
179
 
180
void gtParagraphStyle::setSpaceAbove(double newSpaceAbove)
181
{
182
        spaceAbove = newSpaceAbove;
12895 jghali 183
        flags |= spaceAboveWasSet;
364 Franz 184
}
185
 
23840 jghali 186
double gtParagraphStyle::getSpaceBelow() const
364 Franz 187
{
188
        return spaceBelow;
189
}
190
 
191
void gtParagraphStyle::setSpaceBelow(double newSpaceBelow)
192
{
193
        spaceBelow = newSpaceBelow;
12895 jghali 194
        flags |= spaceBelowWasSet;
364 Franz 195
}
196
 
23840 jghali 197
const QList<ParagraphStyle::TabRecord>& gtParagraphStyle::getTabValues() const
364 Franz 198
{
23840 jghali 199
        return tabValues;
364 Franz 200
}
201
 
375 Franz 202
void gtParagraphStyle::setTabValue(double newTabValue, TabType ttype)
364 Franz 203
{
5184 avox 204
        ParagraphStyle::TabRecord tb;
2282 fschmid 205
        tb.tabPosition = newTabValue;
206
        tb.tabType = ttype;
207
        tb.tabFillChar =  QChar();
208
        tabValues.append(tb);
12895 jghali 209
        flags |= tabValueWasSet;
364 Franz 210
}
211
 
23840 jghali 212
bool gtParagraphStyle::hasDropCap() const
364 Franz 213
{
214
        return dropCap;
215
}
216
 
217
void gtParagraphStyle::setDropCap(bool newDropCap)
218
{
219
        dropCap = newDropCap;
12895 jghali 220
        flags |= dropCapWasSet;
364 Franz 221
}
222
 
223
void gtParagraphStyle::setDropCap(int newHeight)
224
{
225
        setDropCap(true);
226
        dropCapHeight = newHeight;
12895 jghali 227
        flags |= dropCapHeightWasSet;
364 Franz 228
}
229
 
23840 jghali 230
int gtParagraphStyle::getDropCapHeight() const
364 Franz 231
{
232
        return dropCapHeight;
233
}
234
 
235
void   gtParagraphStyle::setDropCapHeight(int newHeight)
236
{
237
        dropCapHeight = newHeight;
12895 jghali 238
        flags |= dropCapHeightWasSet;
364 Franz 239
}
240
 
23840 jghali 241
bool gtParagraphStyle::hasBullet() const
18047 craig 242
{
243
        return m_bullet;
244
}
245
 
23840 jghali 246
QString  gtParagraphStyle::getBullet() const
18047 craig 247
{
248
        return m_bulletStr;
249
}
250
 
22635 craig 251
void gtParagraphStyle::setBullet(bool newBullet, const QString& str)
18047 craig 252
{
253
        m_bullet = newBullet;
18084 jghali 254
        if (str != "")
255
                m_bulletStr = str;
256
        else
257
                m_bulletStr = QString(QChar(0x2022));
18047 craig 258
        flags |= bulletWasSet;
259
}
260
 
23840 jghali 261
bool gtParagraphStyle::hasNum() const
18047 craig 262
{
263
        return m_numeration;
264
}
265
 
22635 craig 266
void gtParagraphStyle::setNum(bool newNum, int format, int level, int start, const QString& prefix, const QString& suffix)
18047 craig 267
{
268
        m_numeration = newNum;
269
        if (newNum)
270
        {
271
                m_numFormat = format;
272
                m_numLevel = level;
273
                m_numStart = start;
274
                m_numPrefix = prefix;
275
                m_numSuffix = suffix;
276
        }
277
        flags |= numWasSet;
278
}
279
 
23840 jghali 280
int gtParagraphStyle::getNumLevel() const
18047 craig 281
{
282
        return m_numLevel;
283
}
284
 
23840 jghali 285
int gtParagraphStyle::getNumFormat() const
18047 craig 286
{
287
        return m_numFormat;
288
}
289
 
23840 jghali 290
int gtParagraphStyle::getNumStart() const
18047 craig 291
{
292
        return m_numStart;
293
}
294
 
23840 jghali 295
QString gtParagraphStyle::getNumPrefix() const
18047 craig 296
{
297
        return m_numPrefix;
298
}
299
 
23840 jghali 300
QString gtParagraphStyle::getNumSuffix() const
18047 craig 301
{
302
        return m_numSuffix;
303
}
304
 
23840 jghali 305
bool gtParagraphStyle::isAdjToBaseline() const
364 Franz 306
{
307
        return adjToBaseline;
308
}
309
 
310
void gtParagraphStyle::setAdjToBaseline(bool newAdjToBaseline)
311
{
312
        adjToBaseline = newAdjToBaseline;
12895 jghali 313
        flags |= adjToBaselineWasSet;
364 Franz 314
}
315
 
316
void gtParagraphStyle::getStyle(gtStyle* style)
317
{
318
        *style = gtStyle(*this);
319
}