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 686471 - # ?pi/?? format misrendering
# ?pi/?? format misrendering
Status: RESOLVED FIXED
Product: libgoffice
Classification: Other
Component: General
GIT
Other Linux
: Normal normal
: ---
Assigned To: Jody Goldberg
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2012-10-19 15:28 UTC by Emmanuel Pacaud
Modified: 2012-11-15 22:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Current output (34.20 KB, image/png)
2012-10-19 15:28 UTC, Emmanuel Pacaud
  Details
result of "# ?pi/??" (52.54 KB, image/png)
2012-11-14 19:23 UTC, Emmanuel Pacaud
  Details
screen shot (46.95 KB, image/png)
2012-11-14 20:20 UTC, Andreas J. Guelzow
  Details
screen shot of fraction tab of format dialog (105.89 KB, image/png)
2012-11-15 00:19 UTC, Andreas J. Guelzow
  Details
proposed patch (505 bytes, patch)
2012-11-15 20:24 UTC, Andreas J. Guelzow
rejected Details | Review
alternative (preferred) patch (510 bytes, patch)
2012-11-15 20:33 UTC, Andreas J. Guelzow
committed Details | Review

Description Emmanuel Pacaud 2012-10-19 15:28:34 UTC
Created attachment 226831 [details]
Current output

In tests/chart-fill-tests.gnumeric, axis labels using the ?pi/?? format don't look good at 0 and pi.

They are displayed as 0pi/1 and pi/1, instead of 0 and pi.
Comment 1 Jean Bréfort 2012-10-19 15:40:30 UTC
This is not charting specific. Looks like a format issue.
Comment 2 Morten Welinder 2012-10-19 23:05:54 UTC
Definitely format.  Probably not new.
Comment 3 Andreas J. Guelzow 2012-11-10 01:27:16 UTC
For fractions without the pi we have for format ?/??:
1 --> 1/1
0 --> 0/1
2 --> 2/1


I am not sure what formatting result do we want.
Comment 4 Andreas J. Guelzow 2012-11-13 21:44:45 UTC
For regular (no-pi) fractions ?/?? Excel 2010 does the same as Gnumeric.

Emmanuel, I am pretty sure that you really want:
# ?pi/??

I would say that this is not a bug! But that the user is using the incorrect format.
Comment 5 Emmanuel Pacaud 2012-11-14 09:30:21 UTC
I don't know if the format string is correct or not. It used to do what I want, ie:

0 and 
Comment 6 Emmanuel Pacaud 2012-11-14 09:31:33 UTC
Arrhhh, it looks like bugzilla doesn't like utf8 characters.

The end of my message was:

0 and pi for angles equal to 0° and 180°.

What is the correct format string that does that.
Comment 7 Andreas J. Guelzow 2012-11-14 15:52:47 UTC
As I suggested in comment #4 you may want to try
# ?pi/??
Comment 8 Emmanuel Pacaud 2012-11-14 16:37:36 UTC
It doesn't work with gnumeric head.
Comment 9 Andreas J. Guelzow 2012-11-14 17:05:26 UTC
If you enter =pi() in a Gnumeric cell and format it as # ?pi/?? What do you get in that cell?
Comment 10 Emmanuel Pacaud 2012-11-14 19:23:58 UTC
Created attachment 229003 [details]
result of "# ?pi/??"
Comment 11 Andreas J. Guelzow 2012-11-14 20:20:05 UTC
Created attachment 229006 [details]
screen shot

I get something different with Gnumeric and goffice head.
Comment 12 Emmanuel Pacaud 2012-11-14 21:46:19 UTC
A rounding issue ?
Comment 13 Andreas J. Guelzow 2012-11-14 23:27:35 UTC
I cannot imagine how this could be a rounding issue. And I get the same some result with 3.14 as for =pi().
Comment 14 Andreas J. Guelzow 2012-11-15 00:19:02 UTC
Created attachment 229016 [details]
screen shot of fraction tab of format dialog

Emmanuel, do you get the same result if you use the fraction tab of the format dialog as shown in this screen shot rather than type in the format string?
Comment 15 Andreas J. Guelzow 2012-11-15 00:27:17 UTC
Strange: it is a locale issue. 

I can replicate by switching to a french locale!

If I create the file in the French locale, save it and open in Canadian English locale I still see pi/1 and the format string is 
#\ ??\ pi/??
Specifically, there is no regular space following the # sign!
Comment 16 Morten Welinder 2012-11-15 01:05:06 UTC
The locale string we show in the gui (and thus what was entered) is localized.
We delocalize it to get the actual format used.

Now, if " " is the locale's decimal separator (unlikely) or the locale's
thousand separator (possible) then I get see localization/delocalization
messing things up.  This probably isn't the best tested code!

What does =TEXT(PI(),"# ?pi/??") produce?
Comment 17 Andreas J. Guelzow 2012-11-15 01:43:05 UTC
In Canadian English locale =TEXT(PI(),"# ?pi/??") yields pi
In French locale =TEXT(PI();"# ?pi/??") yields pi/1


If I use the fraction tab to construct the "# ?pi/??" format and save it into a Gnumeric file, then the file content depends on the locale used:

in Canadian English locale:

<gnm:Style HAlign="GNM_HALIGN_GENERAL" VAlign="GNM_VALIGN_BOTTOM" WrapText="0" ShrinkToFit="0" Rotation="0" Shade="0" Indent="0" Locked="1" Hidden="0" Fore="0:0:0" Back="FFFF:FFFF:FFFF" PatternColor="0:0:0" Format="# ?? pi/??">
            <gnm:Font Unit="10" Bold="0" Italic="0" Underline="0" StrikeThrough="0" Script="0">Sans</gnm:Font>
          </gnm:Style>

in French locale:

<gnm:Style HAlign="GNM_HALIGN_GENERAL" VAlign="GNM_VALIGN_BOTTOM" WrapText="0" ShrinkToFit="0" Rotation="0" Shade="0" Indent="0" Locked="1" Hidden="0" Fore="0:0:0" Back="FFFF:FFFF:FFFF" PatternColor="0:0:0" Format="#\ ??\ pi/??">
            <gnm:Font Unit="10" Bold="0" Italic="0" Underline="0" StrikeThrough="0" Script="0">Sans</gnm:Font>
          </gnm:Style>
Comment 18 Andreas J. Guelzow 2012-11-15 01:47:41 UTC
In the french locale " " is the thousand separator.
Comment 19 Andreas J. Guelzow 2012-11-15 02:28:13 UTC
Some more info. In English locale, I put
=TEXT(PI(),"# ?pi/??"):
into  a A1 and saved it as a file.

I then opened the file in Canadian English locale:

Executing # ?pi/??
OP_NUM_FRACTION_SCALE_PI
OP_NUM_FRACTION 1 0 2
OP_NUM_VAL_SIGN
OP_NUM_FRACTION_WHOLE
OP_NUM_PRINTF_F 0
OP_NUM_SIGN
OP_NUM_MOVETO_ONES
OP_CHAR ' '
OP_NUM_DIGIT_1 '#'
OP_NUM_REST_WHOLE
OP_NUM_APPEND_MODE
OP_CHAR '
Comment 20 Andreas J. Guelzow 2012-11-15 02:30:05 UTC
Some more info. In English locale, I put
=TEXT(PI(),"# ?pi/??"):
into  a A1 and saved it as a file.

Note that since bugzilla hates unicode characters I replaced the greek pi with the word pi below.

I then opened the file in Canadian English locale:

Executing # ?pi/??
OP_NUM_FRACTION_SCALE_PI
OP_NUM_FRACTION 1 0 2
OP_NUM_VAL_SIGN
OP_NUM_FRACTION_WHOLE
OP_NUM_PRINTF_F 0
OP_NUM_SIGN
OP_NUM_MOVETO_ONES
OP_CHAR ' '
OP_NUM_DIGIT_1 '#'
OP_NUM_REST_WHOLE
OP_NUM_APPEND_MODE
OP_CHAR 'pi'
OP_NUM_FRACTION_PI_SUM_START
OP_CHAR ' '
OP_NUM_FRACTION_SIGN
OP_CHAR ' '
OP_NUM_DISABLE_THOUSANDS
OP_NUM_FRACTION_NOMINATOR
OP_NUM_PRINTF_F 0
OP_NUM_SIGN
OP_NUM_MOVETO_ONES
OP_NUM_DIGIT_1 '?'
OP_NUM_REST_WHOLE
OP_NUM_APPEND_MODE
OP_NUM_FRACTION_SLASH
OP_CHAR 'pi'
OP_CHAR '/'
OP_NUM_FRACTION_DENOMINATOR
OP_NUM_PRINTF_F 0
OP_NUM_SIGN
OP_NUM_MOVETO_ONES
OP_NUM_DENUM_DIGIT_Q
OP_NUM_DENUM_DIGIT_Q
OP_NUM_REST_WHOLE
OP_NUM_APPEND_MODE
OP_NUM_FRACTION_ALIGN
OP_NUM_FRACTION_BLANK_PI
OP_NUM_FRACTION_SIMPLIFY_PI
OP_NUM_FRACTION_SIMPLIFY_NUMERATOR_PI
OP_NUM_FRACTION_BLANK_WHOLE
OP_END


I then opened it in French locale:

Executing #,?pi/??
OP_NUM_FRACTION_SCALE_PI
OP_NUM_FRACTION 0 0 2
OP_NUM_VAL_SIGN
OP_NUM_DISABLE_THOUSANDS
OP_NUM_FRACTION_NOMINATOR
OP_NUM_PRINTF_F 0
OP_NUM_SIGN
OP_NUM_MOVETO_ONES
OP_NUM_DIGIT_1 '?'
OP_NUM_DIGIT_1 '#'
OP_NUM_REST_WHOLE
OP_NUM_APPEND_MODE
OP_NUM_FRACTION_SLASH
OP_CHAR 'pi'
OP_CHAR '/'
OP_NUM_FRACTION_DENOMINATOR
OP_NUM_PRINTF_F 0
OP_NUM_SIGN
OP_NUM_MOVETO_ONES
OP_NUM_DENUM_DIGIT_Q
OP_NUM_DENUM_DIGIT_Q
OP_NUM_REST_WHOLE
OP_NUM_APPEND_MODE
OP_NUM_FRACTION_ALIGN
OP_NUM_FRACTION_SIMPLIFY_NUMERATOR_PI
OP_END

So we seem to interpret the format string saved in the .gnumeric file as representing a localized string?!
Comment 21 Morten Welinder 2012-11-15 13:30:15 UTC
All formats in .gnumeric go through make_format in xml-sax-read.c
and thus through gnm_format_import which sends it to go_format_new_from_XL.
go_format_new_from_XL takes an English format string.  So the formats
in .gnumeric are not localised.  Whew!

However, TEXT takes a localised format string and explicitly delocalises
it before passing it to go_format_new_from_XL, so that gives the locale
dependency you are observing.  TEXT may thus not be the best way of
investigating this problem.
Comment 22 Andreas J. Guelzow 2012-11-15 19:14:55 UTC
Okay the good news is:

if I create the format in English locale (using the fraction tab), save it in a file and then open it in French locale I get a format that behaves correctly. So there is a problem with the fraction tab interface (and I have some ideas).
Comment 23 Andreas J. Guelzow 2012-11-15 19:40:34 UTC
No, I don't think it is a ui problem.

Checking for localization/delocalization we have:

Localize in : [# ?? pi/??]
Localize out: [#\ ??\ pi/??]
Delocalize in : [#\ ??\ pi/??]
Delocalize out: [#\ ??\ pi/??]


This is okay if [# ?? pi/??] and [#\ ??\ pi/??] would result in the same rendering, but:

french:

Executing #\ ??\ pi/??
OP_NUM_FRACTION_SCALE_PI
OP_NUM_FRACTION 0 0 2
OP_NUM_VAL_SIGN
OP_NUM_DISABLE_THOUSANDS
OP_NUM_FRACTION_NOMINATOR
OP_NUM_PRINTF_F 0
OP_NUM_SIGN
OP_NUM_MOVETO_ONES
OP_CHAR ' '
OP_NUM_DIGIT_1 '?'
OP_NUM_DIGIT_1 '?'
OP_CHAR ' '
OP_NUM_DIGIT_1 '#'
OP_NUM_REST_WHOLE
OP_NUM_APPEND_MODE
OP_NUM_FRACTION_SLASH
OP_CHAR 'pi'
OP_CHAR '/'
OP_NUM_FRACTION_DENOMINATOR
OP_NUM_PRINTF_F 0
OP_NUM_SIGN
OP_NUM_MOVETO_ONES
OP_NUM_DENUM_DIGIT_Q
OP_NUM_DENUM_DIGIT_Q
OP_NUM_REST_WHOLE
OP_NUM_APPEND_MODE
OP_NUM_FRACTION_ALIGN
OP_NUM_FRACTION_SIMPLIFY_NUMERATOR_PI
OP_END



english:

Executing # ?? pi/??
OP_NUM_FRACTION_SCALE_PI
OP_NUM_FRACTION 1 0 2
OP_NUM_VAL_SIGN
OP_NUM_FRACTION_WHOLE
OP_NUM_PRINTF_F 0
OP_NUM_SIGN
OP_NUM_MOVETO_ONES
OP_CHAR ' '
OP_NUM_DIGIT_1 '#'
OP_NUM_REST_WHOLE
OP_NUM_APPEND_MODE
OP_CHAR 'pi'
OP_NUM_FRACTION_PI_SUM_START
OP_CHAR ' '
OP_NUM_FRACTION_SIGN
OP_CHAR ' '
OP_NUM_DISABLE_THOUSANDS
OP_NUM_FRACTION_NOMINATOR
OP_NUM_PRINTF_F 0
OP_NUM_SIGN
OP_NUM_MOVETO_ONES
OP_CHAR ' '
OP_NUM_DIGIT_1 '?'
OP_NUM_DIGIT_1 '?'
OP_NUM_REST_WHOLE
OP_NUM_APPEND_MODE
OP_NUM_FRACTION_SLASH
OP_CHAR '
Comment 24 Andreas J. Guelzow 2012-11-15 19:42:52 UTC
continued:

         pi'
OP_CHAR '/'
OP_NUM_FRACTION_DENOMINATOR
OP_NUM_PRINTF_F 0
OP_NUM_SIGN
OP_NUM_MOVETO_ONES
OP_NUM_DENUM_DIGIT_Q
OP_NUM_DENUM_DIGIT_Q
OP_NUM_REST_WHOLE
OP_NUM_APPEND_MODE
OP_NUM_FRACTION_ALIGN
OP_NUM_FRACTION_BLANK_PI
OP_NUM_FRACTION_SIMPLIFY_PI
OP_NUM_FRACTION_SIMPLIFY_NUMERATOR_PI
OP_NUM_FRACTION_BLANK_WHOLE
OP_END
Comment 25 Andreas J. Guelzow 2012-11-15 20:21:24 UTC
We have two options here:

1) we can change the delocalization
2) we can change the program creation

both are straightforward. Any preferences?
Comment 26 Andreas J. Guelzow 2012-11-15 20:24:46 UTC
Created attachment 229091 [details] [review]
proposed patch

This proposed patch fixes the program creation.
Comment 27 Andreas J. Guelzow 2012-11-15 20:33:38 UTC
Created attachment 229092 [details] [review]
alternative (preferred) patch

This patch changes the delocalization. I prefer it.
Comment 28 Andreas J. Guelzow 2012-11-15 20:44:25 UTC
Excel accepts [#\ ??/??] as meaning the same as [# ??/??] so we should use the patch that fixes program creation ie. the first of these two patches.
Comment 29 Andreas J. Guelzow 2012-11-15 22:11:28 UTC
On closer inspection of Excel's behaviour, Excel does not retain [#\ ??/??] but changes it to [# ??/??]. This is exactly the behaviour that the second patch would cause. 

I will be committing the second patch.
Comment 30 Andreas J. Guelzow 2012-11-15 22:15:52 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.

Emmanuel, if you find related issues please open a new bug.
Comment 31 Andreas J. Guelzow 2012-11-15 22:17:07 UTC
PS: in French locale, if you create the format string by hand, it needs to be:
#\ ??\ pi/??
since the space character is otherwise interpreted as a thousand separator.