[gnumeric] Improve chart roundtrip through ODF. [#728197]



commit 7315386e782fee91dcae182fe6173b8833959d54
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Fri Apr 18 17:53:59 2014 -0600

    Improve chart roundtrip through ODF. [#728197]
    
    2014-04-18  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (odf_apply_style_props): handle auto-dash and
        auto-color extensions; do not depend on order of attributes
        * openoffice-write.c (odf_write_gog_style_graphic): writeauto-dash
        and auto-color extensions

 plugins/openoffice/ChangeLog          |    7 ++++
 plugins/openoffice/openoffice-read.c  |   50 ++++++++++++++++++++++++++------
 plugins/openoffice/openoffice-write.c |    6 ++-
 test/t6516-graph.pl                   |    7 ++--
 4 files changed, 55 insertions(+), 15 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index af9b563..3f0a1c2 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,12 @@
 2014-04-18  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+       * openoffice-read.c (odf_apply_style_props): handle auto-dash and
+       auto-color extensions; do not depend on order of attributes
+       * openoffice-write.c (odf_write_gog_style_graphic): writeauto-dash
+       and auto-color extensions
+
+2014-04-18  Andreas J. Guelzow <aguelzow pyrshep ca>
+
        * openoffice-read.c (oo_parse_spec_distance): new
        (oo_parse_distance): use oo_parse_spec_distance
        (od_style_prop_chart): read fo:border
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 5609e6e..56085da 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -799,6 +799,14 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style)
        gboolean line_is_not_dash = FALSE;
        unsigned int fill_type = OO_FILL_TYPE_UNKNOWN;
        gboolean stroke_colour_set = FALSE;
+       gboolean lines_value_set = FALSE;
+       gboolean lines_value = FALSE;
+       gboolean gnm_auto_color_value_set = FALSE;
+       gboolean gnm_auto_color_value = FALSE;
+       gboolean gnm_auto_dash_set = FALSE;
+       char const *stroke_dash = NULL;
+
+       style->line.auto_dash = TRUE;
 
        desc = pango_font_description_copy (style->font.font->desc);
        for (l = props; l != NULL; l = l->next) {
@@ -849,8 +857,15 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style)
                                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, "lines")) {
+                       lines_value_set = TRUE;
+                       lines_value = g_value_get_boolean (&prop->value);
+               } else if (0 == strcmp (prop->name, "gnm-auto-color")) {
+                       gnm_auto_color_value_set = TRUE;
+                       gnm_auto_color_value = g_value_get_boolean (&prop->value);
+               } else if (0 == strcmp (prop->name, "gnm-auto-dash")) {
+                       gnm_auto_dash_set = TRUE;
+                       style->line.auto_dash = 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"))
@@ -896,20 +911,22 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style)
                } else if (0 == strcmp (prop->name, "stroke")) {
                        if (0 == strcmp (g_value_get_string (&prop->value), "solid")) {
                                style->line.dash_type = GO_LINE_SOLID;
-                               style->line.auto_dash = FALSE;
+                               if (!gnm_auto_dash_set)
+                                       style->line.auto_dash = FALSE;
                                line_is_not_dash = TRUE;
                        } else if (0 == strcmp (g_value_get_string (&prop->value), "dash")) {
-                               style->line.auto_dash = FALSE;
+                               if (!gnm_auto_dash_set)
+                                       style->line.auto_dash = FALSE;
                                line_is_not_dash = FALSE;
                        } else {
                                style->line.dash_type = GO_LINE_NONE;
-                               style->line.auto_dash = FALSE;
+                               if (!gnm_auto_dash_set)
+                                       style->line.auto_dash = FALSE;
                                line_is_not_dash = TRUE;
                        }
-               } else if (0 == strcmp (prop->name, "stroke-dash") && !line_is_not_dash) {
-                       style->line.dash_type = odf_match_dash_type
-                               (state, g_value_get_string (&prop->value));
-               } else if (0 == strcmp (prop->name, "symbol-type"))
+               } else if (0 == strcmp (prop->name, "stroke-dash"))
+                       stroke_dash = g_value_get_string (&prop->value);
+               else if (0 == strcmp (prop->name, "symbol-type"))
                        symbol_type = g_value_get_int (&prop->value);
                else if (0 == strcmp (prop->name, "symbol-name"))
                        symbol_name = g_value_get_int (&prop->value);
@@ -929,6 +946,11 @@ 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;
+
        if (gnm_stroke_width >= 0)
                style->line.width = gnm_stroke_width;
        else if (stroke_width == 0.) {
@@ -938,7 +960,9 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style)
                style->line.width = stroke_width;
        else
                style->line.width = 0;
-               
+
+       if (stroke_dash != NULL && !line_is_not_dash)
+               style->line.dash_type = odf_match_dash_type (state, stroke_dash);
 
        switch (fill_type) {
        case OO_FILL_TYPE_HATCH:
@@ -7124,6 +7148,12 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
                                (style->other_props,
                                 oo_prop_new_string
                                 ("border", CXML2C(attrs[1])));
+               else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, "auto-color", &btmp))
+                       style->style_props = g_slist_prepend (style->style_props,
+                               oo_prop_new_bool ("gnm-auto-color", btmp));
+               else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, "auto-dash", &btmp))
+                       style->style_props = g_slist_prepend (style->style_props,
+                               oo_prop_new_bool ("gnm-auto-dash", btmp));
        }
 
        if ((stacked_set && !overlap_set) ||
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index fd350fe..5e487ed 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -7130,6 +7130,8 @@ odf_write_gog_style_graphic (GnmOOExport *state, GOStyle const *style, gboolean
                                g_hash_table_insert (state->graph_dashes, g_strdup (dash),
                                                     GINT_TO_POINTER (dash_type));
                        }
+                       if (style->line.auto_dash && state->with_extension)
+                               odf_add_bool (state->xml, GNMSTYLE "auto-dash", TRUE);
                        if (style->line.width == 0.0) {
                                odf_add_pt (state->xml, SVG "stroke-width", 1.);
                                if (state->with_extension)
@@ -7141,8 +7143,8 @@ odf_write_gog_style_graphic (GnmOOExport *state, GOStyle const *style, gboolean
                                color = odf_go_color_to_string (style->line.color);
                                gsf_xml_out_add_cstr (state->xml, SVG "stroke-color",
                                                      color);
-
-                       }
+                       } else if (state->with_extension)
+                               odf_add_bool (state->xml, GNMSTYLE "auto-color", TRUE);         
                } else {
                        gsf_xml_out_add_cstr (state->xml, DRAW "stroke", "none");
                }
diff --git a/test/t6516-graph.pl b/test/t6516-graph.pl
index 70b46ea..a56805b 100755
--- a/test/t6516-graph.pl
+++ b/test/t6516-graph.pl
@@ -13,14 +13,15 @@ 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\"}'";
+# my $ods_auto_filter = "$PERL -p -e 's{auto-dash=\"1\"}{auto-dash=\"0\" dash=\"solid\"}'";
 
 &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_auto_filter,
+#               'filter2' => "$ods_auto_filter | $PERL -p -e '\$_ = \"\" if m{<meta:generator>}'",
+                'filter2' => "$PERL -p -e '\$_ = \"\" if m{<meta:generator>}'",
                 'ignore_failure' => 1);
 
 my $xls_codepage_filter = "$PERL -p -e '\$_ = \"\" if m{<meta:user-defined meta:name=.msole:codepage.}'";


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