Bug 123382 - FILEOPEN DOCX: BELOW and RIGHT in formula fail in the first column
Summary: FILEOPEN DOCX: BELOW and RIGHT in formula fail in the first column
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.3.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.1.0
Keywords: filter:docx
Depends on:
Blocks: DOCX-Fields Regressions-expression-is-faulty
  Show dependency treegraph
 
Reported: 2019-02-12 07:42 UTC by NISZ LibreOffice Team
Modified: 2020-10-15 08:04 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot of the original document side by side in Word and Writer. (281.97 KB, image/png)
2019-02-12 07:43 UTC, NISZ LibreOffice Team
Details
A document which contains some MAX formulas. (20.37 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2019-02-12 07:43 UTC, NISZ LibreOffice Team
Details
fails with AVERAGE too (19.31 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-09-15 15:14 UTC, Xisco Faulí
Details
Modified version of the example file (17.53 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-09-15 15:46 UTC, NISZ LibreOffice Team
Details
Screenshot of the modified document side by side in Word and Writer (158.27 KB, image/png)
2020-09-15 15:51 UTC, NISZ LibreOffice Team
Details
3rd example DOCX - Screenshot MSO LO with values (95.50 KB, image/png)
2020-09-25 12:40 UTC, Timur
Details
3rd example DOCX (28.21 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-10-08 10:23 UTC, Timur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NISZ LibreOffice Team 2019-02-12 07:42:49 UTC
Description:
Table formula MAX() is not working when opened in LO.

Steps to Reproduce:
    1. Create a new docx in Word.
    2. Insert a table with some numbers.
    3. Create a MAX formula in one of the cells.
    4. Save it and open it in LO.

Actual Results:
The cells that contain a formula has a 0 in them regardless what was in them before.

Expected Results:
They should have the same number as in MSO.


Reproducible: Always


User Profile Reset: No



Additional Info:
LibreOffice details: Version: 6.3.0.0.alpha0+
Build ID: 17dd2662ccfa9d04efbea74e5d7548db5b2126d4
CPU threads: 4; OS: Windows 6.1; UI render: default; VCL: win; 
Locale: hu-HU (hu_HU); UI-Language: en-US
Calc: threaded
Comment 1 NISZ LibreOffice Team 2019-02-12 07:43:14 UTC
Created attachment 149181 [details]
Screenshot of the original document side by side in Word and Writer.
Comment 2 NISZ LibreOffice Team 2019-02-12 07:43:35 UTC
Created attachment 149182 [details]
A document which contains some MAX formulas.
Comment 3 Xisco Faulí 2019-02-12 10:28:18 UTC
Formulas

debug:7354:7354: =MAX(BELOW)
debug:7354:7354: =MAX(RIGHT)
debug:7354:7354: =MAX(ABOVE)
debug:7354:7354: =MAX(LEFT)

Closing as a dupe of bug 123355

*** This bug has been marked as a duplicate of bug 123355 ***
Comment 4 Timur 2020-09-15 08:49:39 UTC
Not resolved in bug 123355, it was about Average.
Comment 5 NISZ LibreOffice Team 2020-09-15 14:50:42 UTC
(In reply to Timur from comment #4)
> Not resolved in bug 123355, it was about Average.

A1 has =MAX(BELOW) (=13)
A2 has =MAX(RIGHT) (=8)
C3 has =MAX(ABOVE) (=7)
D4 has =MAX(LEFT) (=15) 
in Word.

Of these the two in column A are not rewritten and give 0 as result in current Writer, but the ones in columns C and D are rewritten (to MAX(<C2:C1>) and MAX(<C4:A4>) ), and give the expected result.

Version: 7.1.0.0.alpha0+ (x64)
Build ID: ed4f610f4a3de12016f8308a17b6ad4f86e9d67a
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: default; VCL: win
Locale: hu-HU (hu_HU); UI: en-US
Calc: CL
Comment 6 Xisco Faulí 2020-09-15 15:14:28 UTC
Created attachment 165536 [details]
fails with AVERAGE too

This is no a problem with the formula MAX, it also fails with AVERAGE. The problem is using BELOW on cell A1
Comment 7 NISZ LibreOffice Team 2020-09-15 15:46:36 UTC
Created attachment 165539 [details]
Modified version of the example file

I don't think the problem is with the MAX function itself. More like with the replacement of the LEFT/RIGHT/ABOVE/BELOW specifiers.
Comment 8 NISZ LibreOffice Team 2020-09-15 15:51:53 UTC
Created attachment 165541 [details]
Screenshot of the modified document side by side in Word and Writer

Here I tried to break things but the only common pattern found yet is that any formula in the first column does not have its LEFT/RIGHT etc replaced.
Comment 9 László Németh 2020-09-16 11:29:47 UTC
@all: thanks for the nice catch and investigation! Handling of the first column missed completely. Interestingly, there was another problem, too: the original formula of the first cell wasn't grab-bagged, causing the same problem, but only in the cell A1:

https://gerrit.libreoffice.org/c/core/+/102849
Comment 10 Commit Notification 2020-09-18 09:41:25 UTC
László Németh committed a patch related to this issue.
It has been pushed to "master":

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

tdf#123382 DOCX import: fix range IDs in column A

It will be available in 7.1.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 11 Timur 2020-09-25 12:40:57 UTC
Created attachment 165843 [details]
3rd example DOCX - Screenshot MSO LO with values

I still see and issue here: values are not the same, maybe a priority problem.

Please also explain why LEFT, RIGHT..are replaced instead of having similar functions.
Comment 12 Xisco Faulí 2020-09-25 13:07:38 UTC Comment hidden (obsolete)
Comment 13 Timur 2020-10-08 10:23:12 UTC
Created attachment 166181 [details]
3rd example DOCX

(In reply to Xisco Faulí from comment #12)
> Which document are you using ? Should we just create a new ticket for it ?
Same examples as here, except I added them to a single DOCX, it's here. 

Note: opening DOC is same is MSO and LO.
Comment 14 László Németh 2020-10-15 08:04:58 UTC
I close the bug, because the new file contains a circular reference in the second row of the second table. I think, circular references are unwanted in formulas of text tables. By the way, Word's results are worse in this example, see Word's number 18 in D1 with formula MAX(BELOW): there is no 18 below that cell. Maybe pressing F9 can fix there, too, maybe not, but for example, circular references are forbidden in Calc by default (you can switch on iterations in LibreOffice Calc->Calculation page, sometimes it's meaningful the result).