r22605 by craig - clazy and clang fixes, part 5

scribus-commit scribus-commit at lists.scribus.net
Sun Aug 5 10:46:27 UTC 2018


Author: craig
Date: Sun Aug  5 10:46:27 2018
New Revision: 22605

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

Modified:
    trunk/Scribus/scribus/imagedataloaders/scimgdataloader_jpeg.cpp
    trunk/Scribus/scribus/imagedataloaders/scimgdataloader_pict.cpp
    trunk/Scribus/scribus/imagedataloaders/scimgdataloader_pict.h
    trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp
    trunk/Scribus/scribus/imagedataloaders/scimgdataloader_psd.cpp
    trunk/Scribus/scribus/imagedataloaders/scimgdataloader_tiff.cpp
    trunk/Scribus/scribus/imagedataloaders/scimgdataloader_wpg.cpp

Modified: trunk/Scribus/scribus/imagedataloaders/scimgdataloader_jpeg.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22605&path=/trunk/Scribus/scribus/imagedataloaders/scimgdataloader_jpeg.cpp
==============================================================================
--- trunk/Scribus/scribus/imagedataloaders/scimgdataloader_jpeg.cpp	(original)
+++ trunk/Scribus/scribus/imagedataloaders/scimgdataloader_jpeg.cpp	Sun Aug  5 10:46:27 2018
@@ -78,7 +78,7 @@
 	jpeg_read_header(&cinfo, true);
 	//jpeg_start_decompress(&cinfo);
 	unsigned int EmbedLen = 0;
-	unsigned char* EmbedBuffer = 0;
+	unsigned char* EmbedBuffer = nullptr;
 	if (read_jpeg_marker(ICC_MARKER, &cinfo, &EmbedBuffer, &EmbedLen))
 	{
 		bool profileIsValid = false;
@@ -317,7 +317,7 @@
 	}
 
 	unsigned int PhotoshopLen = 0;
-	unsigned char * PhotoshopBuffer = 0;
+	unsigned char * PhotoshopBuffer = nullptr;
 	if (read_jpeg_marker(PHOTOSHOP_MARKER, &cinfo, &PhotoshopBuffer, &PhotoshopLen) )
 	{
 		bool savEx = m_imageInfoRecord.exifDataValid;
@@ -382,10 +382,10 @@
 				m_image = m_imageInfoRecord.exifInfo.thumbnail.copy();
 			m_pixelFormat = Format_BGRA_8;
 		}
-		m_imageInfoRecord.valid = (m_imageInfoRecord.PDSpathData.size())>0?true:false; // The only interest is vectormask
+		m_imageInfoRecord.valid = (m_imageInfoRecord.PDSpathData.size())>0; // The only interest is vectormask
 		arrayPhot.clear();
 		free(PhotoshopBuffer );
-		PhotoshopBuffer = 0;
+		PhotoshopBuffer = nullptr;
 		if (m_imageInfoRecord.exifDataValid && !m_imageInfoRecord.exifInfo.thumbnail.isNull() && thumbnail)
 		{
 			jpeg_destroy_decompress(&cinfo);

Modified: trunk/Scribus/scribus/imagedataloaders/scimgdataloader_pict.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22605&path=/trunk/Scribus/scribus/imagedataloaders/scimgdataloader_pict.cpp
==============================================================================
--- trunk/Scribus/scribus/imagedataloaders/scimgdataloader_pict.cpp	(original)
+++ trunk/Scribus/scribus/imagedataloaders/scimgdataloader_pict.cpp	Sun Aug  5 10:46:27 2018
@@ -1165,7 +1165,7 @@
 	alignStreamToWord(ts, 0);
 }
 
-void ScImgDataLoader_PICT::createTextPath(QByteArray textString)
+void ScImgDataLoader_PICT::createTextPath(const QByteArray& textString)
 {
 	QTextCodec *codec = QTextCodec::codecForName("Apple Roman");
 	QString string = codec->toUnicode(textString);
@@ -1174,7 +1174,7 @@
 		textFont = QFont();
 	else
 	{
-		QString fontName = m_fontMap[m_currentFontID];
+		QString fontName(m_fontMap[m_currentFontID]);
 		textFont = QFont(fontName, m_currentTextSize);
 //		QFontInfo inf(textFont);
 //		qDebug() << "Using Font" << inf.family() << "for" << fontName;

Modified: trunk/Scribus/scribus/imagedataloaders/scimgdataloader_pict.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22605&path=/trunk/Scribus/scribus/imagedataloaders/scimgdataloader_pict.h
==============================================================================
--- trunk/Scribus/scribus/imagedataloaders/scimgdataloader_pict.h	(original)
+++ trunk/Scribus/scribus/imagedataloaders/scimgdataloader_pict.h	Sun Aug  5 10:46:27 2018
@@ -50,7 +50,7 @@
 	void handleDHText(QDataStream &ts);
 	void handleDVText(QDataStream &ts);
 	void handleDHVText(QDataStream &ts);
-	void createTextPath(QByteArray textString);
+	void createTextPath(const QByteArray& textString);
 	void handlePenMode(QDataStream &ts);
 	void handlePenSize(QDataStream &ts);
 	void handleOvalSize(QDataStream &ts);

Modified: trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22605&path=/trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp
==============================================================================
--- trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp	(original)
+++ trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp	Sun Aug  5 10:46:27 2018
@@ -202,7 +202,7 @@
 					f2.close();
 					imgc.resize(0);
 					ScImage thum;
-					CMSettings cms(0, "", Intent_Perceptual);
+					CMSettings cms(nullptr, "", Intent_Perceptual);
 					cms.allowColorManagement(false);
 					bool mode = true;
 					if (thum.loadPicture(tmpFile, 1, cms, ScImage::RGBData, 72, &mode))
@@ -410,8 +410,8 @@
 								fakeHeader.width = qRound(b);
 								fakeHeader.height = qRound(h);
 								parseRessourceData(strPhot, fakeHeader, psdata.size());
-								m_imageInfoRecord.valid = (m_imageInfoRecord.PDSpathData.size()) > 0 ? true : false;
-								if (m_imageInfoRecord.PDSpathData.size() > 0)
+								m_imageInfoRecord.valid = (m_imageInfoRecord.PDSpathData.size()) > 0;
+								if (!m_imageInfoRecord.PDSpathData.empty())
 								{
 									QTransform mm;
 									mm.scale(m_imageInfoRecord.xres / 72.0, m_imageInfoRecord.yres / 72.0);
@@ -1757,10 +1757,7 @@
 			m_image.setDotsPerMeterY ((int) (yres / 0.0254));
 			return true;
 		}
-		else
-		{
-			qDebug() << "Ghostscript returned result" << retg;
-		}
+		qDebug() << "Ghostscript returned result" << retg;
 		return false;
 	}
 	m_imageInfoRecord.actualPageNumber = page;

Modified: trunk/Scribus/scribus/imagedataloaders/scimgdataloader_psd.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22605&path=/trunk/Scribus/scribus/imagedataloaders/scimgdataloader_psd.cpp
==============================================================================
--- trunk/Scribus/scribus/imagedataloaders/scimgdataloader_psd.cpp	(original)
+++ trunk/Scribus/scribus/imagedataloaders/scimgdataloader_psd.cpp	Sun Aug  5 10:46:27 2018
@@ -37,7 +37,7 @@
 	initSupportedFormatList();
 }
 
-void ScImgDataLoader_PSD::initSupportedFormatList(void)
+void ScImgDataLoader_PSD::initSupportedFormatList()
 {
 	m_supportedFormats.clear();
 	m_supportedFormats.append( "psd" );
@@ -509,21 +509,15 @@
 			m_imageInfoRecord.valid = true;
 			return re;
 		}
-		else
-		{
-			// Try to decode simple psd file, no layers
-			s.device()->seek(startLayers + layerDataLen);
-			if(s.atEnd())
-				return false;
-			return loadLayer( s, header);
-		}
-	}
-	else
-	{
-		// Decoding simple psd file, no layers
-		s.device()->seek( s.device()->pos() + layerDataLen );
-		loadLayer( s, header);
-	}
+		// Try to decode simple psd file, no layers
+		s.device()->seek(startLayers + layerDataLen);
+		if(s.atEnd())
+			return false;
+		return loadLayer( s, header);
+	}
+	// Decoding simple psd file, no layers
+	s.device()->seek( s.device()->pos() + layerDataLen );
+	loadLayer( s, header);
 	return true;
 }
 
@@ -1075,7 +1069,7 @@
 		{
 			unsigned char *s;
 			unsigned char *d;
-			unsigned char *sm = 0;
+			unsigned char *sm = nullptr;
 			unsigned char r, g, b, src_r, src_g, src_b, src_a, src_alpha, dst_alpha;
 			unsigned char a = 0;
 			uchar new_r, new_g, new_b;
@@ -1086,7 +1080,7 @@
 				s = r2_image.scanLine(qMin(i, r2_image.height()-1));
 				d += qMin(static_cast<int>(startDstX),  r_image.width()-1) * r_image.channels();
 				s += qMin(static_cast<int>(startSrcX), r2_image.width()-1) * r2_image.channels();
-				sm = 0;
+				sm = nullptr;
 				if (hasMask)
 				{
 					sm = mask.scanLine(qMin(i, mask.height()-1));
@@ -1556,9 +1550,7 @@
 
 bool ScImgDataLoader_PSD::IsValid( const PSDHeader & header )
 {
-	if( header.signature != 0x38425053 )
-		return false;
-	return true;
+	return header.signature == 0x38425053;
 }
 
 // Check that the header is supported.
@@ -1570,10 +1562,8 @@
 		return false;
 	if ( header.depth != 8 )
 		return false;
-	if ((header.color_mode == CM_RGB) || (header.color_mode == CM_CMYK) || (header.color_mode == CM_LABCOLOR)
-	 || (header.color_mode == CM_GRAYSCALE) || (header.color_mode == CM_INDEXED) || (header.color_mode == CM_DUOTONE))
-		return true;
-	return false;
+	return (header.color_mode == CM_RGB) || (header.color_mode == CM_CMYK) || (header.color_mode == CM_LABCOLOR)
+	 || (header.color_mode == CM_GRAYSCALE) || (header.color_mode == CM_INDEXED) || (header.color_mode == CM_DUOTONE);
 }
 
 void ScImgDataLoader_PSD::putDuotone(uchar *ptr, uchar cbyte)
@@ -1591,13 +1581,13 @@
 	}
 	else if (m_colorTableSc.count() == 2)
 	{
-		ScColorEngine::getCMYKValues(m_colorTableSc[0], NULL, cmyk);
+		ScColorEngine::getCMYKValues(m_colorTableSc[0], nullptr, cmyk);
 		cmyk.getValues(c, m, y, k);
 		c = qMin((c * m_curveTable1[(int)cb]) >> 8, 255);
 		m = qMin((m * m_curveTable1[(int)cb]) >> 8, 255);
 		y = qMin((y * m_curveTable1[(int)cb]) >> 8, 255);
 		k = qMin((k * m_curveTable1[(int)cb]) >> 8, 255);
-		ScColorEngine::getCMYKValues(m_colorTableSc[1], NULL, cmyk);
+		ScColorEngine::getCMYKValues(m_colorTableSc[1], nullptr, cmyk);
 		cmyk.getValues(c1, m1, y1, k1);
 		c1 = qMin((c1 * m_curveTable2[(int)cb]) >> 8, 255);
 		m1 = qMin((m1 * m_curveTable2[(int)cb]) >> 8, 255);
@@ -1611,19 +1601,19 @@
 	}
 	else if (m_colorTableSc.count() == 3)
 	{
-		ScColorEngine::getCMYKValues(m_colorTableSc[0], NULL, cmyk);
+		ScColorEngine::getCMYKValues(m_colorTableSc[0], nullptr, cmyk);
 		cmyk.getValues(c, m, y, k);
 		c = qMin((c * m_curveTable1[(int)cb]) >> 8, 255);
 		m = qMin((m * m_curveTable1[(int)cb]) >> 8, 255);
 		y = qMin((y * m_curveTable1[(int)cb]) >> 8, 255);
 		k = qMin((k * m_curveTable1[(int)cb]) >> 8, 255);
-		ScColorEngine::getCMYKValues(m_colorTableSc[1], NULL, cmyk);
+		ScColorEngine::getCMYKValues(m_colorTableSc[1], nullptr, cmyk);
 		cmyk.getValues(c1, m1, y1, k1);
 		c1 = qMin((c1 * m_curveTable2[(int)cb]) >> 8, 255);
 		m1 = qMin((m1 * m_curveTable2[(int)cb]) >> 8, 255);
 		y1 = qMin((y1 * m_curveTable2[(int)cb]) >> 8, 255);
 		k1 = qMin((k1 * m_curveTable2[(int)cb]) >> 8, 255);
-		ScColorEngine::getCMYKValues(m_colorTableSc[2], NULL, cmyk);
+		ScColorEngine::getCMYKValues(m_colorTableSc[2], nullptr, cmyk);
 		cmyk.getValues(c2, m2, y2, k2);
 		c2 = qMin((c2 * m_curveTable3[(int)cb]) >> 8, 255);
 		m2 = qMin((m2 * m_curveTable3[(int)cb]) >> 8, 255);
@@ -1637,25 +1627,25 @@
 	}
 	else if (m_colorTableSc.count() == 4)
 	{
-		ScColorEngine::getCMYKValues(m_colorTableSc[0], NULL, cmyk);
+		ScColorEngine::getCMYKValues(m_colorTableSc[0], nullptr, cmyk);
 		cmyk.getValues(c, m, y, k);
 		c = qMin((c * m_curveTable1[(int)cb]) >> 8, 255);
 		m = qMin((m * m_curveTable1[(int)cb]) >> 8, 255);
 		y = qMin((y * m_curveTable1[(int)cb]) >> 8, 255);
 		k = qMin((k * m_curveTable1[(int)cb]) >> 8, 255);
-		ScColorEngine::getCMYKValues(m_colorTableSc[1], NULL, cmyk);
+		ScColorEngine::getCMYKValues(m_colorTableSc[1], nullptr, cmyk);
 		cmyk.getValues(c1, m1, y1, k1);
 		c1 = qMin((c1 * m_curveTable2[(int)cb]) >> 8, 255);
 		m1 = qMin((m1 * m_curveTable2[(int)cb]) >> 8, 255);
 		y1 = qMin((y1 * m_curveTable2[(int)cb]) >> 8, 255);
 		k1 = qMin((k1 * m_curveTable2[(int)cb]) >> 8, 255);
-		ScColorEngine::getCMYKValues(m_colorTableSc[2], NULL, cmyk);
+		ScColorEngine::getCMYKValues(m_colorTableSc[2], nullptr, cmyk);
 		cmyk.getValues(c2, m2, y2, k2);
 		c2 = qMin((c2 * m_curveTable3[(int)cb]) >> 8, 255);
 		m2 = qMin((m2 * m_curveTable3[(int)cb]) >> 8, 255);
 		y2 = qMin((y2 * m_curveTable3[(int)cb]) >> 8, 255);
 		k2 = qMin((k2 * m_curveTable3[(int)cb]) >> 8, 255);
-		ScColorEngine::getCMYKValues(m_colorTableSc[3], NULL, cmyk);
+		ScColorEngine::getCMYKValues(m_colorTableSc[3], nullptr, cmyk);
 		cmyk.getValues(c3, m3, y3, k3);
 		c3 = qMin((c3 * m_curveTable4[(int)cb]) >> 8, 255);
 		m3 = qMin((m3 * m_curveTable4[(int)cb]) >> 8, 255);

Modified: trunk/Scribus/scribus/imagedataloaders/scimgdataloader_tiff.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22605&path=/trunk/Scribus/scribus/imagedataloaders/scimgdataloader_tiff.cpp
==============================================================================
--- trunk/Scribus/scribus/imagedataloaders/scimgdataloader_tiff.cpp	(original)
+++ trunk/Scribus/scribus/imagedataloaders/scimgdataloader_tiff.cpp	Sun Aug  5 10:46:27 2018
@@ -84,7 +84,7 @@
 	hasAlpha = false;
 	if (testAlphaChannelAvailability(fn, page, hasAlpha))
 	{
-		if (hasAlpha == false)
+		if (!hasAlpha)
 			success = true;
 		else if (loadPicture(fn, page, res, false))
 		{
@@ -118,7 +118,7 @@
 
 	do
 	{
-		char *layerName=0;
+		char *layerName=nullptr;
 		TIFFGetField(tif, TIFFTAG_PAGENAME, &layerName);
 		QString name = QString(layerName);
 		if (name.isEmpty())
@@ -250,7 +250,7 @@
 
 bool ScImgDataLoader_TIFF::getImageData(TIFF* tif, RawImage *image, uint widtht, uint heightt, uint size, uint16 photometric, uint16 bitspersample, uint16 samplesperpixel, bool &bilevel, bool &isCMYK)
 {
-	uint32 *bits = 0;
+	uint32 *bits = nullptr;
 	if (photometric == PHOTOMETRIC_SEPARATED)
 	{
 		if (samplesperpixel > 5)
@@ -355,7 +355,7 @@
 {
 	bool gotData = false;
 	uint32* bits = (uint32 *) _TIFFmalloc(size * sizeof(uint32));
-	uint16  extrasamples(0), *extratypes(0);
+	uint16  extrasamples(0), *extratypes(nullptr);
 	if (!TIFFGetField (tif, TIFFTAG_EXTRASAMPLES, &extrasamples, &extratypes))
 		extrasamples = 0;
 	if (bits)
@@ -690,7 +690,7 @@
 
 	bool isCMYK = false;
 	unsigned int widtht, heightt, size;
-	char *description=0, *copyright=0, *datetime=0, *artist=0, *scannerMake=0, *scannerModel=0;
+	char *description=nullptr, *copyright=nullptr, *datetime=nullptr, *artist=nullptr, *scannerMake=nullptr, *scannerModel=nullptr;
 	uint16 bitspersample, fillorder, planar;
 
 	TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &widtht);
@@ -752,7 +752,7 @@
 			m_imageInfoRecord.exifInfo.width = widtht;
 			m_imageInfoRecord.exifInfo.height = heightt;
 			if (!m_imageInfoRecord.valid)
-				m_imageInfoRecord.valid = (m_imageInfoRecord.PDSpathData.size())>0?true:false;
+				m_imageInfoRecord.valid = (m_imageInfoRecord.PDSpathData.size())>0;
 			if (thumbnail)
 			{
 				if (m_photometric == PHOTOMETRIC_SEPARATED)
@@ -948,7 +948,7 @@
 			QImage imt; //QImage imt = tmpImg.copy();
 			double sx = tmpImg.width() / 40.0;
 			double sy = tmpImg.height() / 40.0;
-			imt = tmpImg.convertToQImage((chans > 4) ? true : false);
+			imt = tmpImg.convertToQImage(chans > 4);
 			imt = sy < sx ?	imt.scaled(qRound(imt.width() / sx), qRound(imt.height() / sx), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) :
 										imt.scaled(qRound(imt.width() / sy), qRound(imt.height() / sy), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
 			m_imageInfoRecord.layerInfo[layerNum].thumb = imt.copy();
@@ -1555,7 +1555,7 @@
 				unsigned char *s = r2_image.scanLine(qMin(i, r2_image.height()-1));
 				d += qMin(static_cast<int>(startDstX),  r_image.width()-1) * r_image.channels();
 				s += qMin(static_cast<int>(startSrcX), r2_image.width()-1) * r2_image.channels();
-				unsigned char *sm = 0;
+				unsigned char *sm = nullptr;
 				if (hasMask)
 				{
 					sm = mask.scanLine(qMin(i, mask.height()-1));

Modified: trunk/Scribus/scribus/imagedataloaders/scimgdataloader_wpg.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22605&path=/trunk/Scribus/scribus/imagedataloaders/scimgdataloader_wpg.cpp
==============================================================================
--- trunk/Scribus/scribus/imagedataloaders/scimgdataloader_wpg.cpp	(original)
+++ trunk/Scribus/scribus/imagedataloaders/scimgdataloader_wpg.cpp	Sun Aug  5 10:46:27 2018
@@ -23,7 +23,7 @@
 	isGradient(false),
 	fillSet(false),
 	strokeSet(false),
-	image(NULL)
+	image(nullptr)
 {
 }
 




More information about the scribus-commit mailing list