Bug 164748 - FILEOPEN DOCX: copied even/odd page style missing header properties - dynamic height etc.
Summary: FILEOPEN DOCX: copied even/odd page style missing header properties - dynamic...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.4 all versions
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:25.8.0
Keywords: bibisected, bisected, filter:docx
Depends on:
Blocks: Writer-Styles-Page-Odd-Even
  Show dependency treegraph
 
Reported: 2025-01-17 15:38 UTC by Justin L
Modified: 2025-01-18 00:32 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
bnc519228_odd-breaksB.docx: unit test from sw/qa/core/header_footer (13.35 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-01-17 15:38 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2025-01-17 15:38:50 UTC
Created attachment 198597 [details]
bnc519228_odd-breaksB.docx: unit test from sw/qa/core/header_footer

When a DOCX/RTF file with alternating even/odd sections is loaded, the process creating the style fails to copy over some of the header/footer properties. This can be seen by the lack of header spacing provided to the odd pages in the unit test submitted during the initial implementation in LO 4.4

commit b32881b6723072c8d1a652ea147d12e75766d504
Author: Luboš Luňák on Sun Aug 17 21:35:48 2014 +0200
    fix reading even/odd page breaks from .docx (bnc#519228)

Steps to reproduce:
1.) open bnc519228_odd-breaksB.docx

Notice the difference in the headers on page 1 and page 2. On page 1 (Converted1 page style), there is no space underneath the header - the body text starts immediately. On page 2 (Default Page style) the header is half an inch tall.

Going into the header properties, we see significant differences (from what was supposed to be a "copied" style).
Converted1 : spacing = 0; use dynamic spacing = false; Height = 0.5cm (defaults)
Default PS : spacing = 1.19cm, use dynamic spacing = true; Height = 0.10cm 

The problem is that the header has not yet been turned on when those properties attempt to be copied over - so they were just ignored.

Bug found by Collabora's mso-test.

-------------- code analysis ---------------

sw/source/writerfilter/dmapper/PropertyMap.cxx's CloseSectionGroup()
- createPageStyle
- copy (except staticDenyList) properties of current page style to new
- sets the FollowStyle to the current name
- *** inserts the new style into LO page styles ***
- completeCopyHeaderFooter (which turns on H/F and first/left/right settings)

There is something special that must happen when activating the page style by inserting it into the list of usable styles. (Perhaps it is impossible to actually turn on the H/F until that happens?)
Comment 1 Justin L 2025-01-17 15:42:26 UTC
A sloppy "just make it work" patch at https://gerrit.libreoffice.org/c/core/+/180417
Comment 2 Justin L 2025-01-17 15:52:12 UTC
(In reply to Justin L from comment #0)
> sw/source/writerfilter/dmapper/PropertyMap.cxx's CloseSectionGroup()
Oops: SectionPropertyMap::CreateEvenOddPageStyleCopy()
Comment 3 Commit Notification 2025-01-17 23:34:00 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/23a73756211eb198c2e6e46975d564c6274165a2

tdf#164748 writerfilter: fix missing even/odd header properties

It will be available in 25.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 4 Justin L 2025-01-18 00:32:05 UTC
(In reply to Justin L from comment #1)
> A sloppy "just make it work" patch 
I fixed it so it isn't sloppy any more.