Commit f1e8200a authored by Michael Meeks's avatar Michael Meeks
Browse files

Mike Kestner's stylish work.

parent 4ca1bb93
2000-01-28 Mike Kestner <mkestner@ameritech.net>
* src/sheet-style.c (sheet_style_insert_colrow): Now does option checking
and calls either the new style preserving insert function or the existing
functionality in its new function. (stylish_insert_colrow): New.
Preserves style information by extending ranges that contain the
insertion point. (styleless_insert_colrow): Renamed. Existing algorithm
that fragments style ranges to insert an unformatted col/row.
2000-01-28 Michael Meeks <mmeeks@gnu.org>
* configure.in (have_gb): update.
......
2000-01-28 Mike Kestner <mkestner@ameritech.net>
* src/sheet-style.c (sheet_style_insert_colrow): Now does option checking
and calls either the new style preserving insert function or the existing
functionality in its new function. (stylish_insert_colrow): New.
Preserves style information by extending ranges that contain the
insertion point. (styleless_insert_colrow): Renamed. Existing algorithm
that fragments style ranges to insert an unformatted col/row.
2000-01-28 Michael Meeks <mmeeks@gnu.org>
* configure.in (have_gb): update.
......
......@@ -757,18 +757,56 @@ sheet_style_delete_colrow (Sheet *sheet, int pos, int count,
sheet_style_cache_flush (sheet);
}
void
sheet_style_insert_colrow (Sheet *sheet, int pos, int count,
gboolean is_col)
static void
stylish_insert_colrow (Sheet *sheet, int pos, int count, gboolean is_col)
{
Range move_range, ignore_range;
GList *l, *next;
GList *l, *next;
gint start, end;
/* Don't touch the last 'global' range */
for (l = STYLE_LIST (sheet); l && l->next; l = next) {
StyleRegion *sr = (StyleRegion *)l->data;
next = g_list_next (l);
if (is_col) {
start = sr->range.start.col;
end = sr->range.end.col;
} else {
start = sr->range.start.row;
end = sr->range.end.row;
}
/* We can ignore anything at least 2 cells left or above of insert */
if (pos >= (end + 2))
continue;
g_return_if_fail (pos >= 0);
g_return_if_fail (count > 0);
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
/* End will move for everything else. */
end += count;
/* Check if start should move too. */
if (pos <= start)
start += count;
if (is_col) {
sr->range.start.col = MIN (start, SHEET_MAX_COLS - 1);
sr->range.end.col = MIN (end, SHEET_MAX_COLS - 1);
} else {
sr->range.start.row = MIN (start, SHEET_MAX_ROWS - 1);
sr->range.end.row = MIN (end, SHEET_MAX_ROWS - 1);
}
}
sheet_style_cache_flush (sheet);
}
static void
styleless_insert_colrow (Sheet *sheet, int pos, int count, gboolean is_col)
{
Range move_range, ignore_range;
GList *l, *next;
move_range = sheet_get_full_range ();
ignore_range = sheet_get_full_range ();
if (is_col) {
......@@ -839,6 +877,34 @@ sheet_style_insert_colrow (Sheet *sheet, int pos, int count,
sheet_style_cache_flush (sheet);
}
void
sheet_style_insert_colrow (Sheet *sheet, int pos, int count,
gboolean is_col)
{
gboolean stylish, was_default;
g_return_if_fail (pos >= 0);
g_return_if_fail (count > 0);
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
/* Check if style preserving insert option is specified. */
gnome_config_push_prefix ("Gnumeric/Options/");
stylish = gnome_config_get_bool_with_default ("StylishInsert=true",
&was_default);
if (was_default) {
gnome_config_set_bool ("StylishInsert", stylish);
gnome_config_sync ();
}
gnome_config_pop_prefix ();
if (stylish)
stylish_insert_colrow (sheet, pos, count, is_col);
else
styleless_insert_colrow (sheet, pos, count, is_col);
}
void
sheet_style_relocate (const ExprRelocateInfo *rinfo)
{
......
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