Commit 0b014163 authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

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
parent b7a0b9ca
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
......
......@@ -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]
......
......@@ -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)
......
......@@ -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);
......
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