[gnumeric] odf: be a bit smarter when inserting embedded text.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] odf: be a bit smarter when inserting embedded text.
- Date: Tue, 1 Apr 2014 00:59:22 +0000 (UTC)
commit 1d3c4e4b57d7e33bc19e8d038762f1d2685b64fe
Author: Morten Welinder <terra gnome org>
Date: Mon Mar 31 20:58:52 2014 -0400
odf: be a bit smarter when inserting embedded text.
plugins/openoffice/ChangeLog | 4 +++
plugins/openoffice/openoffice-read.c | 46 +++++++++++++++++++++++++---------
2 files changed, 38 insertions(+), 12 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 545c6eb..12d2506 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,7 @@
+2014-03-31 Morten Welinder <terra gnome org>
+
+ * openoffice-read.c (odf_insert_in_integer): Be a bit smarter.
+
2014-03-31 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (odf_number): try to recognize LO's GENERAL
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index d45dadd..67cf71c 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4834,18 +4834,40 @@ odf_embedded_text_start (GsfXMLIn *xin, xmlChar const **attrs)
}
static void
-odf_insert_in_integer (OOParseState *state, char *str)
-{
- /* We want to insert str in front of the state->cur_format.offset's integer digit */
- /* For the moment we assume that we have just an integer and str does not contain */
- /* any quotation marks */
-
- g_string_insert (state->cur_format.accum,
- state->cur_format.accum->len - state->cur_format.offset,
- "\"\"");
- g_string_insert (state->cur_format.accum,
- state->cur_format.accum->len - state->cur_format.offset - 1,
- str);
+odf_insert_in_integer (OOParseState *state, const char *str)
+{
+ gboolean needs_quoting = FALSE;
+ const char *p;
+ GString *accum = state->cur_format.accum;
+ int pos = state->cur_format.offset;
+
+ g_return_if_fail (pos >= 0 && pos < (int)accum->len);
+
+ /*
+ * We want to insert str in front of the state->cur_format.offset's
+ * integer digit. For the moment we assume that we have just an
+ * integer and str does not contain any quotation marks
+ */
+
+ for (p = str; *p; p++) {
+ switch (*p) {
+ case '-':
+ case ' ':
+ case '(':
+ case ')':
+ break;
+ default:
+ needs_quoting = TRUE;
+ break;
+ }
+ }
+
+ if (needs_quoting) {
+ g_string_insert (accum, accum->len - pos, "\"\"");
+ g_string_insert (accum, accum->len - pos - 1, str);
+ } else {
+ g_string_insert (accum, accum->len - pos, str);
+ }
}
static void
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]