summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 50769be)
raw | patch | inline | side by side (parent: 50769be)
author | ishmal <ishmal@users.sourceforge.net> | |
Wed, 4 Jun 2008 21:21:15 +0000 (21:21 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Wed, 4 Jun 2008 21:21:15 +0000 (21:21 +0000) |
src/dom/svgimpl.cpp | patch | blob | history | |
src/dom/svgimpl.h | patch | blob | history |
diff --git a/src/dom/svgimpl.cpp b/src/dom/svgimpl.cpp
index d2a7e27940b9fd81ad4f4ba0a8aa7eacb541052e..6b2a7fe70391f57593a290b8a385a3cb51ced24c 100644 (file)
--- a/src/dom/svgimpl.cpp
+++ b/src/dom/svgimpl.cpp
{
+/*#########################################################################
+## U T I L I T Y
+#########################################################################*/
+
+static DOMString d2s(double d)
+{
+ char buf[40];
+ snprintf(buf, 40, "%f", d);
+ DOMString s(buf);
+ return s;
+}
+
+static double s2d(const DOMString &s)
+{
+ const char *begin = s.c_str();
+ char *end;
+ double val = strtod(begin, &end);
+ if (end <= begin)
+ return 0.0;
+ return val;
+}
+
+
/*#########################################################################
## Element type lookup table
#########################################################################*/
#########################################################################*/
+/**
+ * Retrieves an attribute value by name.
+ */
+DOMString SVGSVGElementImpl::getAttribute(const DOMString& name)
+{
+ DOMString s;
+ if (name == "x")
+ s = d2s(x.getAnimVal().getValue());
+ else if (name == "y")
+ s = d2s(y.getAnimVal().getValue());
+ else
+ s = SVGElement::getAttribute(name);
+ return s;
+}
+
+/**
+ * Sets an attribute value
+ */
+void SVGSVGElementImpl::setAttribute(const DOMString& name,
+ const DOMString& value)
+ throw(DOMException)
+{
+ if (name == "x")
+ x.getAnimVal().setValue(s2d(value));
+ else if (name == "y")
+ y.getAnimVal().setValue(s2d(value));
+ SVGElement::setAttribute(name, value);
+}
+
+
/**
*
*/
diff --git a/src/dom/svgimpl.h b/src/dom/svgimpl.h
index 701952b0bfbe9326c3591082605861d23b92f43e..4258de58ec58ed1f8200e406638f5465f7a02dba 100644 (file)
--- a/src/dom/svgimpl.h
+++ b/src/dom/svgimpl.h
{
public:
+ /**
+ * Retrieves an attribute value by name.
+ */
+ virtual DOMString getAttribute(const DOMString& name);
+
+ /**
+ * Sets an attribute value
+ */
+ virtual void setAttribute(const DOMString& name,
+ const DOMString& value)
+ throw(DOMException);
+
/**
*
*/