r15022 by jghali - #9059 : rotated text frame corrupts document Replace a bunch of double initialization by +/- 99999.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:22:39 CEST 2010


Revision: 15022
Author: jghali
Date: 2010-04-27T22:19:42.980112Z
Commit message: #9059 : rotated text frame corrupts document
Replace a bunch of double initialization by +/- 99999.9 by corresponding std::numeric_limits values. Use a specific sclimits.h to avoid some msvc quirks

Changeset: 
M  /branches/Version135/Scribus/win32/vc8/Scribus-1.3.x.vcproj
M  /branches/Version135/Scribus/scribus/pageitem.cpp
M  /branches/Version135/Scribus/scribus/scribusXml.cpp
A  /branches/Version135/Scribus/scribus/sclimits.h
M  /branches/Version135/Scribus/scribus/scribusdoc.cpp

Diffs:
Index: scribus/sclimits.h
===================================================================
--- scribus/sclimits.h	(revision 0)
+++ scribus/sclimits.h	(revision 15022)
@@ -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/scribusXml.cpp
===================================================================
--- scribus/scribusXml.cpp	(revision 15021)
+++ scribus/scribusXml.cpp	(revision 15022)
@@ -52,6 +52,7 @@
 #include "util_math.h"
 #include "util_color.h"
 #include "scpattern.h"
+#include "sclimits.h"
 #include "scxmlstreamwriter.h"
 #include "scpainter.h"
 
@@ -1785,10 +1786,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 15021)
+++ scribus/pageitem.cpp	(revision 15022)
@@ -62,6 +62,7 @@
 #include "scribuswin.h"
 #include "sctextstream.h"
 #include "selection.h"
+#include "sclimits.h"
 #include "text/nlsconfig.h"
 #include "undomanager.h"
 #include "undostate.h"
@@ -1542,10 +1543,10 @@
 {
 	QList<PageItem*> emG;
 	emG.clear();
-	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();
 	if (Groups.count() != 0)
 	{
 		for (int ga=0; ga<m_Doc->Items->count(); ++ga)
@@ -4290,10 +4291,10 @@
 
 void PageItem::getBoundingRect(double *x1, double *y1, double *x2, double *y2) const
 {
-	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();
 	if (Rot != 0)
 	{
 		FPointArray pb;
@@ -4432,10 +4433,10 @@
 
 void PageItem::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
 {
-	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 extraSpace = 0.0;
 	if (NamedLStyle.isEmpty())
 	{
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 15021)
+++ scribus/scribusdoc.cpp	(revision 15022)
@@ -68,6 +68,7 @@
 #include "scribusdoc.h"
 #include "scribusview.h"
 #include "scribuswin.h"
+#include "sclimits.h"
 #include "selection.h"
 #include "serializer.h"
 #include "storyeditor.h"
@@ -4017,10 +4018,10 @@
 void ScribusDoc::canvasMinMax(FPoint& minPoint, FPoint& maxPoint)
 {
 	PageItem *currItem;
-	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();
 	uint docItemsCount=Items->count();
 	if (docItemsCount != 0)
 	{
@@ -7996,7 +7997,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newX = 99999.9;
+	double newX = std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -8066,7 +8067,8 @@
 			newX=currentPage()->xOffset() + guidePosition;
 			break;
 		case alignSelection:
-			double minX=99999.9, maxX=-99999.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);
@@ -8092,7 +8094,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newX = -99999.9;
+	double newX = std::numeric_limits<double>::min();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -8137,7 +8139,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newX = -99999.9;
+	double newX = std::numeric_limits<double>::min();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -8182,7 +8184,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newY = 99999.9;
+	double newY = std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -8225,7 +8227,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newY = 99999.9;
+	double newY = std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -8295,7 +8297,8 @@
 			newY=currentPage()->yOffset() + guidePosition;
 			break;
 		case alignSelection:
-			double minY=99999.9, maxY=-99999.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);
@@ -8321,7 +8324,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newY = -99999.9;
+	double newY = std::numeric_limits<double>::min();
 	switch ( currAlignTo ) 
 	{
 		case alignFirst:
@@ -8366,7 +8369,7 @@
 		return;
 	uint alignObjectsCount=AObjects.count();
 	int loopStart=0, loopEnd=alignObjectsCount-1;
-	double newY = -99999.9;
+	double newY = std::numeric_limits<double>::min();
 	switch ( currAlignTo )
 	{
 		case alignFirst:
@@ -10054,10 +10057,10 @@
 			lowestItem = qMin(lowestItem, currItem->ItemNr);
 			highestItem = qMax(highestItem, currItem->ItemNr);
 		}
-		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();
 		for (uint ep = 0; ep < selectedItemCount; ++ep)
 		{
 			PageItem* currItem = itemSelection->itemAt(ep);
Index: win32/vc8/Scribus-1.3.x.vcproj
===================================================================
--- win32/vc8/Scribus-1.3.x.vcproj	(revision 15021)
+++ win32/vc8/Scribus-1.3.x.vcproj	(revision 15022)
@@ -7268,6 +7268,10 @@
 				</FileConfiguration>
 			</File>
 			<File
+				RelativePath="..\..\scribus\sclimits.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\scribus\sclistboxpixmap.h"
 				>
 			</File>




More information about the scribus-commit mailing list