[gnumeric] Foreign paste: improve guessing of pasted range.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Foreign paste: improve guessing of pasted range.
- Date: Mon, 16 Apr 2018 19:34:15 +0000 (UTC)
commit 2102d0f1335fb9a7d955eefc9df6ada1403a2cf2
Author: Morten Welinder <terra gnome org>
Date: Mon Apr 16 15:33:10 2018 -0400
Foreign paste: improve guessing of pasted range.
LibreOffice's paste format fails to specify the range being pasted
so we have to make a guess.
ChangeLog | 3 +++
NEWS | 1 +
src/gui-clipboard.c | 19 +++++++++++++++----
3 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 891122c..fe80718 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
* src/gui-clipboard.c (gnm_x_claim_clipboard): Plug leak. Debug
improvements.
+ (table_cellregion_read): Improve paste-range heuristic for
+ clipboard formats that lack that information, notably
+ LibreOffice's.
* src/workbook-view.c (get_uri_modtime): Fix criticals on paste
from LibreOffice. (Which sends a zipfile over the clipboard.)
diff --git a/NEWS b/NEWS
index 65b40d4..64b0461 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ Morten:
* Test suite improvements.
* Fix problems with boxed types.
* Avoid most punting for object properties.
+ * Fix paste from LibreOffice.
--------------------------------------------------------------------------
Gnumeric 1.12.39
diff --git a/src/gui-clipboard.c b/src/gui-clipboard.c
index db9fd4e..6f323ef 100644
--- a/src/gui-clipboard.c
+++ b/src/gui-clipboard.c
@@ -327,10 +327,21 @@ table_cellregion_read (WorkbookControl *wbc, char const *reader_id,
if (rp) {
r = *rp;
} else {
- r.start.col = 0;
- r.start.row = 0;
- r.end.col = tmpsheet->cols.max_used;
- r.end.row = tmpsheet->rows.max_used;
+ // File format didn't tell us the range being
+ // pasted. Looking at you, LibreOffice!
+ // Make a guess.
+
+ GnmRange fullr;
+ GnmStyle **col_defaults =
+ sheet_style_most_common (tmpsheet, TRUE);
+
+ range_init_full_sheet (&fullr, tmpsheet);
+
+ r = sheet_get_cells_extent (tmpsheet);
+ sheet_style_get_nondefault_extent
+ (tmpsheet, &r, &fullr, col_defaults);
+
+ g_free (col_defaults);
}
ret = clipboard_copy_range (tmpsheet, &r);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]