[gnumeric] diff engine: use a generic pointer for state information.



commit 3e2c2eb216902399878a95bbc230096885db57e9
Author: Morten Welinder <terra gnome org>
Date:   Sun Apr 8 13:31:03 2018 -0400

    diff engine: use a generic pointer for state information.

 src/sheet-diff.c |   68 ++++++++++++++++++++--------------------
 src/sheet-diff.h |   28 ++++++++---------
 src/ssdiff.c     |   91 ++++++++++++++++++++++++++++++++++-------------------
 3 files changed, 105 insertions(+), 82 deletions(-)
---
diff --git a/src/sheet-diff.c b/src/sheet-diff.c
index 0b3e3e5..ebad5b7 100644
--- a/src/sheet-diff.c
+++ b/src/sheet-diff.c
@@ -36,35 +36,35 @@
 /* ------------------------------------------------------------------------- */
 
 static gboolean
-null_diff_start (G_GNUC_UNUSED GnmDiffState *state)
+null_diff_start (G_GNUC_UNUSED gpointer user)
 {
        return FALSE;
 }
 
 static void
-null_diff_end (G_GNUC_UNUSED GnmDiffState *state)
+null_diff_end (G_GNUC_UNUSED gpointer user)
 {
 }
 
 static void
-null_sheet_start (G_GNUC_UNUSED GnmDiffState *state,
+null_sheet_start (G_GNUC_UNUSED gpointer user,
                  G_GNUC_UNUSED Sheet const *os,
                  G_GNUC_UNUSED Sheet const *ns)
 {
 }
 
 static void
-null_sheet_end (G_GNUC_UNUSED GnmDiffState *state)
+null_sheet_end (G_GNUC_UNUSED gpointer user)
 {
 }
 
 static void
-null_sheet_order_changed (G_GNUC_UNUSED GnmDiffState *state)
+null_sheet_order_changed (G_GNUC_UNUSED gpointer user)
 {
 }
 
 static void
-null_sheet_attr_int_changed (G_GNUC_UNUSED GnmDiffState *state,
+null_sheet_attr_int_changed (G_GNUC_UNUSED gpointer user,
                             G_GNUC_UNUSED const char *name,
                             G_GNUC_UNUSED int o,
                             G_GNUC_UNUSED int n)
@@ -72,27 +72,27 @@ null_sheet_attr_int_changed (G_GNUC_UNUSED GnmDiffState *state,
 }
 
 static void
-null_colrow_changed (G_GNUC_UNUSED GnmDiffState *state,
+null_colrow_changed (G_GNUC_UNUSED gpointer user,
                     G_GNUC_UNUSED ColRowInfo const *oc, G_GNUC_UNUSED ColRowInfo const *nc,
                     G_GNUC_UNUSED gboolean is_cols, G_GNUC_UNUSED int i)
 {
 }
 
 static void
-null_cell_changed (G_GNUC_UNUSED GnmDiffState *state,
+null_cell_changed (G_GNUC_UNUSED gpointer user,
                   G_GNUC_UNUSED GnmCell const *oc, GnmCell const *nc)
 {
 }
 
 static void
-null_style_changed (G_GNUC_UNUSED GnmDiffState *state,
+null_style_changed (G_GNUC_UNUSED gpointer user,
                    G_GNUC_UNUSED GnmRange const *r,
                    G_GNUC_UNUSED GnmStyle const *os, G_GNUC_UNUSED GnmStyle const *ns)
 {
 }
 
 static void
-null_name_changed (G_GNUC_UNUSED GnmDiffState *state,
+null_name_changed (G_GNUC_UNUSED gpointer user,
                   G_GNUC_UNUSED GnmNamedExpr const *on, G_GNUC_UNUSED GnmNamedExpr const *nn)
 {
 
@@ -103,7 +103,7 @@ null_name_changed (G_GNUC_UNUSED GnmDiffState *state,
 /* ------------------------------------------------------------------------- */
 
 typedef struct {
-       GnmDiffState *ustate;
+       gpointer user;
 
        const GnmDiffActions *actions;
        gboolean diff_found;
@@ -215,7 +215,7 @@ diff_sheets_cells (GnmDiffIState *istate)
                        else {
                                if (compare_corresponding_cells (co, cn)) {
                                        istate->diff_found = TRUE;
-                                       DISPATCH(cell_changed) (istate->ustate, co, cn);
+                                       DISPATCH(cell_changed) (istate->user, co, cn);
                                }
                                io++, in++;
                                continue;
@@ -224,11 +224,11 @@ diff_sheets_cells (GnmDiffIState *istate)
 
                if (co) {
                        istate->diff_found = TRUE;
-                       DISPATCH(cell_changed) (istate->ustate, co, NULL);
+                       DISPATCH(cell_changed) (istate->user, co, NULL);
                        io++;
                } else if (cn) {
                        istate->diff_found = TRUE;
-                       DISPATCH(cell_changed) (istate->ustate, NULL, cn);
+                       DISPATCH(cell_changed) (istate->user, NULL, cn);
                        in++;
                } else
                        break;
@@ -249,7 +249,7 @@ diff_sheets_colrow (GnmDiffIState *istate, gboolean is_cols)
 
        if (!colrow_equal (old_def, new_def)) {
                istate->diff_found = TRUE;
-               DISPATCH(colrow_changed) (istate->ustate, old_def, new_def, is_cols, -1);
+               DISPATCH(colrow_changed) (istate->user, old_def, new_def, is_cols, -1);
        }
 
        U = is_cols
@@ -267,7 +267,7 @@ diff_sheets_colrow (GnmDiffIState *istate, gboolean is_cols)
                if (!ncr) ncr = new_def;
                if (!colrow_equal (ocr, ncr)) {
                        istate->diff_found = TRUE;
-                       DISPATCH(colrow_changed) (istate->ustate, ocr, ncr, is_cols, i);
+                       DISPATCH(colrow_changed) (istate->user, ocr, ncr, is_cols, i);
                }
        }
 }
@@ -277,7 +277,7 @@ diff_sheets_colrow (GnmDiffIState *istate, gboolean is_cols)
          if (istate->old_sheet->field != istate->new_sheet->field) {   \
                  istate->diff_found = TRUE;                            \
                  DISPATCH(sheet_attr_int_changed)                      \
-                         (istate->ustate, attr, istate->old_sheet->field, istate->new_sheet->field); \
+                         (istate->user, attr, istate->old_sheet->field, istate->new_sheet->field); \
          }                                                             \
   } while (0)
 
@@ -290,12 +290,12 @@ diff_sheets_attrs (GnmDiffIState *istate)
        if (os->max_cols != ns->max_cols) {
                istate->diff_found = TRUE;
                DISPATCH(sheet_attr_int_changed)
-                       (istate->ustate, "Cols", os->max_cols, ns->max_cols);
+                       (istate->user, "Cols", os->max_cols, ns->max_cols);
        }
        if (os->max_rows != ns->max_rows) {
                istate->diff_found = TRUE;
                DISPATCH(sheet_attr_int_changed)
-                       (istate->ustate, "Rows", os->max_rows, ns->max_rows);
+                       (istate->user, "Rows", os->max_rows, ns->max_rows);
        }
 
        DO_INT (display_formulas, "DisplayFormulas");
@@ -331,7 +331,7 @@ cb_diff_sheets_styles_2 (G_GNUC_UNUSED gpointer key,
 
        istate->diff_found = TRUE;
 
-       DISPATCH(style_changed) (istate->ustate, &r, data->old_style, sr->style);
+       DISPATCH(style_changed) (istate->user, &r, data->old_style, sr->style);
 }
 
 static void
@@ -392,7 +392,7 @@ diff_names (GnmDiffIState *istate,
                if (!nn || (on && cb_expr_name_by_name (on, nn) < 0)) {
                        // Old name got removed
                        istate->diff_found = TRUE;
-                       DISPATCH(name_changed) (istate->ustate, on, nn);
+                       DISPATCH(name_changed) (istate->user, on, nn);
                        lo = lo->next;
                        continue;
                }
@@ -400,7 +400,7 @@ diff_names (GnmDiffIState *istate,
                if (!on || (nn && cb_expr_name_by_name (on, nn) > 0)) {
                        // New name got added
                        istate->diff_found = TRUE;
-                       DISPATCH(name_changed) (istate->ustate, on, nn);
+                       DISPATCH(name_changed) (istate->user, on, nn);
                        ln = ln->next;
                        continue;
                }
@@ -409,7 +409,7 @@ diff_names (GnmDiffIState *istate,
                                          nn->texpr, &nn->pos,
                                          convs)) {
                        istate->diff_found = TRUE;
-                       DISPATCH(name_changed) (istate->ustate, on, nn);
+                       DISPATCH(name_changed) (istate->user, on, nn);
                }
 
                lo = lo->next;
@@ -443,13 +443,13 @@ real_diff_sheets (GnmDiffIState *istate, Sheet *old_sheet, Sheet *new_sheet)
 }
 
 gboolean
-gnm_diff_sheets (const GnmDiffActions *actions, GnmDiffState *state,
+gnm_diff_sheets (const GnmDiffActions *actions, gpointer user,
                 Sheet *old_sheet, Sheet *new_sheet)
 {
        GnmDiffIState istate;
 
        memset (&istate, 0, sizeof (istate));
-       istate.ustate = state;
+       istate.user = user;
        istate.actions = actions;
        istate.diff_found = FALSE;
        istate.error = FALSE;
@@ -470,7 +470,7 @@ real_diff_workbooks (GnmDiffIState *istate,
        istate->old_wb = old_wb;
        istate->new_wb = new_wb;
 
-       if (DISPATCH(diff_start) (istate->ustate)) {
+       if (DISPATCH(diff_start) (istate->user)) {
                istate->error = TRUE;
                return;
        }
@@ -484,7 +484,7 @@ real_diff_workbooks (GnmDiffIState *istate,
                Sheet *old_sheet = workbook_sheet_by_index (old_wb, i);
                Sheet *new_sheet = workbook_sheet_by_name (new_wb,
                                                           old_sheet->name_unquoted);
-               DISPATCH(sheet_start) (istate->ustate, old_sheet, new_sheet);
+               DISPATCH(sheet_start) (istate->user, old_sheet, new_sheet);
 
                if (new_sheet) {
                        if (new_sheet->index_in_wb < last_index)
@@ -495,7 +495,7 @@ real_diff_workbooks (GnmDiffIState *istate,
                } else
                        istate->diff_found = TRUE;
 
-               DISPATCH(sheet_end) (istate->ustate);
+               DISPATCH(sheet_end) (istate->user);
        }
 
        count = workbook_sheet_count (new_wb);
@@ -507,27 +507,27 @@ real_diff_workbooks (GnmDiffIState *istate,
                        ; // Nothing -- already done above.
                else {
                        istate->diff_found = TRUE;
-                       DISPATCH(sheet_start) (istate->ustate, old_sheet, new_sheet);
-                       DISPATCH(sheet_end) (istate->ustate);
+                       DISPATCH(sheet_start) (istate->user, old_sheet, new_sheet);
+                       DISPATCH(sheet_end) (istate->user);
                }
        }
 
        if (sheet_order_changed) {
                istate->diff_found = TRUE;
-               DISPATCH(sheet_order_changed) (istate->ustate);
+               DISPATCH(sheet_order_changed) (istate->user);
        }
 
-       DISPATCH(diff_end) (istate->ustate);
+       DISPATCH(diff_end) (istate->user);
 }
 
 int
-gnm_diff_workbooks (const GnmDiffActions *actions, GnmDiffState *state,
+gnm_diff_workbooks (const GnmDiffActions *actions, gpointer user,
                    Workbook *old_wb, Workbook *new_wb)
 {
        GnmDiffIState istate;
 
        memset (&istate, 0, sizeof (istate));
-       istate.ustate = state;
+       istate.user = user;
        istate.actions = actions;
        istate.diff_found = FALSE;
        istate.error = FALSE;
diff --git a/src/sheet-diff.h b/src/sheet-diff.h
index 726accf..82328fc 100644
--- a/src/sheet-diff.h
+++ b/src/sheet-diff.h
@@ -5,66 +5,64 @@
 
 G_BEGIN_DECLS
 
-typedef struct GnmDiffState_ GnmDiffState;
-
 typedef struct {
        // Start comparison of two workbooks.
-       gboolean (*diff_start) (GnmDiffState *state);
+       gboolean (*diff_start) (gpointer user);
 
        // Finish comparison started with above.
-       void (*diff_end) (GnmDiffState *state);
+       void (*diff_end) (gpointer user);
 
        // Clean up allocations
        // This is not actually called by code here
-       void (*dtor) (GnmDiffState *state);
+       void (*dtor) (gpointer user);
 
        /* ------------------------------ */
 
        // Start looking at a sheet.  Either sheet might be NULL.
-       void (*sheet_start) (GnmDiffState *state,
+       void (*sheet_start) (gpointer user,
                             Sheet const *os, Sheet const *ns);
 
        // Finish sheet started with above.
-       void (*sheet_end) (GnmDiffState *state);
+       void (*sheet_end) (gpointer user);
 
        // The order of sheets has changed.
-       void (*sheet_order_changed) (GnmDiffState *state);
+       void (*sheet_order_changed) (gpointer user);
 
        // An integer attribute of the sheet has changed.
-       void (*sheet_attr_int_changed) (GnmDiffState *state, const char *name,
+       void (*sheet_attr_int_changed) (gpointer user, const char *name,
                                        int o, int n);
 
        /* ------------------------------ */
 
        // Column or Row information changed
-       void (*colrow_changed) (GnmDiffState *state,
+       void (*colrow_changed) (gpointer user,
                                ColRowInfo const *oc, ColRowInfo const *nc,
                                gboolean is_cols, int i);
 
        /* ------------------------------ */
 
        // A cell was changed/added/removed.
-       void (*cell_changed) (GnmDiffState *state,
+       void (*cell_changed) (gpointer user,
                              GnmCell const *oc, GnmCell const *nc);
 
        /* ------------------------------ */
 
        // The style of an area was changed.
-       void (*style_changed) (GnmDiffState *state, GnmRange const *r,
+       void (*style_changed) (gpointer user, GnmRange const *r,
                               GnmStyle const *os, GnmStyle const *ns);
 
        /* ------------------------------ */
 
        // A defined name was changed
-       void (*name_changed) (GnmDiffState *state,
+       void (*name_changed) (gpointer user,
                              GnmNamedExpr const *on, GnmNamedExpr const *nn);
 } GnmDiffActions;
 
 
-gboolean gnm_diff_sheets (const GnmDiffActions *actions, GnmDiffState *state,
+gboolean gnm_diff_sheets (const GnmDiffActions *actions, gpointer user,
                          Sheet *old_sheet, Sheet *new_sheet);
 
-int gnm_diff_workbooks (const GnmDiffActions *actions, GnmDiffState *state,
+int gnm_diff_workbooks (const GnmDiffActions *actions, gpointer user,
                        Workbook *old_wb, Workbook *new_wb);
 
 G_END_DECLS
diff --git a/src/ssdiff.c b/src/ssdiff.c
index 2205fd0..7e4e926 100644
--- a/src/ssdiff.c
+++ b/src/ssdiff.c
@@ -85,9 +85,9 @@ typedef struct {
        GsfInput *input;
        Workbook *wb;
        WorkbookView *wbv;
-}  GnmDiffStateFile;
+} GnmDiffStateFile;
 
-struct GnmDiffState_ {
+typedef struct {
        GOIOContext *ioc;
        GnmDiffStateFile old, new;
 
@@ -103,7 +103,7 @@ struct GnmDiffState_ {
        GnmDiffStateFile highlight;
        GOFileSaver const *highlight_fs;
        GnmStyle *highlight_style;
-};
+} DiffState;
 
 /* -------------------------------------------------------------------------- */
 
@@ -163,8 +163,9 @@ def_cell_name (GnmCell const *oc)
 }
 
 static void
-def_sheet_start (GnmDiffState *state, Sheet const *os, Sheet const *ns)
+def_sheet_start (gpointer user, Sheet const *os, Sheet const *ns)
 {
+       DiffState *state = user;
        if (os && ns)
                gsf_output_printf (state->output, _("Differences for sheet %s:\n"), os->name_quoted);
        else if (os)
@@ -176,23 +177,26 @@ def_sheet_start (GnmDiffState *state, Sheet const *os, Sheet const *ns)
 }
 
 static void
-def_sheet_order_changed (GnmDiffState *state)
+def_sheet_order_changed (gpointer user)
 {
+       DiffState *state = user;
        gsf_output_printf (state->output, _("Sheet order changed.\n"));
 }
 
 static void
-def_sheet_attr_int_changed (GnmDiffState *state, const char *name,
+def_sheet_attr_int_changed (gpointer user, const char *name,
                            G_GNUC_UNUSED int o, G_GNUC_UNUSED int n)
 {
+       DiffState *state = user;
        gsf_output_printf (state->output, _("Sheet attribute %s changed.\n"),
                           name);
 }
 
 static void
-def_colrow_changed (GnmDiffState *state, ColRowInfo const *oc, ColRowInfo const *nc,
+def_colrow_changed (gpointer user, ColRowInfo const *oc, ColRowInfo const *nc,
                    gboolean is_cols, int i)
 {
+       DiffState *state = user;
        if (is_cols)
                gsf_output_printf (state->output, _("Column %s changed.\n"),
                                   col_name (i));
@@ -202,8 +206,9 @@ def_colrow_changed (GnmDiffState *state, ColRowInfo const *oc, ColRowInfo const
 }
 
 static void
-def_cell_changed (GnmDiffState *state, GnmCell const *oc, GnmCell const *nc)
+def_cell_changed (gpointer user, GnmCell const *oc, GnmCell const *nc)
 {
+       DiffState *state = user;
        if (oc && nc)
                gsf_output_printf (state->output, _("Cell %s changed.\n"), def_cell_name (oc));
        else if (oc)
@@ -215,18 +220,20 @@ def_cell_changed (GnmDiffState *state, GnmCell const *oc, GnmCell const *nc)
 }
 
 static void
-def_style_changed (GnmDiffState *state, GnmRange const *r,
+def_style_changed (gpointer user, GnmRange const *r,
                   G_GNUC_UNUSED GnmStyle const *os,
                   G_GNUC_UNUSED GnmStyle const *ns)
 {
+       DiffState *state = user;
        gsf_output_printf (state->output, _("Style of %s was changed.\n"),
                           range_as_string (r));
 }
 
 static void
-def_name_changed (GnmDiffState *state,
+def_name_changed (gpointer user,
                  GnmNamedExpr const *on, GnmNamedExpr const *nn)
 {
+       DiffState *state = user;
        if (on && nn)
                gsf_output_printf (state->output, _("Name %s changed.\n"), expr_name_name (on));
        else if (on)
@@ -250,8 +257,9 @@ static const GnmDiffActions default_actions = {
 /* -------------------------------------------------------------------------- */
 
 static gboolean
-xml_diff_start (GnmDiffState *state)
+xml_diff_start (gpointer user)
 {
+       DiffState *state = user;
        char *attr;
 
        state->xml = gsf_xml_out_new (state->output);
@@ -267,14 +275,16 @@ xml_diff_start (GnmDiffState *state)
 }
 
 static void
-xml_diff_end (GnmDiffState *state)
+xml_diff_end (gpointer user)
 {
+       DiffState *state = user;
        gsf_xml_out_end_element (state->xml); /* </Diff> */
 }
 
 static void
-xml_dtor (GnmDiffState *state)
+xml_dtor (gpointer user)
 {
+       DiffState *state = user;
        g_clear_object (&state->xml);
 
        if (state->xml_convs) {
@@ -284,7 +294,7 @@ xml_dtor (GnmDiffState *state)
 }
 
 static void
-xml_close_section (GnmDiffState *state)
+xml_close_section (DiffState *state)
 {
        if (state->xml_section) {
                gsf_xml_out_end_element (state->xml);
@@ -293,7 +303,7 @@ xml_close_section (GnmDiffState *state)
 }
 
 static void
-xml_open_section (GnmDiffState *state, const char *section)
+xml_open_section (DiffState *state, const char *section)
 {
        if (state->xml_section && g_str_equal (section, state->xml_section))
                return;
@@ -304,8 +314,9 @@ xml_open_section (GnmDiffState *state, const char *section)
 }
 
 static void
-xml_sheet_start (GnmDiffState *state, Sheet const *os, Sheet const *ns)
+xml_sheet_start (gpointer user, Sheet const *os, Sheet const *ns)
 {
+       DiffState *state = user;
        Sheet const *sheet = os ? os : ns;
 
        // We might have an open section for global names
@@ -320,16 +331,18 @@ xml_sheet_start (GnmDiffState *state, Sheet const *os, Sheet const *ns)
 }
 
 static void
-xml_sheet_end (GnmDiffState *state)
+xml_sheet_end (gpointer user)
 {
+       DiffState *state = user;
        xml_close_section (state);
        gsf_xml_out_end_element (state->xml); /* </Sheet> */
 }
 
 static void
-xml_sheet_attr_int_changed (GnmDiffState *state, const char *name,
+xml_sheet_attr_int_changed (gpointer user, const char *name,
                            int o, int n)
 {
+       DiffState *state = user;
        char *elem;
 
        elem = g_strconcat (DIFF, name, NULL);
@@ -341,7 +354,7 @@ xml_sheet_attr_int_changed (GnmDiffState *state, const char *name,
 }
 
 static void
-xml_output_texpr (GnmDiffState *state, GnmExprTop const *texpr, GnmParsePos const *pos,
+xml_output_texpr (DiffState *state, GnmExprTop const *texpr, GnmParsePos const *pos,
                  const char *tag)
 {
        GnmConventionsOut out;
@@ -359,7 +372,7 @@ xml_output_texpr (GnmDiffState *state, GnmExprTop const *texpr, GnmParsePos cons
 }
 
 static void
-xml_output_cell (GnmDiffState *state, GnmCell const *cell,
+xml_output_cell (DiffState *state, GnmCell const *cell,
                 const char *tag, const char *valtag, const char *fmttag)
 {
        if (!cell)
@@ -382,9 +395,10 @@ xml_output_cell (GnmDiffState *state, GnmCell const *cell,
 }
 
 static void
-xml_colrow_changed (GnmDiffState *state, ColRowInfo const *oc, ColRowInfo const *nc,
+xml_colrow_changed (gpointer user, ColRowInfo const *oc, ColRowInfo const *nc,
                    gboolean is_cols, int i)
 {
+       DiffState *state = user;
        xml_open_section (state, is_cols ? DIFF "Cols" : DIFF "Rows");
 
        gsf_xml_out_start_element (state->xml, is_cols ? DIFF "ColInfo" : DIFF "RowInfo");
@@ -415,8 +429,9 @@ xml_colrow_changed (GnmDiffState *state, ColRowInfo const *oc, ColRowInfo const
 }
 
 static void
-xml_cell_changed (GnmDiffState *state, GnmCell const *oc, GnmCell const *nc)
+xml_cell_changed (gpointer user, GnmCell const *oc, GnmCell const *nc)
 {
+       DiffState *state = user;
        const GnmCellPos *pos;
 
        xml_open_section (state, DIFF "Cells");
@@ -490,9 +505,10 @@ cb_validation_use_dropdown (GnmValidation const *v)
 }
 
 static void
-xml_style_changed (GnmDiffState *state, GnmRange const *r,
+xml_style_changed (gpointer user, GnmRange const *r,
                   GnmStyle const *os, GnmStyle const *ns)
 {
+       DiffState *state = user;
        unsigned int conflicts;
        GnmStyleElement e;
 
@@ -712,9 +728,10 @@ xml_style_changed (GnmDiffState *state, GnmRange const *r,
 #undef DO_STRINGS
 
 static void
-xml_name_changed (GnmDiffState *state,
+xml_name_changed (gpointer user,
                  GnmNamedExpr const *on, GnmNamedExpr const *nn)
 {
+       DiffState *state = user;
        xml_open_section (state, DIFF "Names");
 
        gsf_xml_out_start_element (state->xml, DIFF "Name");
@@ -742,8 +759,9 @@ static const GnmDiffActions xml_actions = {
 /* -------------------------------------------------------------------------- */
 
 static gboolean
-highlight_diff_start (GnmDiffState *state)
+highlight_diff_start (gpointer user)
 {
+       DiffState *state = user;
        const char *dst = state->new.url;
 
        state->highlight_fs = go_file_saver_for_file_name (ssdiff_output);
@@ -771,15 +789,17 @@ highlight_diff_start (GnmDiffState *state)
 }
 
 static void
-highlight_diff_end (GnmDiffState *state)
+highlight_diff_end (gpointer user)
 {
+       DiffState *state = user;
        wbv_save_to_output (state->highlight.wbv, state->highlight_fs,
                            state->output, state->ioc);
 }
 
 static void
-highlight_dtor (GnmDiffState *state)
+highlight_dtor (gpointer user)
 {
+       DiffState *state = user;
        clear_file_state (&state->highlight);
        if (state->highlight_style) {
                gnm_style_unref (state->highlight_style);
@@ -788,9 +808,11 @@ highlight_dtor (GnmDiffState *state)
 }
 
 static void
-highlight_sheet_start (GnmDiffState *state,
+highlight_sheet_start (gpointer user,
                       G_GNUC_UNUSED Sheet const *os, Sheet const *ns)
 {
+       DiffState *state = user;
+
        // We want the highlight sheet corresponding to new_sheet.
        state->highlight_sheet = ns
                ? workbook_sheet_by_index (state->highlight.wb, ns->index_in_wb)
@@ -798,13 +820,14 @@ highlight_sheet_start (GnmDiffState *state,
 }
 
 static void
-highlight_sheet_end (GnmDiffState *state)
+highlight_sheet_end (gpointer user)
 {
+       DiffState *state = user;
        state->highlight_sheet = NULL;
 }
 
 static void
-highlight_apply (GnmDiffState *state, const GnmRange *r)
+highlight_apply (DiffState *state, const GnmRange *r)
 {
        Sheet *sheet = state->highlight_sheet;
 
@@ -815,18 +838,20 @@ highlight_apply (GnmDiffState *state, const GnmRange *r)
 }
 
 static void
-highlight_cell_changed (GnmDiffState *state,
+highlight_cell_changed (gpointer user,
                        GnmCell const *oc, GnmCell const *nc)
 {
+       DiffState *state = user;
        GnmRange r;
        highlight_apply (state, range_init_cellpos (&r, &(nc ? nc : oc)->pos));
 }
 
 static void
-highlight_style_changed (GnmDiffState *state, GnmRange const *r,
+highlight_style_changed (gpointer user, GnmRange const *r,
                         G_GNUC_UNUSED GnmStyle const *os,
                         G_GNUC_UNUSED GnmStyle const *ns)
 {
+       DiffState *state = user;
        highlight_apply (state, r);
 }
 
@@ -848,7 +873,7 @@ diff (char const *oldfilename, char const *newfilename,
       GOIOContext *ioc,
       GnmDiffActions const *actions, GsfOutput *output)
 {
-       GnmDiffState state;
+       DiffState state;
        int res = 0;
        GnmLocale *locale;
 


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