r23840 by jghali - Refactor gtStyle, gtParagraphStyle and gtFrameStyle

scribus-commit scribus-commit at lists.scribus.net
Tue May 26 13:02:54 UTC 2020


Author: jghali
Date: Tue May 26 13:02:54 2020
New Revision: 23840

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23840
Log:
Refactor gtStyle, gtParagraphStyle and gtFrameStyle

Modified:
    trunk/Scribus/scribus/gtaction.cpp
    trunk/Scribus/scribus/gtfont.h
    trunk/Scribus/scribus/gtframestyle.cpp
    trunk/Scribus/scribus/gtframestyle.h
    trunk/Scribus/scribus/gtparagraphstyle.cpp
    trunk/Scribus/scribus/gtparagraphstyle.h
    trunk/Scribus/scribus/gtstyle.cpp
    trunk/Scribus/scribus/gtstyle.h

Modified: trunk/Scribus/scribus/gtaction.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23840&path=/trunk/Scribus/scribus/gtaction.cpp
==============================================================================
--- trunk/Scribus/scribus/gtaction.cpp	(original)
+++ trunk/Scribus/scribus/gtaction.cpp	Tue May 26 13:02:54 2020
@@ -395,7 +395,7 @@
 	m_textFrame->setFillColor(parseColor(fstyle->getBgColor()));
 	m_textFrame->setFillShade(fstyle->getBgShade());
 	ParagraphStyle newTabs(m_textFrame->itemText.defaultStyle());
-	newTabs.setTabValues(QList<ParagraphStyle::TabRecord>(*(fstyle->getTabValues())));
+	newTabs.setTabValues(fstyle->getTabValues());
 	m_textFrame->itemText.setDefaultStyle(newTabs);
 
 // 	gtParagraphStyle* pstyle = new gtParagraphStyle(*fstyle);
@@ -576,7 +576,7 @@
 	if (flags & gtParagraphStyle::spaceBelowWasSet)
 		style.setGapAfter(pstyle->getSpaceBelow());
 	if (flags & gtParagraphStyle::tabValueWasSet)
-		style.setTabValues(*pstyle->getTabValues());
+		style.setTabValues(pstyle->getTabValues());
 	if (flags & gtParagraphStyle::dropCapWasSet)
 		style.setHasDropCap(pstyle->hasDropCap());
 	if (flags & gtParagraphStyle::dropCapHeightWasSet)

Modified: trunk/Scribus/scribus/gtfont.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23840&path=/trunk/Scribus/scribus/gtfont.h
==============================================================================
--- trunk/Scribus/scribus/gtfont.h	(original)
+++ trunk/Scribus/scribus/gtfont.h	Tue May 26 13:02:54 2020
@@ -115,69 +115,69 @@
 	static const QString fontSlants[];
 	static const QString fontWidths[];
 
-	void noEffects();
-	bool isToggled(FontEffect fe);
-	bool toggleEffect(FontEffect fe);
-	int getFlags();
-	int getEffectsValue();
+	void    noEffects();
+	bool    isToggled(FontEffect fe);
+	bool    toggleEffect(FontEffect fe);
+	int     getFlags();
+	int     getEffectsValue();
 	void	setName(const QString& newName);
-	void setFamily(const QString& newFamily);
+	void    setFamily(const QString& newFamily);
 	QString getFamily();
-	void setWeight(FontWeight newWeight);
-	void setWeight(const QString& newWeight);
+	void    setWeight(FontWeight newWeight);
+	void    setWeight(const QString& newWeight);
 	QString getWeight();
-	void setSlant(FontSlant newSlant);
-	void setSlant(const QString& newSlant);
+	void    setSlant(FontSlant newSlant);
+	void    setSlant(const QString& newSlant);
 	QString getSlant();
-	void setWidth(FontWidth newWidth);
-	void setWidth(const QString& newWidth);
+	void    setWidth(FontWidth newWidth);
+	void    setWidth(const QString& newWidth);
 	QString getWidth();
-	void setSize(int newSize);
-	void setSize(double newSize);
-	void setColor(const QString& newColor);
-	void setShade(int newShade);
-	void setStrokeColor(const QString& newColor);
-	void setStrokeShade(int newShade);
+	void    setSize(int newSize);
+	void    setSize(double newSize);
+	void    setColor(const QString& newColor);
+	void    setShade(int newShade);
+	void    setStrokeColor(const QString& newColor);
+	void    setStrokeShade(int newShade);
 	QString getName();
 	QString getName(uint i);
 	static const int NAMECOUNT = 14;
-	int getSize();
+	int     getSize();
 	QString getColor();
-	int getShade();
+	int     getShade();
 	QString getStrokeColor();
-	int getStrokeShade();
-	int getHscale();
-	void setHscale(int newHscale);
-	int getKerning();
-	void setKerning(int newKerning);
+	int     getStrokeShade();
+	int     getHscale();
+	void    setHscale(int newHscale);
+	int     getKerning();
+	void    setKerning(int newKerning);
 
 private:
-	int m_setflags {0};
+	int     m_setflags {0};
 	QString m_name;
 	QString m_family;
 	QString m_weight;
 	QString m_slant;
 	QString m_width;
 	QString m_append;
-	int m_size {120};
-	bool m_fontEffects[FontEffectMAX];
+	int     m_size {120};
+	bool    m_fontEffects[FontEffectMAX];
 	QString m_color {"Black"};
-	int m_shade {100};
+	int     m_shade {100};
 	QString m_strokeColor {"Black"};
-	int m_strokeShade {100};
+	int     m_strokeShade {100};
 	/* Width of a character in percentages to it's "real width" */
-	int m_hscale {1000};
-	int m_kerning {0};
+	int  m_hscale {1000};
+	int  m_kerning {0};
 	bool m_useFullName {true};
-	int m_weightIndex {0};
-	int m_slantIndex {1};
-	int m_widthIndex {2};
-	int m_smallestIndex {-1};
-	int m_biggestIndex {-1};
-	int m_index {-1};
-	int m_tmpWeightIndex {-1};
-	int m_tmpSlantIndex {-1};
-	int m_tmpWidthIndex {-1};
+	int  m_weightIndex {0};
+	int  m_slantIndex {1};
+	int  m_widthIndex {2};
+	int  m_smallestIndex {-1};
+	int  m_biggestIndex {-1};
+	int  m_index {-1};
+	int  m_tmpWeightIndex {-1};
+	int  m_tmpSlantIndex {-1};
+	int  m_tmpWidthIndex {-1};
 
 	void initArrays();
 	void parseName();
@@ -185,7 +185,7 @@
 	void parseSlant();
 	void parseWidth();
 	void parseFamily();
-	int find(const QString& where, const QString& what);
+	int  find(const QString& where, const QString& what);
 };
 
 #endif // GTFONT_H

Modified: trunk/Scribus/scribus/gtframestyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23840&path=/trunk/Scribus/scribus/gtframestyle.cpp
==============================================================================
--- trunk/Scribus/scribus/gtframestyle.cpp	(original)
+++ trunk/Scribus/scribus/gtframestyle.cpp	Tue May 26 13:02:54 2020
@@ -59,7 +59,7 @@
 	m_bgShade    = 100;
 }
 
-int gtFrameStyle::getColumns()
+int gtFrameStyle::getColumns() const
 {
 	return m_columns;
 }
@@ -69,7 +69,7 @@
 	m_columns = newColumns;
 }
 
-double gtFrameStyle::getColumnsGap()
+double gtFrameStyle::getColumnsGap() const
 {
 	return m_columnsGap;
 }
@@ -79,7 +79,7 @@
 	m_columnsGap = newColumnsGap;
 }
 
-QString gtFrameStyle::getBgColor()
+QString gtFrameStyle::getBgColor() const
 {
 	return m_bgColor;
 }
@@ -89,7 +89,7 @@
 	m_bgColor = newBgColor;
 }
 
-int gtFrameStyle::getBgShade()
+int gtFrameStyle::getBgShade() const
 {
 	return m_bgShade;
 }
@@ -99,7 +99,7 @@
 	m_bgShade = newBgShade;
 }
 
-QString gtFrameStyle::target()
+QString gtFrameStyle::target() const
 {
 	return QString("frame");
 }
@@ -107,9 +107,4 @@
 void gtFrameStyle::getParagraphStyle(gtParagraphStyle* pstyle)
 {
 	*pstyle = gtParagraphStyle(*this);
-}
-
-gtFrameStyle::~gtFrameStyle()
-{
-
-}
+}

Modified: trunk/Scribus/scribus/gtframestyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23840&path=/trunk/Scribus/scribus/gtframestyle.h
==============================================================================
--- trunk/Scribus/scribus/gtframestyle.h	(original)
+++ trunk/Scribus/scribus/gtframestyle.h	Tue May 26 13:02:54 2020
@@ -32,28 +32,32 @@
 
 class SCRIBUS_API gtFrameStyle : public gtParagraphStyle
 {
-private:
-	int     m_columns;
-	double  m_columnsGap;
-	QString m_bgColor;
-	int     m_bgShade;
-	void init();
 public:
 	gtFrameStyle(const QString& name);
 	gtFrameStyle(const gtFrameStyle& f);
 	gtFrameStyle(const gtParagraphStyle& p);
 	gtFrameStyle(const gtStyle& s);
-	~gtFrameStyle();
-	int getColumns();
+	~gtFrameStyle() {};
+	
+	QString target() const override;
+
+	int getColumns() const;
 	void setColumns(int newColumns);
-	double getColumnsGap();
+	double getColumnsGap() const;
 	void setColumnsGap(double newColumnsGap);
-	QString getBgColor();
+	QString getBgColor() const;
 	void setBgColor(const QString& newBgColor);
-	int getBgShade();
+	int getBgShade() const;
 	void setBgShade(int newBgShade);
 	void getParagraphStyle(gtParagraphStyle* pstyle);
-	QString target();
+
+private:
+	int     m_columns { 1 };
+	double  m_columnsGap { 0.0 };
+	QString m_bgColor { "White" };
+	int     m_bgShade { 100 };
+
+	void init();
 };
 
 #endif // GTFRAMESTYLE_H

Modified: trunk/Scribus/scribus/gtparagraphstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23840&path=/trunk/Scribus/scribus/gtparagraphstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/gtparagraphstyle.cpp	(original)
+++ trunk/Scribus/scribus/gtparagraphstyle.cpp	Tue May 26 13:02:54 2020
@@ -88,17 +88,17 @@
 	flags           = 0;
 }
 
-QString gtParagraphStyle::target()
+QString gtParagraphStyle::target() const
 {
 	return QString("paragraph");
 }
 
-int gtParagraphStyle::getFlags()
+int gtParagraphStyle::getFlags() const
 {
 	return flags;
 }
 
-bool gtParagraphStyle::isDefaultStyle()
+bool gtParagraphStyle::isDefaultStyle() const
 {
 	return defaultStyle;
 }
@@ -108,7 +108,7 @@
 	defaultStyle = defStyle;
 }
 
-double gtParagraphStyle::getLineSpacing()
+double gtParagraphStyle::getLineSpacing() const
 {
 	return lineSpacing;
 }
@@ -119,7 +119,7 @@
 	flags |= lineSpacingWasSet;
 }
 
-bool gtParagraphStyle::getAutoLineSpacing()
+bool gtParagraphStyle::getAutoLineSpacing() const
 {
 	return autoLineSpacing;
 }
@@ -130,7 +130,7 @@
 	flags |= autoLineSpacingWasSet;
 }
 
-int gtParagraphStyle::getAlignment()
+int gtParagraphStyle::getAlignment() const
 {
 	return alignment;
 }
@@ -150,7 +150,7 @@
 	}
 }
 
-double gtParagraphStyle::getIndent()
+double gtParagraphStyle::getIndent() const
 {
 	return indent;
 }
@@ -161,7 +161,7 @@
 	flags |= indentWasSet;
 }
 
-double gtParagraphStyle::getFirstLineIndent()
+double gtParagraphStyle::getFirstLineIndent() const
 {
 	return firstLineIndent;
 }
@@ -172,7 +172,7 @@
 	flags |= firstIndentWasSet;
 }
 
-double gtParagraphStyle::getSpaceAbove()
+double gtParagraphStyle::getSpaceAbove() const
 {
 	return spaceAbove;
 }
@@ -183,7 +183,7 @@
 	flags |= spaceAboveWasSet;
 }
 
-double gtParagraphStyle::getSpaceBelow()
+double gtParagraphStyle::getSpaceBelow() const
 {
 	return spaceBelow;
 }
@@ -194,9 +194,9 @@
 	flags |= spaceBelowWasSet;
 }
 
-QList<ParagraphStyle::TabRecord>* gtParagraphStyle::getTabValues()
-{
-	return &tabValues;
+const QList<ParagraphStyle::TabRecord>& gtParagraphStyle::getTabValues() const
+{
+	return tabValues;
 }
 
 void gtParagraphStyle::setTabValue(double newTabValue, TabType ttype)
@@ -209,7 +209,7 @@
 	flags |= tabValueWasSet;
 }
 
-bool gtParagraphStyle::hasDropCap()
+bool gtParagraphStyle::hasDropCap() const
 {
 	return dropCap;
 }
@@ -227,7 +227,7 @@
 	flags |= dropCapHeightWasSet;
 }
 
-int gtParagraphStyle::getDropCapHeight()
+int gtParagraphStyle::getDropCapHeight() const
 {
 	return dropCapHeight;
 }
@@ -238,12 +238,12 @@
 	flags |= dropCapHeightWasSet;
 }
 
-bool gtParagraphStyle::hasBullet()
+bool gtParagraphStyle::hasBullet() const
 {
 	return m_bullet;
 }
 
-QString  gtParagraphStyle::getBullet()
+QString  gtParagraphStyle::getBullet() const
 {
 	return m_bulletStr;
 }
@@ -258,7 +258,7 @@
 	flags |= bulletWasSet;
 }
 
-bool gtParagraphStyle::hasNum()
+bool gtParagraphStyle::hasNum() const
 {
 	return m_numeration;
 }
@@ -277,32 +277,32 @@
 	flags |= numWasSet;
 }
 
-int gtParagraphStyle::getNumLevel()
+int gtParagraphStyle::getNumLevel() const
 {
 	return m_numLevel;
 }
 
-int gtParagraphStyle::getNumFormat()
+int gtParagraphStyle::getNumFormat() const
 {
 	return m_numFormat;
 }
 
-int gtParagraphStyle::getNumStart()
+int gtParagraphStyle::getNumStart() const
 {
 	return m_numStart;
 }
 
-QString gtParagraphStyle::getNumPrefix()
+QString gtParagraphStyle::getNumPrefix() const
 {
 	return m_numPrefix;
 }
 
-QString gtParagraphStyle::getNumSuffix()
+QString gtParagraphStyle::getNumSuffix() const
 {
 	return m_numSuffix;
 }
 
-bool gtParagraphStyle::isAdjToBaseline()
+bool gtParagraphStyle::isAdjToBaseline() const
 {
 	return adjToBaseline;
 }
@@ -317,8 +317,3 @@
 {
 	*style = gtStyle(*this);
 }
-
-gtParagraphStyle::~gtParagraphStyle()
-{
-
-}

Modified: trunk/Scribus/scribus/gtparagraphstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23840&path=/trunk/Scribus/scribus/gtparagraphstyle.h
==============================================================================
--- trunk/Scribus/scribus/gtparagraphstyle.h	(original)
+++ trunk/Scribus/scribus/gtparagraphstyle.h	Tue May 26 13:02:54 2020
@@ -50,32 +50,11 @@
 
 class SCRIBUS_API gtParagraphStyle : public gtStyle
 {
-private:
-	void init();
-protected:
-	int    flags;
-	bool   defaultStyle;
-	double lineSpacing;
-	int    alignment;
-	double indent;
-	double firstLineIndent;
-	double spaceAbove;
-	double spaceBelow;
-	QList<ParagraphStyle::TabRecord> tabValues;
-	bool dropCap;
-	int  dropCapHeight;
-	bool m_bullet; ///< Is style using bullet?
-	QString m_bulletStr; ///< String used as bullet
-	bool m_numeration; ///< Is style using numeration?
-	int m_numLevel; ///< Level in hierarchical numbering
-	int m_numFormat; ///< 1_2_3, i_ii_ii, a_b_c
-	int m_numStart; ///< Numeration starts at number
-	QString m_numPrefix; ///< Numeration prefix of style
-	QString m_numSuffix; ///< Numeration sufffix of style
-	bool adjToBaseline;
-	bool autoLineSpacing;
-	bool isVisible;
 public:
+	gtParagraphStyle(const QString& name);
+	gtParagraphStyle(const gtParagraphStyle& p);
+	gtParagraphStyle(const gtStyle& s);
+	~gtParagraphStyle() {};
 
 	typedef enum
 	{
@@ -95,49 +74,73 @@
 		numWasSet = 8192
 	} wasSetFlags;
 
-	int    getFlags();
-	bool   isDefaultStyle();
+	QString target() const override;
+
+	int    getFlags() const;
+	bool   isDefaultStyle() const;
 	void   setDefaultStyle(bool defStyle);
-	double getLineSpacing();
+	double getLineSpacing() const;
 	void   setLineSpacing(double newLineSpacing);
-	bool   getAutoLineSpacing();
+	bool   getAutoLineSpacing() const;
 	void   setAutoLineSpacing(bool newALS);
-	int    getAlignment();
+	int    getAlignment() const;
 	void   setAlignment(Alignment newAlignment);
 	void   setAlignment(int newAlignment);
-	double getIndent();
+	double getIndent() const;
 	void   setIndent(double newIndent);
-	double getFirstLineIndent();
+	double getFirstLineIndent() const;
 	void   setFirstLineIndent(double newFirstLineIndent);
-	double getSpaceAbove();
+	double getSpaceAbove() const;
 	void   setSpaceAbove(double newSpaceAbove);
-	double getSpaceBelow();
+	double getSpaceBelow() const;
 	void   setSpaceBelow(double newSpaceBelow);
-	QList<ParagraphStyle::TabRecord>* getTabValues();
+	const QList<ParagraphStyle::TabRecord>& getTabValues() const;
 	void   setTabValue(double newTabValue, TabType ttype = LEFT_T);
-	bool   hasDropCap();
+	bool   hasDropCap() const;
 	void   setDropCap(bool newDropCap);
 	void   setDropCap(int newHeight);
-	int    getDropCapHeight();
+	int    getDropCapHeight() const;
 	void   setDropCapHeight(int newHeight);
-	bool   isAdjToBaseline();
+	bool   isAdjToBaseline() const;
 	void   setAdjToBaseline(bool newAdjToBaseline);
 	void   getStyle(gtStyle* style);
-	gtParagraphStyle(const QString& name);
-	gtParagraphStyle(const gtParagraphStyle& p);
-	gtParagraphStyle(const gtStyle& s);
-	~gtParagraphStyle();
-	QString target();
-	bool hasBullet();
+	bool hasBullet() const;
 	void setBullet(bool newBullet, const QString& str);
-	QString getBullet();
-	bool hasNum();
+	QString getBullet() const;
+	bool hasNum() const;
 	void setNum(bool newNum, int format=0, int level=0, int start = 1, const QString& prefix = "", const QString& suffix = "");
-	int getNumLevel();
-	int getNumFormat();
-	int getNumStart();
-	QString getNumPrefix();
-	QString getNumSuffix();
+	int getNumLevel() const;
+	int getNumFormat() const;
+	int getNumStart() const;
+	QString getNumPrefix() const;
+	QString getNumSuffix() const;
+
+protected:
+	int    flags { 0 };
+	bool   defaultStyle { false };
+	double lineSpacing { 15 };
+	int    alignment { LEFT };
+	double indent { 0.0 };
+	double firstLineIndent { 0.0 };
+	double spaceAbove { 0.0 };
+	double spaceBelow { 0.0 };
+	QList<ParagraphStyle::TabRecord> tabValues;
+	bool dropCap { false };
+	int  dropCapHeight { 2 };
+	bool m_bullet { false }; ///< Is style using bullet?
+	QString m_bulletStr { QChar(0x2022) }; ///< String used as bullet
+	bool m_numeration { false }; ///< Is style using numeration?
+	int m_numLevel { 0 }; ///< Level in hierarchical numbering
+	int m_numFormat { 0 }; ///< 1_2_3, i_ii_ii, a_b_c
+	int m_numStart { 1 }; ///< Numeration starts at number
+	QString m_numPrefix; ///< Numeration prefix of style
+	QString m_numSuffix; ///< Numeration sufffix of style
+	bool adjToBaseline { false };
+	bool autoLineSpacing { false };
+	bool isVisible { true };
+
+private:
+	void init();
 };
 
 #endif // GTPARAGRAPHSTYLE_H

Modified: trunk/Scribus/scribus/gtstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23840&path=/trunk/Scribus/scribus/gtstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/gtstyle.cpp	(original)
+++ trunk/Scribus/scribus/gtstyle.cpp	Tue May 26 13:02:54 2020
@@ -57,7 +57,7 @@
 	name = newName;
 }
 
-QString gtStyle::target()
+QString gtStyle::target() const
 {
 	return QString("character");
 }

Modified: trunk/Scribus/scribus/gtstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23840&path=/trunk/Scribus/scribus/gtstyle.h
==============================================================================
--- trunk/Scribus/scribus/gtstyle.h	(original)
+++ trunk/Scribus/scribus/gtstyle.h	Tue May 26 13:02:54 2020
@@ -33,18 +33,21 @@
 
 class SCRIBUS_API gtStyle 
 {
-protected:
-	QString name;
-	gtFont font;
 public:
 	gtStyle(const QString& name);
 	gtStyle(const gtStyle& s);
+	virtual ~gtStyle();
+
 	void setFont(const gtFont& newFont);
 	gtFont* getFont();
 	QString getName();
 	void setName(const QString& newName);
-	virtual ~gtStyle();
-	virtual QString target();
+
+	virtual QString target() const;
+
+protected:
+	QString name;
+	gtFont font;
 };
 
 #endif // STYLE_H




More information about the scribus-commit mailing list