Bug 129878 - Formatting large numbers using certain format strings results in wrong "###" output
Summary: Formatting large numbers using certain format strings results in wrong "###" ...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Mohamed Sameh
URL:
Whiteboard: target:7.0.0 target:7.2.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicDebug
Depends on:
Blocks:
 
Reported: 2020-01-08 07:42 UTC by Mike Kaganski
Modified: 2021-05-21 10:15 UTC (History)
6 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 2020-01-08 07:42:54 UTC
In Calc, "###" code means "The cell is not wide enough to display the contents" [1].

In a spreadsheet put number '2E306' into a cell, and format it with a fraction format, e.g. '# #/#'.

Or use a time span format, like '[HH]'.

Or use a percent format, like '0%'.

This results in "###" displayed in the cell, which has nothing to do with "cell not wide enough", but is an error string from the formatting function.

This easy hack is for changing the error string in the number formatter to something else - e.g., '#FMT'.

The string is defined in ImpSvNumberformatScan::sErrStr (see its declaration in svl/source/numbers/zforscan.hxx), and it's used in svl/source/numbers/zformat.cxx through calls to ImpSvNumberformatScan::GetErrorString.

[1] https://help.libreoffice.org/6.4/en-US/text/scalc/05/02140000.html
Comment 1 Mike Kaganski 2020-01-08 07:47:43 UTC
Additionally, the error code should be listed in both [1] and [2]. In [1], it should be listed after ###, but before all the codes that have actual error number in Calc, since it's not a spreadsheet error (detectable e.g. by spreadsheet function ISERR), but a formatting (display) error, somewhat similar to ###.

[1] https://help.libreoffice.org/6.4/en-US/text/scalc/05/02140000.html
[2] https://help.libreoffice.org/6.4/en-US/text/shared/01/05020301.html
Comment 2 Abhishek 2020-01-30 09:51:26 UTC
Hi there, I am trying to solve this bug. What should be the error message instead of "###" and what test should I perform to test whether this bug is resolved or not? Please help!
Thanks.
Comment 3 Mike Kaganski 2020-01-30 10:00:26 UTC
(In reply to Abhishek from comment #2)

The proposed text is present in the description, namely "#FMT".
The steps to check if the bug is fixed is obvious from the description, too: naturally, one who wants to fix it should first reproduce the problem, which implies preparing a spreadsheet according to examples given in the description. Then, after the problem is fixed, the spreadsheet should show the corrected string instead of ###.

Does it make sense now?
Comment 4 Abhishek 2020-02-01 17:50:07 UTC
Thanks for the help Mike!
Comment 5 Mohamed Sameh 2020-02-10 08:33:46 UTC
I am going to try and work on this easy hack
Comment 6 Mike Kaganski 2020-02-10 08:37:40 UTC
(In reply to Mohamed Sameh from comment #5)
> I am going to try and work on this easy hack

Welcome!
Of course, the bug has been unassigned till now; but please note the comments from Abhishek from ~a week ago. *Possibly* Abhishek has just forgot to assign it - but everything is possible. Please wait for Abhishek's response for a day or two before starting to work on it (however sad I am to say that, since I'd love to have it worked on), to avoid stepping on other's...
Comment 7 Mohamed Sameh 2020-02-10 10:29:07 UTC
(In reply to Mike Kaganski from comment #6)
> (In reply to Mohamed Sameh from comment #5)
> > I am going to try and work on this easy hack
> 
> Welcome!
> Of course, the bug has been unassigned till now; but please note the
> comments from Abhishek from ~a week ago. *Possibly* Abhishek has just forgot
> to assign it - but everything is possible. Please wait for Abhishek's
> response for a day or two before starting to work on it (however sad I am to
> say that, since I'd love to have it worked on), to avoid stepping on
> other's...

Sure, I think you are right. I will give it a day then
Comment 8 Mohamed Sameh 2020-02-12 20:06:58 UTC
it's been 2 days can I start working on this now ?
Comment 9 Buovjaga 2020-02-12 20:11:59 UTC
(In reply to Mohamed Sameh from comment #8)
> it's been 2 days can I start working on this now ?

I think so. Abhishek was not in the Cc list of this report, though, but I noticed that he was working on some completely different bug.
Comment 10 Mohamed Sameh 2020-02-14 18:11:00 UTC
How and where should I define the new string "#FMT' ?
Comment 11 Mohamed Sameh 2020-02-15 15:43:43 UTC
(In reply to Mohamed Sameh from comment #10)
> How and where should I define the new string "#FMT' ?

I read the easyhack description again and realised it should replace the string ### in svl/source/numbers/zformat.cxx. I will be commiting soon
Comment 12 Mohamed Sameh 2020-02-15 16:02:53 UTC
I have commited the change here https://gerrit.libreoffice.org/c/core/+/88760
I am not sure how to edit the 2 HTML pages. are they part of the repository ?
Comment 13 Mike Kaganski 2020-02-15 16:05:55 UTC
(In reply to Mohamed Sameh from comment #12)
> I have commited the change here https://gerrit.libreoffice.org/c/core/+/88760

Thanks!

> I am not sure how to edit the 2 HTML pages. are they part of the repository ?

It's in help [1]. You may see an introduction to Web-based help patching in bug 130572 comment 2.

[1] https://gerrit.libreoffice.org/admin/repos/help
Comment 14 Mohamed Sameh 2020-02-15 19:26:14 UTC
(In reply to Mike Kaganski from comment #13)
> (In reply to Mohamed Sameh from comment #12)
> > I have commited the change here https://gerrit.libreoffice.org/c/core/+/88760
> 
> Thanks!
> 
> > I am not sure how to edit the 2 HTML pages. are they part of the repository ?
> 
> It's in help [1]. You may see an introduction to Web-based help patching in
> bug 130572 comment 2.
> 
> [1] https://gerrit.libreoffice.org/admin/repos/help

Thanks Mike!
I cloned the help repo but I can not find guidelines on how to edit it. I opened the xhp file of the page we need to change but I don't know what to place as the id of the new items I am adding or if I am even supposed to be doing those edits manually or is there a tool to automate edits.

example from xhp file:
<tablecell>
               <paragraph xml-lang="en-US" id="par_id1668467" role="tablecontent" localize="false">###</paragraph>
            </tablecell>
Comment 15 Mike Kaganski 2020-02-16 05:28:10 UTC
(In reply to Mohamed Sameh from comment #14)

I do those edits manually. The ids must be unique throughout the page, nothing else. You may hake the previous id and increment it.
Comment 16 Commit Notification 2020-02-16 07:42:57 UTC
Mohamed Sameh committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/9414882dc22899a3fe0e13294a1b68885f055538

tdf#129878: replace error string for number format errors in Calc

It will be available in 7.0.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 17 Mohamed Sameh 2020-02-16 09:13:13 UTC
(In reply to Mike Kaganski from comment #1)
> Additionally, the error code should be listed in both [1] and [2]. In [1],
> it should be listed after ###, but before all the codes that have actual
> error number in Calc, since it's not a spreadsheet error (detectable e.g. by
> spreadsheet function ISERR), but a formatting (display) error, somewhat
> similar to ###.
> 
> [1] https://help.libreoffice.org/6.4/en-US/text/scalc/05/02140000.html
> [2] https://help.libreoffice.org/6.4/en-US/text/shared/01/05020301.html

I have added the new error code in [1] but I am not sure where to add it in [2].
Also the help repository does not come with logerrit to push commits so I don't know how to push my commits
Comment 18 Mike Kaganski 2020-02-16 09:22:29 UTC
(In reply to Mohamed Sameh from comment #17)
> > [1] https://help.libreoffice.org/6.4/en-US/text/scalc/05/02140000.html
> > [2] https://help.libreoffice.org/6.4/en-US/text/shared/01/05020301.html
> 
> I have added the new error code in [1] but I am not sure where to add it in
> [2].

Either under the relevant sections discussing the format codes that might result in the error (which I would prefer, something like "if formatted value is outside of range ..., then #FMT will be displayed" under percentage formatting), or as a separate section e.g. in the end of the whole page (like "Error codes", "Some format codes may result in "#FMT" shown when formatted value is outside of limits ...").

> Also the help repository does not come with logerrit to push commits so I
> don't know how to push my commits

Use this:

> git push ssh://gerrit.libreoffice.org/help HEAD:refs/for/master
Comment 19 Mohamed Sameh 2020-02-17 12:47:06 UTC
I finished the 2 files but I got The following error from the commit-msg hook when commiting. 
>.git/hooks/commit-msg: 2: Syntax error: newline unexpected
Comment 20 Buovjaga 2020-02-17 12:48:48 UTC
(In reply to Mohamed Sameh from comment #19)
> I finished the 2 files but I got The following error from the commit-msg
> hook when commiting. 
> >.git/hooks/commit-msg: 2: Syntax error: newline unexpected

It sounds like you have an unexpected newline in your commit message. Can you git commit --amend it and somehow make it acceptable to the hook?
Comment 21 Mohamed Sameh 2020-02-20 21:30:38 UTC
(In reply to Buovjaga from comment #20)
> (In reply to Mohamed Sameh from comment #19)
> > I finished the 2 files but I got The following error from the commit-msg
> > hook when commiting. 
> > >.git/hooks/commit-msg: 2: Syntax error: newline unexpected
> 
> It sounds like you have an unexpected newline in your commit message. Can
> you git commit --amend it and somehow make it acceptable to the hook?
I am sorry for replying late but I had a couple of busy days.

I don't have any extra lines, I tried to edit and remove any extra space but no good. so, I commited bypassing the hook msg. However, I am unable to push
>> git push ssh://gerrit.libreoffice.org/help HEAD:refs/for/master
I am not sure what to replace refs/for/master with ?
Comment 22 Mike Kaganski 2020-02-20 21:42:25 UTC
(In reply to Mohamed Sameh from comment #21)
> I don't have any extra lines, I tried to edit and remove any extra space but
> no good.

What is the contents of the hook?

> so, I commited bypassing the hook msg. However, I am unable to push
> >> git push ssh://gerrit.libreoffice.org/help HEAD:refs/for/master
> I am not sure what to replace refs/for/master with ?

You forgot to mention the problem you see - any error message?

You can prepare the commit using Web UI in case something is really problematic with pushing to help...
Comment 23 Mohamed Sameh 2020-02-21 20:25:34 UTC
(In reply to Mike Kaganski from comment #22)
> (In reply to Mohamed Sameh from comment #21)
> > I don't have any extra lines, I tried to edit and remove any extra space but
> > no good.
> 
> What is the contents of the hook?
> 
> > so, I commited bypassing the hook msg. However, I am unable to push
> > >> git push ssh://gerrit.libreoffice.org/help HEAD:refs/for/master
> > I am not sure what to replace refs/for/master with ?
> 
> You forgot to mention the problem you see - any error message?
> 
> You can prepare the commit using Web UI in case something is really
> problematic with pushing to help...

The content of the commit message is between the double quotes
"
tdf#129878: Add FMT error code into help pages

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date:      Mon Feb 17 07:44:12 2020 -0500
#
# On branch easyhack129878
# Changes to be committed:
#	modified:   source/text/scalc/05/02140000.xhp
#	modified:   source/text/shared/01/05020301.xhp
#
"

How do I access the Web UI ?
Comment 24 Mike Kaganski 2020-02-21 20:41:28 UTC
(In reply to Mohamed Sameh from comment #23)
> How do I access the Web UI ?

See comment 13
Comment 25 Mohamed Sameh 2020-02-22 18:36:33 UTC
I did it through the web UI here is the link to the gerrit patch
https://gerrit.libreoffice.org/c/help/+/89269
Comment 26 Commit Notification 2020-02-24 15:12:45 UTC
Mohamed Sameh committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/1936bfe6697be30202547a7775bda81d6b8d0211

tdf#129878: Add FMT error code into help pages
Comment 27 BogdanB 2020-09-19 21:18:56 UTC
It's showing now "#FMT"

Verified in
Version: 7.0.2.0.0+
Build ID: b27137a7091104cce177791478e86d127680c9af
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 28 BogdanB 2020-09-19 21:20:55 UTC
Verified also in
Version: 7.1.0.0.alpha0+
Build ID: d57b14e3394b081adf0888ed8dcb7b86d66c246c
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 29 Commit Notification 2021-05-21 10:15:59 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/a6241e3f7585c3c1806df64d4c485afb47da68c4

tdf#129878: svl_qa_cppunit: Add unittest

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.