[gnumeric] Do not include hidden cells in automatic print range. [#700994]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Do not include hidden cells in automatic print range. [#700994]
- Date: Mon, 27 May 2013 02:57:17 +0000 (UTC)
commit bc62fc0c2e934caf10c8eb2e371681777a0460cf
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sun May 26 20:56:32 2013 -0600
Do not include hidden cells in automatic print range. [#700994]
2013-05-15 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/sheet.c (sheet_get_extent): add argument to indicate whether
to include hidden cells
(cb_sheet_get_extent): handle hidden cells setting
(sheet_get_printarea): do not include hidden cells
* src/sheet.h (sheet_get_extent): add argument and change all
callers
ChangeLog | 9 +++++++++
NEWS | 1 +
plugins/dif/dif.c | 2 +-
plugins/excel/ms-excel-write.c | 2 +-
plugins/html/html.c | 2 +-
plugins/html/latex.c | 2 +-
plugins/html/roff.c | 2 +-
plugins/paradox/paradox.c | 2 +-
plugins/python-loader/py-gnumeric.c | 2 +-
plugins/sylk/sylk-write.c | 2 +-
src/dialogs/dialog-stf-export.c | 2 +-
src/gnm-pane.c | 4 ++--
src/ranges.c | 2 +-
src/sheet-control-gui.c | 2 +-
src/sheet.c | 30 ++++++++++++++++++++++--------
src/sheet.h | 3 ++-
src/stf-export.c | 2 +-
17 files changed, 48 insertions(+), 23 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 51f032a..5db4133 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-05-15 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/sheet.c (sheet_get_extent): add argument to indicate whether
+ to include hidden cells
+ (cb_sheet_get_extent): handle hidden cells setting
+ (sheet_get_printarea): do not include hidden cells
+ * src/sheet.h (sheet_get_extent): add argument and change all
+ callers
+
2013-05-26 Morten Welinder <terra gnome org>
* src/mathfunc.c (ptukey_wprob): Use as many intervals as needed.
diff --git a/NEWS b/NEWS
index 944b185..aadf5a2 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Andreas:
* Fix data merges. [#699897]
* Fix editing of hyperlinks. [#700732]
* Fix conditional formatting crash. [#700969]
+ * Do not include hidden cells in automatic print range. [#700994]
Darrell Tangman:
* Update documentation for Edit and Insert menus. [#700596]
diff --git a/plugins/dif/dif.c b/plugins/dif/dif.c
index 784b097..c264f13 100644
--- a/plugins/dif/dif.c
+++ b/plugins/dif/dif.c
@@ -315,7 +315,7 @@ dif_file_save (GOFileSaver const *fs, GOIOContext *io_context,
return;
}
- r = sheet_get_extent (sheet, FALSE);
+ r = sheet_get_extent (sheet, FALSE, TRUE);
/* Write out the standard headers */
gsf_output_puts (out, "TABLE\n" "0,1\n" "\"GNUMERIC\"\n");
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index a2933ab..cb2c459 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -214,7 +214,7 @@ excel_sheet_extent (Sheet const *sheet, GnmRange *extent, GnmStyle **col_styles,
GnmRange r;
/* Ignore spans and merges past the bound */
- *extent = sheet_get_extent (sheet, FALSE);
+ *extent = sheet_get_extent (sheet, FALSE, TRUE);
range_init (&r, 0, 0,
MAX (maxcols, gnm_sheet_get_max_cols(sheet)) - 1,
diff --git a/plugins/html/html.c b/plugins/html/html.c
index 47b853f..2e2f553 100644
--- a/plugins/html/html.c
+++ b/plugins/html/html.c
@@ -678,7 +678,7 @@ write_sheet (GsfOutput *output, Sheet *sheet,
html_print_encoded (output, sheet->name_unquoted);
gsf_output_puts (output, "</caption>\n");
}
- total_range = sheet_get_extent (sheet, TRUE);
+ total_range = sheet_get_extent (sheet, TRUE, TRUE);
for (row = total_range.start.row; row <= total_range.end.row; row++) {
gsf_output_puts (output, "<tr>\n");
write_row (output, sheet, row, &total_range, version);
diff --git a/plugins/html/latex.c b/plugins/html/latex.c
index f269724..f0d3e78 100644
--- a/plugins/html/latex.c
+++ b/plugins/html/latex.c
@@ -1255,7 +1255,7 @@ file_saver_sheet_get_extent (Sheet *sheet)
if (start_sheet == sheet)
return r;
}
- return sheet_get_extent (sheet, TRUE);
+ return sheet_get_extent (sheet, TRUE, TRUE);
}
/**
diff --git a/plugins/html/roff.c b/plugins/html/roff.c
index 6da970a..d3c8be8 100644
--- a/plugins/html/roff.c
+++ b/plugins/html/roff.c
@@ -98,7 +98,7 @@ roff_file_save (GOFileSaver const *fs, GOIOContext *io_context,
sheets = workbook_sheets (wb);
for (ptr = sheets ; ptr != NULL ; ptr = ptr->next) {
Sheet *sheet = ptr->data;
- GnmRange r = sheet_get_extent (sheet, FALSE);
+ GnmRange r = sheet_get_extent (sheet, FALSE, TRUE);
gsf_output_printf (output, "%s\n\n", sheet->name_unquoted);
gsf_output_printf (output, ".TS H\n");
diff --git a/plugins/paradox/paradox.c b/plugins/paradox/paradox.c
index 7c2d06f..b4bf537 100644
--- a/plugins/paradox/paradox.c
+++ b/plugins/paradox/paradox.c
@@ -312,7 +312,7 @@ paradox_file_save (GOFileSaver const *fs, GOIOContext *io_context,
return;
}
- r = sheet_get_extent (sheet, FALSE);
+ r = sheet_get_extent (sheet, FALSE, TRUE);
#ifdef PX_MEMORY_DEBUGGING
pxdoc = PX_new2 (gn_errorhandler, PX_mp_malloc, PX_mp_realloc, PX_mp_free);
diff --git a/plugins/python-loader/py-gnumeric.c b/plugins/python-loader/py-gnumeric.c
index 2845152..f9e75fa 100644
--- a/plugins/python-loader/py-gnumeric.c
+++ b/plugins/python-loader/py-gnumeric.c
@@ -1557,7 +1557,7 @@ py_sheet_get_extent_method (py_Sheet_object *self, PyObject *args)
return NULL;
}
- range = sheet_get_extent (self->sheet, FALSE);
+ range = sheet_get_extent (self->sheet, FALSE, TRUE);
return py_new_Range_object (&range);
}
diff --git a/plugins/sylk/sylk-write.c b/plugins/sylk/sylk-write.c
index a340faa..c4aaec5 100644
--- a/plugins/sylk/sylk-write.c
+++ b/plugins/sylk/sylk-write.c
@@ -156,7 +156,7 @@ sylk_write_sheet (SylkWriter *state)
GnmRange extent;
/* collect style and font info */
- extent = sheet_get_extent (state->sheet, FALSE);
+ extent = sheet_get_extent (state->sheet, FALSE, TRUE);
sheet_style_foreach (state->sheet,
(GFunc)cb_sylk_collect_styles, state);
sheet_cell_foreach (state->sheet,
diff --git a/src/dialogs/dialog-stf-export.c b/src/dialogs/dialog-stf-export.c
index 171d17f..16b9ee6 100644
--- a/src/dialogs/dialog-stf-export.c
+++ b/src/dialogs/dialog-stf-export.c
@@ -609,7 +609,7 @@ stf_export_dialog_sheet_page_init (TextExportState *state)
for (i = 0 ; i < state->sheets.num ; i++) {
Sheet *sheet = workbook_sheet_by_index (state->wb, i);
- GnmRange total_range = sheet_get_extent (sheet, TRUE);
+ GnmRange total_range = sheet_get_extent (sheet, TRUE, TRUE);
gboolean empty = sheet_is_region_empty (sheet, &total_range);
gboolean export =
!sheet_list || g_slist_find (sheet_list, sheet);
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 91290fe..1610f86 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -320,7 +320,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
scg_set_top_row (scg, sv->edit_pos.row);
} else if (end_mode) {
/* Same as ctrl-end. */
- GnmRange r = sheet_get_extent (sheet, FALSE);
+ GnmRange r = sheet_get_extent (sheet, FALSE, TRUE);
(*movefn) (scg, r.end.col - sv->edit_pos.col, FALSE, TRUE);
(*movefn)(scg, r.end.row - sv->edit_pos.row, FALSE, FALSE);
} else {
@@ -339,7 +339,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
scg_set_left_col (scg, new_col);
scg_set_top_row (scg, new_row);
} else if ((event->state & GDK_CONTROL_MASK)) {
- GnmRange r = sheet_get_extent (sheet, FALSE);
+ GnmRange r = sheet_get_extent (sheet, FALSE, TRUE);
/* do the ctrl-end jump to the extent in 2 steps */
(*movefn)(scg, r.end.col - sv->edit_pos.col, FALSE, TRUE);
diff --git a/src/ranges.c b/src/ranges.c
index 69a421e..56e958a 100644
--- a/src/ranges.c
+++ b/src/ranges.c
@@ -612,7 +612,7 @@ range_clip_to_finite (GnmRange *range, Sheet *sheet)
* way of doing this. possibly using a flag for content changes, and
* using the current values as a cache
*/
- extent = sheet_get_extent (sheet, FALSE);
+ extent = sheet_get_extent (sheet, FALSE, TRUE);
if (range->end.col >= gnm_sheet_get_max_cols (sheet) - 1)
range->end.col = extent.end.col;
if (range->end.row >= gnm_sheet_get_max_rows (sheet) - 1)
diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c
index f6cdf72..12fe593 100644
--- a/src/sheet-control-gui.c
+++ b/src/sheet-control-gui.c
@@ -4191,7 +4191,7 @@ scg_drag_send_text (SheetControlGUI *scg, GtkSelectionData *sd)
{
Sheet *sheet = scg_sheet (scg);
Workbook *wb = sheet->workbook;
- GnmRange range = sheet_get_extent (sheet, TRUE);
+ GnmRange range = sheet_get_extent (sheet, TRUE, TRUE);
GnmCellRegion *reg = clipboard_copy_range (sheet, &range);
GString *s = cellregion_to_string (reg, TRUE, workbook_date_conv (wb));
diff --git a/src/sheet.c b/src/sheet.c
index db24258..79e6bdf 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -341,7 +341,7 @@ cb_colrow_compute_pixels_from_pts (GnmColRowIter const *iter,
}
static void
-cb_clear_rendered_cells (gpointer ignored, GnmCell *cell)
+cb_clear_rendered_cells (G_GNUC_UNUSED gpointer ignored, GnmCell *cell)
{
if (gnm_cell_get_rendered_value (cell) != NULL) {
sheet_cell_queue_respan (cell);
@@ -2139,17 +2139,27 @@ struct sheet_extent_data {
GnmRange range;
gboolean spans_and_merges_extend;
gboolean ignore_empties;
+ gboolean include_hidden;
};
static void
-cb_sheet_get_extent (gpointer ignored, gpointer value, gpointer data)
+cb_sheet_get_extent (G_GNUC_UNUSED gpointer ignored, gpointer value, gpointer data)
{
GnmCell const *cell = (GnmCell const *) value;
struct sheet_extent_data *res = data;
Sheet *sheet = cell->base.sheet;
+ ColRowInfo *ri = NULL;
if (res->ignore_empties && gnm_cell_is_empty (cell))
return;
+ if (!res->include_hidden) {
+ ri = sheet_col_get (sheet, cell->pos.col);
+ if (!ri->visible)
+ return;
+ ri = sheet_row_get (sheet, cell->pos.row);
+ if (!ri->visible)
+ return;
+ }
/* Remember the first cell is the min & max */
if (res->range.start.col > cell->pos.col)
@@ -2171,7 +2181,8 @@ cb_sheet_get_extent (gpointer ignored, gpointer value, gpointer data)
res->range = range_union (&res->range, merged);
} else {
CellSpanInfo const *span;
- ColRowInfo *ri = sheet_row_get (sheet, cell->pos.row);
+ if (ri == NULL)
+ ri = sheet_row_get (sheet, cell->pos.row);
if (ri->needs_respan)
row_calc_spans (ri, cell->pos.row, sheet);
span = row_span_get (ri, cell->pos.col);
@@ -2188,6 +2199,7 @@ cb_sheet_get_extent (gpointer ignored, gpointer value, gpointer data)
* sheet_get_extent:
* @sheet: the sheet
* @spans_and_merges_extend: optionally extend region for spans and merges.
+ * @include_hidden: whether to include the content of hidden cells.
*
* calculates the area occupied by cell data.
*
@@ -2200,7 +2212,7 @@ cb_sheet_get_extent (gpointer ignored, gpointer value, gpointer data)
* Return value: the range.
**/
GnmRange
-sheet_get_extent (Sheet const *sheet, gboolean spans_and_merges_extend)
+sheet_get_extent (Sheet const *sheet, gboolean spans_and_merges_extend, gboolean include_hidden)
{
static GnmRange const dummy = { { 0,0 }, { 0,0 } };
struct sheet_extent_data closure;
@@ -2213,6 +2225,7 @@ sheet_get_extent (Sheet const *sheet, gboolean spans_and_merges_extend)
closure.range.end.col = 0;
closure.range.end.row = 0;
closure.spans_and_merges_extend = spans_and_merges_extend;
+ closure.include_hidden = include_hidden;
closure.ignore_empties = TRUE;
sheet_cell_foreach (sheet, &cb_sheet_get_extent, &closure);
@@ -2263,6 +2276,7 @@ sheet_get_cells_extent (Sheet const *sheet)
closure.range.end.col = 0;
closure.range.end.row = 0;
closure.spans_and_merges_extend = FALSE;
+ closure.include_hidden = TRUE;
closure.ignore_empties = FALSE;
sheet_cell_foreach (sheet, &cb_sheet_get_extent, &closure);
@@ -2331,7 +2345,7 @@ sheet_get_printarea (Sheet const *sheet,
}
}
- print_area = sheet_get_extent (sheet, TRUE);
+ print_area = sheet_get_extent (sheet, TRUE, FALSE);
if (include_styles)
sheet_style_get_extent (sheet, &print_area);
@@ -2490,7 +2504,7 @@ sheet_row_size_fit_pixels (Sheet *sheet, int row, int scol, int ecol,
return 0;
data.max = -1;
- data.ignore_strings = FALSE;
+ data.ignore_strings = ignore_strings;
sheet_foreach_cell_in_range (sheet,
CELL_ITER_IGNORE_NONEXISTENT |
CELL_ITER_IGNORE_HIDDEN |
@@ -4405,7 +4419,7 @@ sheet_row_destroy (Sheet *sheet, int const row, gboolean free_cells)
}
static void
-cb_remove_allcells (gpointer ignore0, GnmCell *cell, gpointer ignore1)
+cb_remove_allcells (G_GNUC_UNUSED gpointer ignore0, GnmCell *cell, G_GNUC_UNUSED gpointer ignore1)
{
cell->base.flags &= ~GNM_CELL_IN_SHEET_LIST;
cell_free (cell);
@@ -5967,7 +5981,7 @@ sheet_dup_names (Sheet const *src, Sheet *dst)
}
static void
-cb_sheet_cell_copy (gpointer unused, gpointer key, gpointer new_sheet_param)
+cb_sheet_cell_copy (G_GNUC_UNUSED gpointer unused, gpointer key, gpointer new_sheet_param)
{
GnmCell const *cell = key;
Sheet *dst = new_sheet_param;
diff --git a/src/sheet.h b/src/sheet.h
index 02de535..e216bad 100644
--- a/src/sheet.h
+++ b/src/sheet.h
@@ -310,7 +310,8 @@ void sheet_scrollbar_config (Sheet const *sheet);
void sheet_mark_dirty (Sheet *sheet);
GnmRange sheet_get_extent (Sheet const *sheet,
- gboolean spans_and_merges_extend);
+ gboolean spans_and_merges_extend,
+ gboolean include_hidden);
GnmRange sheet_get_cells_extent (Sheet const *sheet);
GnmRange sheet_get_printarea (Sheet const *sheet,
gboolean include_styles,
diff --git a/src/stf-export.c b/src/stf-export.c
index a3eebc1..0652447 100644
--- a/src/stf-export.c
+++ b/src/stf-export.c
@@ -302,7 +302,7 @@ stf_export_sheet (GnmStfExport *stfe, Sheet *sheet)
if (start_sheet != sheet)
return TRUE;
} else
- r = sheet_get_extent (sheet, FALSE);
+ r = sheet_get_extent (sheet, FALSE, TRUE);
for (row = r.start.row; row <= r.end.row; row++) {
for (col = r.start.col; col <= r.end.col; col++) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]