[gnumeric] xls: fix selection export.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xls: fix selection export.
- Date: Tue, 27 Mar 2012 18:38:35 +0000 (UTC)
commit e010bdfbfd728c59b04f90b9cdf82e94b4e74677
Author: Morten Welinder <terra gnome org>
Date: Tue Mar 27 14:37:52 2012 -0400
xls: fix selection export.
While not important, we were changing the order of the selection.
plugins/excel/ChangeLog | 7 +++++++
plugins/excel/ms-excel-read.c | 15 +++++++++++----
plugins/excel/ms-excel-write.c | 8 +++++++-
3 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 4858fa5..cfba678 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,10 @@
+2012-03-27 Morten Welinder <terra gnome org>
+
+ * ms-excel-read.c (excel_read_SELECTION): Read in sane order.
+
+ * ms-excel-write.c (excel_write_SELECTION): Write in reverse
+ order.
+
2012-03-12 Morten Welinder <terra gnome org>
* ms-formula-write.c (write_node): Handle sets.
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index dac2825..99f0d0c 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -4476,7 +4476,7 @@ excel_read_IMDATA (BiffQuery *q, gboolean keep_image)
static void
excel_read_SELECTION (BiffQuery *q, ExcelReadSheet *esheet)
{
- GnmCellPos edit_pos, tmp;
+ GnmCellPos edit_pos;
unsigned pane_number, i, j, num_refs;
SheetView *sv = sheet_get_view (esheet->sheet, esheet->container.importer->wbv);
GnmRange r;
@@ -4503,10 +4503,17 @@ excel_read_SELECTION (BiffQuery *q, ExcelReadSheet *esheet)
g_return_if_fail (sv != NULL);
sv_selection_reset (sv);
- for (i = 0; i++ < num_refs ; ) {
- xls_read_range8 (&r, q->data + 9 + 6 * (++j % num_refs));
+ for (i = 0; i <= num_refs ; i++) {
+ GnmCellPos tmp;
+ unsigned i0 = (i == num_refs) ? j : i;
- d (5, g_printerr ("Ref %d = %s\n", i-1, range_as_string (&r)););
+ /* Skip the active; then read it last. */
+ if (i == j || i0 >= num_refs)
+ continue;
+
+ xls_read_range8 (&r, q->data + 9 + 6 * i0);
+
+ d (5, g_printerr ("Ref %d = %s\n", i, range_as_string (&r)););
tmp = (i == num_refs) ? edit_pos : r.start;
sv_selection_add_full (sv,
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index c963f5e..2f43d99 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -4965,12 +4965,16 @@ excel_write_SELECTION (BiffPut *bp, GSList *selections,
int n = g_slist_length (selections);
GSList *ptr;
guint8 *data;
+ int i_active = n - 1;
+
+ /* Write backwards. */
+ selections = g_slist_reverse (g_slist_copy (selections));
data = ms_biff_put_len_next (bp, BIFF_SELECTION, 9 + 6*n);
GSF_LE_SET_GUINT8 (data + 0, pane);
GSF_LE_SET_GUINT16 (data + 1, pos->row);
GSF_LE_SET_GUINT16 (data + 3, pos->col);
- GSF_LE_SET_GUINT16 (data + 5, 0); /* our edit_pos is in 1st range */
+ GSF_LE_SET_GUINT16 (data + 5, i_active); /* last due to reverse */
GSF_LE_SET_GUINT16 (data + 7, n);
data += 9;
@@ -4982,6 +4986,8 @@ excel_write_SELECTION (BiffPut *bp, GSList *selections,
GSF_LE_SET_GUINT8 (data + 5, r->end.col);
}
ms_biff_put_commit (bp);
+
+ g_slist_free (selections);
}
static void
excel_write_selections (BiffPut *bp, ExcelWriteSheet *esheet, SheetView *sv)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]