[gnumeric] CSV: Expand columns to fix, e.g., dates.



commit 6939b8cb95287a6ddec54fb4d613047990b00d8e
Author: Morten Welinder <terra gnome org>
Date:   Fri Dec 10 14:26:08 2010 -0500

    CSV: Expand columns to fix, e.g., dates.

 ChangeLog |    7 +++++++
 NEWS      |    1 +
 src/stf.c |   20 ++++++++++++++++++--
 3 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8c7a2d2..e18a381 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-12-10  Morten Welinder  <terra gnome org>
+
+	* src/stf.c (resize_columns): Expand columns to fit
+	numbers (including dates).
+	(stf_read_workbook): Call resize_columns.
+	(stf_read_workbook_auto_csvtab): Ditto.
+
 2010-12-08  Morten Welinder  <terra gnome org>
 
 	* src/func-builtin.c (gnumeric_if2): Take flags argument and use
diff --git a/NEWS b/NEWS
index f86d2a8..43098fa 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ Jean:
 
 Morten:
 	* Fix array intersection problem with IF.  [#633433]
+	* Make sure columns are wide enough for dates in csv import.
 
 --------------------------------------------------------------------------
 Gnumeric 1.10.12
diff --git a/src/stf.c b/src/stf.c
index 60fdfd9..f2996a3 100644
--- a/src/stf.c
+++ b/src/stf.c
@@ -160,6 +160,22 @@ stf_store_results (DialogStfResult_t *dialogresult,
 				start_col, start_row);
 }
 
+static void
+resize_columns (Sheet *sheet)
+{
+	GnmRange r;
+
+	range_init_full_sheet (&r, sheet);
+	colrow_autofit (sheet, &r, TRUE,
+			TRUE, /* Ignore strings */
+			TRUE, /* Don't shrink */
+			TRUE, /* Don't shrink */
+			NULL, NULL);
+
+	sheet_queue_respan (sheet, 0, gnm_sheet_get_last_row (sheet));
+}
+
+
 /**
  * stf_read_workbook
  * @fo       : file opener
@@ -208,7 +224,7 @@ stf_read_workbook (GOFileOpener const *fo,  gchar const *enc,
 		workbook_sheet_attach (book, sheet);
 		if (stf_store_results (dialogresult, sheet, 0, 0)) {
 			workbook_recalc_all (book);
-			sheet_queue_respan (sheet, 0, gnm_sheet_get_last_row (sheet));
+			resize_columns (sheet);
 		} else {
 			/* the user has cancelled */
 			/* the caller should notice that we have no sheets */
@@ -405,7 +421,7 @@ stf_read_workbook_auto_csvtab (GOFileOpener const *fo, gchar const *enc,
 
 	if (stf_parse_sheet (po, utf8data, NULL, sheet, 0, 0)) {
 		workbook_recalc_all (book);
-		sheet_queue_respan (sheet, 0, gnm_sheet_get_last_row (sheet));
+		resize_columns (sheet);
 		if (po->cols_exceeded || po->rows_exceeded) {
 			const char *msg =
 				_("Some data did not fit on the sheet and was dropped.");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]