1// Copyright (C) 2023 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#include "qsvgvisitor_p.h"
5
6QT_BEGIN_NAMESPACE
7
8void QSvgVisitor::traverse(const QSvgStructureNode *node)
9{
10 switch (node->type()) {
11 case QSvgNode::Switch:
12 if (!visitSwitchNodeStart(node: static_cast<const QSvgSwitch *>(node)))
13 return;
14 break;
15 case QSvgNode::Doc:
16 if (!visitDocumentNodeStart(node: static_cast<const QSvgTinyDocument *>(node)))
17 return;
18 break;
19 case QSvgNode::Defs:
20 if (!visitDefsNodeStart(node: static_cast<const QSvgDefs *>(node)))
21 return;
22 break;
23 case QSvgNode::Group:
24 if (!visitGroupNodeStart(node: static_cast<const QSvgG *>(node)))
25 return;
26 break;
27 case QSvgNode::Mask:
28 if (!visitMaskNodeStart(node: static_cast<const QSvgMask *>(node)))
29 return;
30 break;
31 default:
32 Q_UNREACHABLE();
33 break;
34 }
35
36 for (const auto *child : node->renderers())
37 traverse(node: child);
38
39 switch (node->type()) {
40 case QSvgNode::Switch:
41 visitSwitchNodeEnd(node: static_cast<const QSvgSwitch *>(node));
42 break;
43 case QSvgNode::Doc:
44 visitDocumentNodeEnd(node: static_cast<const QSvgTinyDocument *>(node));
45 break;
46 case QSvgNode::Defs:
47 visitDefsNodeEnd(node: static_cast<const QSvgDefs *>(node));
48 break;
49 case QSvgNode::Group:
50 visitGroupNodeEnd(node: static_cast<const QSvgG *>(node));
51 break;
52 case QSvgNode::Mask:
53 visitMaskNodeEnd(node: static_cast<const QSvgMask *>(node));
54 break;
55 default:
56 Q_UNREACHABLE();
57 break;
58 }
59}
60
61void QSvgVisitor::traverse(const QSvgNode *node)
62{
63 switch (node->type()) {
64 case QSvgNode::Switch:
65 case QSvgNode::Doc:
66 case QSvgNode::Defs:
67 case QSvgNode::Group:
68 case QSvgNode::Mask:
69 traverse(node: static_cast<const QSvgStructureNode *>(node));
70 break;
71 case QSvgNode::Animation:
72 visitAnimationNode(node: static_cast<const QSvgAnimation *>(node));
73 break;
74 case QSvgNode::Circle:
75 case QSvgNode::Ellipse:
76 visitEllipseNode(node: static_cast<const QSvgEllipse *>(node));
77 break;
78 case QSvgNode::Image:
79 visitImageNode(node: static_cast<const QSvgImage *>(node));
80 break;
81 case QSvgNode::Line:
82 visitLineNode(node: static_cast<const QSvgLine *>(node));
83 break;
84 case QSvgNode::Path:
85 visitPathNode(node: static_cast<const QSvgPath *>(node));
86 break;
87 case QSvgNode::Polygon:
88 visitPolygonNode(node: static_cast<const QSvgPolygon *>(node));
89 break;
90 case QSvgNode::Polyline:
91 visitPolylineNode(node: static_cast<const QSvgPolyline *>(node));
92 break;
93 case QSvgNode::Rect:
94 visitRectNode(node: static_cast<const QSvgRect *>(node));
95 break;
96 case QSvgNode::Text:
97 case QSvgNode::Textarea:
98 visitTextNode(node: static_cast<const QSvgText *>(node));
99 break;
100 case QSvgNode::Tspan:
101 visitTspanNode(node: static_cast<const QSvgTspan *>(node));
102 break;
103 case QSvgNode::Use:
104 visitUseNode(node: static_cast<const QSvgUse *>(node));
105 break;
106 case QSvgNode::Video:
107 visitVideoNode(node: static_cast<const QSvgVideo *>(node));
108 break;
109
110 // Enum values that don't have any QSvgNode classes yet:
111 case QSvgNode::Symbol:
112 case QSvgNode::Marker:
113 case QSvgNode::Pattern:
114 case QSvgNode::Filter:
115 case QSvgNode::FeMerge:
116 case QSvgNode::FeMergenode:
117 case QSvgNode::FeColormatrix:
118 case QSvgNode::FeGaussianblur:
119 case QSvgNode::FeOffset:
120 case QSvgNode::FeComposite:
121 case QSvgNode::FeFlood:
122 case QSvgNode::FeUnsupported:
123 qDebug() << "Unhandled type in switch" << node->type();
124 break;
125 }
126}
127
128QT_END_NAMESPACE
129

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtsvg/src/svg/qsvgvisitor.cpp