blob: c88a679ea8a67decf0cb863c4370a17e29884598 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Factory for SPObject tree
*
* Authors:
* Markus Engel
*
* Copyright (C) 2013 Authors
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
*/
#include "sp-factory.h"
// primary
#include "box3d.h"
#include "box3d-side.h"
#include "color-profile.h"
#include "persp3d.h"
#include "sp-anchor.h"
#include "sp-clippath.h"
#include "sp-defs.h"
#include "sp-desc.h"
#include "sp-ellipse.h"
#include "sp-filter.h"
#include "sp-flowdiv.h"
#include "sp-flowregion.h"
#include "sp-flowtext.h"
#include "sp-font.h"
#include "sp-font-face.h"
#include "sp-glyph.h"
#include "sp-glyph-kerning.h"
#include "sp-guide.h"
#include "sp-hatch.h"
#include "sp-hatch-path.h"
#include "sp-image.h"
#include "sp-line.h"
#include "sp-linear-gradient.h"
#include "sp-marker.h"
#include "sp-mask.h"
#include "sp-mesh-gradient.h"
#include "sp-mesh-patch.h"
#include "sp-mesh-row.h"
#include "sp-metadata.h"
#include "sp-missing-glyph.h"
#include "sp-namedview.h"
#include "sp-offset.h"
#include "sp-page.h"
#include "sp-path.h"
#include "sp-pattern.h"
#include "sp-polyline.h"
#include "sp-radial-gradient.h"
#include "sp-rect.h"
#include "sp-root.h"
#include "sp-script.h"
#include "sp-solid-color.h"
#include "sp-spiral.h"
#include "sp-star.h"
#include "sp-stop.h"
#include "sp-string.h"
#include "sp-style-elem.h"
#include "sp-switch.h"
#include "sp-symbol.h"
#include "sp-tag.h"
#include "sp-tag-use.h"
#include "sp-text.h"
#include "sp-textpath.h"
#include "sp-title.h"
#include "sp-tref.h"
#include "sp-tspan.h"
#include "sp-use.h"
#include "live_effects/lpeobject.h"
// filters
#include "filters/blend.h"
#include "filters/colormatrix.h"
#include "filters/componenttransfer.h"
#include "filters/componenttransfer-funcnode.h"
#include "filters/composite.h"
#include "filters/convolvematrix.h"
#include "filters/diffuselighting.h"
#include "filters/displacementmap.h"
#include "filters/distantlight.h"
#include "filters/flood.h"
#include "filters/gaussian-blur.h"
#include "filters/image.h"
#include "filters/merge.h"
#include "filters/mergenode.h"
#include "filters/morphology.h"
#include "filters/offset.h"
#include "filters/pointlight.h"
#include "filters/specularlighting.h"
#include "filters/spotlight.h"
#include "filters/tile.h"
#include "filters/turbulence.h"
SPObject *SPFactory::createObject(std::string const& id)
{
SPObject *ret = nullptr;
if (id == "inkscape:box3d")
ret = new SPBox3D;
else if (id == "inkscape:box3dside")
ret = new Box3DSide;
else if (id == "svg:color-profile")
ret = new Inkscape::ColorProfile;
else if (id == "inkscape:persp3d")
ret = new Persp3D;
else if (id == "svg:a")
ret = new SPAnchor;
else if (id == "svg:clipPath")
ret = new SPClipPath;
else if (id == "svg:defs")
ret = new SPDefs;
else if (id == "svg:desc")
ret = new SPDesc;
else if (id == "svg:ellipse") {
SPGenericEllipse *e = new SPGenericEllipse;
e->type = SP_GENERIC_ELLIPSE_ELLIPSE;
ret = e;
} else if (id == "svg:circle") {
SPGenericEllipse *c = new SPGenericEllipse;
c->type = SP_GENERIC_ELLIPSE_CIRCLE;
ret = c;
} else if (id == "arc") {
SPGenericEllipse *a = new SPGenericEllipse;
a->type = SP_GENERIC_ELLIPSE_ARC;
ret = a;
}
else if (id == "svg:filter")
ret = new SPFilter;
else if (id == "svg:flowDiv")
ret = new SPFlowdiv;
else if (id == "svg:flowSpan")
ret = new SPFlowtspan;
else if (id == "svg:flowPara")
ret = new SPFlowpara;
else if (id == "svg:flowLine")
ret = new SPFlowline;
else if (id == "svg:flowRegionBreak")
ret = new SPFlowregionbreak;
else if (id == "svg:flowRegion")
ret = new SPFlowregion;
else if (id == "svg:flowRegionExclude")
ret = new SPFlowregionExclude;
else if (id == "svg:flowRoot")
ret = new SPFlowtext;
else if (id == "svg:font")
ret = new SPFont;
else if (id == "svg:font-face")
ret = new SPFontFace;
else if (id == "svg:glyph")
ret = new SPGlyph;
else if (id == "svg:hkern")
ret = new SPHkern;
else if (id == "svg:vkern")
ret = new SPVkern;
else if (id == "sodipodi:guide")
ret = new SPGuide;
else if (id == "inkscape:page")
ret = new SPPage;
else if (id == "svg:hatch")
ret = new SPHatch;
else if (id == "svg:hatchpath")
ret = new SPHatchPath;
else if (id == "svg:hatchPath") {
std::cerr << "Warning: <hatchPath> has been renamed <hatchpath>" << std::endl;
ret = new SPHatchPath;
}
else if (id == "svg:image")
ret = new SPImage;
else if (id == "svg:g")
ret = new SPGroup;
else if (id == "svg:line")
ret = new SPLine;
else if (id == "svg:linearGradient")
ret = new SPLinearGradient;
else if (id == "svg:marker")
ret = new SPMarker;
else if (id == "svg:mask")
ret = new SPMask;
else if (id == "svg:mesh") { // SVG 2 old
ret = new SPMeshGradient;
std::cerr << "Warning: <mesh> has been renamed <meshgradient>." << std::endl;
std::cerr << "Warning: <mesh> has been repurposed as a shape that tightly wraps a <meshgradient>." << std::endl;
}
else if (id == "svg:meshGradient") { // SVG 2 old
ret = new SPMeshGradient;
std::cerr << "Warning: <meshGradient> has been renamed <meshgradient>" << std::endl;
}
else if (id == "svg:meshgradient") // SVG 2
ret = new SPMeshGradient;
else if (id == "svg:meshPatch") {
ret = new SPMeshpatch;
std::cerr << "Warning: <meshPatch> and <meshRow> have been renamed <meshpatch> and <meshrow>" << std::endl;
}
else if (id == "svg:meshpatch")
ret = new SPMeshpatch;
else if (id == "svg:meshRow")
ret = new SPMeshrow;
else if (id == "svg:meshrow")
ret = new SPMeshrow;
else if (id == "svg:metadata")
ret = new SPMetadata;
else if (id == "svg:missing-glyph")
ret = new SPMissingGlyph;
else if (id == "sodipodi:namedview")
ret = new SPNamedView;
else if (id == "inkscape:offset")
ret = new SPOffset;
else if (id == "svg:path")
ret = new SPPath;
else if (id == "svg:pattern")
ret = new SPPattern;
else if (id == "svg:polygon")
ret = new SPPolygon;
else if (id == "svg:polyline")
ret = new SPPolyLine;
else if (id == "svg:radialGradient")
ret = new SPRadialGradient;
else if (id == "svg:rect")
ret = new SPRect;
else if (id == "rect") // LPE rect
ret = new SPRect;
else if (id == "svg:svg")
ret = new SPRoot;
else if (id == "svg:script")
ret = new SPScript;
else if (id == "svg:solidColor") {
ret = new SPSolidColor;
std::cerr << "Warning: <solidColor> has been renamed <solidcolor>" << std::endl;
}
else if (id == "svg:solidcolor")
ret = new SPSolidColor;
else if (id == "spiral")
ret = new SPSpiral;
else if (id == "star")
ret = new SPStar;
else if (id == "svg:stop")
ret = new SPStop;
else if (id == "string")
ret = new SPString;
else if (id == "svg:style")
ret = new SPStyleElem;
else if (id == "svg:switch")
ret = new SPSwitch;
else if (id == "svg:symbol")
ret = new SPSymbol;
else if (id == "inkscape:tag")
ret = new SPTag;
else if (id == "inkscape:tagref")
ret = new SPTagUse;
else if (id == "svg:text")
ret = new SPText;
else if (id == "svg:title")
ret = new SPTitle;
else if (id == "svg:tref")
ret = new SPTRef;
else if (id == "svg:tspan")
ret = new SPTSpan;
else if (id == "svg:textPath")
ret = new SPTextPath;
else if (id == "svg:use")
ret = new SPUse;
else if (id == "inkscape:path-effect")
ret = new LivePathEffectObject;
// filters
else if (id == "svg:feBlend")
ret = new SPFeBlend;
else if (id == "svg:feColorMatrix")
ret = new SPFeColorMatrix;
else if (id == "svg:feComponentTransfer")
ret = new SPFeComponentTransfer;
else if (id == "svg:feFuncR")
ret = new SPFeFuncNode(SPFeFuncNode::R);
else if (id == "svg:feFuncG")
ret = new SPFeFuncNode(SPFeFuncNode::G);
else if (id == "svg:feFuncB")
ret = new SPFeFuncNode(SPFeFuncNode::B);
else if (id == "svg:feFuncA")
ret = new SPFeFuncNode(SPFeFuncNode::A);
else if (id == "svg:feComposite")
ret = new SPFeComposite;
else if (id == "svg:feConvolveMatrix")
ret = new SPFeConvolveMatrix;
else if (id == "svg:feDiffuseLighting")
ret = new SPFeDiffuseLighting;
else if (id == "svg:feDisplacementMap")
ret = new SPFeDisplacementMap;
else if (id == "svg:feDistantLight")
ret = new SPFeDistantLight;
else if (id == "svg:feFlood")
ret = new SPFeFlood;
else if (id == "svg:feGaussianBlur")
ret = new SPGaussianBlur;
else if (id == "svg:feImage")
ret = new SPFeImage;
else if (id == "svg:feMerge")
ret = new SPFeMerge;
else if (id == "svg:feMergeNode")
ret = new SPFeMergeNode;
else if (id == "svg:feMorphology")
ret = new SPFeMorphology;
else if (id == "svg:feOffset")
ret = new SPFeOffset;
else if (id == "svg:fePointLight")
ret = new SPFePointLight;
else if (id == "svg:feSpecularLighting")
ret = new SPFeSpecularLighting;
else if (id == "svg:feSpotLight")
ret = new SPFeSpotLight;
else if (id == "svg:feTile")
ret = new SPFeTile;
else if (id == "svg:feTurbulence")
ret = new SPFeTurbulence;
else if (id == "inkscape:grid")
ret = new SPObject; // TODO wtf
else if (id == "rdf:RDF") // no SP node yet
{}
else if (id == "inkscape:clipboard") // SP node not necessary
{}
else if (id == "inkscape:templateinfo" || id == "inkscape:_templateinfo") // metadata for templates
{}
else if (id.empty()) // comments
{}
else {
fprintf(stderr, "WARNING: unknown type: %s\n", id.c_str());
}
return ret;
}
std::string NodeTraits::get_type_string(Inkscape::XML::Node const &node)
{
std::string name;
switch (node.type()) {
case Inkscape::XML::NodeType::TEXT_NODE:
name = "string";
break;
case Inkscape::XML::NodeType::ELEMENT_NODE: {
char const *const sptype = node.attribute("sodipodi:type");
if (sptype) {
name = sptype;
} else {
name = node.name();
}
break;
}
default:
name = "";
break;
}
return name;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
|