[gnumeric] ODF: import/export stroke colour



commit b8d5729e462516ef6d8b91ef785386ab950b8e7c
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri Sep 3 13:41:55 2010 -0600

    ODF: import/export stroke colour
    
    2010-09-03  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (odf_apply_style_props): stroke-color attribute
    	  added
    	(od_style_prop_chart): ditto
    	* openoffice-write.c (odf_write_gog_style_graphic): write stroke-color
    	  attribute

 plugins/openoffice/ChangeLog          |    8 ++++++++
 plugins/openoffice/openoffice-read.c  |   24 +++++++++++++++++++++---
 plugins/openoffice/openoffice-write.c |    9 ++++++++-
 3 files changed, 37 insertions(+), 4 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index c5fc4da..930c73a 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,13 @@
 2010-09-03  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (odf_apply_style_props): stroke-color attribute 
+	  added
+	(od_style_prop_chart): ditto
+	* openoffice-write.c (odf_write_gog_style_graphic): write stroke-color 
+	  attribute
+
+2010-09-03  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (od_draw_image): don't assume that we know the
 	  directory name
 	(opendoc_content_dtd): OOo's images contain a blank <text:p\> element
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index cb7d0a4..67fcb6e 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -598,6 +598,7 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style)
 	GOMarker *m;
 	gboolean line_is_not_dash = FALSE;
 	unsigned int fill_type = OO_FILL_TYPE_UNKNOWN;
+	gboolean stroke_colour_set = FALSE;
 
 	desc = pango_font_description_copy (style->font.font->desc);
 	for (l = props; l != NULL; l = l->next) {
@@ -633,7 +634,20 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style)
 				style->fill.pattern.back = GO_COLOR_FROM_GDK (gdk_color);
 				style->fill.auto_back = FALSE;
 			}
-		} else if (0 == strcmp (prop->name, "fill-gradient-name"))
+		} else if (0 == strcmp (prop->name, "stroke-color")) {
+			GdkColor gdk_color;
+			gchar const *color = g_value_get_string (&prop->value);
+			if (gdk_color_parse (color, &gdk_color)) {
+				style->line.color = GO_COLOR_FROM_GDK (gdk_color);
+				style->line.fore = GO_COLOR_FROM_GDK (gdk_color);
+				style->line.auto_color = FALSE;
+				style->line.auto_fore = FALSE;
+				style->line.pattern = GO_PATTERN_SOLID;
+				stroke_colour_set = TRUE;
+			}
+		} else if (0 == strcmp (prop->name, "lines") && !stroke_colour_set) {
+			style->line.auto_color = g_value_get_boolean (&prop->value);
+ 		} else if (0 == strcmp (prop->name, "fill-gradient-name"))
 			gradient_name = g_value_get_string (&prop->value);
 		else if (0 == strcmp (prop->name, "fill-hatch-name"))
 			hatch_name = g_value_get_string (&prop->value);
@@ -673,8 +687,6 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style)
 			pango_font_description_set_family
 				(desc, g_value_get_string (&prop->value));
 			desc_changed = TRUE;
-		} else if (0 == strcmp (prop->name, "lines")) {
-			style->line.auto_color = g_value_get_boolean (&prop->value);
 		} else if (0 == strcmp (prop->name, "stroke")) {
 			if (0 == strcmp (g_value_get_string (&prop->value), "solid")) {
 				style->line.dash_type = GO_LINE_SOLID;
@@ -4110,6 +4122,12 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 				(style->style_props,
 				 oo_prop_new_string ("stroke-dash",
 						     CXML2C(attrs[1])));
+		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), 
+					       OO_NS_SVG, "stroke-color")) {
+			style->style_props = g_slist_prepend
+				(style->style_props,
+				 oo_prop_new_string ("stroke-color",
+						     CXML2C(attrs[1])));
 		} else if (NULL != oo_attr_distance (xin, attrs, OO_NS_SVG, 
 						     "stroke-width", &ftmp))
 			style->style_props = g_slist_prepend
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 393e9f9..f6327d9 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4705,7 +4705,14 @@ odf_write_gog_style_graphic (GnmOOExport *state, GOStyle const *style)
 			if (style->line.width == 0.0)
 				odf_add_pt (state->xml, SVG "stroke-width", 1.);
 			else if (style->line.width > 0.0)
-				odf_add_pt (state->xml, SVG "stroke-width", style->line.width);
+				odf_add_pt (state->xml, SVG "stroke-width", 
+					    style->line.width);
+			if (!style->line.auto_color) {
+				color = odf_go_color_to_string (style->line.color);
+				gsf_xml_out_add_cstr (state->xml, SVG "stroke-color", 
+						      color);
+	
+			}
 		} else {
 			gsf_xml_out_add_cstr (state->xml, DRAW "stroke", "none");
 		}



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