[dia] svg: support 'color' attribute and 'currentColor' value at import



commit 85ea964b0b58255b549b7683937e4d11f0be9ae2
Author: Hans Breuer <hans breuer org>
Date:   Sun Dec 22 12:13:45 2013 +0100

    svg: support 'color' attribute and 'currentColor' value at import
    
    It was just too easy to make the test suite test fail on it.

 lib/dia_svg.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/lib/dia_svg.c b/lib/dia_svg.c
index d248341..e3a5106 100644
--- a/lib/dia_svg.c
+++ b/lib/dia_svg.c
@@ -38,11 +38,16 @@
  * The Dia application supports various variants of SVG. There are
  * at least two importers of SVG dialects, namely \ref Shapes and
  * the standard SVG importer \ref Plugins. Both are using theses
- * serivces to a large extend, but they are also doing there own
+ * services to a large extend, but they are also doing there own
  * thing regarding the SVG dialect interpretation.
  */
 
 /*!
+ * A global variable to be accessed by "currentColor"
+ */
+static int _current_color = 0xFF000000;
+
+/*!
  * \brief Initialize a style object from another style object or defaults.
  * @param gs An SVG style object to initialize.
  * @param parent_style An SVG style object to copy values from, or NULL,
@@ -329,6 +334,8 @@ _parse_color(gint32 *color, const char *str)
     *color = DIA_SVG_COLOUR_BACKGROUND;
   else if (0 == strcmp(str, "text"))
     *color = DIA_SVG_COLOUR_TEXT;
+  else if (0 == strcmp(str, "currentColor"))
+    *color = _current_color;
   else if (0 == strncmp(str, "rgb(", 4)) {
     int r = 0, g = 0, b = 0;
     if (3 == sscanf (str+4, "%d,%d,%d", &r, &g, &b)) {
@@ -735,6 +742,13 @@ dia_svg_parse_style(xmlNodePtr node, DiaSvgStyle *s, real user_scale)
   /* ugly svg variations, it is allowed to give style properties without
    * the style attribute, i.e. direct attributes
    */
+  str = xmlGetProp(node, (const xmlChar *)"color");
+  if (str) {
+    int c;
+    if (_parse_color (&c, (char *) str))
+      _current_color = c;
+    xmlFree(str);
+  }
   str = xmlGetProp(node, (const xmlChar *)"opacity");
   if (str) {
     real opacity = g_ascii_strtod((char *) str, NULL);
@@ -753,7 +767,7 @@ dia_svg_parse_style(xmlNodePtr node, DiaSvgStyle *s, real user_scale)
   if (str) {
     s->fill_opacity = g_ascii_strtod((char *) str, NULL);
     xmlFree(str);
-  }  
+  }
   str = xmlGetProp(node, (const xmlChar *)"stroke");
   if (str) {
     if (!_parse_color (&s->stroke, (char *) str) && strcmp ((const char *) str, "inherit") != 0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]