id_spreadsheet = par_id;
//TODO: move to expression_cell/range
user_id = cnx->id_user;
serialization = ap_psprintf(p, "%d,%d,%d@", id_spreadsheet, id_column, id_row) ;

__SQL_GET_INTEGER(num_row,
"SELECT row_number FROM co_sys_spreadsheet_row WHERE id=%d",
id_row )
__ASSERT( (num_row>0) , "row with id=%d not found", id_row)
__SQL_GET_INTEGER(num_column,
"SELECT column_number FROM co_sys_spreadsheet_column WHERE id=%d",
id_column )
__ASSERT( (num_column>0) , "column with id=%d not found", id_column)

__CREATE_QUERY("
SELECT
index_ref, id_ref_spreadsheet, id_ref_row, id_ref_column,
is_ref_row_hard, is_ref_column_hard,
is_ref_row_named, is_ref_column_named,
REFCOL.column_number-%d,
REFROW.row_number-%d
FROM co_sys_expression_cell,
co_sys_spreadsheet_column AS REFCOL,
co_sys_spreadsheet_row AS REFROW
WHERE id_column=%d AND id_row=%d AND
REFCOL.id = id_ref_column AND
REFROW.id = id_ref_row
", num_column, num_row, id_column, id_row)
__SQL_GET_RESULT

ntuples = cor_GetTupleCount(cnx, corec);
if (ntuples>0) for (i=0; i<ntuples; i++) {

if (i==0)
serialization = ap_psprintf(p, "%s%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", serialization,
cor_GetValue(cnx, corec,0,0),cor_GetValue(cnx, corec,0,1),cor_GetValue(cnx, corec,0,2),cor_GetValue(cnx, corec,0,3),
cor_GetValue(cnx, corec,0,4),cor_GetValue(cnx, corec,0,5),cor_GetValue(cnx, corec,0,6),cor_GetValue(cnx, corec,0,7),
cor_GetValue(cnx, corec,0,8), cor_GetValue(cnx, corec,0,9) );
else
serialization = ap_psprintf(p, "%s|%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", serialization,
cor_GetValue(cnx, corec,i,0),cor_GetValue(cnx, corec,i,1),cor_GetValue(cnx, corec,i,2),cor_GetValue(cnx, corec,i,3),
cor_GetValue(cnx, corec,i,4),cor_GetValue(cnx, corec,i,5),cor_GetValue(cnx, corec,i,6),cor_GetValue(cnx, corec,i,7),
cor_GetValue(cnx, corec,i,8), cor_GetValue(cnx, corec,i,9) );
}
__CLEAR_RESULT

__CREATE_QUERY("
SELECT
index_ref, function,
id_ref_spreadsheet,
id_ref_row, id_ref_column,
is_ref_row_hard, is_ref_column_hard,
is_ref_row_named, is_ref_column_named,
REFCOL.column_number-%d,
REFROW.row_number-%d,
id_ref_row2, id_ref_column2,
is_ref_row2_hard, is_ref_column2_hard,
is_ref_row2_named, is_ref_column2_named,
REFCOL2.column_number-%d,
REFROW2.row_number-%d
FROM co_sys_expression_range,
co_sys_spreadsheet_column AS REFCOL,
co_sys_spreadsheet_row AS REFROW,
co_sys_spreadsheet_column AS REFCOL2,
co_sys_spreadsheet_row AS REFROW2
WHERE id_column=%d AND id_row=%d AND
REFCOL.id = id_ref_column AND
REFROW.id = id_ref_row AND
REFCOL2.id = id_ref_column2 AND
REFROW2.id = id_ref_row2

", num_column, num_row, num_column, num_row, id_column, id_row)
__SQL_GET_RESULT

ntuples = cor_GetTupleCount(cnx, corec);
if (ntuples>0) for (i=0; i<ntuples; i++) {
if (i==0)
serialization = ap_psprintf(p, "%s#%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", serialization,
cor_GetValue(cnx, corec,0,0),cor_GetValue(cnx, corec,0,1),cor_GetValue(cnx, corec,0,2),cor_GetValue(cnx, corec,0,3),
cor_GetValue(cnx, corec,0,4),cor_GetValue(cnx, corec,0,5),cor_GetValue(cnx, corec,0,6),cor_GetValue(cnx, corec,0,7),
cor_GetValue(cnx, corec,0,8),cor_GetValue(cnx, corec,0,9),cor_GetValue(cnx, corec,0,10),cor_GetValue(cnx, corec,0,11),
cor_GetValue(cnx, corec,0,12),cor_GetValue(cnx, corec,0,13),cor_GetValue(cnx, corec,0,14),
cor_GetValue(cnx, corec,0,15),cor_GetValue(cnx, corec,0,16),cor_GetValue(cnx, corec,0,17), cor_GetValue(cnx, corec,0,18) );
else
serialization = ap_psprintf(p, "%s|%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", serialization,
cor_GetValue(cnx, corec,i,0),cor_GetValue(cnx, corec,i,1),cor_GetValue(cnx, corec,i,2),cor_GetValue(cnx, corec,i,3),
cor_GetValue(cnx, corec,i,4),cor_GetValue(cnx, corec,i,5),cor_GetValue(cnx, corec,i,6),cor_GetValue(cnx, corec,i,7),
cor_GetValue(cnx, corec,i,8),cor_GetValue(cnx, corec,i,9),cor_GetValue(cnx, corec,i,10),cor_GetValue(cnx, corec,i,11),
cor_GetValue(cnx, corec,i,12),cor_GetValue(cnx, corec,i,13),cor_GetValue(cnx, corec,i,14),
cor_GetValue(cnx, corec,i,15),cor_GetValue(cnx, corec,i,16),cor_GetValue(cnx, corec,i,17), cor_GetValue(cnx, corec,i,18) );
}
else /* no ranges */
serialization = ap_psprintf(p, "%s#", serialization);

__CLEAR_RESULT

__CREATE_QUERY("
SELECT expression_parsed from co_sys_expression
WHERE id_column=%d AND id_row=%d", id_column, id_row)
__SQL_GET_RESULT

serialization = ap_psprintf(p, "%s$%s", serialization, cor_GetValue(cnx, corec,0,0) );

__CLEAR_RESULT

@co_call('"sys"','"clipboard"',"insertClipboardObject", serialization => serialization, par_id=>user_id, par_area=>'"sys"', par_class=>'"clipboard"', owner_area=>'"sys"', owner_class=>'"expression"' );