Bug 152885 - FILEOPEN RTF Page break and section break result in extra paragraph
Summary: FILEOPEN RTF Page break and section break result in extra paragraph
Status: RESOLVED DUPLICATE of bug 158586
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.3.0.3 release
Hardware: All All
: medium normal
Assignee: Michael Stahl (allotropia)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: RTF
  Show dependency treegraph
 
Reported: 2023-01-05 00:19 UTC by Gabor Kelemen (allotropia)
Modified: 2024-02-15 13:51 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file from Word 2016 (deleted)
2023-01-05 00:19 UTC, Gabor Kelemen (allotropia)
Details
The example file in Word 2016 and Writer (70.18 KB, image/png)
2023-01-05 00:19 UTC, Gabor Kelemen (allotropia)
Details
The example file saved as docx by Word (42.21 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-01-05 00:21 UTC, Gabor Kelemen (allotropia)
Details
Updated example file (114.56 KB, application/rtf)
2023-11-28 13:58 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2023-01-05 00:19:32 UTC
Created attachment 184488 [details]
Example file from Word 2016

Attached RTF example file contains a page break and a continous section break after each other.
In Word this results in a two pages document, with a paragraph at the very top of the second page.
In Writer the document is two pages and there is an extra empty paragraph at the very top of the second page, changing page layout.

1. Open attached file in Writer
2. Notice there is an empty paragraph before "Second page".

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 44355a90b3450111ad87ad4b6607a564e41d7b54
CPU threads: 14; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: de-DE (hu_HU); UI: en-US
Calc: threaded

Works like this since 5.3, before this commit it was worse (there was an extra empty page):

https://git.libreoffice.org/core/+/50bf96d31ab2eb546f6c71cc93c1fa5dd4bf3044

author	Justin Luth <justin_luth@sil.org>	Sat Jun 25 22:21:08 2016 +0300
committer	Miklos Vajna <vmiklos@collabora.co.uk>	Wed Jun 29 07:35:54 2016 +0000

tdf#90697 docx - don't change continuous break into page break

Before that in 4.3 there were 2 pages but an extra empty paragraph before the page break, so not exactly good either.

If the example file is saved as docx, it is displayed correctly in Writer since 6.0 commit:

https://git.libreoffice.org/core/+/cee02e81cd3b55fb46eacf5db5713e8bf4363bcd%5E%21/#F5

author	Justin Luth <justin_luth@sil.org>	Tue Apr 11 21:01:45 2017 +0300
committer	Justin Luth <justin_luth@sil.org>	Fri May 19 13:31:27 2017 +0200

ooxmlexport: roundtrip tdf#103975's unit tests
Comment 1 Gabor Kelemen (allotropia) 2023-01-05 00:19:56 UTC
Created attachment 184489 [details]
The example file in Word 2016 and Writer
Comment 2 Gabor Kelemen (allotropia) 2023-01-05 00:21:23 UTC
Created attachment 184490 [details]
The example file saved as docx by Word
Comment 3 Dieter 2023-01-24 20:06:17 UTC
I confirm it with

Version: 7.5.0.2 (X86_64) / LibreOffice Community
Build ID: c0dd1bc3f1a385d110b88e26ece634da94921f58
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: CL threaded
Comment 4 Gabor Kelemen (allotropia) 2023-11-28 13:58:27 UTC
Created attachment 191090 [details]
Updated example file
Comment 5 Xisco Faulí 2023-11-29 13:20:32 UTC
The content of attachment 184488 [details] has been deleted for the following reason:

User's request
Comment 6 Michael Stahl (allotropia) 2024-02-15 13:51:03 UTC
not sure if this can be called a duplicate of a bug that was a recent regression;
in any case this was fixed by:

commit 17e2c7226a73675d69febf0915aaeae61ad8e9f1
Author:     Michael Stahl <michael.stahl@allotropia.de>
AuthorDate: Wed Jan 31 14:33:46 2024 +0100
Commit:     Michael Stahl <michael.stahl@allotropia.de>
CommitDate: Wed Jan 31 18:58:56 2024 +0100

    tdf#158586 writerfilter: RTF import: fix \page \sect \skbnone w/ header
    
    The problem was not fixed yet for the less-minimized bugzilla attachment
    where the sections contain headers and footers.
    
    What happened there is that first \page caused a deferred page break,
    then \sect and sectBreak() delayed-read the header substream and the
    \par in the header resets all the deferred break flags.
    
    Add the deferred break to an already existing Context class, and remove
    the direct members in DomainMapper_Impl in favor of always using the
    m_StreamStateStack.
    
    Probably this problem cannot occur for DOCX import, because it imports
    header/footer eagerly where the reference element is, and sectPr is
    before any runs that contain breaks in the same paragraph element.
    
    Change-Id: Iba971955e9cf0c398d416518e72d99307d3e1cfd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162833
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>

*** This bug has been marked as a duplicate of bug 158586 ***