r18883 by jghali - #12110: Inserting Tables/Bezier Curves after changing Line Preferences crashes Scribus

scribus-commit scribus-commit at lists.scribus.net
Thu Mar 6 21:21:09 UTC 2014


Author: jghali
Date: Thu Mar  6 21:21:09 2014
New Revision: 18883

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18883
Log:
#12110: Inserting Tables/Bezier Curves after changing Line Preferences crashes Scribus
This fix also use of arrow properties for computing bounding rect of items which do not display them

Modified:
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/pageitem_line.cpp
    trunk/Scribus/scribus/pageitem_line.h
    trunk/Scribus/scribus/pageitem_pathtext.cpp
    trunk/Scribus/scribus/pageitem_pathtext.h
    trunk/Scribus/scribus/pageitem_polyline.cpp
    trunk/Scribus/scribus/pageitem_polyline.h
    trunk/Scribus/scribus/pageitem_spiral.cpp
    trunk/Scribus/scribus/pageitem_spiral.h

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18883&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Thu Mar  6 21:21:09 2014
@@ -8544,117 +8544,6 @@
 		*x2 = m_xPos + qMax(1.0, qMax(m_width, m_lineWidth));
 		*y2 = m_yPos + qMax(1.0, qMax(m_height, m_lineWidth));
 	}
-	QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
-	if (m_startArrowIndex != 0)
-	{
-		QTransform arrowTrans;
-		FPointArray arrow = m_Doc->arrowStyles().at(m_startArrowIndex-1).points.copy();
-		arrowTrans.translate(m_xPos, m_yPos);
-		arrowTrans.rotate(m_rotation);
-		if (itemType() == Line)
-		{
-			arrowTrans.translate(0, 0);
-			arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
-			if (NamedLStyle.isEmpty())
-			{
-				if (m_lineWidth != 0.0)
-					arrowTrans.scale(m_lineWidth, m_lineWidth);
-			}
-			else
-			{
-				multiLine ml = m_Doc->MLineStyles[NamedLStyle];
-				if (ml[ml.size()-1].Width != 0.0)
-					arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
-			}
-			arrowTrans.scale(-1,1);
-			arrow.map(arrowTrans);
-		}
-		else
-		{
-			FPoint Start = PoLine.point(0);
-			for (int xx = 1; xx < PoLine.size(); xx += 2)
-			{
-				FPoint Vector = PoLine.point(xx);
-				if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
-				{
-					arrowTrans.translate(Start.x(), Start.y());
-					arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
-					arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
-					if (NamedLStyle.isEmpty())
-					{
-						if (m_lineWidth != 0.0)
-							arrowTrans.scale(m_lineWidth, m_lineWidth);
-					}
-					else
-					{
-						multiLine ml = m_Doc->MLineStyles[NamedLStyle];
-						if (ml[ml.size()-1].Width != 0.0)
-							arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
-					}
-					arrow.map(arrowTrans);
-					break;
-				}
-			}
-		}
-		FPoint minAr = getMinClipF(&arrow);
-		FPoint maxAr = getMaxClipF(&arrow);
-		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
-	}
-	if (m_endArrowIndex != 0)
-	{
-		QTransform arrowTrans;
-		FPointArray arrow = m_Doc->arrowStyles().at(m_endArrowIndex-1).points.copy();
-		arrowTrans.translate(m_xPos, m_yPos);
-		arrowTrans.rotate(m_rotation);
-		if (itemType() == Line)
-		{
-			arrowTrans.translate(m_width, 0);
-			arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
-			if (NamedLStyle.isEmpty())
-			{
-				if (m_lineWidth != 0.0)
-					arrowTrans.scale(m_lineWidth, m_lineWidth);
-			}
-			else
-			{
-				multiLine ml = m_Doc->MLineStyles[NamedLStyle];
-				if (ml[ml.size()-1].Width != 0.0)
-					arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
-			}
-			arrow.map(arrowTrans);
-		}
-		else
-		{
-			FPoint End = PoLine.point(PoLine.size()-2);
-			for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
-			{
-				FPoint Vector = PoLine.point(xx);
-				if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
-				{
-					arrowTrans.translate(End.x(), End.y());
-					arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
-					arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
-					if (NamedLStyle.isEmpty())
-					{
-						if (m_lineWidth != 0.0)
-							arrowTrans.scale(m_lineWidth, m_lineWidth);
-					}
-					else
-					{
-						multiLine ml = m_Doc->MLineStyles[NamedLStyle];
-						if (ml[ml.size()-1].Width != 0.0)
-							arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
-					}
-					arrow.map(arrowTrans);
-					break;
-				}
-			}
-		}
-		FPoint minAr = getMinClipF(&arrow);
-		FPoint maxAr = getMaxClipF(&arrow);
-		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
-	}
-	totalRect.getCoords(x1, y1, x2, y2);
 }
 
 void PageItem::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
@@ -8718,124 +8607,6 @@
 		*x2 = *x1 + qMax(visualWidth(), extraSpace);
 		*y2 = *y1 + qMax(visualHeight(), extraSpace);
 	}
-	QRectF totalRect(QPointF(*x1, *y1), QPointF(*x2, *y2));
-	if (m_startArrowIndex != 0)
-	{
-		QTransform arrowTrans;
-		FPointArray arrow = m_Doc->arrowStyles().at(m_startArrowIndex-1).points.copy();
-		arrowTrans.translate(m_xPos, m_yPos);
-		arrowTrans.rotate(m_rotation);
-		if (itemType() == Line)
-		{
-			arrowTrans.translate(0, 0);
-			arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
-			if (NamedLStyle.isEmpty())
-			{
-				if (m_lineWidth != 0.0)
-					arrowTrans.scale(m_lineWidth, m_lineWidth);
-			}
-			else
-			{
-				multiLine ml = m_Doc->MLineStyles[NamedLStyle];
-				if (ml[ml.size()-1].Width != 0.0)
-					arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
-			}
-			arrowTrans.scale(-1,1);
-			arrow.map(arrowTrans);
-		}
-		else
-		{
-			FPoint Start = PoLine.point(0);
-			for (int xx = 1; xx < PoLine.size(); xx += 2)
-			{
-				FPoint Vector = PoLine.point(xx);
-				if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
-				{
-					arrowTrans.translate(Start.x(), Start.y());
-					arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
-					arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
-					if (NamedLStyle.isEmpty())
-					{
-						if (m_lineWidth != 0.0)
-							arrowTrans.scale(m_lineWidth, m_lineWidth);
-					}
-					else
-					{
-						multiLine ml = m_Doc->MLineStyles[NamedLStyle];
-						if (ml[ml.size()-1].Width != 0.0)
-							arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
-					}
-					arrow.map(arrowTrans);
-					break;
-				}
-			}
-		}
-		FPoint minAr = getMinClipF(&arrow);
-		FPoint maxAr = getMaxClipF(&arrow);
-		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
-	}
-	if (m_endArrowIndex != 0)
-	{
-		QTransform arrowTrans;
-		FPointArray arrow = m_Doc->arrowStyles().at(m_endArrowIndex-1).points.copy();
-		arrowTrans.translate(m_xPos, m_yPos);
-		arrowTrans.rotate(m_rotation);
-		if (itemType() == Line)
-		{
-			arrowTrans.translate(m_width, 0);
-			arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
-			if (NamedLStyle.isEmpty())
-			{
-				if (m_lineWidth != 0.0)
-					arrowTrans.scale(m_lineWidth, m_lineWidth);
-			}
-			else
-			{
-				multiLine ml = m_Doc->MLineStyles[NamedLStyle];
-				if (ml[ml.size()-1].Width != 0.0)
-					arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
-			}
-			arrow.map(arrowTrans);
-		}
-		else
-		{
-			FPoint End = PoLine.point(PoLine.size()-2);
-			for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
-			{
-				FPoint Vector = PoLine.point(xx);
-				if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
-				{
-					arrowTrans.translate(End.x(), End.y());
-					arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
-					arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
-					if (NamedLStyle.isEmpty())
-					{
-						if (m_lineWidth != 0.0)
-							arrowTrans.scale(m_lineWidth, m_lineWidth);
-					}
-					else
-					{
-						multiLine ml = m_Doc->MLineStyles[NamedLStyle];
-						if (ml[ml.size()-1].Width != 0.0)
-							arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
-					}
-					arrow.map(arrowTrans);
-					break;
-				}
-			}
-		}
-		FPoint minAr = getMinClipF(&arrow);
-		FPoint maxAr = getMaxClipF(&arrow);
-		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
-	}
-	if (isPathText())
-	{
-		QTransform clipTrans;
-		clipTrans.translate(m_xPos, m_yPos);
-		clipTrans.rotate(m_rotation);
-		totalRect = totalRect.united(QRectF(clipTrans.mapRect(Clip.boundingRect())));
-	}
-	totalRect.getCoords(x1, y1, x2, y2);
 }
 
 double PageItem::visualXPos() const

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18883&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Thu Mar  6 21:21:09 2014
@@ -275,11 +275,13 @@
 	//added switch for not updating welded items - used by notes frames with automatic size adjusted
 	void updateClip(bool updateWelded = true);
 	void convertClip();
-	void getBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
-	void getVisualBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
+	
 	QRectF getBoundingRect() const;
 	QRectF getCurrentBoundingRect(double moreSpace = 0.0) const;
 	QRectF getVisualBoundingRect() const;
+
+	virtual void getBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
+	virtual void getVisualBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
 
 
 	//>> ********* Functions related to drawing the item *********

Modified: trunk/Scribus/scribus/pageitem_line.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18883&path=/trunk/Scribus/scribus/pageitem_line.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_line.cpp (original)
+++ trunk/Scribus/scribus/pageitem_line.cpp Thu Mar  6 21:21:09 2014
@@ -42,6 +42,7 @@
 #include "undomanager.h"
 #include "undostate.h"
 #include "util.h"
+#include "util_math.h"
 
 using namespace std;
 
@@ -170,3 +171,115 @@
 	double y = m_yPos + m_width * sin(rot * M_PI / 180.0);
 	return QPointF(x, y);
 }
+
+void PageItem_Line::getBoundingRect(double *x1, double *y1, double *x2, double *y2) const
+{
+	PageItem::getBoundingRect(x1, y1, x2, y2);
+	QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
+	if (m_startArrowIndex != 0)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_startArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		arrowTrans.translate(0, 0);
+		arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
+		if (NamedLStyle.isEmpty())
+		{
+			if (m_lineWidth != 0.0)
+				arrowTrans.scale(m_lineWidth, m_lineWidth);
+		}
+		else
+		{
+			multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+			if (ml[ml.size()-1].Width != 0.0)
+				arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+		}
+		arrowTrans.scale(-1,1);
+		arrow.map(arrowTrans);
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	if (m_endArrowIndex != 0)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_endArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		arrowTrans.translate(m_width, 0);
+		arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
+		if (NamedLStyle.isEmpty())
+		{
+			if (m_lineWidth != 0.0)
+				arrowTrans.scale(m_lineWidth, m_lineWidth);
+		}
+		else
+		{
+			multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+			if (ml[ml.size()-1].Width != 0.0)
+				arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+		}
+		arrow.map(arrowTrans);
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	totalRect.getCoords(x1, y1, x2, y2);
+}
+
+void PageItem_Line::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
+{
+	PageItem::getVisualBoundingRect(x1, y1, x2, y2);
+	QRectF totalRect(QPointF(*x1, *y1), QPointF(*x2, *y2));
+	if (m_startArrowIndex != 0)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_startArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		arrowTrans.translate(0, 0);
+		arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
+		if (NamedLStyle.isEmpty())
+		{
+			if (m_lineWidth != 0.0)
+				arrowTrans.scale(m_lineWidth, m_lineWidth);
+		}
+		else
+		{
+			multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+			if (ml[ml.size()-1].Width != 0.0)
+				arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+		}
+		arrowTrans.scale(-1,1);
+		arrow.map(arrowTrans);
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	if (m_endArrowIndex != 0)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_endArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		arrowTrans.translate(m_width, 0);
+		arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
+		if (NamedLStyle.isEmpty())
+		{
+			if (m_lineWidth != 0.0)
+				arrowTrans.scale(m_lineWidth, m_lineWidth);
+		}
+		else
+		{
+			multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+			if (ml[ml.size()-1].Width != 0.0)
+				arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+		}
+		arrow.map(arrowTrans);
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	totalRect.getCoords(x1, y1, x2, y2);
+}

Modified: trunk/Scribus/scribus/pageitem_line.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18883&path=/trunk/Scribus/scribus/pageitem_line.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_line.h (original)
+++ trunk/Scribus/scribus/pageitem_line.h Thu Mar  6 21:21:09 2014
@@ -48,6 +48,9 @@
 
 	QPointF startPoint();
 	QPointF endPoint();
+
+	virtual void getBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
+	virtual void getVisualBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
 	
 protected:
 	virtual void DrawObj_Item(ScPainter *p, QRectF e);

Modified: trunk/Scribus/scribus/pageitem_pathtext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18883&path=/trunk/Scribus/scribus/pageitem_pathtext.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_pathtext.cpp (original)
+++ trunk/Scribus/scribus/pageitem_pathtext.cpp Thu Mar  6 21:21:09 2014
@@ -437,3 +437,14 @@
 {
 	return QString();
 }
+
+void PageItem_PathText::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
+{
+	PageItem::getVisualBoundingRect(x1, y1, x2, y2);
+	QRectF totalRect(QPointF(*x1, *y1), QPointF(*x2, *y2));
+	QTransform clipTrans;
+	clipTrans.translate(m_xPos, m_yPos);
+	clipTrans.rotate(m_rotation);
+	totalRect = totalRect.united(QRectF(clipTrans.mapRect(Clip.boundingRect())));
+	totalRect.getCoords(x1, y1, x2, y2);
+}

Modified: trunk/Scribus/scribus/pageitem_pathtext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18883&path=/trunk/Scribus/scribus/pageitem_pathtext.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_pathtext.h (original)
+++ trunk/Scribus/scribus/pageitem_pathtext.h Thu Mar  6 21:21:09 2014
@@ -48,6 +48,8 @@
 	virtual QString infoDescription();
 	StoryText itemRenderText;
 
+	virtual void getVisualBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
+
 protected:
 	virtual void DrawObj_Item(ScPainter *p, QRectF e);
 

Modified: trunk/Scribus/scribus/pageitem_polyline.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18883&path=/trunk/Scribus/scribus/pageitem_polyline.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_polyline.cpp (original)
+++ trunk/Scribus/scribus/pageitem_polyline.cpp Thu Mar  6 21:21:09 2014
@@ -42,6 +42,7 @@
 #include "undomanager.h"
 #include "undostate.h"
 #include "util.h"
+#include "util_math.h"
 
 using namespace std;
 
@@ -214,3 +215,152 @@
 	return QString();
 }
 
+void PageItem_PolyLine::getBoundingRect(double *x1, double *y1, double *x2, double *y2) const
+{
+	PageItem::getBoundingRect(x1, y1, x2, y2);
+	QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
+	if (m_startArrowIndex != 0 && PoLine.size() > 0)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_startArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		FPoint Start = PoLine.point(0);
+		for (int xx = 1; xx < PoLine.size(); xx += 2)
+		{
+			FPoint Vector = PoLine.point(xx);
+			if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
+			{
+				arrowTrans.translate(Start.x(), Start.y());
+				arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
+				arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
+				if (NamedLStyle.isEmpty())
+				{
+					if (m_lineWidth != 0.0)
+						arrowTrans.scale(m_lineWidth, m_lineWidth);
+				}
+				else
+				{
+					multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+					if (ml[ml.size()-1].Width != 0.0)
+						arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+				}
+				arrow.map(arrowTrans);
+				break;
+			}
+		}
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	if (m_endArrowIndex != 0 && PoLine.size() >= 2)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_endArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		FPoint End = PoLine.point(PoLine.size()-2);
+		for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
+		{
+			FPoint Vector = PoLine.point(xx);
+			if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
+			{
+				arrowTrans.translate(End.x(), End.y());
+				arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
+				arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
+				if (NamedLStyle.isEmpty())
+				{
+					if (m_lineWidth != 0.0)
+						arrowTrans.scale(m_lineWidth, m_lineWidth);
+				}
+				else
+				{
+					multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+					if (ml[ml.size()-1].Width != 0.0)
+						arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+				}
+				arrow.map(arrowTrans);
+				break;
+			}
+		}
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	totalRect.getCoords(x1, y1, x2, y2);
+}
+
+void PageItem_PolyLine::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
+{
+	PageItem::getVisualBoundingRect(x1, y1, x2, y2);
+	QRectF totalRect(QPointF(*x1, *y1), QPointF(*x2, *y2));
+	if (m_startArrowIndex != 0 && PoLine.size() > 0)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_startArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		FPoint Start = PoLine.point(0);
+		for (int xx = 1; xx < PoLine.size(); xx += 2)
+		{
+			FPoint Vector = PoLine.point(xx);
+			if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
+			{
+				arrowTrans.translate(Start.x(), Start.y());
+				arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
+				arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
+				if (NamedLStyle.isEmpty())
+				{
+					if (m_lineWidth != 0.0)
+						arrowTrans.scale(m_lineWidth, m_lineWidth);
+				}
+				else
+				{
+					multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+					if (ml[ml.size()-1].Width != 0.0)
+						arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+				}
+				arrow.map(arrowTrans);
+				break;
+			}
+		}
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	if (m_endArrowIndex != 0 && PoLine.size() >= 2)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_endArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		FPoint End = PoLine.point(PoLine.size()-2);
+		for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
+		{
+			FPoint Vector = PoLine.point(xx);
+			if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
+			{
+				arrowTrans.translate(End.x(), End.y());
+				arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
+				arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
+				if (NamedLStyle.isEmpty())
+				{
+					if (m_lineWidth != 0.0)
+						arrowTrans.scale(m_lineWidth, m_lineWidth);
+				}
+				else
+				{
+					multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+					if (ml[ml.size()-1].Width != 0.0)
+						arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+				}
+				arrow.map(arrowTrans);
+				break;
+			}
+		}
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	totalRect.getCoords(x1, y1, x2, y2);
+}

Modified: trunk/Scribus/scribus/pageitem_polyline.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18883&path=/trunk/Scribus/scribus/pageitem_polyline.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_polyline.h (original)
+++ trunk/Scribus/scribus/pageitem_polyline.h Thu Mar  6 21:21:09 2014
@@ -45,6 +45,9 @@
 	virtual void applicableActions(QStringList& actionList);
 	virtual QString infoDescription();
 
+	virtual void getBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
+	virtual void getVisualBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
+
 protected:
 	virtual void DrawObj_Item(ScPainter *p, QRectF e);
 

Modified: trunk/Scribus/scribus/pageitem_spiral.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18883&path=/trunk/Scribus/scribus/pageitem_spiral.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_spiral.cpp (original)
+++ trunk/Scribus/scribus/pageitem_spiral.cpp Thu Mar  6 21:21:09 2014
@@ -349,3 +349,153 @@
 {
 	return QString();
 }
+
+void PageItem_Spiral::getBoundingRect(double *x1, double *y1, double *x2, double *y2) const
+{
+	PageItem::getBoundingRect(x1, y1, x2, y2);
+	QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
+	if (m_startArrowIndex != 0 && PoLine.size() > 0)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_startArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		FPoint Start = PoLine.point(0);
+		for (int xx = 1; xx < PoLine.size(); xx += 2)
+		{
+			FPoint Vector = PoLine.point(xx);
+			if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
+			{
+				arrowTrans.translate(Start.x(), Start.y());
+				arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
+				arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
+				if (NamedLStyle.isEmpty())
+				{
+					if (m_lineWidth != 0.0)
+						arrowTrans.scale(m_lineWidth, m_lineWidth);
+				}
+				else
+				{
+					multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+					if (ml[ml.size()-1].Width != 0.0)
+						arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+				}
+				arrow.map(arrowTrans);
+				break;
+			}
+		}
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	if (m_endArrowIndex != 0 && PoLine.size() >= 2)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_endArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		FPoint End = PoLine.point(PoLine.size()-2);
+		for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
+		{
+			FPoint Vector = PoLine.point(xx);
+			if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
+			{
+				arrowTrans.translate(End.x(), End.y());
+				arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
+				arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
+				if (NamedLStyle.isEmpty())
+				{
+					if (m_lineWidth != 0.0)
+						arrowTrans.scale(m_lineWidth, m_lineWidth);
+				}
+				else
+				{
+					multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+					if (ml[ml.size()-1].Width != 0.0)
+						arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+				}
+				arrow.map(arrowTrans);
+				break;
+			}
+		}
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	totalRect.getCoords(x1, y1, x2, y2);
+}
+
+void PageItem_Spiral::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
+{
+	PageItem::getVisualBoundingRect(x1, y1, x2, y2);
+	QRectF totalRect(QPointF(*x1, *y1), QPointF(*x2, *y2));
+	if (m_startArrowIndex != 0 && PoLine.size() > 0)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_startArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		FPoint Start = PoLine.point(0);
+		for (int xx = 1; xx < PoLine.size(); xx += 2)
+		{
+			FPoint Vector = PoLine.point(xx);
+			if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
+			{
+				arrowTrans.translate(Start.x(), Start.y());
+				arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
+				arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
+				if (NamedLStyle.isEmpty())
+				{
+					if (m_lineWidth != 0.0)
+						arrowTrans.scale(m_lineWidth, m_lineWidth);
+				}
+				else
+				{
+					multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+					if (ml[ml.size()-1].Width != 0.0)
+						arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+				}
+				arrow.map(arrowTrans);
+				break;
+			}
+		}
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	if (m_endArrowIndex != 0 && PoLine.size() >= 2)
+	{
+		QTransform arrowTrans;
+		FPointArray arrow = m_Doc->arrowStyles().at(m_endArrowIndex-1).points.copy();
+		arrowTrans.translate(m_xPos, m_yPos);
+		arrowTrans.rotate(m_rotation);
+		FPoint End = PoLine.point(PoLine.size()-2);
+		for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
+		{
+			FPoint Vector = PoLine.point(xx);
+			if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
+			{
+				arrowTrans.translate(End.x(), End.y());
+				arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
+				arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
+				if (NamedLStyle.isEmpty())
+				{
+					if (m_lineWidth != 0.0)
+						arrowTrans.scale(m_lineWidth, m_lineWidth);
+				}
+				else
+				{
+					multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+					if (ml[ml.size()-1].Width != 0.0)
+						arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
+				}
+				arrow.map(arrowTrans);
+				break;
+			}
+		}
+		FPoint minAr = getMinClipF(&arrow);
+		FPoint maxAr = getMaxClipF(&arrow);
+		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
+	}
+	totalRect.getCoords(x1, y1, x2, y2);
+}

Modified: trunk/Scribus/scribus/pageitem_spiral.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18883&path=/trunk/Scribus/scribus/pageitem_spiral.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_spiral.h (original)
+++ trunk/Scribus/scribus/pageitem_spiral.h Thu Mar  6 21:21:09 2014
@@ -49,6 +49,9 @@
 	double spiralStartAngle;    //! angle where the spiral starts
 	double spiralEndAngle;    //! angle the spiral spans
 	double spiralFactor;	//! factor the spiral gets smaller
+
+	virtual void getBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
+	virtual void getVisualBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
 	
 protected:
 	virtual void DrawObj_Item(ScPainter *p, QRectF e);




More information about the scribus-commit mailing list