r14547 by fschmid - DRW Importer: fixed incorrect object scaling again.

scribus-commit scribus-commit at lists.scribus.net
Wed Jan 20 20:35:22 CET 2010


Revision: 14547
Author: fschmid
Date: 2010-01-20T19:32:40.980899Z
Commit message: DRW Importer: fixed incorrect object scaling again.

Changeset: 
M  /trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp
M  /trunk/Scribus/scribus/plugins/import/drw/importdrw.h

Diffs:
Index: scribus/plugins/import/drw/importdrw.cpp
===================================================================
--- scribus/plugins/import/drw/importdrw.cpp	(revision 14546)
+++ scribus/plugins/import/drw/importdrw.cpp	(revision 14547)
@@ -434,7 +434,7 @@
 			break;
 		case 6:
 			cmdText = "DRW Polygon";
-			if (createObjCode == 1)
+			if ((createObjCode == 1) || (createObjCode == 3))
 			{
 				bool first = true;
 				bool first2 = true;
@@ -457,7 +457,8 @@
 						if (coor == startP)
 						{
 							first = true;
-							Coords.svgClosePath();
+							if (createObjCode == 1)
+								Coords.svgClosePath();
 						}
 						else
 							Coords.svgLineTo(coor.x(), coor.y());
@@ -499,7 +500,7 @@
 				{
 				//	Coords.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
 					currentItem->PoLine = Coords.copy();
-					finishItem(currentItem);
+					finishItem(currentItem, false);
 				}
 				createObjCode = 0;
 				currentItem = NULL;
@@ -743,7 +744,6 @@
 			lineWidth = getValue(ds);
 			z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, baseX + bBox.x() + bX, baseY + bBox.y() + bY, bBox.width(), bBox.height(), lineWidth, CommonStrings::None, lineColor, true);
 			currentItem = m_Doc->Items->at(z);
-		//	currentItem->PoLine.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
 			finishItem(currentItem);
 			break;
 		case 5:
@@ -765,7 +765,7 @@
 			ds >> dummy;
 			lineWidth = getValue(ds);
 			nrOfPoints = nPoints;
-			createObjCode = 1;
+			createObjCode = 3;
 			z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX + bBox.x() + bX, baseY + bBox.y() + bY, bBox.width(), bBox.height(), lineWidth, CommonStrings::None, lineColor, true);
 			currentItem = m_Doc->Items->at(z);
 			break;
@@ -796,7 +796,6 @@
 			lineWidth = getValue(ds);
 			z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, baseX + bBox.x() + bX, baseY + bBox.y() + bY, bBox.width(), bBox.height(), lineWidth, fillC, CommonStrings::None, true);
 			currentItem = m_Doc->Items->at(z);
-		//	currentItem->PoLine.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
 			finishItem(currentItem);
 			if (data8 == 11)
 				currentItem->setCornerRadius(cornerRadius);
@@ -821,7 +820,6 @@
 			lineWidth = getValue(ds);
 			z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, baseX + bBox.x() + bX, baseY + bBox.y() + bY, bBox.width(), bBox.height(), lineWidth, fillC, lineColor, true);
 			currentItem = m_Doc->Items->at(z);
-		//	currentItem->PoLine.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
 			finishItem(currentItem);
 			break;
 		case 14:
@@ -1083,7 +1081,7 @@
 	return handleColor(color, "FromDRW"+color.name());
 }
 
-void DrwPlug::finishItem(PageItem* ite)
+void DrwPlug::finishItem(PageItem* ite, bool scale)
 {
 	ite->ClipEdited = true;
 	ite->FrameType = 3;
@@ -1091,20 +1089,23 @@
 //	ite->setWidthHeight(wh.x(),wh.y());
 	ite->setTextFlowMode(PageItem::TextFlowDisabled);
 //	m_Doc->AdjustItemSize(ite);
-	QPainterPath pa = ite->PoLine.toQPainterPath(true);
-	QRectF bb = pa.boundingRect();
-	double scx = 1.0;
-	double scy = 1.0;
-	if ((bb.width() == 0.0) || (ite->width() == 0.0))
-		scx = 1.0;
-	else
-		scx = ite->width() / bb.width();
-	if ((bb.height() == 0.0) || (ite->height() == 0.0))
-		scy = 1.0;
-	else
-		scy = ite->height() / bb.height();
+	if (scale)
+	{
+		QPainterPath pa = ite->PoLine.toQPainterPath(true);
+		QRectF bb = pa.boundingRect();
+		double scx = 1.0;
+		double scy = 1.0;
+		if ((bb.width() == 0.0) || (ite->width() == 0.0))
+			scx = 1.0;
+		else
+			scx = ite->width() / bb.width();
+		if ((bb.height() == 0.0) || (ite->height() == 0.0))
+			scy = 1.0;
+		else
+			scy = ite->height() / bb.height();
 //	qDebug() << scx << scy;
-	ite->PoLine.scale(scx, scy);
+		ite->PoLine.scale(scx, scy);
+	}
 	ite->OldB2 = ite->width();
 	ite->OldH2 = ite->height();
 	ite->updateClip();
Index: scribus/plugins/import/drw/importdrw.h
===================================================================
--- scribus/plugins/import/drw/importdrw.h	(revision 14546)
+++ scribus/plugins/import/drw/importdrw.h	(revision 14547)
@@ -69,7 +69,7 @@
 	void handlePreviewBitmap(QDataStream &ds);
 	QString handleColor(ScColor &color, QString proposedName);
 	QString getColor(QDataStream &ds);
-	void finishItem(PageItem* ite);
+	void finishItem(PageItem* ite, bool scale = true);
 	double getValue(QDataStream &ds);
 	double getRawValue(QDataStream &ds);
 	QPointF getCoordinate(QDataStream &ds);




More information about the scribus-commit mailing list