r20005 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:20 UTC 2015
Author: jghali
Date: Wed Apr 15 23:25:20 2015
New Revision: 20005
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20005
Log:
fix small scaling error when importing SVGs with viewbow attribute
Modified:
trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
trunk/Scribus/scribus/plugins/import/svg/svgplugin.h
Modified: trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20005&path=/trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp Wed Apr 15 23:25:20 2015
@@ -247,7 +247,7 @@
QDir::setCurrent(efp.path());
SvgStyle *gc = new SvgStyle;
QDomElement docElem = inpdoc.documentElement();
- QSize wh = parseWidthHeight(docElem);
+ QSizeF wh = parseWidthHeight(docElem);
m_Doc = new ScribusDoc();
m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
m_Doc->setPage(wh.width(), wh.height(), 0, 0, 0, 0, 0, 0, false, false);
@@ -271,7 +271,7 @@
if (points.size() > 3)
{
QTransform matrix;
- QSize wh2 = parseWidthHeight(docElem);
+ QSizeF wh2 = parseWidthHeight(docElem);
double w2 = wh2.width();
double h2 = wh2.height();
addGraphicContext();
@@ -366,7 +366,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))
@@ -418,7 +418,7 @@
if (points.size() > 3)
{
QTransform matrix;
- QSize wh2 = parseWidthHeight(docElem);
+ QSizeF wh2 = parseWidthHeight(docElem);
double w2 = wh2.width();
double h2 = wh2.height();
addGraphicContext();
@@ -964,9 +964,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;
@@ -976,7 +976,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);
@@ -994,14 +994,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: trunk/Scribus/scribus/plugins/import/svg/svgplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20005&path=/trunk/Scribus/scribus/plugins/import/svg/svgplugin.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svg/svgplugin.h (original)
+++ trunk/Scribus/scribus/plugins/import/svg/svgplugin.h Wed Apr 15 23:25:20 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"
@@ -243,8 +244,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