Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsvghandler_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSVGHANDLER_P_H
5#define QSVGHANDLER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "QtCore/qxmlstream.h"
19#include "QtCore/qhash.h"
20#include "QtCore/qstack.h"
21#include <QtCore/QLoggingCategory>
22#include "qsvgstyle_p.h"
23#if QT_CONFIG(cssparser)
24#include "private/qcssparser_p.h"
25#endif
26#include "qsvggraphics_p.h"
27#include "qtsvgglobal_p.h"
28
30
31class QSvgNode;
33class QSvgHandler;
34class QColor;
36
37#ifndef QT_NO_CSSPARSER
38
44
45#endif
46
47class Q_SVG_EXPORT QSvgHandler
48{
49public:
60
61public:
62 QSvgHandler(QIODevice *device, QtSvg::Options options = {});
63 QSvgHandler(const QByteArray &data, QtSvg::Options options = {});
64 QSvgHandler(QXmlStreamReader *const data, QtSvg::Options options = {});
66
67 QIODevice *device() const;
69
70 inline bool ok() const {
71 return document() != 0 && !xml->hasError();
72 }
73
74 inline QString errorString() const { return xml->errorString(); }
75 inline int lineNumber() const { return xml->lineNumber(); }
76
77 void setDefaultCoordinateSystem(LengthType type);
78 LengthType defaultCoordinateSystem() const;
79
80 void pushColor(const QColor &color);
81 void pushColorCopy();
82 void popColor();
83 QColor currentColor() const;
84
85#ifndef QT_NO_CSSPARSER
86 void setInStyle(bool b);
87 bool inStyle() const;
88
90#endif
91
92 void setAnimPeriod(int start, int end);
93 int animationDuration() const;
94
95#ifndef QT_NO_CSSPARSER
96 void parseCSStoXMLAttrs(const QString &css, QList<QSvgCssAttribute> *attributes);
97#endif
98
99 inline QPen defaultPen() const
100 { return m_defaultPen; }
101
102 QtSvg::Options options() const;
103 bool trustedSourceMode() const;
104
105public:
106 bool startElement(const QString &localName, const QXmlStreamAttributes &attributes);
107 bool endElement(QStringView localName);
109 bool processingInstruction(const QString &target, const QString &data);
110
111private:
112 void init();
113
114 QSvgTinyDocument *m_doc;
115 QStack<QSvgNode *> m_nodes;
116 // TODO: This is only needed during parsing, so it unnecessarily takes up space after that.
117 // Temporary container for :
118 // - <use> nodes which haven't been resolved yet.
119 // - <filter> nodes to be checked for unsupported filter primitives.
120 QList<QSvgNode *> m_toBeResolved;
121
122 enum CurrentNode
123 {
124 Unknown,
125 Graphics,
126 Style,
127 Doc
128 };
129 QStack<CurrentNode> m_skipNodes;
130
135 QStack<QSvgText::WhitespaceMode> m_whitespaceMode;
136
137 QSvgRefCounter<QSvgStyleProperty> m_style;
138
139 LengthType m_defaultCoords;
140
141 QStack<QColor> m_colorStack;
142 QStack<int> m_colorTagCount;
143
144 int m_animEnd;
145
146 QXmlStreamReader *const xml;
147#ifndef QT_NO_CSSPARSER
148 bool m_inStyle;
149 QSvgStyleSelector *m_selector;
150 QCss::Parser m_cssParser;
151#endif
152 void parse();
153 void resolvePaintServers(QSvgNode *node, int nestedDepth = 0);
154 void resolveNodes();
155
156 QPen m_defaultPen;
161 const bool m_ownsReader;
162
163 const QtSvg::Options m_options;
164};
165
166Q_DECLARE_LOGGING_CATEGORY(lcSvgHandler)
167
169
170#endif // QSVGHANDLER_P_H
IOBluetoothDevice * device
\inmodule QtCore
Definition qbytearray.h:57
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore \reentrant
Definition qiodevice.h:34
\inmodule QtGui
Definition qpen.h:28
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool ok() const
int lineNumber() const
QPen defaultPen() const
QString errorString() const
QString str
[2]
Combined button and popup list for selecting options.
emscripten::val document()
Definition qwasmdom.h:49
SharedPointerFileDialogOptions m_options
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLboolean GLboolean GLboolean b
GLuint GLuint end
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint color
[2]
GLenum type
GLenum target
GLuint start
static void parseCSStoXMLAttrs(const QList< QCss::Declaration > &declarations, QXmlStreamAttributes &attributes)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
QList< QChar > characters
QFileSelector selector
[1]
QXmlStreamReader xml
[0]