r22632 by craig - clazy and clang fixes, part 14

scribus-commit scribus-commit at lists.scribus.net
Tue Aug 14 20:13:04 UTC 2018


Author: craig
Date: Tue Aug 14 20:13:04 2018
New Revision: 22632

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22632
Log:
clazy and clang fixes, part 14

Modified:
    trunk/Scribus/scribus/scclocale.cpp
    trunk/Scribus/scribus/scfonts.cpp
    trunk/Scribus/scribus/scfonts.h
    trunk/Scribus/scribus/style.h
    trunk/Scribus/scribus/styles/charstyle.cpp
    trunk/Scribus/scribus/styles/charstyle.h
    trunk/Scribus/scribus/styles/linestyle.cpp
    trunk/Scribus/scribus/styles/linestyle.h
    trunk/Scribus/scribus/styles/paragraphstyle.cpp
    trunk/Scribus/scribus/styles/paragraphstyle.h
    trunk/Scribus/scribus/styles/style.cpp
    trunk/Scribus/scribus/styles/style.h
    trunk/Scribus/scribus/styles/stylecontextproxy.cpp
    trunk/Scribus/scribus/ui/collectforoutput_ui.cpp
    trunk/Scribus/scribus/ui/colorlistbox.cpp
    trunk/Scribus/scribus/util.cpp
    trunk/Scribus/scribus/util.h
    trunk/Scribus/scribus/util_color.cpp
    trunk/Scribus/scribus/util_color.h
    trunk/Scribus/scribus/util_ghostscript.cpp
    trunk/Scribus/scribus/util_ghostscript.h
    trunk/Scribus/scribus/util_math.cpp
    trunk/Scribus/scribus/util_math.h

Modified: trunk/Scribus/scribus/scclocale.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/scclocale.cpp
==============================================================================
--- trunk/Scribus/scribus/scclocale.cpp	(original)
+++ trunk/Scribus/scribus/scclocale.cpp	Tue Aug 14 20:13:04 2018
@@ -18,9 +18,9 @@
 #include <QByteArray>
 #include <QDebug>
 
-ScCLocale * ScCLocale::m_instance = 0;
+ScCLocale * ScCLocale::m_instance = nullptr;
 ScCLocale::ScCLocale()
-	:qLocale(QLocale::C), cLocale(0)
+	:qLocale(QLocale::C), cLocale(nullptr)
 {
 	qLocale.setNumberOptions(QLocale::OmitGroupSeparator);
 

Modified: trunk/Scribus/scribus/scfonts.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/scfonts.cpp
==============================================================================
--- trunk/Scribus/scribus/scfonts.cpp	(original)
+++ trunk/Scribus/scribus/scfonts.cpp	Tue Aug 14 20:13:04 2018
@@ -123,7 +123,7 @@
 		FontPath.insert(FontPath.count(),p);
 }
 
-void SCFonts::AddScalableFonts(const QString &path, QString DocName)
+void SCFonts::AddScalableFonts(const QString &path, const QString& DocName)
 {
 	//Make sure this is not empty or we will scan the whole drive on *nix
 	//QString::null+/ is / of course.
@@ -320,7 +320,7 @@
 	{
 		if (a.name_id == TT_NAME_ID_PREFERRED_FAMILY)
 			return true;
-		else if (b.name_id == TT_NAME_ID_PREFERRED_FAMILY)
+		if (b.name_id == TT_NAME_ID_PREFERRED_FAMILY)
 			return false;
 	}
 
@@ -331,11 +331,11 @@
 	{
 		if (a.platform_id == TT_PLATFORM_MICROSOFT)
 			return true;
-		else if (b.platform_id == TT_PLATFORM_MICROSOFT)
+		if (b.platform_id == TT_PLATFORM_MICROSOFT)
 			return false;
-		else if (a.platform_id == TT_PLATFORM_APPLE_UNICODE)
+		if (a.platform_id == TT_PLATFORM_APPLE_UNICODE)
 			return true;
-		else if (b.platform_id == TT_PLATFORM_APPLE_UNICODE)
+		if (b.platform_id == TT_PLATFORM_APPLE_UNICODE)
 			return false;
 	}
 
@@ -362,7 +362,7 @@
 		{
 			if (a.language_id == TT_MS_LANGID_ENGLISH_UNITED_STATES)
 				return true;
-			else if (b.language_id == TT_MS_LANGID_ENGLISH_UNITED_STATES)
+			if (b.language_id == TT_MS_LANGID_ENGLISH_UNITED_STATES)
 				return false;
 		}
 	}
@@ -901,12 +901,12 @@
 		error = FT_New_Face(library, QFile::encodeName(filename), faceIndex, &face);
 	} //while
 	
-	if (face != 0)
+	if (face != nullptr)
 		FT_Done_Face(face);
 	return error && faceIndex == 0;
 }
 
-void SCFonts::removeFont(QString name)
+void SCFonts::removeFont(const QString& name)
 {
 	remove(name);
 	updateFontMap();
@@ -990,7 +990,7 @@
 	// The ObjectSet tells FontConfig what information about each match to return.
 	// We currently just need FC_FILE, but other info like font family and style
 	// is available - see "man fontconfig".
-	FcObjectSet* os = FcObjectSetBuild (FC_FILE, (char *) 0);
+	FcObjectSet* os = FcObjectSetBuild (FC_FILE, (char *) nullptr);
 	if (!os)
 	{
 		qFatal("SCFonts::AddFontconfigFonts() FcObjectSet* os failed to build object set");
@@ -1100,7 +1100,7 @@
  * allowing a user to have extra fonts installed
  * only for this user. Can also be used also as an emergency
  * fallback if no suitable fonts are found elsewere */
-void SCFonts::AddUserPath(QString )
+void SCFonts::AddUserPath(const QString& pf)
 {
 	PrefsContext *pc = PrefsManager::instance()->prefsFile->getContext("Fonts");
 	PrefsTable *extraDirs = pc->getTable("ExtraFontDirs");
@@ -1108,7 +1108,7 @@
 		AddPath(extraDirs->get(i, 0));
 }
 
-void SCFonts::ReadCacheList(QString pf)
+void SCFonts::ReadCacheList(const QString& pf)
 {
 	QFile fr(pf + "/cfonts.xml");
 	QFileInfo fir(fr);

Modified: trunk/Scribus/scribus/scfonts.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/scfonts.h
==============================================================================
--- trunk/Scribus/scribus/scfonts.h	(original)
+++ trunk/Scribus/scribus/scfonts.h	Tue Aug 14 20:13:04 2018
@@ -41,7 +41,7 @@
 		void updateFontMap();
 		void GetFonts(QString pf, bool showFontInfo=false);
 		ScFace LoadScalableFont(const QString &filename);
-		void AddScalableFonts(const QString& path, QString DocName = "");
+		void AddScalableFonts(const QString& path, const QString& DocName = "");
 		/// Returns a font with that name; creates a replacement font if not found
 		const ScFace& findFont(const QString& fontName, ScribusDoc* doc = nullptr);
 		const ScFace& findFont(const QString& fontFamily, const QString& fontStyle, ScribusDoc* doc = nullptr);
@@ -49,17 +49,17 @@
 		QMap<QString,QString> getSubstitutions(const QList<QString> skip = QList<QString>()) const;
 		/// Changes replacement fonts to point to new real fonts. For all keys 'nam' in 'substitutes', findFont(name).isReplacement() must be true
 		void setSubstitutions(const QMap<QString,QString>& substitutes, ScribusDoc* doc = nullptr);
-		void removeFont(QString name);
+		void removeFont(const QString& name);
 		/// Write checked fonts file
 		void WriteCacheList();
 		/// maps family name to face variants
 		QMap<QString, QStringList> fontMap;
 	private:
-		void ReadCacheList(QString pf);
+		void ReadCacheList(const QString& pf);
 		void WriteCacheList(QString pf);
 		void AddPath(QString p);
 		bool AddScalableFont(QString filename, FT_Library &library, QString DocName);
-		void AddUserPath(QString pf);
+		void AddUserPath(const QString& pf);
 #ifdef HAVE_FONTCONFIG
 		void AddFontconfigFonts();
 #else

Modified: trunk/Scribus/scribus/style.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/style.h
==============================================================================
--- trunk/Scribus/scribus/style.h	(original)
+++ trunk/Scribus/scribus/style.h	Tue Aug 14 20:13:04 2018
@@ -69,7 +69,7 @@
 	// this is an abstract class, so:
 	// static const Xml_string saxxDefaultElem; 
 	template<class SUBSTYLE>
-		static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag);
+		static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, const Xml_string& elemtag);
 	
 	void saxxAttributes(Xml_attr& attr) const;
 	//virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const;

Modified: trunk/Scribus/scribus/styles/charstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/styles/charstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/styles/charstyle.cpp	(original)
+++ trunk/Scribus/scribus/styles/charstyle.cpp	Tue Aug 14 20:13:04 2018
@@ -186,8 +186,7 @@
 		return name();
 //	else if ( inheritsAll() )
 //		return parent()->displayName();
-	else 
-		return parentStyle()->displayName() + "+";
+	return parentStyle()->displayName() + "+";
 }
 
 QString CharStyle::asString() const
@@ -510,7 +509,7 @@
 
 const Xml_string CharStyle::saxxDefaultElem("charstyle");
 
-void CharStyle::desaxeRules(const Xml_string& prefixPattern, Digester& ruleset, Xml_string elemtag)
+void CharStyle::desaxeRules(const Xml_string& prefixPattern, Digester& ruleset, const Xml_string& elemtag)
 {
 	Xml_string stylePrefix(Digester::concat(prefixPattern, elemtag));
 	ruleset.addRule(stylePrefix, Factory<CharStyle>());

Modified: trunk/Scribus/scribus/styles/charstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/styles/charstyle.h
==============================================================================
--- trunk/Scribus/scribus/styles/charstyle.h	(original)
+++ trunk/Scribus/scribus/styles/charstyle.h	Tue Aug 14 20:13:04 2018
@@ -119,7 +119,7 @@
 	CharStyle & operator=(const CharStyle & other);
 	
 	static const Xml_string saxxDefaultElem;
-	static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = 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); }

Modified: trunk/Scribus/scribus/styles/linestyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/styles/linestyle.cpp
==============================================================================
--- trunk/Scribus/scribus/styles/linestyle.cpp	(original)
+++ trunk/Scribus/scribus/styles/linestyle.cpp	Tue Aug 14 20:13:04 2018
@@ -62,8 +62,7 @@
 		return name();
 //	else if ( inheritsAll() )
 //		return parent()->displayName();
-	else 
-		return parentStyle()->displayName() + "+";
+	return parentStyle()->displayName() + "+";
 }
 
 
@@ -250,7 +249,7 @@
 
 const Xml_string LineStyle::saxxDefaultElem("linestyle");
 
-void LineStyle::desaxeRules(const Xml_string& prefixPattern, Digester& ruleset, Xml_string elemtag)
+void LineStyle::desaxeRules(const Xml_string& prefixPattern, Digester& ruleset, const Xml_string& elemtag)
 {
 	Xml_string stylePrefix(Digester::concat(prefixPattern, elemtag));
 	ruleset.addRule(stylePrefix, Factory<LineStyle>());

Modified: trunk/Scribus/scribus/styles/linestyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/styles/linestyle.h
==============================================================================
--- trunk/Scribus/scribus/styles/linestyle.h	(original)
+++ trunk/Scribus/scribus/styles/linestyle.h	Tue Aug 14 20:13:04 2018
@@ -49,7 +49,7 @@
 	LineStyle & operator=(const LineStyle & other);
 	
 	static const Xml_string saxxDefaultElem;
-	static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = 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); }

Modified: trunk/Scribus/scribus/styles/paragraphstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/styles/paragraphstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/styles/paragraphstyle.cpp	(original)
+++ trunk/Scribus/scribus/styles/paragraphstyle.cpp	Tue Aug 14 20:13:04 2018
@@ -73,8 +73,7 @@
 		return name();
 	//	else if ( inheritsAll() )
 	//		return parent()->displayName();
-	else 
-		return parentStyle()->displayName() + "+";
+	return parentStyle()->displayName() + "+";
 }
 
 
@@ -379,7 +378,7 @@
 
 const Xml_string ParagraphStyle::saxxDefaultElem("style");
 
-void ParagraphStyle::desaxeRules(const Xml_string& prefixPattern, Digester& ruleset, Xml_string elemtag)
+void ParagraphStyle::desaxeRules(const Xml_string& prefixPattern, Digester& ruleset, const Xml_string& elemtag)
 {
 	typedef ParagraphStyle::TabRecord TabRecord;
 		

Modified: trunk/Scribus/scribus/styles/paragraphstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/styles/paragraphstyle.h
==============================================================================
--- trunk/Scribus/scribus/styles/paragraphstyle.h	(original)
+++ trunk/Scribus/scribus/styles/paragraphstyle.h	Tue Aug 14 20:13:04 2018
@@ -74,7 +74,7 @@
 	~ParagraphStyle();
 
 	static const Xml_string saxxDefaultElem;
-	static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = 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); }

Modified: trunk/Scribus/scribus/styles/style.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/styles/style.cpp
==============================================================================
--- trunk/Scribus/scribus/styles/style.cpp	(original)
+++ trunk/Scribus/scribus/styles/style.cpp	Tue Aug 14 20:13:04 2018
@@ -65,7 +65,9 @@
 	if (m_isDefaultStyle)
 		return nullptr;
 	const BaseStyle * par = m_context ? m_context->resolve(m_parent) : nullptr;
-	if (par == this) return nullptr; else return par;
+	if (par == this)
+		return nullptr;
+	return par;
 }
 
 bool BaseStyle::canInherit(const QString& parentName) const

Modified: trunk/Scribus/scribus/styles/style.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/styles/style.h
==============================================================================
--- trunk/Scribus/scribus/styles/style.h	(original)
+++ trunk/Scribus/scribus/styles/style.h	Tue Aug 14 20:13:04 2018
@@ -13,7 +13,7 @@
 
 template<class SUBSTYLE>
 inline
-void BaseStyle::desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag)
+void BaseStyle::desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, const Xml_string&  elemtag)
 {
 	static QString emptyString;
 	Xml_string stylePrefix(Digester::concat(prefixPattern,elemtag));

Modified: trunk/Scribus/scribus/styles/stylecontextproxy.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/styles/stylecontextproxy.cpp
==============================================================================
--- trunk/Scribus/scribus/styles/stylecontextproxy.cpp	(original)
+++ trunk/Scribus/scribus/styles/stylecontextproxy.cpp	Tue Aug 14 20:13:04 2018
@@ -28,8 +28,7 @@
 	
 	if (name.isEmpty() || ! context)
 		return m_default;
-	else if (this == context)
-		return NULL;
-	else
-		return context->resolve(name);
+	if (this == context)
+		return nullptr;
+	return context->resolve(name);
 }

Modified: trunk/Scribus/scribus/ui/collectforoutput_ui.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/ui/collectforoutput_ui.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/collectforoutput_ui.cpp	(original)
+++ trunk/Scribus/scribus/ui/collectforoutput_ui.cpp	Tue Aug 14 20:13:04 2018
@@ -1,3 +1,5 @@
+#include <utility>
+
 /*
 For general Scribus (>=1.3.2) copyright and licensing information please refer
 to the COPYING file provided with the program. Following this notice may exist
@@ -127,7 +129,7 @@
 
 	progressDialog->close();
 	delete progressDialog;
-	progressDialog = 0;
+	progressDialog = nullptr;
 
 	return QString::null;
 }

Modified: trunk/Scribus/scribus/ui/colorlistbox.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/ui/colorlistbox.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorlistbox.cpp	(original)
+++ trunk/Scribus/scribus/ui/colorlistbox.cpp	Tue Aug 14 20:13:04 2018
@@ -28,7 +28,7 @@
 
 
 
-ColorPixmapValue::ColorPixmapValue() : m_color(), m_doc(nullptr), m_name("invalid")
+ColorPixmapValue::ColorPixmapValue() : m_doc(nullptr), m_name("invalid")
 {}
 
 ColorPixmapValue::ColorPixmapValue(const ColorPixmapValue& other) : m_color(other.m_color), m_doc(other.m_doc), m_name(other.m_name)
@@ -42,7 +42,7 @@
 	return *this;
 }
 
-ColorPixmapValue::ColorPixmapValue( const ScColor& col, ScribusDoc* doc, const QString& colName ) 
+ColorPixmapValue::ColorPixmapValue( const ScColor& col, ScribusDoc* doc, const QString& colName )
 {
 	m_doc = (doc) ? doc->guardedPtr() : nullptr;
 	m_color = col;
@@ -176,24 +176,21 @@
 {
 	if (data.canConvert<ColorPixmapValue>())
 		return data.value<ColorPixmapValue>().m_name;
-	else
-		return data.toString();
+	return data.toString();
 }
 
 QString ColorWideItemDelegate::text(const QVariant& data) const
 {
 	if (data.canConvert<ColorPixmapValue>())
 		return data.value<ColorPixmapValue>().m_name;
-	else
-		return data.toString();
+	return data.toString();
 }
 
 QString ColorFancyItemDelegate::text(const QVariant& data) const
 {
 	if (data.canConvert<ColorPixmapValue>())
 		return data.value<ColorPixmapValue>().m_name;
-	else
-		return data.toString();
+	return data.toString();
 }
 
 
@@ -311,8 +308,7 @@
 		QAbstractItemModel* itemModel = model();
 		return itemModel->data(currentIndex(), Qt::DisplayRole).toString();
 	}
-	else
-		return CommonStrings::tr_NoneColor;
+	return CommonStrings::tr_NoneColor;
 }
 
 int ColorListBox::currentRow() const
@@ -354,7 +350,7 @@
 	if (!colorListModel)
 		return;
 
-	ScribusDoc* doc = 0;
+	ScribusDoc* doc = nullptr;
 	if (cList)
 		doc = cList->document();
 
@@ -432,8 +428,7 @@
 		if (!colorDelegate)
 		{
 			setItemDelegate(new ColorFancyItemDelegate());
-			if (oldDelegate)
-				delete oldDelegate;
+			delete oldDelegate;
 			m_type = type;
 		}
 	}
@@ -444,8 +439,7 @@
 		if (!colorDelegate)
 		{
 			setItemDelegate(new ColorWideItemDelegate());
-			if (oldDelegate)
-				delete oldDelegate;
+			delete oldDelegate;
 			m_type = type;
 		}
 	}
@@ -456,8 +450,7 @@
 		if (!colorDelegate)
 		{
 			setItemDelegate(new ColorSmallItemDelegate());
-			if (oldDelegate)
-				delete oldDelegate;
+			delete oldDelegate;
 			m_type = type;
 		}
 	}

Modified: trunk/Scribus/scribus/util.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/util.cpp
==============================================================================
--- trunk/Scribus/scribus/util.cpp	(original)
+++ trunk/Scribus/scribus/util.cpp	Tue Aug 14 20:13:04 2018
@@ -60,7 +60,7 @@
 	return cleanLang;
 }
 
-int System(const QString exename, const QStringList & args, const QString fileStdErr, const QString fileStdOut, bool* cancel)
+int System(const QString& exename, const QStringList & args, const QString& fileStdErr, const QString& fileStdOut, const bool* cancel)
 {
 	QProcess proc;
 	if (!fileStdOut.isEmpty())
@@ -73,14 +73,14 @@
 		while (!proc.waitForFinished(15000))
 		{
 			qApp->processEvents();
-			if (cancel && (*cancel == true))
+			if (cancel && (*cancel))
 			{
 				proc.kill();
 				break;
 			}
 		}
 	}
-	if (cancel && (*cancel == true))
+	if (cancel && (*cancel))
 		return -1;
 	return proc.exitCode();
 }
@@ -130,7 +130,7 @@
 // Use loadRawText instead.
 // FIXME XXX
 //
-bool loadText(QString filename, QString *Buffer)
+bool loadText(const QString& filename, QString *Buffer)
 {
 	QFile f(filename);
 	QFileInfo fi(f);
@@ -319,13 +319,13 @@
 	return out;
 }
 
-QString Path2Relative(QString Path, const QString& baseDir)
+QString Path2Relative(const QString& Path, const QString& baseDir)
 {
 	QDir d(baseDir);
 	return d.relativeFilePath(Path);
 }
 
-QString Relative2Path(QString File, const QString& baseDir)
+QString Relative2Path(const QString& File, const QString& baseDir)
 {
 	QString   absPath;
 	QFileInfo fi(File);
@@ -350,7 +350,7 @@
 // check if the file exists, if it does, ask if they're sure
 // return true if they're sure, else return false;
 
-bool overwrite(QWidget *parent, QString filename)
+bool overwrite(QWidget *parent, const QString& filename)
 {
 	bool retval = true;
 	QFileInfo fi(filename);
@@ -380,26 +380,22 @@
 	bool first = true;
 	PageItem *nextItem = currItem;
 	PageItem *nbl = currItem;
-	while (nextItem != 0)
-	{
-		if (nextItem->prevInChain() != 0)
+	while (nextItem != nullptr)
+	{
+		if (nextItem->prevInChain() != nullptr)
 			nextItem = nextItem->prevInChain();
 		else
 			break;
 	}
-	while (nextItem != 0)
+	while (nextItem != nullptr)
 	{
 		for (int a = qMax(nextItem->firstInFrame(),0); a <= nextItem->lastInFrame() && a < nextItem->itemText.length(); ++a)
 		{
 			QChar b = nextItem->itemText.text(a);
 			if (b == SpecialChars::PARSEP)
-			{
 				para++;
-			}
 			if ((!b.isLetterOrNumber()) && (Dat.isLetterOrNumber()) && (!first))
-			{
 				ww++;
-			}
 			if (b.isSurrogate())
 				++a;
 			cc++;
@@ -409,19 +405,16 @@
 		nbl = nextItem;
 		nextItem = nextItem->nextInChain();
 	}
-	if (nbl->frameOverflows()) {
+	if (nbl->frameOverflows())
+	{
 		paraN++;
 		for (int a = nbl->lastInFrame()+1; a < nbl->itemText.length(); ++a)
 		{
 			QChar b = nbl->itemText.text(a);
 			if (b == SpecialChars::PARSEP)
-			{
 				paraN++;
-			}
 			if ((!b.isLetterOrNumber()) && (Dat.isLetterOrNumber()) && (!first))
-			{
 				wwN++;
-			}
 			if (b.isSurrogate())
 				++a;
 			ccN++;
@@ -479,11 +472,9 @@
 \param s2 second string
 \retval bool t/f related s1>s2
  */
-bool compareQStrings(QString s1, QString s2)
-{
-	if (QString::localeAwareCompare(s1, s2) >= 0)
-		return false;
-	return true;
+bool compareQStrings(const QString& s1, const QString& s2)
+{
+	return QString::localeAwareCompare(s1, s2) < 0;
 }
 
 QStringList sortQStringList(QStringList aList)
@@ -522,7 +513,7 @@
 	return newName;
 }
 
-QString getFileNameByPage(ScribusDoc* currDoc, uint pageNo, QString extension, QString prefix)
+QString getFileNameByPage(ScribusDoc* currDoc, uint pageNo, const QString& extension, const QString& prefix)
 {
 	uint number = pageNo + currDoc->FirstPnum;
 	QString defaultName;
@@ -540,9 +531,9 @@
 	return QString("%1-%2%3.%4").arg(defaultName).arg(QObject::tr("page", "page export")).arg(number, 3, 10, QChar('0')).arg(extension);
 }
 
-const QString getStringFromSequence(NumFormat type, uint position, QString asterix)
-{
-	QString retVal("");
+const QString getStringFromSequence(NumFormat type, uint position, const QString& asterix)
+{
+	QString retVal;
 
 	const QString english("abcdefghijklmnopqrstuvwxyz");
 	const QString arabic("أبتثجحخدذرزسشصضطظعغفقكلÙ
نهوي");
@@ -723,7 +714,7 @@
 }
 
 //CB Moved from scribus.cpp
-void parsePagesString(QString pages, std::vector<int>* pageNs, int sourcePageCount)
+void parsePagesString(const QString& pages, std::vector<int>* pageNs, int sourcePageCount)
 {
 	QString tmp(pages);
 	QString token;
@@ -802,7 +793,7 @@
 	return ret.trimmed();
 }
 
-void setCurrentComboItem(QComboBox *box, QString text)
+void setCurrentComboItem(QComboBox *box, const QString& text)
 {
 	bool sigBlocked = box->blockSignals(true);
 	int ind = box->findText(text);
@@ -811,7 +802,7 @@
 	box->blockSignals(sigBlocked);
 }
 
-void setCurrentComboItemFromData(QComboBox *box, QString data)
+void setCurrentComboItemFromData(QComboBox *box, const QString& data)
 {
 	bool sigBlocked = box->blockSignals(true);
 	int ind = box->findData(data);
@@ -820,7 +811,7 @@
 	box->blockSignals(sigBlocked);
 }
 
-void removeComboItem(QComboBox *box, QString text)
+void removeComboItem(QComboBox *box, const QString& text)
 {
 	bool sigBlocked = box->blockSignals(true);
 	int ind = box->findText(text);
@@ -1172,7 +1163,7 @@
 	w->setFont(f);
 }
 
-void getUniqueName(QString &name, QStringList list, QString separator, bool prepend)
+void getUniqueName(QString &name, const QStringList& list, const QString& separator, bool prepend)
 {
 	if (!list.contains(name))
 		return;

Modified: trunk/Scribus/scribus/util.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/util.h
==============================================================================
--- trunk/Scribus/scribus/util.h	(original)
+++ trunk/Scribus/scribus/util.h	Tue Aug 14 20:13:04 2018
@@ -54,16 +54,16 @@
 bool SCRIBUS_API sortingQPairOfStrings( QPair<QString, QString> aP, QPair<QString, QString> bP);
 void SCRIBUS_API ReOrderText(ScribusDoc *currentDoc, ScribusView *view);
 void SCRIBUS_API WordAndPara(PageItem *currItem, int *w, int *p, int *c, int *wN, int *pN, int *cN);
-bool SCRIBUS_API overwrite(QWidget *parent, QString filename);
-QString SCRIBUS_API Path2Relative(QString Path, const QString& baseDir = QDir::currentPath());
-QString SCRIBUS_API Relative2Path(QString File, const QString& baseDir = QDir::currentPath());
+bool SCRIBUS_API overwrite(QWidget *parent, const QString& filename);
+QString SCRIBUS_API Path2Relative(const QString& Path, const QString& baseDir = QDir::currentPath());
+QString SCRIBUS_API Relative2Path(const QString& File, const QString& baseDir = QDir::currentPath());
 char SCRIBUS_API *toAscii85( quint32 value, bool& allZero );
 char SCRIBUS_API *toHex( uchar u );
 QString SCRIBUS_API String2Hex(QString *in, bool lang = true);
 QString SCRIBUS_API CompressStr(QString *in);
 QByteArray SCRIBUS_API CompressArray(const QByteArray& in);
 //! \brief WARNING: loadText is INCORRECT - use loadRawText instead!
-bool SCRIBUS_API loadText(QString nam, QString *Buffer);
+bool SCRIBUS_API loadText(const QString& nam, QString *Buffer);
 /*! \brief Replacement version of loadText that returns a QCString as an out parameter.
 The QCString is filled with the contents of the specified file. The return
 byte string is of unknown encoding; the caller must handle encoding issues.
@@ -94,9 +94,9 @@
    * @return Program exit code, or 1 on failure.
    *
 */
-int SCRIBUS_API System(const QString exename, const QStringList & args,
-					   const QString fileStdErr = "", const QString fileStdOut = "",
-					   bool* cancel = nullptr);
+int SCRIBUS_API System(const QString& exename, const QStringList & args,
+					   const QString& fileStdErr = "", const QString& fileStdOut = "",
+					   const bool* cancel = nullptr);
 
 /*!
  \fn QString checkFileExtension(const QString &currName, const QString &extension)
@@ -124,20 +124,20 @@
    \retval QString standardized filename
    \author Petr Vanek
  */
-QString SCRIBUS_API getFileNameByPage(ScribusDoc* currDoc, uint pageNo, QString extension, QString prefix=QString::null);
+QString SCRIBUS_API getFileNameByPage(ScribusDoc* currDoc, uint pageNo, const QString& extension, const QString& prefix=QString::null);
 //asterix is QString used in numeration when number is presented as few chars, like *, **, *** etc
 //default is '*' but can be used any string
-const QString SCRIBUS_API getStringFromSequence(NumFormat type, uint position, QString asterix="*");
+const QString SCRIBUS_API getStringFromSequence(NumFormat type, uint position, const QString& asterix="*");
 const QString SCRIBUS_API numberToRoman(uint i);
 const QString SCRIBUS_API numberToCJK(uint i);
 QChar SCRIBUS_API cjkDigit(uint i);
 const QString SCRIBUS_API numberToLetterSequence(const QString& letters, uint num);
-void SCRIBUS_API parsePagesString(QString pages, std::vector<int>* pageNs, int sourcePageCount);
+void SCRIBUS_API parsePagesString(const QString& pages, std::vector<int>* pageNs, int sourcePageCount);
 
 QString SCRIBUS_API readLineFromDataStream(QDataStream &s);
-void SCRIBUS_API setCurrentComboItem(QComboBox *box, QString text);
-void SCRIBUS_API setCurrentComboItemFromData(QComboBox *box, QString data);
-void SCRIBUS_API removeComboItem(QComboBox *box, QString text);
+void SCRIBUS_API setCurrentComboItem(QComboBox *box, const QString& text);
+void SCRIBUS_API setCurrentComboItemFromData(QComboBox *box, const QString& data);
+void SCRIBUS_API removeComboItem(QComboBox *box, const QString& text);
 
 QString SCRIBUS_API readAdobeUniCodeString(QDataStream &s);
 QString SCRIBUS_API readAdobeUniCodeString16(QDataStream &s);
@@ -158,6 +158,6 @@
  * check if name exists in list
  * if exist then seprator and numbers are pre/append to name while it will be unique
 */
-void SCRIBUS_API getUniqueName(QString &name, QStringList list, QString separator = "", bool prepend = false);
+void SCRIBUS_API getUniqueName(QString &name, const QStringList& list, const QString& separator = "", bool prepend = false);
 
 #endif

Modified: trunk/Scribus/scribus/util_color.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/util_color.cpp
==============================================================================
--- trunk/Scribus/scribus/util_color.cpp	(original)
+++ trunk/Scribus/scribus/util_color.cpp	Tue Aug 14 20:13:04 2018
@@ -143,7 +143,7 @@
 	return out;
 }
 
-QColor SetColor(ScribusDoc *currentDoc, QString color, int shad)
+QColor SetColor(ScribusDoc *currentDoc, const QString& color, int shad)
 {
 	if (color == CommonStrings::None)
 		return QColor(0, 0, 0, 0);
@@ -156,7 +156,7 @@
  * QPixmaps are really slow with Qt/Mac 3.3.4. Really, *really*, slow.
  * So we better cache them.
  */
-QPixmap * getSmallPixmap(QColor rgb)
+QPixmap * getSmallPixmap(const QColor& rgb)
 {
 	static ScPixmapCache<QRgb> pxCache;
 
@@ -177,7 +177,7 @@
 	return pm;
 }
 
-QPixmap * getWidePixmap(QColor rgb)
+QPixmap * getWidePixmap(const QColor& rgb)
 {
 	static ScPixmapCache<QRgb> pxCache;
 
@@ -514,7 +514,7 @@
 	FPoint p0,p1,p2,p3;
 	double c0,c1,c2,c3;
 	double val = 0.5;
-	if (curve.size() == 0)
+	if (curve.isEmpty())
 		return 0.5;
 	// First find curve segment
 	p = curve.point(0);
@@ -592,7 +592,6 @@
 	red = qRound(rP * 255);
 	green = qRound(gP * 255);
 	blue = qRound(bP * 255);
-	return;
 }
 
 void clipColor(double& red, double& green, double& blue)
@@ -629,7 +628,7 @@
 	return CommonStrings::trUnknownCS;
 }
 
-bool importColorsFromFile(QString fileName, ColorList &EditColors, QHash<QString, VGradient> *dialogGradients, bool merge)
+bool importColorsFromFile(const QString& fileName, ColorList &EditColors, QHash<QString, VGradient> *dialogGradients, bool merge)
 {
 	if (fileName.isEmpty())
 		return false;
@@ -643,320 +642,318 @@
 		psPalLoader.setupTargets(&EditColors, dialogGradients);
 		return psPalLoader.importFile(fileName, merge);
 	}
-	else
-	{
-		QStringList allFormatsV = LoadSavePlugin::getExtensionsForColors();
-		if (allFormatsV.contains(ext))
-		{
-			FileLoader fl(fileName);
-			int testResult = fl.testFile();
-			if (testResult != -1)
+
+
+	QStringList allFormatsV = LoadSavePlugin::getExtensionsForColors();
+	if (allFormatsV.contains(ext))
+	{
+		FileLoader fl(fileName);
+		int testResult = fl.testFile();
+		if (testResult != -1)
+		{
+			ColorList LColors;
+			if (fl.readColors(LColors))
 			{
-				ColorList LColors;
-				if (fl.readColors(LColors))
+				ColorList::Iterator it;
+				for (it = LColors.begin(); it != LColors.end(); ++it)
 				{
-					ColorList::Iterator it;
-					for (it = LColors.begin(); it != LColors.end(); ++it)
+					EditColors.tryAddColor(it.key(), it.value());
+				}
+				return (EditColors.count() != oldCount);
+			}
+		}
+	}
+	if (ext == "acb")			// Adobe color book format
+	{
+		PaletteLoader_Adobe_acb adobePalLoader;
+		if (adobePalLoader.isFileSupported(fileName))
+		{
+			adobePalLoader.setupTargets(&EditColors, dialogGradients);
+			return adobePalLoader.importFile(fileName, merge);
+		}
+
+		PaletteLoader_Autocad_acb autocadPalLoder;
+		if (autocadPalLoder.isFileSupported(fileName))
+		{
+			autocadPalLoder.setupTargets(&EditColors, dialogGradients);
+			return autocadPalLoder.importFile(fileName, merge);
+		}
+		return false;
+	}
+	if (ext == "aco")			// Adobe color swatch format
+	{
+		PaletteLoader_Adobe_aco adobePalLoader;
+		if (adobePalLoader.isFileSupported(fileName))
+		{
+			adobePalLoader.setupTargets(&EditColors, dialogGradients);
+			return adobePalLoader.importFile(fileName, merge);
+		}
+		return false;
+	}
+	if (ext == "ase")			// Adobe swatch exchange format
+	{
+		PaletteLoader_Adobe_ase adobePalLoader;
+		if (adobePalLoader.isFileSupported(fileName))
+		{
+			adobePalLoader.setupTargets(&EditColors, dialogGradients);
+			return adobePalLoader.importFile(fileName, merge);
+		}
+		return false;
+	}
+	if (ext == "cxf")			// Adobe swatch exchange format
+	{
+		PaletteLoader_CxF cxfLoader;
+		if (cxfLoader.isFileSupported(fileName))
+		{
+			cxfLoader.setupTargets(&EditColors, dialogGradients);
+			return cxfLoader.importFile(fileName, merge);
+		}
+		return false;
+	}
+	if (ext == "skp")			// Sk1 palette
+	{
+		PaletteLoader_sK1 sk1PalLoader;
+		if (sk1PalLoader.isFileSupported(fileName))
+		{
+			sk1PalLoader.setupTargets(&EditColors, dialogGradients);
+			return sk1PalLoader.importFile(fileName, merge);
+		}
+		return false;
+	}
+	if (ext == "sbz")
+	{
+		PaletteLoader_Swatchbook swatchbookLoader;
+		if (swatchbookLoader.isFileSupported(fileName))
+		{
+			swatchbookLoader.setupTargets(&EditColors, dialogGradients);
+			return swatchbookLoader.importFile(fileName, merge);
+		}
+		return false;
+	}
+
+	QFile fiC(fileName);
+	if (fiC.open(QIODevice::ReadOnly))
+	{
+		QString ColorEn, Cname;
+		int Rval, Gval, Bval, Kval;
+		ScTextStream tsC(&fiC);
+		ColorEn = tsC.readLine();
+		bool cus = false;
+		if (ColorEn.contains("OpenOffice"))
+			cus = true;
+		if ((ColorEn.startsWith("<?xml version=")) || (ColorEn.contains("VivaColors")))
+		{
+			QByteArray docBytes("");
+			loadRawText(fileName, docBytes);
+			QString docText("");
+			docText = QString::fromUtf8(docBytes);
+			QDomDocument docu("scridoc");
+			docu.setContent(docText);
+			ScColor lf = ScColor();
+			QDomElement elem = docu.documentElement();
+			QString dTag = "";
+			dTag = elem.tagName();
+			QString nameMask = "%1";
+			nameMask = elem.attribute("mask", "%1");
+			QDomNode PAGE = elem.firstChild();
+			while (!PAGE.isNull())
+			{
+				QDomElement pg = PAGE.toElement();
+				if (pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
+				{
+					if (pg.hasAttribute("SPACE"))
 					{
-						EditColors.tryAddColor(it.key(), it.value());
+						QString space = pg.attribute("SPACE");
+						if (space == "CMYK")
+						{
+							double c = pg.attribute("C", "0").toDouble() / 100.0;
+							double m = pg.attribute("M", "0").toDouble() / 100.0;
+							double y = pg.attribute("Y", "0").toDouble() / 100.0;
+							double k = pg.attribute("K", "0").toDouble() / 100.0;
+							lf.setCmykColorF(c, m, y, k);
+						}
+						else if (space == "RGB")
+						{
+							double r = pg.attribute("R", "0").toDouble() / 255.0;
+							double g = pg.attribute("G", "0").toDouble() / 255.0;
+							double b = pg.attribute("B", "0").toDouble() / 255.0;
+							lf.setRgbColorF(r, g, b);
+						}
+						else if (space == "Lab")
+						{
+							double L = pg.attribute("L", "0").toDouble();
+							double a = pg.attribute("A", "0").toDouble();
+							double b = pg.attribute("B", "0").toDouble();
+							lf.setLabColor(L, a, b);
+						}
 					}
-					return (EditColors.count() != oldCount);
+					else if (pg.hasAttribute("CMYK"))
+						lf.setNamedColor(pg.attribute("CMYK"));
+					else if (pg.hasAttribute("RGB"))
+						lf.fromQColor(QColor(pg.attribute("RGB")));
+					else
+					{
+						double L = pg.attribute("L", "0").toDouble();
+						double a = pg.attribute("A", "0").toDouble();
+						double b = pg.attribute("B", "0").toDouble();
+						lf.setLabColor(L, a, b);
+					}
+					if (pg.hasAttribute("Spot"))
+						lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
+					else
+						lf.setSpotColor(false);
+					if (pg.hasAttribute("Register"))
+						lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
+					else
+						lf.setRegistrationColor(false);
+					EditColors.tryAddColor(pg.attribute("NAME"), lf);
 				}
-			}
-		}
-		if (ext == "acb")			// Adobe color book format
-		{
-			PaletteLoader_Adobe_acb adobePalLoader;
-			if (adobePalLoader.isFileSupported(fileName))
-			{
-				adobePalLoader.setupTargets(&EditColors, dialogGradients);
-				return adobePalLoader.importFile(fileName, merge);
-			}
-
-			PaletteLoader_Autocad_acb autocadPalLoder;
-			if (autocadPalLoder.isFileSupported(fileName))
-			{
-				autocadPalLoder.setupTargets(&EditColors, dialogGradients);
-				return autocadPalLoder.importFile(fileName, merge);
-			}
-			return false;
-		}
-		else if (ext == "aco")			// Adobe color swatch format
-		{
-			PaletteLoader_Adobe_aco adobePalLoader;
-			if (adobePalLoader.isFileSupported(fileName))
-			{
-				adobePalLoader.setupTargets(&EditColors, dialogGradients);
-				return adobePalLoader.importFile(fileName, merge);
-			}
-			return false;
-		}
-		else if (ext == "ase")			// Adobe swatch exchange format
-		{
-			PaletteLoader_Adobe_ase adobePalLoader;
-			if (adobePalLoader.isFileSupported(fileName))
-			{
-				adobePalLoader.setupTargets(&EditColors, dialogGradients);
-				return adobePalLoader.importFile(fileName, merge);
-			}
-			return false;
-		}
-		else if (ext == "cxf")			// Adobe swatch exchange format
-		{
-			PaletteLoader_CxF cxfLoader;
-			if (cxfLoader.isFileSupported(fileName))
-			{
-				cxfLoader.setupTargets(&EditColors, dialogGradients);
-				return cxfLoader.importFile(fileName, merge);
-			}
-			return false;
-		}
-		else if (ext == "skp")			// Sk1 palette
-		{
-			PaletteLoader_sK1 sk1PalLoader;
-			if (sk1PalLoader.isFileSupported(fileName))
-			{
-				sk1PalLoader.setupTargets(&EditColors, dialogGradients);
-				return sk1PalLoader.importFile(fileName, merge);
-			}
-			return false;
-		}
-		else if (ext == "sbz")
-		{
-			PaletteLoader_Swatchbook swatchbookLoader;
-			if (swatchbookLoader.isFileSupported(fileName))
-			{
-				swatchbookLoader.setupTargets(&EditColors, dialogGradients);
-				return swatchbookLoader.importFile(fileName, merge);
-			}
-			return false;
-		}
-		else							// try for OpenOffice, Viva and our own format
-		{
-			QFile fiC(fileName);
-			if (fiC.open(QIODevice::ReadOnly))
-			{
-				QString ColorEn, Cname;
-				int Rval, Gval, Bval, Kval;
-				ScTextStream tsC(&fiC);
-				ColorEn = tsC.readLine();
-				bool cus = false;
-				if (ColorEn.contains("OpenOffice"))
-					cus = true;
-				if ((ColorEn.startsWith("<?xml version=")) || (ColorEn.contains("VivaColors")))
+				else if (pg.tagName() == "Gradient")
 				{
-					QByteArray docBytes("");
-					loadRawText(fileName, docBytes);
-					QString docText("");
-					docText = QString::fromUtf8(docBytes);
-					QDomDocument docu("scridoc");
-					docu.setContent(docText);
-					ScColor lf = ScColor();
-					QDomElement elem = docu.documentElement();
-					QString dTag = "";
-					dTag = elem.tagName();
-					QString nameMask = "%1";
-					nameMask = elem.attribute("mask", "%1");
-					QDomNode PAGE = elem.firstChild();
-					while (!PAGE.isNull())
+					if (dialogGradients != nullptr)
 					{
-						QDomElement pg = PAGE.toElement();
-						if (pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
+						VGradient gra = VGradient(VGradient::linear);
+						gra.clearStops();
+						QDomNode grad = pg.firstChild();
+						while (!grad.isNull())
 						{
-							if (pg.hasAttribute("SPACE"))
-							{
-								QString space = pg.attribute("SPACE");
-								if (space == "CMYK")
-								{
-									double c = pg.attribute("C", "0").toDouble() / 100.0;
-									double m = pg.attribute("M", "0").toDouble() / 100.0;
-									double y = pg.attribute("Y", "0").toDouble() / 100.0;
-									double k = pg.attribute("K", "0").toDouble() / 100.0;
-									lf.setCmykColorF(c, m, y, k);
-								}
-								else if (space == "RGB")
-								{
-									double r = pg.attribute("R", "0").toDouble() / 255.0;
-									double g = pg.attribute("G", "0").toDouble() / 255.0;
-									double b = pg.attribute("B", "0").toDouble() / 255.0;
-									lf.setRgbColorF(r, g, b);
-								}
-								else if (space == "Lab")
-								{
-									double L = pg.attribute("L", "0").toDouble();
-									double a = pg.attribute("A", "0").toDouble();
-									double b = pg.attribute("B", "0").toDouble();
-									lf.setLabColor(L, a, b);
-								}
-							}
-							else if (pg.hasAttribute("CMYK"))
-								lf.setNamedColor(pg.attribute("CMYK"));
-							else if (pg.hasAttribute("RGB"))
-								lf.fromQColor(QColor(pg.attribute("RGB")));
+							QDomElement stop = grad.toElement();
+							QString name = stop.attribute("NAME");
+							double ramp  = ScCLocale::toDoubleC(stop.attribute("RAMP"), 0.0);
+							int shade    = stop.attribute("SHADE", "100").toInt();
+							double opa   = ScCLocale::toDoubleC(stop.attribute("TRANS"), 1.0);
+							QColor color;
+							if (name == CommonStrings::None)
+								color = QColor(255, 255, 255, 0);
 							else
 							{
-								double L = pg.attribute("L", "0").toDouble();
-								double a = pg.attribute("A", "0").toDouble();
-								double b = pg.attribute("B", "0").toDouble();
-								lf.setLabColor(L, a, b);
+								const ScColor& col = EditColors[name];
+								color = ScColorEngine::getShadeColorProof(col, nullptr, shade);
 							}
-							if (pg.hasAttribute("Spot"))
-								lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
-							else
-								lf.setSpotColor(false);
-							if (pg.hasAttribute("Register"))
-								lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
-							else
-								lf.setRegistrationColor(false);
-							EditColors.tryAddColor(pg.attribute("NAME"), lf);
+							gra.addStop(color, ramp, 0.5, opa, name, shade);
+							grad = grad.nextSibling();
 						}
-						else if (pg.tagName() == "Gradient")
+						if ((!dialogGradients->contains(pg.attribute("Name"))) || (merge))
+							dialogGradients->insert(pg.attribute("Name"), gra);
+						else
 						{
-							if (dialogGradients != nullptr)
-							{
-								VGradient gra = VGradient(VGradient::linear);
-								gra.clearStops();
-								QDomNode grad = pg.firstChild();
-								while (!grad.isNull())
-								{
-									QDomElement stop = grad.toElement();
-									QString name = stop.attribute("NAME");
-									double ramp  = ScCLocale::toDoubleC(stop.attribute("RAMP"), 0.0);
-									int shade    = stop.attribute("SHADE", "100").toInt();
-									double opa   = ScCLocale::toDoubleC(stop.attribute("TRANS"), 1.0);
-									QColor color;
-									if (name == CommonStrings::None)
-										color = QColor(255, 255, 255, 0);
-									else
-									{
-										const ScColor& col = EditColors[name];
-										color = ScColorEngine::getShadeColorProof(col, nullptr, shade);
-									}
-									gra.addStop(color, ramp, 0.5, opa, name, shade);
-									grad = grad.nextSibling();
-								}
-								if ((!dialogGradients->contains(pg.attribute("Name"))) || (merge))
-									dialogGradients->insert(pg.attribute("Name"), gra);
-								else
-								{
-									QString tmp;
-									QString name = pg.attribute("Name");
-									name += "("+tmp.setNum(dialogGradients->count())+")";
-									dialogGradients->insert(name, gra);
-								}
-							}
+							QString tmp;
+							QString name = pg.attribute("Name");
+							name += "("+tmp.setNum(dialogGradients->count())+")";
+							dialogGradients->insert(name, gra);
 						}
-						else if (pg.tagName()=="draw:color" && pg.attribute("draw:name")!=CommonStrings::None)
+					}
+				}
+				else if (pg.tagName()=="draw:color" && pg.attribute("draw:name")!=CommonStrings::None)
+				{
+					if (pg.hasAttribute("draw:color"))
+						lf.setNamedColor(pg.attribute("draw:color"));
+					lf.setSpotColor(false);
+					lf.setRegistrationColor(false);
+					QString nam = pg.attribute("draw:name");
+					if (!nam.isEmpty())
+						EditColors.tryAddColor(nam, lf);
+				}
+				else if (dTag == "VivaColors")
+				{
+					int cVal = 0;
+					int mVal = 0;
+					int yVal = 0;
+					int kVal = 0;
+					QString nam = nameMask.arg(pg.attribute("name"));
+					if (pg.attribute("type") == "cmyk")
+					{
+						QDomNode colNode = pg.firstChild();
+						while (!colNode.isNull())
 						{
-							if (pg.hasAttribute("draw:color"))
-								lf.setNamedColor(pg.attribute("draw:color"));
-							lf.setSpotColor(false);
-							lf.setRegistrationColor(false);
-							QString nam = pg.attribute("draw:name");
-							if (!nam.isEmpty())
-								EditColors.tryAddColor(nam, lf);
+							QDomElement colVal = colNode.toElement();
+							if (colVal.tagName() == "cyan")
+								cVal = colVal.text().toInt();
+							if (colVal.tagName() == "magenta")
+								mVal = colVal.text().toInt();
+							if (colVal.tagName() == "yellow")
+								yVal = colVal.text().toInt();
+							if (colVal.tagName() == "key")
+								kVal = colVal.text().toInt();
+							colNode = colNode.nextSibling();
 						}
-						else if (dTag == "VivaColors")
+						lf.setColorF(cVal / 100.0, mVal / 100.0, yVal / 100.0, kVal / 100.0);
+						lf.setSpotColor(false);
+						lf.setRegistrationColor(false);
+						if (!nam.isEmpty())
+							EditColors.tryAddColor(nam, lf);
+					}
+					else if (pg.attribute("type") == "rgb")
+					{
+						QDomNode colNode = pg.firstChild();
+						while (!colNode.isNull())
 						{
-							int cVal = 0;
-							int mVal = 0;
-							int yVal = 0;
-							int kVal = 0;
-							QString nam = nameMask.arg(pg.attribute("name"));
-							if (pg.attribute("type") == "cmyk")
-							{
-								QDomNode colNode = pg.firstChild();
-								while (!colNode.isNull())
-								{
-									QDomElement colVal = colNode.toElement();
-									if (colVal.tagName() == "cyan")
-										cVal = colVal.text().toInt();
-									if (colVal.tagName() == "magenta")
-										mVal = colVal.text().toInt();
-									if (colVal.tagName() == "yellow")
-										yVal = colVal.text().toInt();
-									if (colVal.tagName() == "key")
-										kVal = colVal.text().toInt();
-									colNode = colNode.nextSibling();
-								}
-								lf.setColorF(cVal / 100.0, mVal / 100.0, yVal / 100.0, kVal / 100.0);
-								lf.setSpotColor(false);
-								lf.setRegistrationColor(false);
-								if (!nam.isEmpty())
-									EditColors.tryAddColor(nam, lf);
-							}
-							else if (pg.attribute("type") == "rgb")
-							{
-								QDomNode colNode = pg.firstChild();
-								while (!colNode.isNull())
-								{
-									QDomElement colVal = colNode.toElement();
-									if (colVal.tagName() == "red")
-										cVal = colVal.text().toInt();
-									if (colVal.tagName() == "green")
-										mVal = colVal.text().toInt();
-									if (colVal.tagName() == "blue")
-										yVal = colVal.text().toInt();
-									colNode = colNode.nextSibling();
-								}
-								lf.setRgbColor(cVal, mVal, yVal);
-								lf.setSpotColor(false);
-								lf.setRegistrationColor(false);
-								if (!nam.isEmpty())
-									EditColors.tryAddColor(nam, lf);
-							}
+							QDomElement colVal = colNode.toElement();
+							if (colVal.tagName() == "red")
+								cVal = colVal.text().toInt();
+							if (colVal.tagName() == "green")
+								mVal = colVal.text().toInt();
+							if (colVal.tagName() == "blue")
+								yVal = colVal.text().toInt();
+							colNode = colNode.nextSibling();
 						}
-						PAGE=PAGE.nextSibling();
+						lf.setRgbColor(cVal, mVal, yVal);
+						lf.setSpotColor(false);
+						lf.setRegistrationColor(false);
+						if (!nam.isEmpty())
+							EditColors.tryAddColor(nam, lf);
 					}
+				}
+				PAGE=PAGE.nextSibling();
+			}
+		}
+		else
+		{
+			QString paletteName = "";
+			QString dummy;
+			if (ColorEn.startsWith("GIMP Palette"))
+			{
+				ColorEn = tsC.readLine();
+				ScTextStream CoE(&ColorEn, QIODevice::ReadOnly);
+				CoE >> dummy >> paletteName;
+			}
+			while (!tsC.atEnd())
+			{
+				ScColor tmp;
+				ColorEn = tsC.readLine();
+				if (ColorEn.length()>0 && ColorEn[0]==QChar('#'))
+					continue;
+				ScTextStream CoE(&ColorEn, QIODevice::ReadOnly);
+				CoE >> Rval;
+				CoE >> Gval;
+				CoE >> Bval;
+				if (cus)
+				{
+					CoE >> Kval;
+					Cname = CoE.readAll().trimmed();
+					tmp.setColor(Rval, Gval, Bval, Kval);
 				}
 				else
 				{
-					QString paletteName = "";
-					QString dummy;
-					if (ColorEn.startsWith("GIMP Palette"))
-					{
-						ColorEn = tsC.readLine();
-						ScTextStream CoE(&ColorEn, QIODevice::ReadOnly);
-						CoE >> dummy >> paletteName;
-					}
-					while (!tsC.atEnd())
-					{
-						ScColor tmp;
-						ColorEn = tsC.readLine();
-						if (ColorEn.length()>0 && ColorEn[0]==QChar('#'))
-							continue;
-						ScTextStream CoE(&ColorEn, QIODevice::ReadOnly);
-						CoE >> Rval;
-						CoE >> Gval;
-						CoE >> Bval;
-						if (cus)
-						{
-							CoE >> Kval;
-							Cname = CoE.readAll().trimmed();
-							tmp.setColor(Rval, Gval, Bval, Kval);
-						}
-						else
-						{
-							Cname = CoE.readAll().trimmed();
-							tmp.setRgbColor(Rval, Gval, Bval);
-						}
-						if (Cname == "Untitled")
-							Cname = "";
-						if (Cname.length() == 0)
-						{
-							if (!cus)
-								Cname = paletteName + QString("#%1%2%3").arg(Rval,2,16).arg(Gval,2,16).arg(Bval,2,16).toUpper();
-							else
-								Cname = paletteName + QString("#%1%2%3%4").arg(Rval,2,16).arg(Gval,2,16).arg(Bval,2,16).arg(Kval,2,16).toUpper();
-							Cname.replace(" ","0");
-						}
-						EditColors.tryAddColor(Cname, tmp);
-					}
+					Cname = CoE.readAll().trimmed();
+					tmp.setRgbColor(Rval, Gval, Bval);
 				}
-				fiC.close();
+				if (Cname == "Untitled")
+					Cname = "";
+				if (Cname.length() == 0)
+				{
+					if (!cus)
+						Cname = paletteName + QString("#%1%2%3").arg(Rval,2,16).arg(Gval,2,16).arg(Bval,2,16).toUpper();
+					else
+						Cname = paletteName + QString("#%1%2%3%4").arg(Rval,2,16).arg(Gval,2,16).arg(Bval,2,16).arg(Kval,2,16).toUpper();
+					Cname.replace(" ","0");
+				}
+				EditColors.tryAddColor(Cname, tmp);
 			}
 		}
-	}
+		fiC.close();
+	}
+
 
 	return (EditColors.count() != oldCount);
 }

Modified: trunk/Scribus/scribus/util_color.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/util_color.h
==============================================================================
--- trunk/Scribus/scribus/util_color.h	(original)
+++ trunk/Scribus/scribus/util_color.h	Tue Aug 14 20:13:04 2018
@@ -19,14 +19,14 @@
 
 class ScribusDoc;
 
-QColor SCRIBUS_API SetColor(ScribusDoc *currentDoc, QString color, int shad);
+QColor SCRIBUS_API SetColor(ScribusDoc *currentDoc, const QString& color, int shad);
 
 /*! \brief Create a cool all-infos pixmaps for the specified color.
 \param col Scribus color
 \retval QPixmap image with various icons depending on the col properties.
  */
-QPixmap SCRIBUS_API *getSmallPixmap(QColor rgb);
-QPixmap SCRIBUS_API *getWidePixmap(QColor rgb);
+QPixmap SCRIBUS_API *getSmallPixmap(const QColor& rgb);
+QPixmap SCRIBUS_API *getWidePixmap(const QColor& rgb);
 QPixmap SCRIBUS_API *getFancyPixmap(const ScColor& col, ScribusDoc* doc);
 
 /*! \brief Put toPaint pixmap into target at the x, y place.
@@ -117,6 +117,6 @@
  * \param EditColors Color list to store the imported colors
  * \return true if any colors have been found
 */
-bool SCRIBUS_API importColorsFromFile(QString fileName, ColorList &EditColors, QHash<QString,VGradient> *dialogGradients = nullptr, bool merge = false);
+bool SCRIBUS_API importColorsFromFile(const QString& fileName, ColorList &EditColors, QHash<QString,VGradient> *dialogGradients = nullptr, bool merge = false);
 
 #endif

Modified: trunk/Scribus/scribus/util_ghostscript.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/util_ghostscript.cpp
==============================================================================
--- trunk/Scribus/scribus/util_ghostscript.cpp	(original)
+++ trunk/Scribus/scribus/util_ghostscript.cpp	Tue Aug 14 20:13:04 2018
@@ -59,7 +59,7 @@
 using namespace std;
 
 
-int callGS(const QStringList& args_in, const QString device, const QString fileStdErr, const QString fileStdOut)
+int callGS(const QStringList& args_in, const QString& device, const QString& fileStdErr, const QString& fileStdOut)
 {
 	QString cmd;
  	QStringList args;
@@ -100,7 +100,7 @@
 	return System( getShortPathName(prefsManager->ghostscriptExecutable()), args, fileStdErr, fileStdOut );
 }
 
-int callGS(const QString& args_in, const QString device)
+int callGS(const QString& args_in, const QString& device)
 {
 	PrefsManager* prefsManager=PrefsManager::instance();
 	QString cmd1 = getShortPathName(prefsManager->ghostscriptExecutable());
@@ -140,7 +140,7 @@
 	return system(cmd1.toLocal8Bit().constData());
 }
 
-int convertPS2PS(QString in, QString out, const QStringList& opts, int level)
+int convertPS2PS(const QString& in, const QString& out, const QStringList& opts, int level)
 {
 	PrefsManager* prefsManager=PrefsManager::instance();
 	QStringList args;
@@ -177,7 +177,7 @@
 	return ret;
 }
 
-int convertPS2PDF(QString in, QString out, const QStringList& opts)
+int convertPS2PDF(const QString& in, const QString& out, const QStringList& opts)
 {
 	PrefsManager* prefsManager=PrefsManager::instance();
 	QStringList args;
@@ -194,7 +194,7 @@
 	return ret;
 }
 
-bool testGSAvailability( void )
+bool testGSAvailability()
 {
 	QStringList args;
 	PrefsManager* prefsManager = PrefsManager::instance();
@@ -273,12 +273,10 @@
 	if (!success)
 		return false;
 	minor = ver.section('.', 1, 1).toInt(&success);
-	if (!success)
-		return false;
-	return true;
-}
-
-QString getGSDefaultExeName(void)
+	return success;
+}
+
+QString getGSDefaultExeName()
 {
 	QString gsName("gs");
 #if defined _WIN32
@@ -421,7 +419,7 @@
 	return gsVersions;
 }
 
-QPixmap LoadPDF(QString fn, int Page, int Size, int *w, int *h)
+QPixmap LoadPDF(const QString& fn, int Page, int Size, int *w, int *h)
 {
 	QString tmp;
 	QString pdfFile = QDir::toNativeSeparators(fn);

Modified: trunk/Scribus/scribus/util_ghostscript.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/util_ghostscript.h
==============================================================================
--- trunk/Scribus/scribus/util_ghostscript.h	(original)
+++ trunk/Scribus/scribus/util_ghostscript.h	Tue Aug 14 20:13:04 2018
@@ -21,7 +21,7 @@
 
 #include "scribusapi.h"
 
-QPixmap SCRIBUS_API LoadPDF(QString fn, int Page, int Size, int *w, int *h);
+QPixmap SCRIBUS_API LoadPDF(const QString& fn, int Page, int Size, int *w, int *h);
 /**
  * @brief Call GhostScript synchronously and store output
    *
@@ -38,10 +38,10 @@
    * @param args_in Custom arguments to GhostScript
    * @param device GS device to use (defaults to an image device if omitted)
  */
-int     SCRIBUS_API callGS(const QStringList& args_in, const QString device="", const QString fileStdErr = "", const QString fileStdOut = "");
-int     SCRIBUS_API callGS(const QString& args_in, const QString device="");
-int     SCRIBUS_API convertPS2PS(QString in, QString out, const QStringList& opts, int level);
-int     SCRIBUS_API convertPS2PDF(QString in, QString out, const QStringList& opts);
+int     SCRIBUS_API callGS(const QStringList& args_in, const QString& device="", const QString& fileStdErr = "", const QString& fileStdOut = "");
+int     SCRIBUS_API callGS(const QString& args_in, const QString& device="");
+int     SCRIBUS_API convertPS2PS(const QString& in, const QString& out, const QStringList& opts, int level);
+int     SCRIBUS_API convertPS2PDF(const QString& in, const QString& out, const QStringList& opts);
 bool    SCRIBUS_API testGSAvailability( void );
 bool    SCRIBUS_API testGSAvailability( const QString& gsPath );
 bool    SCRIBUS_API testGSDeviceAvailability( const QString& device );

Modified: trunk/Scribus/scribus/util_math.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/util_math.cpp
==============================================================================
--- trunk/Scribus/scribus/util_math.cpp	(original)
+++ trunk/Scribus/scribus/util_math.cpp	Tue Aug 14 20:13:04 2018
@@ -30,7 +30,7 @@
 
 using namespace std;
 
-uint getDouble(const QByteArray in, bool raw)
+uint getDouble(const QByteArray& in, bool raw)
 {
 	QByteArray bb(4, ' ');
 	if (raw)
@@ -344,7 +344,8 @@
 	const QVector<QRect> rects = shape.rects();
 	pbox = (rectCount == 1) ? &boundingRect : rects.constData();
 	pboxEnd = pbox + rectCount;
-	for (; pbox < pboxEnd; ++pbox) {
+	for (; pbox < pboxEnd; ++pbox)
+	{
 		if (pbox->bottom() < ry)
 			continue;
 
@@ -389,7 +390,7 @@
 	/*bool newResult = partIn ? ((ry <= prect->bottom()) ? false : true) : false;
 	if (oldResult != newResult)
 		int test = 0;*/
-	return partIn ? ((ry <= prect->bottom()) ? false : true) : false;
+	return partIn ? (ry > prect->bottom()) : false;
 }
 
 QPolygon FlattenPath(const FPointArray& ina, QList<uint> &Segs)
@@ -406,10 +407,10 @@
 			Segs.append(outa.size());
 			continue;
 		}
-		FPoint a1 = ina.point(poi);
-		FPoint a2 = ina.point(poi+1);
-		FPoint a3 = ina.point(poi+3);
-		FPoint a4 = ina.point(poi+2);
+		const FPoint& a1 = ina.point(poi);
+		const FPoint& a2 = ina.point(poi+1);
+		const FPoint& a3 = ina.point(poi+3);
+		const FPoint& a4 = ina.point(poi+2);
 		QPainterPath Bez;
 		Bez.moveTo(a1.x(), a1.y());
 		Bez.cubicTo(a2.x(), a2.y(), a3.x(), a3.y(), a4.x(), a4.y());

Modified: trunk/Scribus/scribus/util_math.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22632&path=/trunk/Scribus/scribus/util_math.h
==============================================================================
--- trunk/Scribus/scribus/util_math.h	(original)
+++ trunk/Scribus/scribus/util_math.h	Tue Aug 14 20:13:04 2018
@@ -29,7 +29,7 @@
 If premultiplication does not allow to store result in a long value, perform a standard comparison.
 */
 bool SCRIBUS_API compareDouble(double a, double b);
-uint SCRIBUS_API getDouble(const QByteArray in, bool raw);
+uint SCRIBUS_API getDouble(const QByteArray& in, bool raw);
 FPoint   SCRIBUS_API getMaxClipF(FPointArray* Clip);
 FPoint   SCRIBUS_API getMinClipF(FPointArray* Clip);
 FPoint   SCRIBUS_API projectPointOnLine(FPoint p, QPointF lineStart, QPointF lineEnd);




More information about the scribus-commit mailing list