2 * analysis-auto-expression.c:
5 * Andreas J. Guelzow <aguelzow@pyrshep.ca>
7 * (C) Copyright 2009 by Andreas J. Guelzow <aguelzow@pyrshep.ca>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, see <https://www.gnu.org/licenses/>.
24 #include <gnumeric-config.h>
25 #include <glib/gi18n-lib.h>
27 #include <tools/analysis-auto-expression.h>
28 #include <tools/analysis-tools.h>
36 analysis_tool_auto_expression_engine_run (data_analysis_output_t
*dao
,
37 analysis_tools_data_auto_expression_t
*info
)
40 GSList
*data
= info
->base
.input
;
43 for (col
= 0; data
!= NULL
; data
= data
->next
, col
++)
48 gnm_expr_new_constant (value_dup (data
->data
))));
55 make_rangeref (- col
, 0, -1, 0)));
57 for (col
= 0; data
!= NULL
; data
= data
->next
, col
++)
62 gnm_expr_new_constant (value_dup (data
->data
))));
69 make_rangeref (0, - col
, 0, -1)));
71 dao_redraw_respan (dao
);
77 analysis_tool_auto_expression_engine_clean (gpointer specs
)
79 analysis_tools_data_auto_expression_t
*info
= specs
;
81 gnm_func_dec_usage (info
->func
);
84 return analysis_tool_generic_clean (specs
);
88 analysis_tool_auto_expression_engine (G_GNUC_UNUSED GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
89 analysis_tool_engine_t selector
, gpointer result
)
91 analysis_tools_data_auto_expression_t
*info
= specs
;
94 case TOOL_ENGINE_UPDATE_DESCRIPTOR
:
95 return (dao_command_descriptor
96 (dao
, _("Auto Expression (%s)"), result
)
98 case TOOL_ENGINE_UPDATE_DAO
:
99 prepare_input_range (&info
->base
.input
, info
->base
.group_by
);
102 (info
->multiple
? 1 : 0) + g_slist_length (info
->base
.input
),
106 (info
->multiple
? 1 : 0) + g_slist_length (info
->base
.input
));
108 case TOOL_ENGINE_CLEAN_UP
:
109 return analysis_tool_auto_expression_engine_clean (specs
);
110 case TOOL_ENGINE_LAST_VALIDITY_CHECK
:
112 case TOOL_ENGINE_PREPARE_OUTPUT_RANGE
:
113 dao_prepare_output (NULL
, dao
, _("Auto Expression"));
115 case TOOL_ENGINE_FORMAT_OUTPUT_RANGE
:
116 return dao_format_output (dao
, _("Auto Expression"));
117 case TOOL_ENGINE_PERFORM_CALC
:
119 return analysis_tool_auto_expression_engine_run (dao
, specs
);