Commit 213a7230 authored by Michael Meeks's avatar Michael Meeks Committed by Michael Meeks

clean.

1999-12-18  Michael Meeks  <mmeeks@gnu.org>

	* src/corba-sheet.c (command_context_corba): clean.

	* src/sheet-style.c (sheet_style_get_extent): implement.

	* src/sheet.c (sheet_get_extent): Add union with style extent,
	fix silly typo.

	* src/ranges.c (range_is_infinite): Add new function.
	(range_union): implement.
parent 9e77fdd9
1999-12-18 Michael Meeks <mmeeks@gnu.org>
* src/corba-sheet.c (command_context_corba): clean.
* src/sheet-style.c (sheet_style_get_extent): implement.
* src/sheet.c (sheet_get_extent): Add union with style extent,
fix silly typo.
* src/ranges.c (range_is_infinite): Add new function.
(range_union): implement.
1999-12-18 Morten Welinder <terra@diku.dk>
* src/functions/fn-financial.c (gnumeric_yieldmat,
......
1999-12-18 Michael Meeks <mmeeks@gnu.org>
* src/corba-sheet.c (command_context_corba): clean.
* src/sheet-style.c (sheet_style_get_extent): implement.
* src/sheet.c (sheet_get_extent): Add union with style extent,
fix silly typo.
* src/ranges.c (range_is_infinite): Add new function.
(range_union): implement.
1999-12-18 Morten Welinder <terra@diku.dk>
* src/functions/fn-financial.c (gnumeric_yieldmat,
......
This diff is collapsed.
......@@ -48,8 +48,8 @@ out_of_range (CORBA_Environment *ev)
CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Gnumeric_Sheet_OutOfRange, NULL);
}
struct _CmdContext *
command_context_corba ()
CmdContext *
command_context_corba (void)
{
/* FIXME FIXME FIXME : corba context */
return NULL;
......
#ifndef GNUMERIC_CORBA_H
#define GNUMERIC_CORBA_H
extern PortableServer_POA gnumeric_poa;
gboolean WorkbookFactory_init (void);
extern PortableServer_POA gnumeric_poa;
gboolean WorkbookFactory_init (void);
struct _CmdContext * command_context_corba ();
CmdContext *command_context_corba (void);
#endif
......@@ -754,12 +754,76 @@ range_intersection (Range const *a, Range const *b)
return ans;
}
/**
* range_union:
* @a: range a
* @b: range b
*
* This computes the union; on a Venn
* diagram this would be A U B
* NB. totally commutative. Also, this may
* include cells not in either range since
* it must return a Range.
*
* Return value: the union
**/
Range
range_union (Range const *a, Range const *b)
{
Range ans;
if (a->start.col < b->start.col)
ans.start.col = a->start.col;
else
ans.start.col = b->start.col;
if (a->end.col > b->end.col)
ans.end.col = a->end.col;
else
ans.end.col = b->end.col;
if (a->start.row < b->start.row)
ans.start.row = a->start.row;
else
ans.start.row = b->start.row;
if (a->end.row > b->end.row)
ans.end.row = a->end.row;
else
ans.end.row = b->end.row;
return ans;
}
gboolean
range_is_singleton (Range const *r)
{
return r->start.col == r->end.col && r->start.row == r->end.row;
}
/**
* range_is_infinite:
* @r: the range.
*
* This determines whether @r completely spans a sheet
* in either dimension ( semi-infinite )
*
* Return value: TRUE if it is infinite else FALSE
**/
gboolean
range_is_infinite (Range const *r)
{
if (r->start.col == 0 &&
r->end.col >= SHEET_MAX_COLS - 1)
return TRUE;
if (r->start.row == 0 &&
r->end.row >= SHEET_MAX_ROWS - 1)
return TRUE;
return FALSE;
}
static void
range_style_apply_cb (Sheet *sheet, const Range *range, gpointer user_data)
{
......
......@@ -50,11 +50,13 @@ void ranges_set_style (Sheet *sheet, GSList *ranges,
MStyle *mstyle);
gboolean range_is_singleton (Range const *r);
gboolean range_is_infinite (Range const *r);
gboolean range_overlap (Range const *a, Range const *b);
gboolean range_contained (Range const *a, Range const *b);
gboolean range_adjacent (Range const *a, Range const *b);
Range range_merge (Range const *a, Range const *b);
Range range_intersection (Range const *a, Range const *b);
Range range_union (Range const *a, Range const *b);
gboolean range_translate (Range *range, int col_offset, int row_offset);
gboolean range_expand (Range *range, int d_tlx, int d_tly, int d_brx, int d_bry);
void range_dump (Range const *src);
......
......@@ -1455,3 +1455,24 @@ sheet_selection_get_unique_style (Sheet *sheet, MStyleBorder **borders)
return cl.mstyle;
}
/**
* sheet_style_get_extent:
* @r: input / output range
* @sheet: for this sheet.
*
* This enlarges r by a union with each non infinite style
* range.
**/
void
sheet_style_get_extent (Range *r, Sheet const *sheet)
{
GList *l;
for (l = STYLE_LIST (sheet); l; l = g_list_next (l)) {
Range *sr = (Range *)l->data;
if (!range_is_infinite (sr))
*r = range_union (r, sr);
}
}
......@@ -606,13 +606,15 @@ sheet_get_extent (Sheet const *sheet)
if (r.start.col >= SHEET_MAX_COLS - 2)
r.start.col = 0;
if (r.start.col >= SHEET_MAX_ROWS - 2)
if (r.start.row >= SHEET_MAX_ROWS - 2)
r.start.row = 0;
if (r.end.col < 0)
r.end.col = 0;
if (r.end.row < 0)
r.end.row = 0;
sheet_style_get_extent (&r, sheet);
return r;
}
......
......@@ -293,6 +293,7 @@ void sheet_styles_dump (Sheet *sheet);
void sheet_cells_update (Sheet *sheet, Range r,
gboolean render_text);
Range sheet_get_full_range (void);
void sheet_style_get_extent (Range *r, Sheet const *sheet);
Range sheet_get_extent (Sheet const *sheet);
gboolean sheet_check_for_partial_array (Sheet *sheet,
......
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