Qt
6.x
The Qt SDK
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
29
QT_BEGIN_NAMESPACE
30
31
class
QSvgNode
;
32
class
QSvgTinyDocument
;
33
class
QSvgHandler
;
34
class
QColor
;
35
class
QSvgStyleSelector
;
36
37
#ifndef QT_NO_CSSPARSER
38
39
struct
QSvgCssAttribute
40
{
41
QString
name
;
42
QString
value
;
43
};
44
45
#endif
46
47
class
Q_SVG_PRIVATE_EXPORT
QSvgHandler
48
{
49
public
:
50
enum
LengthType
{
51
LT_PERCENT
,
52
LT_PX
,
53
LT_PC
,
54
LT_PT
,
55
LT_MM
,
56
LT_CM
,
57
LT_IN
,
58
LT_OTHER
59
};
60
61
public
:
62
QSvgHandler
(
QIODevice
*
device
);
63
QSvgHandler
(
const
QByteArray
&
data
);
64
QSvgHandler
(QXmlStreamReader *
const
data
);
65
~QSvgHandler
();
66
67
QIODevice
*
device
()
const
;
68
QSvgTinyDocument
*document()
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
89
QSvgStyleSelector
*
selector
()
const
;
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
public
:
103
bool
startElement(
const
QString
&localName,
const
QXmlStreamAttributes
&attributes);
104
bool
endElement(
QStringView
localName);
105
bool
characters
(
QStringView
str
);
106
bool
processingInstruction(
const
QString
&
target
,
const
QString
&
data
);
107
108
private
:
109
void
init
();
110
111
QSvgTinyDocument
*m_doc;
112
QStack<QSvgNode *>
m_nodes;
113
// TODO: This is only needed during parsing, so it unnecessarily takes up space after that.
114
// Temporary container for <use> nodes which haven't been resolved yet.
115
QList<QSvgUse *>
m_toBeResolved;
116
117
enum
CurrentNode
118
{
119
Unknown
,
120
Graphics,
121
Style
122
};
123
QStack<CurrentNode>
m_skipNodes;
124
129
QStack<QSvgText::WhitespaceMode>
m_whitespaceMode;
130
131
QSvgRefCounter<QSvgStyleProperty>
m_style;
132
133
LengthType m_defaultCoords;
134
135
QStack<QColor>
m_colorStack;
136
QStack<int>
m_colorTagCount;
137
138
int
m_animEnd;
139
140
QXmlStreamReader *
const
xml
;
141
#ifndef QT_NO_CSSPARSER
142
bool
m_inStyle;
143
QSvgStyleSelector
*m_selector;
144
QCss::Parser
m_cssParser;
145
#endif
146
void
parse();
147
void
resolveGradients(
QSvgNode
*node,
int
nestedDepth = 0);
148
void
resolveNodes();
149
150
QPen
m_defaultPen;
155
const
bool
m_ownsReader;
156
};
157
158
Q_DECLARE_LOGGING_CATEGORY
(lcSvgHandler)
159
160
QT_END_NAMESPACE
161
162
#endif
// QSVGHANDLER_P_H
device
IOBluetoothDevice * device
Definition
btl2capchannel.mm:17
QByteArray
\inmodule QtCore
Definition
qbytearray.h:57
QColor
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition
qcolor.h:31
QCss::Parser
Definition
qcssparser_p.h:723
QIODevice
\inmodule QtCore \reentrant
Definition
qiodevice.h:34
QList
Definition
qlist.h:74
QPen
\inmodule QtGui
Definition
qpen.h:25
QStack
\inmodule QtCore
Definition
qstack.h:13
QStringView
\inmodule QtCore
Definition
qstringview.h:76
QString
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition
qstring.h:127
QSvgHandler
Definition
qsvghandler_p.h:48
QSvgHandler::ok
bool ok() const
Definition
qsvghandler_p.h:70
QSvgHandler::LengthType
LengthType
Definition
qsvghandler_p.h:50
QSvgHandler::LT_PX
@ LT_PX
Definition
qsvghandler_p.h:52
QSvgHandler::LT_PC
@ LT_PC
Definition
qsvghandler_p.h:53
QSvgHandler::LT_MM
@ LT_MM
Definition
qsvghandler_p.h:55
QSvgHandler::LT_PT
@ LT_PT
Definition
qsvghandler_p.h:54
QSvgHandler::LT_IN
@ LT_IN
Definition
qsvghandler_p.h:57
QSvgHandler::LT_PERCENT
@ LT_PERCENT
Definition
qsvghandler_p.h:51
QSvgHandler::LT_CM
@ LT_CM
Definition
qsvghandler_p.h:56
QSvgHandler::lineNumber
int lineNumber() const
Definition
qsvghandler_p.h:75
QSvgHandler::defaultPen
QPen defaultPen() const
Definition
qsvghandler_p.h:99
QSvgHandler::errorString
QString errorString() const
Definition
qsvghandler_p.h:74
QSvgNode
Definition
qsvgnode_p.h:30
QSvgRefCounter
Definition
qsvgstyle_p.h:35
QSvgStyleSelector
Definition
qsvghandler.cpp:436
QSvgTinyDocument
Definition
qsvgtinydocument_p.h:37
QXmlStreamAttributes
Definition
qxmlstream.h:75
str
QString str
[2]
Definition
doc_src_containers.cpp:175
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
QT_END_NAMESPACE
Definition
qsharedpointer.cpp:1545
color
Definition
qssgutils_p.h:103
Q_DECLARE_LOGGING_CATEGORY
#define Q_DECLARE_LOGGING_CATEGORY(name)
Definition
qloggingcategory.h:106
QOcspCertificateStatus::Unknown
@ Unknown
b
GLboolean GLboolean GLboolean b
Definition
qopengles2ext.h:337
end
GLuint GLuint end
Definition
qopengles2ext.h:354
type
GLenum type
Definition
qopengles2ext.h:150
target
GLenum target
Definition
qopengles2ext.h:751
data
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
Definition
qopengles2ext.h:206
start
GLuint start
Definition
qopengles2ext.h:354
qsvggraphics_p.h
parseCSStoXMLAttrs
static void parseCSStoXMLAttrs(const QList< QCss::Declaration > &declarations, QXmlStreamAttributes &attributes)
Definition
qsvghandler.cpp:1898
qsvgstyle_p.h
init
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
Definition
qtextboundaryfinder.cpp:10
qtsvgglobal_p.h
characters
QList< QChar > characters
Definition
src_concurrent_qtconcurrentfilter.cpp:76
selector
QFileSelector selector
[1]
Definition
src_corelib_io_qfileselector.cpp:25
xml
QXmlStreamReader xml
[0]
Definition
src_corelib_xml_qxmlstream.cpp:5
QSvgCssAttribute
Definition
qsvghandler_p.h:40
QSvgCssAttribute::name
QString name
Definition
qsvghandler_p.h:41
QSvgCssAttribute::value
QString value
Definition
qsvghandler_p.h:42
qtsvg
src
svg
qsvghandler_p.h
Generated by
1.9.7