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 651561 - "EE" format doesn't produce superscripts in cells
"EE" format doesn't produce superscripts in cells
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: GUI
git master
Other All
: Normal enhancement
: ---
Assigned To: Andreas J. Guelzow
Jody Goldberg
Depends on:
Blocks: 655605
 
 
Reported: 2011-05-31 16:14 UTC by Andreas J. Guelzow
Modified: 2011-08-02 03:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch to goffice (3.48 KB, patch)
2011-06-01 19:39 UTC, Andreas J. Guelzow
none Details | Review
proposed patch to goffice (3.47 KB, patch)
2011-06-01 19:41 UTC, Andreas J. Guelzow
none Details | Review
proposed patch to goffice (14.99 KB, patch)
2011-06-02 05:53 UTC, Andreas J. Guelzow
none Details | Review
proposed patch to gnumeric (9.44 KB, patch)
2011-06-02 05:55 UTC, Andreas J. Guelzow
none Details | Review
proposed patch to goffice (26.74 KB, patch)
2011-06-02 07:54 UTC, Andreas J. Guelzow
none Details | Review
proposed patch to gnumeric (9.67 KB, patch)
2011-06-02 07:55 UTC, Andreas J. Guelzow
none Details | Review
proposed patch to goffice (27.42 KB, patch)
2011-06-02 08:53 UTC, Andreas J. Guelzow
none Details | Review
proposed patch to goffice (27.43 KB, patch)
2011-06-03 07:30 UTC, Andreas J. Guelzow
none Details | Review
proposed patch to gnumeric (11.19 KB, patch)
2011-06-03 07:32 UTC, Andreas J. Guelzow
none Details | Review
proposed patch to gnumeric (31.90 KB, patch)
2011-06-04 06:05 UTC, Andreas J. Guelzow
none Details | Review
proposed patch to goffice (29.60 KB, patch)
2011-06-04 06:06 UTC, Andreas J. Guelzow
none Details | Review
extended patch for goffice to try to handle the ticks too (35.56 KB, patch)
2011-06-05 00:45 UTC, Andreas J. Guelzow
none Details | Review
extended patch for goffice that also handles the ticks (39.63 KB, patch)
2011-06-05 14:21 UTC, Andreas J. Guelzow
none Details | Review

Description Andreas J. Guelzow 2011-05-31 16:14:56 UTC
#EE0 appears to be accepted as a valid format code by the format selector. The preview shows:
4×10<sup>3</sup>

If the format is chosen the cell shows only 
######## 
but when the cell is selected the formula box shows 
4×10<sup>3</sup>

This bug is extracted from the comments to bug #417631 which is really a charting bug.
Comment 1 Andreas J. Guelzow 2011-05-31 16:20:23 UTC
If you make the cell really wide you see in fact the literal 4×10<sup>3</sup> but this should be shown as superscript!
Comment 2 Morten Welinder 2011-06-01 00:53:22 UTC
This is very close to be "as expected".  At least by me.
Comment 3 Andreas J. Guelzow 2011-06-01 14:52:13 UTC
Since we have already pangomarkup inthe cell we can get true superscripts quite easily:
--------------------------------------------------
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index 6c62419..263055e 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -2511,7 +2511,7 @@ SUFFIX(go_format_execute) (PangoLayout *layout, GString *dst,
                switch (op) {
                case OP_END:
                        if (layout)
-                               pango_layout_set_text (layout, dst->str, -1);
+                               pango_layout_set_markup (layout, dst->str, -1);
                        if (numtxt)
                                g_string_free (numtxt, TRUE);
                        if (oldlocale) {
---------------------------------------------------

Unfortunately once we use pango_layout_set_markup we loose the ability to set pango attributes, ie. font, font size, styles. So this "fix" would not be acceptable.
Comment 4 Morten Welinder 2011-06-01 14:59:27 UTC
As well as the ability to have "<sup>" (with quotes) in the format.
Comment 5 Andreas J. Guelzow 2011-06-01 19:39:19 UTC
Created attachment 189036 [details] [review]
proposed patch to goffice

The only remaining problem I see with this patch is that the superscript is raised by a about 5 points, ie 5000 PangoUnits. This looks okay as a superscript in font sizes of about 10 to 12 point.

This is not that different from what we are doing with super and subscripts in Gnumeric. That's where the 5000 came from. I would have preferred 8 x PANGO_SCALE currently about 8200.
Comment 6 Andreas J. Guelzow 2011-06-01 19:41:55 UTC
Created attachment 189037 [details] [review]
proposed patch to goffice

Oops, the previous patch had my preferred 8*PANGO_SCALE, this one uses 5000.
Comment 7 Morten Welinder 2011-06-01 19:48:53 UTC
pango-markup.c hardcodes 5000, but I suppose we could derive that value
by creating (once) a layout containing "<sup>x</sup>" and looking at that.

Does the patch work within goffice, i.e., do the graph uses still work?
Comment 8 Andreas J. Guelzow 2011-06-01 19:57:09 UTC
hmm, apparently not. The superscripts in graphs now fail.
Comment 9 Andreas J. Guelzow 2011-06-02 05:53:34 UTC
Created attachment 189059 [details] [review]
proposed patch to goffice
Comment 10 Andreas J. Guelzow 2011-06-02 05:55:57 UTC
Created attachment 189060 [details] [review]
proposed patch to gnumeric

This patch and the last patch to goffice are a slight improvement (but not ready for consumption)

This seems to handle the in-sheet cells and the SUM= field correctly.

[Note that this breaks the goffice API so is intended for after branching.]
Comment 11 Andreas J. Guelzow 2011-06-02 07:54:17 UTC
Created attachment 189064 [details] [review]
proposed patch to goffice
Comment 12 Andreas J. Guelzow 2011-06-02 07:55:38 UTC
Created attachment 189065 [details] [review]
proposed patch to gnumeric

These new revisions also handle the preview in the format selector (+- a little issue in go_load_pango_attributes_into_buffer that pango uses bytes and the textbuffer characters)
Comment 13 Andreas J. Guelzow 2011-06-02 08:53:48 UTC
Created attachment 189066 [details] [review]
proposed patch to goffice

This patch also fixes the misalignment between character and byte offset.
Comment 14 Andreas J. Guelzow 2011-06-03 07:30:45 UTC
Created attachment 189138 [details] [review]
proposed patch to goffice
Comment 15 Andreas J. Guelzow 2011-06-03 07:32:44 UTC
Created attachment 189139 [details] [review]
proposed patch to gnumeric

The last two patches fix the problem that the cells did not showed the correct foreground colour (if one was set.)
Comment 16 Morten Welinder 2011-06-03 13:23:54 UTC
In the Gnumeric case, wouldn't it be simpler to create a
format_value_layout instead of adding an attribute return parameter to
format_value_gstring?

It seems to me that splitting the layout into text and attributes risks
losing some setting of the layout.
Comment 17 Andreas J. Guelzow 2011-06-03 14:37:46 UTC
Replacing the GoColor** argument with a PangoAttrList** argument seemed the smaller change (note that these can be NULL if we don't care about them.)

The "format_value_layout" is sort of our gnm_format_value_gstring. (The GString passes info both ways, and it can be called with layout==NULL if we don't care about formatting.)
Comment 18 Andreas J. Guelzow 2011-06-04 06:05:49 UTC
Created attachment 189200 [details] [review]
proposed patch to gnumeric

Updated patches with format_value_layout
Comment 19 Andreas J. Guelzow 2011-06-04 06:06:13 UTC
Created attachment 189201 [details] [review]
proposed patch to goffice
Comment 20 Andreas J. Guelzow 2011-06-05 00:45:21 UTC
Created attachment 189247 [details] [review]
extended patch for goffice to try to handle the ticks too

I have tried to extend the attribute handling into goffice. The problem I encountered is that I can't see a way of getting an appropriate layout in gog-axis.c if I just have an axis and no gog-renderer.
Comment 21 Jean Bréfort 2011-06-05 05:22:53 UTC
I would not do that this way. I think we should attach a PangoAttrList to all goffice structures displaying a text, and change the GogRenderer API accordingly.
Comment 22 Andreas J. Guelzow 2011-06-05 05:55:45 UTC
Jean, the patch attached to comment #19 started adding a PangoAttrList. In view of the second paragraph of comment #16, I was now trying to go the PangoLayout route.
Comment 23 Jean Bréfort 2011-06-05 06:06:15 UTC
OK, then I'll go this way for labels too. Just GOString uses an attribute list, not a layout.
Comment 24 Andreas J. Guelzow 2011-06-05 14:21:18 UTC
Created attachment 189268 [details] [review]
extended patch for goffice that also handles the ticks

This patch to gofice typesets the ticks correctly.

It attaches a layout to each tick _but_ I am not sure that is a good idea: I don't see how we get a correct cairo layout at that time. In the patch we are using a generic layout but later have to copy its information when we get the right layout. This seems to be not much better than attaching a string, attribute list and tab array.
Comment 25 Jean Bréfort 2011-06-07 12:45:02 UTC
We might use a GOString here.
Comment 26 Andreas J. Guelzow 2011-08-02 03:58:05 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.