[gnumeric] Allow single merge to single merge copying. [#87296]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Allow single merge to single merge copying. [#87296]
- Date: Sun, 18 Jul 2010 07:01:26 +0000 (UTC)
commit 0b01416305cc8d701944a278170026012c1942b6
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sun Jul 18 01:01:44 2010 -0600
Allow single merge to single merge copying. [#87296]
2010-07-18 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/clipboard.c (clipboard_paste_region): allow single merge to single
merge pasting
* src/commands.c (CmdPasteCopy): add field
(cmd_paste_copy): allow single merge to single merge pasting
ChangeLog | 7 +++++++
NEWS | 1 +
src/clipboard.c | 13 +++++++++++--
src/commands.c | 24 ++++++++++++++++++++++--
4 files changed, 41 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 36d159e..f14975f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-07-18 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/clipboard.c (clipboard_paste_region): allow single merge to single
+ merge pasting
+ * src/commands.c (CmdPasteCopy): add field
+ (cmd_paste_copy): allow single merge to single merge pasting
+
2010-07-16 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/sheet-control-gui.c (context_menu_handler): handle merging and
diff --git a/NEWS b/NEWS
index a762fdd..b3624e5 100644
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,7 @@ Andreas:
[#55124]
* Add merge and unmerge items to the cell context menu.
* Permit double-clicking of functions in the function selector.
+ * Allow single merge to single merge copying. [#87296]
Jean:
* Fix strong/weak cursor display. [#623241]
diff --git a/src/clipboard.c b/src/clipboard.c
index 3df1d69..6b27865 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -380,6 +380,7 @@ clipboard_paste_region (GnmCellRegion const *cr,
GnmRange const *r;
gboolean has_contents, adjust_merges = TRUE;
struct paste_cell_data dat;
+ GnmRange const *merge_src;
g_return_val_if_fail (pt != NULL, TRUE);
g_return_val_if_fail (cr != NULL, TRUE);
@@ -402,13 +403,21 @@ clipboard_paste_region (GnmCellRegion const *cr,
src_cols = cr->cols;
src_rows = cr->rows;
- /* If the source is a single cell */
+
+
+ /* If the source is a single cell or a single merge */
/* Treat a target of a single merge specially, don't split the merge */
- if (src_cols == 1 && src_rows == 1) {
+ if ((src_cols == 1 && src_rows == 1) ||
+ (g_slist_length (cr->merged) == 1 &&
+ (NULL != (merge_src = cr->merged->data)) &&
+ range_height (merge_src) == cr->rows &&
+ range_width (merge_src) == cr->cols)) {
GnmRange const *merge = gnm_sheet_merge_is_corner (pt->sheet, &r->start);
if (merge != NULL && range_equal (r, merge)) {
dst_cols = dst_rows = 1;
adjust_merges = FALSE;
+ src_cols = 1;
+ src_rows = 1;
}
/* Apparently links do not supercede merges */
} else if (pt->paste_flags & PASTE_LINK)
diff --git a/src/commands.c b/src/commands.c
index aa59960..f7768ff 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -2725,6 +2725,7 @@ typedef struct {
gboolean has_been_through_cycle;
gboolean only_objects;
ColRowStateList *saved_sizes;
+ gboolean single_merge_to_single_merge;
} CmdPasteCopy;
static void
@@ -2903,6 +2904,7 @@ cmd_paste_copy (WorkbookControl *wbc,
CmdPasteCopy *me;
int n_r = 1, n_c = 1;
char *range_name;
+ GnmRange const *merge_src;
g_return_val_if_fail (pt != NULL, TRUE);
g_return_val_if_fail (IS_SHEET (pt->sheet), TRUE);
@@ -2925,11 +2927,27 @@ cmd_paste_copy (WorkbookControl *wbc,
me->pasted_objects = NULL;
me->orig_contents_objects =
go_slist_map (cr->objects, (GOMapFunc)sheet_object_dup);
+ me->single_merge_to_single_merge = FALSE;
/* If the input is only objects ignore all this range stuff */
if (!me->only_objects) {
/* see if we need to do any tiling */
GnmRange *r = &me->dst.range;
+ if (g_slist_length (cr->merged) == 1 &&
+ (NULL != (merge_src = cr->merged->data)) &&
+ range_height (merge_src) == cr->rows &&
+ range_width (merge_src) == cr->cols) {
+ /* We are copying from a single merge */
+ GnmRange const *merge = gnm_sheet_merge_is_corner (pt->sheet, &r->start);
+ if (merge != NULL && range_equal (r, merge)) {
+ /* To a single merge */
+ me->single_merge_to_single_merge = TRUE;
+ n_c = n_r = 1;
+ me->dst.paste_flags |= PASTE_DONT_MERGE;
+ goto copy_ready;
+ }
+ }
+
if (pt->paste_flags & PASTE_TRANSPOSE) {
n_c = range_width (r) / cr->rows;
if (n_c < 1) n_c = 1;
@@ -2997,6 +3015,7 @@ cmd_paste_copy (WorkbookControl *wbc,
}
}
+ copy_ready:
/* Use translate to do a quiet sanity check */
if (range_translate (&me->dst.range, pt->sheet, 0, 0)) {
go_cmd_context_error_invalid (GO_CMD_CONTEXT (wbc),
@@ -3006,8 +3025,9 @@ cmd_paste_copy (WorkbookControl *wbc,
return TRUE;
}
- /* no need to test if all we have are objects */
- if ((!me->only_objects) &&
+ /* no need to test if all we have are objects or are copying from */
+ /*a single merge to a single merge*/
+ if ((!me->only_objects) && (!me->single_merge_to_single_merge)&&
sheet_range_splits_region (pt->sheet, &me->dst.range,
NULL, GO_CMD_CONTEXT (wbc), me->cmd.cmd_descriptor)) {
g_object_unref (me);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]