Commit b18b73be authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

save the merged regions. (clipboard_release) : cleanup merged regions.


2001-01-24  Jody Goldberg <jgoldberg@home.com>

	* src/clipboard.c (clipboard_copy_range) : save the merged regions.
	(clipboard_release) : cleanup merged regions.

	* src/commands.c (cmd_merge_cells_redo) : move the non-corner content
	  clearing from here.
	* src/sheet-merge.c (sheet_merge_add) : to here.  Apply the style from
	  the corner to the entire region.

	* src/sheet.c (sheet_range_set_text) : clear range_filled merged
	  regions.

	* src/item-grid.c (item_grid_draw) : borders & grids for merged cells.

2001-01-23  Jody Goldberg <jgoldberg@home.com>

	* src/sheet-style.c (style_row) : move the clearing of grid lines
	* src/item-grid.c (item_grid_draw) : from here.
parent 783d67db
......@@ -13,12 +13,11 @@ Release Critical
- Merged Cells
- copy/paste (cut works)
- fix undo ins/del row/col to restore lost merged regions
- fill range should not put entries in
- autofill should not fill in the invisible areas.
- Fix Borders
- border style double_line does not handle all of the different
intersection cases.
- diagonals
Long term breakage
------------------
......
2001-01-24 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_range) : save the merged regions.
(clipboard_release) : cleanup merged regions.
* src/commands.c (cmd_merge_cells_redo) : move the non-corner content
clearing from here.
* src/sheet-merge.c (sheet_merge_add) : to here. Apply the style from
the corner to the entire region.
* src/sheet.c (sheet_range_set_text) : clear range_filled merged
regions.
* src/item-grid.c (item_grid_draw) : borders & grids for merged cells.
2001-01-23 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (style_row) : move the clearing of grid lines
* src/item-grid.c (item_grid_draw) : from here.
2001-01-24 Almer S. Tigelaar <almer1@dds.nl>
* src/gnumeric-util.c (gnumeric_create_popup_menu):
......
2001-01-24 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_range) : save the merged regions.
(clipboard_release) : cleanup merged regions.
* src/commands.c (cmd_merge_cells_redo) : move the non-corner content
clearing from here.
* src/sheet-merge.c (sheet_merge_add) : to here. Apply the style from
the corner to the entire region.
* src/sheet.c (sheet_range_set_text) : clear range_filled merged
regions.
* src/item-grid.c (item_grid_draw) : borders & grids for merged cells.
2001-01-23 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (style_row) : move the clearing of grid lines
* src/item-grid.c (item_grid_draw) : from here.
2001-01-24 Almer S. Tigelaar <almer1@dds.nl>
* src/gnumeric-util.c (gnumeric_create_popup_menu):
......
2001-01-24 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_range) : save the merged regions.
(clipboard_release) : cleanup merged regions.
* src/commands.c (cmd_merge_cells_redo) : move the non-corner content
clearing from here.
* src/sheet-merge.c (sheet_merge_add) : to here. Apply the style from
the corner to the entire region.
* src/sheet.c (sheet_range_set_text) : clear range_filled merged
regions.
* src/item-grid.c (item_grid_draw) : borders & grids for merged cells.
2001-01-23 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (style_row) : move the clearing of grid lines
* src/item-grid.c (item_grid_draw) : from here.
2001-01-24 Almer S. Tigelaar <almer1@dds.nl>
* src/gnumeric-util.c (gnumeric_create_popup_menu):
......
2001-01-24 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_range) : save the merged regions.
(clipboard_release) : cleanup merged regions.
* src/commands.c (cmd_merge_cells_redo) : move the non-corner content
clearing from here.
* src/sheet-merge.c (sheet_merge_add) : to here. Apply the style from
the corner to the entire region.
* src/sheet.c (sheet_range_set_text) : clear range_filled merged
regions.
* src/item-grid.c (item_grid_draw) : borders & grids for merged cells.
2001-01-23 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (style_row) : move the clearing of grid lines
* src/item-grid.c (item_grid_draw) : from here.
2001-01-24 Almer S. Tigelaar <almer1@dds.nl>
* src/gnumeric-util.c (gnumeric_create_popup_menu):
......
2001-01-24 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_range) : save the merged regions.
(clipboard_release) : cleanup merged regions.
* src/commands.c (cmd_merge_cells_redo) : move the non-corner content
clearing from here.
* src/sheet-merge.c (sheet_merge_add) : to here. Apply the style from
the corner to the entire region.
* src/sheet.c (sheet_range_set_text) : clear range_filled merged
regions.
* src/item-grid.c (item_grid_draw) : borders & grids for merged cells.
2001-01-23 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (style_row) : move the clearing of grid lines
* src/item-grid.c (item_grid_draw) : from here.
2001-01-24 Almer S. Tigelaar <almer1@dds.nl>
* src/gnumeric-util.c (gnumeric_create_popup_menu):
......
......@@ -3376,7 +3376,7 @@ ms_excel_read_mergecells (BiffQuery *q, ExcelSheet *sheet)
r.end.row = MS_OLE_GET_GUINT16(ptr+2);
r.start.col = MS_OLE_GET_GUINT16(ptr+4);
r.end.col = MS_OLE_GET_GUINT16(ptr+6);
sheet_merge_add (NULL, sheet->gnum_sheet, &r);
sheet_merge_add (NULL, sheet->gnum_sheet, &r, FALSE);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 1) {
range_dump (&r, "\n");
......
......@@ -15,6 +15,7 @@
#include "dependent.h"
#include "sheet.h"
#include "sheet-style.h"
#include "sheet-merge.h"
#include "eval.h"
#include "selection.h"
#include "application.h"
......@@ -428,9 +429,10 @@ CellRegion *
clipboard_copy_range (Sheet *sheet, Range const *r)
{
CellRegion *c;
GSList *merged, *ptr;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
g_return_val_if_fail (r != NULL, NULL);
g_return_val_if_fail (r->start.col <= r->end.col, NULL);
g_return_val_if_fail (r->start.row <= r->end.row, NULL);
......@@ -450,11 +452,16 @@ clipboard_copy_range (Sheet *sheet, Range const *r)
r->start.col, r->start.row,
r->end.col, r->end.row,
clipboard_prepend_cell, c);
/* reverse the list so that upper left corner is first */
c->list = g_list_reverse (c->list);
c->styles = sheet_style_get_list (sheet, r);
/* reverse the list so that upper left corner is first */
c->list = g_list_reverse (c->list);
c->merged = NULL;
merged = sheet_merge_get_overlap (sheet, r);
for (ptr = merged ; ptr != NULL ; ptr = ptr->next)
c->merged = g_slist_prepend (c->merged, range_copy (ptr->data));
g_slist_free (merged);
return c;
}
......@@ -470,7 +477,6 @@ clipboard_paste (WorkbookControl *wbc, PasteTarget const *pt, guint32 time)
CellRegion *content;
g_return_if_fail (pt != NULL);
g_return_if_fail (pt->sheet != NULL);
g_return_if_fail (IS_SHEET (pt->sheet));
content = application_clipboard_contents_get ();
......@@ -495,7 +501,7 @@ clipboard_release (CellRegion *content)
g_return_if_fail (content != NULL);
for (l = content->list; l; l = l->next){
for (l = content->list; l; l = l->next) {
CellCopy *this_cell = l->data;
if (this_cell->type == CELL_COPY_TYPE_CELL) {
......@@ -513,6 +519,13 @@ clipboard_release (CellRegion *content)
style_list_free (content->styles);
content->styles = NULL;
}
if (content->merged != NULL) {
GSList *ptr;
for (ptr = content->merged; ptr != NULL ; ptr = ptr->next)
g_free (ptr->data);
g_slist_free (content->merged);
content->merged = NULL;
}
g_list_free (content->list);
content->list = NULL;
......
......@@ -50,6 +50,7 @@ struct _CellRegion {
int cols, rows;
CellCopyList *list;
GList *styles;
GSList *merged;
};
struct _PasteTarget {
......
......@@ -2461,7 +2461,7 @@ cmd_unmerge_cells_undo_internal (GnumericCommand *cmd, WorkbookControl *wbc,
for (i = 0 ; i < me->unmerged_regions->len ; ++i) {
Range const *tmp = &(g_array_index (me->unmerged_regions, Range, i));
sheet_merge_add (wbc, me->sheet, tmp);
sheet_merge_add (wbc, me->sheet, tmp, FALSE);
if (re_span)
sheet_range_calc_spans (me->sheet, *tmp, SPANCALC_RE_RENDER);
}
......@@ -2627,20 +2627,7 @@ cmd_merge_cells_redo (GnumericCommand *cmd, WorkbookControl *wbc)
me->old_content = g_slist_prepend (me->old_content,
clipboard_copy_range (me->unmerge.sheet, r));
if (r->start.col != r->end.col)
sheet_clear_region (wbc, me->unmerge.sheet,
r->start.col+1, r->start.row,
r->end.col, r->end.row,
CLEAR_VALUES | CLEAR_FORMATS |
CLEAR_COMMENTS | CLEAR_NOCHECKARRAY);
if (r->start.row != r->end.row)
sheet_clear_region (wbc, me->unmerge.sheet,
r->start.col, r->start.row+1,
/* yes I mean start.col */ r->start.col, r->end.row,
CLEAR_VALUES | CLEAR_FORMATS |
CLEAR_COMMENTS | CLEAR_NOCHECKARRAY);
sheet_merge_add (wbc, me->unmerge.sheet, r);
sheet_merge_add (wbc, me->unmerge.sheet, r, TRUE);
}
me->old_content = g_slist_reverse (me->old_content);
......
......@@ -192,7 +192,7 @@ item_grid_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int
/**
* item_grid_draw_merged_range:
*
* Handle the special drawin requirements for a 'merged cell'.
* Handle the special drawing requirements for a 'merged cell'.
* First draw the entire range (clipped to the visible region) then redraw any
* segments that are selected.
*/
......@@ -202,19 +202,23 @@ item_grid_draw_merged_range (GdkDrawable *drawable, ItemGrid *grid,
Range const *view, Range const *range,
StyleRow const *sr)
{
int l, r, t, b, tmp;
Sheet *sheet = grid->scg->sheet;
GdkGC * const gc = grid->empty_gc;
Cell const *cell = sheet_cell_get (sheet, range->start.col, range->start.row);
MStyle *mstyle = sheet_style_get (sheet, range->start.col, range->start.row);
int l, r, t, b, tmp, col;
GdkGC *gc = grid->empty_gc;
Sheet const *sheet = grid->scg->sheet;
Cell const *cell = sheet_cell_get (sheet, range->start.col, range->start.row);
MStyle const *mstyle = sheet_style_get (sheet, range->start.col, range->start.row);
gboolean const is_selected = (sheet->edit_pos.col != range->start.col ||
sheet->edit_pos.row != range->start.row) &&
sheet_is_full_range_selected (sheet, range);
l = r = start_x;
if (view->start.col < range->start.col)
if (view->start.col < range->start.col) {
l += scg_colrow_distance_get (grid->scg, TRUE,
view->start.col, range->start.col);
col = range->start.col;
} else
col = view->start.col;
if (range->end.col <= (tmp = view->end.col))
tmp = range->end.col;
r += scg_colrow_distance_get (grid->scg, TRUE, view->start.col, tmp+1);
......@@ -223,27 +227,42 @@ item_grid_draw_merged_range (GdkDrawable *drawable, ItemGrid *grid,
if (view->start.row < range->start.row)
t += scg_colrow_distance_get (grid->scg, FALSE,
view->start.row, range->start.row);
else if (view->start.row == range->start.row) {
#warning draw top borders here
}
if (range->end.row <= (tmp = view->end.row))
tmp = range->end.row;
b += scg_colrow_distance_get (grid->scg, FALSE, view->start.row, tmp+1);
if (gnumeric_background_set_gc (mstyle, gc, grid->canvas_item.canvas, is_selected))
/* Remember X excludes the far pixels */
gdk_draw_rectangle (drawable, gc, TRUE, l, t, r-l+1, b-t+1);
/* Remember X excludes the far pixels */
gdk_draw_rectangle (drawable, gc, TRUE, l, t, r-l+1, b-t+1);
if (range->start.col < view->start.col)
l -= scg_colrow_distance_get (grid->scg, TRUE,
range->start.col, view->start.col);
if (view->end.col < range->end.col)
r += scg_colrow_distance_get (grid->scg, TRUE,
view->end.col+1, range->end.col+1);
if (range->start.row < view->start.row)
t -= scg_colrow_distance_get (grid->scg, FALSE,
range->start.row, view->start.row);
else if (view->start.row == range->start.row) {
/* Keep this in sync with the standard code */
StyleBorder const *top = sr->top [col];
if (top == style_border_none ()) {
if (sheet->show_grid) {
int offset = 0;
/* Do not over write background patterns */
if ((col > view->start.col && sr->top [col - 1] == NULL) ||
(col < view->end.col && sr->top [col + 1] == NULL))
offset = 1;
gdk_draw_line (drawable, grid->grid_gc, l + offset, t,
r - offset, t);
}
} else if (top != NULL)
style_border_draw (top, STYLE_BORDER_TOP, drawable,
l, t, r, t, NULL, NULL);
}
if (view->end.row < range->end.row)
b += scg_colrow_distance_get (grid->scg, FALSE,
view->end.row+1, range->end.row+1);
......@@ -259,14 +278,14 @@ item_grid_draw_merged_range (GdkDrawable *drawable, ItemGrid *grid,
}
}
static gboolean
static void
item_grid_draw_background (GdkDrawable *drawable, ItemGrid *ig,
MStyle const *style,
int col, int row, int x, int y, int w, int h)
{
SheetControlGUI *scg = ig->scg;
Sheet const *sheet = scg->sheet;
GdkGC * const gc = ig->empty_gc;
GdkGC *gc = ig->empty_gc;
SheetControlGUI const *scg = ig->scg;
Sheet const *sheet = scg->sheet;
gboolean const is_selected =
scg->current_object == NULL && scg->new_object == NULL &&
!(sheet->edit_pos.col == col && sheet->edit_pos.row == row) &&
......@@ -278,8 +297,6 @@ item_grid_draw_background (GdkDrawable *drawable, ItemGrid *ig,
if (has_back || is_selected)
/* Fill the entire cell (API excludes far pixel) */
gdk_draw_rectangle (drawable, gc, TRUE, x, y, w+1, h+1);
return has_back;
}
static gint
......@@ -301,7 +318,7 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int draw_x, int dr
/* To ensure that far and near borders get drawn we pretend to draw +-2
* pixels around the target area which would include the surrounding
* borders if necessary */
int x, y, col, row, n;
int x, y, col, row, n, inc_x, next_col;
int const start_col = gnumeric_sheet_find_col (gsheet, draw_x-2, &x);
int end_col = gnumeric_sheet_find_col (gsheet, draw_x+width+2, NULL);
int const diff_x = draw_x - x;
......@@ -395,21 +412,23 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int draw_x, int dr
}
first_row = FALSE;
for (col = start_col, x = -diff_x; col <= end_col ; ++col) {
for (col = start_col, x = -diff_x; col <= end_col ; ) {
MStyle const *style;
CellSpanInfo const *span;
ColRowInfo const *ci = sheet_col_get_info (sheet, col);
if (!ci->visible)
if (!ci->visible) {
col++;
continue;
}
/* Skip any merged regions */
if (merged_active) {
Range const *r = merged_active->data;
if (r->start.col <= col) {
x += scg_colrow_distance_get (
inc_x = scg_colrow_distance_get (
gsheet->scg, TRUE, col, r->end.col+1);
col = r->end.col;
next_col = r->end.col;
ptr = merged_active;
merged_active = merged_active->next;
......@@ -422,24 +441,15 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int draw_x, int dr
merged_active_seen = ptr;
MERGE_DEBUG (r, " : active -> seen\n");
}
continue;
goto left_border;
}
}
style = sr.styles [col];
if (item_grid_draw_background (drawable, item_grid,
style, col, row, x, y,
ci->size_pixels,
ri->size_pixels)) {
if (sr.vertical [col] == none)
sr.vertical [col] = NULL;
if (sr.vertical [col+1] == none)
sr.vertical [col+1] = NULL;
if (sr.top [col] == none)
sr.top [col] = NULL;
if (sr.bottom [col] == none)
sr.bottom [col] = NULL;
}
item_grid_draw_background (drawable, item_grid,
style, col, row, x, y,
ci->size_pixels,
ri->size_pixels);
/* Is this part of a span?
* 1) There are cells allocated in the row
......@@ -496,12 +506,14 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int draw_x, int dr
} else if (col != span->left)
sr.vertical [col] = NULL;
/* Keep this in sync with the merge cell code */
top = sr.top [col];
if (top == none) {
if (sheet->show_grid) {
int offset = 0;
/* Do not over write background patterns */
if (col > start_col && sr.top [col - 1] == NULL)
if ((col > start_col && sr.top [col - 1] == NULL) ||
(col < end_col && sr.top [col + 1] == NULL))
offset = 1;
gdk_draw_line (drawable, grid_gc, x + offset, y,
x + ci->size_pixels - offset, y);
......@@ -510,12 +522,17 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int draw_x, int dr
style_border_draw (top, STYLE_BORDER_TOP, drawable,
x, y, x + ci->size_pixels, y, NULL, NULL);
inc_x = ci->size_pixels;
next_col = col;
left_border :
vert = sr.vertical [col];
if (vert == none) {
if (sheet->show_grid) {
int offset = 0;
/* Do not over write background patterns */
if (top == NULL || (col > start_col && sr.top [col - 1] == NULL))
if (top == NULL ||
(col > start_col && sr.top [col - 1] == NULL))
offset = 1;
gdk_draw_line (drawable, grid_gc,
x, y + offset,
......@@ -525,7 +542,8 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int draw_x, int dr
style_border_draw (vert, STYLE_BORDER_LEFT, drawable,
x, y, x, y + ri->size_pixels, NULL, NULL);
x += ci->size_pixels;
x += inc_x;
col = next_col + 1;
}
y += ri->size_pixels;
......
......@@ -139,6 +139,9 @@ gnumeric_background_set_gc (MStyle const *mstyle, GdkGC *gc,
}
return TRUE;
} else if (is_selected) {
/* No need to reset the gc to white if not selected
* we only paint a cell packground if it is non-white
*/
gdk_gc_set_fill (gc, GDK_SOLID);
gdk_gc_set_foreground (gc, &gs_lavender);
}
......
......@@ -1117,7 +1117,7 @@ selection_to_string (Sheet *sheet, gboolean include_sheet_name_prefix)
/*
* selection_contains_colrow :
* @sheet : The whose selection we are interested in.
* @sheet : containing the selection
* @colrow: The column or row number we are interested in.
* @is_col: A flag indicating whether this it is a column or a row.
*
......@@ -1427,7 +1427,7 @@ sheet_row_selection_type (Sheet const *sheet, int row)
* @is_cols :
* @index :
*
* returns TRUE if all of the selected cols/rows in the selection fully
* returns TRUE if all of the selected cols/rows in the selection
* are fully selected and the selection contains the specified col.
*/
gboolean
......
......@@ -755,7 +755,7 @@ sheet_autofill_dir (Sheet *sheet,
range_init (&tmp, col, row,
col + fi->merged_size.col,
row + fi->merged_size.row);
sheet_merge_add (NULL, sheet, &tmp);
sheet_merge_add (NULL, sheet, &tmp, TRUE);
}
col += col_inc;
......
......@@ -131,7 +131,7 @@ void scg_set_cursor_bounds (SheetControlGUI *scg,
void scg_compute_visible_region (SheetControlGUI *scg, gboolean full_recompute);
void scg_make_cell_visible (SheetControlGUI *scg, int col, int row,
gboolean force_scroll);
void scg_create_edit_cursor (SheetControlGUI *scg);
void scg_create_editor (SheetControlGUI *scg);
void scg_stop_editing (SheetControlGUI *scg);
void scg_stop_cell_selection (SheetControlGUI *scg, gboolean clear_string);
......
......@@ -26,6 +26,8 @@
#include "sheet-private.h"
#include "ranges.h"
#include "cell.h"
#include "sheet-style.h"
#include "mstyle.h"
#include "expr.h"
#include "command-context.h"
......@@ -46,40 +48,65 @@ range_row_cmp (Range const *a, Range const *b)
* @wbc : workbook control
* @sheet : the sheet which will contain the region
* @src : The region to merge
* @clear : should the non-corner content of the region be cleared and the
* style from the corner applied.
*
* Add a range to the list of merge targets. Checks for array spliting returns
* TRUE if there was an error. Does not regen spans, redraw or render.
*/
gboolean
sheet_merge_add (WorkbookControl *wbc, Sheet *sheet, Range const *range)
sheet_merge_add (WorkbookControl *wbc,
Sheet *sheet, Range const *r, gboolean clear)
{
GSList *test;
Range *r_copy;
Cell *cell;
MStyle *style;
g_return_val_if_fail (IS_SHEET (sheet), TRUE);
g_return_val_if_fail (range != NULL, TRUE);
g_return_val_if_fail (r != NULL, TRUE);
if (sheet_range_splits_array (sheet, range, wbc, _("Merge")))
if (sheet_range_splits_array (sheet, r, wbc, _("Merge")))
return TRUE;
test = sheet_merge_get_overlap (sheet, range);
test = sheet_merge_get_overlap (sheet, r);
if (test != NULL) {
gnumeric_error_invalid (COMMAND_CONTEXT (wbc),
_("There is already a merged region that intersects"),
range_name (range));
range_name (r));
g_slist_free (test);
return TRUE;
}
r_copy = range_copy (range);
if (clear) {
/* Clear the non-corner content */
if (r->start.col != r->end.col)
sheet_clear_region (wbc, sheet,
r->start.col+1, r->start.row,
r->end.col, r->end.row,
CLEAR_VALUES | CLEAR_COMMENTS |
CLEAR_NOCHECKARRAY);
if (r->start.row != r->end.row)
sheet_clear_region (wbc, sheet,
r->start.col, r->start.row+1,
/* yes I mean start.col */ r->start.col, r->end.row,
CLEAR_VALUES | CLEAR_COMMENTS |
CLEAR_NOCHECKARRAY);
/* Apply the corner style to the entire region */
style = sheet_style_get (sheet, r->start.col, r->start.row);
mstyle_ref (style);
sheet_style_set_range (sheet, r, style);
}
r_copy = range_copy (r);
g_hash_table_insert (sheet->hash_merged, &r_copy->start, r_copy);
/* Store in order from bottom to top then LEFT TO RIGHT (by start coord) */
sheet->list_merged = g_slist_insert_sorted (sheet->list_merged, r_copy,
(GCompareFunc)range_row_cmp);
cell = sheet_cell_get (sheet, range->start.col, range->start.row);
cell = sheet_cell_get (sheet, r->start.col, r->start.row);
if (cell != NULL)
cell->base.flags |= CELL_IS_MERGED;
......@@ -277,7 +304,7 @@ sheet_merge_relocate (ExprRelocateInfo const *ri)
/* move the ranges after removing the previous content in case of overlap */
for (ptr = to_move ; ptr != NULL ; ptr = ptr->next) {
Range *dest = ptr->data;
sheet_merge_add (NULL, ri->target_sheet, dest);
sheet_merge_add (NULL, ri->target_sheet, dest, TRUE);
g_free (dest);
}
g_slist_free (to_move);
......
......@@ -4,7 +4,8 @@
#include "gnumeric.h"
gboolean sheet_merge_add (WorkbookControl *cc,
Sheet *sheet, Range const *r);
Sheet *sheet, Range const *r,
gboolean clear);
gboolean sheet_merge_remove (WorkbookControl *cc,
Sheet *sheet, Range const *r);
GSList *sheet_merge_get_overlap (Sheet const *sheet, Range const *r);
......
......@@ -858,31 +858,40 @@ tail_recursion :
return NULL;
}
#define border_null(b) ((b) == none || (b) == NULL)
static inline void
style_row (MStyle *style, int start_col, int end_col, StyleRow *sr)
{
StyleBorder *top, *bottom, *none = style_border_none ();
StyleBorder *left, *right, *v;
StyleBorder const *top, *bottom, *none = style_border_none ();
StyleBorder const *left, *right, *v;
int const end = MIN (end_col, sr->end_col);
int i = MAX (start_col, sr->start_col);
#if 0
gboolean const has_back = mstyle_get_pattern (mstyle) > 0;
#endif
top = mstyle_get_border (style, MSTYLE_BORDER_TOP);
bottom = mstyle_get_border (style, MSTYLE_BORDER_BOTTOM);
left = mstyle_get_border (style, MSTYLE_BORDER_LEFT);
right = mstyle_get_border (style, MSTYLE_BORDER_RIGHT);
if (left != none &&
(sr->vertical [i] == none || sr->vertical [i] == NULL))
/* Cancel grids if there is a background */
if (mstyle_get_pattern (style) > 0) {
if (top == none)
top = NULL;
if (bottom == none)
bottom = NULL;
if (left == none)
left = NULL;
if (right == none)
right = NULL;
}
if (left != none && border_null (sr->vertical [i]))
sr->vertical [i] = left;
v = (right != none) ? right : left;
while (i <= end) {
sr->styles [i] = style;
if (top != none &&
(sr->top [i] == none || sr->top [i] == NULL))
if (top != none && border_null (sr->top [i]))
sr->top [i] = top;
sr->bottom [i] = bottom;
sr->vertical [++i] = v;
......
......@@ -1127,6 +1127,15 @@ cb_set_cell_content (Sheet *sheet, int col, int row, Cell *cell,
return NULL;
}
static Value *
cb_clear_non_corner (Sheet *sheet, int col, int row, Cell *cell,
Range const *merged)
{
if (merged->start.col != col || merged->start.row != row)
cell_set_value (cell, value_new_empty (), NULL);
return NULL;
}
/**
* sheet_range_set_text :
*
......@@ -1142,6 +1151,7 @@ void
sheet_range_set_text (EvalPos const *pos, Range const *r, char const *str)
{
closure_set_cell_value closure;
GSList *merged, *ptr;
g_return_if_fail (pos != NULL);
g_return_if_fail (r != NULL);
......@@ -1153,10 +1163,21 @@ sheet_range_set_text (EvalPos const *pos, Range const *r, char const *str)
/* Store the parsed result creating any cells necessary */
sheet_foreach_cell_in_range (pos->sheet, FALSE,
r->start.col, r->start.row,
r->end.col, r->end.row,
(ForeachCellCB)&cb_set_cell_content,
&closure);
r->start.col, r->start.row,
r->end.col, r->end.row,
(ForeachCellCB)&cb_set_cell_content,
&closure);
merged = sheet_merge_get_overlap (pos->sheet, r);
for (ptr = merged ; ptr != NULL ; ptr = ptr->next) {
Range const *r = ptr->data;
sheet_foreach_cell_in_range (pos->sheet, FALSE,
r->start.col, r->start.row,
r->end.col, r->end.row,
(ForeachCellCB)&cb_clear_non_corner,
(gpointer)r);
}
g_slist_free (merged);
if (closure.format)
style_format_unref (closure.format);
......@@ -3645,7 +3666,7 @@ sheet_clone_merged_regions (Sheet const *src, Sheet *dst)
{
GSList *ptr;
for (ptr = src->list_merged ; ptr