r23337 by jghali - Code style fixes

scribus-commit scribus-commit at lists.scribus.net
Wed Nov 6 02:24:27 UTC 2019


Author: jghali
Date: Wed Nov  6 02:24:27 2019
New Revision: 23337

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

Modified:
    trunk/Scribus/scribus/scimage.cpp
    trunk/Scribus/scribus/scpainter.cpp

Modified: trunk/Scribus/scribus/scimage.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23337&path=/trunk/Scribus/scribus/scimage.cpp
==============================================================================
--- trunk/Scribus/scribus/scimage.cpp	(original)
+++ trunk/Scribus/scribus/scimage.cpp	Wed Nov  6 02:24:27 2019
@@ -1612,8 +1612,8 @@
 	}
 	xscale = (double) newcols / (double) cols;
 	yscale = (double) newrows / (double) rows;
-	sxscale = (long)(xscale * SCALE);
-	syscale = (long)(yscale * SCALE);
+	sxscale = (long) (xscale * SCALE);
+	syscale = (long) (yscale * SCALE);
 	if ( newrows != rows )	/* shortcut Y scaling if possible */
 		tempxelrow = new QRgb[cols];
 	as = new long[cols];
@@ -1623,19 +1623,19 @@
 	rowsread = 0;
 	fracrowleft = syscale;
 	needtoreadrow = 1;
-	for ( col = 0; col < cols; ++col )
+	for (col = 0; col < cols; ++col)
 		rs[col] = gs[col] =  as[col] = bs[col] = HALFSCALE;
 	fracrowtofill = SCALE;
-	for ( row = 0; row < newrows; ++row )
+	for (row = 0; row < newrows; ++row)
 	{
 		if ( newrows == rows )
-			tempxelrow = xelrow = (QRgb*)scanLine(rowsread++);
+			tempxelrow = xelrow = (QRgb*) scanLine(rowsread++);
 		else
 		{
 			while ( fracrowleft < fracrowtofill )
 			{
 				if ( needtoreadrow && rowsread < rows )
-					xelrow = (QRgb*)scanLine(rowsread++);
+					xelrow = (QRgb*) scanLine(rowsread++);
 				for ( col = 0, xP = xelrow; col < cols; ++col, ++xP )
 				{
 					as[col] += fracrowleft * qAlpha( *xP );
@@ -1647,13 +1647,13 @@
 				fracrowleft = syscale;
 				needtoreadrow = 1;
 			}
-			if ( needtoreadrow && rowsread < rows )
-			{
-				xelrow = (QRgb*)scanLine(rowsread++);
+			if (needtoreadrow && rowsread < rows)
+			{
+				xelrow = (QRgb*) scanLine(rowsread++);
 				needtoreadrow = 0;
 			}
-			long a=0;
-			for ( col = 0, xP = xelrow, nxP = tempxelrow; col < cols; ++col, ++xP, ++nxP )
+			long a = 0;
+			for (col = 0, xP = xelrow, nxP = tempxelrow; col < cols; ++col, ++xP, ++nxP)
 			{
 				long r, g, b;
 				a = as[col] + fracrowtofill * qAlpha( *xP );
@@ -1661,114 +1661,126 @@
 				g = gs[col] + fracrowtofill * qGreen( *xP );
 				b = bs[col] + fracrowtofill * qBlue( *xP );
 				r /= SCALE;
-				if ( r > maxval ) r = maxval;
+				if (r > maxval)
+					r = maxval;
 				g /= SCALE;
-				if ( g > maxval ) g = maxval;
+				if (g > maxval)
+					g = maxval;
 				b /= SCALE;
-				if ( b > maxval ) b = maxval;
+				if (b > maxval)
+					b = maxval;
 				a /= SCALE;
-				if ( a > maxval ) a = maxval;
-				*nxP = qRgba( (int)r, (int)g, (int)b , (int)a);
+				if (a > maxval)
+					a = maxval;
+				*nxP = qRgba((int) r, (int) g, (int) b , (int) a);
 				rs[col] = as[col] = gs[col] = bs[col] = HALFSCALE;
 			}
 			fracrowleft -= fracrowtofill;
-			if ( fracrowleft == 0 )
+			if (fracrowleft == 0)
 			{
 				fracrowleft = syscale;
 				needtoreadrow = 1;
 			}
 			fracrowtofill = SCALE;
 		}
-		if ( newcols == cols )
+		if (newcols == cols)
 			memcpy(dst.scanLine(rowswritten++), tempxelrow, newcols*4);
 		else
 		{
 			long a, r, g, b;
 			long fraccoltofill, fraccolleft = 0;
 			int needcol;
-			nxP = (QRgb*)dst.scanLine(rowswritten++);
+			nxP = (QRgb*) dst.scanLine(rowswritten++);
 			QRgb *nxPEnd = nxP + newcols;
 			fraccoltofill = SCALE;
 			a = r = g = b = HALFSCALE;
 			needcol = 0;
-			for ( col = 0, xP = tempxelrow; col < cols; ++col, ++xP )
+			for (col = 0, xP = tempxelrow; col < cols; ++col, ++xP)
 			{
 				fraccolleft = sxscale;
-				while ( fraccolleft >= fraccoltofill )
+				while (fraccolleft >= fraccoltofill)
 				{
-					if ( needcol )
+					if (needcol)
 					{
 						++nxP;
 						a = r = g = b = HALFSCALE;
 					}
-					a += fraccoltofill * qAlpha( *xP );
-					r += fraccoltofill * qRed( *xP );
-					g += fraccoltofill * qGreen( *xP );
-					b += fraccoltofill * qBlue( *xP );
+					a += fraccoltofill * qAlpha(*xP);
+					r += fraccoltofill * qRed(*xP);
+					g += fraccoltofill * qGreen(*xP);
+					b += fraccoltofill * qBlue(*xP);
 					r /= SCALE;
-					if ( r > maxval ) r = maxval;
+					if (r > maxval)
+						r = maxval;
 					g /= SCALE;
-					if ( g > maxval ) g = maxval;
+					if (g > maxval)
+						g = maxval;
 					b /= SCALE;
-					if ( b > maxval ) b = maxval;
+					if (b > maxval)
+						b = maxval;
 					a /= SCALE;
-					if ( a > maxval ) a = maxval;
-					*nxP = qRgba( (int)r, (int)g, (int)b, (int)a );
+					if (a > maxval)
+						a = maxval;
+					*nxP = qRgba((int) r, (int) g, (int) b, (int) a);
 					fraccolleft -= fraccoltofill;
 					fraccoltofill = SCALE;
 					needcol = 1;
 				}
-				if ( fraccolleft > 0 )
+				if (fraccolleft > 0)
 				{
-					if ( needcol )
+					if (needcol)
 					{
 						++nxP;
 						a = r = g = b = HALFSCALE;
 						needcol = 0;
 					}
-					a += fraccolleft * qAlpha( *xP );
-					r += fraccolleft * qRed( *xP );
-					g += fraccolleft * qGreen( *xP );
-					b += fraccolleft * qBlue( *xP );
+					a += fraccolleft * qAlpha(*xP);
+					r += fraccolleft * qRed(*xP);
+					g += fraccolleft * qGreen(*xP);
+					b += fraccolleft * qBlue(*xP);
 					fraccoltofill -= fraccolleft;
 				}
 			}
-			if ( fraccoltofill > 0 )
+			if (fraccoltofill > 0)
 			{
 				--xP;
-				a += fraccoltofill * qAlpha( *xP );
-				r += fraccoltofill * qRed( *xP );
-				g += fraccoltofill * qGreen( *xP );
-				b += fraccoltofill * qBlue( *xP );
+				a += fraccoltofill * qAlpha(*xP);
+				r += fraccoltofill * qRed(*xP);
+				g += fraccoltofill * qGreen(*xP);
+				b += fraccoltofill * qBlue(*xP);
 			}
 			if (nxP < nxPEnd)
 			{
 				r /= SCALE;
-				if ( r > maxval ) r = maxval;
+				if (r > maxval)
+					r = maxval;
 				g /= SCALE;
-				if ( g > maxval ) g = maxval;
+				if (g > maxval)
+					g = maxval;
 				b /= SCALE;
-				if ( b > maxval ) b = maxval;
+				if (b > maxval)
+					b = maxval;
 				a /= SCALE;
-				if ( a > maxval ) a = maxval;
-				*nxP = qRgba( (int)r, (int)g, (int)b, (int)a );
+				if (a > maxval)
+					a = maxval;
+				*nxP = qRgba((int) r, (int) g, (int) b, (int) a);
 				while (++nxP != nxPEnd)
 					nxP[0] = nxP[-1];
 			}
 		}
 	}
-	if ( newrows != rows && tempxelrow )// Robust, tempxelrow might be 0 1 day
+	if (newrows != rows && tempxelrow) // Robust, tempxelrow might be 0 1 day
 		delete [] tempxelrow;
 	delete [] as;
 	delete [] rs;
 	delete [] gs;
 	delete [] bs;
 	QImage::operator=(QImage(nwidth, nheight, QImage::Format_ARGB32));
-	for (int yi=0; yi < dst.height(); ++yi)
-	{
-		QRgb *s = (QRgb*)(dst.scanLine( yi ));
-		QRgb *d = (QRgb*)(scanLine( yi ));
-		for (int xi=0; xi < dst.width(); ++xi)
+	for (int yi = 0; yi < dst.height(); ++yi)
+	{
+		QRgb *s = (QRgb*) dst.scanLine(yi);
+		QRgb *d = (QRgb*) scanLine(yi);
+		for (int xi = 0; xi < dst.width(); ++xi)
 		{
 			(*d) = (*s);
 			s++;
@@ -1833,7 +1845,7 @@
 	yscale = (double) newrows / (double) rows;
 	sxscale = (long)(xscale * SCALE);
 	syscale = (long)(yscale * SCALE);
-	if ( newrows != rows )	/* shortcut Y scaling if possible */
+	if (newrows != rows)	/* shortcut Y scaling if possible */
 		tempxelrow = new unsigned char[cols * nChannels];
 	ps = new long[cols];
 
@@ -1874,12 +1886,13 @@
 				{
 					p = ps[col] + fracrowtofill * (*xP);
 					p /= SCALE;
-					if ( p > maxval ) p = maxval;
+					if (p > maxval)
+						p = maxval;
 					*nxP = (unsigned char) p;
 					ps[col] = HALFSCALE;
 				}
 				fracrowleft -= fracrowtofill;
-				if ( fracrowleft == 0 )
+				if (fracrowleft == 0)
 				{
 					fracrowleft = syscale;
 					needtoreadrow = 1;
@@ -1903,16 +1916,17 @@
 				for (col = 0, xP = tempxelrow + chIndex; col < cols; ++col, xP += nChannels)
 				{
 					fraccolleft = sxscale;
-					while ( fraccolleft >= fraccoltofill )
+					while (fraccolleft >= fraccoltofill)
 					{
-						if ( needcol )
+						if (needcol)
 						{
 							nxP += nChannels;
 							p = HALFSCALE;
 						}
-						p += fraccoltofill * ( *xP );
+						p += fraccoltofill * (*xP);
 						p /= SCALE;
-						if ( p > maxval ) p = maxval;
+						if (p > maxval)
+							p = maxval;
 						*nxP = (unsigned char) p;
 						fraccolleft -= fraccoltofill;
 						fraccoltofill = SCALE;
@@ -1938,7 +1952,8 @@
 				if (nxP < nxPEnd)
 				{
 					p /= SCALE;
-					if ( p > maxval ) p = maxval;
+					if (p > maxval)
+						p = maxval;
 					*nxP = (unsigned char) p;
 					while ((nxP += nChannels) != nxPEnd)
 						nxP[0] = nxP[-nChannels];
@@ -1952,10 +1967,10 @@
 
 	int scanWidth = dst.width() * nChannels;
 	QImage::operator=(QImage(nwidth, nheight, this->format()));
-	for (int yi=0; yi < dst.height(); ++yi)
-	{
-		uchar *s = (dst.scanLine( yi ));
-		uchar *d = (scanLine( yi ));
+	for (int yi = 0; yi < dst.height(); ++yi)
+	{
+		uchar *s = dst.scanLine(yi);
+		uchar *d = scanLine(yi);
 		memcpy(d, s, scanWidth);
 	}
 }
@@ -2068,10 +2083,10 @@
 			alpha.resize(hm * wm);
 			if (alpha.size() > 0) // 
 			{
-				for (int yi=0; yi < hm; ++yi)
+				for (int yi = 0; yi < hm; ++yi)
 				{
-					s = (QRgb*)(rImage.scanLine( yi ));
-					for (int xi=0; xi < wm; ++xi)
+					s = (QRgb*) rImage.scanLine(yi);
+					for (int xi = 0; xi < wm; ++xi)
 					{
 						r = *s++;
 						u = qAlpha(r);
@@ -2094,12 +2109,12 @@
 			alpha.resize(hm * w2);
 			if (alpha.size() > 0)
 			{
-				for (int yi=0; yi < hm; ++yi)
+				for (int yi = 0; yi < hm; ++yi)
 				{
 					s = iMask.scanLine( yi );
-					for (int xi=0; xi < w2; ++xi)
+					for (int xi = 0; xi < w2; ++xi)
 					{
-						u = *(s+xi);
+						u = *(s + xi);
 						if (PDF) u = ~u;
 						alpha[i++] = u;
 					}

Modified: trunk/Scribus/scribus/scpainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23337&path=/trunk/Scribus/scribus/scpainter.cpp
==============================================================================
--- trunk/Scribus/scribus/scpainter.cpp	(original)
+++ trunk/Scribus/scribus/scpainter.cpp	Wed Nov  6 02:24:27 2019
@@ -24,8 +24,8 @@
 
 ScPainter::ScPainter( QImage *target, int w, int h, double transparency, int blendmode )
 {
-	Q_ASSERT(w>=0);
-	Q_ASSERT(h>=0);
+	Q_ASSERT(w >= 0);
+	Q_ASSERT(h >= 0);
 	m_maskPattern = nullptr;
 	m_pattern = nullptr;
 	m_imageMask = nullptr;
@@ -675,10 +675,10 @@
 			int k;
 			QRgb *s;
 			QRgb r;
-			for (int yi=0; yi < h; ++yi)
+			for (int yi = 0; yi < h; ++yi)
 			{
 				s = (QRgb*)(m_imageQ.scanLine( yi ));
-				for (int xi=0; xi < w; ++xi)
+				for (int xi = 0; xi < w; ++xi)
 				{
 					r = *s;
 					if (qAlpha(r) == 0)
@@ -1471,7 +1471,7 @@
 		return;
 
 	newPath();
-	for (int poi=0; poi<points->size()-3; poi += 4)
+	for (int poi = 0; poi < points->size() - 3; poi += 4)
 	{
 		if (points->isMarker(poi))
 		{
@@ -1513,7 +1513,7 @@
 		return;
 
 	newPath();
-	for (int poi=0; poi<points->size()-3; poi += 4)
+	for (int poi = 0; poi < points->size() - 3; poi += 4)
 	{
 		if (points->isMarker(poi))
 		{
@@ -1952,9 +1952,9 @@
 	int divsum = (div+1)>>1;
 	divsum *= divsum;
 	int *dv = new int[256*divsum];
-	for (i=0; i < 256*divsum; ++i)
-	{
-		dv[i] = (i/divsum);
+	for (i = 0; i < 256 * divsum; ++i)
+	{
+		dv[i] = (i / divsum);
 	}
 	yw = yi = 0;
 	int **stack = new int*[div];
@@ -1985,38 +1985,38 @@
 				aoutsum += sir[0];
 		}
 		stackpointer = radius;
-		for (x=0; x < w; ++x)
+		for (x = 0; x < w; ++x)
 		{
 			a[yi] = dv[asum];
 			asum -= aoutsum;
 			stackstart = stackpointer-radius+div;
-			sir = stack[stackstart%div];
+			sir = stack[stackstart % div];
 			aoutsum -= sir[0];
 			if (y == 0)
-				vmin[x] = qMin(x+radius+1,wm);
-			p = pix[yw+vmin[x]];
+				vmin[x] = qMin(x + radius + 1, wm);
+			p = pix[yw + vmin[x]];
 			sir[0] = qAlpha(p);
 			ainsum += sir[0];
 			asum += ainsum;
-			stackpointer = (stackpointer+1)%div;
-			sir = stack[(stackpointer)%div];
+			stackpointer = (stackpointer + 1) % div;
+			sir = stack[(stackpointer) % div];
 			aoutsum += sir[0];
 			ainsum -= sir[0];
 			++yi;
 		}
 		yw += w;
 	}
-	for (x=0; x < w; ++x)
+	for (x = 0; x < w; ++x)
 	{
 		ainsum = aoutsum = asum = 0;
 		yp = -radius * w;
 		for (i = -radius; i <= radius; ++i)
 		{
-			yi=qMax(0,yp)+x;
-			sir = stack[i+radius];
+			yi = qMax(0, yp) + x;
+			sir = stack[i + radius];
 			sir[0] = a[yi];
-			rbs = r1-abs(i);
-			asum += a[yi]*rbs;
+			rbs = r1 - abs(i);
+			asum += a[yi] * rbs;
 			if (i > 0)
 				ainsum += sir[0];
 			else
@@ -2028,18 +2028,18 @@
 		}
 		yi = x;
 		stackpointer = radius;
-		for (y=0; y < h; ++y)
+		for (y = 0; y < h; ++y)
 		{
 			pix[yi] = qRgba(qRed(pix[yi]), qGreen(pix[yi]), qBlue(pix[yi]), dv[asum]);
 			asum -= aoutsum;
-			stackstart = stackpointer-radius+div;
+			stackstart = stackpointer - radius + div;
 			sir = stack[stackstart%div];
 			aoutsum -= sir[0];
-			if (x==0)
+			if (x == 0)
 			{
-				vmin[y] = qMin(y+r1,hm)*w;
+				vmin[y] = qMin(y + r1, hm) * w;
 			}
-			p = x+vmin[y];
+			p = x + vmin[y];
 			sir[0] = a[p];
 			ainsum += sir[0];
 			asum += ainsum;
@@ -2083,9 +2083,9 @@
 	int divsum = (div+1)>>1;
 	divsum *= divsum;
 	int *dv = new int[256*divsum];
-	for (i=0; i < 256*divsum; ++i)
-	{
-		dv[i] = (i/divsum);
+	for (i = 0; i < 256 * divsum; ++i)
+	{
+		dv[i] = (i / divsum);
 	}
 	yw = yi = 0;
 	int **stack = new int*[div];
@@ -2105,17 +2105,17 @@
 		rinsum = ginsum = binsum = ainsum = routsum = goutsum = boutsum = aoutsum = rsum = gsum = bsum = asum = 0;
 		for (i = -radius; i <= radius; ++i)
 		{
-			p = pix[yi+qMin(wm,qMax(i,0))];
-			sir = stack[i+radius];
+			p = pix[yi + qMin(wm, qMax(i, 0))];
+			sir = stack[i + radius];
 			sir[0] = qRed(p);
 			sir[1] = qGreen(p);
 			sir[2] = qBlue(p);
 			sir[3] = qAlpha(p);
-			rbs = r1-abs(i);
-			rsum += sir[0]*rbs;
-			gsum += sir[1]*rbs;
-			bsum += sir[2]*rbs;
-			asum += sir[3]*rbs;
+			rbs = r1 - abs(i);
+			rsum += sir[0] * rbs;
+			gsum += sir[1] * rbs;
+			bsum += sir[2] * rbs;
+			asum += sir[3] * rbs;
 			if (i > 0)
 			{
 				rinsum += sir[0];
@@ -2132,7 +2132,7 @@
 			}
 		}
 		stackpointer = radius;
-		for (x=0; x < w; ++x)
+		for (x = 0; x < w; ++x)
 		{
 			r[yi] = dv[rsum];
 			g[yi] = dv[gsum];
@@ -2142,17 +2142,17 @@
 			gsum -= goutsum;
 			bsum -= boutsum;
 			asum -= aoutsum;
-			stackstart = stackpointer-radius+div;
-			sir = stack[stackstart%div];
+			stackstart = stackpointer - radius + div;
+			sir = stack[stackstart % div];
 			routsum -= sir[0];
 			goutsum -= sir[1];
 			boutsum -= sir[2];
 			aoutsum -= sir[3];
 			if (y == 0)
 			{
-				vmin[x] = qMin(x+radius+1,wm);
+				vmin[x] = qMin(x + radius + 1,wm);
 			}
-			p = pix[yw+vmin[x]];
+			p = pix[yw + vmin[x]];
 			sir[0] = qRed(p);
 			sir[1] = qGreen(p);
 			sir[2] = qBlue(p);
@@ -2179,23 +2179,23 @@
 		}
 		yw += w;
 	}
-	for (x=0; x < w; ++x)
+	for (x = 0; x < w; ++x)
 	{
 		rinsum = ginsum = binsum = ainsum = routsum = goutsum = boutsum = aoutsum = rsum = gsum = bsum = asum = 0;
 		yp =- radius * w;
-		for (i=-radius; i <= radius; ++i)
-		{
-			yi=qMax(0,yp)+x;
-			sir = stack[i+radius];
+		for (i = -radius; i <= radius; ++i)
+		{
+			yi = qMax(0, yp) + x;
+			sir = stack[i + radius];
 			sir[0] = r[yi];
 			sir[1] = g[yi];
 			sir[2] = b[yi];
 			sir[3] = a[yi];
 			rbs = r1-abs(i);
-			rsum += r[yi]*rbs;
-			gsum += g[yi]*rbs;
-			bsum += b[yi]*rbs;
-			asum += a[yi]*rbs;
+			rsum += r[yi] * rbs;
+			gsum += g[yi] * rbs;
+			bsum += b[yi] * rbs;
+			asum += a[yi] * rbs;
 			if (i > 0)
 			{
 				rinsum += sir[0];
@@ -2217,24 +2217,24 @@
 		}
 		yi = x;
 		stackpointer = radius;
-		for (y=0; y < h; ++y)
+		for (y = 0; y < h; ++y)
 		{
 			pix[yi] = qRgba(dv[rsum], dv[gsum], dv[bsum], dv[asum]);
 			rsum -= routsum;
 			gsum -= goutsum;
 			bsum -= boutsum;
 			asum -= aoutsum;
-			stackstart = stackpointer-radius+div;
-			sir = stack[stackstart%div];
+			stackstart = stackpointer - radius + div;
+			sir = stack[stackstart % div];
 			routsum -= sir[0];
 			goutsum -= sir[1];
 			boutsum -= sir[2];
 			aoutsum -= sir[3];
-			if (x==0)
+			if (x == 0)
 			{
-				vmin[y] = qMin(y+r1,hm)*w;
+				vmin[y] = qMin(y + r1, hm) * w;
 			}
-			p = x+vmin[y];
+			p = x + vmin[y];
 			sir[0] = r[p];
 			sir[1] = g[p];
 			sir[2] = b[p];
@@ -2247,7 +2247,7 @@
 			gsum += ginsum;
 			bsum += binsum;
 			asum += ainsum;
-			stackpointer = (stackpointer+1)%div;
+			stackpointer = (stackpointer + 1) % div;
 			sir = stack[stackpointer];
 			routsum += sir[0];
 			goutsum += sir[1];




More information about the scribus-commit mailing list