[gnumeric] Implement printing of errors as blanks.



commit cc83ddaf6cfd5311baee044f339dc720cd85bd51
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Jul 27 01:40:47 2011 -0600

    Implement printing of errors as blanks.
    
    2011-07-27 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/print-cell.h (gnm_gtk_print_cell_range): change argument type
    	* src/print-cell.c (gnm_gtk_print_cell_range): change argument type
    	(print_cell_gtk): consider print-info and possibly print errors	as blank
    	(print_merged_range_gtk): ditto
    	* src/print.c (print_page_cells): adjust call of gnm_gtk_print_cell_range
    
    2011-07-27 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* dialog-printer-setup.c (do_setup_error_display): enable
    	combo for as_blank

 ChangeLog                          |    8 ++++++
 NEWS                               |    1 +
 src/dialogs/ChangeLog              |    5 ++++
 src/dialogs/dialog-printer-setup.c |   15 +++++------
 src/print-cell.c                   |   42 ++++++++++++++++++++++-----------
 src/print-cell.h                   |    3 +-
 src/print.c                        |   44 +++++++++++++++++++----------------
 7 files changed, 75 insertions(+), 43 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3d6ee39..1a76256 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-07-27 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* src/print-cell.h (gnm_gtk_print_cell_range): change argument type
+	* src/print-cell.c (gnm_gtk_print_cell_range): change argument type
+	(print_cell_gtk): consider print-info and possibly print errors	as blank
+	(print_merged_range_gtk): ditto
+	* src/print.c (print_page_cells): adjust call of gnm_gtk_print_cell_range
+
 2011-07-20  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/collect.h (collect_float_pairs): add argument
diff --git a/NEWS b/NEWS
index 72b3be5..42d43ea 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Andreas:
 	* Speed up frequent calls to INTERPOLATION with the same 
 	abscissae/ordinates. [#654538]
 	* Export defined names to xlsx. [#655010]
+	* Implement printing of errors as blanks.
 
 Morten:
 	* Fix --with-gnome compilation:  [#652802]
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 7cfcfd5..6fe3da3 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,8 @@
+2011-07-27 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* dialog-printer-setup.c (do_setup_error_display): enable
+	combo for as_blank
+
 2011-07-26 Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* print.ui: show error display and comment placement combo boxes,
diff --git a/src/dialogs/dialog-printer-setup.c b/src/dialogs/dialog-printer-setup.c
index ae31925..572b80d 100644
--- a/src/dialogs/dialog-printer-setup.c
+++ b/src/dialogs/dialog-printer-setup.c
@@ -2189,9 +2189,9 @@ do_setup_error_display (PrinterSetupState *state)
 		guint  type;
 	} display_types[] = {
 		{N_("Print as displayed"), PRINT_ERRORS_AS_DISPLAYED},
-		{N_("Print as spaces"),    PRINT_ERRORS_AS_BLANK},
-		{N_("Print as dashes"),    PRINT_ERRORS_AS_DASHES},
-		{N_("Print as #N/A"),      PRINT_ERRORS_AS_NA}
+		{N_("Print as spaces"),    PRINT_ERRORS_AS_BLANK}/* , */
+		/* {N_("Print as dashes"),    PRINT_ERRORS_AS_DASHES}, */
+		/* {N_("Print as #N/A"),      PRINT_ERRORS_AS_NA} */
 	};
 	
 	gint i;
@@ -2205,17 +2205,16 @@ do_setup_error_display (PrinterSetupState *state)
                                                    0, _(display_types[i].label),
 						   1, display_types[i].type,
 						   -1);
-		/* if (display_types[i].type == state->pi->error_display) */
-		/* 	item = i; */
+		if (display_types[i].type == state->pi->error_display)
+			item = i;
 	}
 	cell = gtk_cell_renderer_text_new();
 	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(state->error_display.combo), cell, TRUE);
-	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(state->error_display.combo), cell, "text", 0, NULL);
+	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(state->error_display.combo), 
+				       cell, "text", 0, NULL);
 	if (gtk_tree_model_iter_nth_child
 	    (GTK_TREE_MODEL (state->error_display.store), &iter, NULL, item))
 		gtk_combo_box_set_active_iter (GTK_COMBO_BOX (state->error_display.combo), &iter);
-
-	gtk_widget_set_sensitive (state->error_display.combo, FALSE);
 }
 
 static void
diff --git a/src/print-cell.c b/src/print-cell.c
index 14078d4..8153586 100644
--- a/src/print-cell.c
+++ b/src/print-cell.c
@@ -31,6 +31,7 @@
 #include "sheet-merge.h"
 #include "rendered-value.h"
 #include "cell-draw.h"
+#include "print-info.h"
 
 #include <string.h>
 #include <locale.h>
@@ -56,7 +57,8 @@ static void
 print_cell_gtk (GnmCell const *cell,
 		cairo_t *context,
 		double x1, double y1,
-		double width, double height, double h_center)
+		double width, double height, double h_center,
+		PrintInformation const *pinfo)
 {
 	GnmRenderedValue *rv, *rv100 = NULL;
 	GOColor fore_color;
@@ -65,6 +67,11 @@ print_cell_gtk (GnmCell const *cell,
 	double const scale_h = 72. / gnm_app_display_dpi_get (TRUE);
 	double const scale_v = 72. / gnm_app_display_dpi_get (FALSE);
 
+	gboolean cell_has_error = (gnm_cell_is_error (cell) != NULL);
+
+	if (cell_has_error && pinfo->error_display == PRINT_ERRORS_AS_BLANK)
+		return;
+
 	/* Get the sizes exclusive of margins and grids */
 	/* Note: +1 because size_pixels includes leading gridline.  */
 	height -= GNM_ROW_MARGIN + GNM_ROW_MARGIN + 1;
@@ -155,8 +162,9 @@ print_rectangle_gtk (cairo_t *context,
 
 static void
 print_cell_background_gtk (cairo_t *context,
-		       GnmStyle const *style, int col, int row,
-		       double x, double y, double w, double h)
+			   GnmStyle const *style, 
+			   G_GNUC_UNUSED int col, G_GNUC_UNUSED int row,
+			   double x, double y, double w, double h)
 {
 	if (gnumeric_background_set_gtk (style, context))
 		/* Remember api excludes the far pixels */
@@ -174,9 +182,10 @@ print_cell_background_gtk (cairo_t *context,
  */
 static void
 print_merged_range_gtk (cairo_t *context,
-		    Sheet const *sheet,
-		    double start_x, double start_y,
-		    GnmRange const *view, GnmRange const *range)
+			Sheet const *sheet,
+			double start_x, double start_y,
+			GnmRange const *view, GnmRange const *range,
+			PrintInformation const *pinfo)
 {
 	double l, r, t, b;
 	int last;
@@ -237,10 +246,10 @@ print_merged_range_gtk (cairo_t *context,
 
 		if (sheet->text_is_rtl)
 			print_cell_gtk (cell, context,
-				r, t, l - r, b - t, -1.);
+					r, t, l - r, b - t, -1., pinfo);
 		else
 			print_cell_gtk (cell, context,
-				l, t, r - l, b - t, -1.);
+					l, t, r - l, b - t, -1., pinfo);
 	}
 	gnm_style_border_print_diag_gtk (style, context, l, t, r, b);
 }
@@ -256,7 +265,7 @@ void
 gnm_gtk_print_cell_range (cairo_t *context,
 			  Sheet const *sheet, GnmRange *range,
 			  double base_x, double base_y,
-			  gboolean hide_grid)
+			  PrintInformation const *pinfo)
 {
 	ColRowInfo const *ri = NULL, *next_ri = NULL;
 	int const dir = sheet->text_is_rtl ? -1 : 1;
@@ -266,19 +275,23 @@ gnm_gtk_print_cell_range (cairo_t *context,
 	GnmStyleRow sr, next_sr;
 	GnmStyle const **styles;
 	GnmBorder const **borders, **prev_vert;
-	GnmBorder const *none =
-		hide_grid ? NULL : gnm_style_border_none ();
+	GnmBorder const *none;
 
 	int n, col, row;
 	double x, y, offset;
 	GnmRange     view;
 	GSList	 *merged_active, *merged_active_seen,
 		 *merged_used, *merged_unused, *ptr, **lag;
+	gboolean hide_grid;
 
 	g_return_if_fail (IS_SHEET (sheet));
 	g_return_if_fail (range != NULL);
 	g_return_if_fail (range->start.col <= range->end.col);
 	g_return_if_fail (range->start.row <= range->end.row);
+	g_return_if_fail (pinfo != NULL);
+
+	hide_grid = !pinfo->print_grid_lines;
+	none = hide_grid ? NULL : gnm_style_border_none ();
 
 	start_col = range->start.col;
 	start_row = range->start.row;
@@ -383,7 +396,8 @@ gnm_gtk_print_cell_range (cairo_t *context,
 
 				if (ci->visible)
 					print_merged_range_gtk (context, sheet,
-								base_x, y, &view, r);
+								base_x, y, &view, r,
+								pinfo);
 				}
 			} else {
 				lag = &(ptr->next);
@@ -483,7 +497,7 @@ gnm_gtk_print_cell_range (cairo_t *context,
 				if (!gnm_cell_is_empty (cell))
 					print_cell_gtk (cell, context, x, y,
 							ci->size_pts * hscale,
-							ri->size_pts, -1.);
+							ri->size_pts, -1., pinfo);
 
 			/* Only draw spaning cells after all the backgrounds
 			 * that we are going to draw have been drawn.  No need
@@ -529,7 +543,7 @@ gnm_gtk_print_cell_range (cairo_t *context,
 
 				print_cell_gtk (cell, context,
 						real_x, y, tmp_width, ri->size_pts,
-						center_offset);
+						center_offset, pinfo);
 			} else if (col != span->left)
 				sr.vertical [col] = NULL;
 
diff --git a/src/print-cell.h b/src/print-cell.h
index 9efc383..7cd3d08 100644
--- a/src/print-cell.h
+++ b/src/print-cell.h
@@ -3,6 +3,7 @@
 # define _GNM_PRINT_CELL_H_
 
 #include "gnumeric.h"
+#include "print-info.h"
 #include <cairo.h>
 #include <gtk/gtk.h>
 
@@ -11,7 +12,7 @@ G_BEGIN_DECLS
 void gnm_gtk_print_cell_range (cairo_t *context,
 			       Sheet const *sheet, GnmRange *range,
 			       double base_x, double base_y,
-			       gboolean hide_grid);
+			       PrintInformation const *pinfo);
 
 G_END_DECLS
 
diff --git a/src/print.c b/src/print.c
index 85e5cfd..2bde8d1 100644
--- a/src/print.c
+++ b/src/print.c
@@ -196,13 +196,14 @@ gnm_print_sheet_objects (cairo_t *cr,
 }
 
 static void
-print_page_cells (GtkPrintContext   *context, PrintingInstance * pi,
+print_page_cells (G_GNUC_UNUSED GtkPrintContext   *context, 
+		  G_GNUC_UNUSED PrintingInstance * pi,
 		  cairo_t *cr, Sheet const *sheet, GnmRange *range,
 		  double base_x, double base_y)
-{	PrintInformation const *pinfo = sheet->print_info;
-
+{
 	gnm_gtk_print_cell_range (cr, sheet, range,
-				  base_x, base_y, !pinfo->print_grid_lines);
+				  base_x, base_y,
+				  (PrintInformation const *) sheet->print_info);
 	gnm_print_sheet_objects (cr, sheet, range, base_x, base_y);
 }
 
@@ -239,9 +240,10 @@ print_header_gtk (GtkPrintContext   *context, cairo_t *cr,
 }
 
 static void
-print_page_col_headers (GtkPrintContext   *context, PrintingInstance * pi,
-		  cairo_t *cr, Sheet const *sheet, GnmRange *range,
-		  double row_header_width, double col_header_height)
+print_page_col_headers (GtkPrintContext   *context, 
+			G_GNUC_UNUSED PrintingInstance * pi,
+			cairo_t *cr, Sheet const *sheet, GnmRange *range,
+			double row_header_width, double col_header_height)
 {
 	int start_col, end_col;
 	int col;
@@ -281,9 +283,10 @@ print_page_col_headers (GtkPrintContext   *context, PrintingInstance * pi,
 }
 
 static void
-print_page_row_headers (GtkPrintContext   *context, PrintingInstance * pi,
-		  cairo_t *cr, Sheet const *sheet, GnmRange *range,
-		  double row_header_width, double col_header_height)
+print_page_row_headers (GtkPrintContext *context, 
+			G_GNUC_UNUSED PrintingInstance * pi,
+			cairo_t *cr, Sheet const *sheet, GnmRange *range,
+			double row_header_width, double col_header_height)
 {
 	int start_row, end_row;
 	int row;
@@ -349,7 +352,8 @@ ensure_decoration_layout (GtkPrintContext *context)
  * the rectangle.
  */
 static void
-print_hf_element (GtkPrintContext   *context, cairo_t *cr, Sheet const *sheet,
+print_hf_element (GtkPrintContext *context, cairo_t *cr, 
+		  G_GNUC_UNUSED Sheet const *sheet,
 		  char const *format,
 		  PangoAlignment side, gdouble width, gboolean align_bottom,
 		  HFRenderInfo *hfi)
@@ -417,7 +421,7 @@ print_hf_line (GtkPrintContext   *context, cairo_t *cr, Sheet const *sheet,
  * regular flow.
  */
 static gboolean
-print_page (GtkPrintOperation *operation,
+print_page (G_GNUC_UNUSED GtkPrintOperation *operation,
 	    GtkPrintContext   *context,
 	    PrintingInstance * pi,
 	    SheetPageRange *gsr)
@@ -1043,7 +1047,7 @@ compute_sheet_pages (GtkPrintContext   *context,
  * print request.
  */
 static void
-compute_pages (GtkPrintOperation *operation,
+compute_pages (G_GNUC_UNUSED GtkPrintOperation *operation,
 	       PrintingInstance * pi,
 	       PrintRange pr,
 	       guint from,
@@ -1188,7 +1192,7 @@ gnm_paginate_cb (GtkPrintOperation *operation,
 
 static void
 gnm_begin_print_cb (GtkPrintOperation *operation,
-                    GtkPrintContext   *context,
+                    G_GNUC_UNUSED GtkPrintContext   *context,
 		    gpointer           user_data)
 {
 	PrintingInstance * pi = (PrintingInstance *) user_data;
@@ -1228,8 +1232,8 @@ gnm_begin_print_cb (GtkPrintOperation *operation,
 }
 
 static void
-gnm_end_print_cb (GtkPrintOperation *operation,
-                  GtkPrintContext   *context,
+gnm_end_print_cb (G_GNUC_UNUSED GtkPrintOperation *operation,
+                  G_GNUC_UNUSED GtkPrintContext   *context,
                   gpointer           user_data)
 {
 	PrintingInstance * pi = (PrintingInstance *) user_data;
@@ -1253,7 +1257,7 @@ cp_gtk_page_setup (GtkPageSetup *from, GtkPageSetup *to)
 
 static void
 gnm_request_page_setup_cb (GtkPrintOperation *operation,
-                           GtkPrintContext   *context,
+                           G_GNUC_UNUSED GtkPrintContext   *context,
 			   gint               page_nr,
 			   GtkPageSetup      *setup,
 			   gpointer           user_data)
@@ -1486,9 +1490,9 @@ gnm_create_widget_cb (GtkPrintOperation *operation, gpointer user_data)
 }
 
 static void
-gnm_custom_widget_apply_cb (GtkPrintOperation *operation,
-			    GtkWidget         *widget,
-			    gpointer           user_data)
+gnm_custom_widget_apply_cb (GtkPrintOperation       *operation,
+			    G_GNUC_UNUSED GtkWidget *widget,
+			    gpointer                 user_data)
 {
 	PrintingInstance * pi = (PrintingInstance *) user_data;
 	GtkPrintSettings * settings;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]