Bug 107410 - FILEOPEN RTF: "Expression is faulty" instead of numbers (take alternate part if formula parsing fails)
Summary: FILEOPEN RTF: "Expression is faulty" instead of numbers (take alternate part ...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.4.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected
: 111460 (view as bug list)
Depends on:
Blocks: RTF Regressions-expression-is-faulty
  Show dependency treegraph
 
Reported: 2017-04-25 10:50 UTC by Xisco Faulí
Modified: 2025-06-18 14:09 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
comparison MSO 2010 and LibreOffice 5.4 (104.08 KB, image/png)
2017-04-25 10:51 UTC, Xisco Faulí
Details
How it looks in LibreOffice 7.1 master (92.71 KB, image/png)
2020-09-15 15:59 UTC, Xisco Faulí
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2017-04-25 10:50:22 UTC
Steps to reproduce:
1. Open attachment 84867 [details] from bug 68715
2. Go to page 5

Observed behaviour: Table contains some ** Expression is faulty ** instead of numbers

Reproduced in

Version: 5.4.0.0.alpha0+
Build ID: 7635e0c1c7f821a1081f8e3868f641ae74a172d6
CPU threads: 4; OS: Linux 4.8; UI render: default; VCL: gtk2; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group

but not in

Version: 5.4.0.0.alpha0+
Build ID: 5a5889d1e1bd17c16930b2132d8c2674fb7fa05a
CPU threads: 4; OS: Linux 4.8; UI render: default; VCL: gtk2; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group
Comment 1 Xisco Faulí 2017-04-25 10:51:32 UTC
Created attachment 132826 [details]
comparison MSO 2010 and LibreOffice 5.4
Comment 2 Jacques Guilleron 2017-04-25 12:35:31 UTC
Hello Xisco,

I reproduce too with:
LO 5.4.0.0.alpha0+ Build ID: 100e00fd3273536ebff130cfddc5da2b1fe609b1
CPU threads: 2; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2017-04-20_05:12:24
Locale: en-US (fr_FR); Calc: CL
and 
LO 5.4.0.0.alpha0+ Build ID: 98ebfb6a8638a76e96ffe7ada2485b3d13ed1fb9
CPU threads: 2; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2017-04-11_01:03:05
Locale: fr-FR (fr_FR); Calc: CL

but not with:
LO 5.4.0.0.alpha0+ Build ID: 1cd7edadfedc8bf55b979449cbb084082a888e89
CPU threads: 2; OS: Windows 6.1; UI render: GL; 
TinderBox: Win-x86@42, Branch:master, Time: 2017-03-30_03:06:30
Locale: fr-FR (fr_FR); Calc: CL
Comment 3 Xisco Faulí 2017-04-27 00:02:22 UTC
Regression introduced by:

author	Jean-Sebastien Bevilacqua <realitix@gmail.com>	2017-02-16 09:54:33 (GMT)
committer	Miklos Vajna <vmiklos@collabora.co.uk>	2017-03-30 17:39:00 (GMT)
commit c568eb7d3bb4584867f0a1f0a7965f73097f009b (patch)
tree ea7e6fb1e0d77369a90bc69dd8756f589bb352e4
parent 53c2507bf97867011fd2bfbbac6c86b7fc494338 (diff)
tdf#105975 Add Formula field parsing (docx) in SWriter
Introduction
------------

In MSWord, you can create a formula field (starting with =).
When you save your file as `docx`, this `FORMULA` field is registered
in you file (a field starting with `=`). In its current state,
LibreOffice can't parse the `FORMULA` field in `docx` file.

Context of this fix
-------------------

This fix is entirely located in the `DomainMapper_Impl.cxx` file
because it's where the parsing is done.

How this fix works
------------------

First, we add `FORMULA` support by adding it to the `aFields[]` variable.
Next, to handle the `FORMULA` constant, we add a condition (swith case) in
`DomainMapper_Impl::CloseFieldCommand()` to call `handleFieldFormula`.

Note
----

In function `lcl_ExtractToken`, if command starts with `=`, it's a
`FORMULA` field.

Bisected with

Adding Cc: to Jean-Sebastien Bevilacqua
Comment 4 Jean-Sebastien Bevilacqua 2017-05-19 08:55:03 UTC Comment hidden (obsolete)
Comment 5 Jean-Sebastien Bevilacqua 2017-05-19 09:23:17 UTC
Before my patch, your document was not properly handled either.
If you take a look, the fields have a grey background but are not seen as "field" and can be directly modified.
Comment 6 Jean-Sebastien Bevilacqua 2017-05-19 09:43:50 UTC
Your rtf document contains bookmarks defined as =C6 or =SUM(C12:C27).
Theses references don't seem to exist.

Moreover, in your file, some fields are defined as formula and others not.

Can you give more informations on this file, how do you generate it ?

The error you see come from the field formula format like this:

=curr_emp+curr_adm \\# "#,##0"

The last part is not supported, I should convert it to

=curr_emp+curr_adm

BUT it will no resolve your problem since variable curr_emp and curr_adm are not well defined.
Before the patch, LibreOffice was taking the alternate part of the field because it couldn't parse it. Now it can parse it (badly).

Jean-Sébastien Bevilacqua
Comment 7 Xisco Faulí 2017-05-19 12:14:51 UTC
Hi Jean-Sebastien,

Thanks for taking a look at it.
To be honest, I don't know how the document was generated. As I mentioned in the summary, it's taken from another bug report. I just noticed before and after your commit it was different, but I don't have more technical details.
Comment 8 Jean-Sebastien Bevilacqua 2017-05-19 12:51:04 UTC
A solution would be to try parsing the formula and to take the alternate part if parsing fails.
Comment 9 Xisco Faulí 2017-07-20 15:06:28 UTC
Same problem affects attachment 52931 [details] from bug 41679
Comment 10 Xisco Faulí 2017-08-07 19:31:57 UTC
*** Bug 111460 has been marked as a duplicate of this bug. ***
Comment 11 QA Administrators 2018-08-08 02:36:49 UTC Comment hidden (obsolete)
Comment 12 Timur 2018-08-08 14:26:01 UTC
Repro 6.2+
Comment 13 Xisco Faulí 2019-02-12 10:43:01 UTC
Formulas

debug:8159:8159: =curr_turn \# "#,##0"
debug:8159:8159: =prev_turn \# "#,##0"
debug:8159:8159: =curr_turn \# "#,##0"
debug:8159:8159: =prev_turn \# "#,##0"
debug:8159:8159: =curr_emp+curr_adm \# "#,##0"
debug:8159:8159: =prev_emp+prev_adm \# "#,##0"
debug:8159:8159: =abs(curr_turn-curr_emp-curr_adm) \# "#,##0"
debug:8159:8159: =abs(prev_turn-prev_emp-prev_adm) \# "#,##0"
debug:8159:8159: =curr_int \# "#,##0"
debug:8159:8159: =prev_int \# "#,##0"
debug:8159:8159: =abs(curr_turn-curr_emp-curr_adm+curr_int) \# "#,##0"
debug:8159:8159: =abs(prev_turn-prev_emp-prev_adm+prev_int) \# "#,##0"
debug:8159:8159: =curr_emp \# "#,##0"
debug:8159:8159: =prev_emp \# "#,##0"
debug:8159:8159: =curr_turn \# "#,##0"
debug:8159:8159: =prev_turn \# "#,##0"
debug:8159:8159: =curr_emp \# "#,##0"
debug:8159:8159: =prev_emp \# "#,##0"
debug:8159:8159: =curr_adm \# "#,##0"
debug:8159:8159: =prev_adm \# "#,##0"
debug:8159:8159: =curr_emp+curr_adm \# "#,##0"
debug:8159:8159: =abs(curr_turn+curr_int-curr_emp-curr_adm) \# "#,##0"
debug:8159:8159: =abs(prev_turn+prev_int-prev_emp-prev_adm) \# "#,##0"
debug:8159:8159: =C6 \# "#,##0"
debug:8159:8159: =SUM(C12:C27) \# "#,##0"
debug:8159:8159: =curr_emp+curr_adm \# "#,##0"

Removing the regression keyword...
Comment 14 Xisco Faulí 2020-09-15 15:58:37 UTC
This has improved in

Version: 7.1.0.0.alpha0+
Build ID: 6f1e02c96b887750f974c187a82ecd6236e6a435
CPU threads: 4; OS: Linux 5.7; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 15 Xisco Faulí 2020-09-15 15:59:00 UTC
Created attachment 165543 [details]
How it looks in LibreOffice 7.1 master
Comment 16 QA Administrators 2023-08-16 03:05:45 UTC Comment hidden (obsolete)
Comment 17 Xisco Faulí 2025-06-18 14:09:35 UTC
Still reproducible in

Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 7b7de629dd2b86ec534ea2d9f94852a54877a42d
CPU threads: 8; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded