Commit 984592e7 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Move the handling of singletons and the setting of the selection here.


2000-05-27  Jody Goldberg <jgoldberg@home.com>

	* src/commands.c (cmd_paste_copy) : Move the handling of singletons
	  and the setting of the selection here.
	* src/clipboard.c (clipboard_paste_region) : From here.

	* src/cmd-edit.c (cmd_paste_to_selection) : Remove incorrect
	  precondition.
parent 352d6328
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy) : Move the handling of singletons
and the setting of the selection here.
* src/clipboard.c (clipboard_paste_region) : From here.
* src/cmd-edit.c (cmd_paste_to_selection) : Remove incorrect
precondition.
2000-05-27 Valek Filippov <frob@df.ru>
* src/functions/fn-math.c, fn-stat.c, fn-lookup.c: typos in
......
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy) : Move the handling of singletons
and the setting of the selection here.
* src/clipboard.c (clipboard_paste_region) : From here.
* src/cmd-edit.c (cmd_paste_to_selection) : Remove incorrect
precondition.
2000-05-27 Valek Filippov <frob@df.ru>
* src/functions/fn-math.c, fn-stat.c, fn-lookup.c: typos in
......
......@@ -2,6 +2,8 @@ Gnumeric 0.55
Jody:
* Speedup workbook exit, copy/paste.
* Improve copy/paste, added undo.
* More work on function druid.
Morten:
* Changed a bunch of internals to work with StyleFormats instead
......
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy) : Move the handling of singletons
and the setting of the selection here.
* src/clipboard.c (clipboard_paste_region) : From here.
* src/cmd-edit.c (cmd_paste_to_selection) : Remove incorrect
precondition.
2000-05-27 Valek Filippov <frob@df.ru>
* src/functions/fn-math.c, fn-stat.c, fn-lookup.c: typos in
......
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy) : Move the handling of singletons
and the setting of the selection here.
* src/clipboard.c (clipboard_paste_region) : From here.
* src/cmd-edit.c (cmd_paste_to_selection) : Remove incorrect
precondition.
2000-05-27 Valek Filippov <frob@df.ru>
* src/functions/fn-math.c, fn-stat.c, fn-lookup.c: typos in
......
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy) : Move the handling of singletons
and the setting of the selection here.
* src/clipboard.c (clipboard_paste_region) : From here.
* src/cmd-edit.c (cmd_paste_to_selection) : Remove incorrect
precondition.
2000-05-27 Valek Filippov <frob@df.ru>
* src/functions/fn-math.c, fn-stat.c, fn-lookup.c: typos in
......
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy) : Move the handling of singletons
and the setting of the selection here.
* src/clipboard.c (clipboard_paste_region) : From here.
* src/cmd-edit.c (cmd_paste_to_selection) : Remove incorrect
precondition.
2000-05-27 Valek Filippov <frob@df.ru>
* src/functions/fn-math.c, fn-stat.c, fn-lookup.c: typos in
......
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy) : Move the handling of singletons
and the setting of the selection here.
* src/clipboard.c (clipboard_paste_region) : From here.
* src/cmd-edit.c (cmd_paste_to_selection) : Remove incorrect
precondition.
2000-05-27 Valek Filippov <frob@df.ru>
* src/functions/fn-math.c, fn-stat.c, fn-lookup.c: typos in
......
......@@ -91,6 +91,11 @@ paste_cell_flags (Sheet *dest_sheet, int target_col, int target_row,
* @context : The context for error handling.
* @pt : Where to paste the values.
* @content : The CellRegion to paste.
*
* Pastes the supplied CellRegion (@content) into the supplied
* PasteTarget (@pt). This operation is not undoable. It does not auto grow
* the destination if the target is a singleton. This is a simple interface to
* paste a region.
*/
void
clipboard_paste_region (CommandContext *context,
......@@ -111,33 +116,26 @@ clipboard_paste_region (CommandContext *context,
}
/* calculate the tiling */
if (dst_cols == 1 && dst_rows == 1) {
/* If the destination is a singleton paste the entire content */
repeat_horizontal = repeat_vertical = 1;
dst_cols = src_cols;
dst_rows = src_rows;
} else {
repeat_horizontal = dst_cols/src_cols;
if (repeat_horizontal * src_cols != dst_cols) {
char *msg = g_strdup_printf (
_("destination does not have an even multiple of source columns (%d vs %d)\n\n"
"Try selecting a single cell or an area of the same shape and size."),
dst_cols, src_cols);
gnumeric_error_invalid (context, _("Unable to paste"), msg);
g_free (msg);
return;
}
repeat_horizontal = dst_cols/src_cols;
if (repeat_horizontal * src_cols != dst_cols) {
char *msg = g_strdup_printf (
_("destination does not have an even multiple of source columns (%d vs %d)\n\n"
"Try selecting a single cell or an area of the same shape and size."),
dst_cols, src_cols);
gnumeric_error_invalid (context, _("Unable to paste"), msg);
g_free (msg);
return;
}
repeat_vertical = dst_rows/src_rows;
if (repeat_vertical * src_rows != dst_rows) {
char *msg = g_strdup_printf (
_("destination does not have an even multiple of source rows (%d vs %d)\n\n"
"Try selecting a single cell or an area of the same shape and size."),
dst_rows, src_rows);
gnumeric_error_invalid (context, _("Unable to paste"), msg);
g_free (msg);
return;
}
repeat_vertical = dst_rows/src_rows;
if (repeat_vertical * src_rows != dst_rows) {
char *msg = g_strdup_printf (
_("destination does not have an even multiple of source rows (%d vs %d)\n\n"
"Try selecting a single cell or an area of the same shape and size."),
dst_rows, src_rows);
gnumeric_error_invalid (context, _("Unable to paste"), msg);
g_free (msg);
return;
}
if ((pt->range.start.col + dst_cols) >= SHEET_MAX_COLS ||
......@@ -201,24 +199,15 @@ clipboard_paste_region (CommandContext *context,
}
}
if (pt->paste_flags & (PASTE_VALUES|PASTE_FORMULAS)) {
GList *deps =
sheet_region_get_deps (pt->sheet,
pt->range.start.col,
pt->range.start.row,
pt->range.start.col + dst_cols - 1,
pt->range.start.row + dst_rows - 1);
if (pt->paste_flags & (PASTE_FORMULAS|PASTE_VALUES)) {
GList *deps = sheet_region_get_deps (pt->sheet,
pt->range.start.col,
pt->range.start.row,
pt->range.end.col,
pt->range.end.row);
if (deps)
eval_queue_list (deps, TRUE);
}
/* Make the newly pasted content the selection (this queues a redraw) */
sheet_selection_reset_only (pt->sheet);
sheet_selection_add_range (pt->sheet,
pt->range.start.col, pt->range.start.row,
pt->range.start.col, pt->range.start.row,
pt->range.start.col + dst_cols - 1,
pt->range.start.row + dst_rows - 1);
}
typedef struct {
......
......@@ -352,8 +352,6 @@ cmd_paste_to_selection (CommandContext *context, Sheet *dest_sheet, int paste_fl
Range const *dest_range;
PasteTarget pt;
g_return_if_fail (!application_clipboard_is_empty ());
if (!selection_is_simple (context, dest_sheet, _("Paste")))
return;
......
/* vim: set sw=8:
* $Id$
*/
/*
* command.c : Handlers to undo & redo commands
* commands.c: Handlers to undo & redo commands
*
* Copyright (C) 1999, 2000 Jody Goldberg (jgoldberg@home.com)
*
* Author:
* Jody Goldberg <jgoldberg@home.com>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* (C) 1999, 2000 Jody Goldberg
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#include <config.h>
#include "gnumeric-type-util.h"
......@@ -1825,6 +1841,13 @@ cmd_paste_copy_undo (GnumericCommand *cmd, CommandContext *context)
me->content = content;
me->release_content = TRUE;
/* Make the newly pasted content the selection (this queues a redraw) */
sheet_selection_reset_only (me->dst.sheet);
sheet_selection_add_range (me->dst.sheet,
me->dst.range.start.col, me->dst.range.start.row,
me->dst.range.start.col, me->dst.range.start.row,
me->dst.range.end.col, me->dst.range.end.row);
sheet_update (me->dst.sheet);
return FALSE;
......@@ -1864,6 +1887,18 @@ cmd_paste_copy (CommandContext *context,
me->dst = *pt;
me->content = content;
me->release_content = FALSE;
/* If the destination is a singleton paste the entire content */
if (range_is_singleton (&me->dst.range)) {
if (pt->paste_flags & PASTE_TRANSPOSE) {
me->dst.range.end.col = me->dst.range.start.col + content->rows -1;
me->dst.range.end.row = me->dst.range.start.row + content->cols -1;
} else {
me->dst.range.end.col = me->dst.range.start.col + content->cols -1;
me->dst.range.end.row = me->dst.range.start.row + content->rows -1;
}
}
me->parent.cmd_descriptor = g_strdup_printf (_("Pasting into %s"), range_name(&pt->range));
/* Register the command object */
......
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