Bug 158814 - FILEOPEN DOCX RTF Empty header with formatted paragraph and shape appears
Summary: FILEOPEN DOCX RTF Empty header with formatted paragraph and shape appears
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.0.0.5 release
Hardware: All All
: medium normal
Assignee: Miklos Vajna
URL:
Whiteboard: target:24.8.0 target:24.2.1
Keywords: bibisected, bisected, regression
Depends on:
Blocks: DOCX-Header-Footer RTF-Header-Footer
  Show dependency treegraph
 
Reported: 2023-12-21 21:30 UTC by Gabor Kelemen (allotropia)
Modified: 2024-03-22 13:44 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
The example file saved as docx (29.04 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-12-21 21:30 UTC, Gabor Kelemen (allotropia)
Details
The docx example file in Word 2016 and Writer (34.19 KB, image/png)
2023-12-21 21:30 UTC, Gabor Kelemen (allotropia)
Details
Same example in doc format, this is / was always good (55.00 KB, application/msword)
2023-12-21 21:33 UTC, Gabor Kelemen (allotropia)
Details
DOCX exported to PDF by Office 365 (26.72 KB, application/pdf)
2024-01-04 22:17 UTC, Stéphane Guillou (stragu)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2023-12-21 21:30:17 UTC
Created attachment 191550 [details]
The example file saved as docx

attachment 191548 [details] is an RTF file with only a formatted paragraph and drawing shape (line) in the header.
Word hides this, but in Writer it's enabled, changing document layout.
Also happens if the document is converted to docx format.

1. Open attachment 191548 [details] or the attached docx version
-> page header is enabled, showing a line and a lot of spacing between the top of the page and the document body.

Screenshot is attachment 191549 [details]

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 2eb428a8890dda29fbdc8b639fc1377080fab59f
CPU threads: 15; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: en-US
Calc: threaded

This seems to have started in 5.0 (for both docx/rtf), before it was good for both RTF/DOCX. Still good in doc: there the header is not enabled.

https://cgit.freedesktop.org/libreoffice/core/commit/?id=17e51f427b3f0cec74ac8e0a1b3f51189006ae6f

author	Miklos Vajna <vmiklos@collabora.co.uk>	2014-11-21 17:41:24 +0100
committer	Miklos Vajna <vmiklos@collabora.co.uk>	2014-11-21 18:10:59 +0100
commit 17e51f427b3f0cec74ac8e0a1b3f51189006ae6f (patch)

DOCX import: first page header should always set default headers as well
Comment 1 Gabor Kelemen (allotropia) 2023-12-21 21:30:51 UTC
Created attachment 191551 [details]
The docx example file in Word 2016 and Writer
Comment 2 Gabor Kelemen (allotropia) 2023-12-21 21:33:03 UTC
Created attachment 191552 [details]
Same example in doc format, this is / was always good
Comment 3 Stéphane Guillou (stragu) 2024-01-04 22:16:31 UTC
Confirmed for both DOCX and RTF in recent trunk build:

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

Online Office 365 has no such spacing and line at the top.

But doesn't it make sense that LO shows the header if it has contents?
Export the DOCX to PDF with Office 365 and you get two lines and spacing in both header and footer. I think LO is doing better as a WYSIWYG than MS Office here, so my take is "not a bug".

Miklos, what do you think?
Comment 4 Stéphane Guillou (stragu) 2024-01-04 22:17:06 UTC
Created attachment 191768 [details]
DOCX exported to PDF by Office 365
Comment 5 Stéphane Guillou (stragu) 2024-01-04 22:21:14 UTC
(In reply to Stéphane Guillou (stragu) from comment #4)
> Created attachment 191768 [details]
> DOCX exported to PDF by Office 365
Sorry, I need to clarify: this is the export _after_ expanding the header in the DOCX (but without editing it).
If the document is exported without expanding the header, there are no lines and no extra space.

Still feels like a MS Office bug to me.
Comment 6 Miklos Vajna 2024-01-05 07:47:07 UTC
I think the useful reference for desktop Writer's Word format handling is desktop Word. Seeing that our render differs in attachment 191551 [details] , I would tend to say it's useful to fix our side to match.

And it's indeed annoying that sometimes Office Online 365 itself differs from desktop Word, but that's their problem. :-)
Comment 7 Gabor Kelemen (allotropia) 2024-01-08 15:15:38 UTC
(In reply to Stéphane Guillou (stragu) from comment #3)
> But doesn't it make sense that LO shows the header if it has contents?

No, because MS is cheating all over the place (not rendering what's written into the XML or even into OOXML standard), and if we don't copy such cheats, documents will fall apart and the user experience will be: "LO sucks".

Setting New per comment #6.
Comment 8 Commit Notification 2024-02-05 11:37:20 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

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

tdf#158814 DOCX import: fix unwanted header with type="first" & no titlePg

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 9 Commit Notification 2024-02-05 13:44:43 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-24-2":

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

tdf#158814 DOCX import: fix unwanted header with type="first" & no titlePg

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