Bug 115026 - EDITING: LibreOffice ignores page break when adding a table to the second page (& deletes a page in a certain case)
Summary: EDITING: LibreOffice ignores page break when adding a table to the second pag...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.0.0.3 release
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:6.5.0 target:6.4.1
Keywords: bibisected, regression
Depends on:
Blocks: Writer-Tables Writer-Tables-Style
  Show dependency treegraph
 
Reported: 2018-01-15 17:47 UTC by Telesto
Modified: 2020-01-15 09:30 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Bibisect log (2.91 KB, text/plain)
2018-01-15 18:29 UTC, Telesto
Details
Bibisect log (4.92 KB, text/plain)
2018-01-17 09:47 UTC, Telesto
Details
commit that introduce Break table-level property recording (1.44 KB, text/plain)
2018-01-20 05:41 UTC, Jim Raykowski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Telesto 2018-01-15 17:47:01 UTC
Description:
LibreOffice ignores page break when adding a table to the second page

Steps to Reproduce:
1. Open Writer
2. Insert a page break -> CTRL+ENTER
3. Insert a table on the second page -> Second page disappears; table moves to the first

4. Second attempt: Insert some text on the first page. Press CTRL+ENTER.. Try to add a table to the second page. Table will be at the first page

Actual Results:  
Table the the first page

Expected Results:
Table should be added to the second page


Reproducible: Always


User Profile Reset: No



Additional Info:
Found in
Versie: 6.0.0.2
Build ID: 06b618bb6f431d27fd2def25aa19c833e29b61cd
CPU-threads: 4; Besturingssysteem: Windows 6.3; UI-render: GL; 
Locale: nl-NL (nl_NL); Calc: CL


User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
Comment 1 Telesto 2018-01-15 18:29:17 UTC
Created attachment 139115 [details]
Bibisect log

Bisected to:
author	Jim Raykowski <raykowj@gmail.com>	2017-10-31 15:48:07 -0800
committer	Yousuf Philips <philipz85@hotmail.com>	2017-12-27 15:27:50 +0100
commit 203b913155812706e9be14c5fe2b8f543cc4fdc7 (patch)
tree e2233e80cbc67d0bf834d4eb716ff935cebe6d08
parent 023949fac0043408ac1b86dc67732666d041875e (diff)
tdf#107555 Apply 'Default Style' table style to newly inserted tables
Comment 2 Telesto 2018-01-15 18:34:03 UTC
@Jay,
Thought you might be interested in this one
Comment 3 Jacques Guilleron 2018-01-16 17:26:56 UTC
Hi Telesto,

I confirm with
LO  6.0.0.2 Build ID: 06b618bb6f431d27fd2def25aa19c833e29b61cd
Threads CPU : 2; OS : Windows 6.1; UI Render : par défaut; 
Locale : fr-FR (fr_FR); Calc: CL
Worked as excepted with
LO 6.0.0.1 (x64) Build ID: d2bec56d7865f05a1003dc88449f2b0fdd85309a
Threads CPU : 2; OS : Windows 6.1; UI Render : par défaut; 
Locale : fr-FR (fr_FR); Calc: CL
Comment 4 Yousuf Philips (jay) (retired) 2018-01-16 18:38:03 UTC
@Jim,
Seems your apply default table style to inserted table patch has a regression.

https://gerrit.libreoffice.org/#/c/46842/
Comment 5 Jim Raykowski 2018-01-17 02:15:44 UTC
(In reply to Yousuf Philips (jay) from comment #4)
> @Jim,
> Seems your apply default table style to inserted table patch has a
> regression.
> 
> https://gerrit.libreoffice.org/#/c/46842/

Hi Jay,

This behavior can be reproduced in versions before the patch was merged by manually performing what the patch does automatically. (Apply a style to a table)

I have reproduced it in the following two versions:
Version: 5.4.4.2, Build ID: 1:5.4.4~rc2-0ubuntu0.16.04.1~lo1 
and
Version: 6.0.0.0.beta2 (x64) mswindows

Here are the steps to reproduce in pre patched versions:
1. Open a version of Writer without this patch
2. Open Sidebar -> View > Sidebar
3. Click on Styles deck icon
4. Click on Tables Styles icon in Styles Panel
5. Insert a page break -> CTRL+ENTER
6. Insert a table on the second page
7. Double click on any table style in the list box in the Styles Panel

Actual Results: 
Table moves to previous page

Expected Results:
Table should stay on page it was on
Comment 6 Telesto 2018-01-17 09:19:07 UTC
Found in
Versie 4.0.0.3 (Bouw-id: 7545bee9c2a0782548772a21bc84a9dcc583b89)

but not in
LibreOffice 3.5.7.2 
Build ID: 3215f89-f603614-ab984f2-7348103-1225a5

1. Open Writer
2. Insert a page break (CTRL+ENTER)
3. Add a table on the next page
4. Menu Table -> Autoformat styles -> Choose a style and apply

Table moves to previous page
Comment 7 Telesto 2018-01-17 09:47:56 UTC
Created attachment 139143 [details]
Bibisect log

I would suspect the patch for bug 49342...
Comment 8 Jacques Guilleron 2018-01-17 14:04:19 UTC
Confirm the behavior from Comment 6 with
LO 3.6.0.4 (Build ID: 932b512)
and upper versions
but not with
LO 3.5.7.2 Version ID : 3215f89-f603614-ab984f2-7348103-1225a5b
under Windows 7 Home.
Comment 9 Jim Raykowski 2018-01-20 01:12:50 UTC
I have located what seems to be the cause of this bug. 

tblafmt.cxx

void SwTableAutoFormat::RestoreTableProperties(SwTable &table) const
{
    SwTableFormat* pFormat = table.GetFrameFormat();
    if (!pFormat)
        return;

    SwDoc *pDoc = pFormat->GetDoc();
    if (!pDoc)
        return;

    SfxItemSet rSet(pDoc->GetAttrPool(), aTableSetRange);

//    rSet.Put(m_aBreak);  <<<<< comment this line

When this line of code is removed a table inserted at the start of a new page behaves as expected. I don't really understand why. My knowledge of itemsets and pools and ranges is not strong.
Comment 10 Jim Raykowski 2018-01-20 05:41:05 UTC
Created attachment 139232 [details]
commit that introduce Break table-level property recording

Here may be where this behavior began.
Comment 11 Telesto 2018-05-04 16:23:34 UTC
Repro with:
Version: 6.1.0.0.alpha0+
Build ID: 2ed7c02478968852d7d39c2c4677f2ecf3441bc7
CPU threads: 4; OS: Windows 6.3; UI render: GL; 
TinderBox: Win-x86@42, Branch:master, Time: 2018-04-22_01:00:56
Locale: nl-NL (nl_NL); Calc: CL
Comment 12 Telesto 2018-07-17 17:41:13 UTC
Repro
Version: 6.2.0.0.alpha0+
Build ID: 8e9d43546c8e46ea635472ddf07f5c183dc13360
CPU threads: 4; OS: Mac OS X 10.12.6; UI render: default; 
TinderBox: MacOSX-x86_64@49-TDF, Branch:master, Time: 2018-07-11_23:34:15
Locale: nl-NL (nl_NL.UTF-8); Calc: group threaded

STR
1. Open Writer
2. Insert a page break -> CTRL+ENTER
3. Insert a table with a table style applied (non-default)
Comment 13 Jim Raykowski 2018-07-18 06:47:39 UTC
This is related to the table properties text flow:

Table > Properties... > Text Flow tab > Break checkbox and break type radio buttons.

One way we can can work around this case is by not setting the break here [1] if it is SvxBreak::NONE.  

[1] https://opengrok.libreoffice.org/xref/core/sw/source/core/doc/tblafmt.cxx#906
Comment 14 QA Administrators 2019-07-19 02:53:26 UTC Comment hidden (obsolete, spam)
Comment 15 Justin L 2019-11-27 12:08:49 UTC
(In reply to Jim Raykowski from comment #13)
> One way we can can work around this case is by not setting the break here
> [1] if it is SvxBreak::NONE.  

Exactly.  https://gerrit.libreoffice.org/#/c/83879
Comment 16 Commit Notification 2019-12-20 09:54:23 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/43f983d08d66520536980339f33ef44d5eec35f6

tdf#115026 sw tableAutoFormat: don't clear break/keep

It will be available in 6.5.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 17 Xisco Faulí 2020-01-09 13:14:28 UTC
(In reply to Telesto from comment #12)
> Repro
> Version: 6.2.0.0.alpha0+
> Build ID: 8e9d43546c8e46ea635472ddf07f5c183dc13360
> CPU threads: 4; OS: Mac OS X 10.12.6; UI render: default; 
> TinderBox: MacOSX-x86_64@49-TDF, Branch:master, Time: 2018-07-11_23:34:15
> Locale: nl-NL (nl_NL.UTF-8); Calc: group threaded
> 
> STR
> 1. Open Writer
> 2. Insert a page break -> CTRL+ENTER
> 3. Insert a table with a table style applied (non-default)

Issue verified in

Version: 6.5.0.0.alpha0+
Build ID: 838935758a5ec8e0e68f4df0cf5bfcf737e3f6f2
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

@Justin, thanks for fixing this issue!!
Comment 18 Commit Notification 2020-01-09 13:17:31 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-6-4":

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

tdf#115026 sw tableAutoFormat: don't clear break/keep

It will be available in 6.4.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 2020-01-09 20:10:58 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/43d8dc34d74832e928c2cc215e9bf512f4edf3b3

tdf#115026: Add uitest

It will be available in 6.5.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 20 Commit Notification 2020-01-10 10:25:14 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "libreoffice-6-4":

https://git.libreoffice.org/core/commit/822bbe6984a642ea3c09ca8a337499655cd54173

tdf#115026: Add uitest

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