r25045 by jghali - Code cleanup

scribus-commit scribus-commit at lists.scribus.net
Fri Mar 18 22:49:20 UTC 2022


Author: jghali
Date: Fri Mar 18 22:49:20 2022
New Revision: 25045

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

Modified:
    trunk/Scribus/scribus/style.h
    trunk/Scribus/scribus/styles/charstyle.cpp
    trunk/Scribus/scribus/styles/charstyle.h
    trunk/Scribus/scribus/styles/paragraphstyle.h

Modified: trunk/Scribus/scribus/style.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25045&path=/trunk/Scribus/scribus/style.h
==============================================================================
--- trunk/Scribus/scribus/style.h	(original)
+++ trunk/Scribus/scribus/style.h	Fri Mar 18 22:49:20 2022
@@ -36,19 +36,17 @@
 class SCRIBUS_API BaseStyle : public SaxIO
 {
 protected:
-	bool m_isDefaultStyle;
+	bool m_isDefaultStyle { false };
 	QString m_name;
-	const StyleContext* m_context;
-	int m_contextversion;
+	const StyleContext* m_context { nullptr };
+	int m_contextversion { -1 };
 	QString m_parent;
 	QString m_shortcut;
 
 public:
-//	static const short NOVALUE = -16000;
+	BaseStyle() = default;
 
-	BaseStyle(): m_isDefaultStyle(false), m_name(""), m_context(nullptr), m_contextversion(-1), m_parent(""), m_shortcut() {}
-
-	BaseStyle(StyleContext* b, QString n): m_isDefaultStyle(false), m_name(n), m_context(b), m_contextversion(-1), m_parent(""), m_shortcut() {}
+	BaseStyle(StyleContext * b, QString n) : m_name(n), m_context(b) {}
 	
 	BaseStyle& operator=(const BaseStyle& o)
 	{ //assert(typeinfo() == o.typeinfo()); 

Modified: trunk/Scribus/scribus/styles/charstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25045&path=/trunk/Scribus/scribus/styles/charstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/styles/charstyle.cpp	(original)
+++ trunk/Scribus/scribus/styles/charstyle.cpp	Fri Mar 18 22:49:20 2022
@@ -35,42 +35,49 @@
 	return *this;
 }
 
-StyleFlag StyleFlag::operator& (const StyleFlag& right)
+StyleFlag StyleFlag::operator& (const StyleFlag& right) const
 {
 	int val = static_cast<int>(value) & static_cast<int>(right.value);
 	StyleFlag result(static_cast<StyleFlagValue>(val)); 
 	return result;
 }
 
-StyleFlag StyleFlag::operator& (int right)
+StyleFlag StyleFlag::operator& (int right) const
 {
 	int val = static_cast<int>(value) & right;
 	StyleFlag result(static_cast<StyleFlagValue>(val)); 
 	return result;
 }
 
-StyleFlag StyleFlag::operator| (const StyleFlag& right)
+StyleFlag StyleFlag::operator| (const StyleFlag& right) const
 {
 	int val = static_cast<int>(value) | static_cast<int>(right.value);
 	StyleFlag result(static_cast<StyleFlagValue>(val)); 
 	return result;
 }
 
-StyleFlag StyleFlag::operator^ (const StyleFlag& right)
+StyleFlag StyleFlag::operator| (int right) const
+{
+	int val = static_cast<int>(value) | right;
+	StyleFlag result(static_cast<StyleFlagValue>(val));
+	return result;
+}
+
+StyleFlag StyleFlag::operator^ (const StyleFlag& right) const
 {
 	int val = static_cast<int>(value) ^ static_cast<int>(right.value);
 	StyleFlag result(static_cast<StyleFlagValue>(val)); 
 	return result;
 }
 
-StyleFlag StyleFlag::operator^ (int right)
+StyleFlag StyleFlag::operator^ (int right) const
 {
 	int val = static_cast<int>(value) ^ right;
 	StyleFlag result(static_cast<StyleFlagValue>(val)); 
 	return result;
 }
 
-StyleFlag StyleFlag::operator~ ()
+StyleFlag StyleFlag::operator~ () const
 {
 	int val = ~ static_cast<int>(value);
 	StyleFlag result(static_cast<StyleFlagValue>(val)); 
@@ -107,6 +114,11 @@
 }
 
 bool StyleFlag::operator!= (const StyleFlagValue right) const
+{
+	return !(*this == right);
+}
+
+bool StyleFlag::operator!= (int right) const
 {
 	return !(*this == right);
 }

Modified: trunk/Scribus/scribus/styles/charstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25045&path=/trunk/Scribus/scribus/styles/charstyle.h
==============================================================================
--- trunk/Scribus/scribus/styles/charstyle.h	(original)
+++ trunk/Scribus/scribus/styles/charstyle.h	Fri Mar 18 22:49:20 2022
@@ -49,9 +49,9 @@
 {
 public:
 
-	StyleFlagValue value;
-
-	StyleFlag(void) { value = ScStyle_Default; }
+	StyleFlagValue value { ScStyle_Default };
+
+	StyleFlag() = default;
 	StyleFlag(StyleFlagValue val) { value = val; }
 	StyleFlag(int val) { value = static_cast<StyleFlagValue>(val); }
 
@@ -62,12 +62,13 @@
 	StyleFlag& operator=  (StyleFlagValue val) { value = val; return *this;}
 	StyleFlag& operator&= (const StyleFlag& right);
 	StyleFlag& operator|= (const StyleFlag& right);
-	StyleFlag  operator&  (const StyleFlag& right);
-	StyleFlag  operator&  (int right);
-	StyleFlag  operator|  (const StyleFlag& right);
-	StyleFlag  operator^  (const StyleFlag& right);
-	StyleFlag  operator^  (int right);
-	StyleFlag  operator~  ();
+	StyleFlag  operator&  (const StyleFlag& right) const;
+	StyleFlag  operator&  (int right) const;
+	StyleFlag  operator|  (const StyleFlag& right) const;
+	StyleFlag  operator|  (int right) const;
+	StyleFlag  operator^  (const StyleFlag& right) const;
+	StyleFlag  operator^  (int right) const;
+	StyleFlag  operator~  () const;
 
 	bool equivForShaping(const StyleFlag& right) const;
 	bool operator== (const StyleFlag& right) const;
@@ -75,6 +76,7 @@
 	bool operator== (int right) const;
 	bool operator!= (const StyleFlag& right) const;
 	bool operator!= (const StyleFlagValue right) const;
+	bool operator!= (int right) const;
 };
 
 class SCRIBUS_API CharStyle : public BaseStyle {
@@ -121,28 +123,28 @@
 	static const Xml_string saxxDefaultElem;
 	static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, const Xml_string& elemtag = saxxDefaultElem);
 	
-	virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const;
-	virtual void saxx(SaxHandler& handler) const { saxx(handler, saxxDefaultElem); }
+	void saxx(SaxHandler& handler, const Xml_string& elemtag) const override;
+	void saxx(SaxHandler& handler) const override { saxx(handler, saxxDefaultElem); }
 	
 
 	void getNamedResources(ResourceCollection& lists) const;
 	void replaceNamedResources(ResourceCollection& newNames);
 
-	QString displayName() const;
-
-	void update(const StyleContext * b);
+	QString displayName() const override;
+
+	void update(const StyleContext * b) override;
 	
 	/** This method may alter any of the attributes depending on the value of 'features'.
 		Used for font effects */
 	void updateFeatures();
 	
-	bool equiv(const BaseStyle& other) const;
+	bool equiv(const BaseStyle& other) const override;
 	bool equivForShaping(const CharStyle &other) const;
 
 	void applyCharStyle(const CharStyle & other);
 	void eraseCharStyle(const CharStyle & other);
 	void setStyle(const CharStyle & other);
-	void erase() { eraseCharStyle(*this); }
+	void erase() override { eraseCharStyle(*this); }
 	void eraseDirectFormatting();
 	
 	QString asString() const;

Modified: trunk/Scribus/scribus/styles/paragraphstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25045&path=/trunk/Scribus/scribus/styles/paragraphstyle.h
==============================================================================
--- trunk/Scribus/scribus/styles/paragraphstyle.h	(original)
+++ trunk/Scribus/scribus/styles/paragraphstyle.h	Fri Mar 18 22:49:20 2022
@@ -86,24 +86,23 @@
 	static const Xml_string saxxDefaultElem;
 	static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, const Xml_string& elemtag = saxxDefaultElem);
 	
-	virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const;
-	virtual void saxx(SaxHandler& handler) const { saxx(handler, saxxDefaultElem); }
-	
+	void saxx(SaxHandler& handler, const Xml_string& elemtag) const override;
+	void saxx(SaxHandler& handler) const override { saxx(handler, saxxDefaultElem); }
 
 	void getNamedResources(ResourceCollection& lists) const;
 	void replaceNamedResources(ResourceCollection& newNames);
 
-	QString displayName() const;
+	QString displayName() const override;
 
-	void setContext(const StyleContext* context);
-	void update(const StyleContext*);
+	void setContext(const StyleContext* context) override;
+	void update(const StyleContext*) override;
 	
-	bool equiv(const BaseStyle& other) const;
+	bool equiv(const BaseStyle& other) const override;
 	
 	void applyStyle(const ParagraphStyle& other);
 	void eraseStyle(const ParagraphStyle& other);
 	void setStyle(const ParagraphStyle& other);
-	void erase() { eraseStyle(*this); }
+	void erase() override { eraseStyle(*this); }
 
 	StyleContext* charStyleContext() { return & m_cstyleContext; }
 	const StyleContext* charStyleContext() const { return & m_cstyleContext; }




More information about the scribus-commit mailing list