r24732 by jghali - Code cleanup

scribus-commit scribus-commit at lists.scribus.net
Mon Oct 4 18:09:15 UTC 2021


Author: jghali
Date: Mon Oct  4 18:09:15 2021
New Revision: 24732

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24732
Log:
Code cleanup

Modified:
    trunk/Scribus/scribus/fonts/scfontmetrics.cpp
    trunk/Scribus/scribus/sampleitem.cpp
    trunk/Scribus/scribus/sampleitem.h
    trunk/Scribus/scribus/styles/paragraphstyle.cpp
    trunk/Scribus/scribus/styles/paragraphstyle.h

Modified: trunk/Scribus/scribus/fonts/scfontmetrics.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24732&path=/trunk/Scribus/scribus/fonts/scfontmetrics.cpp
==============================================================================
--- trunk/Scribus/scribus/fonts/scfontmetrics.cpp	(original)
+++ trunk/Scribus/scribus/fonts/scfontmetrics.cpp	Mon Oct  4 18:09:15 2021
@@ -253,7 +253,7 @@
 	pen_x = 0;
 	ymax = 0.0;
 
-	std::unique_ptr<ScPainter> p = std::make_unique<ScPainter>(&pm, pm.width(), pm.height());
+	std::unique_ptr<ScPainter> p(new ScPainter(&pm, pm.width(), pm.height()));
 	p->clear(back);
 	p->setFillMode(ScPainter::Solid);
 	p->setLineWidth(0.0);

Modified: trunk/Scribus/scribus/sampleitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24732&path=/trunk/Scribus/scribus/sampleitem.cpp
==============================================================================
--- trunk/Scribus/scribus/sampleitem.cpp	(original)
+++ trunk/Scribus/scribus/sampleitem.cpp	Mon Oct  4 18:09:15 2021
@@ -209,7 +209,7 @@
 	m_tmpStyle.charStyle().setFillColor(fColor);
 }
 
-void SampleItem::setTxtFillShade(int fShade)
+void SampleItem::setTxtFillShade(double fShade)
 {
 	m_tmpStyle.charStyle().setFillShade(fShade);
 }
@@ -219,64 +219,69 @@
 	m_tmpStyle.charStyle().setStrokeColor(sColor);
 }
 
-void SampleItem::setTxtStrokeShade(int sShade)
+void SampleItem::setTxtStrokeShade(double sShade)
 {
 	m_tmpStyle.charStyle().setStrokeShade(sShade);
 }
 
-void SampleItem::setTxtShadowX(int txtShadowX)
+void SampleItem::setTxtShadowX(double txtShadowX)
 {
 	m_tmpStyle.charStyle().setShadowXOffset(txtShadowX);
 }
 
-void SampleItem::setTxtShadowY(int txtShadowY)
+void SampleItem::setTxtShadowY(double txtShadowY)
 {
 	m_tmpStyle.charStyle().setShadowYOffset(txtShadowY);
 }
 
-void SampleItem::setTxtOutline(int txtOutline)
+void SampleItem::setTxtOutlineWidth(double txtOutline)
 {
 	m_tmpStyle.charStyle().setOutlineWidth(txtOutline);
 }
 
-void SampleItem::setTxtUnderPos(int txtUnderPos)
+void SampleItem::setTxtUnderlineOffset(double txtUnderPos)
 {
 	m_tmpStyle.charStyle().setUnderlineOffset(txtUnderPos);
 }
 
-void SampleItem::setTxtUnderWidth(int txtUnderWidth)
+void SampleItem::setTxtUnderlineWidth(double txtUnderWidth)
 {
 	m_tmpStyle.charStyle().setUnderlineWidth(txtUnderWidth);
 }
 
-void SampleItem::setTxtStrikePos(int txtStrikePos)
+void SampleItem::setTxtStrikethruOffset(double txtStrikePos)
 {
 	m_tmpStyle.charStyle().setStrikethruOffset(txtStrikePos);
 }
 
-void SampleItem::setTxtStrikeWidth(int txtStrikeWidth)
+void SampleItem::setTxtStrikethruWidth(double txtStrikeWidth)
 {
 	m_tmpStyle.charStyle().setStrikethruWidth(txtStrikeWidth);
 }
 
-void SampleItem::setScaleH(int scaleH)
+void SampleItem::setScaleH(double scaleH)
 {
 	m_tmpStyle.charStyle().setScaleH(scaleH);
 }
 
-void SampleItem::setScaleV(int scaleV)
+void SampleItem::setScaleV(double scaleV)
 {
 	m_tmpStyle.charStyle().setScaleV(scaleV);
 }
 
-void SampleItem::setBaseOff(int baseOff)
+void SampleItem::setBaselineOffset(double baseOff)
 {
 	m_tmpStyle.charStyle().setBaselineOffset(baseOff);
 }
 
-void SampleItem::setKernVal(int kernVal)
+void SampleItem::setKernVal(double kernVal)
 {
 	m_tmpStyle.charStyle().setTracking(kernVal);
+}
+
+void SampleItem::setWordTracking(double val)
+{
+	m_tmpStyle.charStyle().setWordTracking(val);
 }
 
 QPixmap SampleItem::getSample(int width, int height)

Modified: trunk/Scribus/scribus/sampleitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24732&path=/trunk/Scribus/scribus/sampleitem.h
==============================================================================
--- trunk/Scribus/scribus/sampleitem.h	(original)
+++ trunk/Scribus/scribus/sampleitem.h	Mon Oct  4 18:09:15 2021
@@ -76,20 +76,21 @@
 		void setParEffectDist(double dropDist);
 		void setFontEffect(int fontEffect);
 		void setTxtFillColor(const QString& fColor);
-		void setTxtFillShade(int fShade);
+		void setTxtFillShade(double fShade);
 		void setTxtStrokeColor(const QString& sColor);
-		void setTxtStrokeShade(int sShade);
-		void setTxtShadowX(int txtShadowX);
-		void setTxtShadowY(int txtShadowY);
-		void setTxtOutline(int txtOutline);
-		void setTxtUnderPos(int txtUnderPos);
-		void setTxtUnderWidth(int txtUnderWidth);
-		void setTxtStrikePos(int txtStrikePos);
-		void setTxtStrikeWidth(int txtStrikeWidth);
-		void setScaleH(int scaleH);
-		void setScaleV(int scaleV);
-		void setBaseOff(int baseOff);
-		void setKernVal(int kernVal);
+		void setTxtStrokeShade(double sShade);
+		void setTxtShadowX(double txtShadowX);
+		void setTxtShadowY(double txtShadowY);
+		void setTxtOutlineWidth(double txtOutline);
+		void setTxtUnderlineOffset(double txtUnderPos);
+		void setTxtUnderlineWidth(double txtUnderWidth);
+		void setTxtStrikethruOffset(double txtStrikePos);
+		void setTxtStrikethruWidth(double txtStrikeWidth);
+		void setScaleH(double scaleH);
+		void setScaleV(double scaleV);
+		void setBaselineOffset(double baseOff);
+		void setKernVal(double kernVal);
+		void setWordTracking(double wordTracking);
 
 		/*! \brief Get the sample.
 		\param width W of the sample

Modified: trunk/Scribus/scribus/styles/paragraphstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24732&path=/trunk/Scribus/scribus/styles/paragraphstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/styles/paragraphstyle.cpp	(original)
+++ trunk/Scribus/scribus/styles/paragraphstyle.cpp	Mon Oct  4 18:09:15 2021
@@ -27,7 +27,7 @@
 	return isequiv(tabPosition, other.tabPosition) && tabType==other.tabType && tabFillChar == other.tabFillChar;
 }
 
-ParagraphStyle::ParagraphStyle() : m_cstyleContext(nullptr), m_cstyleContextIsInh(true)
+ParagraphStyle::ParagraphStyle()
 {
 	setParent("");
 	m_cstyleContext.setDefaultStyle( &m_cstyle );
@@ -38,11 +38,14 @@
 #include "paragraphstyle.attrdefs.cxx"
 #undef ATTRDEF
 	
-	m_isDefaultStyle=false;
-}
-
-
-ParagraphStyle::ParagraphStyle(const ParagraphStyle& other) : BaseStyle(other), m_cstyleContext(nullptr), m_cstyleContextIsInh(other.m_cstyleContextIsInh), m_cstyle(other.charStyle())
+	m_isDefaultStyle = false;
+}
+
+
+ParagraphStyle::ParagraphStyle(const ParagraphStyle& other)
+	          : BaseStyle(other), 
+	            m_cstyleContextIsInh(other.m_cstyleContextIsInh),
+	            m_cstyle(other.charStyle())
 {
 	if (m_cstyleContextIsInh)
 		m_cstyle.setContext(nullptr);
@@ -58,12 +61,6 @@
 #include "paragraphstyle.attrdefs.cxx"
 #undef ATTRDEF
 }
-
-ParagraphStyle::~ParagraphStyle()
-{
-//	qDebug() << QString("~ParagraphStyle %1").arg(reinterpret_cast<uint>(this));
-}
-	
 
 QString ParagraphStyle::displayName() const
 {
@@ -80,7 +77,7 @@
 bool ParagraphStyle::equiv(const BaseStyle& other) const
 {
 	other.validate();
-	const ParagraphStyle* oth = reinterpret_cast<const ParagraphStyle*> ( & other );
+	const auto* oth = reinterpret_cast<const ParagraphStyle*> ( & other );
 	return  oth &&
 		parent() == oth->parent() && m_cstyle.equiv(oth->charStyle())
 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
@@ -91,25 +88,6 @@
 		;
 }	
 
-
-/* hm... av
-static void updateAutoLinespacing(ParagraphStyle& that)
-{
-	switch (that.lineSpacingMode())
-	{
-		case 0: 
-			that.setLineSpacing(((that.charStyle().fontSize() / 10.0) * static_cast<qreal>(typographicSettings.autoLineSpacing) / 100));
-			break;
-		case 1:
-			that.setLineSpacing(that.charStyle().font().height(size));
-			break;
-		case 2:
-			that.setLineSpacing(typographicSettings.valueBaseGrid-1);
-			break;
-	}
-}
-*/
-
 ParagraphStyle& ParagraphStyle::operator=(const ParagraphStyle& other) 
 {
 	static_cast<BaseStyle&>(*this) = static_cast<const BaseStyle&>(other);
@@ -122,7 +100,7 @@
 	
 	if (m_cstyleContextIsInh)
 	{
-		const ParagraphStyle * parent = reinterpret_cast<const ParagraphStyle*> ( parentStyle() );
+		const auto * parent = reinterpret_cast<const ParagraphStyle*> ( parentStyle() );
 		m_cstyle.setContext(parent ? parent->charStyleContext() : nullptr);
 	}
 	else
@@ -148,8 +126,9 @@
 
 void ParagraphStyle::repairImplicitCharStyleInheritance()
 {
-	if (m_cstyleContextIsInh) {
-		const ParagraphStyle * newParent = reinterpret_cast<const ParagraphStyle*> ( parentStyle() );
+	if (m_cstyleContextIsInh)
+	{
+		const auto * newParent = reinterpret_cast<const ParagraphStyle*> ( parentStyle() );
 		m_cstyle.setContext(newParent ? newParent->charStyleContext() : nullptr);
 	}
 }
@@ -171,9 +150,9 @@
 	m_cstyle.validate();
 	m_cstyleContext.invalidate();
 
-	const ParagraphStyle * oth = reinterpret_cast<const ParagraphStyle*> ( parentStyle() );
+	const auto * oth = reinterpret_cast<const ParagraphStyle*> ( parentStyle() );
 //	qDebug() << QString("ParagraphStyle::update(%1) parent=%2").arg((unsigned long int)context).arg((unsigned long int)oth);
-	if (oth) {
+	if (oth){
 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
 		if (inh_##attr_NAME) \
 			m_##attr_NAME = oth->attr_GETTER();
@@ -323,7 +302,7 @@
 	void end (const Xml_string& /*tagname*/)
 	{
 		ParagraphStyle* pstyle = this->dig->top<ParagraphStyle>(1);
-		CharStyle* cstyle = this->dig->top<CharStyle>(0);
+		const CharStyle* cstyle = this->dig->top<CharStyle>(0);
 		pstyle->charStyle() = *cstyle;
 	}
 };

Modified: trunk/Scribus/scribus/styles/paragraphstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24732&path=/trunk/Scribus/scribus/styles/paragraphstyle.h
==============================================================================
--- trunk/Scribus/scribus/styles/paragraphstyle.h	(original)
+++ trunk/Scribus/scribus/styles/paragraphstyle.h	Mon Oct  4 18:09:15 2021
@@ -71,7 +71,7 @@
 	ParagraphStyle();
 	ParagraphStyle(const ParagraphStyle& other);
 	ParagraphStyle& operator=(const ParagraphStyle& other);
-	~ParagraphStyle();
+	~ParagraphStyle() = default;
 
 	static const Xml_string saxxDefaultElem;
 	static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, const Xml_string& elemtag = saxxDefaultElem);
@@ -153,8 +153,8 @@
 private:
 		
 	// member declarations:
-	StyleContextProxy m_cstyleContext;
-	bool m_cstyleContextIsInh;
+	StyleContextProxy m_cstyleContext { nullptr };
+	bool m_cstyleContextIsInh { true };
 	CharStyle m_cstyle;
 	
 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \




More information about the scribus-commit mailing list