[gnumeric] Improve horizontal fill. [#594193, part 2]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Improve horizontal fill. [#594193, part 2]
- Date: Wed, 30 Jun 2010 20:50:36 +0000 (UTC)
commit da563f65f55aa919f67542aea1a5175691494be1
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Wed Jun 30 14:50:37 2010 -0600
Improve horizontal fill. [#594193, part 2]
2010-06-30 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/gnm-format.c (format_value_common): in one-paragraph mode
replace newlines with visible glyphs.
ChangeLog | 5 +++++
NEWS | 1 +
src/gnm-format.c | 30 ++++++++++++++++++++++++++++++
3 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c15770c..c0ce65d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2010-06-30 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * src/gnm-format.c (format_value_common): in one-paragraph mode
+ replace newlines with visible glyphs.
+
+2010-06-30 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* src/stf-export.c (try_auto_float): new
(stf_export_cell): call try_auto_float
diff --git a/NEWS b/NEWS
index 31f5228..9d9ed29 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Andreas:
* Add new Excel and Openformula units ("pica" and "picapt") to CONVERT.
* Save default search settings. [#105615]
* Improve configurable text export of numbers. [#126444]
+ * Improve horizontal fill. [#594193, part 2]
--------------------------------------------------------------------------
Gnumeric 1.10.7
diff --git a/src/gnm-format.c b/src/gnm-format.c
index 72d02e0..a856247 100644
--- a/src/gnm-format.c
+++ b/src/gnm-format.c
@@ -33,6 +33,9 @@
#include <string.h>
#include <style-font.h>
+#define UTF8_NEWLINE "\xe2\x86\xa9" /* unicode U+21A9 */
+#define UTF8_NEWLINE_RTL "\xe2\x86\xaa" /* unicode U+21AA */
+
static char const *
format_nonnumber (GnmValue const *value)
{
@@ -88,6 +91,7 @@ format_value_common (PangoLayout *layout, GString *str,
GOFormatNumberError err;
gnm_float val;
const char *sval;
+ char *sval_free = NULL;
char type;
g_return_val_if_fail (value != NULL, GO_FORMAT_NUMBER_INVALID_FORMAT);
@@ -111,12 +115,38 @@ format_value_common (PangoLayout *layout, GString *str,
/* Close enough: */
type = VALUE_IS_ERROR (value) ? 'E' : 'S';
sval = format_nonnumber (value);
+ if (sval != NULL && layout != NULL &&
+ pango_layout_get_single_paragraph_mode (layout)
+ && strchr (sval, '\n') != NULL) {
+ /* We are in single paragraph mode. This happens in HALIGN_FILL */
+ GString *str = g_string_new (sval);
+ gchar *ptr;
+ PangoDirection dir;
+ gboolean rtl = FALSE;
+ PangoLayoutLine *line;
+
+ pango_layout_set_text (layout, sval, -1);
+ line = pango_layout_get_line (layout, 0);
+ if (line) {
+ dir = line->resolved_dir;
+ rtl = (dir == PANGO_DIRECTION_RTL || dir == PANGO_DIRECTION_TTB_RTL
+ || dir == PANGO_DIRECTION_WEAK_RTL);
+ }
+
+ while ((ptr = strchr (str->str, '\n')) != NULL) {
+ gssize pos = ptr - str->str;
+ g_string_erase (str, pos, 1);
+ g_string_insert (str, pos, rtl ? UTF8_NEWLINE_RTL : UTF8_NEWLINE);
+ }
+ sval = sval_free = g_string_free (str, FALSE);
+ }
}
err = gnm_format_value_gstring (layout, str, measure, metrics,
format,
val, type, sval,
go_color,
col_width, date_conv, unicode_minus);
+ g_free (sval_free);
switch (err) {
case GO_FORMAT_NUMBER_OK:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]