Krita Source Code Documentation
Loading...
Searching...
No Matches
KoSvgPaste Class Reference

#include <KoSvgPaste.h>

Classes

class  Private
 

Public Member Functions

QList< KoShape * > fetchShapes (QRectF viewportInPx, qreal resolutionPPI, QSizeF *fragmentSize=nullptr)
 
bool hasShapes ()
 
 KoSvgPaste ()
 
virtual ~KoSvgPaste ()
 

Static Public Member Functions

static QList< KoShape * > fetchShapesFromData (const QByteArray &data, QRectF viewportInPx, qreal resolutionPPI, QSizeF *fragmentSize=nullptr)
 

Private Member Functions

 Q_DISABLE_COPY (KoSvgPaste)
 

Private Attributes

Private *const d
 

Detailed Description

Definition at line 18 of file KoSvgPaste.h.

Constructor & Destructor Documentation

◆ KoSvgPaste()

KoSvgPaste::KoSvgPaste ( )

Definition at line 31 of file KoSvgPaste.cpp.

32 : d(new Private)
33{
34}
Private *const d
Definition KoSvgPaste.h:31

◆ ~KoSvgPaste()

KoSvgPaste::~KoSvgPaste ( )
virtual

Definition at line 36 of file KoSvgPaste.cpp.

37{
38 delete(d);
39}

References d.

Member Function Documentation

◆ fetchShapes()

QList< KoShape * > KoSvgPaste::fetchShapes ( QRectF viewportInPx,
qreal resolutionPPI,
QSizeF * fragmentSize = nullptr )

Definition at line 56 of file KoSvgPaste.cpp.

57{
58 QList<KoShape*> shapes;
59
60 if (!d->mimeData) return shapes;
61
62 QByteArray data;
63
64 Q_FOREACH(const QString &format, d->mimeData->formats()) {
65 if (format.toLower().contains("svg")) {
66 data = d->mimeData->data(format);
67 break;
68 }
69 }
70
71 if (data.isEmpty()) {
72 return shapes;
73 }
74
75 return fetchShapesFromData(data, viewportInPx, resolutionPPI, fragmentSize);
76
77}
const QMimeData * mimeData
static QList< KoShape * > fetchShapesFromData(const QByteArray &data, QRectF viewportInPx, qreal resolutionPPI, QSizeF *fragmentSize=nullptr)

References d, fetchShapesFromData(), and KoSvgPaste::Private::mimeData.

◆ fetchShapesFromData()

QList< KoShape * > KoSvgPaste::fetchShapesFromData ( const QByteArray & data,
QRectF viewportInPx,
qreal resolutionPPI,
QSizeF * fragmentSize = nullptr )
static

Definition at line 79 of file KoSvgPaste.cpp.

80{
81 QList<KoShape*> shapes;
82
83 if (data.isEmpty()) {
84 return shapes;
85 }
86
87
88
89 QString errorMsg;
90 int errorLine = 0;
91 int errorColumn = 0;
92
93 QDomDocument doc = SvgParser::createDocumentFromSvg(data, &errorMsg, &errorLine, &errorColumn);
94 if (doc.isNull()) {
95 qWarning() << "Failed to process an SVG file at"
96 << errorLine << ":" << errorColumn << "->" << errorMsg;
97 return shapes;
98 }
99
100 KoDocumentResourceManager resourceManager;
101 SvgParser parser(&resourceManager);
102 parser.setResolution(viewportInPx, resolutionPPI);
103
104 shapes = parser.parseSvg(doc.documentElement(), fragmentSize);
105
106 return shapes;
107}
static QDomDocument createDocumentFromSvg(QIODevice *device, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0)

References SvgParser::createDocumentFromSvg(), SvgParser::parseSvg(), and SvgParser::setResolution().

◆ hasShapes()

bool KoSvgPaste::hasShapes ( )

Definition at line 41 of file KoSvgPaste.cpp.

42{
43 bool hasSvg = false;
44 if (d->mimeData) {
45 Q_FOREACH(const QString &format, d->mimeData->formats()) {
46 if (format.toLower().contains("svg")) {
47 hasSvg = true;
48 break;
49 }
50 }
51 }
52
53 return hasSvg;
54}

References d, and KoSvgPaste::Private::mimeData.

◆ Q_DISABLE_COPY()

KoSvgPaste::Q_DISABLE_COPY ( KoSvgPaste )
private

Member Data Documentation

◆ d

Private* const KoSvgPaste::d
private

Definition at line 31 of file KoSvgPaste.h.


The documentation for this class was generated from the following files: