[gnumeric] Fix cell overflow in case of marked up scientific format. [#686540]



commit a145e5d2ee65a8b62e41e679848bd6bd8ad154a5
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Thu Nov 8 20:08:22 2012 -0700

    Fix cell overflow in case of marked up scientific format. [#686540]
    
    2012-11-08  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/cell-draw.c (cell_draw_simplify_cb): new
    	(cell_draw_simplify_attributes): new
    	(cell_calc_layout): use the above after setting hashes

 ChangeLog       |    6 ++++++
 NEWS            |    3 ++-
 src/cell-draw.c |   21 +++++++++++++++++++++
 3 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 17cebc4..6ee97b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-11-08  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* src/cell-draw.c (cell_draw_simplify_cb): new
+	(cell_draw_simplify_attributes): new
+	(cell_calc_layout): use the above after setting hashes
+
 2012-11-07  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/cell.c (gnm_cell_get_format_given_style): new
diff --git a/NEWS b/NEWS
index db5e632..17739fb 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,8 @@ Andreas:
 	* Fix ODF export of conditional styles including data styles. [#683739]
 	* Fix encounter with macro sheets on xls import. [#684646]
 	* Make ODF import handling of strike-through match LO. [#686789]
-	* Fix style handling in ODF export for empty cells with objects. [#687693] 
+	* Fix style handling in ODF export for empty cells with objects. [#687693]
+	* Fix cell overflow in case of marked up scientific format. [#686540]
 
 Jean:
 	* Fixed indentation in cell format dialog. [#683576]
diff --git a/src/cell-draw.c b/src/cell-draw.c
index 410e7fd..96295ee 100644
--- a/src/cell-draw.c
+++ b/src/cell-draw.c
@@ -27,6 +27,25 @@
 static char const hashes[] =
 "################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################";
 
+static gboolean 
+cell_draw_simplify_cb (PangoAttribute *attribute,
+		       G_GNUC_UNUSED gpointer data)
+{
+	return ((attribute->klass->type == PANGO_ATTR_RISE) ||
+		(attribute->klass->type == PANGO_ATTR_SCALE) ||
+		(attribute->klass->type == PANGO_ATTR_SHAPE));
+}
+
+static void
+cell_draw_simplify_attributes (PangoLayout *layout)
+{
+	PangoAttrList *pal = pango_attr_list_ref 
+		(pango_layout_get_attributes (layout));
+	pango_attr_list_unref 
+		(pango_attr_list_filter 
+		 (pal, (PangoAttrFilterFunc) cell_draw_simplify_cb, NULL));
+}
+
 /*
  *             G      G
  *             r      r
@@ -93,6 +112,7 @@ cell_calc_layout (G_GNUC_UNUSED GnmCell const *cell, GnmRenderedValue *rv, int y
 		   the characters in the number.  Probably ok.  */
 		pango_layout_set_text (layout, hashes,
 				       MIN (sizeof (hashes) - 1, 2 * textlen));
+		cell_draw_simplify_attributes (layout);
 		rv->numeric_overflow = TRUE;
 		rv->variable_width = TRUE;
 		rv->hfilled = TRUE;
@@ -101,6 +121,7 @@ cell_calc_layout (G_GNUC_UNUSED GnmCell const *cell, GnmRenderedValue *rv, int y
 	/* Special handling of error dates.  */
 	if (!was_drawn && rv->numeric_overflow) {
 		pango_layout_set_text (layout, hashes, -1);
+		cell_draw_simplify_attributes (layout);
 		rv->variable_width = TRUE;
 		rv->hfilled = TRUE;
 	}



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