Commit 1bd931eb authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

For numbers, map '-' to U2212 which has same width as "+".

2005-02-28  Morten Welinder  <terra@gnome.org>

	* src/rendered-value.c (rendered_value_render): For numbers, map
	'-' to U2212 which has same width as "+".

	* src/gnm-format.h: Define a bunch of unicode characters by name.
	* src/parser.y (yylex): Use these.
	* src/cell-draw.c (cell_calc_layout): Ditto.
parent 86264573
2005-02-28 Morten Welinder <terra@gnome.org>
* src/rendered-value.c (rendered_value_render): For numbers, map
'-' to U2212 which has same width as "+".
* src/gnm-format.h: Define a bunch of unicode characters by name.
* src/parser.y (yylex): Use these.
* src/cell-draw.c (cell_calc_layout): Ditto.
2005-02-25 Morten Welinder <terra@gnome.org>
* src/main-application.c (main): Properly get rid of wbcgs when
......
......@@ -33,6 +33,7 @@ Morten:
* Fix saving.
* Fix crash when using --quit. Fix leak too.
* Fix rare crash on exit.
* Use unicode minus (U2212) for numbers. [#168467]
--------------------------------------------------------------------------
Gnumeric 1.5.0
......
2005-02-28 Morten Welinder <terra@gnome.org>
* src/rendered-value.c (rendered_value_render): For numbers, map
'-' to U2212 which has same width as "+".
* src/gnm-format.h: Define a bunch of unicode characters by name.
* src/parser.y (yylex): Use these.
* src/cell-draw.c (cell_calc_layout): Ditto.
2005-02-25 Morten Welinder <terra@gnome.org>
* src/main-application.c (main): Properly get rid of wbcgs when
......
......@@ -14,6 +14,7 @@
#include "style.h"
#include "cell.h"
#include "sheet.h"
#include "gnm-format.h"
#include "rendered-value.h"
#include "parse-util.h"
#include <goffice/utils/go-color.h>
......@@ -24,8 +25,6 @@
static char const hashes[] =
"################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################";
gunichar const zero_width_space = 0x200b;
/*
* G G
* r r
......@@ -122,7 +121,7 @@ cell_calc_layout (GnmCell const *cell, RenderedValue *rv, int y_direction,
int i;
for (i = 0; i < copies; i++) {
if (i)
g_string_append_unichar (multi, zero_width_space);
g_string_append_unichar (multi, UNICODE_ZERO_WIDTH_SPACE_C);
g_string_append_len (multi, copy1, len1);
}
pango_layout_set_text (layout, multi->str, multi->len);
......
......@@ -12,4 +12,23 @@ void format_value_gstring (GString *result,
GnmValue const *value, GOColor *go_color,
double col_width, GODateConventions const *date_conv);
/*
* http://www.unicode.org/charts/PDF/U0080.pdf
* http://www.unicode.org/charts/PDF/U2000.pdf
* http://www.unicode.org/charts/PDF/U20A0.pdf
* http://www.unicode.org/charts/PDF/U2200.pdf
*/
#define UNICODE_LOGICAL_NOT_C 0x00AC
#define UNICODE_ZERO_WIDTH_SPACE_C 0X200B
#define UNICODE_EURO_SIGN_C 0x20AC
#define UNICODE_MINUS_SIGN_C 0x2212
#define UNICODE_DIVISION_SLASH_C 0x2215
#define UNICODE_LOGICAL_AND_C 0x2227
#define UNICODE_LOGICAL_OR_C 0x2228
#define UNICODE_NOT_EQUAL_TO_C 0x2260
#define UNICODE_LESS_THAN_OR_EQUAL_TO_C 0x2264
#define UNICODE_GREATER_THAN_OR_EQUAL_TO_C 0x2265
#endif /* GNM_FORMAT_H */
......@@ -861,13 +861,14 @@ ignore_space_before (gunichar c)
case ')':
case '#':
case '"': case '\'': /* Refers to opening quote only. */
case 0x00AC: /* NOT */
case 0x2215: /* '/' */
case 0x2227: /* AND */
case 0x2228: /* OR */
case 0x2260: /* NE */
case 0x2264: /* LTE */
case 0x2265: /* GTE */
case UNICODE_LOGICAL_NOT_C:
case UNICODE_LOGICAL_AND_C:
case UNICODE_LOGICAL_OR_C:
case UNICODE_MINUS_SIGN_C:
case UNICODE_DIVISION_SLASH_C:
case UNICODE_NOT_EQUAL_TO_C:
case UNICODE_LESS_THAN_OR_EQUAL_TO_C:
case UNICODE_GREATER_THAN_OR_EQUAL_TO_C:
case 0:
return TRUE;
default:
......@@ -886,13 +887,14 @@ ignore_space_after (gunichar c)
case '>': case '<': case '=':
case '(':
case '"': case '\'': /* Refers to closing quote only [not actually hit]. */
case 0x00AC: /* NOT */
case 0x2215: /* '/' */
case 0x2227: /* AND */
case 0x2228: /* OR */
case 0x2260: /* NE */
case 0x2264: /* LTE */
case 0x2265: /* GTE */
case UNICODE_LOGICAL_NOT_C:
case UNICODE_LOGICAL_AND_C:
case UNICODE_LOGICAL_OR_C:
case UNICODE_MINUS_SIGN_C:
case UNICODE_DIVISION_SLASH_C:
case UNICODE_NOT_EQUAL_TO_C:
case UNICODE_LESS_THAN_OR_EQUAL_TO_C:
case UNICODE_GREATER_THAN_OR_EQUAL_TO_C:
case 0:
return TRUE;
default:
......@@ -1280,14 +1282,14 @@ yylex (void)
return (state->array_col_separator == ',')
? ARRAY_START_COMMA : ARRAY_START_BSLASH;
case 0x00AC: return NOT;
case 0x2212: return '-';
case 0x2215: return '/';
case 0x2227: return AND;
case 0x2228: return OR;
case 0x2260: return eat_space (state, NE);
case 0x2264: return eat_space (state, LTE);
case 0x2265: return eat_space (state, GTE);
case UNICODE_LOGICAL_NOT_C: return NOT;
case UNICODE_MINUS_SIGN_C: return '-';
case UNICODE_DIVISION_SLASH_C: return '/';
case UNICODE_LOGICAL_AND_C: return AND;
case UNICODE_LOGICAL_OR_C: return OR;
case UNICODE_NOT_EQUAL_TO_C: return eat_space (state, NE);
case UNICODE_LESS_THAN_OR_EQUAL_TO_C: return eat_space (state, LTE);
case UNICODE_GREATER_THAN_OR_EQUAL_TO_C: return eat_space (state, GTE);
}
if (ignore_space_after (c))
......
......@@ -63,6 +63,9 @@ static GOMemChunk *rendered_value_pool;
#endif
static int minus_utf8_len;
static char minus_utf8[6];
static guint16
calc_indent (PangoContext *context, const GnmStyle *mstyle, Sheet *sheet)
{
......@@ -109,6 +112,7 @@ rendered_value_render (GString *str,
} else if (sheet && sheet->hide_zero && cell_is_zero (cell)) {
*go_color = 0;
} else if (mstyle_is_element_set (mstyle, MSTYLE_FORMAT)) {
gboolean handle_minus;
double col_width = -1.;
/* entered text CAN be null if called by set_value */
GOFormat *format = mstyle_get_format (mstyle);
......@@ -155,6 +159,26 @@ rendered_value_render (GString *str,
format_value_gstring (str, format, cell->value, go_color,
col_width,
sheet ? workbook_date_conv (sheet->workbook) : NULL);
switch (VALUE_TYPE (cell->value)) {
case VALUE_INTEGER:
handle_minus = (value_get_as_int (cell->value) < 0);
break;
case VALUE_FLOAT:
handle_minus = (value_get_as_float (cell->value) < 1.0);
break;
default:
handle_minus = FALSE;
break;
}
if (handle_minus) {
unsigned i;
for (i = 0; i < str->len; i++)
if (str->str[i] == '-') {
str->str[i] = minus_utf8[0];
g_string_insert_len (str, i + 1, minus_utf8 + 1, minus_utf8_len - 1);
i += minus_utf8_len - 1;
}
}
} else {
g_warning ("No format: serious error");
}
......@@ -578,6 +602,7 @@ cell_rendered_offset (GnmCell const * cell)
void
rendered_value_init (void)
{
minus_utf8_len = g_unichar_to_utf8 (UNICODE_MINUS_SIGN_C, minus_utf8);
#if USE_RV_POOLS
rendered_value_pool =
go_mem_chunk_new ("rendered value pool",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment