r20006 by jghali - fix small scaling error when importing SVGs with viewbow attribute

scribus-commit scribus-commit at lists.scribus.net
Wed Apr 15 23:25:45 UTC 2015


Author: jghali
Date: Wed Apr 15 23:25:44 2015
New Revision: 20006

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20006
Log:
fix small scaling error when importing SVGs with viewbow attribute

Modified:
    branches/Version14x/Scribus/scribus/plugins/import/svg/svgplugin.cpp
    branches/Version14x/Scribus/scribus/plugins/import/svg/svgplugin.h

Modified: branches/Version14x/Scribus/scribus/plugins/import/svg/svgplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20006&path=/branches/Version14x/Scribus/scribus/plugins/import/svg/svgplugin.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/import/svg/svgplugin.cpp (original)
+++ branches/Version14x/Scribus/scribus/plugins/import/svg/svgplugin.cpp Wed Apr 15 23:25:44 2015
@@ -272,7 +272,7 @@
 	bool ret = false;
 	SvgStyle *gc = new SvgStyle;
 	QDomElement docElem = inpdoc.documentElement();
-	QSize wh = parseWidthHeight(docElem);
+	QSizeF wh = parseWidthHeight(docElem);
 	double width = wh.width();
 	double height = wh.height();
 	if (!interactive || (flags & LoadSavePlugin::lfInsertPage))
@@ -319,7 +319,7 @@
 		if (points.size() > 3)
 		{
 			QMatrix matrix;
-			QSize wh2 = parseWidthHeight(docElem);
+			QSizeF wh2 = parseWidthHeight(docElem);
 			double w2 = wh2.width();
 			double h2 = wh2.height();
 			addGraphicContext();
@@ -745,9 +745,9 @@
 	return FPoint(x, y);
 }
 
-QSize SVGPlug::parseWidthHeight(const QDomElement &e)
-{
-	QSize size(550, 841);
+QSizeF SVGPlug::parseWidthHeight(const QDomElement &e)
+{
+	QSizeF size(550, 841);
 	QString sw = e.attribute("width", "100%");
 	QString sh = e.attribute("height", "100%");
 	double w =  550, h = 841;
@@ -757,7 +757,7 @@
 		h = sh.endsWith("%") ? fromPercentage(sh) : parseUnit(sh);
 	if (!e.attribute("viewBox").isEmpty())
 	{
-		QRect viewBox = parseViewBox(e);
+		QRectF viewBox = parseViewBox(e);
 		double scw = (viewBox.width() > 0 && viewBox.height() > 0) ? viewBox.width()  : size.width();
 		double sch = (viewBox.width() > 0 && viewBox.height() > 0) ? viewBox.height() : size.height();
 		w *= (sw.endsWith("%") ? scw : 1.0);
@@ -775,14 +775,14 @@
 		w = w / m * 842;
 		h = h / m * 842;
 	}
-	size.setWidth(qRound(w));
-	size.setHeight(qRound(h));
+	size.setWidth(w);
+	size.setHeight(h);
 	return size;
 }
 
-QRect SVGPlug::parseViewBox(const QDomElement &e)
-{
-	QRect box(0, 0, 0, 0);
+QRectF SVGPlug::parseViewBox(const QDomElement &e)
+{
+	QRectF box(0, 0, 0, 0);
 	if ( !e.attribute( "viewBox" ).isEmpty() )
 	{
 		QString viewbox( e.attribute( "viewBox" ) );

Modified: branches/Version14x/Scribus/scribus/plugins/import/svg/svgplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20006&path=/branches/Version14x/Scribus/scribus/plugins/import/svg/svgplugin.h
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/import/svg/svgplugin.h (original)
+++ branches/Version14x/Scribus/scribus/plugins/import/svg/svgplugin.h Wed Apr 15 23:25:44 2015
@@ -10,7 +10,8 @@
 #include <QDomElement>
 #include <QFont>
 #include <QList>
-#include <QSize>
+#include <QRectF>
+#include <QSizeF>
 #include <QStack>
 #include "pluginapi.h"
 #include "loadsaveplugin.h"
@@ -203,8 +204,8 @@
 	bool isIgnorableNode( const QDomElement &e );
 	bool isIgnorableNodeName( const QString &n );
 	FPoint parseTextPosition(const QDomElement &e, const FPoint* pos = NULL);
-	QSize  parseWidthHeight(const QDomElement &e);
-	QRect  parseViewBox(const QDomElement &e);
+	QSizeF  parseWidthHeight(const QDomElement &e);
+	QRectF  parseViewBox(const QDomElement &e);
 	void parseDefs(const QDomElement &e);
 	void parseClipPath(const QDomElement &e);
 	void parseClipPathAttr(const QDomElement &e, FPointArray& clipPath);




More information about the scribus-commit mailing list