[gnumeric] distinguish <> from <
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] distinguish <> from <
- Date: Tue, 2 Jun 2009 23:32:17 -0400 (EDT)
commit 66457f486b40925aa017e6accf4aefc1f0f3e593
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Tue Jun 2 21:31:36 2009 -0600
distinguish <> from <
2009-06-02 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (odf_number_style_end): shorten code and distinguish
<> from <
---
plugins/openoffice/ChangeLog | 5 ++
plugins/openoffice/openoffice-read.c | 90 +++++++++++++++++++++++-----------
2 files changed, 67 insertions(+), 28 deletions(-)
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 3554b75..872fb7f 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,10 @@
2009-06-02 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-read.c (odf_number_style_end): shorten code and distinguish
+ <> from <
+
+2009-06-02 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* openoffice-read.c (oo_cell_start): fix style leak
2009-06-02 Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 1cf93a8..5dc33ee 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1921,20 +1921,19 @@ odf_number_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
lf = state->cond_formats;
while (lc && lf) {
char *cond = lc->data;
- if (*cond == '>') {
+ if (cond != NULL && *cond == '>') {
char *val = cond + strcspn (cond, "0123456789.");
float value = atof (val);
- if (value != 0. || (*(cond+1) != '=')) {
- g_string_append_c (state->accum_fmt, '[');
- g_string_append_c (state->accum_fmt, '>');
- if (*(cond+1) == '=')
- g_string_append_c (state->accum_fmt, '=');
- g_string_append_printf (state->accum_fmt, "%.2f", value);
- g_string_append_c (state->accum_fmt, ']');
- }
+ if (value != 0. || (*(cond+1) != '='))
+ g_string_append_printf
+ (state->accum_fmt,
+ (*(cond+1) == '=') ? "[>=%.2f]" : "[>%.2f]", value);
g_string_append (state->accum_fmt, go_format_as_XL
(g_hash_table_lookup (state->formats, lf->data)));
parts++;
+ g_free (lc->data);
+ lc->data = NULL;
+ break;
}
lc = lc->next;
lf = lf->next;
@@ -1945,16 +1944,37 @@ odf_number_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
lf = state->cond_formats;
while (lc && lf) {
char *cond = lc->data;
- if (*cond == '=') {
+ if (cond != NULL && *cond == '=') {
+ char *val = cond + strcspn (cond, "0123456789.");
+ float value = atof (val);
+ g_string_append_printf (state->accum_fmt, "[=%.2f]", value);
+ g_string_append (state->accum_fmt, go_format_as_XL
+ (g_hash_table_lookup (state->formats, lf->data)));
+ parts++;
+ g_free (lc->data);
+ lc->data = NULL;
+ break;
+ }
+ lc = lc->next;
+ lf = lf->next;
+ }
+ }
+
+ if (parts == 0) {
+ lc = state->conditions;
+ lf = state->cond_formats;
+ while (lc && lf) {
+ char *cond = lc->data;
+ if (cond != NULL && *cond == '<' && *(cond + 1) == '>') {
char *val = cond + strcspn (cond, "0123456789.");
float value = atof (val);
- g_string_append_c (state->accum_fmt, '[');
- g_string_append_c (state->accum_fmt, '=');
- g_string_append_printf (state->accum_fmt, "%.2f", value);
- g_string_append_c (state->accum_fmt, ']');
+ g_string_append_printf (state->accum_fmt, "[<>%.2f]", value);
g_string_append (state->accum_fmt, go_format_as_XL
(g_hash_table_lookup (state->formats, lf->data)));
parts++;
+ g_free (lc->data);
+ lc->data = NULL;
+ break;
}
lc = lc->next;
lf = lf->next;
@@ -1970,19 +1990,15 @@ odf_number_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
lf = state->cond_formats;
while (lc && lf) {
char *cond = lc->data;
- if (*cond == '<') {
+ if (cond != NULL && *cond == '<' && *(cond + 1) != '>') {
char *val = cond + strcspn (cond, "0123456789.");
float value = atof (val);
if (parts > 0)
g_string_append_c (state->accum_fmt, ';');
- if (value != 0. || (*(cond+1) != '=')) {
- g_string_append_c (state->accum_fmt, '[');
- g_string_append_c (state->accum_fmt, '<');
- if (*(cond+1) == '=')
- g_string_append_c (state->accum_fmt, '=');
- g_string_append_printf (state->accum_fmt, "%.2f", value);
- g_string_append_c (state->accum_fmt, ']');
- }
+ if (value != 0. || (*(cond+1) != '='))
+ g_string_append_printf
+ (state->accum_fmt,
+ (*(cond+1) == '=') ? "[<=%.2f]" : "[<%.2f]", value);
g_string_append (state->accum_fmt, go_format_as_XL
(g_hash_table_lookup (state->formats, lf->data)));
parts++;
@@ -1996,24 +2012,42 @@ odf_number_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
lf = state->cond_formats;
while (lc && lf) {
char *cond = lc->data;
- if (*cond == '=') {
+ if (cond != NULL && *cond == '=') {
char *val = cond + strcspn (cond, "0123456789.");
float value = atof (val);
if (parts > 0)
g_string_append_c (state->accum_fmt, ';');
- g_string_append_c (state->accum_fmt, '[');
- g_string_append_c (state->accum_fmt, '=');
- g_string_append_printf (state->accum_fmt, "%.2f", value);
- g_string_append_c (state->accum_fmt, ']');
+ g_string_append_printf (state->accum_fmt, "[=%.2f]", value);
g_string_append (state->accum_fmt, go_format_as_XL
(g_hash_table_lookup (state->formats, lf->data)));
parts++;
+ break;
}
lc = lc->next;
lf = lf->next;
}
}
+ if (parts < 2) {
+ lc = state->conditions;
+ lf = state->cond_formats;
+ while (lc && lf) {
+ char *cond = lc->data;
+ if (cond != NULL && *cond == '<' && *(cond + 1) == '>') {
+ char *val = cond + strcspn (cond, "0123456789.");
+ float value = atof (val);
+ if (parts > 0)
+ g_string_append_c (state->accum_fmt, ';');
+ g_string_append_printf (state->accum_fmt, "[<>%.2f]", value);
+ g_string_append (state->accum_fmt, go_format_as_XL
+ (g_hash_table_lookup (state->formats, lf->data)));
+ parts++;
+ break;
+ }
+ lc = lc->next;
+ lf = lf->next;
+ }
+ }
if (accum != NULL) {
if (parts > 0)
g_string_append_c (state->accum_fmt, ';');
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]