Commit 4252b602 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Add PASTE_IGNORE_COMMENTS.


2001-05-08  Jody Goldberg <jgoldberg@home.com>

	* src/clipboard.c (clipboard_paste_region) : Add PASTE_IGNORE_COMMENTS.

	* src/commands.c (cmd_merge_cells_undo) : Use it here.

2001-05-07  Jody Goldberg <jgoldberg@home.com>

	* src/sheet-merge.c (sheet_merge_remove) : adjust comments.
	(sheet_merge_add) : ditto.

	* src/sheet-object-cell-comment.c (comment_get_points) : handle merged
	  cells.

	* src/commands.c (cmd_unmerge_cells) : don't queue an undo object if
	  there is nothing to do.
	(cmd_merge_cells) : filter existing ranges too.
parent 2469741e
2001-05-08 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Add PASTE_IGNORE_COMMENTS.
* src/commands.c (cmd_merge_cells_undo) : Use it here.
2001-05-07 Jody Goldberg <jgoldberg@home.com>
* src/sheet-merge.c (sheet_merge_remove) : adjust comments.
(sheet_merge_add) : ditto.
* src/sheet-object-cell-comment.c (comment_get_points) : handle merged
cells.
* src/commands.c (cmd_unmerge_cells) : don't queue an undo object if
there is nothing to do.
(cmd_merge_cells) : filter existing ranges too.
2001-05-07 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_event) : ignore events while editing.
......
2001-05-08 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Add PASTE_IGNORE_COMMENTS.
* src/commands.c (cmd_merge_cells_undo) : Use it here.
2001-05-07 Jody Goldberg <jgoldberg@home.com>
* src/sheet-merge.c (sheet_merge_remove) : adjust comments.
(sheet_merge_add) : ditto.
* src/sheet-object-cell-comment.c (comment_get_points) : handle merged
cells.
* src/commands.c (cmd_unmerge_cells) : don't queue an undo object if
there is nothing to do.
(cmd_merge_cells) : filter existing ranges too.
2001-05-07 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_event) : ignore events while editing.
......
2001-05-08 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Add PASTE_IGNORE_COMMENTS.
* src/commands.c (cmd_merge_cells_undo) : Use it here.
2001-05-07 Jody Goldberg <jgoldberg@home.com>
* src/sheet-merge.c (sheet_merge_remove) : adjust comments.
(sheet_merge_add) : ditto.
* src/sheet-object-cell-comment.c (comment_get_points) : handle merged
cells.
* src/commands.c (cmd_unmerge_cells) : don't queue an undo object if
there is nothing to do.
(cmd_merge_cells) : filter existing ranges too.
2001-05-07 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_event) : ignore events while editing.
......
2001-05-08 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Add PASTE_IGNORE_COMMENTS.
* src/commands.c (cmd_merge_cells_undo) : Use it here.
2001-05-07 Jody Goldberg <jgoldberg@home.com>
* src/sheet-merge.c (sheet_merge_remove) : adjust comments.
(sheet_merge_add) : ditto.
* src/sheet-object-cell-comment.c (comment_get_points) : handle merged
cells.
* src/commands.c (cmd_unmerge_cells) : don't queue an undo object if
there is nothing to do.
(cmd_merge_cells) : filter existing ranges too.
2001-05-07 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_event) : ignore events while editing.
......
2001-05-08 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Add PASTE_IGNORE_COMMENTS.
* src/commands.c (cmd_merge_cells_undo) : Use it here.
2001-05-07 Jody Goldberg <jgoldberg@home.com>
* src/sheet-merge.c (sheet_merge_remove) : adjust comments.
(sheet_merge_add) : ditto.
* src/sheet-object-cell-comment.c (comment_get_points) : handle merged
cells.
* src/commands.c (cmd_unmerge_cells) : don't queue an undo object if
there is nothing to do.
(cmd_merge_cells) : filter existing ranges too.
2001-05-07 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_event) : ignore events while editing.
......
......@@ -315,7 +315,7 @@ sc_parse_let (sc_file_state_t *src, const char *cmd, const char *str, int col, i
typedef struct {
const char *name;
size_t namelen;
int namelen;
gboolean (*handler) (sc_file_state_t *src, const char *name,
const char *str, int col, int row);
unsigned have_coord : 1;
......
......@@ -314,8 +314,11 @@ clipboard_paste_region (WorkbookControl *wbc,
tmp = 0;
/* clear the region where we will paste */
if (has_content)
tmp = CLEAR_VALUES | CLEAR_COMMENTS;
if (has_content) {
tmp = CLEAR_VALUES;
if (!(pt->paste_flags & PASTE_IGNORE_COMMENTS))
tmp |= CLEAR_COMMENTS;
}
/* No need to clear the formats. We will paste over top of these. */
/* if (pt->paste_flags & PASTE_FORMATS) tmp |= CLEAR_FORMATS; */
......
......@@ -29,8 +29,11 @@ enum {
/* Do not paste merged regions (probably not needed) */
PASTE_DONT_MERGE = 1 << 12,
/* Do not clear comments */
PASTE_IGNORE_COMMENTS = 1 << 13,
/* Update the row height when pasting? (for large fonts, etc.) */
PASTE_UPDATE_ROW_HEIGHT = 1 << 13
PASTE_UPDATE_ROW_HEIGHT = 1 << 14
};
#define PASTE_ALL_TYPES (PASTE_CONTENT | PASTE_FORMATS)
......
......@@ -2906,8 +2906,18 @@ cmd_unmerge_cells (WorkbookControl *wbc, Sheet *sheet, GSList const *selection)
me->unmerged_regions = NULL;
me->ranges = g_array_new (FALSE, FALSE, sizeof (Range));
for ( ; selection != NULL ; selection = selection->next)
g_array_append_val (me->ranges, *(Range *)selection->data);
for ( ; selection != NULL ; selection = selection->next) {
GSList *merged = sheet_merge_get_overlap (sheet, selection->data);
if (merged != NULL) {
g_array_append_val (me->ranges, *(Range *)selection->data);
g_slist_free (merged);
}
}
if (me->ranges->len <= 0) {
gtk_object_destroy (GTK_OBJECT (me));
return TRUE;
}
/* Register the command object */
return command_push_undo (wbc, obj);
......@@ -2949,7 +2959,7 @@ cmd_merge_cells_undo (GnumericCommand *cmd, WorkbookControl *wbc)
c = me->old_content->data;
clipboard_paste_region (wbc,
paste_target_init (&pt, me->parent.sheet, r,
PASTE_CONTENT | PASTE_FORMATS),
PASTE_CONTENT | PASTE_FORMATS | PASTE_IGNORE_COMMENTS),
c);
cellregion_free (c);
me->old_content = g_slist_remove (me->old_content, c);
......@@ -3034,9 +3044,17 @@ cmd_merge_cells (WorkbookControl *wbc, Sheet *sheet, GSList const *selection)
g_string_free (names, TRUE);
me->ranges = g_array_new (FALSE, FALSE, sizeof (Range));
for ( ; selection != NULL ; selection = selection->next)
if (!range_is_singleton (selection->data))
g_array_append_val (me->ranges, *(Range *)selection->data);
for ( ; selection != NULL ; selection = selection->next) {
Range const *exist;
Range const *r = selection->data;
if (range_is_singleton (selection->data))
continue;
if (NULL != (exist = sheet_merge_is_corner (sheet, &r->start)) &&
range_equal (r, exist))
continue;
g_array_append_val (me->ranges, *(Range *)selection->data);
}
if (me->ranges->len <= 0) {
gtk_object_destroy (GTK_OBJECT (me));
return TRUE;
......
......@@ -22,6 +22,7 @@
*/
#include <config.h>
#include "sheet-merge.h"
#include "sheet-object.h"
#include "sheet.h"
#include "sheet-private.h"
#include "ranges.h"
......@@ -63,6 +64,7 @@ sheet_merge_add (WorkbookControl *wbc,
Range *r_copy;
Cell *cell;
MStyle *style;
CellComment *comment;
g_return_val_if_fail (IS_SHEET (sheet), TRUE);
g_return_val_if_fail (range_is_sane (r), TRUE);
......@@ -125,6 +127,10 @@ sheet_merge_add (WorkbookControl *wbc,
if (range_contains (r, sheet->edit_pos.col, sheet->edit_pos.row))
sheet_set_edit_pos (sheet, r->start.col, r->start.row);
comment = cell_has_comment_pos (sheet, &r->start);
if (comment != NULL)
sheet_object_position (SHEET_OBJECT (comment), NULL);
sheet->priv->reposition_selection = TRUE;
return FALSE;
}
......@@ -140,26 +146,31 @@ sheet_merge_add (WorkbookControl *wbc,
* returns TRUE if there was an error.
*/
gboolean
sheet_merge_remove (WorkbookControl *wbc, Sheet *sheet, Range const *range)
sheet_merge_remove (WorkbookControl *wbc, Sheet *sheet, Range const *r)
{
Range *r_copy;
Cell *cell;
CellComment *comment;
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);
r_copy = g_hash_table_lookup (sheet->hash_merged, &range->start);
r_copy = g_hash_table_lookup (sheet->hash_merged, &r->start);
g_return_val_if_fail (r_copy != NULL, TRUE);
g_return_val_if_fail (range_equal (range, r_copy), TRUE);
g_return_val_if_fail (range_equal (r, r_copy), TRUE);
g_hash_table_remove (sheet->hash_merged, &r_copy->start);
sheet->list_merged = g_slist_remove (sheet->list_merged, r_copy);
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;
comment = cell_has_comment_pos (sheet, &r->start);
if (comment != NULL)
sheet_object_position (SHEET_OBJECT (comment), NULL);
g_free (r_copy);
sheet->priv->reposition_selection = TRUE;
return FALSE;
......
......@@ -24,6 +24,7 @@
#include "sheet-object-cell-comment.h"
#include "sheet-object-impl.h"
#include "sheet.h"
#include "sheet-merge.h"
#include "sheet-control-gui.h"
#include "gnumeric-type-util.h"
#include <gal/widgets/e-cursors.h>
......@@ -66,10 +67,14 @@ static GnomeCanvasPoints *
comment_get_points (SheetControlGUI *scg, SheetObject const *so)
{
GnomeCanvasPoints *points;
int x, y, i;
int x, y, i, far_col;
Range const *r;
r = sheet_merge_is_corner (so->sheet, &so->cell_bound.start);
far_col = 1 + ((r != NULL) ? r->end.col : so->cell_bound.start.col);
/* TODO : This could be optimized using the offsets associated with the visible region */
x = scg_colrow_distance_get (scg, TRUE, 0, so->cell_bound.start.col + 1) - 1;
x = scg_colrow_distance_get (scg, TRUE, 0, far_col) - 1;
y = scg_colrow_distance_get (scg, FALSE, 0, so->cell_bound.start.row) + 1;
points = gnome_canvas_points_new (3);
......
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