[gnumeric] Export external references to ODF and fix rangeref export.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Export external references to ODF and fix rangeref export.
- Date: Wed, 11 May 2011 05:05:31 +0000 (UTC)
commit 569a765d596b04844eca73be7506ff98e1ba8691
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Tue May 10 23:04:31 2011 -0600
Export external references to ODF and fix rangeref export.
2011-05-10 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-write.c (odf_cellref_as_string_base): extracted from
odf_cellref_as_string
(odf_cellref_as_string): use odf_cellref_as_string_base
(odf_rangeref_as_string): use odf_cellref_as_string
* openoffice-read.c (oo_cell_start): add comments
(oo_style): add comments
(oo_style_end): check for NULL
NEWS | 1 +
plugins/openoffice/ChangeLog | 10 ++++++++
plugins/openoffice/openoffice-read.c | 25 ++++++++++++++-----
plugins/openoffice/openoffice-write.c | 40 +++++++++++++++-----------------
4 files changed, 48 insertions(+), 28 deletions(-)
---
diff --git a/NEWS b/NEWS
index 919caab..a0cb266 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Andreas:
* Restore Gnumeric print range. [#649714]
* Set default, save and restore print file name. [#649711][#649713]
* Some ODF 1.2 export fixes including [#649906] and [#649914].
+ * Export external references to ODF.
Morten:
* Fix problems with localized function docs.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 280d66d..ed6714f 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,13 @@
+2011-05-10 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-write.c (odf_cellref_as_string_base): extracted from
+ odf_cellref_as_string
+ (odf_cellref_as_string): use odf_cellref_as_string_base
+ (odf_rangeref_as_string): use odf_cellref_as_string
+ * openoffice-read.c (oo_cell_start): add comments
+ (oo_style): add comments
+ (oo_style_end): check for NULL
+
2011-05-09 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (openoffice_file_open): initialize cur_control
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 554e9bd..cbcabd5 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -2118,6 +2118,7 @@ oo_cell_start (GsfXMLIn *xin, xmlChar const **attrs)
|| go_format_is_general (gnm_style_get_format (style)))) {
GOFormat *format;
style = (style == NULL) ? gnm_style_new_default () : gnm_style_dup (style);
+ /* Now we have one reference for style */
if (has_datetime) {
format = go_format_default_date_time ();
g_hash_table_replace (state->styles.cell_datetime,
@@ -2130,11 +2131,14 @@ oo_cell_start (GsfXMLIn *xin, xmlChar const **attrs)
format = go_format_default_time ();
g_hash_table_replace (state->styles.cell_time,
g_strdup (style_name), style);
- }
+ }
gnm_style_set_format (style, format);
+ /* Since (has_datetime || has_date || has_time) we now */
+ /* have net 0 references for style */
}
}
}
+ /* 0 references for style */
if (style != NULL)
gnm_style_ref (style);
}
@@ -2641,7 +2645,7 @@ oo_style (GsfXMLIn *xin, xmlChar const **attrs)
: NULL;
state->cur_style.cells = (style != NULL)
? gnm_style_dup (style) : gnm_style_new_default ();
- gnm_style_ref (state->cur_style.cells);
+ gnm_style_ref (state->cur_style.cells); /* We now have 2 references */
state->h_align_is_valid = state->repeat_content = FALSE;
state->text_align = -2;
state->gnm_halign = -2;
@@ -2649,15 +2653,20 @@ oo_style (GsfXMLIn *xin, xmlChar const **attrs)
if (fmt != NULL)
gnm_style_set_format (state->cur_style.cells, fmt);
- if (name != NULL)
+ if (name != NULL) {
g_hash_table_replace (state->styles.cell,
g_strdup (name), state->cur_style.cells);
- else if (0 == strcmp (xin->node->id, "DEFAULT_STYLE")) {
+ /* one reference left for state->cur_style.cells */
+ } else if (0 == strcmp (xin->node->id, "DEFAULT_STYLE")) {
if (state->default_style.cells)
gnm_style_unref (state->default_style.cells);
state->default_style.cells = state->cur_style.cells;
- } else
+ /* one reference left for state->cur_style.cells */
+ } else {
gnm_style_unref (state->cur_style.cells);
+ /* one reference left for state->cur_style.cells */
+ }
+
break;
case OO_STYLE_COL:
@@ -2730,8 +2739,10 @@ oo_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
switch (state->cur_style.type) {
case OO_STYLE_CELL :
- gnm_style_unref (state->cur_style.cells);
- state->cur_style.cells = NULL;
+ if (state->cur_style.cells != NULL) {
+ gnm_style_unref (state->cur_style.cells);
+ state->cur_style.cells = NULL;
+ }
break;
case OO_STYLE_COL :
case OO_STYLE_ROW :
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index c74c26c..8c4f718 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1809,7 +1809,7 @@ odf_print_string (GnmConventionsOut *out, char const *str, char quote)
}
static void
-odf_cellref_as_string (GnmConventionsOut *out,
+odf_cellref_as_string_base (GnmConventionsOut *out,
GnmCellRef const *cell_ref,
gboolean no_sheetname)
{
@@ -1820,16 +1820,14 @@ odf_cellref_as_string (GnmConventionsOut *out,
GnmSheetSize const *ss =
gnm_sheet_get_size2 (size_sheet, out->pp->wb);
- g_string_append (target, "[");
- if (sheet != NULL) {
+ if (sheet != NULL && !no_sheetname) {
if (NULL != out->pp->wb && sheet->workbook != out->pp->wb) {
- /* We need to check this */
- /* char *rel_uri = wb_rel_uri (sheet->workbook, out->pp->wb); */
- /* g_string_append_c (target, '['); */
- /* g_string_append (target, rel_uri); */
- /* g_string_append_c (target, ']'); */
- /* g_free (rel_uri); */
+ char const *ext_ref;
+ ext_ref = go_doc_get_uri ((GODoc *)(sheet->workbook));
+ odf_print_string (out, ext_ref, '\'');
+ g_string_append_c (target, '#');
}
+ g_string_append_c (target, '$');
odf_print_string (out, sheet->name_unquoted, '\'');
}
g_string_append_c (target, '.');
@@ -1844,25 +1842,25 @@ odf_cellref_as_string (GnmConventionsOut *out,
g_string_append_c (target, '$');
g_string_append (target, row_name (pos.row));
- g_string_append (target, "]");
}
-#warning Check on external ref syntax
+static void
+odf_cellref_as_string (GnmConventionsOut *out,
+ GnmCellRef const *cell_ref,
+ gboolean no_sheetname)
+{
+ g_string_append (out->accum, "[");
+ odf_cellref_as_string_base (out, cell_ref, no_sheetname);
+ g_string_append (out->accum, "]");
+}
static void
odf_rangeref_as_string (GnmConventionsOut *out, GnmRangeRef const *ref)
{
g_string_append (out->accum, "[");
- if (ref->a.sheet == NULL)
- g_string_append_c (out->accum, '.');
- cellref_as_string (out, &(ref->a), FALSE);
-
- if (ref->b.sheet == NULL)
- g_string_append (out->accum, ":.");
- else
- g_string_append_c (out->accum, ':');
-
- cellref_as_string (out, &(ref->b), FALSE);
+ odf_cellref_as_string_base (out, &(ref->a), FALSE);
+ g_string_append_c (out->accum, ':');
+ odf_cellref_as_string_base (out, &(ref->b), ref->b.sheet == ref->a.sheet);
g_string_append (out->accum, "]");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]