[gnumeric] ODF: import/export stroke width



commit 0eb0e2160397162e628dfdd7f4c9f6f292428e9e
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Aug 31 13:09:15 2010 -0600

    ODF: import/export stroke width
    
    2010-08-31  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (odf_apply_style_props): new attribute stroke-width
    	(oo_hatch): use gnm_float, not double
    	(oo_prop_new_float): rename to oo_prop_new_double and change all callers
    	(od_style_prop_chart): handle stroke-width
    	* openoffice-write.c (odf_write_gog_style_graphic): write stroke-width

 plugins/openoffice/ChangeLog          |    8 ++++++++
 plugins/openoffice/openoffice-read.c  |   30 +++++++++++++++++++-----------
 plugins/openoffice/openoffice-write.c |   11 ++++++++---
 3 files changed, 35 insertions(+), 14 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 51c12ee..21597fe 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,13 @@
 2010-08-31  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (odf_apply_style_props): new attribute stroke-width
+	(oo_hatch): use gnm_float, not double
+	(oo_prop_new_float): rename to oo_prop_new_double and change all callers
+	(od_style_prop_chart): handle stroke-width
+	* openoffice-write.c (odf_write_gog_style_graphic): write stroke-width
+	
+2010-08-31  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (odf_apply_style_props): don't use gnm-fore-color,
 	  use the stored hatch description
 	(oo_parse_angle): new
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index b28d6fa..62a6589 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -647,6 +647,8 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style)
 			symbol_type = g_value_get_int (&prop->value);
 		else if (0 == strcmp (prop->name, "symbol-name"))
 			symbol_name = g_value_get_int (&prop->value);
+		else if (0 == strcmp (prop->name, "stroke-width"))
+		        style->line.width = g_value_get_double (&prop->value);
 	}
 	if (desc_changed)
 		go_style_set_font_desc	(style, desc);
@@ -1886,7 +1888,7 @@ oo_hatch (GsfXMLIn *xin, xmlChar const **attrs)
 	OOParseState *state = (OOParseState *)xin->user_state;
 	GOPattern *hatch = g_new (GOPattern, 1);
 	char const *hatch_name = NULL;
-	double distance = -1.0;
+	gnm_float distance = -1.0;
 	int angle = 0;
 	char const *style = NULL;
 
@@ -3462,7 +3464,7 @@ oo_style_map (GsfXMLIn *xin, xmlChar const **attrs)
 }
 
 static OOProp *
-oo_prop_new_float (char const *name, gnm_float val)
+oo_prop_new_double (char const *name, gnm_float val)
 {
 	OOProp *res = g_new0 (OOProp, 1);
 	res->name = name;
@@ -3692,31 +3694,31 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 		} else if (oo_attr_float (xin, attrs, OO_NS_CHART, 
 					  "minimum", &ftmp)) {
 			style->axis_props = g_slist_prepend (style->axis_props,
-				oo_prop_new_float ("minimum", ftmp));
+				oo_prop_new_double ("minimum", ftmp));
 		} else if (oo_attr_float (xin, attrs, OO_NS_CHART, 
 					  "maximum", &ftmp)) {
 			style->axis_props = g_slist_prepend (style->axis_props,
-				oo_prop_new_float ("maximum", ftmp));
+				oo_prop_new_double ("maximum", ftmp));
 		} else if (oo_attr_float (xin, attrs, OO_GNUM_NS_EXT, 
 					  "radius-ratio", &ftmp)) {
 			style->plot_props = g_slist_prepend (style->plot_props,
-				oo_prop_new_float ("radius-ratio", ftmp));
+				oo_prop_new_double ("radius-ratio", ftmp));
 		} else if (oo_attr_percent (xin, attrs, OO_GNUM_NS_EXT, 
 					    "default-separation", &ftmp)) {
 			style->plot_props = g_slist_prepend (style->plot_props,
-				oo_prop_new_float ("default-separation", ftmp));
+				oo_prop_new_double ("default-separation", ftmp));
 		} else if (oo_attr_int_range (xin, attrs, OO_NS_CHART, 
 					      "pie-offset", &tmp, 0, 500)) {
 			style->plot_props = g_slist_prepend (style->plot_props,
-				oo_prop_new_float ("default-separation", 
+				oo_prop_new_double ("default-separation", 
 						   tmp/100.));
 			style->plot_props = g_slist_prepend (style->plot_props,
-				oo_prop_new_float ("separation", 
+				oo_prop_new_double ("separation", 
 						   tmp/100.));
 		} else if (oo_attr_percent (xin, attrs, OO_NS_CHART, 
 					    "hole-size", &ftmp)) {
 			style->plot_props = g_slist_prepend (style->plot_props,
-				oo_prop_new_float ("center-size", ftmp));
+				oo_prop_new_double ("center-size", ftmp));
 		} else if (oo_attr_bool (xin, attrs, OO_NS_CHART, 
 					 "reverse-direction", &btmp)) {
 			style->axis_props = g_slist_prepend (style->axis_props,
@@ -3793,7 +3795,13 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 				(style->style_props,
 				 oo_prop_new_string ("stroke-dash",
 						     CXML2C(attrs[1])));
-		} else if (oo_attr_bool (xin, attrs, OO_NS_CHART, "lines", &btmp)) {
+		} else if (NULL != oo_attr_distance (xin, attrs, OO_NS_SVG, 
+						     "stroke-width", &ftmp))
+			style->style_props = g_slist_prepend
+				(style->style_props,
+				 oo_prop_new_double ("stroke-width",
+						    ftmp));
+		else if (oo_attr_bool (xin, attrs, OO_NS_CHART, "lines", &btmp)) {
 			style->style_props = g_slist_prepend
 				(style->style_props,
 				 oo_prop_new_bool ("lines", btmp));
@@ -3841,7 +3849,7 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
 		} else if (NULL != oo_attr_distance (xin, attrs, OO_NS_FO, "font-size", &ftmp))
 			style->style_props = g_slist_prepend
 				(style->style_props,
-				 oo_prop_new_float ("font-size", ftmp));
+				 oo_prop_new_double ("font-size", ftmp));
 		else if (oo_attr_font_weight (xin, attrs, &tmp))
 			style->style_props = g_slist_prepend
 				(style->style_props,
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 28ec7b6..05af5fe 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4475,6 +4475,7 @@ odf_write_gog_style_graphic (GnmOOExport *state, GOStyle const *style)
 {
 	if (style != NULL) {
 		char *color;
+
 		switch (style->fill.type) {
 		case GO_STYLE_FILL_NONE:
 			gsf_xml_out_add_cstr (state->xml, DRAW "fill", "none");
@@ -4507,16 +4508,16 @@ odf_write_gog_style_graphic (GnmOOExport *state, GOStyle const *style)
 			break;
 		case GO_STYLE_FILL_GRADIENT:
 			gsf_xml_out_add_cstr (state->xml, DRAW "fill", "none");
-/* 			gsf_xml_out_add_cstr (state->xml, DRAW "fill", "gradient"); */
+			/* 			gsf_xml_out_add_cstr (state->xml, DRAW "fill", "gradient"); */
 			break;
 		case GO_STYLE_FILL_IMAGE:
 			gsf_xml_out_add_cstr (state->xml, DRAW "fill", "none");
-/* 			gsf_xml_out_add_cstr (state->xml, DRAW "fill", "bitmap"); */
+			/* 			gsf_xml_out_add_cstr (state->xml, DRAW "fill", "bitmap"); */
 			break;
 		}
 		if (go_style_is_line_visible (style)) {
 			GOLineDashType dash_type = style->line.dash_type;
-			
+				
 			if (dash_type == GO_LINE_SOLID)
 				gsf_xml_out_add_cstr (state->xml, 
 						      DRAW "stroke", "solid");
@@ -4530,6 +4531,10 @@ odf_write_gog_style_graphic (GnmOOExport *state, GOStyle const *style)
 				g_hash_table_insert (state->graph_dashes, g_strdup (dash), 
 						     GINT_TO_POINTER (dash_type));
 			}
+			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);
 		} 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]