r15023 by jghali - Replace a bunch of double initialization by +/- 999999.9 by corresponding std::numeric_limits values. Use a specific sclimits.h to avoid some msvc quirks.

scribus-commit scribus-commit at lists.scribus.net
Wed Apr 28 00:30:40 CEST 2010


Revision: 15023
Author: jghali
Date: 2010-04-27T22:23:22.558776Z
Commit message: Replace a bunch of double initialization by +/- 999999.9 by corresponding std::numeric_limits values. Use a specific sclimits.h to avoid some msvc quirks.

Changeset: 
M  /trunk/Scribus/scribus/scribus.cpp
M  /trunk/Scribus/scribus/pageitem.cpp
M  /trunk/Scribus/scribus/scribusXml.cpp
A  /trunk/Scribus/scribus/sclimits.h
M  /trunk/Scribus/scribus/scribusdoc.cpp
M  /trunk/Scribus/win32/vc8/Scribus.vcproj

Diffs:
Index: scribus/sclimits.h
===================================================================
--- scribus/sclimits.h	(revision 0)
+++ scribus/sclimits.h	(revision 15023)
@@ -0,0 +1,25 @@
+/*
+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
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+#ifndef SCLIMITS_H
+#define SCLIMITS_H
+
+#if defined(_MSC_VER)
+#define _USE_MATH_DEFINES
+#endif
+
+#include <limits>
+
+#ifdef _WIN32
+#ifdef min
+	#undef min
+#endif
+#ifdef max
+	#undef max
+#endif
+#endif
+
+#endif
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 15022)
+++ scribus/scribusdoc.cpp	(revision 15023)
@@ -21,7 +21,6 @@
  *                                                                         *
  ***************************************************************************/
 
-
 #include <utility>
 
 #include <QByteArray>
@@ -66,6 +65,7 @@
 #include "colormgmt/sccolormgmtenginefactory.h"
 #include "scclocale.h"
 #include "scpainter.h"
+#include "sclimits.h"
 #include "scraction.h"
 #include "scribus.h"
 #include "scribusXml.h"
@@ -85,7 +85,6 @@
 #include "util_math.h"
 
 
-
 // static const bool FRAMESELECTION_EDITS_DEFAULTSTYLE = false;
 
 
@@ -4642,10 +4641,10 @@
 void ScribusDoc::canvasMinMax(FPoint& minPoint, FPoint& maxPoint)
 {
 	PageItem *currItem;
-	double minx = 9999999.9;
-	double miny = 9999999.9;
-	double maxx = -9999999.9;
-	double maxy = -9999999.9;
+	double minx = std::numeric_limits<double>::max();
+	double miny = std::numeric_limits<double>::max();
+	double maxx = std::numeric_limits<double>::min();
+	double maxy = std::numeric_limits<double>::min();
 	uint docItemsCount=Items->count();
 	if (docItemsCount != 0)
 	{
@@ -8784,7 +8783,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newX = 9999999.9;
+	double newX = std::numeric_limits<double>::max();
 	switch ( currAlignTo )
 	{
 		case alignFirst:
@@ -8827,7 +8826,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newX = 9999999.9;
+	double newX = std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -8897,7 +8896,8 @@
 			newX=currentPage()->xOffset() + guidePosition;
 			break;
 		case alignSelection:
-			double minX=9999999.9, maxX=-9999999.9;
+			double minX = std::numeric_limits<double>::max();
+			double maxX = std::numeric_limits<double>::min();
 			for (uint a = 0; a < alignObjectsCount; ++a)
 			{
 				minX = qMin(AObjects[a].x1, minX);
@@ -8923,7 +8923,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newX = -9999999.9;
+	double newX = std::numeric_limits<double>::min();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -8968,7 +8968,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newX = -9999999.9;
+	double newX = std::numeric_limits<double>::min();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -9013,7 +9013,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newY = 9999999.9;
+	double newY = std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -9056,7 +9056,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newY = 9999999.9;
+	double newY = std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -9126,7 +9126,8 @@
 			newY=currentPage()->yOffset() + guidePosition;
 			break;
 		case alignSelection:
-			double minY=9999999.9, maxY=-9999999.9;
+			double minY = std::numeric_limits<double>::max();
+			double maxY = std::numeric_limits<double>::min();
 			for (uint a = 0; a < alignObjectsCount; ++a)
 			{
 				minY = qMin(AObjects[a].y1, minY);
@@ -9152,7 +9153,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newY = -9999999.9;
+	double newY = std::numeric_limits<double>::min();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -9197,7 +9198,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newY = -9999999.9;
+	double newY = std::numeric_limits<double>::min();
 	switch ( currAlignTo )
 	{
 		case alignFirst:
@@ -9758,8 +9759,8 @@
 	int itemIndex=itX.value(); //get our first item's index in the AObjects array
 //	bool found=false;
 //	double itXX=itX.key();
-	minY=9999999.9;
-	maxY=-9999999.9;
+	minY = std::numeric_limits<double>::max();
+	maxY = std::numeric_limits<double>::min();
 	int nextItemIndex=itemIndex;
 	circleList.append(nextItemIndex);
 	++circleListCounter;
@@ -9872,8 +9873,8 @@
 	int itemIndex=itX.value(); //get our first item's index in the AObjects array
 //	bool found=false;
 //	double itXX=itX.key();
-	minY=9999999.9;
-	maxY=-9999999.9;
+	minY = std::numeric_limits<double>::max();
+	maxY = std::numeric_limits<double>::min();
 	int nextItemIndex=itemIndex;
 	circleList.append(nextItemIndex);
 	++circleListCounter;
@@ -11129,10 +11130,10 @@
 			lowestItem = qMin(lowestItem, currItem->ItemNr);
 			highestItem = qMax(highestItem, currItem->ItemNr);
 		}
-		double minx = 9999999.9;
-		double miny = 9999999.9;
-		double maxx = -9999999.9;
-		double maxy = -9999999.9;
+		double minx = std::numeric_limits<double>::max();
+		double miny = std::numeric_limits<double>::max();
+		double maxx = std::numeric_limits<double>::min();
+		double maxy = std::numeric_limits<double>::min();
 		for (uint ep = 0; ep < selectedItemCount; ++ep)
 		{
 			PageItem* currItem = itemSelection->itemAt(ep);
Index: scribus/scribusXml.cpp
===================================================================
--- scribus/scribusXml.cpp	(revision 15022)
+++ scribus/scribusXml.cpp	(revision 15023)
@@ -55,13 +55,16 @@
 #include "util_text.h"
 #include "util_math.h"
 #include "util_color.h"
+#include "sclimits.h"
 #include "scpattern.h"
 #include "sctextstream.h"
 #include "scxmlstreamwriter.h"
 #include "scpainter.h"
 
+
 using namespace std;
 
+
 ScriXmlDoc::ScriXmlDoc()
 {
 	prefsManager=PrefsManager::instance();
@@ -2117,10 +2120,10 @@
 	{
 		if (item->rotation() != 0)
 		{
-			double minx = 99999.9;
-			double miny = 99999.9;
-			double maxx = -99999.9;
-			double maxy = -99999.9;
+			double minx = std::numeric_limits<double>::max();
+			double miny = std::numeric_limits<double>::max();
+			double maxx = std::numeric_limits<double>::min();
+			double maxy = std::numeric_limits<double>::min();
 			double xpo = item->xPos() - doc->currentPage()->xOffset();
 			double ypo = item->yPos() - doc->currentPage()->yOffset();
 			FPointArray pb(4);
Index: scribus/pageitem.cpp
===================================================================
--- scribus/pageitem.cpp	(revision 15022)
+++ scribus/pageitem.cpp	(revision 15023)
@@ -61,6 +61,7 @@
 #include "scribuswin.h"
 #include "sctextstream.h"
 #include "selection.h"
+#include "sclimits.h"
 #include "text/nlsconfig.h"
 #include "undomanager.h"
 #include "undostate.h"
@@ -2134,10 +2135,10 @@
 {
 	QList<PageItem*> emG;
 	emG.clear();
-	double minx = 9999999.9;
-	double miny = 9999999.9;
-	double maxx = -9999999.9;
-	double maxy = -9999999.9;
+	double minx = std::numeric_limits<double>::max();
+	double miny = std::numeric_limits<double>::max();
+	double maxx = std::numeric_limits<double>::min();
+	double maxy = std::numeric_limits<double>::min();
 	if (Groups.count() != 0)
 	{
 		for (int ga=0; ga<m_Doc->Items->count(); ++ga)
@@ -5376,10 +5377,10 @@
 
 void PageItem::getBoundingRect(double *x1, double *y1, double *x2, double *y2) const
 {
-	double minx = 9999999.9;
-	double miny = 9999999.9;
-	double maxx = -9999999.9;
-	double maxy = -9999999.9;
+	double minx = std::numeric_limits<double>::max();
+	double miny = std::numeric_limits<double>::max();
+	double maxx = std::numeric_limits<double>::min();
+	double maxy = std::numeric_limits<double>::min();
 	if (Rot != 0)
 	{
 		FPointArray pb;
@@ -5518,10 +5519,10 @@
 
 void PageItem::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
 {
-	double minx = 9999999.9;
-	double miny = 9999999.9;
-	double maxx = -9999999.9;
-	double maxy = -9999999.9;
+	double minx = std::numeric_limits<double>::max();
+	double miny = std::numeric_limits<double>::max();
+	double maxx = std::numeric_limits<double>::min();
+	double maxy = std::numeric_limits<double>::min();
 	double extraSpace = 0.0;
 	if (NamedLStyle.isEmpty())
 	{
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp	(revision 15022)
+++ scribus/scribus.cpp	(revision 15023)
@@ -229,12 +229,13 @@
 #include "plugins/formatidlist.h"
 #include "scimagecachemanager.h"
 
-
 #if defined(_WIN32)
 #include "scdocoutput_ps2.h"
 #include "scprintengine_gdi.h"
 #endif
 
+#include "sclimits.h"
+
 using namespace std;
 
 bool previewDinUse;
@@ -9707,10 +9708,10 @@
 	int ae = doc->Items->count();
 	if ((docSelectionCount > 1) && (!isGroup))
 	{
-		double minx = 9999999.9;
-		double miny = 9999999.9;
-		double maxx = -9999999.9;
-		double maxy = -9999999.9;
+		double minx = std::numeric_limits<double>::max();
+		double miny = std::numeric_limits<double>::max();
+		double maxx = std::numeric_limits<double>::min();
+		double maxy = std::numeric_limits<double>::min();
 		for (int as = ac+1; as < ae; ++as)
 		{
 			PageItem* currItem = doc->Items->at(as);
Index: win32/vc8/Scribus.vcproj
===================================================================
--- win32/vc8/Scribus.vcproj	(revision 15022)
+++ win32/vc8/Scribus.vcproj	(revision 15023)
@@ -8896,6 +8896,10 @@
 				</FileConfiguration>
 			</File>
 			<File
+				RelativePath="..\..\scribus\sclimits.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\scribus\sclistboxpixmap.h"
 				>
 			</File>




More information about the scribus-commit mailing list