Bug 159027 - Writer table formulas calculated incorrectly in merged cells when table splits over pages
Summary: Writer table formulas calculated incorrectly in merged cells when table split...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha0+
Hardware: All All
: high normal
Assignee: Oliver Specht (CIB)
URL:
Whiteboard: target:24.8.0 target:25.2.0
Keywords: bibisected, bisected, regression
: 161403 (view as bug list)
Depends on:
Blocks: Writer-Tables-Formulas
  Show dependency treegraph
 
Reported: 2024-01-04 20:08 UTC by William Friedman
Modified: 2024-09-05 09:30 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Requested attachment (11.32 KB, application/vnd.oasis.opendocument.text)
2024-01-05 17:46 UTC, William Friedman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description William Friedman 2024-01-04 20:08:45 UTC
Description:
If a Writer table splits over multiple pages, and a cell is merged that crosses the page boundary, a formula in the merged cell that involves cells not on the current page only calculates using the cells on the same page as the merged cell.

Steps to Reproduce:
1. Insert a new line. (Not part of the bug, just helps demonstrate it later on.)
2. Create a table with 2 columns and 100 rows.
3. Insert the number 1 into every cell of the first column.
4. Merge all of the cells in the second column into a single cell (e.g., select the entire column and hit F4 or right-click | Merge cells).
5. In the merged cell, insert the formula =SUM(<A1:A100>).
6. Notice that 50 is displayed.
7. Above the table, insert another new line (i.e., force another row to the following page).
8. Recalculate the table. Notice that 49 is displayed.

Actual Results:
Only the cells on the current page are included in the calculation.

Expected Results:
All cells in the specified range should be included in the calculation.


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 4; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded
Comment 1 m_a_riosv 2024-01-05 01:01:37 UTC
Please attach a sample file.
Comment 2 William Friedman 2024-01-05 17:46:42 UTC
Created attachment 191781 [details]
Requested attachment

Here is the requested attachment. I generated it following precisely the instructions I provided in the bug report, in case anyone wishes to reproduce it from scratch. The bug is obvious from when the document is opened, and can be seen by inserting additional new lines above the table and recalculating the table.
Comment 3 m_a_riosv 2024-01-05 22:35:31 UTC
The sum uses only two rows of the next page.

Reproducible:
Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 16; OS: Windows 10.0 Build 22631; UI render: Skia/Raster; VCL: win
Locale: es-ES (es_ES); UI: en-US
Calc: CL threaded
Also with
Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 5056da285da2f130d741add1f8432cd590116a96
CPU threads: 16; OS: Windows 10.0 Build 22631; UI render: default; VCL: win
Locale: es-ES (es_ES); UI: en-US
Calc: CL threaded

Hi @Miklos, could be in relation with your work on floating tables?
Comment 4 Stéphane Guillou (stragu) 2024-01-05 22:42:12 UTC
Reproduced with sample document, starting at step 7, in recent trunk build:

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 5056da285da2f130d741add1f8432cd590116a96
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

...and in 7.3.7.2 as well.

In 7.2.0.4, value would go to the correct 100 when using Tools > Update > Update all.

Bibisected with linux-64-7.3 repository to first bad build [4a2fbf050faa2e4417e2067dad096613b4ac8c94] which points to:

commit 01807ad5e04966abeb396b7599cbbbf822de6a03
author	Luboš Luňák 	Fri Oct 01 12:30:15 2021 +0200
committer	Luboš Luňák 	Sat Oct 02 00:36:00 2021 +0200
fix SwRect::Union() with empty SwRect
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122914

Luboš is not active anymore, so increasing the priority.
Comment 5 Commit Notification 2024-05-10 09:06:28 UTC
Oliver Specht committed a patch related to this issue.
It has been pushed to "master":

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

tdf#159027: Fix calculation in tables with merged cells

It will be available in 24.8.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 6 Stéphane Guillou (stragu) 2024-05-14 07:52:06 UTC
Thanks Oliver, much appreciated. Verified in own build with patch.
Comment 7 Stéphane Guillou (stragu) 2024-06-08 12:02:04 UTC
*** Bug 161403 has been marked as a duplicate of this bug. ***
Comment 8 Commit Notification 2024-09-05 09:30:19 UTC
Oliver Specht committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/497d328042b18853c5236e95a0f38a4ab733688c

tdf#159027 test added

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