After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 656056 - Incorrect creation of scientific format
Incorrect creation of scientific format
Status: RESOLVED FIXED
Product: libgoffice
Classification: Other
Component: General
0.8.x
Other Linux
: Normal normal
: ---
Assigned To: Jody Goldberg
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2011-08-05 20:41 UTC by Andreas J. Guelzow
Modified: 2011-08-08 16:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sample file (5.25 KB, application/vnd.oasis.opendocument.spreadsheet)
2011-08-05 20:46 UTC, Andreas J. Guelzow
Details

Description Andreas J. Guelzow 2011-08-05 20:41:41 UTC
Breakpoint 2, odf_scientific (xin=0xbfffdbd8, attrs=0x87b35e8)
    at openoffice-read.c:4052
4052		go_format_generate_str (state->cur_format.accum, details);
(gdb) p *details
$2 = {family = GO_FORMAT_SCIENTIFIC, magic = GO_FORMAT_MAGIC_NONE, 
  min_digits = 1, num_decimals = 2, thousands_sep = 0, negative_red = 0, 
  negative_paren = 0, currency = 0x0, force_quoted = 0, exponent_step = 1, 
  exponent_digits = 4, use_markup = 1, simplify_mantissa = 0, expansion = {
    0 <repeats 30 times>}}
(gdb) p state->cur_format.accum->str
$4 = (gchar *) 0x87b3a50 ""
(gdb) n
[Thread 0xb3200b70 (LWP 2445) exited]
4054		go_format_details_free (details);
(gdb) p state->cur_format.accum->str
$5 = (gchar *) 0x87b3a50 "0.00EE0"

Note that exponent_digits = 4 but the created format string does not reflect that!
Comment 1 Andreas J. Guelzow 2011-08-05 20:46:46 UTC
Created attachment 193328 [details]
sample file

Both cells should have 4 digits in the exponent. In the use_markup=TRUE case this fails.
Comment 2 Andreas J. Guelzow 2011-08-05 21:20:51 UTC
The code makes it look intentional, but why?

We have:

	if (details->use_markup)
		g_string_append (dst, "EE0");
	else {
		/* Maximum not terribly important. */
		int digits = CLAMP (details->exponent_digits, 1, 10);
		g_string_append (dst, "E+");
		go_string_append_c_n (dst, '0', digits);
	}

I think this should just be:

	int digits;

	if (details->use_markup)
		g_string_append_c (dst, 'E');

	/* Maximum not terribly important. */
        digits = CLAMP (details->exponent_digits, 1, 10);
	g_string_append (dst, "E+");
	go_string_append_c_n (dst, '0', digits);
Comment 3 Andreas J. Guelzow 2011-08-05 21:21:21 UTC
That's in go_format_generate_scientific_str
Comment 4 Andreas J. Guelzow 2011-08-08 16:37:02 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.