summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: eba069b)
raw | patch | inline | side by side (parent: eba069b)
author | ishmal <ishmal@users.sourceforge.net> | |
Tue, 3 Jun 2008 18:24:50 +0000 (18:24 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Tue, 3 Jun 2008 18:24:50 +0000 (18:24 +0000) |
src/dom/svg.h | patch | blob | history | |
src/dom/svgimpl.cpp | patch | blob | history | |
src/dom/svgimpl.h | patch | blob | history | |
src/dom/svgreader.cpp | patch | blob | history |
diff --git a/src/dom/svg.h b/src/dom/svg.h
index 09a58a7e52ae4c7fd8ad125d643a8a232525e46c..5bf943cc6884439c8fdba9a36ac0ce25ff92558a 100644 (file)
--- a/src/dom/svg.h
+++ b/src/dom/svg.h
#include <math.h>
+#define SVG_NAMESPACE "http://www.w3.org/2000/svg"
namespace org
diff --git a/src/dom/svgimpl.cpp b/src/dom/svgimpl.cpp
index fc0af59c9b7bce42a928c18d377ed711610a397e..76bdfa163f2a8243c70ca20ea86477f18e31f1f3 100644 (file)
--- a/src/dom/svgimpl.cpp
+++ b/src/dom/svgimpl.cpp
{
+/*#########################################################################
+## Element type lookup table
+#########################################################################*/
+
+/**
+ * Used for mapping name->enum and enum->name. For SVG element types.
+ */
+typedef struct
+{
+ const char *name;
+ int type;
+} SVGElementTableEntry;
+
+
+
+SVGElementTableEntry svgElementTable[] =
+{
+ { "a", SVG_A_ELEMENT },
+ { "altGlyph", SVG_ALTGLYPH_ELEMENT },
+ { "altGlyphDef", SVG_ALTGLYPHDEF_ELEMENT },
+ { "altGlyphItem", SVG_ALTGLYPHITEM_ELEMENT },
+ { "animate", SVG_ANIMATE_ELEMENT },
+ { "animateColor", SVG_ANIMATECOLOR_ELEMENT },
+ { "animateMotion", SVG_ANIMATEMOTION_ELEMENT },
+ { "animateTransform", SVG_ANIMATETRANSFORM_ELEMENT },
+ { "circle", SVG_CIRCLE_ELEMENT },
+ { "clipPath", SVG_CLIPPATH_ELEMENT },
+ { "color-profile", SVG_COLOR_PROFILE_ELEMENT },
+ { "cursor", SVG_CURSOR_ELEMENT },
+ { "definition-src", SVG_DEFINITION_SRC_ELEMENT },
+ { "defs", SVG_DEFS_ELEMENT },
+ { "desc", SVG_DESC_ELEMENT },
+ { "ellipse", SVG_ELLIPSE_ELEMENT },
+ { "feBlend", SVG_FEBLEND_ELEMENT },
+ { "feColorMatrix", SVG_FECOLORMATRIX_ELEMENT },
+ { "feComponentTransfer", SVG_FECOMPONENTTRANSFER_ELEMENT },
+ { "feComposite", SVG_FECOMPOSITE_ELEMENT },
+ { "feConvolveMatrix", SVG_FECONVOLVEMATRIX_ELEMENT },
+ { "feDiffuseLighting", SVG_FEDIFFUSELIGHTING_ELEMENT },
+ { "feDisplacementMap", SVG_FEDISPLACEMENTMAP_ELEMENT },
+ { "feDistantLight", SVG_FEDISTANTLIGHT_ELEMENT },
+ { "feFlood", SVG_FEFLOOD_ELEMENT },
+ { "feFuncA", SVG_FEFUNCA_ELEMENT },
+ { "feFuncB", SVG_FEFUNCB_ELEMENT },
+ { "feFuncG", SVG_FEFUNCG_ELEMENT },
+ { "feFuncR", SVG_FEFUNCR_ELEMENT },
+ { "feGaussianBlur", SVG_FEGAUSSIANBLUR_ELEMENT },
+ { "feImage", SVG_FEIMAGE_ELEMENT },
+ { "feMerge", SVG_FEMERGE_ELEMENT },
+ { "feMergeNode", SVG_FEMERGENODE_ELEMENT },
+ { "feMorphology", SVG_FEMORPHOLOGY_ELEMENT },
+ { "feOffset", SVG_FEOFFSET_ELEMENT },
+ { "fePointLight", SVG_FEPOINTLIGHT_ELEMENT },
+ { "feSpecularLighting", SVG_FESPECULARLIGHTING_ELEMENT },
+ { "feSpotLight", SVG_FESPOTLIGHT_ELEMENT },
+ { "feTile", SVG_FETILE_ELEMENT },
+ { "feTurbulence", SVG_FETURBULENCE_ELEMENT },
+ { "filter", SVG_FILTER_ELEMENT },
+ { "font", SVG_FONT_ELEMENT },
+ { "font-face", SVG_FONT_FACE_ELEMENT },
+ { "font-face-format", SVG_FONT_FACE_FORMAT_ELEMENT },
+ { "font-face-name", SVG_FONT_FACE_NAME_ELEMENT },
+ { "font-face-src", SVG_FONT_FACE_SRC_ELEMENT },
+ { "font-face-uri", SVG_FONT_FACE_URI_ELEMENT },
+ { "foreignObject", SVG_FOREIGNOBJECT_ELEMENT },
+ { "g", SVG_G_ELEMENT },
+ { "glyph", SVG_GLYPH_ELEMENT },
+ { "glyphRef", SVG_GLYPHREF_ELEMENT },
+ { "hkern", SVG_HKERN_ELEMENT },
+ { "image", SVG_IMAGE_ELEMENT },
+ { "line", SVG_LINE_ELEMENT },
+ { "linearGradient", SVG_LINEARGRADIENT_ELEMENT },
+ { "marker", SVG_MARKER_ELEMENT },
+ { "mask", SVG_MASK_ELEMENT },
+ { "metadata", SVG_METADATA_ELEMENT },
+ { "missing-glyph", SVG_MISSING_GLYPH_ELEMENT },
+ { "mpath", SVG_MPATH_ELEMENT },
+ { "path", SVG_PATH_ELEMENT },
+ { "pattern", SVG_PATTERN_ELEMENT },
+ { "polygon", SVG_POLYGON_ELEMENT },
+ { "polyline", SVG_POLYLINE_ELEMENT },
+ { "radialGradient", SVG_RADIALGRADIENT_ELEMENT },
+ { "rect", SVG_RECT_ELEMENT },
+ { "script", SVG_SCRIPT_ELEMENT },
+ { "set", SVG_SET_ELEMENT },
+ { "stop", SVG_STOP_ELEMENT },
+ { "style", SVG_STYLE_ELEMENT },
+ { "svg", SVG_SVG_ELEMENT },
+ { "switch", SVG_SWITCH_ELEMENT },
+ { "symbol", SVG_SYMBOL_ELEMENT },
+ { "text", SVG_TEXT_ELEMENT },
+ { "textPath", SVG_TEXTPATH_ELEMENT },
+ { "title", SVG_TITLE_ELEMENT },
+ { "tref", SVG_TREF_ELEMENT },
+ { "tspan", SVG_TSPAN_ELEMENT },
+ { "use", SVG_USE_ELEMENT },
+ { "view", SVG_VIEW_ELEMENT },
+ { "vkern", SVG_VKERN_ELEMENT }
+ };
+
+
+static int _entryComparison(const void *vkey, const void *ventry)
+{
+ const char *key = (const char *)vkey;
+ const SVGElementTableEntry *entry = (const SVGElementTableEntry *)ventry;
+ return strcmp(key, entry->name);
+}
+
+/**
+ * Look up the SVG Element type enum for a given string
+ * Return -1 if not found
+ */
+int svgElementStrToEnum(const char *str)
+{
+ if (!str)
+ return -1;
+ SVGElementTableEntry *entry =
+ (SVGElementTableEntry *)bsearch(str, svgElementTable,
+ SVG_MAX_ELEMENT, sizeof(SVGElementTableEntry), _entryComparison);
+ if (!entry)
+ return -1;
+ return entry->type;
+}
+
+
+/**
+ * Return the string corresponding to a given SVG element type enum
+ * Return "unknown" if not found
+ */
+const char *svgElementEnumToStr(int type)
+{
+ if (type < 0 || type >= SVG_MAX_ELEMENT)
+ return "unknown";
+ return svgElementTable[type].name;
+}
+
+
/*#########################################################################
## SVGElementImpl
#########################################################################*/
ElementPtr SVGDocumentImpl::createElement(const DOMString& tagName)
throw(DOMException)
{
- SVGElementPtr elem = new SVGElementImpl(this, tagName);
+ ElementPtr elem;
+ int elementType = svgElementStrToEnum(tagName.c_str());
+ switch (elementType)
+ {
+ case SVG_A_ELEMENT:
+ {
+ elem = new SVGAElementImpl();
+ break;
+ }
+ case SVG_ALTGLYPH_ELEMENT:
+ {
+ break;
+ }
+ case SVG_ALTGLYPHDEF_ELEMENT:
+ {
+ break;
+ }
+ case SVG_ALTGLYPHITEM_ELEMENT:
+ {
+ break;
+ }
+ case SVG_ANIMATE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_ANIMATECOLOR_ELEMENT:
+ {
+ break;
+ }
+ case SVG_ANIMATEMOTION_ELEMENT:
+ {
+ break;
+ }
+ case SVG_ANIMATETRANSFORM_ELEMENT:
+ {
+ break;
+ }
+ case SVG_CIRCLE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_CLIPPATH_ELEMENT:
+ {
+ break;
+ }
+ case SVG_COLOR_PROFILE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_CURSOR_ELEMENT:
+ {
+ break;
+ }
+ case SVG_DEFINITION_SRC_ELEMENT:
+ {
+ break;
+ }
+ case SVG_DEFS_ELEMENT:
+ {
+ break;
+ }
+ case SVG_DESC_ELEMENT:
+ {
+ break;
+ }
+ case SVG_ELLIPSE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEBLEND_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FECOLORMATRIX_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FECOMPONENTTRANSFER_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FECOMPOSITE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FECONVOLVEMATRIX_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEDIFFUSELIGHTING_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEDISPLACEMENTMAP_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEDISTANTLIGHT_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEFLOOD_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEFUNCA_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEFUNCB_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEFUNCG_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEFUNCR_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEGAUSSIANBLUR_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEIMAGE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEMERGE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEMERGENODE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEMORPHOLOGY_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEOFFSET_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FEPOINTLIGHT_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FESPECULARLIGHTING_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FESPOTLIGHT_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FETILE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FETURBULENCE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FILTER_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FONT_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FONT_FACE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FONT_FACE_FORMAT_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FONT_FACE_NAME_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FONT_FACE_SRC_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FONT_FACE_URI_ELEMENT:
+ {
+ break;
+ }
+ case SVG_FOREIGNOBJECT_ELEMENT:
+ {
+ break;
+ }
+ case SVG_G_ELEMENT:
+ {
+ break;
+ }
+ case SVG_GLYPH_ELEMENT:
+ {
+ break;
+ }
+ case SVG_GLYPHREF_ELEMENT:
+ {
+ break;
+ }
+ case SVG_HKERN_ELEMENT:
+ {
+ break;
+ }
+ case SVG_IMAGE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_LINE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_LINEARGRADIENT_ELEMENT:
+ {
+ break;
+ }
+ case SVG_MARKER_ELEMENT:
+ {
+ break;
+ }
+ case SVG_MASK_ELEMENT:
+ {
+ break;
+ }
+ case SVG_METADATA_ELEMENT:
+ {
+ break;
+ }
+ case SVG_MISSING_GLYPH_ELEMENT:
+ {
+ break;
+ }
+ case SVG_MPATH_ELEMENT:
+ {
+ break;
+ }
+ case SVG_PATH_ELEMENT:
+ {
+ break;
+ }
+ case SVG_PATTERN_ELEMENT:
+ {
+ break;
+ }
+ case SVG_POLYGON_ELEMENT:
+ {
+ break;
+ }
+ case SVG_POLYLINE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_RADIALGRADIENT_ELEMENT:
+ {
+ break;
+ }
+ case SVG_RECT_ELEMENT:
+ {
+ break;
+ }
+ case SVG_SCRIPT_ELEMENT:
+ {
+ break;
+ }
+ case SVG_SET_ELEMENT:
+ {
+ break;
+ }
+ case SVG_STOP_ELEMENT:
+ {
+ break;
+ }
+ case SVG_STYLE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_SVG_ELEMENT:
+ {
+ break;
+ }
+ case SVG_SWITCH_ELEMENT:
+ {
+ break;
+ }
+ case SVG_SYMBOL_ELEMENT:
+ {
+ break;
+ }
+ case SVG_TEXT_ELEMENT:
+ {
+ break;
+ }
+ case SVG_TEXTPATH_ELEMENT:
+ {
+ break;
+ }
+ case SVG_TITLE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_TREF_ELEMENT:
+ {
+ break;
+ }
+ case SVG_TSPAN_ELEMENT:
+ {
+ break;
+ }
+ case SVG_USE_ELEMENT:
+ {
+ break;
+ }
+ case SVG_VIEW_ELEMENT:
+ {
+ break;
+ }
+ case SVG_VKERN_ELEMENT:
+ {
+ break;
+ }
+ default:
+ {
+ }
+ }
return elem;
}
const DOMString& qualifiedName)
throw(DOMException)
{
- SVGElementPtr elem = new SVGElementImpl(this, namespaceURI, qualifiedName);
+ ElementPtr elem;
+ if (namespaceURI == SVG_NAMESPACE)
+ elem = createElement(qualifiedName);
+ else
+ elem = new SVGElementImpl(this, namespaceURI, qualifiedName);
return elem;
}
diff --git a/src/dom/svgimpl.h b/src/dom/svgimpl.h
index 80800098ac18aeb94b41c2d8f6e1717d063fc9bf..58a10c396c3c2d79bd601169c9ca9abbb8184d86 100644 (file)
--- a/src/dom/svgimpl.h
+++ b/src/dom/svgimpl.h
class SVGDocumentImpl;
typedef Ptr<SVGDocumentImpl> SVGDocumentImplPtr;
+/*#########################################################################
+## Types
+#########################################################################*/
+
+typedef enum
+{
+/**
+ * Defines a hyperlink
+ */
+SVG_A_ELEMENT = 0,
+/**
+ * Allows control over glyphs used to render particular character
+ * data (e.g. for music symbols or Asian text)
+ */
+SVG_ALTGLYPH_ELEMENT,
+/**
+ * Defines a set of glyph substitutions (e.g. for music symbols or Asian text)
+ */
+SVG_ALTGLYPHDEF_ELEMENT,
+/**
+ * Defines a candidate set of glyph substitutions (e.g. for music symbols
+ * or Asian text)
+ */
+SVG_ALTGLYPHITEM_ELEMENT,
+/**
+ * Animates an attribute or property over time
+ */
+SVG_ANIMATE_ELEMENT,
+/**
+ * Specifies a color transformation over time
+ */
+SVG_ANIMATECOLOR_ELEMENT,
+/**
+ * Causes an element to move along a motion path
+ */
+SVG_ANIMATEMOTION_ELEMENT,
+/**
+ * Animates a transformation attribute on an element
+ */
+SVG_ANIMATETRANSFORM_ELEMENT,
+/**
+ * Defines a circle
+ */
+SVG_CIRCLE_ELEMENT,
+/**
+ *
+ */
+SVG_CLIPPATH_ELEMENT,
+/**
+ * Specifies a color profile description
+ */
+SVG_COLOR_PROFILE_ELEMENT,
+/**
+ * Defines a platform-independent cursor
+ */
+SVG_CURSOR_ELEMENT,
+/**
+ * Defines a separate font definition resource
+ */
+SVG_DEFINITION_SRC_ELEMENT,
+/**
+ * A container for referenced elements
+ */
+SVG_DEFS_ELEMENT,
+/**
+ * A text-only description for elements in SVG - not displayed as part
+ * of the graphics. User agents may display the text as a tooltip
+ */
+SVG_DESC_ELEMENT,
+/**
+ * Defines an ellipse
+ */
+SVG_ELLIPSE_ELEMENT,
+/**
+ * SVG filter. Composites two objects together using different blending modes
+ */
+SVG_FEBLEND_ELEMENT,
+/**
+ * SVG filter. Applies a matrix transformation
+ */
+SVG_FECOLORMATRIX_ELEMENT,
+/**
+ * SVG filter. Performs component-wise remapping of data
+ */
+SVG_FECOMPONENTTRANSFER_ELEMENT,
+/**
+ * SVG filter.
+ */
+SVG_FECOMPOSITE_ELEMENT,
+/**
+ * SVG filter.
+ */
+SVG_FECONVOLVEMATRIX_ELEMENT,
+/**
+ * SVG filter.
+ */
+SVG_FEDIFFUSELIGHTING_ELEMENT,
+/**
+ * SVG filter.
+ */
+SVG_FEDISPLACEMENTMAP_ELEMENT,
+/**
+ * SVG filter. Defines a light source
+ */
+SVG_FEDISTANTLIGHT_ELEMENT,
+/**
+ * SVG filter.
+ */
+SVG_FEFLOOD_ELEMENT,
+/**
+ * SVG filter. Sub-element to feComponentTransfer
+ */
+SVG_FEFUNCA_ELEMENT,
+/**
+ * SVG filter. Sub-element to feComponentTransfer
+ */
+SVG_FEFUNCB_ELEMENT,
+/**
+ * SVG filter. Sub-element to feComponentTransfer
+ */
+SVG_FEFUNCG_ELEMENT,
+/**
+ * SVG filter. Sub-element to feComponentTransfer
+ */
+SVG_FEFUNCR_ELEMENT,
+/**
+ * SVG filter. Performs a Gaussian blur on the image
+ */
+SVG_FEGAUSSIANBLUR_ELEMENT,
+/**
+ * SVG filter.
+ */
+SVG_FEIMAGE_ELEMENT,
+/**
+ * SVG filter. Creates image layers on top of each other
+ */
+SVG_FEMERGE_ELEMENT,
+/**
+ * SVG filter. Sub-element to feMerge
+ */
+SVG_FEMERGENODE_ELEMENT,
+/**
+ * SVG filter. Performs a "fattening" or "thinning" on a source graphic
+ */
+SVG_FEMORPHOLOGY_ELEMENT,
+/**
+ * SVG filter. Moves an image relative to its current position
+ */
+SVG_FEOFFSET_ELEMENT,
+/**
+ * SVG filter.
+ */
+SVG_FEPOINTLIGHT_ELEMENT,
+/**
+ * SVG filter.
+ */
+SVG_FESPECULARLIGHTING_ELEMENT,
+/**
+ * SVG filter.
+ */
+SVG_FESPOTLIGHT_ELEMENT,
+/**
+ * SVG filter.
+ */
+SVG_FETILE_ELEMENT,
+/**
+ * SVG filter.
+ */
+SVG_FETURBULENCE_ELEMENT,
+/**
+ * Container for filter effects
+ */
+SVG_FILTER_ELEMENT,
+/**
+ * Defines a font
+ */
+SVG_FONT_ELEMENT,
+/**
+ * Describes the characteristics of a font
+ */
+SVG_FONT_FACE_ELEMENT,
+/**
+ *
+ */
+SVG_FONT_FACE_FORMAT_ELEMENT,
+/**
+ *
+ */
+SVG_FONT_FACE_NAME_ELEMENT,
+/**
+ *
+ */
+SVG_FONT_FACE_SRC_ELEMENT,
+/**
+ *
+ */
+SVG_FONT_FACE_URI_ELEMENT,
+/**
+ *
+ */
+SVG_FOREIGNOBJECT_ELEMENT,
+/**
+ * A container element for grouping together related elements
+ */
+SVG_G_ELEMENT,
+/**
+ * Defines the graphics for a given glyph
+ */
+SVG_GLYPH_ELEMENT,
+/**
+ * Defines a possible glyph to use
+ */
+SVG_GLYPHREF_ELEMENT,
+/**
+ *
+ */
+SVG_HKERN_ELEMENT,
+/**
+ *
+ */
+SVG_IMAGE_ELEMENT,
+/**
+ * Defines a line
+ */
+SVG_LINE_ELEMENT,
+/**
+ * Defines a linear gradient
+ */
+SVG_LINEARGRADIENT_ELEMENT,
+/**
+ *
+ */
+SVG_MARKER_ELEMENT,
+/**
+ *
+ */
+SVG_MASK_ELEMENT,
+/**
+ * Specifies metadata
+ */
+SVG_METADATA_ELEMENT,
+/**
+ *
+ */
+SVG_MISSING_GLYPH_ELEMENT,
+/**
+ *
+ */
+SVG_MPATH_ELEMENT,
+/**
+ * Defines a path
+ */
+SVG_PATH_ELEMENT,
+/**
+ *
+ */
+SVG_PATTERN_ELEMENT,
+/**
+ * Defines a closed shape that consists of a set of connected straight lines
+ */
+SVG_POLYGON_ELEMENT,
+/**
+ * Defines a set of connected straight lines
+ */
+SVG_POLYLINE_ELEMENT,
+/**
+ * Defines a radial gradient
+ */
+SVG_RADIALGRADIENT_ELEMENT,
+/**
+ * Defines a rectangle
+ */
+SVG_RECT_ELEMENT,
+/**
+ * Container for scripts (e.g., ECMAScript)
+ */
+SVG_SCRIPT_ELEMENT,
+/**
+ * Sets the value of an attribute for a specified duration
+ */
+SVG_SET_ELEMENT,
+/**
+ *
+ */
+SVG_STOP_ELEMENT,
+/**
+ * Allows style sheets to be embedded directly within SVG content
+ */
+SVG_STYLE_ELEMENT,
+/**
+ * Defines an SVG document fragment
+ */
+SVG_SVG_ELEMENT,
+/**
+ *
+ */
+SVG_SWITCH_ELEMENT,
+/**
+ *
+ */
+SVG_SYMBOL_ELEMENT,
+/**
+ *
+ */
+SVG_TEXT_ELEMENT,
+/**
+ *
+ */
+SVG_TEXTPATH_ELEMENT,
+/**
+ * A text-only description for elements in SVG - not displayed as part of
+ * the graphics. User agents may display the text as a tooltip
+ */
+SVG_TITLE_ELEMENT,
+/**
+ *
+ */
+SVG_TREF_ELEMENT,
+/**
+ *
+ */
+SVG_TSPAN_ELEMENT,
+/**
+ *
+ */
+SVG_USE_ELEMENT,
+/**
+ *
+ */
+SVG_VIEW_ELEMENT,
+/**
+ *
+ */
+SVG_VKERN_ELEMENT,
+/**
+ *
+ */
+SVG_MAX_ELEMENT
+
+} SVGElementType;
+
+
+
+
+/**
+ * Look up the SVG Element type enum for a given string
+ * Return -1 if not found
+ */
+int svgElementStrToEnum(const char *str);
+
+
+/**
+ * Return the string corresponding to a given SVG element type enum
+ * Return "unknown" if not found
+ */
+const char *svgElementEnumToStr(int type);
+
+
/*#########################################################################
## SVGDocumentImpl
#########################################################################*/
diff --git a/src/dom/svgreader.cpp b/src/dom/svgreader.cpp
index 9db6affa2537b5d22f7db22f7af9b3ca343e9679..ea4392f50fb494f0b1c0745956421690677dab03 100644 (file)
--- a/src/dom/svgreader.cpp
+++ b/src/dom/svgreader.cpp
#include <stdarg.h>
-#define SVG_NAMESPACE "http://www.w3.org/2000/svg"
namespace org
{
-/*#########################################################################
-## Types
-#########################################################################*/
-
-typedef enum
-{
-/**
- * Defines a hyperlink
- */
-SVG_A_ELEMENT = 0,
-/**
- * Allows control over glyphs used to render particular character
- * data (e.g. for music symbols or Asian text)
- */
-SVG_ALTGLYPH_ELEMENT,
-/**
- * Defines a set of glyph substitutions (e.g. for music symbols or Asian text)
- */
-SVG_ALTGLYPHDEF_ELEMENT,
-/**
- * Defines a candidate set of glyph substitutions (e.g. for music symbols
- * or Asian text)
- */
-SVG_ALTGLYPHITEM_ELEMENT,
-/**
- * Animates an attribute or property over time
- */
-SVG_ANIMATE_ELEMENT,
-/**
- * Specifies a color transformation over time
- */
-SVG_ANIMATECOLOR_ELEMENT,
-/**
- * Causes an element to move along a motion path
- */
-SVG_ANIMATEMOTION_ELEMENT,
-/**
- * Animates a transformation attribute on an element
- */
-SVG_ANIMATETRANSFORM_ELEMENT,
-/**
- * Defines a circle
- */
-SVG_CIRCLE_ELEMENT,
-/**
- *
- */
-SVG_CLIPPATH_ELEMENT,
-/**
- * Specifies a color profile description
- */
-SVG_COLOR_PROFILE_ELEMENT,
-/**
- * Defines a platform-independent cursor
- */
-SVG_CURSOR_ELEMENT,
-/**
- * Defines a separate font definition resource
- */
-SVG_DEFINITION_SRC_ELEMENT,
-/**
- * A container for referenced elements
- */
-SVG_DEFS_ELEMENT,
-/**
- * A text-only description for elements in SVG - not displayed as part
- * of the graphics. User agents may display the text as a tooltip
- */
-SVG_DESC_ELEMENT,
-/**
- * Defines an ellipse
- */
-SVG_ELLIPSE_ELEMENT,
-/**
- * SVG filter. Composites two objects together using different blending modes
- */
-SVG_FEBLEND_ELEMENT,
-/**
- * SVG filter. Applies a matrix transformation
- */
-SVG_FECOLORMATRIX_ELEMENT,
-/**
- * SVG filter. Performs component-wise remapping of data
- */
-SVG_FECOMPONENTTRANSFER_ELEMENT,
-/**
- * SVG filter.
- */
-SVG_FECOMPOSITE_ELEMENT,
-/**
- * SVG filter.
- */
-SVG_FECONVOLVEMATRIX_ELEMENT,
-/**
- * SVG filter.
- */
-SVG_FEDIFFUSELIGHTING_ELEMENT,
-/**
- * SVG filter.
- */
-SVG_FEDISPLACEMENTMAP_ELEMENT,
-/**
- * SVG filter. Defines a light source
- */
-SVG_FEDISTANTLIGHT_ELEMENT,
-/**
- * SVG filter.
- */
-SVG_FEFLOOD_ELEMENT,
-/**
- * SVG filter. Sub-element to feComponentTransfer
- */
-SVG_FEFUNCA_ELEMENT,
-/**
- * SVG filter. Sub-element to feComponentTransfer
- */
-SVG_FEFUNCB_ELEMENT,
-/**
- * SVG filter. Sub-element to feComponentTransfer
- */
-SVG_FEFUNCG_ELEMENT,
-/**
- * SVG filter. Sub-element to feComponentTransfer
- */
-SVG_FEFUNCR_ELEMENT,
-/**
- * SVG filter. Performs a Gaussian blur on the image
- */
-SVG_FEGAUSSIANBLUR_ELEMENT,
-/**
- * SVG filter.
- */
-SVG_FEIMAGE_ELEMENT,
-/**
- * SVG filter. Creates image layers on top of each other
- */
-SVG_FEMERGE_ELEMENT,
-/**
- * SVG filter. Sub-element to feMerge
- */
-SVG_FEMERGENODE_ELEMENT,
-/**
- * SVG filter. Performs a "fattening" or "thinning" on a source graphic
- */
-SVG_FEMORPHOLOGY_ELEMENT,
-/**
- * SVG filter. Moves an image relative to its current position
- */
-SVG_FEOFFSET_ELEMENT,
-/**
- * SVG filter.
- */
-SVG_FEPOINTLIGHT_ELEMENT,
-/**
- * SVG filter.
- */
-SVG_FESPECULARLIGHTING_ELEMENT,
-/**
- * SVG filter.
- */
-SVG_FESPOTLIGHT_ELEMENT,
-/**
- * SVG filter.
- */
-SVG_FETILE_ELEMENT,
-/**
- * SVG filter.
- */
-SVG_FETURBULENCE_ELEMENT,
-/**
- * Container for filter effects
- */
-SVG_FILTER_ELEMENT,
-/**
- * Defines a font
- */
-SVG_FONT_ELEMENT,
-/**
- * Describes the characteristics of a font
- */
-SVG_FONT_FACE_ELEMENT,
-/**
- *
- */
-SVG_FONT_FACE_FORMAT_ELEMENT,
-/**
- *
- */
-SVG_FONT_FACE_NAME_ELEMENT,
-/**
- *
- */
-SVG_FONT_FACE_SRC_ELEMENT,
-/**
- *
- */
-SVG_FONT_FACE_URI_ELEMENT,
-/**
- *
- */
-SVG_FOREIGNOBJECT_ELEMENT,
-/**
- * A container element for grouping together related elements
- */
-SVG_G_ELEMENT,
-/**
- * Defines the graphics for a given glyph
- */
-SVG_GLYPH_ELEMENT,
-/**
- * Defines a possible glyph to use
- */
-SVG_GLYPHREF_ELEMENT,
-/**
- *
- */
-SVG_HKERN_ELEMENT,
-/**
- *
- */
-SVG_IMAGE_ELEMENT,
-/**
- * Defines a line
- */
-SVG_LINE_ELEMENT,
-/**
- * Defines a linear gradient
- */
-SVG_LINEARGRADIENT_ELEMENT,
-/**
- *
- */
-SVG_MARKER_ELEMENT,
-/**
- *
- */
-SVG_MASK_ELEMENT,
-/**
- * Specifies metadata
- */
-SVG_METADATA_ELEMENT,
-/**
- *
- */
-SVG_MISSING_GLYPH_ELEMENT,
-/**
- *
- */
-SVG_MPATH_ELEMENT,
-/**
- * Defines a path
- */
-SVG_PATH_ELEMENT,
-/**
- *
- */
-SVG_PATTERN_ELEMENT,
-/**
- * Defines a closed shape that consists of a set of connected straight lines
- */
-SVG_POLYGON_ELEMENT,
-/**
- * Defines a set of connected straight lines
- */
-SVG_POLYLINE_ELEMENT,
-/**
- * Defines a radial gradient
- */
-SVG_RADIALGRADIENT_ELEMENT,
-/**
- * Defines a rectangle
- */
-SVG_RECT_ELEMENT,
-/**
- * Container for scripts (e.g., ECMAScript)
- */
-SVG_SCRIPT_ELEMENT,
-/**
- * Sets the value of an attribute for a specified duration
- */
-SVG_SET_ELEMENT,
-/**
- *
- */
-SVG_STOP_ELEMENT,
-/**
- * Allows style sheets to be embedded directly within SVG content
- */
-SVG_STYLE_ELEMENT,
-/**
- * Defines an SVG document fragment
- */
-SVG_SVG_ELEMENT,
-/**
- *
- */
-SVG_SWITCH_ELEMENT,
-/**
- *
- */
-SVG_SYMBOL_ELEMENT,
-/**
- *
- */
-SVG_TEXT_ELEMENT,
-/**
- *
- */
-SVG_TEXTPATH_ELEMENT,
-/**
- * A text-only description for elements in SVG - not displayed as part of
- * the graphics. User agents may display the text as a tooltip
- */
-SVG_TITLE_ELEMENT,
-/**
- *
- */
-SVG_TREF_ELEMENT,
-/**
- *
- */
-SVG_TSPAN_ELEMENT,
-/**
- *
- */
-SVG_USE_ELEMENT,
-/**
- *
- */
-SVG_VIEW_ELEMENT,
-/**
- *
- */
-SVG_VKERN_ELEMENT,
-/**
- *
- */
-SVG_MAX_ELEMENT
-
-} SVGElementType;
-
-
-
-/**
- * Used for mapping name->enum and enum->name. For SVG element types.
- */
-typedef struct
-{
- const char *name;
- int type;
-} SVGElementTableEntry;
-
-
-
-SVGElementTableEntry svgElementTable[] =
-{
- { "a", SVG_A_ELEMENT },
- { "altGlyph", SVG_ALTGLYPH_ELEMENT },
- { "altGlyphDef", SVG_ALTGLYPHDEF_ELEMENT },
- { "altGlyphItem", SVG_ALTGLYPHITEM_ELEMENT },
- { "animate", SVG_ANIMATE_ELEMENT },
- { "animateColor", SVG_ANIMATECOLOR_ELEMENT },
- { "animateMotion", SVG_ANIMATEMOTION_ELEMENT },
- { "animateTransform", SVG_ANIMATETRANSFORM_ELEMENT },
- { "circle", SVG_CIRCLE_ELEMENT },
- { "clipPath", SVG_CLIPPATH_ELEMENT },
- { "color-profile", SVG_COLOR_PROFILE_ELEMENT },
- { "cursor", SVG_CURSOR_ELEMENT },
- { "definition-src", SVG_DEFINITION_SRC_ELEMENT },
- { "defs", SVG_DEFS_ELEMENT },
- { "desc", SVG_DESC_ELEMENT },
- { "ellipse", SVG_ELLIPSE_ELEMENT },
- { "feBlend", SVG_FEBLEND_ELEMENT },
- { "feColorMatrix", SVG_FECOLORMATRIX_ELEMENT },
- { "feComponentTransfer", SVG_FECOMPONENTTRANSFER_ELEMENT },
- { "feComposite", SVG_FECOMPOSITE_ELEMENT },
- { "feConvolveMatrix", SVG_FECONVOLVEMATRIX_ELEMENT },
- { "feDiffuseLighting", SVG_FEDIFFUSELIGHTING_ELEMENT },
- { "feDisplacementMap", SVG_FEDISPLACEMENTMAP_ELEMENT },
- { "feDistantLight", SVG_FEDISTANTLIGHT_ELEMENT },
- { "feFlood", SVG_FEFLOOD_ELEMENT },
- { "feFuncA", SVG_FEFUNCA_ELEMENT },
- { "feFuncB", SVG_FEFUNCB_ELEMENT },
- { "feFuncG", SVG_FEFUNCG_ELEMENT },
- { "feFuncR", SVG_FEFUNCR_ELEMENT },
- { "feGaussianBlur", SVG_FEGAUSSIANBLUR_ELEMENT },
- { "feImage", SVG_FEIMAGE_ELEMENT },
- { "feMerge", SVG_FEMERGE_ELEMENT },
- { "feMergeNode", SVG_FEMERGENODE_ELEMENT },
- { "feMorphology", SVG_FEMORPHOLOGY_ELEMENT },
- { "feOffset", SVG_FEOFFSET_ELEMENT },
- { "fePointLight", SVG_FEPOINTLIGHT_ELEMENT },
- { "feSpecularLighting", SVG_FESPECULARLIGHTING_ELEMENT },
- { "feSpotLight", SVG_FESPOTLIGHT_ELEMENT },
- { "feTile", SVG_FETILE_ELEMENT },
- { "feTurbulence", SVG_FETURBULENCE_ELEMENT },
- { "filter", SVG_FILTER_ELEMENT },
- { "font", SVG_FONT_ELEMENT },
- { "font-face", SVG_FONT_FACE_ELEMENT },
- { "font-face-format", SVG_FONT_FACE_FORMAT_ELEMENT },
- { "font-face-name", SVG_FONT_FACE_NAME_ELEMENT },
- { "font-face-src", SVG_FONT_FACE_SRC_ELEMENT },
- { "font-face-uri", SVG_FONT_FACE_URI_ELEMENT },
- { "foreignObject", SVG_FOREIGNOBJECT_ELEMENT },
- { "g", SVG_G_ELEMENT },
- { "glyph", SVG_GLYPH_ELEMENT },
- { "glyphRef", SVG_GLYPHREF_ELEMENT },
- { "hkern", SVG_HKERN_ELEMENT },
- { "image", SVG_IMAGE_ELEMENT },
- { "line", SVG_LINE_ELEMENT },
- { "linearGradient", SVG_LINEARGRADIENT_ELEMENT },
- { "marker", SVG_MARKER_ELEMENT },
- { "mask", SVG_MASK_ELEMENT },
- { "metadata", SVG_METADATA_ELEMENT },
- { "missing-glyph", SVG_MISSING_GLYPH_ELEMENT },
- { "mpath", SVG_MPATH_ELEMENT },
- { "path", SVG_PATH_ELEMENT },
- { "pattern", SVG_PATTERN_ELEMENT },
- { "polygon", SVG_POLYGON_ELEMENT },
- { "polyline", SVG_POLYLINE_ELEMENT },
- { "radialGradient", SVG_RADIALGRADIENT_ELEMENT },
- { "rect", SVG_RECT_ELEMENT },
- { "script", SVG_SCRIPT_ELEMENT },
- { "set", SVG_SET_ELEMENT },
- { "stop", SVG_STOP_ELEMENT },
- { "style", SVG_STYLE_ELEMENT },
- { "svg", SVG_SVG_ELEMENT },
- { "switch", SVG_SWITCH_ELEMENT },
- { "symbol", SVG_SYMBOL_ELEMENT },
- { "text", SVG_TEXT_ELEMENT },
- { "textPath", SVG_TEXTPATH_ELEMENT },
- { "title", SVG_TITLE_ELEMENT },
- { "tref", SVG_TREF_ELEMENT },
- { "tspan", SVG_TSPAN_ELEMENT },
- { "use", SVG_USE_ELEMENT },
- { "view", SVG_VIEW_ELEMENT },
- { "vkern", SVG_VKERN_ELEMENT },
- { NULL, -1 }
- };
-
-
-/**
- * Look up the SVG Element type enum for a given string
- * Return -1 if not found
- */
-int svgElementStrToEnum(const char *str)
-{
- if (!str)
- return -1;
- for (SVGElementTableEntry *entry = svgElementTable ;
- entry->name; entry++)
- {
- if (strcmp(str, entry->name) == 0)
- return entry->type;
- }
- return -1;
-}
-
-
-/**
- * Return the string corresponding to a given SVG element type enum
- * Return "unknown" if not found
- */
-const char *svgElementStrToEnum(int type)
-{
- if (type < 0 || type >= SVG_MAX_ELEMENT)
- return "unknown";
- return svgElementTable[type].name;
-}
-
-
/**
* Get the character at the position and record the fact
*/
//printf("namespaceURI:%s\n", namespaceURI.c_str());
DOMString tagName = sourceElem->getTagName();
printf("tag name:%s\n", tagName.c_str());
-
- ElementImplPtr newElement = NULL;
- if (namespaceURI != SVG_NAMESPACE)
+ ElementPtr newElement = doc->createElementNS(namespaceURI, tagName);
+ if (!newElement)
{
- newElement = new SVGSVGElementImpl();
- newElement->assign(*sourceElem);
- parent->appendChild(newElement);
- }
- else //## SVG!!
- {
-
- //####################################################
- //## ATTRIBUTES
- //####################################################
- DOMString style = sourceElem->getAttribute("style");
- if (style.size() > 0)
- {
- css::CssReader parser;
- style.insert(0, "{");
- style.append("}");
- //printf("CSS:%s\n", style.c_str());
- if (!parser.parse(style))
- {
- error("parsing style attribute");
- }
- else
- {
- //printf("##parsed!\n");
- }
- }
-
- DOMString transform = sourceElem->getAttribute("transform");
- if (transform.size() > 0)
- {
- if (!parseTransform(transform))
- {
- error("parsing transform attribute");
- }
- else
- {
- //printf("##parsed!\n");
- }
- }
+ return false;
+ }
+ NamedNodeMap &attrs = sourceElem->getAttributes();
+ for (unsigned int i=0 ; i<attrs.getLength() ; i++)
+ {
+ NodePtr n = attrs.item(i);
+ newElement->setAttribute(n->getNodeName(), n->getNodeValue());//should be exception here
+ }
+ parent->appendChild(newElement);
- //####################################################
- //## ELEMENT - SPECIFIC
- //####################################################
- if (tagName == "svg")
- {
- newElement = new SVGSVGElementImpl();
- newElement->assign(*sourceElem);
- parent->appendChild(newElement);
- }
- else if (tagName == "title")
- {
- newElement = new SVGTitleElementImpl();
- newElement->assign(*sourceElem);
- parent->appendChild(newElement);
- }
- else if (tagName == "desc")
- {
- newElement = new SVGDescElementImpl();
- newElement->assign(*sourceElem);
- parent->appendChild(newElement);
- }
- else if (tagName == "defs")
- {
- newElement = new SVGDefsElementImpl();
- newElement->assign(*sourceElem);
- parent->appendChild(newElement);
- }
- else if (tagName == "style")
- {
- newElement = new SVGStyleElementImpl();
- newElement->assign(*sourceElem);
- parent->appendChild(newElement);
- }
- else if (tagName == "g")
- {
- newElement = new SVGGElementImpl();
- newElement->assign(*sourceElem);
- parent->appendChild(newElement);
- }
- else if (tagName == "path")
- {
- newElement = new SVGPathElementImpl();
- newElement->assign(*sourceElem);
- parent->appendChild(newElement);
- }
- }
NodeList children = sourceElem->getChildNodes();
int nodeCount = children.getLength();