[gnumeric] change how "no print area set" is stored
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] change how "no print area set" is stored
- Date: Tue, 9 Jun 2009 23:44:16 -0400 (EDT)
commit 3269227f1a858ee0297da77b0e79f1b342c8a478
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Tue Jun 9 21:43:27 2009 -0600
change how "no print area set" is stored
2009-06-09 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/sheet.h (sheet_get_nominal_printarea): change return type
* src/sheet.c (gnm_sheet_constructor): change initialization
of print area
(sheet_get_nominal_printarea): change return type
(sheet_get_printarea): adjust for changes in
sheet_get_nominal_printarea
* src/wbc-gtk-actions.c (cb_file_print_area_clear): change to
match changed print area interpretation
(cb_file_print_area_show): ditto
* src/xml-io.c (xml_read_names): since existing files will assume
the old meaning of print area we should adjust upon loading.
* src/xml-sax-read.c (xml_sax_named_expr_end): ditto
2009-06-09 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-printer-setup.c (load_print_area) adjust for changes in
sheet_get_nominal_printarea
---
ChangeLog | 15 +++++++
src/dialogs/ChangeLog | 5 ++
src/dialogs/dialog-printer-setup.c | 15 +++++--
src/sheet.c | 73 +++++++++++++++++++----------------
src/sheet.h | 2 +-
src/wbc-gtk-actions.c | 20 +++++----
src/xml-io.c | 9 ++++
src/xml-sax-read.c | 38 +++++++++++--------
8 files changed, 113 insertions(+), 64 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 24b0e9d..d5f5033 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2009-06-09 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/sheet.h (sheet_get_nominal_printarea): change return type
+ * src/sheet.c (gnm_sheet_constructor): change initialization
+ of print area
+ (sheet_get_nominal_printarea): change return type
+ (sheet_get_printarea): adjust for changes in
+ sheet_get_nominal_printarea
+ * src/wbc-gtk-actions.c (cb_file_print_area_clear): change to
+ match changed print area interpretation
+ (cb_file_print_area_show): ditto
+ * src/xml-io.c (xml_read_names): since existing files will assume
+ the old meaning of print area we should adjust upon loading.
+ * src/xml-sax-read.c (xml_sax_named_expr_end): ditto
+
2009-06-09 Jody Goldberg <jody gnome org>
* src/go-string.c (go_string_shutdown) : don't leak the shared string
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 22812a0..7155249 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,8 @@
+2009-06-09 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * dialog-printer-setup.c (load_print_area) adjust for changes in
+ sheet_get_nominal_printarea
+
2009-06-07 Andreas J. Guelzow <aguelzow pyrshep ca>
* chi-squared.glade: new
diff --git a/src/dialogs/dialog-printer-setup.c b/src/dialogs/dialog-printer-setup.c
index 8d41c82..c389d0a 100644
--- a/src/dialogs/dialog-printer-setup.c
+++ b/src/dialogs/dialog-printer-setup.c
@@ -2040,15 +2040,20 @@ display_order_icon (GtkToggleButton *toggle, PrinterSetupState *state)
static void
load_print_area (PrinterSetupState *state)
{
- GnmRange print_area;
+ GnmRange *print_area;
print_area = sheet_get_nominal_printarea
(wb_control_cur_sheet
(WORKBOOK_CONTROL (state->wbcg)));
- gnm_expr_entry_load_from_range
- (state->area_entry,
- wb_control_cur_sheet (WORKBOOK_CONTROL (state->wbcg)),
- &print_area);
+ if (print_area != NULL)
+ gnm_expr_entry_load_from_range
+ (state->area_entry,
+ wb_control_cur_sheet (WORKBOOK_CONTROL (state->wbcg)),
+ print_area);
+ else
+ gnm_expr_entry_load_from_text
+ (state->area_entry, "");
+ g_free (print_area);
}
static void
diff --git a/src/sheet.c b/src/sheet.c
index 725108c..285d60c 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -679,7 +679,6 @@ gnm_sheet_constructor (GType type,
break;
case GNM_SHEET_DATA: {
/* We have to add permanent names */
- GnmRange r;
GnmExprTop const *texpr;
if (sheet->name_unquoted)
@@ -691,10 +690,10 @@ gnm_sheet_constructor (GType type,
expr_name_perm_add (sheet, "Sheet_Title",
texpr, FALSE);
- range_init_full_sheet (&r, sheet);
- texpr = gnm_expr_top_new_constant (value_new_cellrange_r (sheet, &r));
+ texpr = gnm_expr_top_new_constant
+ (value_new_error_REF (NULL));
expr_name_perm_add (sheet, "Print_Area",
- texpr, TRUE);
+ texpr, FALSE);
break;
}
default:
@@ -2049,37 +2048,43 @@ sheet_get_extent (Sheet const *sheet, gboolean spans_and_merges_extend)
return closure.range;
}
-GnmRange
+GnmRange *
sheet_get_nominal_printarea (Sheet const *sheet)
{
GnmNamedExpr *nexpr;
+ GnmValue *val;
GnmParsePos pos;
- GnmRange print_area, full_sheet, r;
+ GnmRange *r;
+ GnmRangeRef const *r_ref;
+ gint max_rows;
+ gint max_cols;
- range_init_full_sheet (&full_sheet, sheet);
- print_area = full_sheet;
-
- g_return_val_if_fail (IS_SHEET (sheet), print_area);
+ g_return_val_if_fail (IS_SHEET (sheet), NULL);
parse_pos_init_sheet (&pos, sheet);
nexpr = expr_name_lookup (&pos, "Print_Area");
- if (nexpr != NULL) {
- GnmValue *val = gnm_expr_top_get_range (nexpr->texpr);
- if (val != NULL) {
- GnmRangeRef const *r_ref = value_get_rangeref (val);
- if (r_ref != NULL)
- range_init_rangeref (&print_area, r_ref);
- value_release (val);
- }
- }
+ if (nexpr == NULL)
+ return NULL;
- /* We are now trying to fix any problems with the print area */
- if (range_intersection (&r, &print_area, &full_sheet))
- print_area = r;
- else
- print_area = full_sheet;
+ val = gnm_expr_top_get_range (nexpr->texpr);
+ if (val == NULL)
+ return NULL;
- return print_area;
+ r_ref = value_get_rangeref (val);
+ value_release (val);
+
+ if (r_ref == NULL)
+ return NULL;
+
+ r = g_new0 (GnmRange, 1);
+ range_init_rangeref (r, r_ref);
+
+ if (r->end.col >= (max_cols = gnm_sheet_get_max_cols (sheet)))
+ r->end.col = max_cols - 1;
+ if (r->end.row >= (max_rows = gnm_sheet_get_max_rows (sheet)))
+ r->end.row = max_rows - 1;
+
+ return r;
}
GnmRange
@@ -2088,22 +2093,24 @@ sheet_get_printarea (Sheet const *sheet,
gboolean ignore_printarea)
{
static GnmRange const dummy = { { 0,0 }, { 0,0 } };
- GnmRange r;
+ GnmRange print_area;
g_return_val_if_fail (IS_SHEET (sheet), dummy);
if (!ignore_printarea) {
- r = sheet_get_nominal_printarea (sheet);
- if (!range_is_full (&r, sheet, TRUE) ||
- !range_is_full (&r, sheet, FALSE))
- return r;
+ GnmRange *r = sheet_get_nominal_printarea (sheet);
+ if (r != NULL) {
+ print_area = *r;
+ g_free (r);
+ return print_area;
+ }
}
- r = sheet_get_extent (sheet, TRUE);
+ print_area = sheet_get_extent (sheet, TRUE);
if (include_styles)
- sheet_style_get_extent (sheet, &r, NULL);
+ sheet_style_get_extent (sheet, &print_area, NULL);
- return r;
+ return print_area;
}
struct cb_fit {
diff --git a/src/sheet.h b/src/sheet.h
index ce00d12..4a18917 100644
--- a/src/sheet.h
+++ b/src/sheet.h
@@ -301,7 +301,7 @@ GnmRange sheet_get_extent (Sheet const *sheet,
GnmRange sheet_get_printarea (Sheet const *sheet,
gboolean include_styles,
gboolean ignore_printarea);
-GnmRange sheet_get_nominal_printarea (Sheet const *sheet);
+GnmRange *sheet_get_nominal_printarea (Sheet const *sheet);
/*
* Utilities to set cell contents, queueing recalcs,
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 6b0acb9..6fd66b2 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -256,27 +256,29 @@ static GNM_ACTION_DEF (cb_file_print_area_set)
static GNM_ACTION_DEF (cb_file_print_area_clear)
{
GnmParsePos pp;
- GnmRange r;
Sheet *sheet = wbcg_cur_sheet (wbcg);
- range_init_full_sheet (&r, sheet);
parse_pos_init_sheet (&pp, sheet);
cmd_define_name (WORKBOOK_CONTROL (wbcg), "Print_Area", &pp,
gnm_expr_top_new_constant
- (value_new_cellrange_r (NULL, &r)),
+ (value_new_error_REF (NULL)),
_("Clear Print Area"));
}
static GNM_ACTION_DEF (cb_file_print_area_show)
{
Sheet *sheet = wbcg_cur_sheet (wbcg);
- SheetView *sv = sheet_get_view (sheet, wb_control_view (WORKBOOK_CONTROL (wbcg)));
- GnmRange r = sheet_get_nominal_printarea (sheet);
+ GnmRange *r = sheet_get_nominal_printarea (sheet);
- wb_control_sheet_focus (WORKBOOK_CONTROL (wbcg), sheet);
- sv_selection_reset (sv);
- sv_selection_add_range (sv, &r);
- sv_make_cell_visible (sv, r.start.col, r.start.row, FALSE);
+ if (r != NULL) {
+ SheetView *sv = sheet_get_view (sheet,
+ wb_control_view (WORKBOOK_CONTROL (wbcg)));
+ wb_control_sheet_focus (WORKBOOK_CONTROL (wbcg), sheet);
+ sv_selection_reset (sv);
+ sv_selection_add_range (sv, r);
+ sv_make_cell_visible (sv, r->start.col, r->start.row, FALSE);
+ g_free (r);
+ }
}
static GNM_ACTION_DEF (cb_file_print)
diff --git a/src/xml-io.c b/src/xml-io.c
index 83e52d1..314f759 100644
--- a/src/xml-io.c
+++ b/src/xml-io.c
@@ -368,6 +368,15 @@ xml_read_names (XmlParseContext *ctxt, xmlNodePtr tree,
expr_str = xml_node_get_cstr (expr_node, NULL);
g_return_if_fail (name_str != NULL && expr_str != NULL);
+
+ /*For the next while we have to ignore Print_areas that look like a whole sheet */
+ if (0 == strcmp (CXML2C (name_str), "Print_Area")
+ && g_str_has_suffix (CXML2C (expr_str), "$A$1:$IV$65536")) {
+ xmlFree (name_str);
+ xmlFree (expr_str);
+ continue;
+ }
+
parse_pos_init (&pp, wb, sheet, 0, 0);
if (position != NULL) {
xmlChar *pos_txt = xml_node_get_cstr (position, NULL);
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index 0dc374b..e9220e0 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -2221,25 +2221,31 @@ xml_sax_named_expr_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
g_return_if_fail (state->name.name != NULL);
g_return_if_fail (state->name.value != NULL);
- parse_pos_init (&pp, state->wb, state->sheet, 0, 0);
- nexpr = expr_name_add (&pp, state->name.name,
- gnm_expr_top_new_constant (value_new_empty ()),
- NULL,
- TRUE,
- NULL);
-
- state->delayed_names = g_list_prepend (state->delayed_names, state->sheet);
- state->delayed_names = g_list_prepend (state->delayed_names, state->name.value);
- state->name.value = NULL;
- state->delayed_names = g_list_prepend (state->delayed_names, state->name.position);
- state->name.position = NULL;
- state->delayed_names = g_list_prepend (state->delayed_names, nexpr);
+ /*For the next while we have to ignore Print_areas that look like a whole sheet */
+ if (0 == strcmp (state->name.name, "Print_Area")
+ && g_str_has_suffix (state->name.value, "$A$1:$IV$65536")) {
+ g_free (state->name.value);
+ state->name.value = NULL;
+ g_free (state->name.position);
+ state->name.position = NULL;
+ } else {
+ parse_pos_init (&pp, state->wb, state->sheet, 0, 0);
+ nexpr = expr_name_add (&pp, state->name.name,
+ gnm_expr_top_new_constant (value_new_empty ()),
+ NULL,
+ TRUE,
+ NULL);
+
+ state->delayed_names = g_list_prepend (state->delayed_names, state->sheet);
+ state->delayed_names = g_list_prepend (state->delayed_names, state->name.value);
+ state->name.value = NULL;
+ state->delayed_names = g_list_prepend (state->delayed_names, state->name.position);
+ state->name.position = NULL;
+ state->delayed_names = g_list_prepend (state->delayed_names, nexpr);
+ }
g_free (state->name.name);
state->name.name = NULL;
-
- g_free (state->name.value);
- state->name.value = NULL;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]