Commit bf3f5fde authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa
Browse files

Keep track of the sheet->objects structure. (sheet_object_create_line,

1998-09-17  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/sheet-object.c (sheet_object_destroy): Keep track of the
	sheet->objects structure.
	(sheet_object_create_line, sheet_object_create_filled): Keep track
	of the sheet->objects structure.
	(sheet_object_realize, sheet_object_unrealize): Export these
	functions.
	(sheet_object_destroy): Keep track of the sheet->objects structure

	* src/sheet-autofill.c (autofill_cell): Implemented autofill on
	strings that contains numbers.  This allows autofill to handle
	stuff like "Product1" -> "Product2", ...
parent 68dd2a59
1998-09-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-object.c (sheet_object_destroy): Keep track of the
sheet->objects structure.
(sheet_object_create_line, sheet_object_create_filled): Keep track
of the sheet->objects structure.
(sheet_object_realize, sheet_object_unrealize): Export these
functions.
(sheet_object_destroy): Keep track of the sheet->objects structure
* src/sheet-autofill.c (autofill_cell): Implemented autofill on
strings that contains numbers. This allows autofill to handle
stuff like "Product1" -> "Product2", ...
Wed Sep 16 23:56:59 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c: started working on object saving/loading.
......
1998-09-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-object.c (sheet_object_destroy): Keep track of the
sheet->objects structure.
(sheet_object_create_line, sheet_object_create_filled): Keep track
of the sheet->objects structure.
(sheet_object_realize, sheet_object_unrealize): Export these
functions.
(sheet_object_destroy): Keep track of the sheet->objects structure
* src/sheet-autofill.c (autofill_cell): Implemented autofill on
strings that contains numbers. This allows autofill to handle
stuff like "Product1" -> "Product2", ...
Wed Sep 16 23:56:59 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c: started working on object saving/loading.
......
1998-09-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-object.c (sheet_object_destroy): Keep track of the
sheet->objects structure.
(sheet_object_create_line, sheet_object_create_filled): Keep track
of the sheet->objects structure.
(sheet_object_realize, sheet_object_unrealize): Export these
functions.
(sheet_object_destroy): Keep track of the sheet->objects structure
* src/sheet-autofill.c (autofill_cell): Implemented autofill on
strings that contains numbers. This allows autofill to handle
stuff like "Product1" -> "Product2", ...
Wed Sep 16 23:56:59 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c: started working on object saving/loading.
......
1998-09-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-object.c (sheet_object_destroy): Keep track of the
sheet->objects structure.
(sheet_object_create_line, sheet_object_create_filled): Keep track
of the sheet->objects structure.
(sheet_object_realize, sheet_object_unrealize): Export these
functions.
(sheet_object_destroy): Keep track of the sheet->objects structure
* src/sheet-autofill.c (autofill_cell): Implemented autofill on
strings that contains numbers. This allows autofill to handle
stuff like "Product1" -> "Product2", ...
Wed Sep 16 23:56:59 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c: started working on object saving/loading.
......
......@@ -16,6 +16,7 @@
#include <gnome.h>
#include <string.h>
#include <ctype.h>
#include "gnumeric.h"
#include "sheet-autofill.h"
......@@ -141,7 +142,28 @@ matches_list (String *str, int *n, int *is_i18n)
static int
string_has_number (String *str, int *num, int *pos)
{
return FALSE;
char *s = str->str, *p;
int l = strlen (s);
if (isdigit (*s)){
*num = atoi (s);
*pos = 0;
return TRUE;
}
if (l <= 1)
return FALSE;
for (p = s + l - 1; p > str->str && isdigit (*p); p--)
;
if (p == str->str)
return FALSE;
p++;
*num = atoi (p);
*pos = p - str->str;
return TRUE;
}
static void
......@@ -265,7 +287,7 @@ autofill_compute_delta (GList *list_last, GList *fill_item_list)
if (list_last->prev){
lfi = list_last->prev->data;
fi->delta.d_int = lfi->v.numstr.num - fi->v.numstr.num;
fi->delta.d_int = fi->v.numstr.num - lfi->v.numstr.num;
}
return;
......@@ -398,8 +420,32 @@ autofill_cell (Cell *cell, int idx, FillItem *fi)
cell_set_text (cell, fi->v.str->str);
return;
case FILL_STRING_WITH_NUMBER:
case FILL_STRING_WITH_NUMBER: {
FillItem *last = fi->group_last;
char buffer [50], *v;
int i;
i = last->v.numstr.num + idx * last->delta.d_int;
snprintf (buffer, sizeof (buffer)-1, "%d", i);
if (last->v.numstr.pos == 0){
char *p = last->v.numstr.str->str;
while (*p && isdigit (*p))
p++;
v = g_copy_strings (buffer, p, NULL);
} else {
char *n = g_strdup (last->v.numstr.str->str);
n [last->v.numstr.pos] = 0;
v = g_copy_strings (n, buffer, NULL);
g_free (n);
}
cell_set_text (cell, v);
g_free (v);
return;
}
case FILL_NUMBER: {
FillItem *last = fi->group_last;
......@@ -430,9 +476,6 @@ autofill_cell (Cell *cell, int idx, FillItem *fi)
n %= last->v.list.list->count;
printf ("base=%d idx=%d delta=%d\n", last->v.list.num, idx, last->delta.d_int);
printf ("count=%d, n=%d\n", last->v.list.list->count, n);
if (n < 0)
n = (last->v.list.list->count + n);
......@@ -440,9 +483,6 @@ autofill_cell (Cell *cell, int idx, FillItem *fi)
if (last->v.list.was_i18n)
text = _(text);
if (!text)
text = "X";
cell_set_text (cell, text);
return;
......
......@@ -10,7 +10,7 @@
#define GNUMERIC_SHEET_VIEW(p) GNUMERIC_SHEET (SHEET_VIEW(p)->sheet_view);
static void sheet_finish_object_creation (Sheet *sheet);
static void sheet_finish_object_creation (Sheet *sheet, SheetObject *object);
static void sheet_object_unrealize (Sheet *sheet, SheetObject *object);
static void sheet_object_realize (Sheet *sheet, SheetObject *object);
static void sheet_object_start_editing (SheetObject *object);
......@@ -98,6 +98,7 @@ sheet_object_create_filled (Sheet *sheet, int type,
if (fill_color)
sfo->fill_color = string_get (fill_color);
sheet->objects = g_list_prepend (sheet->objects, sfo);
return (SheetObject *) sfo;
}
......@@ -121,6 +122,8 @@ sheet_object_create_line (Sheet *sheet, int is_arrow, double x1, double y1, doub
so->color = string_get (color);
so->width = w;
sheet->objects = g_list_prepend (sheet->objects, sfo);
return so;
}
......@@ -154,6 +157,8 @@ sheet_object_destroy (SheetObject *object)
gtk_object_destroy (GTK_OBJECT (item));
}
g_list_free (l);
sheet->objects = g_list_remove (sheet->objects, object);
g_free (object);
}
......@@ -260,11 +265,16 @@ sheet_view_object_unrealize (SheetView *sheet_view, SheetObject *object)
}
}
static void
void
sheet_object_realize (Sheet *sheet, SheetObject *object)
{
GList *l;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (object != NULL);
g_return_if_fail (IS_SHEET_OBJECT (object));
for (l = sheet->sheet_views; l; l = l->next){
SheetView *sheet_view = l->data;
GnomeCanvasItem *item;
......@@ -274,11 +284,16 @@ sheet_object_realize (Sheet *sheet, SheetObject *object)
}
}
static void
void
sheet_object_unrealize (Sheet *sheet, SheetObject *object)
{
GList *l;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (object != NULL);
g_return_if_fail (IS_SHEET_OBJECT (object));
for (l = sheet->sheet_views; l; l = l->next){
SheetView *sheet_view = l->data;
......@@ -369,7 +384,7 @@ sheet_button_release (GnumericSheet *gsheet, GdkEventButton *event, Sheet *sheet
sheet_object_make_current (sheet, o);
sheet_finish_object_creation (sheet);
sheet_finish_object_creation (sheet, o);
return 1;
}
......@@ -399,7 +414,7 @@ sheet_button_press (GnumericSheet *gsheet, GdkEventButton *event, Sheet *sheet)
}
static void
sheet_finish_object_creation (Sheet *sheet)
sheet_finish_object_creation (Sheet *sheet, SheetObject *o)
{
GList *l;
......
......@@ -46,13 +46,18 @@ void sheet_object_destroy (SheetObject *object);
/*
* This routine creates the SheetObject in the SheetViews's Canvases.
*/
GnomeCanvasItem *sheet_view_object_realize (SheetView *sheet_view,
void sheet_object_realize (SheetView *sheet_view,
SheetObject *object);
void sheet_view_object_unrealize (SheetView *sheet_view,
void sheet_object_unrealize (SheetView *sheet_view,
SheetObject *object);
void sheet_object_make_current (Sheet *sheet,
SheetObject *object);
/* Registers the object in the Sheet, otherwise we cant keep track of it */
void sheet_object_register (Sheet *sheet,
SheetObject *object);
#endif
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