Commit 13f125e4 authored by Morten Welinder's avatar Morten Welinder

xlsx: fix roundtrip for columns.

Column width is an inexact science, so don't let 1e-5 changes get in
the way.
parent f93795ad
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,
......
......@@ -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.
......
......@@ -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);
}
......
......@@ -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 &&
......
......@@ -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);
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