[gnumeric] xlsx: fix roundtrip for columns.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xlsx: fix roundtrip for columns.
- Date: Mon, 24 Feb 2014 16:48:20 +0000 (UTC)
commit 13f125e459e0f0d7da04bae09104a9916eec17eb
Author: Morten Welinder <terra gnome org>
Date: Mon Feb 24 11:47:23 2014 -0500
xlsx: fix roundtrip for columns.
Column width is an inexact science, so don't let 1e-5 changes get in
the way.
ChangeLog | 5 +++++
plugins/excel/xlsx-read.c | 11 ++++-------
plugins/excel/xlsx-write.c | 4 ++--
src/colrow.c | 2 +-
test/t6502-styles.pl | 1 +
5 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2676263..5a05cf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-24 Morten Welinder <terra gnome org>
+
+ * src/colrow.c (colrow_equal): Don't use floating-point equality
+ here. Allow a difference of 1e-5 pt for size.
+
2014-02-23 Morten Welinder <terra gnome org>
* src/sheet.c (gnm_sheet_resize_main): When expanding a sheet,
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 29932c5..25f2aa8 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -1522,7 +1522,7 @@ xlsx_CT_Col (GsfXMLIn *xin, xmlChar const **attrs)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
int first = -1, last = -1, xf_index;
- gnm_float width = -1.;
+ double width = -1.;
gboolean cust_width = FALSE, best_fit = FALSE, collapsed = FALSE;
int i, hidden = -1;
int outline = -1;
@@ -1556,9 +1556,9 @@ xlsx_CT_Col (GsfXMLIn *xin, xmlChar const **attrs)
last--;
}
+ first = CLAMP (first, 0, gnm_sheet_get_last_col (state->sheet));
+ last = CLAMP (last, 0, gnm_sheet_get_last_col (state->sheet));
- if (last >= gnm_sheet_get_max_cols (state->sheet))
- last = gnm_sheet_get_max_cols (state->sheet) - 1;
for (i = first; i <= last; i++) {
if (width > 4)
sheet_col_set_size_pts (state->sheet, i, width,
@@ -1569,10 +1569,7 @@ xlsx_CT_Col (GsfXMLIn *xin, xmlChar const **attrs)
}
if (NULL != style) {
GnmRange r;
- r.start.col = first;
- r.end.col = last;
- r.start.row = 0;
- r.end.row = gnm_sheet_get_max_rows (state->sheet) - 1;
+ range_init_cols (&r, state->sheet, first, last);
/*
* Sometimes we see a lot of columns with the same style.
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 148846d..7c443b8 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -1204,7 +1204,7 @@ row_boring (Sheet *sheet, int r)
return TRUE;
return (!ri->hard_size &&
- ri->size_pts == sheet->rows.default_style.size_pts &&
+ fabs (ri->size_pts - sheet->rows.default_style.size_pts) < 1e-6 &&
!ri->is_collapsed &&
ri->visible &&
ri->outline_level == 0);
@@ -1254,7 +1254,7 @@ xlsx_write_cells (XLSXWriteState *state, GsfXMLOut *xml,
xlsx_write_init_row (&needs_row, xml, r, cheesy_span);
gsf_xml_out_add_cstr_unchecked (xml, "customHeight", "1");
}
- if (ri->hard_size || ri->size_pts != sheet->cols.default_style.size_pts) {
+ if (ri->hard_size || fabs (ri->size_pts - sheet->cols.default_style.size_pts) > 1e-6)
{
xlsx_write_init_row (&needs_row, xml, r, cheesy_span);
gsf_xml_out_add_float (xml, "ht", ri->size_pts, 4);
}
diff --git a/src/colrow.c b/src/colrow.c
index 08f6c9d..e83c2fc 100644
--- a/src/colrow.c
+++ b/src/colrow.c
@@ -139,7 +139,7 @@ colrow_equal (ColRowInfo const *a, ColRowInfo const *b)
if (b == NULL)
return FALSE;
- return a->size_pts == b->size_pts &&
+ return fabs (a->size_pts - b->size_pts) < 1e-5 &&
a->outline_level == b->outline_level &&
a->is_collapsed == b->is_collapsed &&
a->hard_size == b->hard_size &&
diff --git a/test/t6502-styles.pl b/test/t6502-styles.pl
index da20d8e..f334084 100755
--- a/test/t6502-styles.pl
+++ b/test/t6502-styles.pl
@@ -49,4 +49,5 @@ my $xls_pattern_filter = "$PERL -p -e 'use English; my \%m=(19,14,20,7,21,4,22,4
'format' => 'Gnumeric_Excel:xlsx',
'ext' => "xlsx",
'resize' => '1048576x16384',
+ 'filter1' => $xls_pattern_filter,
'ignore_failure' => 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]