Bug 104254 - FILEOPEN DOCX image in header overlaps header text in compat15 mode
Summary: FILEOPEN DOCX image in header overlaps header text in compat15 mode
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.3.0.4 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:docx
: 135940 (view as bug list)
Depends on:
Blocks: DOCX-Images DOCX-Header-Footer DOCX-compatibilityMode-15 143793
  Show dependency treegraph
 
Reported: 2016-11-29 12:52 UTC by Gabor Kelemen (allotropia)
Modified: 2022-02-28 14:40 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
Image in the header (30.30 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2016-11-29 12:52 UTC, Gabor Kelemen (allotropia)
Details
The file opened in Word 2013 and LO 5.4.1 side by side (174.06 KB, image/png)
2016-11-29 12:54 UTC, Gabor Kelemen (allotropia)
Details
Simplified example file from Word (32.53 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2019-11-08 11:38 UTC, NISZ LibreOffice Team
Details
The simplified example file in Word and Writer master (94.93 KB, image/png)
2019-11-08 11:40 UTC, NISZ LibreOffice Team
Details
problem with the suggested patch (133.29 KB, image/png)
2021-05-03 17:15 UTC, László Németh
Details
104254_imageInheaderMinimalc14.docx: comment 6's flle, but at compatibilityMode 14 (32.09 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2021-08-02 07:58 UTC, Justin L
Details
patch_104254.diff (11.28 KB, patch)
2021-11-24 10:17 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2016-11-29 12:52:50 UTC
Created attachment 129117 [details]
Image in the header

Attached document has an image in the header and a few lines of text next to it.
When opened in Writer the text gets behind the image making the text unreadable.
Comment 1 Gabor Kelemen (allotropia) 2016-11-29 12:54:19 UTC
Created attachment 129118 [details]
The file opened in Word 2013 and LO 5.4.1 side by side

Screenshot shows LO 5.1, but the same happens with an uptodate master build too.
Comment 2 Xisco Faulí 2016-11-30 01:16:25 UTC
Confirmed in

Version: 5.4.0.0.alpha0+
Build ID: ef0e1c05c32a5a69502e0f0d1d97789c125345a2
CPU Threads: 4; OS Version: Linux 4.8; UI Render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group

- Version: 4.5.0.0.alpha0+
Build ID: 2851ce5afd0f37764cbbc2c2a9a63c7adc844311
Locale: ca_ES

-Version: 4.3.0.0.alpha1+
Build ID: c15927f20d4727c3b8de68497b6949e72f9e6e9e
Comment 3 QA Administrators 2017-12-08 08:07:50 UTC Comment hidden (obsolete)
Comment 4 Gabor Kelemen (allotropia) 2017-12-09 19:51:01 UTC
Still present in 
q8p26‖Version: 6.1.0.0.alpha0+
XZmEs‖Build ID: 7886de305809e265cd2126d39912147131d3a004
Dk4vc‖CPU threads: 4; 5DyEd‖OS: Linux 4.4; Yqrwo‖UI render: ZitRE‖default; VCL: gtk2; 
Ru2AA‖Locale: hu-HU (hu_HU.UTF-8); Calc: group threaded
Comment 5 QA Administrators 2019-11-08 03:38:58 UTC Comment hidden (obsolete)
Comment 6 NISZ LibreOffice Team 2019-11-08 11:38:39 UTC
Created attachment 155631 [details]
Simplified example file from Word
Comment 7 NISZ LibreOffice Team 2019-11-08 11:40:27 UTC
Created attachment 155632 [details]
The simplified example file in Word and Writer master

Simplified file shows that the problem is specific to the header, as the same content appears correctly in the document body.

Version: 6.4.0.0.alpha1+ (x86)
Build ID: 80109586e6cb6d3e2e0a53a9079c3125ec9b8368
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: default; VCL: win; 
Locale: hu-HU (hu_HU); UI-Language: en-US
Calc: CL
Comment 8 László Németh 2021-05-03 17:15:33 UTC
Created attachment 171616 [details]
problem with the suggested patch

regression with the suggested patch of https://gerrit.libreoffice.org/c/core/+/113098 using the test document of https://bz.apache.org/ooo/show_bug.cgi?id=13832

Patch:


diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index a5fb1f6..ca040b5 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -843,7 +843,7 @@
     const bool bAllowCompatWrap = m_pCurrFrame->IsInTab() && (bFooterHeader || m_pCurrFrame->IsInFootnote());
     const bool bWrapAllowed = ( pIDSA->get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING) ||
                                     bAllowCompatWrap ||
-                                    (!m_pCurrFrame->IsInFootnote() && !bFooterHeader));
+                                    !m_pCurrFrame->IsInFootnote() );
 
     m_bOn = false;
Comment 9 Commit Notification 2021-05-21 06:01:06 UTC
Daniel Arato (NISZ) committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/798b69087119c01a3b51e0bb3240ef35cfededeb

tdf#104254 sw DOCX import: fix text wrapping in headers

It will be available in 7.2.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 10 NISZ LibreOffice Team 2021-06-08 05:31:37 UTC
Verified in: 
Version: 7.2.0.0.alpha1+ (x64) / LibreOffice Community
Build ID: 3b57ebb445df8a2bc3d916ea79f8af45e20e4e62
CPU threads: 4; OS: Windows 10.0 Build 17134; UI render: default; VCL: win
Locale: hu-HU (hu_HU); UI: hu-HU
Calc: threaded
Comment 11 Timur 2021-06-09 09:45:32 UTC
As seen in bug 80392, this fixed original 66 pages file MSO 14 attachment 115772 [details] DOCX. 
It didn't fix shorter 3 page reproducer MSO 15 attachment 131068 [details] DOCX.
Comment 12 NISZ LibreOffice Team 2021-07-16 08:13:42 UTC
*** Bug 135940 has been marked as a duplicate of this bug. ***
Comment 13 Justin L 2021-08-02 07:58:17 UTC
Created attachment 174021 [details]
104254_imageInheaderMinimalc14.docx: comment 6's flle, but at compatibilityMode 14

I'm very surprised that comment 9's patch has not triggered all kinds of regression reports already. I would recommend reverting it, and trying to redo the fix for 7.3.

It is VERY intentional that headers/footers are explicitly excluded from considering wrapping. That should be fairly obvious from the code context. There is already a compat flag to turn on "old behaviour" that allows wrapping in these situations. (for example, see the commit memesage in https://cgit.freedesktop.org/libreoffice/core/commit/?id=e4635544b816d1ca27bd1ebba60f51444b0a898e)

It looks like DOCX 2013 did a major reversal in how it handles wrapping in headers. Changing the compatibilityMode from 15 to 14 causes a very different layout in Word - which LibreOffice matched by ignoring the wrapping. So any fix here MUST take into consideration the compatibility level. (P.S. When saving to DOC format, that also ignores the wrapping.)
Comment 14 Commit Notification 2021-08-04 04:05:08 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

Revert "tdf#104254 sw DOCX import: fix text wrapping in headers"

It will be available in 7.3.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 15 Justin L 2021-08-04 04:08:22 UTC
Patch reverted since it overturns an old decision to act like MS formats - when the USE_FORMER_TEXT_WRAPPING compat flag was introduced. This affects ALL formats, including ODT, not just DOCX.
Comment 16 Commit Notification 2021-08-09 13:38:05 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

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

Revert "tdf#104254 sw DOCX import: fix text wrapping in headers"

It will be available in 7.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.
Comment 17 Commit Notification 2021-08-10 17:31:35 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-7-2-0":

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

Revert "tdf#104254 sw DOCX import: fix text wrapping in headers"

It will be available in 7.2.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 18 Justin L 2021-08-31 11:01:32 UTC
bug 143793 has a lot of comments relevant to this issue.
-LO "native" handling was changed to match MS Word. So do we change again to be compatible with only modern DOCX?
-attachment 174179 [details] UseFormerTextWrapping.odt attempts to show the relevant situations.
Comment 19 Justin L 2021-08-31 11:20:06 UTC
I'd say this depends on bug 143793 being solved first. The two are completely intertwined, and solving one will effectively solve the other, but that report is more generic and broader in scope, and better documented, so best to deal with it first.
Comment 20 Justin L 2021-11-09 17:27:20 UTC
I might consider proposing http://gerrit.libreoffice.org/c/core/+/124931 for LO 7.4. However, the test documents I'm playing with act strangely and easily enter into either long loading/layout loops or perhaps even loop infinitely. So any changes here can easily throw our horrible layout code into a funk.
Comment 21 Timur 2021-11-09 18:27:47 UTC
Justin, please consider adding to https://wiki.documentfoundation.org/Development/Budget2022. 
IIUC, seems like a complex issue that's hardly solvable with single patches. 
I don't know what's accepted, but frequent problems should be there IMO.
Comment 22 Justin L 2021-11-24 10:17:56 UTC
Created attachment 176461 [details]
patch_104254.diff

Abandoning my proposal, but archiving the suggestion here.

The patch itself is fine, but the layout code in general is too fragile. So it exposes a lot of situations that layout hasn't had to deal with before and so will easily lock up or loop, and I don't have the skills to deal with that kind of fallout.