sql_attribute_value = cou_buildEncodedSQL(cnx, attribute_value);
/* value_noeval is "virtual attribute" which does not cause */
/* evaluation of dependent expressions. Used in evalDependent only */
if (strcmp(attribute_name,"value_noeval")==0) {
attribute_name="value";
bEvalDependent=0; /* do not evaluate dependent expressions */
}
if (!strcmp(attribute_name,"value"))
{
@co_call(par_area,'"spreadsheet"',"onEvent", par_area=>par_area, par_class=>'"spreadsheet"', par_id=>par_id, column_id=>column_id,row_id=>row_id,event_name=>'"onbeforevaluechange"');
}
/* first, just set the attribute (as string) */
__CREATE_QUERY("UPDATE co_%s_spreadsheet_cell SET %s='%s' WHERE column_id=%d AND row_id=%d", par_area, attribute_name, sql_attribute_value, column_id, row_id);
__SQL_EXEC
if (!ok)
{
__CREATE_QUERY("INSERT INTO co_%s_spreadsheet_cell(column_id,row_id,%s) VALUES(%d,%d,'%s')", par_area, attribute_name, column_id, row_id, sql_attribute_value);
__SQL_EXEC
}
/* value is a special case: store numeric value in a separate field */
/* and (perhaps) eval dependent expressions */
if (!strcmp(attribute_name,"value")) {
/* useful constants */
double infinity;
infinity = atof("Inf");
/* set numeric value ?and date? see strtod() */
errno=0; /* clean up */
double_value = strtod(attribute_value, &end_ptr); /* or just use atof()*/
if (errno!=0) double_value=0;
/* more scrict test if value is numeric */
while (isspace(*end_ptr)) end_ptr++;
if ((*end_ptr)!='\0') double_value=0; /* numeric only if whitespace till end */
if (double_value==infinity) cou_error(cnx, "Infinity detected");
//__SEND_MESG_DEBUG("value_num=%f errno=%d", double_value, errno )
// double_value = atof(attribute_value);
// if (double_value != 0)
// {
__CREATE_QUERY(
"UPDATE co_%s_spreadsheet_cell SET value_num='%f' "
"WHERE column_id=%d AND row_id=%d"
, par_area, double_value, column_id, row_id
)
__SQL_EXEC
// }
if (bEvalDependent)
{
@co_call(par_area,'"expression"',"evalDependent",par_area=>par_area,par_class=>'"expression"',par_id=>par_id,id_column=>column_id,id_row=>row_id);
}
}
puta_ids[0] = par_id; puta_ids[1] = column_id; puta_ids[2] = row_id;
cou_queueActionX( cnx, "spreadsheet_cell", puta_classes, puta_ids, CO_OP_UPDATE, attribute_name, attribute_value, NULL);
if (!strcmp(attribute_name,"value"))
{
@co_call(par_area,'"spreadsheet"',"onEvent", par_area=>par_area, par_class=>'"spreadsheet"', par_id=>par_id, column_id=>column_id,row_id=>row_id,event_name=>'"onaftervaluechange"');
}