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 */
7 /***************************************************************************
8  *   Copyright (C) 2004 by Riku Leino                                      *
9  *   tsoots@gmail.com                                                      *
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  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
25  ***************************************************************************/
26 
27 #ifndef GTPARAGRAPHSTYLE_H
28 #define GTPARAGRAPHSTYLE_H
29 
30 #include "scribusapi.h"
31 #include "gtstyle.h"
32 #include "sctextstruct.h"
33 
34 enum Alignment {
35 	LEFT,
36 	CENTER,
37 	RIGHT,
38 	BLOCK,
39 	FORCED,
40 	AlignmentMAX
41 };
42 
43 enum TabType {
44 	LEFT_T,
45 	RIGHT_T,
46 	FULL_STOP_T,
47 	COMMA_T,
48 	CENTER_T
49 };
50 
51 class SCRIBUS_API gtParagraphStyle : public gtStyle
52 {
53 public:
54 	gtParagraphStyle(const QString& name);
55 	gtParagraphStyle(const gtParagraphStyle& p);
56 	gtParagraphStyle(const gtStyle& s);
~gtParagraphStyle()57 	~gtParagraphStyle() {};
58 
59 	typedef enum
60 	{
61 		lineSpacingWasSet = 1,
62 		alignmentWasSet = 2,
63 		indentWasSet = 4,
64 		firstIndentWasSet = 8,
65 		spaceAboveWasSet  = 16,
66 		spaceBelowWasSet = 32,
67 		tabValueWasSet = 64,
68 		fillShadeWasSet = 128,
69 		dropCapWasSet = 256,
70 		dropCapHeightWasSet = 512,
71 		adjToBaselineWasSet = 1024,
72 		autoLineSpacingWasSet  = 2048,
73 		bulletWasSet = 4096,
74 		numWasSet = 8192
75 	} wasSetFlags;
76 
asGtStyle()77 	gtStyle& asGtStyle() { return dynamic_cast<gtStyle&>(*this); }
asGtStyle()78 	const gtStyle& asGtStyle() const { return dynamic_cast<const gtStyle&>(*this); }
79 
80 	QString target() const override;
81 
82 	int    getFlags() const;
83 	bool   isDefaultStyle() const;
84 	void   setDefaultStyle(bool defStyle);
85 	double getLineSpacing() const;
86 	void   setLineSpacing(double newLineSpacing);
87 	bool   getAutoLineSpacing() const;
88 	void   setAutoLineSpacing(bool newALS);
89 	int    getAlignment() const;
90 	void   setAlignment(Alignment newAlignment);
91 	void   setAlignment(int newAlignment);
92 	double getIndent() const;
93 	void   setIndent(double newIndent);
94 	double getFirstLineIndent() const;
95 	void   setFirstLineIndent(double newFirstLineIndent);
96 	double getSpaceAbove() const;
97 	void   setSpaceAbove(double newSpaceAbove);
98 	double getSpaceBelow() const;
99 	void   setSpaceBelow(double newSpaceBelow);
100 	const QList<ParagraphStyle::TabRecord>& getTabValues() const;
101 	void   setTabValue(double newTabValue, TabType ttype = LEFT_T);
102 	bool   hasDropCap() const;
103 	void   setDropCap(bool newDropCap);
104 	void   setDropCap(int newHeight);
105 	int    getDropCapHeight() const;
106 	void   setDropCapHeight(int newHeight);
107 	bool   isAdjToBaseline() const;
108 	void   setAdjToBaseline(bool newAdjToBaseline);
109 	void   getStyle(gtStyle* style);
110 	bool hasBullet() const;
111 	void setBullet(bool newBullet, const QString& str);
112 	QString getBullet() const;
113 	bool hasNum() const;
114 	void setNum(bool newNum, int format=0, int level=0, int start = 1, const QString& prefix = QString(), const QString& suffix = QString());
115 	int getNumLevel() const;
116 	int getNumFormat() const;
117 	int getNumStart() const;
118 	QString getNumPrefix() const;
119 	QString getNumSuffix() const;
120 
121 protected:
122 	int    flags { 0 };
123 	bool   defaultStyle { false };
124 	double lineSpacing { 15 };
125 	int    alignment { LEFT };
126 	double indent { 0.0 };
127 	double firstLineIndent { 0.0 };
128 	double spaceAbove { 0.0 };
129 	double spaceBelow { 0.0 };
130 	QList<ParagraphStyle::TabRecord> tabValues;
131 	bool dropCap { false };
132 	int  dropCapHeight { 2 };
133 	bool m_bullet { false }; ///< Is style using bullet?
134 	QString m_bulletStr { QChar(0x2022) }; ///< String used as bullet
135 	bool m_numeration { false }; ///< Is style using numeration?
136 	int m_numLevel { 0 }; ///< Level in hierarchical numbering
137 	int m_numFormat { 0 }; ///< 1_2_3, i_ii_ii, a_b_c
138 	int m_numStart { 1 }; ///< Numeration starts at number
139 	QString m_numPrefix; ///< Numeration prefix of style
140 	QString m_numSuffix; ///< Numeration sufffix of style
141 	bool adjToBaseline { false };
142 	bool autoLineSpacing { false };
143 	bool isVisible { true };
144 
145 private:
146 	void init();
147 };
148 
149 #endif // GTPARAGRAPHSTYLE_H
150