r14441 by fschmid - Xara Importer: protect skew calculation from invalid values.

scribus-commit scribus-commit at lists.scribus.net
Sun Dec 20 13:40:24 CET 2009


Revision: 14441
Author: fschmid
Date: 2009-12-20T01:00:05.932667Z
Commit message: Xara Importer: protect skew calculation from invalid values.

Changeset: 
M  /trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
M  /trunk/Scribus/scribus/ui/cpalette.cpp

Diffs:
Index: scribus/ui/cpalette.cpp
===================================================================
--- scribus/ui/cpalette.cpp	(revision 14440)
+++ scribus/ui/cpalette.cpp	(revision 14441)
@@ -700,12 +700,31 @@
 	m_Pattern_offsetX = dia->spinXoffset->value();
 	m_Pattern_offsetY = dia->spinYoffset->value();
 	m_Pattern_rotation = dia->spinAngle->value();
-	double a    = M_PI / 180.0 * dia->spinXSkew->value();
-	double b    = M_PI / 180.0 * dia->spinYSkew->value();
-	double sina = tan(a);
-	double sinb = tan(b);
-	m_Pattern_skewX = sina;
-	m_Pattern_skewY = sinb;
+	double skewX = dia->spinXSkew->value();
+	double a;
+	if (skewX == 90)
+		a = 1;
+	else if (skewX == 180)
+		a = 0;
+	else if (skewX == 270)
+		a = -1;
+	else if (skewX == 360)
+		a = 0;
+	else
+		a = tan(M_PI / 180.0 * skewX);
+	m_Pattern_skewX = tan(a);
+	skewX = dia->spinYSkew->value();
+	if (skewX == 90)
+		a = 1;
+	else if (skewX == 180)
+		a = 0;
+	else if (skewX == 270)
+		a = -1;
+	else if (skewX == 360)
+		a = 0;
+	else
+		a = tan(M_PI / 180.0 * skewX);
+	m_Pattern_skewY = tan(a);
 	m_Pattern_mirrorX = dia->FlipH->isChecked();
 	m_Pattern_mirrorY = dia->FlipV->isChecked();
 	delete dia;
@@ -735,12 +754,31 @@
 	m_Pattern_offsetXS = dia->spinXoffset->value();
 	m_Pattern_offsetYS = dia->spinYoffset->value();
 	m_Pattern_rotationS = dia->spinAngle->value();
-	double a    = M_PI / 180.0 * dia->spinXSkew->value();
-	double b    = M_PI / 180.0 * dia->spinYSkew->value();
-	double sina = tan(a);
-	double sinb = tan(b);
-	m_Pattern_skewXS = sina;
-	m_Pattern_skewYS = sinb;
+	double skewX = dia->spinXSkew->value();
+	double a;
+	if (skewX == 90)
+		a = 1;
+	else if (skewX == 180)
+		a = 0;
+	else if (skewX == 270)
+		a = -1;
+	else if (skewX == 360)
+		a = 0;
+	else
+		a = tan(M_PI / 180.0 * skewX);
+	m_Pattern_skewXS = tan(a);
+	skewX = dia->spinYSkew->value();
+	if (skewX == 90)
+		a = 1;
+	else if (skewX == 180)
+		a = 0;
+	else if (skewX == 270)
+		a = -1;
+	else if (skewX == 360)
+		a = 0;
+	else
+		a = tan(M_PI / 180.0 * skewX);
+	m_Pattern_skewYS = tan(a);
 	m_Pattern_spaceS = dia->spinSpacing->value() / 100.0;
 	m_Pattern_mirrorXS = dia->FlipH->isChecked();
 	m_Pattern_mirrorYS = dia->FlipV->isChecked();
Index: scribus/plugins/import/xar/importxar.cpp
===================================================================
--- scribus/plugins/import/xar/importxar.cpp	(revision 14440)
+++ scribus/plugins/import/xar/importxar.cpp	(revision 14441)
@@ -2106,7 +2106,19 @@
 		gc->patternOffsetX = 0.0;
 		gc->patternOffsetY = 0.0;
 		gc->patternRotation = -rotB;
-		gc->patternSkewX = tan(M_PI / 180.0 * (rotS - 90 - rotB));
+		double skewX = rotS - 90 - rotB;
+		double a;
+		if (skewX == 90)
+			a = 1;
+		else if (skewX == 180)
+			a = 0;
+		else if (skewX == 270)
+			a = -1;
+		else if (skewX == 360)
+			a = 0;
+		else
+			a = tan(M_PI / 180.0 * skewX);
+		gc->patternSkewX = tan(a);
 		gc->patternSkewY = 0.0;
 		if (textData.count() > 0)
 		{
@@ -2220,7 +2232,19 @@
 		gc->patternOffsetX = 0.0;
 		gc->patternOffsetY = 0.0;
 		gc->patternRotation = -rotB;
-		gc->patternSkewX = tan(M_PI / 180.0 * (rotS - 90 - rotB));
+		double skewX = rotS - 90 - rotB;
+		double a;
+		if (skewX == 90)
+			a = 1;
+		else if (skewX == 180)
+			a = 0;
+		else if (skewX == 270)
+			a = -1;
+		else if (skewX == 360)
+			a = 0;
+		else
+			a = tan(M_PI / 180.0 * skewX);
+		gc->patternSkewX = tan(a);
 		gc->patternSkewY = 0.0;
 		if (textData.count() > 0)
 		{




More information about the scribus-commit mailing list