summaryrefslogtreecommitdiffstats
path: root/src/svg
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-05-28 10:27:50 +0200
committerThierry Bastian <thierry.bastian@nokia.com>2009-05-28 10:31:07 +0200
commitf390f9b51cf8686e9ed44f13a33c7349b9e96a09 (patch)
tree162c768769713a7215bca64daf8f2bdc75c9fbee /src/svg
parent0bb0699d403b7541472a72a4057ecf0ca366a7cd (diff)
improved string operations all over the place
used character operations whenever possible better usage of QLatin1String
Diffstat (limited to 'src/svg')
-rw-r--r--src/svg/qsvggenerator.cpp77
1 files changed, 37 insertions, 40 deletions
diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp
index 2d351ff7c6..d51636f77a 100644
--- a/src/svg/qsvggenerator.cpp
+++ b/src/svg/qsvggenerator.cpp
@@ -362,7 +362,7 @@ public:
translate_dashPattern(spen.dashPattern(), penWidth, &dashPattern);
// SVG uses absolute offset
- dashOffset = QString::fromLatin1("%1").arg(spen.dashOffset() * penWidth);
+ dashOffset = QString::number(spen.dashOffset() * penWidth);
d_func()->attributes.stroke = color;
d_func()->attributes.strokeOpacity = colorOpacity;
@@ -403,8 +403,8 @@ public:
}
switch (spen.joinStyle()) {
case Qt::MiterJoin:
- stream() << "stroke-linejoin=\"miter\" ";
- stream() << "stroke-miterlimit=\""<<spen.miterLimit()<<"\" ";
+ stream() << "stroke-linejoin=\"miter\" "
+ "stroke-miterlimit=\""<<spen.miterLimit()<<"\" ";
break;
case Qt::BevelJoin:
stream() << "stroke-linejoin=\"bevel\" ";
@@ -413,8 +413,8 @@ public:
stream() << "stroke-linejoin=\"round\" ";
break;
case Qt::SvgMiterJoin:
- stream() << "stroke-linejoin=\"miter\" ";
- stream() << "stroke-miterlimit=\""<<spen.miterLimit()<<"\" ";
+ stream() << "stroke-linejoin=\"miter\" "
+ "stroke-miterlimit=\""<<spen.miterLimit()<<"\" ";
break;
default:
qWarning("Unhandled join style");
@@ -427,8 +427,8 @@ public:
case Qt::SolidPattern: {
QString color, colorOpacity;
translate_color(sbrush.color(), &color, &colorOpacity);
- stream() << "fill=\"" << color << "\" ";
- stream() << "fill-opacity=\""
+ stream() << "fill=\"" << color << "\" "
+ "fill-opacity=\""
<< colorOpacity << "\" ";
d_func()->attributes.fill = color;
d_func()->attributes.fillOpacity = colorOpacity;
@@ -493,9 +493,9 @@ public:
d->attributes.font_style = d->font.italic() ? QLatin1String("italic") : QLatin1String("normal");
*d->stream << "font-family=\"" << d->attributes.font_family << "\" "
- << "font-size=\"" << d->attributes.font_size << "\" "
- << "font-weight=\"" << d->attributes.font_weight << "\" "
- << "font-style=\"" << d->attributes.font_style << "\" "
+ "font-size=\"" << d->attributes.font_size << "\" "
+ "font-weight=\"" << d->attributes.font_weight << "\" "
+ "font-style=\"" << d->attributes.font_style << "\" "
<< endl;
}
};
@@ -849,13 +849,13 @@ bool QSvgPaintEngine::begin(QPaintDevice *)
}
if (d->viewBox.isValid()) {
- *d->stream << " viewBox=\"" << d->viewBox.left() << " " << d->viewBox.top();
- *d->stream << " " << d->viewBox.width() << " " << d->viewBox.height() << "\"" << endl;
+ *d->stream << " viewBox=\"" << d->viewBox.left() << ' ' << d->viewBox.top();
+ *d->stream << ' ' << d->viewBox.width() << ' ' << d->viewBox.height() << '\"' << endl;
}
*d->stream << " xmlns=\"http://www.w3.org/2000/svg\""
- << " xmlns:xlink=\"http://www.w3.org/1999/xlink\" "
- << " version=\"1.2\" baseProfile=\"tiny\">" << endl;
+ " xmlns:xlink=\"http://www.w3.org/1999/xlink\" "
+ " version=\"1.2\" baseProfile=\"tiny\">" << endl;
if (!d->attributes.document_title.isEmpty()) {
*d->stream << "<title>" << d->attributes.document_title << "</title>" << endl;
@@ -918,10 +918,10 @@ void QSvgPaintEngine::drawImage(const QRectF &r, const QImage &image,
Q_UNUSED(sr);
Q_UNUSED(flags);
stream() << "<image ";
- stream() << "x=\""<<r.x()<<"\" ";
- stream() << "y=\""<<r.y()<<"\" ";
- stream() << "width=\""<<r.width()<<"\" ";
- stream() << "height=\""<<r.height()<<"\" ";
+ stream() << "x=\""<<r.x()<<"\" "
+ "y=\""<<r.y()<<"\" "
+ "width=\""<<r.width()<<"\" "
+ "height=\""<<r.height()<<"\" ";
QByteArray data;
QBuffer buffer(&data);
@@ -930,8 +930,7 @@ void QSvgPaintEngine::drawImage(const QRectF &r, const QImage &image,
buffer.close();
stream() << "xlink:href=\"data:image/png;base64,"
<< data.toBase64()
- <<"\" ";
- stream() << "/>\n";
+ <<"\" />\n";
}
void QSvgPaintEngine::updateState(const QPaintEngineState &state)
@@ -958,10 +957,10 @@ void QSvgPaintEngine::updateState(const QPaintEngineState &state)
if (flags & QPaintEngine::DirtyTransform) {
d->matrix = state.matrix();
- *d->stream << "transform=\"matrix(" << d->matrix.m11() << ","
- << d->matrix.m12() << ","
- << d->matrix.m21() << "," << d->matrix.m22() << ","
- << d->matrix.dx() << "," << d->matrix.dy()
+ *d->stream << "transform=\"matrix(" << d->matrix.m11() << ','
+ << d->matrix.m12() << ','
+ << d->matrix.m21() << ',' << d->matrix.m22() << ','
+ << d->matrix.dx() << ',' << d->matrix.dy()
<< ")\""
<< endl;
}
@@ -975,7 +974,7 @@ void QSvgPaintEngine::updateState(const QPaintEngineState &state)
stream() << "opacity=\""<<state.opacity()<<"\" ";
}
- *d->stream << ">" << endl;
+ *d->stream << '>' << endl;
d->afterFirstUpdate = true;
}
@@ -984,10 +983,8 @@ void QSvgPaintEngine::drawPath(const QPainterPath &p)
{
Q_D(QSvgPaintEngine);
- *d->stream << "<path ";
-
-
- *d->stream << "fill-rule=";
+ *d->stream << "<path "
+ "fill-rule=";
if (p.fillRule() == Qt::OddEvenFill)
*d->stream << "\"evenodd\" ";
else
@@ -999,13 +996,13 @@ void QSvgPaintEngine::drawPath(const QPainterPath &p)
const QPainterPath::Element &e = p.elementAt(i);
switch (e.type) {
case QPainterPath::MoveToElement:
- *d->stream << "M" << e.x << "," << e.y;
+ *d->stream << 'M' << e.x << ',' << e.y;
break;
case QPainterPath::LineToElement:
- *d->stream << "L" << e.x << "," << e.y;
+ *d->stream << 'L' << e.x << ',' << e.y;
break;
case QPainterPath::CurveToElement:
- *d->stream << "C" << e.x << "," << e.y;
+ *d->stream << 'C' << e.x << ',' << e.y;
++i;
while (i < p.elementCount()) {
const QPainterPath::Element &e = p.elementAt(i);
@@ -1013,8 +1010,8 @@ void QSvgPaintEngine::drawPath(const QPainterPath &p)
--i;
break;
} else
- *d->stream << " ";
- *d->stream << e.x << "," << e.y;
+ *d->stream << ' ';
+ *d->stream << e.x << ',' << e.y;
++i;
}
break;
@@ -1022,7 +1019,7 @@ void QSvgPaintEngine::drawPath(const QPainterPath &p)
break;
}
if (i != p.elementCount() - 1) {
- *d->stream << " ";
+ *d->stream << ' ';
}
}
@@ -1044,7 +1041,7 @@ void QSvgPaintEngine::drawPolygon(const QPointF *points, int pointCount,
stream() << "<polyline fill=\"none\" points=\"";
for (int i = 0; i < pointCount; ++i) {
const QPointF &pt = points[i];
- stream() << pt.x() << "," << pt.y() << " ";
+ stream() << pt.x() << ',' << pt.y() << ' ';
}
stream() << "\" />" <<endl;
} else {
@@ -1063,10 +1060,10 @@ void QSvgPaintEngine::drawTextItem(const QPointF &pt, const QTextItem &textItem)
QString s = QString::fromRawData(ti.chars, ti.num_chars);
*d->stream << "<text "
- << "fill=\"" << d->attributes.stroke << "\" "
- << "fill-opacity=\"" << d->attributes.strokeOpacity << "\" "
- << "stroke=\"none\" "
- << "x=\"" << pt.x() << "\" y=\"" << pt.y() << "\" ";
+ "fill=\"" << d->attributes.stroke << "\" "
+ "fill-opacity=\"" << d->attributes.strokeOpacity << "\" "
+ "stroke=\"none\" "
+ "x=\"" << pt.x() << "\" y=\"" << pt.y() << "\" ";
qfontToSvg(textItem.font());
*d->stream << " >"
<< Qt::escape(s)