https://bugs.documentfoundation.org/show_bug.cgi?id=174049

            Bug ID: 174049
           Summary: FILEOPEN DOCX: page break right before a w:altChunk is
                    applied after the chunk content
           Product: LibreOffice
           Version: 26.8.0.3 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Keywords: filter:docx
          Severity: normal
          Priority: medium
         Component: Writer
          Assignee: [email protected]
          Reporter: [email protected]
            Blocks: 104520, 108519, 140202

Created attachment 209178
  --> https://bugs.documentfoundation.org/attachment.cgi?id=209178&action=edit
altchunk-after-page-break.docx: page break paragraph, then an altChunk

A page break in the paragraph right before a w:altChunk is applied after the
content of the chunk, not before it. The chunk content stays on the previous
page.

Steps to reproduce:
1. Open the attached altchunk-after-page-break.docx. The body is: a paragraph
"V1 before", a paragraph with only <w:br w:type="page"/>, then <w:altChunk
r:id="rId7"/> (an inner DOCX with one paragraph "ANNEX-B only paragraph"), then
a paragraph "V1 after".
2. Look at the pages (or export to PDF).

Actual: page 1 has "V1 before" and "ANNEX-B only paragraph". Page 2 has "V1
after".

Expected: page 1 has "V1 before". Page 2 has "ANNEX-B only paragraph" and "V1
after", because the break is before the chunk in the file.

With a normal text paragraph between the break and the chunk, the result is
right. The content of the chunk itself (runs, lists, tables) is imported fine,
only its position after the break is wrong. The same happens with two chunks
when the second one is right after a page break.

The file is made with PHPWord (the altChunk support in
https://github.com/PHPOffice/PHPWord/pull/2958). Word for Mac 16.114 opens it
as expected, the chunk is on page 2 (attached
altchunk-after-page-break-word.pdf, saved as PDF from Word).

In sw/source/writerfilter/dmapper the page break is only deferred
(DomainMapper.cxx, case 0x0c), and without splitPgBreakAndParaMark it is set as
PAGE_BEFORE on the start of the next paragraph.
DomainMapper_Impl::HandleAltChunk() imports the chunk with a new importer that
does not know about this deferred break, so the outer importer puts the break
on the paragraph after the chunk.

The attached altchunk-after-page-break-master.pdf is the output of current
master.

Reproduced on 26.8.0.3 and on master e7cbc3dce071 (2026-10-16), macOS.


Referenced Bugs:

https://bugs.documentfoundation.org/show_bug.cgi?id=104520
[Bug 104520] [META] DOCX (OOXML) bug tracker
https://bugs.documentfoundation.org/show_bug.cgi?id=108519
[Bug 108519] [META] Page break bugs and enhancements
https://bugs.documentfoundation.org/show_bug.cgi?id=140202
[Bug 140202] [META] Issues with files in MS Office formats created by external
producers (not MS Office)
-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to