gnumeric r16855 - in trunk: . component src



Author: jbrefort
Date: Sat Oct  4 15:51:47 2008
New Revision: 16855
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16855&view=rev

Log:
2008-10-04  Jean Brefort  <jean brefort normalesup org>

	* component/gnumeric.c: render sheet objects using
	gnm_print_sheet_objects, and fixed cap for cell borders.
	* src/print-cell.c: removed the unused GtkPrintContext* argument.
	* src/print-cell.h: ditto.
	* src/print.c: renamed print_sheet_objects to gnm_print_sheet_objects,
	made it public, removed the unused GtkPrintContext* argument, and
	fixed objects position in layout (#554993).
	* src/print.h: ditto.



Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/component/gnumeric.c
   trunk/src/print-cell.c
   trunk/src/print-cell.h
   trunk/src/print.c
   trunk/src/print.h

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Sat Oct  4 15:51:47 2008
@@ -28,6 +28,7 @@
 Jean:
 	* Fix printing of rotated text. [#539734]
 	* Fix leakage in histogram tool. [#552596]
+	* Fix horizontal position of sheet objects in print. [#554993]
 	* Reimplemented the goffice component.
 
 Jody:

Modified: trunk/component/gnumeric.c
==============================================================================
--- trunk/component/gnumeric.c	(original)
+++ trunk/component/gnumeric.c	Sat Oct  4 15:51:47 2008
@@ -167,30 +167,15 @@
 	SheetObjectAnchor const *anchor;
 
 	range_init (&range, gognm->col_start, gognm->row_start, gognm->col_end, gognm->row_end);
+	cairo_save (cr);
+	cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
 	cairo_scale (cr, ((double) width_pixels) / gognm->width, ((double) height_pixels) / gognm->height);
-	gnm_gtk_print_cell_range (NULL, cr, gognm->sheet, &range, 0., 0., TRUE);
+	cairo_rectangle (cr, 0., 0., gognm->width, gognm->height);
+	cairo_clip (cr); /* not sure it is necessary */
+	gnm_gtk_print_cell_range (cr, gognm->sheet, &range, 0., 0., TRUE);
 	/* Now render objects */
-	l = gognm->sheet->sheet_objects;
-	while (l) {
-		so = SHEET_OBJECT (l->data);
-		anchor = sheet_object_get_anchor (so);
-		/* test if the object overlaps the exposed range */
-		if ((anchor->cell_bound.start.col <= gognm->col_end) &&
-			(anchor->cell_bound.end.col >= gognm->col_start) &&
-			(anchor->cell_bound.start.row <= gognm->row_end) &&
-			(anchor->cell_bound.end.row >= gognm->row_start)) {
-			/* translate the origin to start cell of object */
-			xoffset = sheet_col_get_distance_pts (gognm->sheet, gognm->col_start,
-				anchor->cell_bound.start.col);
-			yoffset = sheet_row_get_distance_pts (gognm->sheet, gognm->row_start,
-				anchor->cell_bound.start.row);
-			cairo_save (cr);
-			cairo_translate (cr, xoffset, yoffset);
-			sheet_object_draw_cairo (so, cr, TRUE);
-			cairo_restore (cr);
-		}
-		l = l->next;
-	}
+	gnm_print_sheet_objects (cr, gognm->sheet, &range, 0., 0.);
+	cairo_restore (cr);
 }
 
 static void

Modified: trunk/src/print-cell.c
==============================================================================
--- trunk/src/print-cell.c	(original)
+++ trunk/src/print-cell.c	Sat Oct  4 15:51:47 2008
@@ -256,7 +256,7 @@
 
 
 void
-gnm_gtk_print_cell_range (GtkPrintContext *print_context, cairo_t *context,
+gnm_gtk_print_cell_range (cairo_t *context,
 			  Sheet const *sheet, GnmRange *range,
 			  double base_x, double base_y,
 			  gboolean hide_grid)

Modified: trunk/src/print-cell.h
==============================================================================
--- trunk/src/print-cell.h	(original)
+++ trunk/src/print-cell.h	Sat Oct  4 15:51:47 2008
@@ -8,8 +8,7 @@
 
 G_BEGIN_DECLS
 
-void gnm_gtk_print_cell_range (GtkPrintContext *print_context,
-			       cairo_t *context,
+void gnm_gtk_print_cell_range (cairo_t *context,
 			       Sheet const *sheet, GnmRange *range,
 			       double base_x, double base_y,
 			       gboolean hide_grid);

Modified: trunk/src/print.c
==============================================================================
--- trunk/src/print.c	(original)
+++ trunk/src/print.c	Sat Oct  4 15:51:47 2008
@@ -118,18 +118,16 @@
 	g_free (pi);
 }
 
-static void
-print_sheet_objects (GtkPrintContext   *context,
-		     cairo_t *cr,
-		     Sheet const *sheet,
-		     GnmRange *range,
-		     double base_x, double base_y)
+void
+gnm_print_sheet_objects (cairo_t *cr,
+			 Sheet const *sheet,
+			 GnmRange *range,
+			 double base_x, double base_y)
 {
 	GSList *ptr, *objects;
 	double width, height;
 
 	g_return_if_fail (IS_SHEET (sheet));
-	g_return_if_fail (context != NULL);
 	g_return_if_fail (cr != NULL);
 	g_return_if_fail (range != NULL);
 
@@ -164,22 +162,22 @@
 		/* move to top left */
 		if (sheet->text_is_rtl) {
 			double tr_x, tr_y;
-			tr_x =  base_x
+			tr_x =  base_x - 0.5 /* because of leading gridline */
 				- sheet_col_get_distance_pts (sheet, 0, r->end.col+1)
 				+ sheet_col_get_distance_pts (sheet, 0,
 							      range->start.col);
-			tr_y = - base_y
+			tr_y =  base_y + 0.5
 				+ sheet_row_get_distance_pts (sheet, 0, r->start.row)
 				- sheet_row_get_distance_pts (sheet, 0,
 							      range->start.row);
 			cairo_translate (cr, tr_x, tr_y);
 		} else
 			cairo_translate (cr,
-					 - base_x
+					 base_x + 0.5
 					 + sheet_col_get_distance_pts (sheet, 0, r->start.col)
 					 - sheet_col_get_distance_pts (sheet, 0,
 								       range->start.col),
-					 - base_y
+					 base_y + 0.5
 					 + sheet_row_get_distance_pts (sheet, 0, r->start.row)
 					 - sheet_row_get_distance_pts (sheet, 0,
 								       range->start.row));
@@ -199,9 +197,9 @@
 		  double base_x, double base_y)
 {	PrintInformation const *pinfo = sheet->print_info;
 
-	gnm_gtk_print_cell_range (context, cr, sheet, range,
+	gnm_gtk_print_cell_range (cr, sheet, range,
 				  base_x, base_y, !pinfo->print_grid_lines);
-	print_sheet_objects (context, cr, sheet, range, base_x, base_y);
+	gnm_print_sheet_objects (cr, sheet, range, base_x, base_y);
 }
 
 static void

Modified: trunk/src/print.h
==============================================================================
--- trunk/src/print.h	(original)
+++ trunk/src/print.h	Sat Oct  4 15:51:47 2008
@@ -4,6 +4,7 @@
 
 #include "gnumeric.h"
 #include <gsf/gsf-output.h>
+#include <cairo.h>
 
 G_BEGIN_DECLS
 
@@ -25,6 +26,11 @@
 		      gboolean preview, PrintRange default_range,
 		      GsfOutput *export_dst);
 
+void gnm_print_sheet_objects (cairo_t *cr,
+			      Sheet const *sheet,
+			      GnmRange *range,
+			      double base_x, double base_y);
+
 /* Internal */
 extern gboolean gnm_print_debug;
 



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