Commit c03ad77a authored by JP Rosevear's avatar JP Rosevear Committed by JP Rosevear

Tidy and handle the case where the ranges don't intersect.

1999-12-21  JP Rosevear <jpr@arcavia.com>

        * src/ranges.c (range_intersection) : Tidy and handle the case
        where the ranges don't intersect.

        * src/dialogs/dialog-cell-sort.c (dialog_cell_sort) : Use
        sheet_get_extent only if there are infinite ranges, so the user
        sees their manually selected range if possible.
parent 423c4b57
1999-12-21 JP Rosevear <jpr@arcavia.com>
* src/ranges.c (range_intersection) : Tidy and handle the case
where the ranges don't intersect.
* src/dialogs/dialog-cell-sort.c (dialog_cell_sort) : Use
sheet_get_extent only if there are infinite ranges, so the user
sees their manually selected range if possible.
1999-12-21 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (expr_implicit_intersection) : New routine split from
......
1999-12-21 JP Rosevear <jpr@arcavia.com>
* src/ranges.c (range_intersection) : Tidy and handle the case
where the ranges don't intersect.
* src/dialogs/dialog-cell-sort.c (dialog_cell_sort) : Use
sheet_get_extent only if there are infinite ranges, so the user
sees their manually selected range if possible.
1999-12-21 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (expr_implicit_intersection) : New routine split from
......
......@@ -724,33 +724,22 @@ range_fragment_free (GList *fragments)
* diagram this would be A (upside down U) B
* NB. totally commutative.
*
* Return value: the intersection.
* Return value: the intersection
**/
Range
range_intersection (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;
g_return_if_fail (range_overlap (a, b));
ans.start.col = MAX(a->start.col, b->start.col);
ans.start.row = MAX(a->start.row, b->start.row);
ans.end.col = MIN(a->end.col, b->end.col);
ans.end.row = MIN(a->end.row, b->end.row);
/* Make sure this is an actual intersection */
return ans;
}
......
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