Commit 1d858cdf authored by Blackbeard (alberto flores)'s avatar Blackbeard (alberto flores) 🚢

Use SvgParser to loadFromDevice

parent f17c8274
/*
/*
* Copyright (c) 2010 Cyrille Berger <cberger@cberger.net>
*
* This program is free software; you can redistribute it and/or modify
......@@ -24,6 +24,12 @@
#include <QImageReader>
#include <QSvgRenderer>
#include <SvgParser.h>
#include <KoDocumentResourceManager.h>
#include <KoXmlReader.h>
#include <QDebug>
KisVectorAnimatedBrush::KisVectorAnimatedBrush(const QString& filename)
: KisScalingSizeBrush(filename)
{
......@@ -61,11 +67,42 @@ bool KisVectorAnimatedBrush::load()
bool KisVectorAnimatedBrush::loadFromDevice(QIODevice *dev)
{
m_svg = dev->readAll();
QSvgRenderer renderer(m_svg);
KoXmlDocument documento = SvgParser::createDocumentFromSvg(m_svg);
// qDebug() << documento.toString();
KoXmlElement elementos = documento.documentElement();
/* qDebug() << documento.toString();
qDebug() << elementos.text(); */
KoDocumentResourceManager manager;
SvgParser parser(&manager);
parser.setResolution(QRectF(0,0,100,100), 72); // initialize with default values
QSizeF fragmentSize;
// QList<KoShape*> shapes = parser.parseSvg(documento.documentElement(), &fragmentSize);
QList<KoShape*> list = parser.parseSvg(elementos, &fragmentSize);
/* // According to documentation it is better to use const_iterator if we won't change the QList elements
QList<KoShape*>::const_iterator i;
for (i = list.constBegin(); i != list.constEnd(); ++i)
qDebug() << "figura" << *i;
// qDebug() << list.at(*i) ;
*/
for (int i = 0; i != list.size(); ++i) {
qDebug() << "figura" << i;
qDebug() << list.at(i);
}
/* qDebug() << "shapes" << list[0]; */
// ------------------------------------------- old ------------------------
QSvgRenderer renderer(m_svg);
QRect box = renderer.viewBox();
if (box.isEmpty()) return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment