Bug 122648 - [RFE] DOCX import: fix table formulas in all tables (It was: Missing advanced sum formulas in Writer: SUM(ABOVE), SUM(LEFT), SUM(BELOW), SUM(RIGHT))
Summary: [RFE] DOCX import: fix table formulas in all tables (It was: Missing advanced...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:7.1.0
Keywords:
: 123383 138294 (view as bug list)
Depends on:
Blocks: Writer-Tables-Enhancements Writer-Tables-Formulas
  Show dependency treegraph
 
Reported: 2019-01-11 09:35 UTC by Marina Latini (SUSE)
Modified: 2021-02-24 14:43 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample DOCX (19.01 KB, application/vnd.openxmlformats-officedocument.wordprocessingml)
2019-01-11 16:17 UTC, Timur
Details
=SUM(xyz) test file created with MS Word 2016 (12.26 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-09-16 09:24 UTC, Thomas Lendo
Details
Screencast showing the values getting updated to 0 after loading the file (408.61 KB, video/x-matroska)
2020-09-16 11:40 UTC, Xisco Faulí
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marina Latini (SUSE) 2019-01-11 09:35:47 UTC
Description:
In writer is not possible to use advanced sum formulas in tables.

MSO Word is providing the following sum formulas in tables:
a) =SUM(ABOVE) adds the numbers in the column above the cell you’re in.
b) =SUM(LEFT)  adds the numbers in the row to the left of the cell you’re in.
c) =SUM(BELOW) adds the numbers in the column below the cell you’re in.
d) =SUM(RIGHT) adds the numbers in the row to the right of the cell you’re in.

For a reference see: https://support.office.com/en-us/article/sum-a-column-or-row-of-numbers-in-a-table-2e373a5f-2d8a-478a-9b85-275c8668bebb


Steps to Reproduce:
1. Insert a table in Writer with 1 column and 3 rows
2. add a value in A1
3. add a value in A2
3. type this formula in A3 -> =SUM(ABOVE)

Actual Results:
the function doesn't work

Expected Results:
The formula provides the sum of the values entered in A1 and A2.


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Timur 2019-01-11 16:17:29 UTC Comment hidden (obsolete)
Comment 2 Roman Kuznetsov 2019-01-15 08:27:35 UTC
(In reply to Timur from comment #1)
> Created attachment 148239 [details]
> Sample DOCX
> 
> Thank you for reporting a bug. Could you please attach a sample document..:)
> Or if I can do it, here it is. 
> This is not really an enhancement, because LO doesn't read DOCX, but let's
> keep it like that (to avoid those QA inquiries).

Timur, I think need to create a different normal bug about opening of DOCX file with table and advanced SUM function when Writer shows us wrong result. I'll do it
Comment 3 Xisco Faulí 2020-09-15 15:20:06 UTC
Already fixed in bug 123355

*** This bug has been marked as a duplicate of bug 123355 ***
Comment 4 Timur 2020-09-16 07:55:48 UTC
I don't see this as fixed. If it is, please write steps.
Comment 5 Thomas Lendo 2020-09-16 09:24:49 UTC
Created attachment 165561 [details]
=SUM(xyz) test file created with MS Word 2016

Fields not working with

Version: 6.4.6.2 (x64)
Build-ID: 0ce51a4fd21bff07a5c061082cc82c5ed232f115
CPU-Threads: 12; BS: Windows 10.0 Build 18363; UI-Render: Standard; VCL: win; 
Gebietsschema: de-AT (de_AT); UI-Sprache: de-DE

and

Version: 7.1.0.0.alpha0+ (x64)
Build ID: abcc4eb907661e07ad850ccce7eb06f129da4286
CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: Skia/Vulkan; VCL: win
Locale: de-AT (de_AT); UI: en-US
Comment 6 Xisco Faulí 2020-09-16 11:22:04 UTC
(In reply to Thomas Lendo from comment #5)
> Created attachment 165561 [details]
> =SUM(xyz) test file created with MS Word 2016
> 
> Fields not working with
> 
> Version: 6.4.6.2 (x64)
> Build-ID: 0ce51a4fd21bff07a5c061082cc82c5ed232f115
> CPU-Threads: 12; BS: Windows 10.0 Build 18363; UI-Render: Standard; VCL:
> win; 
> Gebietsschema: de-AT (de_AT); UI-Sprache: de-DE
> 
> and
> 
> Version: 7.1.0.0.alpha0+ (x64)
> Build ID: abcc4eb907661e07ad850ccce7eb06f129da4286
> CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: Skia/Vulkan; VCL:
> win
> Locale: de-AT (de_AT); UI: en-US

Hi Thomas,
Thanks for creating the document. I do believe the problem exhibit in the document is the one described in bug 123382
Comment 7 Xisco Faulí 2020-09-16 11:30:28 UTC
mmm, this is interesting, even with https://gerrit.libreoffice.org/c/core/+/102849 ( fix for bug 123382 ), the formulas LEFT, BELOW and RIGHT are converted to SUM(<?:?>) and the resulting value is 0

@László Németh, since you are working on bug 123382, I thought you might be interested in this issue as well
Comment 8 Xisco Faulí 2020-09-16 11:31:34 UTC
it's worth to mention the values are correct for a second while loading the document, then they change to 0
Comment 9 Xisco Faulí 2020-09-16 11:40:57 UTC
Created attachment 165569 [details]
Screencast showing the values getting updated to 0 after loading the file

Reproduced in

Version: 7.1.0.0.alpha0+
Build ID: 6f1e02c96b887750f974c187a82ecd6236e6a435
CPU threads: 4; OS: Linux 5.7; UI render: default; VCL: x11
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

as you can see, the correct values are displayed for a few seconds and then updated to 0
Comment 10 László Németh 2020-09-16 15:47:22 UTC
@Timur: very nice catch! It seems, this is a general problem for documents with multiple tables, i.e. plain formula import was fixed only for the first table of the document, too.
Comment 11 László Németh 2020-09-16 15:48:34 UTC
@Xisco: thanks for the screen cast. I was able to reproduce the problem, and it seems, it's possible to fix it soon.
Comment 12 Commit Notification 2020-09-18 18:21:47 UTC
László Németh committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/782700c6940341d489eabf00a531cb184941484e

tdf#122648 DOCX import: fix table formula in all tables

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 13 László Németh 2020-09-21 05:59:45 UTC
tdf#122648 DOCX import: fix table formula in all tables

Table formula import worked only in the first table,
because of using bad fallback table for cell references
without table names during formula conversion to internal
formula.

Set table of the text field as the correct fallback table.

Follow-up of commit 68e74bdf63e992666016c790e8e4cfd5b28d6abe
(tdf133647 tdf123386 tdf123389 Improved .docx table formula import).
Comment 14 Timur 2020-09-25 13:13:02 UTC
*** Bug 123383 has been marked as a duplicate of this bug. ***
Comment 15 NISZ LibreOffice Team 2020-10-08 08:51:52 UTC
Verified in:

Version: 7.1.0.0.alpha0+ (x64)
Build ID: a3b4831208da615789bd1e2d5660dd130807f504
CPU threads: 4; OS: Windows 10.0 Build 17134; UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: hu-HU
Calc: threaded

Thanks, László :)
Comment 16 Timur 2021-02-24 14:43:38 UTC
*** Bug 138294 has been marked as a duplicate of this bug. ***