Commit 186b3aa9 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

Save the repeat ranges routine. (print_info_save): Save the repeat ranges.

1999-06-29  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/print-info.c (save_range): Save the repeat ranges routine.
	(print_info_save): Save the repeat ranges.

	* src/expr.c (value_cellrange_get_as_string): Implemented.
	(value_get_as_string): Expanded to render cellranges.

	* src/print-info.c (load_range): New routine, loads a range from
	the config file.

	* src/print.c (print_sheet_range): off-by-one error fix.
parent 8895c282
1999-06-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/print-info.c (save_range): Save the repeat ranges routine.
(print_info_save): Save the repeat ranges.
* src/expr.c (value_cellrange_get_as_string): Implemented.
(value_get_as_string): Expanded to render cellranges.
* src/print-info.c (load_range): New routine, loads a range from
the config file.
* src/print.c (print_sheet_range): off-by-one error fix.
1999-06-29 Jukka-Pekka Iivonen <iivonen@iki.fi>
* samples/textfuns.xls: Added a new test file.
......
1999-06-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/print-info.c (save_range): Save the repeat ranges routine.
(print_info_save): Save the repeat ranges.
* src/expr.c (value_cellrange_get_as_string): Implemented.
(value_get_as_string): Expanded to render cellranges.
* src/print-info.c (load_range): New routine, loads a range from
the config file.
* src/print.c (print_sheet_range): off-by-one error fix.
1999-06-29 Jukka-Pekka Iivonen <iivonen@iki.fi>
* samples/textfuns.xls: Added a new test file.
......
1999-06-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/print-info.c (save_range): Save the repeat ranges routine.
(print_info_save): Save the repeat ranges.
* src/expr.c (value_cellrange_get_as_string): Implemented.
(value_get_as_string): Expanded to render cellranges.
* src/print-info.c (load_range): New routine, loads a range from
the config file.
* src/print.c (print_sheet_range): off-by-one error fix.
1999-06-29 Jukka-Pekka Iivonen <iivonen@iki.fi>
* samples/textfuns.xls: Added a new test file.
......
1999-06-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/print-info.c (save_range): Save the repeat ranges routine.
(print_info_save): Save the repeat ranges.
* src/expr.c (value_cellrange_get_as_string): Implemented.
(value_get_as_string): Expanded to render cellranges.
* src/print-info.c (load_range): New routine, loads a range from
the config file.
* src/print.c (print_sheet_range): off-by-one error fix.
1999-06-29 Jukka-Pekka Iivonen <iivonen@iki.fi>
* samples/textfuns.xls: Added a new test file.
......
......@@ -327,6 +327,12 @@ display_order_icon (GtkToggleButton *toggle, dialog_print_info_t *dpi)
gtk_widget_hide (hide);
}
static gboolean
is_range_empty (const Value *v)
{
return (v->v.cell_range.cell_a.col == -1);
}
static void
do_setup_page_info (dialog_print_info_t *dpi)
{
......@@ -335,6 +341,7 @@ do_setup_page_info (dialog_print_info_t *dpi)
GtkWidget *titles = glade_xml_get_widget (dpi->gui, "check-print-titles");
GtkWidget *order = glade_xml_get_widget (dpi->gui, "radio-order-right");
GtkWidget *table = glade_xml_get_widget (dpi->gui, "page-order-table");
GtkEntry *entry_top, *entry_left;
dpi->icon_rd = load_image ("right-down.png");
dpi->icon_dr = load_image ("down-right.png");
......@@ -349,7 +356,7 @@ do_setup_page_info (dialog_print_info_t *dpi)
GTK_TABLE (table), dpi->icon_dr,
1, 2, 0, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
gtk_signal_connect (GTK_OBJECT (order), "toggle", GTK_SIGNAL_FUNC(display_order_icon), dpi);
gtk_signal_connect (GTK_OBJECT (order), "toggled", GTK_SIGNAL_FUNC(display_order_icon), dpi);
if (dpi->pi->print_line_divisions)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (divisions), TRUE);
......@@ -360,8 +367,26 @@ do_setup_page_info (dialog_print_info_t *dpi)
if (dpi->pi->print_titles)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (titles), TRUE);
if (dpi->pi->print_order)
if (dpi->pi->print_order == PRINT_ORDER_DOWN_THEN_RIGHT)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (order), TRUE);
if (!is_range_empty (&dpi->pi->repeat_top_range)){
char *s;
entry_top = GTK_ENTRY (glade_xml_get_widget (dpi->gui, "repeat-rows-entry"));
s = value_cellrange_get_as_string (&dpi->pi->repeat_top_range, FALSE);
gtk_entry_set_text (entry_top, s);
g_free (s);
}
if (!is_range_empty (&dpi->pi->repeat_left_range)){
char *s;
entry_left = GTK_ENTRY (glade_xml_get_widget (dpi->gui, "repeat-cols-entry"));
s = value_cellrange_get_as_string (&dpi->pi->repeat_left_range, FALSE);
gtk_entry_set_text (entry_left, s);
g_free (s);
}
}
static void
......@@ -516,7 +541,7 @@ dialog_print_info_new (Workbook *wb)
return NULL;
}
dpi = g_new (dialog_print_info_t, 1);
dpi = g_new0 (dialog_print_info_t, 1);
dpi->workbook = wb;
dpi->gui = gui;
dpi->pi = wb->print_info;
......@@ -605,9 +630,11 @@ do_fetch_hf (dialog_print_info_t *dpi)
static void
do_fetch_page_info (dialog_print_info_t *dpi)
{
{
GtkToggleButton *t;
Value top_range, left_range;
GtkEntry *entry_top, *entry_left;
t = GTK_TOGGLE_BUTTON (glade_xml_get_widget (dpi->gui, "check-print-divisions"));
dpi->pi->print_line_divisions = t->active;
......@@ -618,7 +645,16 @@ do_fetch_page_info (dialog_print_info_t *dpi)
dpi->pi->print_titles = t->active;
t = GTK_TOGGLE_BUTTON (glade_xml_get_widget (dpi->gui, "radio-order-right"));
dpi->pi->print_order = t->active;
dpi->pi->print_order = t->active ? PRINT_ORDER_RIGHT_THEN_DOWN : PRINT_ORDER_DOWN_THEN_RIGHT;
entry_top = GTK_ENTRY (glade_xml_get_widget (dpi->gui, "repeat-rows-entry"));
entry_left = GTK_ENTRY (glade_xml_get_widget (dpi->gui, "repeat-cols-entry"));
if (range_parse (NULL, gtk_entry_get_text (entry_top), &top_range))
dpi->pi->repeat_top_range = top_range;
if (range_parse (NULL, gtk_entry_get_text (entry_left), &left_range))
dpi->pi->repeat_left_range = left_range;
}
static void
......
......@@ -327,6 +327,12 @@ display_order_icon (GtkToggleButton *toggle, dialog_print_info_t *dpi)
gtk_widget_hide (hide);
}
static gboolean
is_range_empty (const Value *v)
{
return (v->v.cell_range.cell_a.col == -1);
}
static void
do_setup_page_info (dialog_print_info_t *dpi)
{
......@@ -335,6 +341,7 @@ do_setup_page_info (dialog_print_info_t *dpi)
GtkWidget *titles = glade_xml_get_widget (dpi->gui, "check-print-titles");
GtkWidget *order = glade_xml_get_widget (dpi->gui, "radio-order-right");
GtkWidget *table = glade_xml_get_widget (dpi->gui, "page-order-table");
GtkEntry *entry_top, *entry_left;
dpi->icon_rd = load_image ("right-down.png");
dpi->icon_dr = load_image ("down-right.png");
......@@ -349,7 +356,7 @@ do_setup_page_info (dialog_print_info_t *dpi)
GTK_TABLE (table), dpi->icon_dr,
1, 2, 0, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
gtk_signal_connect (GTK_OBJECT (order), "toggle", GTK_SIGNAL_FUNC(display_order_icon), dpi);
gtk_signal_connect (GTK_OBJECT (order), "toggled", GTK_SIGNAL_FUNC(display_order_icon), dpi);
if (dpi->pi->print_line_divisions)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (divisions), TRUE);
......@@ -360,8 +367,26 @@ do_setup_page_info (dialog_print_info_t *dpi)
if (dpi->pi->print_titles)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (titles), TRUE);
if (dpi->pi->print_order)
if (dpi->pi->print_order == PRINT_ORDER_DOWN_THEN_RIGHT)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (order), TRUE);
if (!is_range_empty (&dpi->pi->repeat_top_range)){
char *s;
entry_top = GTK_ENTRY (glade_xml_get_widget (dpi->gui, "repeat-rows-entry"));
s = value_cellrange_get_as_string (&dpi->pi->repeat_top_range, FALSE);
gtk_entry_set_text (entry_top, s);
g_free (s);
}
if (!is_range_empty (&dpi->pi->repeat_left_range)){
char *s;
entry_left = GTK_ENTRY (glade_xml_get_widget (dpi->gui, "repeat-cols-entry"));
s = value_cellrange_get_as_string (&dpi->pi->repeat_left_range, FALSE);
gtk_entry_set_text (entry_left, s);
g_free (s);
}
}
static void
......@@ -516,7 +541,7 @@ dialog_print_info_new (Workbook *wb)
return NULL;
}
dpi = g_new (dialog_print_info_t, 1);
dpi = g_new0 (dialog_print_info_t, 1);
dpi->workbook = wb;
dpi->gui = gui;
dpi->pi = wb->print_info;
......@@ -605,9 +630,11 @@ do_fetch_hf (dialog_print_info_t *dpi)
static void
do_fetch_page_info (dialog_print_info_t *dpi)
{
{
GtkToggleButton *t;
Value top_range, left_range;
GtkEntry *entry_top, *entry_left;
t = GTK_TOGGLE_BUTTON (glade_xml_get_widget (dpi->gui, "check-print-divisions"));
dpi->pi->print_line_divisions = t->active;
......@@ -618,7 +645,16 @@ do_fetch_page_info (dialog_print_info_t *dpi)
dpi->pi->print_titles = t->active;
t = GTK_TOGGLE_BUTTON (glade_xml_get_widget (dpi->gui, "radio-order-right"));
dpi->pi->print_order = t->active;
dpi->pi->print_order = t->active ? PRINT_ORDER_RIGHT_THEN_DOWN : PRINT_ORDER_DOWN_THEN_RIGHT;
entry_top = GTK_ENTRY (glade_xml_get_widget (dpi->gui, "repeat-rows-entry"));
entry_left = GTK_ENTRY (glade_xml_get_widget (dpi->gui, "repeat-cols-entry"));
if (range_parse (NULL, gtk_entry_get_text (entry_top), &top_range))
dpi->pi->repeat_top_range = top_range;
if (range_parse (NULL, gtk_entry_get_text (entry_left), &left_range))
dpi->pi->repeat_left_range = left_range;
}
static void
......
......@@ -1367,7 +1367,7 @@
<widget>
<class>GtkEntry</class>
<name>entry5</name>
<name>repeat-rows-entry</name>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
......@@ -1391,7 +1391,7 @@
<widget>
<class>GtkEntry</class>
<name>entry6</name>
<name>repeat-cols-entry</name>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
......
......@@ -395,6 +395,57 @@ expr_tree_unref (ExprTree *tree)
do_expr_tree_unref (tree);
}
static void
encode_cellref (GString *dest, const CellRef *ref, gboolean use_relative_syntax)
{
if (ref->sheet){
g_string_append_c (dest, '\'');
g_string_append (dest, ref->sheet->name);
g_string_append (dest, "'!");
}
if (use_relative_syntax && !ref->col_relative)
g_string_append_c (dest, '$');
g_string_append (dest, col_name (ref->col));
if (use_relative_syntax && !ref->row_relative)
g_string_append_c (dest, '$');
g_string_sprintfa (dest, "%d", ref->row+1);
}
/*
* value_cellrange_get_as_string:
* @value: a value containing a VALUE_CELLRANGE
* @use_relative_syntax: true if you want the result to contain relative indicators
*
* Returns: a string reprensenting the Value, for example:
* use_relative_syntax == TRUE: $a4:$b$1
* use_relative_syntax == FALSE: a4:b1
*/
char *
value_cellrange_get_as_string (const Value *value, gboolean use_relative_syntax)
{
GString *str;
char *ans;
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (value->type == VALUE_CELLRANGE, NULL);
str = g_string_new ("");
encode_cellref (str, &value->v.cell_range.cell_a, use_relative_syntax);
if ((value->v.cell_range.cell_a.col != value->v.cell_range.cell_b.col) ||
(value->v.cell_range.cell_a.row != value->v.cell_range.cell_b.row) ||
(value->v.cell_range.cell_a.col_relative != value->v.cell_range.cell_b.col_relative) ||
(value->v.cell_range.cell_a.sheet != value->v.cell_range.cell_b.sheet)){
g_string_append_c (str, ':');
encode_cellref (str, &value->v.cell_range.cell_b, use_relative_syntax);
}
ans = str->str;
g_string_free (str, FALSE);
return ans;
}
/*
* simplistic value rendering
*/
......@@ -442,8 +493,9 @@ value_get_as_string (const Value *value)
return ans;
}
case VALUE_CELLRANGE:
break;
case VALUE_CELLRANGE:
return value_cellrange_get_as_string (value, TRUE);
default:
g_warning ("value_string problem\n");
break;
......
......@@ -261,6 +261,9 @@ int value_get_as_bool (const Value *v, int *err);
float_t value_get_as_float (const Value *v);
int value_get_as_int (const Value *v);
char *value_get_as_string (const Value *value);
char *value_cellrange_get_as_string
(const Value *value,
gboolean use_relative_syntax);
void value_dump (const Value *value);
......
......@@ -434,8 +434,10 @@ print_cell_grid (GnomePrintContext *context,
g_return_if_fail (start_col < end_col);
g_return_if_fail (start_row < end_row);
printf ("Range: %d %d - %d %d\n", start_col, start_row, end_col, end_row);
gnome_print_setlinewidth (context, 0.5);
end_col++;
end_row++;
x = base_x;
for (col = start_col; col <= end_col; col++){
......
......@@ -10,6 +10,7 @@
#include <gnome.h>
#include <stdio.h>
#include "gnumeric.h"
#include "ranges.h"
#include "print-info.h"
PrintHF *
......@@ -97,6 +98,37 @@ load_hf (const char *type, const char *a, const char *b, const char *c)
return format;
}
static void
init_invalid_range (Value *v)
{
v->type = VALUE_CELLRANGE;
v->v.cell_range.cell_a.sheet = NULL;
v->v.cell_range.cell_b.sheet = NULL;
v->v.cell_range.cell_a.col = -1;
v->v.cell_range.cell_a.row = -1;
v->v.cell_range.cell_b.col = -1;
v->v.cell_range.cell_b.row = -1;
}
static const Value *
load_range (const char *name)
{
static Value v;
char *str;
str = gnome_config_get_string (name);
if (!str){
init_invalid_range (&v);
return &v;
}
if (!range_parse (NULL, str, &v))
init_invalid_range (&v);
g_free (str);
return &v;
}
#define CENTIMETER_IN_POINTS "28.346457"
#define HALF_CENTIMETER_IN_POINTS "14.1732285"
......@@ -149,13 +181,20 @@ print_info_new (void)
pi->paper = gnome_paper_with_name (gnome_paper_name_default ());
g_free (s);
pi->center_horizontally = gnome_config_get_bool ("center_horizontally");
pi->center_vertically = gnome_config_get_bool ("center_vertically");
pi->print_line_divisions = gnome_config_get_bool ("print_divisions");
pi->print_black_and_white = gnome_config_get_bool ("print_black_and_white");
pi->print_titles = gnome_config_get_bool ("print_titles");
pi->print_order = gnome_config_get_bool ("order_right");
pi->center_horizontally = gnome_config_get_bool ("center_horizontally=false");
pi->center_vertically = gnome_config_get_bool ("center_vertically=false");
pi->print_line_divisions = gnome_config_get_bool ("print_divisions=false");
pi->print_black_and_white = gnome_config_get_bool ("print_black_and_white=false");
pi->print_titles = gnome_config_get_bool ("print_titles=false");
if (gnome_config_get_bool ("order_right=true"))
pi->print_order = PRINT_ORDER_RIGHT_THEN_DOWN;
else
pi->print_order = PRINT_ORDER_DOWN_THEN_RIGHT;
pi->repeat_top_range = *load_range ("repeat_top_range=");
pi->repeat_left_range = *load_range ("repeat_bottom_range=");
gnome_config_pop_prefix ();
gnome_config_sync ();
......@@ -172,6 +211,20 @@ save_margin (const char *prefix, PrintUnit *p)
g_free (x);
}
static void
save_range (const char *section, Value *v)
{
if (v->v.cell_range.cell_a.col == -1)
gnome_config_set_string (section, "");
else {
char *s;
s = value_cellrange_get_as_string (v, FALSE);
gnome_config_set_string (section, s);
g_free (s);
}
}
void
print_info_save (PrintInformation *pi)
{
......@@ -198,6 +251,9 @@ print_info_save (PrintInformation *pi)
gnome_config_set_bool ("print_black_and_white", pi->print_black_and_white);
gnome_config_set_bool ("print_titles", pi->print_titles);
gnome_config_set_bool ("order_right", pi->print_order);
save_range ("repeat_top_range", &pi->repeat_top_range);
save_range ("repeat_left_range", &pi->repeat_left_range);
gnome_config_pop_prefix ();
gnome_config_sync ();
......
......@@ -73,16 +73,18 @@ struct _PrintInformation {
unsigned int print_as_draft:1;
unsigned int print_titles:1;
/*
* 0: Down, then right
* 1: Right, then down
*/
unsigned int print_order:1;
enum {
PRINT_ORDER_DOWN_THEN_RIGHT,
PRINT_ORDER_RIGHT_THEN_DOWN
} print_order;
PrintHF *header;
PrintHF *footer;
const GnomePaper *paper;
Value repeat_top_range;
Value repeat_left_range;
};
PrintInformation *print_info_new (void);
......
......@@ -75,7 +75,7 @@ print_page (Sheet *sheet, int start_col, int start_row, int end_col, int end_row
base_x = 0;
base_y = 0;
print_height = sheet_row_get_unit_distance (sheet, start_row, end_row);
print_height = sheet_row_get_unit_distance (sheet, start_row, end_row+1);
if (pj->pi->center_vertically){
if (pj->pi->print_titles)
......@@ -83,7 +83,7 @@ print_page (Sheet *sheet, int start_col, int start_row, int end_col, int end_row
base_y = (pj->y_points - print_height)/2;
}
print_width = sheet_col_get_unit_distance (sheet, start_col, end_col);
print_width = sheet_col_get_unit_distance (sheet, start_col, end_col+1);
if (pj->pi->center_horizontally){
if (pj->pi->print_titles)
print_width += sheet->default_col_style.units;
......@@ -180,7 +180,7 @@ print_sheet_range (Sheet *sheet, int start_col, int start_row, int end_col, int
cols = compute_groups (sheet, start_col, end_col, usable_x, sheet_col_get_info);
rows = compute_groups (sheet, start_row, end_row, usable_y, sheet_row_get_info);
if (pj->pi->print_order == 0){
if (pj->pi->print_order == PRINT_ORDER_DOWN_THEN_RIGHT){
int col = start_col;
for (l = cols; l; l = l->next){
......@@ -190,7 +190,7 @@ print_sheet_range (Sheet *sheet, int start_col, int start_row, int end_col, int
for (m = rows; m; m = m->next){
int row_count = GPOINTER_TO_INT (m->data);
print_page (sheet, col, row, col + col_count, row + row_count, pj);
print_page (sheet, col, row, col + col_count - 1, row + row_count - 1, pj);
row += row_count;
}
......@@ -206,7 +206,7 @@ print_sheet_range (Sheet *sheet, int start_col, int start_row, int end_col, int
for (m = cols; m; m = m->next){
int col_count = GPOINTER_TO_INT (m->data);
print_page (sheet, col, row, col + col_count, row + row_count, pj);
print_page (sheet, col, row, col + col_count - 1, row + row_count - 1, pj);
col += col_count;
}
......
......@@ -1367,7 +1367,7 @@
<widget>
<class>GtkEntry</class>
<name>entry5</name>
<name>repeat-rows-entry</name>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
......@@ -1391,7 +1391,7 @@
<widget>
<class>GtkEntry</class>
<name>entry6</name>
<name>repeat-cols-entry</name>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
......
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