Bug 57155 - FILEOPEN Wrapped objects in linked headers/footers not shown in DOCX
Summary: FILEOPEN Wrapped objects in linked headers/footers not shown in DOCX
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.1.0
Keywords: filter:docx
Depends on:
Blocks: DOCX-Header-Footer
  Show dependency treegraph
 
Reported: 2012-11-15 13:51 UTC by jpxsat
Modified: 2020-09-15 13:12 UTC (History)
11 users (show)

See Also:
Crash report or crash signature:


Attachments
DOCX - How it should be seen (1.21 MB, application/pdf)
2012-11-15 13:51 UTC, jpxsat
Details
DOCX file (2.92 MB, application/zip)
2012-11-15 14:05 UTC, jpxsat
Details
Stripped Down Bug Doc Showing Header Issue (75.44 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2016-12-07 09:58 UTC, Luke
Details
Another sample DOCX (18.89 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-06-18 04:29 UTC, Aron Budea
Details
DOCX - 1st page compared (184.61 KB, image/png)
2020-09-15 09:12 UTC, Timur
Details
DOCX resaved in MSO (3.28 MB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-09-15 09:13 UTC, Timur
Details
DOCX resaved in MSO - 1st page compared (125.04 KB, image/png)
2020-09-15 09:17 UTC, Timur
Details
DOC saved in MSO from DOCX (4.13 MB, application/msword)
2020-09-15 09:22 UTC, Timur
Details
DOC saved in MSO from DOCX - 1st page compared (127.66 KB, image/png)
2020-09-15 09:23 UTC, Timur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jpxsat 2012-11-15 13:51:33 UTC
Created attachment 70116 [details]
DOCX - How it should be seen

A friend send me a .docx created with office 2007.
I had to ask to a friend to send me the file in PDF to see it right...
The things are not in order and not even on the same page...
I'm joining both files here...
Comment 1 jpxsat 2012-11-15 14:05:00 UTC
Created attachment 70118 [details]
DOCX file
Comment 2 s-joyemusequna 2012-12-18 13:15:43 UTC Comment hidden (obsolete)
Comment 3 s-joyemusequna 2012-12-18 13:40:17 UTC Comment hidden (obsolete)
Comment 4 Joel Madero 2015-05-02 15:44:28 UTC Comment hidden (obsolete)
Comment 5 Buovjaga 2015-06-21 13:45:46 UTC Comment hidden (obsolete)
Comment 6 QA Administrators 2016-09-20 10:12:00 UTC Comment hidden (obsolete)
Comment 7 Luke 2016-12-07 09:54:07 UTC
These multi-issue bug reports need to be broken down into single issues. There are 3 issues I see here

1) Headers set to all pages but only displayed on First
2) Text Boxes and Pictures shifted down on several pages

Let's track all the layout and picture/textbox issues of 2) in separate reports.
Comment 8 Luke 2016-12-07 09:58:10 UTC
Created attachment 129364 [details]
Stripped Down Bug Doc Showing Header Issue

Header should be shown on all pages but Writer only shows on first page.
Comment 9 Xisco Faulí 2017-09-19 10:46:30 UTC Comment hidden (obsolete)
Comment 10 Luke 2018-02-26 00:34:13 UTC Comment hidden (obsolete)
Comment 11 Timur 2018-02-26 09:39:13 UTC
Section 2 content with Link to Previous is not shown. 
If Link to Previous is turned off in MSO, it is.
Comment 12 Aron Budea 2018-06-18 04:29:06 UTC
Created attachment 142833 [details]
Another sample DOCX

(In reply to Timur from comment #11)
> Section 2 content with Link to Previous is not shown. 
> If Link to Previous is turned off in MSO, it is.
Only shapes/graphical content, and only if text wrapping is enabled.
Attaching another sample with a bit of text included, the header has wrapping set to Square, the footer is set to In Line With Text.
Comment 13 Xisco Faulí 2019-09-03 15:31:45 UTC Comment hidden (obsolete)
Comment 14 Xisco Faulí 2019-09-03 15:53:55 UTC
(In reply to Xisco Faulí from comment #13)
> (In reply to Aron Budea from comment #12)
> > Created attachment 142833 [details]
> > Another sample DOCX
> > 
> > (In reply to Timur from comment #11)
> > > Section 2 content with Link to Previous is not shown. 
> > > If Link to Previous is turned off in MSO, it is.
> > Only shapes/graphical content, and only if text wrapping is enabled.
> > Attaching another sample with a bit of text included, the header has
> > wrapping set to Square, the footer is set to In Line With Text.
> 
> Hi Aron,
> The problem with that specific document is no longer reproduced in
> 
> Version: 6.4.0.0.alpha0+
> Build ID: 41cd3e8e817c8c33a13608e62eeb06ce2c6977e4
> CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
> Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US
> Calc: threaded
> 
> bisecting it to find when it got fixed could help with the document
> submitted by Luke

it got fixed in https://cgit.freedesktop.org/libreoffice/core/commit/?id=28b77c89dfcafae82cf2a6d85731b643ff9290e5
@Michael Stahl, since you commit fixed one of the problematic files in this issue, I thought you might be interested in this one...
Comment 15 Justin L 2020-07-21 11:09:54 UTC
The problem of the header graphic not showing up on page 2 is fixed in 7.0 (and 6.3.6) by commit 81ec0039b2085faab49380c7a56af0c562d4c9e4
Author: Michael Stahl on Mon Jan 20 13:48:27 2020 +0100

    tdf#129582 sw: fix copying of flys in header/footer in DOCX/RTF import
    
    The problem is that the exception for writerfilter in
    IsDestroyFrameAnchoredAtChar() and IsSelectFrameAnchoredAtPara() is
    wrong in the case when the header/footer content is copied via
    SwXText::copyText(); that is, previously the situation was that
    writerfilter relied on Delete not deleting such flys (for
    RemoveLastParagraph) but Copy copying them.
    
    (regression from 28b77c89dfcafae82cf2a6d85731b643ff9290e5
     and e75dd1fc992f168f24d66595265a978071cdd277)
    
    So restrict the writerfilter hack to delete; this causes a problem with
    ooxmlexport9 test testTdf100075: it has 2 flys anchored at the
    same paragraph; writerfilter will insert the content into the body and
    then convert to fly; when the 2nd one is converted it will copy the 1st
    fly and anchor it inside the 2nd fly but then unotext.cxx:1719 will
    reset its anchor to inside the body...
    
    Prevent this unwanted copy by relying on the new parameter bCopyText
    that was introduced in 04b2310aaa094794ceedaa1bb6ff1823a2d29d3e,
    but change things a bit so that the case that pass in the extra flag
    isn't the copyText() one that wants the *normal* selection semantics in
    writerfilter import, but the 2 known places that want the *exceptional*
    selection semantics in writerfilter import (hopefully there aren't more).
    
    This is not ideal and the various bool parameters to CopyRange() plus
    mbCopyIsMove plus mbIsRedlineMove should probably be consolidated
    into some flags enum passed to CopyRange().
Comment 16 Xisco Faulí 2020-07-21 11:57:30 UTC
Hi Justin,
Thanks for the revert bisection.
Since bug 129582 is a regression and this issue is inherit from OOo I've created another unittest for this ticket at https://gerrit.libreoffice.org/c/core/+/99131
Comment 17 Justin L 2020-07-21 13:06:26 UTC
The problem of the image on the first page moving to the following page was fixed in 7.1 commit b216fc5b583050cfb1cdf9bd82ec3c1bd2e09d70
Author: Bakos Attila on Tue Jun 30 15:03:31 2020 +0200
    tdf#118701 DOCX import: fix image position on page break
    
    If an image anchored to an empty paragraph only with
    section properties, don't remove that paragraph to keep
    the image on the page before the page break.
    
    IsLastParaEmpty() tries to move a text cursor over the
    empty paragraph marked for deletion. If it contains an
    image anchored as a character, the cursor won't reach
    the end of the previous paragraph by goLeft(2).
    
    Co-authored-by: Attila Bánhegyi (NISZ)
Comment 18 Commit Notification 2020-07-21 13:42:15 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

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

tdf#57155: sw_ooxmlexport7: Add unittest

It will be available in 7.1.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 19 Timur 2020-09-15 09:12:10 UTC
Created attachment 165512 [details]
DOCX - 1st page compared

This is a messy report. I think we were looking at 1st page. So it's OK now, as seen.
Comment 20 Timur 2020-09-15 09:13:27 UTC
Created attachment 165513 [details]
DOCX resaved in MSO

Original DOCX is older 2007, we need to also test newer DOCX resaved in MSO.
Comment 21 Timur 2020-09-15 09:17:06 UTC
Created attachment 165514 [details]
DOCX resaved in MSO - 1st page compared

DOCX resaved in MSO has all the elements but formatting is not good. 
Surely another bug, question is just if already reported.
Comment 22 Timur 2020-09-15 09:22:53 UTC
Created attachment 165515 [details]
DOC saved in MSO from DOCX

Since this is a complex document, let's see also DOC saved in MSO from DOCX.
Comment 23 Timur 2020-09-15 09:23:37 UTC
Created attachment 165516 [details]
DOC saved in MSO from DOCX - 1st page compared

1st page looks good in LO 7.1+
Comment 24 Timur 2020-09-15 13:12:38 UTC
(In reply to Timur from comment #21)
> Created attachment 165514 [details]
> DOCX resaved in MSO - 1st page compared
> 
> DOCX resaved in MSO has all the elements but formatting is not good. 
> Surely another bug, question is just if already reported.

bug 136772