gnumeric r16757 - in trunk: . plugins/excel src
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16757 - in trunk: . plugins/excel src
- Date: Fri, 29 Aug 2008 19:01:11 +0000 (UTC)
Author: mortenw
Date: Fri Aug 29 19:01:11 2008
New Revision: 16757
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16757&view=rev
Log:
2008-08-29 Morten Welinder <terra gnome org>
* src/gnm-format.c (gnm_format_import): Support-function to handle
broken 1.6 formats. Fixes #548414.
* src/xml-sax-read.c (make_format): Handle broken 1.6 formats.
2008-08-29 Morten Welinder <terra gnome org>
* ms-excel-read.c (excel_wb_get_fmt): Handle broken 1.6 formats.
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/plugins/excel/ChangeLog
trunk/plugins/excel/ms-excel-read.c
trunk/src/gnm-format.c
trunk/src/gnm-format.h
trunk/src/xml-sax-read.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Fri Aug 29 19:01:11 2008
@@ -32,7 +32,8 @@
* Make ssgrep a lot more grep-like.
* Unify functions that work on sorted ranges.
* Fix date entry problem. [#540198]
- * Fix entry of error constants. [#546759]
+ * Fix entry of error constants. [#546759]
+ * Fix import of broken 1.6 formats. [#548414]
Nick Lamb:
* Retain ()s. [#69813]
Modified: trunk/plugins/excel/ms-excel-read.c
==============================================================================
--- trunk/plugins/excel/ms-excel-read.c (original)
+++ trunk/plugins/excel/ms-excel-read.c Fri Aug 29 19:01:11 2008
@@ -261,12 +261,12 @@
g_printerr ("Unknown format: 0x%x\n", idx);
if (ans) {
- GOFormat *fmt = go_format_new_from_XL (ans);
-
- if (go_format_is_invalid (fmt)) {
- g_warning ("Ignoring invalid format [%s]",
- go_format_as_XL (fmt));
- go_format_unref (fmt);
+ GOFormat *fmt = gnm_format_import
+ (ans,
+ GNM_FORMAT_IMPORT_NULL_INVALID |
+ GNM_FORMAT_IMPORT_PATCHUP_INCOMPLETE);
+ if (!fmt) {
+ g_warning ("Ignoring invalid format [%s]", ans);
fmt = go_format_general ();
go_format_ref (fmt);
}
Modified: trunk/src/gnm-format.c
==============================================================================
--- trunk/src/gnm-format.c (original)
+++ trunk/src/gnm-format.c Fri Aug 29 19:01:11 2008
@@ -293,3 +293,38 @@
return go_format_has_hour (fmt);
}
+
+GOFormat *
+gnm_format_import (const char *fmt,
+ GnmFormatImportFlags flags)
+{
+ GOFormat *res = go_format_new_from_XL (fmt);
+ size_t len;
+
+ if (!go_format_is_invalid (res))
+ return res;
+
+ len = strlen (fmt);
+ if ((flags & GNM_FORMAT_IMPORT_PATCHUP_INCOMPLETE) &&
+ len > 0 &&
+ fmt[len - 1] == '_') {
+ GString *fmt2 = g_string_new (fmt);
+ GOFormat *res2;
+
+ g_string_append_c (fmt2, ')');
+ res2 = go_format_new_from_XL (fmt2->str);
+ g_string_free (fmt2, TRUE);
+
+ if (!go_format_is_invalid (res2)) {
+ go_format_unref (res);
+ return res2;
+ }
+ }
+
+ if (flags & GNM_FORMAT_IMPORT_NULL_INVALID) {
+ go_format_unref (res);
+ res = NULL;
+ }
+
+ return res;
+}
Modified: trunk/src/gnm-format.h
==============================================================================
--- trunk/src/gnm-format.h (original)
+++ trunk/src/gnm-format.h Fri Aug 29 19:01:11 2008
@@ -45,6 +45,14 @@
gboolean gnm_format_has_hour (GOFormat const *fmt,
GnmValue const *value);
+typedef enum {
+ GNM_FORMAT_IMPORT_NULL_INVALID,
+ GNM_FORMAT_IMPORT_PATCHUP_INCOMPLETE
+} GnmFormatImportFlags;
+
+GOFormat *gnm_format_import (const char *fmt,
+ GnmFormatImportFlags flags);
+
/*
* http://www.unicode.org/charts/PDF/U0080.pdf
* http://www.unicode.org/charts/PDF/U2000.pdf
Modified: trunk/src/xml-sax-read.c
==============================================================================
--- trunk/src/xml-sax-read.c (original)
+++ trunk/src/xml-sax-read.c Fri Aug 29 19:01:11 2008
@@ -53,6 +53,7 @@
#include "sheet-object-cell-comment.h"
#include "gnm-so-line.h"
#include "gnm-so-filled.h"
+#include "gnm-format.h"
#include "sheet-object-graph.h"
#include "application.h"
#include "xml-io.h"
@@ -90,12 +91,12 @@
static GOFormat *
make_format (const char *str)
{
- GOFormat *res = go_format_new_from_XL (str);
-
- if (go_format_is_invalid (res)) {
- g_warning ("Ignoring invalid format [%s]",
- go_format_as_XL (res));
- go_format_unref (res);
+ GOFormat *res =
+ gnm_format_import (str,
+ GNM_FORMAT_IMPORT_NULL_INVALID |
+ GNM_FORMAT_IMPORT_PATCHUP_INCOMPLETE);
+ if (!res) {
+ g_warning ("Ignoring invalid format [%s]", str);
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]