Commit 76aa836a authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Support-function to handle broken 1.6 formats. Fixes #548414.

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.


svn path=/trunk/; revision=16757
parent 68948126
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 J.H.M. Dassen (Ray) <jdassen@debian.org>
* gnumeric.desktop.in: Add a Version field; drop obsoleted
......
......@@ -32,7 +32,8 @@ Morten:
* 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]
......
2008-08-29 Morten Welinder <terra@gnome.org>
* ms-excel-read.c (excel_wb_get_fmt): Handle broken 1.6 formats.
2008-08-02 Jean Brefort <jean.brefort@normalesup.org>
* xlsx-read.c: Fixed axis position.
......
......@@ -261,12 +261,12 @@ excel_wb_get_fmt (GnmXLImporter *importer, unsigned idx)
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);
}
......
......@@ -293,3 +293,38 @@ gnm_format_has_hour (GOFormat const *fmt,
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;
}
......@@ -45,6 +45,14 @@ GOFormat *gnm_format_for_date_editing (GnmCell const *cell);
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
......
......@@ -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 @@ attr_eq (const xmlChar *a, const char *s)
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;
}
......
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