[gnumeric] fix print flag roundtrip for charts



commit e66813749b6c3749988cdd6a0d1288859838d218
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Fri May 8 22:13:44 2020 -0600

    fix print flag roundtrip for charts
    
    2020-05-08  Andreas J. Guelzow <aguelzow pyrshep ca>
    
            * openoffice-read.c (od_draw_frame_start): read style_name
            (od_draw_frame_end_full): apply properties from style
            * openoffice-write.c (odf_write_graph): write style name

 plugins/openoffice/ChangeLog          |  6 ++++++
 plugins/openoffice/openoffice-read.c  | 15 ++++++++++++++-
 plugins/openoffice/openoffice-write.c |  4 ++++
 3 files changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 18b4003a2..5a1ff9d36 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-08  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (od_draw_frame_start): read style_name
+       (od_draw_frame_end_full): apply properties from style
+       * openoffice-write.c (odf_write_graph): write style name
+
 2020-05-08  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-read.c (odf_so_set_props): new
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 9e3a2a537..41fee4d11 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -232,6 +232,7 @@ typedef struct {
        SheetObject     *so;
        GSList          *list; /* used by Stock plot and textbox*/
        char            *name;
+       char            *style_name;
 
        /* set in plot-area */
        GogPlot         *plot;
@@ -8154,6 +8155,7 @@ od_draw_frame_start (GsfXMLIn *xin, xmlChar const **attrs)
        int last_col = gnm_sheet_get_last_col (state->pos.sheet);
 
        state->chart.name = NULL;
+       state->chart.style_name = NULL;
 
        height = width = x = y = 0.;
        for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2){
@@ -8182,6 +8184,8 @@ od_draw_frame_start (GsfXMLIn *xin, xmlChar const **attrs)
                        ;
                else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_DRAW, "name"))
                        state->chart.name = g_strdup (CXML2C (attrs[1]));
+               else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_DRAW, "style-name"))
+                       state->chart.style_name = g_strdup (CXML2C (attrs[1]));
        }
 
        frame_offset[0] = x;
@@ -8254,11 +8258,18 @@ od_draw_frame_end_full (GsfXMLIn *xin, gboolean absolute_distance, char const *c
                state->chart_list = g_slist_prepend ( state->chart_list, ob_off);
                if (state->chart.name)
                        sheet_object_set_name (state->chart.so, state->chart.name);
-
+               if (state->chart.style_name) {
+                       OOChartStyle *oostyle = g_hash_table_lookup
+                               (state->chart.graph_styles, state->chart.style_name);
+                       if (oostyle != NULL)
+                               odf_so_set_props (state, oostyle);
+               }
                state->chart.so = NULL;
        }
        g_free (state->chart.name);
        state->chart.name = NULL;
+       g_free (state->chart.style_name);
+       state->chart.style_name = NULL;
 }
 
 static void
@@ -13823,6 +13834,8 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
        state.cell_comment      = NULL;
        state.sharer = gnm_expr_sharer_new ();
        state.chart.name = NULL;
+       state.chart.style_name = NULL;
+
        state.chart.cs_enhanced_path = NULL;
        state.chart.cs_modifiers = NULL;
        state.chart.cs_viewbox = NULL;
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index e1434c794..ec85cb6c6 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -2983,6 +2983,8 @@ static void
 odf_write_graph (GnmOOExport *state, SheetObject *so, char const *name)
 {
        GnmParsePos pp;
+       gchar const *style_name = g_hash_table_lookup (state->so_styles, so);
+
        parse_pos_init_sheet (&pp, state->sheet);
 
        if (name != NULL) {
@@ -3003,6 +3005,8 @@ odf_write_graph (GnmOOExport *state, SheetObject *so, char const *name)
                        while  (l) {
                                char *full_name = g_strdup_printf ("%s-%i/", name, i);
                                gsf_xml_out_start_element (state->xml, DRAW "frame");
+                               if (style_name != NULL)
+                                       gsf_xml_out_add_cstr (state->xml, DRAW "style-name", style_name);
                                if (multichart)
                                        odf_write_multi_chart_frame_size (state, so, GOG_OBJECT (l->data),
                                                                          total_rows, total_columns);


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