sp-factory.cpp revision b6514916e41354d0f2049c5f41dcb5a440f2e2f2
390N/A/*
390N/A * Factory for SPObject tree
390N/A *
390N/A * Authors:
390N/A * Markus Engel
390N/A *
390N/A * Copyright (C) 2013 Authors
390N/A * Released under GNU GPL, read the file 'COPYING' for more information
390N/A */
390N/A
390N/A#include "sp-factory.h"
390N/A
390N/A// primary
390N/A#include "box3d.h"
390N/A#include "box3d-side.h"
390N/A#include "color-profile.h"
390N/A#include "persp3d.h"
390N/A#include "sp-anchor.h"
390N/A#include "sp-clippath.h"
390N/A#include "sp-defs.h"
390N/A#include "sp-desc.h"
390N/A#include "sp-ellipse.h"
5575N/A#include "sp-filter.h"
390N/A#include "sp-flowdiv.h"
390N/A#include "sp-flowregion.h"
390N/A#include "sp-flowtext.h"
390N/A#include "sp-font.h"
390N/A#include "sp-font-face.h"
1413N/A#include "sp-glyph.h"
390N/A#include "sp-glyph-kerning.h"
390N/A#include "sp-guide.h"
618N/A#include "sp-hatch.h"
844N/A#include "sp-hatch-path.h"
1413N/A#include "sp-image.h"
1413N/A#include "sp-item-group.h"
1363N/A#include "sp-line.h"
4035N/A#include "sp-linear-gradient.h"
1413N/A#include "sp-marker.h"
3817N/A#include "sp-mask.h"
3817N/A#include "sp-mesh.h"
3817N/A#include "sp-mesh-patch.h"
390N/A#include "sp-mesh-row.h"
1938N/A#include "sp-metadata.h"
1447N/A#include "sp-missing-glyph.h"
390N/A#include "sp-namedview.h"
390N/A#include "sp-object.h"
390N/A#include "sp-offset.h"
5575N/A#include "sp-path.h"
1413N/A#include "sp-pattern.h"
3743N/A#include "sp-polygon.h"
5575N/A#include "sp-polyline.h"
5575N/A#include "sp-radial-gradient.h"
5575N/A#include "sp-rect.h"
5575N/A#include "sp-root.h"
5575N/A#include "sp-script.h"
5575N/A#include "sp-solid-color.h"
5575N/A#include "sp-spiral.h"
5575N/A#include "sp-star.h"
5575N/A#include "sp-stop.h"
5575N/A#include "sp-string.h"
390N/A#include "sp-style-elem.h"
1413N/A#include "sp-switch.h"
390N/A#include "sp-symbol.h"
1413N/A#include "sp-tag.h"
390N/A#include "sp-tag-use.h"
1413N/A#include "sp-text.h"
390N/A#include "sp-textpath.h"
4337N/A#include "sp-title.h"
4337N/A#include "sp-tref.h"
390N/A#include "sp-tspan.h"
3817N/A#include "sp-use.h"
5575N/A#include "live_effects/lpeobject.h"
5575N/A
5575N/A// filters
3817N/A#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 = NULL;
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 == "svg:hatch")
ret = new SPHatch;
else if (id == "svg:hatchPath")
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")
ret = new SPMesh;
else if (id == "svg:meshpatch")
ret = new SPMeshpatch;
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 == "svg:svg")
ret = new SPRoot;
else if (id == "svg:script")
ret = new SPScript;
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") // ?
{}
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::TEXT_NODE:
name = "string";
break;
case Inkscape::XML::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 :