Bug 131638 - Text cell prompting about incorect formula
Summary: Text cell prompting about incorect formula
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium minor
Assignee: Baole Fang
URL:
Whiteboard: target:7.6.0
Keywords: difficultyMedium, easyHack, skillCpp
Depends on:
Blocks:
 
Reported: 2020-03-28 08:25 UTC by Rafallauterbach
Modified: 2023-06-17 15:16 UTC (History)
3 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 Rafallauterbach 2020-03-28 08:25:04 UTC
If you set cell to text type and than write -/[number](eg. -/2) , than it pops up message "LibreOffice Calc found an error in the formula entered.
Do you want to accept the correction proposed below =/-2"

I discused this on forum and it might be incorrect behaviour.

I would not expect libbre office to interpret anything that is in text cell. It should set cell to text that I just wrote, no matter what's in here.

I'm using version 6.3.0.4 and couldn't check it out if in newer version it is already fixed.
Comment 1 Mike Kaganski 2020-03-28 08:35:21 UTC
Reproducible with Version: 6.4.2.2 (x64)
Build ID: 4e471d8c02c9c90f512f7f9ead8875b57fcb1ec3
CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: default; VCL: win; 
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: CL

and with Version: 7.0.0.0.alpha0+ (x64)
Build ID: 5a94ac9eec4a63708262b2389aa2a434aa47112e
CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win; 
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: CL

So setting Text format to the cell does not prevent interpreting formulas starting with "-", as opposed to formulas starting with "=".
Comment 2 Mike Kaganski 2020-03-28 08:52:33 UTC
In fact, it pre-processes any formula (starting with +, -, or =). The prompt appears on "invalid formulas", despite it's not going to store it as formula eventually.

Cf.: "=///2" with "=2": in first case, it would try correct the input before storing the result as string, while in the second case, it will store it as string immediately.

A code pointer: see ScViewFunc::EnterData, which processes formula (see "bool bFormula") before processing cell type (see "if (nType == SvNumFormatType::TEXT").
Comment 3 Mike Kaganski 2021-07-25 05:17:36 UTC
Possibly related: in empty cells formatted as text, typing "=" or "-" or "+" then pressing an arrow key adds respective cell address to the "formula".

See https://ask.libreoffice.org/en/question/319620/can-i-turn-off-a-minus-signs-behavior/
Comment 4 Mike Kaganski 2022-07-05 07:37:39 UTC
The code pointer is in comment 2. Resolution of this easy hack should include a unit test (UITest) [1].

[1] https://wiki.documentfoundation.org/Development/UITests
Comment 5 Baole Fang 2023-05-27 21:38:02 UTC
start working on this
Comment 6 Commit Notification 2023-06-02 08:22:53 UTC
Baole Fang committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/730e6fa063fccbd12913362dd5d3c74ea14957be

tdf#131638: Fix text cell incorrect formula

It will be available in 7.6.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.