Commit 42e62f53 authored by Michael Meeks's avatar Michael Meeks Committed by Michael Meeks
Browse files

More print work; #ifdef out all bonobo-print work.

More print work;
#ifdef out all bonobo-print work.

2000-04-09  Michael Meeks  <michael@helixcode.com>

	* src/sheet-object-bonobo.c (sheet_object_bonobo_class_init): add print
	hooks.

	* src/sheet-object-graphic.c (sheet_object_graphic_print): implement.
	(sheet_object_graphic_class_init): setup print method

	* src/print.c (print_page_object): implement.
	(print_page): add hook.

	* src/sheet-object.c (sheet_object_print): implement.
	(sheet_object_class_init): setup default print behavior.

	* src/sheet-object.h: Add virtual method 'print'

	* src/dialogs/dialog-cell-format.c (fmt_dialog_init_format_page):
	free list after creation. (fmt_dialog_impl, cb_notebook_destroy):
	pass the signal id without using the FormatState that is free'd by
	the time we destroy the notebook.
parent 6a628fe4
2000-04-09 Michael Meeks <michael@helixcode.com>
* src/sheet-object-bonobo.c (sheet_object_bonobo_class_init): add print
hooks.
* src/sheet-object-graphic.c (sheet_object_graphic_print): implement.
(sheet_object_graphic_class_init): setup print method
2000-04-09 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-cell-format.c : Do not change the target style if
......
2000-04-09 Michael Meeks <michael@helixcode.com>
* src/sheet-object-bonobo.c (sheet_object_bonobo_class_init): add print
hooks.
* src/sheet-object-graphic.c (sheet_object_graphic_print): implement.
(sheet_object_graphic_class_init): setup print method
2000-04-09 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-cell-format.c : Do not change the target style if
......
2000-04-09 Michael Meeks <michael@helixcode.com>
* src/sheet-object-bonobo.c (sheet_object_bonobo_class_init): add print
hooks.
* src/sheet-object-graphic.c (sheet_object_graphic_print): implement.
(sheet_object_graphic_class_init): setup print method
2000-04-09 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-cell-format.c : Do not change the target style if
......
2000-04-09 Michael Meeks <michael@helixcode.com>
* src/sheet-object-bonobo.c (sheet_object_bonobo_class_init): add print
hooks.
* src/sheet-object-graphic.c (sheet_object_graphic_print): implement.
(sheet_object_graphic_class_init): setup print method
2000-04-09 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-cell-format.c : Do not change the target style if
......
2000-04-09 Michael Meeks <michael@helixcode.com>
* src/sheet-object-bonobo.c (sheet_object_bonobo_class_init): add print
hooks.
* src/sheet-object-graphic.c (sheet_object_graphic_print): implement.
(sheet_object_graphic_class_init): setup print method
2000-04-09 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-cell-format.c : Do not change the target style if
......
2000-04-09 Michael Meeks <michael@helixcode.com>
* src/sheet-object-bonobo.c (sheet_object_bonobo_class_init): add print
hooks.
* src/sheet-object-graphic.c (sheet_object_graphic_print): implement.
(sheet_object_graphic_class_init): setup print method
2000-04-09 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-cell-format.c : Do not change the target style if
......
2000-04-09 Michael Meeks <michael@helixcode.com>
* src/sheet-object-bonobo.c (sheet_object_bonobo_class_init): add print
hooks.
* src/sheet-object-graphic.c (sheet_object_graphic_print): implement.
(sheet_object_graphic_class_init): setup print method
2000-04-09 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-cell-format.c : Do not change the target style if
......
......@@ -249,6 +249,7 @@ gnumeric_bonobo_LDADD = \
$(GNOME_XML_LIB) \
$(GUILE_LIBS) \
$(INTLLIBS)
# -lbonobo-print \
wc:
wc -l $(gnumeric_SOURCES)
......
......@@ -168,7 +168,7 @@ print_page_cells (Sheet *sheet,
base_x, base_y, TRUE);
}
#ifdef ENABLE_BONOBO
#ifdef ENABLE_BONOBO_PRINT
static void
print_page_object (SheetObject *so,
int start_col, int start_row, int end_col, int end_row,
......@@ -176,33 +176,32 @@ print_page_object (SheetObject *so,
PrintJobInfo *pj)
{
SheetObjectPrintInfo so_pi;
double tlx, tly, brx, bry;
double canvas_x, canvas_y;
g_return_if_fail (pj != NULL);
g_return_if_fail (so != NULL);
base_y = pj->height - base_y;
g_warning ("FIXME: we need some cunning maths here");
so_pi.pc = pj->print_context;
so_pi.pi = pj->pi;
sheet_object_get_bounds (so, &tlx, &tly, &brx, &bry);
canvas_x = sheet_col_get_distance_pts (so->sheet, 0, start_col);
canvas_y = sheet_row_get_distance_pts (so->sheet, 0, start_row);
if (tlx - canvas_x < 0 ||
/* if (tlx - canvas_x < 0 ||
tly - canvas_y < 0) {
g_warning ("Object needs scissoring (%g, %g %g, %g) (%g, %g)",
g_warning ("Object out of range (%g, %g %g, %g) (%g, %g)",
tlx, tly, brx, bry, canvas_x, canvas_y);
return;
}
so_pi.x = tlx - canvas_x;
so_pi.y = tly - canvas_y;
so_pi.width = brx - tlx;
so_pi.height = bry - tly;
}*/
/* FIXME: this maths is a quick hack; sorry */
so_pi.x = sheet_col_get_distance_pts (so->sheet, 0, start_col);
so_pi.y = sheet_row_get_distance_pts (so->sheet, 0, start_row);
so_pi.width = sheet_col_get_distance_pts (so->sheet, start_col, end_col + 1);
so_pi.height = sheet_row_get_distance_pts (so->sheet, start_row, end_row + 1);
so_pi.print_x = base_x;
so_pi.print_y = base_y;
/* Canvas -> print */
so_pi.print_x_scale = print_width / so_pi.width;
so_pi.print_y_scale = print_height / so_pi.height;
/*
* We calculate the bounds of the page in canvas co-ordinates and
......@@ -425,7 +424,7 @@ print_page (Sheet *sheet, int start_col, int start_row, int end_col, int end_row
sheet, start_col, start_row, end_col, end_row,
x, y, print_width, print_height, pj);
#ifdef ENABLE_BONOBO
#ifdef ENABLE_BONOBO_PRINT
/*
* Print objects
*/
......
......@@ -196,13 +196,51 @@ sheet_object_bonobo_load (SheetObjectBonobo *sob,
return TRUE;
}
#ifdef ENABLE_BONOBO_PRINT
static void
sheet_object_bonobo_print (SheetObject *so, SheetObjectPrintInfo *pi)
{
SheetObjectBonobo *sob = SHEET_OBJECT_BONOBO (so);
double tlx, tly, brx, bry;
BonoboPrintClient *bpc;
BonoboPrintContext *pc;
bpc = bonobo_print_client_get (sob->object_server);
if (!bpc) {
static gboolean warned = FALSE;
if (!warned)
g_warning ("Some bonobo objects are not printable");
warned = TRUE;
return;
}
/* Gnome print uses a strange co-ordinate system */
sheet_object_get_bounds (so, &tlx, &tly, &brx, &bry);
pc = bonobo_print_context_new (
pi->print_x + (tlx - pi->x) * pi->print_x_scale,
pi->print_y - (bry - pi->y) * pi->print_y_scale,
pi->print_x + (brx - pi->x) * pi->print_x_scale,
pi->print_y - (tly - pi->y) * pi->print_y_scale);
bonobo_print_client_print_to (bpc, pc, pi->pc);
bonobo_print_context_free (pc);
}
#endif
static void
sheet_object_bonobo_class_init (GtkObjectClass *object_class)
{
SheetObjectClass *sheet_object_class = SHEET_OBJECT_CLASS (object_class);
sheet_object_bonobo_parent_class = gtk_type_class (sheet_object_get_type ());
/* Object class method overrides */
object_class->destroy = sheet_object_bonobo_destroy;
#ifdef ENABLE_BONOBO_PRINT
sheet_object_class->print = sheet_object_bonobo_print;
#endif
}
GtkType
......
......@@ -7,6 +7,7 @@
#include <config.h>
#include <gnome.h>
#include <gdk/gdkkeysyms.h>
#include <libgnomeprint/gnome-print.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "dialogs.h"
......@@ -24,6 +25,37 @@ sheet_object_graphic_destroy (GtkObject *object)
GTK_OBJECT_CLASS (sheet_object_graphic_parent_class)->destroy (object);
}
static void
sheet_object_graphic_print (SheetObject *so, SheetObjectPrintInfo *pi)
{
double x, y;
if (so->type == SHEET_OBJECT_ARROW) {
static gboolean warned = FALSE;
g_warning ("FIXME: I print arrows as lines");
warned = TRUE;
}
/* Gnome print uses a strange co-ordinate system */
gnome_print_gsave (pi->pc);
x = so->bbox_points->coords [0];
y = so->bbox_points->coords [1];
gnome_print_moveto (pi->pc,
pi->print_x + (x - pi->x) * pi->print_x_scale,
pi->print_y - (y - pi->y) * pi->print_y_scale);
x = so->bbox_points->coords [2];
y = so->bbox_points->coords [3];
gnome_print_lineto (pi->pc,
pi->print_x + (x - pi->x) * pi->print_x_scale,
pi->print_y - (y - pi->y) * pi->print_y_scale);
gnome_print_stroke (pi->pc);
gnome_print_grestore (pi->pc);
}
static GnomeCanvasItem *
sheet_object_graphic_realize (SheetObject *so, SheetView *sheet_view)
{
......@@ -77,6 +109,7 @@ sheet_object_graphic_class_init (GtkObjectClass *object_class)
/* SheetObject class method overrides */
sheet_object_class->realize = sheet_object_graphic_realize;
sheet_object_class->print = sheet_object_graphic_print;
}
GtkType
......
......@@ -35,11 +35,17 @@ typedef struct {
typedef struct {
GnomePrintContext *pc;
PrintInformation *pi;
/* Dimensions of the page in canvas co-ordinates */
/* Dimensions of the object in canvas co-ordinates */
double x;
double y;
double width;
double height;
/* Offset into the page to print at */
double print_x;
double print_y;
/* Width & height scaling factors */
double print_x_scale;
double print_y_scale;
} SheetObjectPrintInfo;
typedef struct {
......
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