Bug 119248 - Status bar displays "wrong" sum when colored negative cell format used
Summary: Status bar displays "wrong" sum when colored negative cell format used
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: reviewed:2023
Keywords: easyHack, skillCpp
Depends on:
Blocks: Statusbar
  Show dependency treegraph
 
Reported: 2018-08-13 12:23 UTC by Mike Kaganski
Modified: 2023-08-24 13:49 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2018-08-13 12:23:03 UTC
If current cell is formatted to only show negatives using color, without minus sign, then the format is used to display status bar functions (sum, average, ...), but does not use colors, which is confusing.

Steps:

1. Put -1 to A1, -2 to A2
2. Format A2 to use "0;[RED]0" format string.

Now if you select A2, status bar would show sum as 2; if you select A2 and A1 *starting from A2* (so that thick border marks A2), sum shown as 3 (but if you select them starting from A1, sum is shown a -3).

The problem is that color information is discarded in ScTabViewShell::GetFunction; if we could store the color in the resulting string somehow, then we could use it in SvxPosSizeStatusBarControl::Paint; in that case, we would still need to use undecorated string in SvxPosSizeStatusBarControl::StateChanged when setting item text used in tooltips.

Nominating as easy hack; Eike: could you please also look at it if this is reasonable?
Comment 1 raal 2018-08-13 20:25:20 UTC
reproducible Version: 6.2.0.0.alpha0+
Build ID: ea59fc4831b9d2430de51faa8c3e0a24e6d90cd1
CPU threads: 4; OS: Linux 4.4; UI render: default; VCL: gtk3;
Comment 2 Xisco Faulí 2018-08-21 13:15:53 UTC
Also reproduced in

LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 3 Eike Rathke 2018-08-23 09:59:35 UTC
Transporting colour to display in status bar IMHO would be overkill. Solution probably would be to not use the actually applied format, but the format's locale's category's default format instead. Of course not for currencies..

Suitable as EasyHack, code pointer:
sc/source/ui/view/tabvwsha.cxx
ScTabViewShell::GetFunction()
place calling pDoc->GetNumberFormat(...)

Add something calling SvNumberFormatter::GetStandardFormat( double, sal_uInt32, SvNumFormatType, LanguageType)
Comment 4 Eleni Zapridou 2019-01-25 16:03:30 UTC
I am interested to work on this bug with two coworkers of mine, so I am assigning this to me. We will try to solve this, following the proposing instructions from Eike Rathke.
Comment 5 Eleni Zapridou 2019-01-29 16:55:53 UTC
I am not sure actually this is really a bug. The sum is being displayed correctly but according to the format of the first cell you select.

So for the example of Mike Kaganski:
If you select A2 and then A1 the sum is 3 because of the "0;[RED]0" format (which displays negative numbers without the "-"). 
If you select A1 and then A2 the sum is -3 displayed with the standard format of A1.

I checked the same example using Excel and it has the exact same results.

So I think we should recosinder if this is a bug or not.
Comment 6 Mike Kaganski 2019-03-15 06:13:41 UTC
(In reply to Eleni Zapridou from comment #5)

This is not a bug per se, and it was never stated otherwise. Even the title has "wrong" in quotes.

Still, there's a usability issue. The status bar is incapable of displaying the formatted value using all the features which cells can use - like colors in format strings, or conditional formatting that might change background for negatives e.g. Also users could custom-format cells to look like sort of booleans to indicate if something matches some conditions or not (like '[<10]"GOOD";[<20]"WARNING";"BAD"')... and it totally doesn't make sense to have such things in status bar for aggregates, when for a sum of cells, you'd see "BAD" in status instead of "100" - what is "BAD" for a data point is not necessarily bad for the sum.

So there is a suggestion by Eike in comment 3, which is to use *cell format category's default format* for displaying aggregates in the status bar, which are expected to be generic enough to provide useful aggregate results, even when selection has some fancy formatting.
Comment 7 Hossein 2023-08-24 13:49:23 UTC
Re-evaluating the EasyHack in 2023

This bug is still relevant in the latest LO dev master, and the status is as described in comment 1.