Subversion Repositories Scribus

Rev

Rev 18047 | Rev 18122 | Go to most recent revision | 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.,                                       *
24
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
25
 ***************************************************************************/
26
 
27
#include "gtparagraphstyle.h"
2714 craig 28
#include "scribusstructs.h"
364 Franz 29
 
30
gtParagraphStyle::gtParagraphStyle(QString name) : gtStyle(name)
31
{
32
        init();
33
}
34
 
35
gtParagraphStyle::gtParagraphStyle(const gtParagraphStyle& p) : gtStyle(p)
36
{
10111 jghali 37
        defaultStyle    = false;
364 Franz 38
        lineSpacing     = p.lineSpacing;
39
        alignment       = p.alignment;
40
        indent          = p.indent;
41
        firstLineIndent = p.firstLineIndent;
42
        spaceAbove      = p.spaceAbove;
43
        spaceBelow      = p.spaceBelow;
44
        dropCap         = p.dropCap;
18047 craig 45
        m_bullet          = p.m_bullet;
46
        m_bulletStr       = p.m_bulletStr;
364 Franz 47
        dropCapHeight   = p.dropCapHeight;
18047 craig 48
        m_numeration      = p.m_numeration;
49
        m_numFormat       = p.m_numFormat;
50
        m_numLevel        = p.m_numLevel;
51
        m_numStart        = p.m_numStart;
52
        m_numPrefix       = p.m_numPrefix;
53
        m_numSuffix       = p.m_numSuffix;
364 Franz 54
        adjToBaseline   = p.adjToBaseline;
411 Franz 55
        autoLineSpacing = p.autoLineSpacing;
56
        isVisible       = p.isVisible;
12895 jghali 57
        flags           = p.flags;
364 Franz 58
}
59
 
60
gtParagraphStyle::gtParagraphStyle(const gtStyle& s) : gtStyle(s)
61
{
62
        init();
63
}
64
 
65
void gtParagraphStyle::init()
66
{
10111 jghali 67
        defaultStyle    = false;
364 Franz 68
        lineSpacing     = 15;
69
        alignment       = LEFT;
70
        indent          = 0;
71
        firstLineIndent = 0;
72
        spaceAbove      = 0;
73
        spaceBelow      = 0;
74
        dropCap         = false;
75
        dropCapHeight   = 2;
18047 craig 76
        m_bullet          = false;
77
        m_bulletStr       = QString(QChar(0x2022));
78
        m_numeration      = false;
79
        m_numFormat       = 0;
80
        m_numLevel        = 0;
81
        m_numStart        = 1;
82
        m_numPrefix       = QString();
83
        m_numSuffix       = QString();
364 Franz 84
        adjToBaseline   = false;
411 Franz 85
        autoLineSpacing = false;
86
        isVisible       = true;
12895 jghali 87
        flags           = 0;
364 Franz 88
}
89
 
90
QString gtParagraphStyle::target()
91
{
92
        return QString("paragraph");
93
}
94
 
12895 jghali 95
int gtParagraphStyle::getFlags()
96
{
97
        return flags;
98
}
99
 
10111 jghali 100
bool gtParagraphStyle::isDefaultStyle()
101
{
102
        return defaultStyle;
103
}
104
 
105
void gtParagraphStyle::setDefaultStyle(bool defStyle)
106
{
107
        defaultStyle = defStyle;
108
}
109
 
364 Franz 110
double gtParagraphStyle::getLineSpacing()
111
{
112
        return lineSpacing;
113
}
114
 
115
void gtParagraphStyle::setLineSpacing(double newLineSpacing)
116
{
117
        lineSpacing = newLineSpacing;
12895 jghali 118
        flags |= lineSpacingWasSet;
364 Franz 119
}
120
 
411 Franz 121
bool gtParagraphStyle::getAutoLineSpacing()
122
{
123
        return autoLineSpacing;
124
}
125
 
126
void gtParagraphStyle::setAutoLineSpacing(bool newALS)
127
{
128
        autoLineSpacing = newALS;
12895 jghali 129
        flags |= autoLineSpacingWasSet;
411 Franz 130
}
131
 
364 Franz 132
int gtParagraphStyle::getAlignment()
133
{
134
        return alignment;
135
}
136
 
137
void gtParagraphStyle::setAlignment(Alignment newAlignment)
138
{
139
        alignment = newAlignment;
12895 jghali 140
        flags |= alignmentWasSet;
364 Franz 141
}
142
 
143
void gtParagraphStyle::setAlignment(int newAlignment)
144
{
145
        if ((newAlignment > -1) && (newAlignment < AlignmentMAX))
12895 jghali 146
        {
364 Franz 147
                alignment = newAlignment;
12895 jghali 148
                flags |= alignmentWasSet;
149
        }
364 Franz 150
}
151
 
152
double gtParagraphStyle::getIndent()
153
{
154
        return indent;
155
}
156
 
157
void gtParagraphStyle::setIndent(double newIndent)
158
{
159
        indent = newIndent;
12895 jghali 160
        flags |= indentWasSet;
364 Franz 161
}
162
 
163
double gtParagraphStyle::getFirstLineIndent()
164
{
165
        return firstLineIndent;
166
}
167
 
168
void gtParagraphStyle::setFirstLineIndent(double newFirstLineIndent)
169
{
170
        firstLineIndent = newFirstLineIndent;
12895 jghali 171
        flags |= firstIndentWasSet;
364 Franz 172
}
173
 
174
double gtParagraphStyle::getSpaceAbove()
175
{
176
        return spaceAbove;
177
}
178
 
179
void gtParagraphStyle::setSpaceAbove(double newSpaceAbove)
180
{
181
        spaceAbove = newSpaceAbove;
12895 jghali 182
        flags |= spaceAboveWasSet;
364 Franz 183
}
184
 
185
double gtParagraphStyle::getSpaceBelow()
186
{
187
        return spaceBelow;
188
}
189
 
190
void gtParagraphStyle::setSpaceBelow(double newSpaceBelow)
191
{
192
        spaceBelow = newSpaceBelow;
12895 jghali 193
        flags |= spaceBelowWasSet;
364 Franz 194
}
195
 
9797 avox 196
QList<ParagraphStyle::TabRecord>* gtParagraphStyle::getTabValues()
364 Franz 197
{
198
        return &tabValues;
199
}
200
 
375 Franz 201
void gtParagraphStyle::setTabValue(double newTabValue, TabType ttype)
364 Franz 202
{
5184 avox 203
        ParagraphStyle::TabRecord tb;
2282 fschmid 204
        tb.tabPosition = newTabValue;
205
        tb.tabType = ttype;
206
        tb.tabFillChar =  QChar();
207
        tabValues.append(tb);
12895 jghali 208
        flags |= tabValueWasSet;
364 Franz 209
}
210
 
211
bool gtParagraphStyle::hasDropCap()
212
{
213
        return dropCap;
214
}
215
 
216
void gtParagraphStyle::setDropCap(bool newDropCap)
217
{
218
        dropCap = newDropCap;
12895 jghali 219
        flags |= dropCapWasSet;
364 Franz 220
}
221
 
222
void gtParagraphStyle::setDropCap(int newHeight)
223
{
224
        setDropCap(true);
225
        dropCapHeight = newHeight;
12895 jghali 226
        flags |= dropCapHeightWasSet;
364 Franz 227
}
228
 
229
int gtParagraphStyle::getDropCapHeight()
230
{
231
        return dropCapHeight;
232
}
233
 
234
void   gtParagraphStyle::setDropCapHeight(int newHeight)
235
{
236
        dropCapHeight = newHeight;
12895 jghali 237
        flags |= dropCapHeightWasSet;
364 Franz 238
}
239
 
18047 craig 240
bool gtParagraphStyle::hasBullet()
241
{
242
        return m_bullet;
243
}
244
 
245
QString  gtParagraphStyle::getBullet()
246
{
247
        return m_bulletStr;
248
}
249
 
250
void gtParagraphStyle::setBullet(bool newBullet, QString str)
251
{
252
        m_bullet = newBullet;
18084 jghali 253
        if (str != "")
254
                m_bulletStr = str;
255
        else
256
                m_bulletStr = QString(QChar(0x2022));
18047 craig 257
        flags |= bulletWasSet;
258
}
259
 
260
bool gtParagraphStyle::hasNum()
261
{
262
        return m_numeration;
263
}
264
 
265
void gtParagraphStyle::setNum(bool newNum, int format, int level, int start, QString prefix, QString suffix)
266
{
267
        m_numeration = newNum;
268
        if (newNum)
269
        {
270
                m_numFormat = format;
271
                m_numLevel = level;
272
                m_numStart = start;
273
                m_numPrefix = prefix;
274
                m_numSuffix = suffix;
275
        }
276
        flags |= numWasSet;
277
}
278
 
279
int gtParagraphStyle::getNumLevel()
280
{
281
        return m_numLevel;
282
}
283
 
284
int gtParagraphStyle::getNumFormat()
285
{
286
        return m_numFormat;
287
}
288
 
289
int gtParagraphStyle::getNumStart()
290
{
291
        return m_numStart;
292
}
293
 
294
QString gtParagraphStyle::getNumPrefix()
295
{
296
        return m_numPrefix;
297
}
298
 
299
QString gtParagraphStyle::getNumSuffix()
300
{
301
        return m_numSuffix;
302
}
303
 
364 Franz 304
bool gtParagraphStyle::isAdjToBaseline()
305
{
306
        return adjToBaseline;
307
}
308
 
309
void gtParagraphStyle::setAdjToBaseline(bool newAdjToBaseline)
310
{
311
        adjToBaseline = newAdjToBaseline;
12895 jghali 312
        flags |= adjToBaselineWasSet;
364 Franz 313
}
314
 
315
void gtParagraphStyle::getStyle(gtStyle* style)
316
{
317
        *style = gtStyle(*this);
318
}
319
 
320
gtParagraphStyle::~gtParagraphStyle()
321
{
322
 
323
}