summaryrefslogtreecommitdiffstats
path: root/src/dom/svgimpl.cpp
diff options
context:
space:
mode:
authorBob Jamison <ishmalius@gmail.com>2008-06-04 21:21:15 +0000
committerishmal <ishmal@users.sourceforge.net>2008-06-04 21:21:15 +0000
commit40f279b15a6d05fb7d7e7d22f517a68df28038f4 (patch)
treeb0929a4041c1bd17d6006362f1ea8471c0a088e6 /src/dom/svgimpl.cpp
parentimprove piping (diff)
downloadinkscape-40f279b15a6d05fb7d7e7d22f517a68df28038f4.tar.gz
inkscape-40f279b15a6d05fb7d7e7d22f517a68df28038f4.zip
first try at attribute overloading
(bzr r5808)
Diffstat (limited to 'src/dom/svgimpl.cpp')
-rw-r--r--src/dom/svgimpl.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/dom/svgimpl.cpp b/src/dom/svgimpl.cpp
index d2a7e2794..6b2a7fe70 100644
--- a/src/dom/svgimpl.cpp
+++ b/src/dom/svgimpl.cpp
@@ -46,6 +46,29 @@ namespace svg
/*#########################################################################
+## 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
#########################################################################*/
@@ -668,6 +691,36 @@ void SVGDocumentImpl::init()
/**
+ * 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);
+}
+
+
+/**
*
*/
unsigned long SVGSVGElementImpl::suspendRedraw(unsigned long /*max_wait_milliseconds*/ )