Bug 122224 - FILEOPEN DOCX The formula field is incorrect in the table, when we change the number format
Summary: FILEOPEN DOCX The formula field is incorrect in the table, when we change the...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.4.0.3 release
Hardware: All All
: medium normal
Assignee: László Németh
URL:
Whiteboard: target:6.3.0 target:6.2.1 target:6.1.5
Keywords: bibisected, bisected, regression
Depends on:
Blocks: DOCX-Fields Regressions-expression-is-faulty
  Show dependency treegraph
 
Reported: 2018-12-20 12:52 UTC by NISZ LibreOffice Team
Modified: 2019-02-12 10:02 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot of the original document side by side in Word and Writer. (76.80 KB, image/png)
2018-12-20 12:54 UTC, NISZ LibreOffice Team
Details
Example file from Word (18.85 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-12-20 12:54 UTC, NISZ LibreOffice Team
Details
bibisect in bibisect-linux-64-5.4, tail of terminal output (3.13 KB, text/plain)
2019-01-06 19:34 UTC, Terrence Enger
Details
How the document looks after RT in LibreOffice 6.3 master (3.83 KB, image/png)
2019-01-09 13:10 UTC, Xisco Faulí
Details
Example compared MSO LO62 LO63+ (73.83 KB, image/jpeg)
2019-01-09 13:45 UTC, Timur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NISZ LibreOffice Team 2018-12-20 12:52:35 UTC
Description:
The formula field is incorrect in the table, when we change the number format.

Steps to Reproduce:
    1. Create a new document in Microsoft Word 2016.
    2. Insert a table and click in the first cell.
    3. On the Insert tab, click Quick Parts > Field.
    4. In the Field dialog box, click on Formula button.
    5. In the Formula dialog box, type a formula and change the number format.
    6. Click on OK button.
    7. Save the file as DOCX.
    8. Open the same file in LibreOffice Writer.


Actual Results:
The value of the field is incorrect: ** Expression is faulty **.

Expected Results:
The formula field should have the same value as in the original file when the document is opened in Microsoft Word 2016.


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 NISZ LibreOffice Team 2018-12-20 12:54:35 UTC
Created attachment 147699 [details]
Screenshot of the original document side by side in Word and Writer.
Comment 2 NISZ LibreOffice Team 2018-12-20 12:54:59 UTC
Created attachment 147700 [details]
Example file from Word
Comment 3 Dieter 2018-12-20 13:22:42 UTC
I confirm it with

Version: 6.3.0.0.alpha0+ (x64)
Build ID: ffa5b8a82eab18041bbee4d6914892b82c7801d3
CPU threads: 4; OS: Windows 10.0; UI render: default; VCL: win; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2018-12-19_03:24:54
Locale: en-US (de_DE); UI-Language: en-US
Calc: threaded

If you display the field codes you can see, that the equal signs are missing in the odt-file.
Comment 4 Telesto 2018-12-20 19:19:30 UTC
No repro with
Versie: 4.4.7.2 
Build ID: f3153a8b245191196a4b6b9abd1d0da16eead600
Locale: nl_NL
Comment 5 Terrence Enger 2019-01-06 19:34:58 UTC
Created attachment 148074 [details]
bibisect in bibisect-linux-64-5.4, tail of terminal output

Working on debian-buster in bibisect-linux-64-5.4 repository, I looked
only at the displayed result when LibreOffice opened the attached
.docx.  The bad commit is : commit 009e5f66, source hash c568eb7d,
2017-03-30.  The commit message for the source commit is:

    commit c568eb7d3bb4584867f0a1f0a7965f73097f009b
    Author: Jean-Sebastien Bevilacqua <realitix@gmail.com>
    Date:   Thu Feb 16 10:54:33 2017 +0100

        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.
    
        Change-Id: If7d25de5413aa3133b22523d8a3f34ab6961adfc
        Reviewed-on: https://gerrit.libreoffice.org/34334
        Reviewed-by: Michael Stahl <mstahl@redhat.com>
        Tested-by: Jenkins <ci@libreoffice.org>

I am removing keyword bibisectRequest and adding bisected, bibisected;
and I am adding the author and Michael Stahl to cc.
Comment 6 Gabor Kelemen (allotropia) 2019-01-07 10:04:51 UTC
Thanks for bibisecting this.
I checked in 5.3 and while the formatted formula results appear correctly, they are just plain text and not fields as they were in Word.

I guess importing and exporting field formatting codes here can be considered a feature request and not a regression.
Comment 7 László Németh 2019-01-07 21:33:12 UTC
Proposed workaround: https://gerrit.libreoffice.org/#/c/65945/

This fix the bug (syntax error), but not the enhancement (support custom number format code).

Gábor: Indeed, it's not a true regression, especially if the working formulas are important.

Note: It has to fix the DOCX export of the formula fields, too.
Comment 8 Xisco Faulí 2019-01-08 09:33:10 UTC
Hello László,
bug 107410 is a similar issue but for RTF format.
Does your commit fix it as well ?
Comment 9 Commit Notification 2019-01-08 10:10:17 UTC
László Németh committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/7209feef41c3c858476a2ae9795a7d2264c0ffc0%5E%21

tdf#122224 DOCX import: fix formula field syntax

It will be available in 6.3.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 10 László Németh 2019-01-08 10:12:50 UTC
(In reply to Xisco Faulí from comment #8)
> Hello László,
> bug 107410 is a similar issue but for RTF format.
> Does your commit fix it as well ?

Hello Xisco. Unfortunately, it doesn't,  because that is related to the unknown function "abs".
Comment 11 László Németh 2019-01-08 10:16:04 UTC
(In reply to László Németh from comment #10)
> (In reply to Xisco Faulí from comment #8)
> > Hello László,
> > bug 107410 is a similar issue but for RTF format.
> > Does your commit fix it as well ?
> 
> Hello Xisco. Unfortunately, it doesn't,  because that is related to the
> unknown function "abs".

Xisco, more precisely, this commit has been fixed most of those syntax problems, too, except the "abs" related ones. :)
Comment 12 Xisco Faulí 2019-01-09 13:07:34 UTC
I don't see this bug fixed in

Version: 6.3.0.0.alpha0+
Build ID: 54515a6a01a372729bf8a7f9e992c51f214ec9a6
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US
Calc: threaded
Comment 13 Xisco Faulí 2019-01-09 13:10:25 UTC
Created attachment 148168 [details]
How the document looks after RT in LibreOffice 6.3 master
Comment 14 László Németh 2019-01-09 13:27:53 UTC
(In reply to Xisco Faulí from comment #13)
> Created attachment 148168 [details]
> How the document looks after RT in LibreOffice 6.3 master

Xisco: sorry, I've closed this issue only according to the "FILEOPEN" in the commit description, and because of the bigger set of missing features, planned to fix by the following set of commits/maybe new issues in the future:

– field DOCX export
– style DOCX import
– style DOCX export
– add table reference and ABS support (closing the related RTF issue)
– add export of the previous

I started to work on them, but unfortunately, there are other issues with higher priority, yet.

In fact, first we need a basic field export, too, so we can wait for it to close this issue. 

@Gábor, what is your opinion?

Note: it may need to press F9 to see the update of the fields.
Comment 15 Timur 2019-01-09 13:45:04 UTC
Created attachment 148169 [details]
Example compared MSO LO62 LO63+

I'll set to verified. Format is another issue.
Comment 16 Timur 2019-01-09 13:48:43 UTC
In case when a single issue is fixed, we close and open another bug. That's why I intended to set Verified for Fileopen.
But if a dev is willing to pursue other obvious issue, it's surely better to do in the same bug.
Comment 17 Xisco Faulí 2019-01-16 16:21:48 UTC
oh, wait a minute, I thought it was a FILESAVE problem. Rereading it, I see it's not. my bad.
Closing as VERIFIED FIXED. Indeed, it's fixed in

Version: 6.1.4.2
Build ID: 1:6.1.4-0ubuntu0.16.04.1~lo2
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group threaded

@László Németh, Thanks for fixing this!!!
Comment 18 Commit Notification 2019-01-16 16:24:44 UTC
László Németh committed a patch related to this issue.
It has been pushed to "libreoffice-6-2":

https://git.libreoffice.org/core/+/b095e8f3b27331f0d646b1d33e51e17c37e43e2c%5E%21

tdf#122224 DOCX import: fix formula field syntax

It will be available in 6.2.1.

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 19 Commit Notification 2019-01-16 20:06:42 UTC
László Németh committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

https://git.libreoffice.org/core/+/7798ce2e8c938b9d05a3f39e50a2737e64957197%5E%21

tdf#122224 DOCX import: fix formula field syntax

It will be available in 6.1.5.

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.