Commit 9bf3f4d9 authored by Morten Welinder's avatar Morten Welinder

dao: autofit improvements.

Use general colrow code for the fitting and avoid shrinking any columns.
parent 2fd7ab95
2016-02-10 Morten Welinder <terra@gnome.org>
* dao.c (dao_autofit_rows): New function.
(dao_autofit_these_columns): Simply use colrow_autofit. Don't
shrink any columns.
2016-02-06 Morten Welinder <terra@gnome.org>
* Release 1.12.27
......
......@@ -81,6 +81,7 @@ dao_init (data_analysis_output_t *dao,
dao->rows = 1;
dao->sheet = NULL;
dao->autofit_flag = TRUE;
dao->autofit_noshrink = TRUE;
dao->clear_outputrange = TRUE;
dao->retain_format = FALSE;
dao->retain_comments = FALSE;
......@@ -621,62 +622,36 @@ dao_set_cell_comment (data_analysis_output_t *dao, int col, int row,
}
/**
* autofit_column:
* @dao:
* @col:
*
* fits a column to the content
*
*
**/
static void
dao_autofit_column (data_analysis_output_t *dao, int col)
{
int ideal_size, actual_col;
actual_col = dao->start_col + col;
ideal_size = sheet_col_size_fit_pixels (dao->sheet, actual_col,
0, gnm_sheet_get_last_row (dao->sheet),
FALSE);
if (ideal_size == 0)
return;
sheet_col_set_size_pixels (dao->sheet, actual_col, ideal_size, TRUE);
sheet_recompute_spans_for_col (dao->sheet, col);
}
/**
* dao_autofit_these_columns:
* @dao:
* @from_col:
* @to_col:
*
* fits all columns to their content
*
*
* Fits the specified columns to their content
**/
void
dao_autofit_these_columns (data_analysis_output_t *dao, int from_col, int to_col)
{
int i;
GnmRange r;
if (!dao->autofit_flag)
return;
for (i = from_col; i <= to_col; i++)
dao_autofit_column (dao,i);
range_init_cols (&r, dao->sheet,
from_col + dao->start_col,
to_col + dao->start_col);
colrow_autofit (dao->sheet, &r, TRUE,
FALSE, dao->autofit_noshrink, FALSE,
NULL, NULL);
}
/**
* autofit_columns:
* dao_autofit_columns:
* @dao:
* @from:
* @to:
*
* fits all columns to their content
*
*
**/
void
dao_autofit_columns (data_analysis_output_t *dao)
......@@ -684,6 +659,30 @@ dao_autofit_columns (data_analysis_output_t *dao)
dao_autofit_these_columns (dao, 0, dao->cols - 1);
}
void
dao_autofit_these_rows (data_analysis_output_t *dao, int from_row, int to_row)
{
GnmRange r;
if (!dao->autofit_flag)
return;
range_init_rows (&r, dao->sheet,
from_row + dao->start_row,
to_row + dao->start_row);
colrow_autofit (dao->sheet, &r, FALSE,
FALSE, dao->autofit_noshrink, FALSE,
NULL, NULL);
}
void
dao_autofit_rows (data_analysis_output_t *dao)
{
dao_autofit_these_rows (dao, 0, dao->rows - 1);
}
/**
* dao_set_style:
* @dao:
......
......@@ -47,6 +47,7 @@ typedef struct {
int start_row, rows;
int offset_col, offset_row;
gboolean autofit_flag;
gboolean autofit_noshrink;
gboolean clear_outputrange;
gboolean retain_format;
gboolean retain_comments;
......@@ -65,8 +66,11 @@ data_analysis_output_t *dao_load_from_value (data_analysis_output_t *dao,
void dao_free (data_analysis_output_t *dao);
void dao_autofit_columns (data_analysis_output_t *dao);
void dao_autofit_these_columns (data_analysis_output_t *dao, int from_col,
int to_col);
void dao_autofit_these_columns (data_analysis_output_t *dao, int from_col, int to_col);
void dao_autofit_rows (data_analysis_output_t *dao);
void dao_autofit_these_rows (data_analysis_output_t *dao, int from_row, int to_row);
gboolean dao_cell_is_visible (data_analysis_output_t *dao, int col, int row);
void dao_set_bold (data_analysis_output_t *dao, int col1, int row1,
int col2, int row2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment