[gnumeric] ods: improve marker colours import/export.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ods: improve marker colours import/export.
- Date: Wed, 14 May 2014 18:01:37 +0000 (UTC)
commit d47c27fca847e599ff8d7b41cb45f0ebaa7a8981
Author: Morten Welinder <terra gnome org>
Date: Wed May 14 14:01:09 2014 -0400
ods: improve marker colours import/export.
plugins/openoffice/ChangeLog | 8 ++++++++
plugins/openoffice/openoffice-read.c | 20 ++++++++++++++++----
plugins/openoffice/openoffice-write.c | 26 ++++++++++++++++++++------
test/ChangeLog | 4 ++++
test/t6516-graph.pl | 6 +++---
5 files changed, 51 insertions(+), 13 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 81b5af8..864d770 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,11 @@
+2014-05-14 Morten Welinder <terra gnome org>
+
+ * openoffice-read.c (odf_apply_style_props): Set marker's colours
+ too.
+
+ * openoffice-write.c (odf_write_gog_style_graphic): Use marker's
+ colour if we don't have a line.
+
2014-05-12 Morten Welinder <terra gnome org>
* openoffice-write.c (odf_write_gog_style_graphic): Improve
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index c94bb29..ac46093 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -957,10 +957,14 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style)
else
pango_font_description_free (desc);
- if (gnm_auto_color_value_set)
- style->line.auto_color = gnm_auto_color_value;
- else if (lines_value_set && !stroke_colour_set)
- style->line.auto_color = lines_value;
+ /*
+ * Stroke colour is tricky: if we have lines, that is what it
+ * refers to. Otherwise it refers to markers.
+ */
+ if (!gnm_auto_color_value_set)
+ gnm_auto_color_value = !stroke_colour_set;
+
+ style->line.auto_color = (lines_value ? gnm_auto_color_value : TRUE);
if (gnm_stroke_width >= 0)
style->line.width = gnm_stroke_width;
@@ -1106,6 +1110,14 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style)
break;
}
if (m) {
+ if (symbol_type != OO_SYMBOL_TYPE_NONE) {
+ /* Inherit line colour. */
+ go_marker_set_fill_color (m, style->line.color);
+ style->marker.auto_fill_color = gnm_auto_color_value;
+ go_marker_set_outline_color (m, style->line.color);
+ style->marker.auto_outline_color = gnm_auto_color_value;
+ }
+
if (symbol_height >= 0. || symbol_width >= 0.) {
double size;
/* If we have only one dimension, use that for the other */
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 23a7edd..2dc6a82 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -7169,8 +7169,11 @@ odf_write_gog_style_graphic (GnmOOExport *state, GOStyle const *style, gboolean
if (style->interesting_fields & (GO_STYLE_LINE | GO_STYLE_OUTLINE)) {
GOLineDashType dash_type = style->line.dash_type;
+ gboolean has_line = go_style_is_line_visible (style);
+ gboolean is_auto;
+ GOColor color;
- if (!go_style_is_line_visible (style))
+ if (!has_line)
gsf_xml_out_add_cstr (state->xml,
DRAW "stroke", "none");
else if (dash_type == GO_LINE_SOLID)
@@ -7198,11 +7201,22 @@ odf_write_gog_style_graphic (GnmOOExport *state, GOStyle const *style, gboolean
} else if (style->line.width > 0.0)
odf_add_pt (state->xml, SVG "stroke-width",
style->line.width);
- if (!style->line.auto_color) {
- char *color = odf_go_color_to_string (style->line.color);
- gsf_xml_out_add_cstr (state->xml, SVG "stroke-color",
- color);
- g_free (color);
+
+ /*
+ * ods doesn't have seperate colours for the marker, so use
+ * the marker colour if we don't have a line.
+ */
+ is_auto = style->line.auto_color;
+ color = style->line.color;
+ if (!has_line && (style->interesting_fields & GO_STYLE_MARKER)) {
+ is_auto = style->marker.auto_fill_color;
+ color = go_marker_get_fill_color (style->marker.mark);
+ }
+
+ if (!is_auto) {
+ char *s = odf_go_color_to_string (color);
+ gsf_xml_out_add_cstr (state->xml, SVG "stroke-color", s);
+ g_free (s);
} else if (state->with_extension)
odf_add_bool (state->xml, GNMSTYLE "auto-color", TRUE);
} else {
diff --git a/test/ChangeLog b/test/ChangeLog
index 8b021fc..053986d 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2014-05-14 Morten Welinder <terra gnome org>
+
+ * t6516-graph.pl: Ignore ods differences for outline colour.
+
2014-04-30 Morten Welinder <terra gnome org>
* Release 1.12.15
diff --git a/test/t6516-graph.pl b/test/t6516-graph.pl
index a56805b..59fd9dd 100755
--- a/test/t6516-graph.pl
+++ b/test/t6516-graph.pl
@@ -13,14 +13,14 @@ my $file = "$samples/graph-tests.gnumeric";
'ext' => "gnm",
'ignore_failure' => 1);
-# my $ods_auto_filter = "$PERL -p -e 's{auto-dash=\"1\"}{auto-dash=\"0\" dash=\"solid\"}'";
+# ods doesn't have outline colour, so copy the fill colour.
+my $ods_outline_filter = "$PERL -p -e 'if (/\\bmarker\\b.*fill-color=\"([A-Z0-9:]+)\"/) { my \$col = \$1;
s{\\b(outline-color)=\"[A-Z0-9:]+\"}{\$1=\"\$col\"}; }'";
&message ("Check graph ods roundtrip.");
&test_roundtrip ($file,
'format' => 'Gnumeric_OpenCalc:odf',
'ext' => "ods",
-# 'filter1' => $ods_auto_filter,
-# 'filter2' => "$ods_auto_filter | $PERL -p -e '\$_ = \"\" if m{<meta:generator>}'",
+ 'filter1' => $ods_outline_filter,
'filter2' => "$PERL -p -e '\$_ = \"\" if m{<meta:generator>}'",
'ignore_failure' => 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]