[gnumeric] add gnm_cell_get_format_given_style to be used in odf_write_cell



commit 393344373c88ef318e0204459999a572ee59c011
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Nov 7 13:22:01 2012 -0700

    add gnm_cell_get_format_given_style to be used in odf_write_cell
    
    2012-11-07  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-write.c (odf_write_cell): use
    	gnm_cell_get_format_given_style
    	instead of gnm_style_get_format instead
    
    2012-11-07  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/cell.c (gnm_cell_get_format_given_style): new
    	(gnm_cell_get_format): use gnm_cell_get_format_given_style

 ChangeLog                             |    5 +++++
 plugins/openoffice/ChangeLog          |    6 ++++++
 plugins/openoffice/openoffice-write.c |    8 ++++----
 src/cell.c                            |   23 ++++++++++++++++++++---
 src/cell.h                            |    1 +
 5 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 44092e0..17cebc4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-11-07  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* src/cell.c (gnm_cell_get_format_given_style): new
+	(gnm_cell_get_format): use gnm_cell_get_format_given_style
+
 2012-11-04  Jean Brefort  <jean brefort normalesup org>
 
 	* src/sheet.c: add API doc for sheet_cells to fix an introspection warning.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index f016650..a7dddee 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,9 @@
+2012-11-07  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-write.c (odf_write_cell): use
+	gnm_cell_get_format_given_style
+	instead of gnm_style_get_format instead
+
 2012-11-05  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-write.c (odf_write_cell): use gnm_style_get_format instead of
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 62ab57f..b035e1a 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3222,7 +3222,7 @@ odf_write_cell (GnmOOExport *state, GnmCell *cell, GnmRange const *merge_range,
 				value_get_as_bool (cell->value, NULL));
 			break;
 		case VALUE_FLOAT: {
-			GOFormat const *fmt = style ? gnm_style_get_format (style) : gnm_cell_get_format (cell);
+			GOFormat const *fmt = gnm_cell_get_format_given_style (cell, style);
 			if (go_format_is_date (fmt)) {
 				char *str;
 				gnm_float f = value_get_as_float (cell->value);
@@ -3295,8 +3295,8 @@ odf_write_cell (GnmOOExport *state, GnmCell *cell, GnmRange const *merge_range,
 	odf_write_objects (state, objects);
 
 	if (cell != NULL && cell->value != NULL) {
-		gboolean pp = TRUE;
-		g_object_get (G_OBJECT (state->xml), "pretty-print", &pp, NULL);
+		gboolean pprint = TRUE;
+		g_object_get (G_OBJECT (state->xml), "pretty-print", &pprint, NULL);
 		g_object_set (G_OBJECT (state->xml), "pretty-print", FALSE, NULL);
 
 		if ((VALUE_FMT (cell->value) == NULL)
@@ -3328,7 +3328,7 @@ odf_write_cell (GnmOOExport *state, GnmCell *cell, GnmRange const *merge_range,
 
 			g_string_free (str, TRUE);
 		}
-		g_object_set (G_OBJECT (state->xml), "pretty-print", pp, NULL);
+		g_object_set (G_OBJECT (state->xml), "pretty-print", pprint, NULL);
 	}
 
 
diff --git a/src/cell.c b/src/cell.c
index 5f690c9..68991e7 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -917,20 +917,24 @@ gnm_cell_get_style (GnmCell const *cell)
 }
 
 /**
- * gnm_cell_get_format:
+ * gnm_cell_get_format_given_style:
  * @cell:
+ * @style:
  *
  * Get the display format.  If the assigned format is General,
  * the format of the value will be used.
  **/
 GOFormat const *
-gnm_cell_get_format (GnmCell const *cell)
+gnm_cell_get_format_given_style (GnmCell const *cell, GnmStyle const *style)
 {
 	GOFormat const *fmt;
 
 	g_return_val_if_fail (cell != NULL, go_format_general ());
 
-	fmt = gnm_style_get_format (gnm_cell_get_style (cell));
+	if (style == NULL)
+		style = gnm_cell_get_style (cell);
+
+	fmt = gnm_style_get_format (style);
 
 	g_return_val_if_fail (fmt != NULL, go_format_general ());
 
@@ -941,6 +945,19 @@ gnm_cell_get_format (GnmCell const *cell)
 	return fmt;
 }
 
+/**
+ * gnm_cell_get_format:
+ * @cell:
+ *
+ * Get the display format.  If the assigned format is General,
+ * the format of the value will be used.
+ **/
+GOFormat const *
+gnm_cell_get_format (GnmCell const *cell)
+{
+	gnm_cell_get_format_given_style (cell, NULL);	
+}
+
 /*
  * gnm_cell_set_format:
  *
diff --git a/src/cell.h b/src/cell.h
index e391c90..d1a1818 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -77,6 +77,7 @@ void gnm_cell_convert_expr_to_value	(GnmCell *cell);
  */
 GnmStyle const *gnm_cell_get_style	(GnmCell const *cell);
 GOFormat const *gnm_cell_get_format	(GnmCell const *cell);
+GOFormat const *gnm_cell_get_format_given_style (GnmCell const *cell, GnmStyle const *style);
 void	gnm_cell_set_format		(GnmCell *cell, char const *format);
 
 GnmRenderedValue *gnm_cell_get_rendered_value (GnmCell const *cell);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]